@radix-ui/react-radio-group 1.4.2 → 1.4.3-rc.1783030075339
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +15 -1
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +15 -1
- package/dist/index.mjs.map +3 -3
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -46,6 +46,7 @@ type ScopedProps<P> = P & {
|
|
|
46
46
|
declare const createRadioGroupScope: _radix_ui_react_context.CreateScope;
|
|
47
47
|
type RadioGroupContextValue = {
|
|
48
48
|
name?: string;
|
|
49
|
+
form?: string;
|
|
49
50
|
required: boolean;
|
|
50
51
|
disabled: boolean;
|
|
51
52
|
value: string | null;
|
|
@@ -55,6 +56,7 @@ type RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGr
|
|
|
55
56
|
type PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
56
57
|
interface RadioGroupProps extends PrimitiveDivProps {
|
|
57
58
|
name?: RadioGroupContextValue['name'];
|
|
59
|
+
form?: React.ComponentPropsWithoutRef<typeof Radio>['form'];
|
|
58
60
|
required?: React.ComponentPropsWithoutRef<typeof Radio>['required'];
|
|
59
61
|
disabled?: React.ComponentPropsWithoutRef<typeof Radio>['disabled'];
|
|
60
62
|
dir?: RovingFocusGroupProps['dir'];
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ type ScopedProps<P> = P & {
|
|
|
46
46
|
declare const createRadioGroupScope: _radix_ui_react_context.CreateScope;
|
|
47
47
|
type RadioGroupContextValue = {
|
|
48
48
|
name?: string;
|
|
49
|
+
form?: string;
|
|
49
50
|
required: boolean;
|
|
50
51
|
disabled: boolean;
|
|
51
52
|
value: string | null;
|
|
@@ -55,6 +56,7 @@ type RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGr
|
|
|
55
56
|
type PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
56
57
|
interface RadioGroupProps extends PrimitiveDivProps {
|
|
57
58
|
name?: RadioGroupContextValue['name'];
|
|
59
|
+
form?: React.ComponentPropsWithoutRef<typeof Radio>['form'];
|
|
58
60
|
required?: React.ComponentPropsWithoutRef<typeof Radio>['required'];
|
|
59
61
|
disabled?: React.ComponentPropsWithoutRef<typeof Radio>['disabled'];
|
|
60
62
|
dir?: RovingFocusGroupProps['dir'];
|
package/dist/index.js
CHANGED
|
@@ -288,6 +288,7 @@ var RadioGroup = React2.forwardRef(
|
|
|
288
288
|
const {
|
|
289
289
|
__scopeRadioGroup,
|
|
290
290
|
name,
|
|
291
|
+
form,
|
|
291
292
|
defaultValue,
|
|
292
293
|
value: valueProp,
|
|
293
294
|
required = false,
|
|
@@ -306,11 +307,23 @@ var RadioGroup = React2.forwardRef(
|
|
|
306
307
|
onChange: onValueChange,
|
|
307
308
|
caller: RADIO_GROUP_NAME
|
|
308
309
|
});
|
|
310
|
+
const [control, setControl] = React2.useState(null);
|
|
311
|
+
const composedRefs = (0, import_react_compose_refs2.useComposedRefs)(forwardedRef, setControl);
|
|
312
|
+
const initialValueRef = React2.useRef(value);
|
|
313
|
+
React2.useEffect(() => {
|
|
314
|
+
const associatedForm = form ? control?.ownerDocument.getElementById(form) : control?.closest("form");
|
|
315
|
+
if (associatedForm instanceof HTMLFormElement) {
|
|
316
|
+
const reset = () => setValue(initialValueRef.current);
|
|
317
|
+
associatedForm.addEventListener("reset", reset);
|
|
318
|
+
return () => associatedForm.removeEventListener("reset", reset);
|
|
319
|
+
}
|
|
320
|
+
}, [control, form, setValue]);
|
|
309
321
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
310
322
|
RadioGroupProvider,
|
|
311
323
|
{
|
|
312
324
|
scope: __scopeRadioGroup,
|
|
313
325
|
name,
|
|
326
|
+
form,
|
|
314
327
|
required,
|
|
315
328
|
disabled,
|
|
316
329
|
value,
|
|
@@ -332,7 +345,7 @@ var RadioGroup = React2.forwardRef(
|
|
|
332
345
|
"data-disabled": disabled ? "" : void 0,
|
|
333
346
|
dir: direction,
|
|
334
347
|
...groupProps,
|
|
335
|
-
ref:
|
|
348
|
+
ref: composedRefs
|
|
336
349
|
}
|
|
337
350
|
)
|
|
338
351
|
}
|
|
@@ -366,6 +379,7 @@ function RadioGroupItemProvider(props) {
|
|
|
366
379
|
disabled: isDisabled,
|
|
367
380
|
required: context.required,
|
|
368
381
|
name: context.name,
|
|
382
|
+
form: context.form,
|
|
369
383
|
value,
|
|
370
384
|
onCheck: () => context.onValueChange(value),
|
|
371
385
|
internal_do_not_use_render,
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/radio-group.tsx", "../src/radio.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupItemProvider as unstable_RadioGroupItemProvider,\n RadioGroupItemTrigger as unstable_RadioGroupItemTrigger,\n RadioGroupItemBubbleInput as unstable_RadioGroupItemBubbleInput,\n RadioGroupIndicator,\n //\n Root,\n Item,\n ItemProvider as unstable_ItemProvider,\n ItemTrigger as unstable_ItemTrigger,\n ItemBubbleInput as unstable_ItemBubbleInput,\n Indicator,\n} from './radio-group';\nexport type {\n RadioGroupProps,\n RadioGroupItemProps,\n RadioGroupItemProviderProps as unstable_RadioGroupItemProviderProps,\n RadioGroupItemTriggerProps as unstable_RadioGroupItemTriggerProps,\n RadioGroupItemBubbleInputProps as unstable_RadioGroupItemBubbleInputProps,\n RadioGroupIndicatorProps,\n} from './radio-group';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useDirection } from '@radix-ui/react-direction';\nimport {\n type Radio,\n RadioProvider,\n RadioTrigger,\n RadioBubbleInput,\n RadioIndicator,\n createRadioScope,\n useRadioContext,\n} from './radio';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroup\n * -----------------------------------------------------------------------------------------------*/\nconst RADIO_GROUP_NAME = 'RadioGroup';\n\ntype ScopedProps<P> = P & { __scopeRadioGroup?: Scope };\nconst [createRadioGroupContext, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [\n createRovingFocusGroupScope,\n createRadioScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\nconst useRadioScope = createRadioScope();\n\ntype RadioGroupContextValue = {\n name?: string;\n required: boolean;\n disabled: boolean;\n value: string | null;\n onValueChange(value: string): void;\n};\n\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContext<RadioGroupContextValue>(RADIO_GROUP_NAME);\n\ntype RadioGroupElement = React.ComponentRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface RadioGroupProps extends PrimitiveDivProps {\n name?: RadioGroupContextValue['name'];\n required?: React.ComponentPropsWithoutRef<typeof Radio>['required'];\n disabled?: React.ComponentPropsWithoutRef<typeof Radio>['disabled'];\n dir?: RovingFocusGroupProps['dir'];\n orientation?: RovingFocusGroupProps['orientation'];\n loop?: RovingFocusGroupProps['loop'];\n defaultValue?: string;\n value?: string | null;\n onValueChange?: RadioGroupContextValue['onValueChange'];\n}\n\nconst RadioGroup = React.forwardRef<RadioGroupElement, RadioGroupProps>(\n (props: ScopedProps<RadioGroupProps>, forwardedRef) => {\n const {\n __scopeRadioGroup,\n name,\n defaultValue,\n value: valueProp,\n required = false,\n disabled = false,\n orientation,\n dir,\n loop = true,\n onValueChange,\n ...groupProps\n } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const direction = useDirection(dir);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? null,\n onChange: onValueChange as (value: string | null) => void,\n caller: RADIO_GROUP_NAME,\n });\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n name={name}\n required={required}\n disabled={disabled}\n value={value}\n onValueChange={setValue}\n >\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={orientation}\n dir={direction}\n loop={loop}\n >\n <Primitive.div\n role=\"radiogroup\"\n aria-required={required}\n aria-orientation={orientation}\n data-disabled={disabled ? '' : undefined}\n dir={direction}\n {...groupProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n </RadioGroupProvider>\n );\n },\n);\n\nRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'RadioGroupItem';\nconst ITEM_PROVIDER_NAME = 'RadioGroupItemProvider';\nconst ITEM_TRIGGER_NAME = 'RadioGroupItemTrigger';\nconst ITEM_BUBBLE_INPUT_NAME = 'RadioGroupItemBubbleInput';\n\ninterface RadioGroupItemProviderProps {\n value: string;\n disabled?: boolean;\n children?: React.ReactNode;\n}\n\nfunction RadioGroupItemProvider(props: ScopedProps<RadioGroupItemProviderProps>) {\n const {\n __scopeRadioGroup,\n value,\n disabled,\n children,\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n const context = useRadioGroupContext(ITEM_PROVIDER_NAME, __scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const isDisabled = context.disabled || disabled;\n\n return (\n <RadioProvider\n {...radioScope}\n checked={context.value === value}\n disabled={isDisabled}\n required={context.required}\n name={context.name}\n value={value}\n onCheck={() => context.onValueChange(value)}\n // @ts-expect-error\n internal_do_not_use_render={internal_do_not_use_render}\n >\n {children}\n </RadioProvider>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemTrigger\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemTriggerElement = React.ComponentRef<typeof RadioTrigger>;\ninterface RadioGroupItemTriggerProps extends React.ComponentPropsWithoutRef<typeof RadioTrigger> {}\n\nconst RadioGroupItemTrigger = React.forwardRef<\n RadioGroupItemTriggerElement,\n RadioGroupItemTriggerProps\n>((props: ScopedProps<RadioGroupItemTriggerProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...triggerProps } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const { checked, disabled } = useRadioContext(ITEM_TRIGGER_NAME, radioScope.__scopeRadio);\n const ref = React.useRef<RadioGroupItemTriggerElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const isArrowKeyPressedRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (ARROW_KEYS.includes(event.key)) {\n isArrowKeyPressedRef.current = true;\n }\n };\n const handleKeyUp = () => (isArrowKeyPressedRef.current = false);\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('keyup', handleKeyUp);\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('keyup', handleKeyUp);\n };\n }, []);\n\n return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={checked}\n >\n <RadioTrigger\n {...radioScope}\n {...triggerProps}\n ref={composedRefs}\n onKeyDown={composeEventHandlers(triggerProps.onKeyDown, (event) => {\n // According to WAI ARIA, radio groups don't activate items on enter\n // keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onFocus={composeEventHandlers(triggerProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with\n * arrow keys and we need to \"check\" it in that case. We click it to\n * \"check\" it (instead of updating `context.value`) so that the radio\n * change event fires.\n */\n if (isArrowKeyPressedRef.current) {\n ref.current?.click();\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n});\n\nRadioGroupItemTrigger.displayName = ITEM_TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemElement = React.ComponentRef<typeof Radio>;\ntype RadioProps = React.ComponentPropsWithoutRef<typeof Radio>;\ninterface RadioGroupItemProps extends Omit<RadioProps, 'onCheck' | 'name'> {\n value: string;\n}\n\nconst RadioGroupItem = React.forwardRef<RadioGroupItemElement, RadioGroupItemProps>(\n (props: ScopedProps<RadioGroupItemProps>, forwardedRef) => {\n const { __scopeRadioGroup, value, disabled, ...itemProps } = props;\n\n return (\n <RadioGroupItemProvider\n __scopeRadioGroup={__scopeRadioGroup}\n value={value}\n disabled={disabled}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: { isFormControl: boolean }) => (\n <>\n <RadioGroupItemTrigger\n {...itemProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n {isFormControl && (\n <RadioGroupItemBubbleInput\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\nRadioGroupItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemBubbleInputElement = React.ComponentRef<typeof RadioBubbleInput>;\ninterface RadioGroupItemBubbleInputProps extends React.ComponentPropsWithoutRef<\n typeof RadioBubbleInput\n> {}\n\nconst RadioGroupItemBubbleInput = React.forwardRef<\n RadioGroupItemBubbleInputElement,\n RadioGroupItemBubbleInputProps\n>((props: ScopedProps<RadioGroupItemBubbleInputProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...bubbleProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioBubbleInput {...radioScope} {...bubbleProps} ref={forwardedRef} />;\n});\n\nRadioGroupItemBubbleInput.displayName = ITEM_BUBBLE_INPUT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioGroupIndicator';\n\ntype RadioGroupIndicatorElement = React.ComponentRef<typeof RadioIndicator>;\ntype RadioIndicatorProps = React.ComponentPropsWithoutRef<typeof RadioIndicator>;\ninterface RadioGroupIndicatorProps extends RadioIndicatorProps {}\n\nconst RadioGroupIndicator = React.forwardRef<RadioGroupIndicatorElement, RadioGroupIndicatorProps>(\n (props: ScopedProps<RadioGroupIndicatorProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...indicatorProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioIndicator {...radioScope} {...indicatorProps} ref={forwardedRef} />;\n },\n);\n\nRadioGroupIndicator.displayName = INDICATOR_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupItemProvider,\n RadioGroupItemTrigger,\n RadioGroupItemBubbleInput,\n RadioGroupIndicator,\n //\n RadioGroup as Root,\n RadioGroupItem as Item,\n RadioGroupItemProvider as ItemProvider,\n RadioGroupItemTrigger as ItemTrigger,\n RadioGroupItemBubbleInput as ItemBubbleInput,\n RadioGroupIndicator as Indicator,\n};\nexport type {\n RadioGroupProps,\n RadioGroupItemProps,\n RadioGroupItemProviderProps,\n RadioGroupItemTriggerProps,\n RadioGroupItemBubbleInputProps,\n RadioGroupIndicatorProps,\n};\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst RADIO_NAME = 'Radio';\n\ntype ScopedProps<P> = P & { __scopeRadio?: Scope };\nconst [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);\n\ntype RadioContextValue = {\n checked: boolean;\n disabled: boolean | undefined;\n required: boolean | undefined;\n name: string | undefined;\n form: string | undefined;\n value: string | number | readonly string[];\n control: HTMLButtonElement | null;\n setControl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;\n hasConsumerStoppedPropagationRef: React.RefObject<boolean>;\n isFormControl: boolean;\n bubbleInput: HTMLInputElement | null;\n setBubbleInput: React.Dispatch<React.SetStateAction<HTMLInputElement | null>>;\n onCheck(): void;\n};\n\nconst [RadioProviderImpl, useRadioContext] = createRadioContext<RadioContextValue>(RADIO_NAME);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface RadioProviderProps {\n checked?: boolean;\n required?: boolean;\n disabled?: boolean;\n name?: string;\n form?: string;\n value?: string | number | readonly string[];\n onCheck?(): void;\n children?: React.ReactNode;\n}\n\nfunction RadioProvider(props: ScopedProps<RadioProviderProps>) {\n const {\n __scopeRadio,\n checked = false,\n children,\n disabled,\n form,\n name,\n onCheck,\n required,\n value = 'on',\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n\n const [control, setControl] = React.useState<HTMLButtonElement | null>(null);\n const [bubbleInput, setBubbleInput] = React.useState<HTMLInputElement | null>(null);\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = control\n ? !!form || !!control.closest('form')\n : // We set this to true by default so that events bubble to forms without JS (SSR)\n true;\n\n const context: RadioContextValue = {\n checked,\n disabled,\n required,\n name,\n form,\n value,\n control,\n setControl,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n setBubbleInput,\n onCheck: () => onCheck?.(),\n };\n\n return (\n <RadioProviderImpl scope={__scopeRadio} {...context}>\n {isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children}\n </RadioProviderImpl>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'RadioTrigger';\n\ninterface RadioTriggerProps extends Omit<\n React.ComponentPropsWithoutRef<typeof Primitive.button>,\n keyof RadioProviderProps\n> {\n children?: React.ReactNode;\n}\n\nconst RadioTrigger = React.forwardRef<HTMLButtonElement, RadioTriggerProps>(\n ({ __scopeRadio, onClick, ...radioProps }: ScopedProps<RadioTriggerProps>, forwardedRef) => {\n const {\n checked,\n disabled,\n value,\n setControl,\n onCheck,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n } = useRadioContext(TRIGGER_NAME, __scopeRadio);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n return (\n <Primitive.button\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...radioProps}\n ref={composedRefs}\n onClick={composeEventHandlers(onClick, (event) => {\n // radios cannot be unchecked so we only communicate a checked state\n if (!checked) onCheck();\n if (bubbleInput && isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if radio has a bubble input and is a form control, stop propagation\n // from the button so that we only propagate one click event (from the\n // input). We propagate changes from an input so that native form\n // validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n );\n },\n);\n\nRadioTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * Radio\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface RadioProps extends Omit<PrimitiveButtonProps, 'checked'> {\n checked?: boolean;\n required?: boolean;\n onCheck?(): void;\n}\n\nconst Radio = React.forwardRef<RadioElement, RadioProps>(\n (props: ScopedProps<RadioProps>, forwardedRef) => {\n const { __scopeRadio, name, checked, required, disabled, value, onCheck, form, ...radioProps } =\n props;\n\n return (\n <RadioProvider\n __scopeRadio={__scopeRadio}\n checked={checked}\n disabled={disabled}\n required={required}\n onCheck={onCheck}\n name={name}\n form={form}\n value={value}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: RadioContextValue) => (\n <>\n <RadioTrigger\n {...radioProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n {isFormControl && (\n <RadioBubbleInput\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\nRadio.displayName = RADIO_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioIndicator';\n\ntype RadioIndicatorElement = React.ComponentRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\nexport interface RadioIndicatorProps extends PrimitiveSpanProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst RadioIndicator = React.forwardRef<RadioIndicatorElement, RadioIndicatorProps>(\n (props: ScopedProps<RadioIndicatorProps>, forwardedRef) => {\n const { __scopeRadio, forceMount, ...indicatorProps } = props;\n const context = useRadioContext(INDICATOR_NAME, __scopeRadio);\n return (\n <Presence present={forceMount || context.checked}>\n <Primitive.span\n data-state={getState(context.checked)}\n data-disabled={context.disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n />\n </Presence>\n );\n },\n);\n\nRadioIndicator.displayName = INDICATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst BUBBLE_INPUT_NAME = 'RadioBubbleInput';\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface RadioBubbleInputProps extends Omit<InputProps, 'checked'> {}\n\nconst RadioBubbleInput = React.forwardRef<HTMLInputElement, RadioBubbleInputProps>(\n ({ __scopeRadio, ...props }: ScopedProps<RadioBubbleInputProps>, forwardedRef) => {\n const {\n control,\n checked,\n required,\n disabled,\n name,\n value,\n form,\n bubbleInput,\n setBubbleInput,\n hasConsumerStoppedPropagationRef,\n } = useRadioContext(BUBBLE_INPUT_NAME, __scopeRadio);\n\n const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = bubbleInput;\n if (!input) return;\n\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked',\n ) as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n const bubbles = !hasConsumerStoppedPropagationRef.current;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);\n\n const defaultCheckedRef = React.useRef(checked);\n return (\n <Primitive.input\n type=\"radio\"\n aria-hidden\n defaultChecked={defaultCheckedRef.current}\n required={required}\n disabled={disabled}\n name={name}\n value={value}\n form={form}\n {...props}\n tabIndex={-1}\n ref={composedRefs}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n transform: 'translateX(-100%)',\n }}\n />\n );\n },\n);\n\nRadioBubbleInput.displayName = BUBBLE_INPUT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction isFunction(value: unknown): value is (...args: any[]) => any {\n return typeof value === 'function';\n}\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nexport {\n createRadioScope,\n useRadioContext,\n //\n Radio,\n RadioProvider,\n RadioTrigger,\n RadioIndicator,\n RadioBubbleInput,\n};\nexport type { RadioProps, RadioProviderProps, RadioTriggerProps, RadioBubbleInputProps };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,SAAuB;AACvB,IAAAC,oBAAqC;AACrC,IAAAC,6BAAgC;AAChC,IAAAC,wBAAmC;AACnC,IAAAC,0BAA0B;AAC1B,uBAAkC;AAClC,gCAA4C;AAC5C,0CAAqC;AACrC,6BAA6B;;;ACR7B,YAAuB;AACvB,uBAAqC;AACrC,gCAAgC;AAChC,2BAAmC;AACnC,4BAAwB;AACxB,gCAA4B;AAC5B,4BAAyB;AACzB,6BAA0B;AAkFtB;AA9EJ,IAAM,aAAa;AAGnB,IAAM,CAAC,oBAAoB,gBAAgB,QAAI,yCAAmB,UAAU;AAkB5E,IAAM,CAAC,mBAAmB,eAAe,IAAI,mBAAsC,UAAU;AAiB7F,SAAS,cAAc,OAAwC;AAC7D,QAAM;AAAA,IACJ;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA;AAAA,IAER;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,SAAS,UAAU,IAAU,eAAmC,IAAI;AAC3E,QAAM,CAAC,aAAa,cAAc,IAAU,eAAkC,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kBAAc,uCAAY,OAAO;AACvC,UAAM,kBAAc,+BAAQ,OAAO;AAGnC,IAAM,gBAAU,MAAM;AACpB,YAAM,QAAQ;AACd,UAAI,CAAC,MAAO;AAEZ,YAAM,aAAa,OAAO,iBAAiB;AAC3C,YAAM,aAAa,OAAO;AAAA,QACxB;AAAA,QACA;AAAA,MACF;AACA,YAAM,aAAa,WAAW;AAE9B,YAAM,UAAU,CAAC,iCAAiC;AAClD,UAAI,gBAAgB,WAAW,YAAY;AACzC,cAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,QAAQ,CAAC;AAC5C,mBAAW,KAAK,OAAO,OAAO;AAC9B,cAAM,cAAc,KAAK;AAAA,MAC3B;AAAA,IACF,GAAG,CAAC,aAAa,aAAa,SAAS,gCAAgC,CAAC;AAExE,UAAM,oBAA0B,aAAO,OAAO;AAC9C,WACE;AAAA,MAAC,iCAAU;AAAA,MAAV;AAAA,QACC,MAAK;AAAA,QACL,eAAW;AAAA,QACX,gBAAgB,kBAAkB;AAAA,QAClC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QACJ,UAAU;AAAA,QACV,KAAK;AAAA,QACL,OAAO;AAAA,UACL,GAAG,MAAM;AAAA,UACT,GAAG;AAAA,UACH,UAAU;AAAA,UACV,eAAe;AAAA,UACf,SAAS;AAAA,UACT,QAAQ;AAAA;AAAA;AAAA;AAAA,UAIR,WAAW;AAAA,QACb;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,iBAAiB,cAAc;AAI/B,SAAS,WAAW,OAAkD;AACpE,SAAO,OAAO,UAAU;AAC1B;AAEA,SAAS,SAAS,SAAkB;AAClC,SAAO,UAAU,YAAY;AAC/B;;;
|
|
4
|
+
"sourcesContent": ["'use client';\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupItemProvider as unstable_RadioGroupItemProvider,\n RadioGroupItemTrigger as unstable_RadioGroupItemTrigger,\n RadioGroupItemBubbleInput as unstable_RadioGroupItemBubbleInput,\n RadioGroupIndicator,\n //\n Root,\n Item,\n ItemProvider as unstable_ItemProvider,\n ItemTrigger as unstable_ItemTrigger,\n ItemBubbleInput as unstable_ItemBubbleInput,\n Indicator,\n} from './radio-group';\nexport type {\n RadioGroupProps,\n RadioGroupItemProps,\n RadioGroupItemProviderProps as unstable_RadioGroupItemProviderProps,\n RadioGroupItemTriggerProps as unstable_RadioGroupItemTriggerProps,\n RadioGroupItemBubbleInputProps as unstable_RadioGroupItemBubbleInputProps,\n RadioGroupIndicatorProps,\n} from './radio-group';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useDirection } from '@radix-ui/react-direction';\nimport {\n type Radio,\n RadioProvider,\n RadioTrigger,\n RadioBubbleInput,\n RadioIndicator,\n createRadioScope,\n useRadioContext,\n} from './radio';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroup\n * -----------------------------------------------------------------------------------------------*/\nconst RADIO_GROUP_NAME = 'RadioGroup';\n\ntype ScopedProps<P> = P & { __scopeRadioGroup?: Scope };\nconst [createRadioGroupContext, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [\n createRovingFocusGroupScope,\n createRadioScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\nconst useRadioScope = createRadioScope();\n\ntype RadioGroupContextValue = {\n name?: string;\n form?: string;\n required: boolean;\n disabled: boolean;\n value: string | null;\n onValueChange(value: string): void;\n};\n\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContext<RadioGroupContextValue>(RADIO_GROUP_NAME);\n\ntype RadioGroupElement = React.ComponentRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface RadioGroupProps extends PrimitiveDivProps {\n name?: RadioGroupContextValue['name'];\n form?: React.ComponentPropsWithoutRef<typeof Radio>['form'];\n required?: React.ComponentPropsWithoutRef<typeof Radio>['required'];\n disabled?: React.ComponentPropsWithoutRef<typeof Radio>['disabled'];\n dir?: RovingFocusGroupProps['dir'];\n orientation?: RovingFocusGroupProps['orientation'];\n loop?: RovingFocusGroupProps['loop'];\n defaultValue?: string;\n value?: string | null;\n onValueChange?: RadioGroupContextValue['onValueChange'];\n}\n\nconst RadioGroup = React.forwardRef<RadioGroupElement, RadioGroupProps>(\n (props: ScopedProps<RadioGroupProps>, forwardedRef) => {\n const {\n __scopeRadioGroup,\n name,\n form,\n defaultValue,\n value: valueProp,\n required = false,\n disabled = false,\n orientation,\n dir,\n loop = true,\n onValueChange,\n ...groupProps\n } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const direction = useDirection(dir);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? null,\n onChange: onValueChange as (value: string | null) => void,\n caller: RADIO_GROUP_NAME,\n });\n const [control, setControl] = React.useState<RadioGroupElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n const initialValueRef = React.useRef(value);\n React.useEffect(() => {\n const associatedForm = form\n ? control?.ownerDocument.getElementById(form)\n : control?.closest('form');\n if (associatedForm instanceof HTMLFormElement) {\n const reset = () => setValue(initialValueRef.current);\n associatedForm.addEventListener('reset', reset);\n return () => associatedForm.removeEventListener('reset', reset);\n }\n }, [control, form, setValue]);\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n name={name}\n form={form}\n required={required}\n disabled={disabled}\n value={value}\n onValueChange={setValue}\n >\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={orientation}\n dir={direction}\n loop={loop}\n >\n <Primitive.div\n role=\"radiogroup\"\n aria-required={required}\n aria-orientation={orientation}\n data-disabled={disabled ? '' : undefined}\n dir={direction}\n {...groupProps}\n ref={composedRefs}\n />\n </RovingFocusGroup.Root>\n </RadioGroupProvider>\n );\n },\n);\n\nRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'RadioGroupItem';\nconst ITEM_PROVIDER_NAME = 'RadioGroupItemProvider';\nconst ITEM_TRIGGER_NAME = 'RadioGroupItemTrigger';\nconst ITEM_BUBBLE_INPUT_NAME = 'RadioGroupItemBubbleInput';\n\ninterface RadioGroupItemProviderProps {\n value: string;\n disabled?: boolean;\n children?: React.ReactNode;\n}\n\nfunction RadioGroupItemProvider(props: ScopedProps<RadioGroupItemProviderProps>) {\n const {\n __scopeRadioGroup,\n value,\n disabled,\n children,\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n const context = useRadioGroupContext(ITEM_PROVIDER_NAME, __scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const isDisabled = context.disabled || disabled;\n\n return (\n <RadioProvider\n {...radioScope}\n checked={context.value === value}\n disabled={isDisabled}\n required={context.required}\n name={context.name}\n form={context.form}\n value={value}\n onCheck={() => context.onValueChange(value)}\n // @ts-expect-error\n internal_do_not_use_render={internal_do_not_use_render}\n >\n {children}\n </RadioProvider>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemTrigger\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemTriggerElement = React.ComponentRef<typeof RadioTrigger>;\ninterface RadioGroupItemTriggerProps extends React.ComponentPropsWithoutRef<typeof RadioTrigger> {}\n\nconst RadioGroupItemTrigger = React.forwardRef<\n RadioGroupItemTriggerElement,\n RadioGroupItemTriggerProps\n>((props: ScopedProps<RadioGroupItemTriggerProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...triggerProps } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const { checked, disabled } = useRadioContext(ITEM_TRIGGER_NAME, radioScope.__scopeRadio);\n const ref = React.useRef<RadioGroupItemTriggerElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const isArrowKeyPressedRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (ARROW_KEYS.includes(event.key)) {\n isArrowKeyPressedRef.current = true;\n }\n };\n const handleKeyUp = () => (isArrowKeyPressedRef.current = false);\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('keyup', handleKeyUp);\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('keyup', handleKeyUp);\n };\n }, []);\n\n return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={checked}\n >\n <RadioTrigger\n {...radioScope}\n {...triggerProps}\n ref={composedRefs}\n onKeyDown={composeEventHandlers(triggerProps.onKeyDown, (event) => {\n // According to WAI ARIA, radio groups don't activate items on enter\n // keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onFocus={composeEventHandlers(triggerProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with\n * arrow keys and we need to \"check\" it in that case. We click it to\n * \"check\" it (instead of updating `context.value`) so that the radio\n * change event fires.\n */\n if (isArrowKeyPressedRef.current) {\n ref.current?.click();\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n});\n\nRadioGroupItemTrigger.displayName = ITEM_TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemElement = React.ComponentRef<typeof Radio>;\ntype RadioProps = React.ComponentPropsWithoutRef<typeof Radio>;\ninterface RadioGroupItemProps extends Omit<RadioProps, 'onCheck' | 'name'> {\n value: string;\n}\n\nconst RadioGroupItem = React.forwardRef<RadioGroupItemElement, RadioGroupItemProps>(\n (props: ScopedProps<RadioGroupItemProps>, forwardedRef) => {\n const { __scopeRadioGroup, value, disabled, ...itemProps } = props;\n\n return (\n <RadioGroupItemProvider\n __scopeRadioGroup={__scopeRadioGroup}\n value={value}\n disabled={disabled}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: { isFormControl: boolean }) => (\n <>\n <RadioGroupItemTrigger\n {...itemProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n {isFormControl && (\n <RadioGroupItemBubbleInput\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\nRadioGroupItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemBubbleInputElement = React.ComponentRef<typeof RadioBubbleInput>;\ninterface RadioGroupItemBubbleInputProps extends React.ComponentPropsWithoutRef<\n typeof RadioBubbleInput\n> {}\n\nconst RadioGroupItemBubbleInput = React.forwardRef<\n RadioGroupItemBubbleInputElement,\n RadioGroupItemBubbleInputProps\n>((props: ScopedProps<RadioGroupItemBubbleInputProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...bubbleProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioBubbleInput {...radioScope} {...bubbleProps} ref={forwardedRef} />;\n});\n\nRadioGroupItemBubbleInput.displayName = ITEM_BUBBLE_INPUT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioGroupIndicator';\n\ntype RadioGroupIndicatorElement = React.ComponentRef<typeof RadioIndicator>;\ntype RadioIndicatorProps = React.ComponentPropsWithoutRef<typeof RadioIndicator>;\ninterface RadioGroupIndicatorProps extends RadioIndicatorProps {}\n\nconst RadioGroupIndicator = React.forwardRef<RadioGroupIndicatorElement, RadioGroupIndicatorProps>(\n (props: ScopedProps<RadioGroupIndicatorProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...indicatorProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioIndicator {...radioScope} {...indicatorProps} ref={forwardedRef} />;\n },\n);\n\nRadioGroupIndicator.displayName = INDICATOR_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupItemProvider,\n RadioGroupItemTrigger,\n RadioGroupItemBubbleInput,\n RadioGroupIndicator,\n //\n RadioGroup as Root,\n RadioGroupItem as Item,\n RadioGroupItemProvider as ItemProvider,\n RadioGroupItemTrigger as ItemTrigger,\n RadioGroupItemBubbleInput as ItemBubbleInput,\n RadioGroupIndicator as Indicator,\n};\nexport type {\n RadioGroupProps,\n RadioGroupItemProps,\n RadioGroupItemProviderProps,\n RadioGroupItemTriggerProps,\n RadioGroupItemBubbleInputProps,\n RadioGroupIndicatorProps,\n};\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst RADIO_NAME = 'Radio';\n\ntype ScopedProps<P> = P & { __scopeRadio?: Scope };\nconst [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);\n\ntype RadioContextValue = {\n checked: boolean;\n disabled: boolean | undefined;\n required: boolean | undefined;\n name: string | undefined;\n form: string | undefined;\n value: string | number | readonly string[];\n control: HTMLButtonElement | null;\n setControl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;\n hasConsumerStoppedPropagationRef: React.RefObject<boolean>;\n isFormControl: boolean;\n bubbleInput: HTMLInputElement | null;\n setBubbleInput: React.Dispatch<React.SetStateAction<HTMLInputElement | null>>;\n onCheck(): void;\n};\n\nconst [RadioProviderImpl, useRadioContext] = createRadioContext<RadioContextValue>(RADIO_NAME);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface RadioProviderProps {\n checked?: boolean;\n required?: boolean;\n disabled?: boolean;\n name?: string;\n form?: string;\n value?: string | number | readonly string[];\n onCheck?(): void;\n children?: React.ReactNode;\n}\n\nfunction RadioProvider(props: ScopedProps<RadioProviderProps>) {\n const {\n __scopeRadio,\n checked = false,\n children,\n disabled,\n form,\n name,\n onCheck,\n required,\n value = 'on',\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n\n const [control, setControl] = React.useState<HTMLButtonElement | null>(null);\n const [bubbleInput, setBubbleInput] = React.useState<HTMLInputElement | null>(null);\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = control\n ? !!form || !!control.closest('form')\n : // We set this to true by default so that events bubble to forms without JS (SSR)\n true;\n\n const context: RadioContextValue = {\n checked,\n disabled,\n required,\n name,\n form,\n value,\n control,\n setControl,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n setBubbleInput,\n onCheck: () => onCheck?.(),\n };\n\n return (\n <RadioProviderImpl scope={__scopeRadio} {...context}>\n {isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children}\n </RadioProviderImpl>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'RadioTrigger';\n\ninterface RadioTriggerProps extends Omit<\n React.ComponentPropsWithoutRef<typeof Primitive.button>,\n keyof RadioProviderProps\n> {\n children?: React.ReactNode;\n}\n\nconst RadioTrigger = React.forwardRef<HTMLButtonElement, RadioTriggerProps>(\n ({ __scopeRadio, onClick, ...radioProps }: ScopedProps<RadioTriggerProps>, forwardedRef) => {\n const {\n checked,\n disabled,\n value,\n setControl,\n onCheck,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n } = useRadioContext(TRIGGER_NAME, __scopeRadio);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n return (\n <Primitive.button\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...radioProps}\n ref={composedRefs}\n onClick={composeEventHandlers(onClick, (event) => {\n // radios cannot be unchecked so we only communicate a checked state\n if (!checked) onCheck();\n if (bubbleInput && isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if radio has a bubble input and is a form control, stop propagation\n // from the button so that we only propagate one click event (from the\n // input). We propagate changes from an input so that native form\n // validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n );\n },\n);\n\nRadioTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * Radio\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface RadioProps extends Omit<PrimitiveButtonProps, 'checked'> {\n checked?: boolean;\n required?: boolean;\n onCheck?(): void;\n}\n\nconst Radio = React.forwardRef<RadioElement, RadioProps>(\n (props: ScopedProps<RadioProps>, forwardedRef) => {\n const { __scopeRadio, name, checked, required, disabled, value, onCheck, form, ...radioProps } =\n props;\n\n return (\n <RadioProvider\n __scopeRadio={__scopeRadio}\n checked={checked}\n disabled={disabled}\n required={required}\n onCheck={onCheck}\n name={name}\n form={form}\n value={value}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: RadioContextValue) => (\n <>\n <RadioTrigger\n {...radioProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n {isFormControl && (\n <RadioBubbleInput\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\nRadio.displayName = RADIO_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioIndicator';\n\ntype RadioIndicatorElement = React.ComponentRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\nexport interface RadioIndicatorProps extends PrimitiveSpanProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst RadioIndicator = React.forwardRef<RadioIndicatorElement, RadioIndicatorProps>(\n (props: ScopedProps<RadioIndicatorProps>, forwardedRef) => {\n const { __scopeRadio, forceMount, ...indicatorProps } = props;\n const context = useRadioContext(INDICATOR_NAME, __scopeRadio);\n return (\n <Presence present={forceMount || context.checked}>\n <Primitive.span\n data-state={getState(context.checked)}\n data-disabled={context.disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n />\n </Presence>\n );\n },\n);\n\nRadioIndicator.displayName = INDICATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst BUBBLE_INPUT_NAME = 'RadioBubbleInput';\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface RadioBubbleInputProps extends Omit<InputProps, 'checked'> {}\n\nconst RadioBubbleInput = React.forwardRef<HTMLInputElement, RadioBubbleInputProps>(\n ({ __scopeRadio, ...props }: ScopedProps<RadioBubbleInputProps>, forwardedRef) => {\n const {\n control,\n checked,\n required,\n disabled,\n name,\n value,\n form,\n bubbleInput,\n setBubbleInput,\n hasConsumerStoppedPropagationRef,\n } = useRadioContext(BUBBLE_INPUT_NAME, __scopeRadio);\n\n const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = bubbleInput;\n if (!input) return;\n\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked',\n ) as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n const bubbles = !hasConsumerStoppedPropagationRef.current;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);\n\n const defaultCheckedRef = React.useRef(checked);\n return (\n <Primitive.input\n type=\"radio\"\n aria-hidden\n defaultChecked={defaultCheckedRef.current}\n required={required}\n disabled={disabled}\n name={name}\n value={value}\n form={form}\n {...props}\n tabIndex={-1}\n ref={composedRefs}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n transform: 'translateX(-100%)',\n }}\n />\n );\n },\n);\n\nRadioBubbleInput.displayName = BUBBLE_INPUT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction isFunction(value: unknown): value is (...args: any[]) => any {\n return typeof value === 'function';\n}\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nexport {\n createRadioScope,\n useRadioContext,\n //\n Radio,\n RadioProvider,\n RadioTrigger,\n RadioIndicator,\n RadioBubbleInput,\n};\nexport type { RadioProps, RadioProviderProps, RadioTriggerProps, RadioBubbleInputProps };\n"],
|
|
5
|
+
"mappings": ";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A,EAChC,CAAC,OAA8C,iBAAiB;AAC9D,UAAM,EAAE,mBAAmB,GAAG,eAAe,IAAI;AACjD,UAAM,aAAa,cAAc,iBAAiB;AAClD,WAAO,6CAAC,kBAAgB,GAAG,YAAa,GAAG,gBAAgB,KAAK,cAAc;AAAA,EAChF;AACF;AAEA,oBAAoB,cAAcA;",
|
|
6
6
|
"names": ["React", "import_primitive", "import_react_compose_refs", "import_react_context", "import_react_primitive", "import_jsx_runtime", "INDICATOR_NAME"]
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -241,6 +241,7 @@ var RadioGroup = React2.forwardRef(
|
|
|
241
241
|
const {
|
|
242
242
|
__scopeRadioGroup,
|
|
243
243
|
name,
|
|
244
|
+
form,
|
|
244
245
|
defaultValue,
|
|
245
246
|
value: valueProp,
|
|
246
247
|
required = false,
|
|
@@ -259,11 +260,23 @@ var RadioGroup = React2.forwardRef(
|
|
|
259
260
|
onChange: onValueChange,
|
|
260
261
|
caller: RADIO_GROUP_NAME
|
|
261
262
|
});
|
|
263
|
+
const [control, setControl] = React2.useState(null);
|
|
264
|
+
const composedRefs = useComposedRefs2(forwardedRef, setControl);
|
|
265
|
+
const initialValueRef = React2.useRef(value);
|
|
266
|
+
React2.useEffect(() => {
|
|
267
|
+
const associatedForm = form ? control?.ownerDocument.getElementById(form) : control?.closest("form");
|
|
268
|
+
if (associatedForm instanceof HTMLFormElement) {
|
|
269
|
+
const reset = () => setValue(initialValueRef.current);
|
|
270
|
+
associatedForm.addEventListener("reset", reset);
|
|
271
|
+
return () => associatedForm.removeEventListener("reset", reset);
|
|
272
|
+
}
|
|
273
|
+
}, [control, form, setValue]);
|
|
262
274
|
return /* @__PURE__ */ jsx2(
|
|
263
275
|
RadioGroupProvider,
|
|
264
276
|
{
|
|
265
277
|
scope: __scopeRadioGroup,
|
|
266
278
|
name,
|
|
279
|
+
form,
|
|
267
280
|
required,
|
|
268
281
|
disabled,
|
|
269
282
|
value,
|
|
@@ -285,7 +298,7 @@ var RadioGroup = React2.forwardRef(
|
|
|
285
298
|
"data-disabled": disabled ? "" : void 0,
|
|
286
299
|
dir: direction,
|
|
287
300
|
...groupProps,
|
|
288
|
-
ref:
|
|
301
|
+
ref: composedRefs
|
|
289
302
|
}
|
|
290
303
|
)
|
|
291
304
|
}
|
|
@@ -319,6 +332,7 @@ function RadioGroupItemProvider(props) {
|
|
|
319
332
|
disabled: isDisabled,
|
|
320
333
|
required: context.required,
|
|
321
334
|
name: context.name,
|
|
335
|
+
form: context.form,
|
|
322
336
|
value,
|
|
323
337
|
onCheck: () => context.onValueChange(value),
|
|
324
338
|
internal_do_not_use_render,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/radio-group.tsx", "../src/radio.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useDirection } from '@radix-ui/react-direction';\nimport {\n type Radio,\n RadioProvider,\n RadioTrigger,\n RadioBubbleInput,\n RadioIndicator,\n createRadioScope,\n useRadioContext,\n} from './radio';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroup\n * -----------------------------------------------------------------------------------------------*/\nconst RADIO_GROUP_NAME = 'RadioGroup';\n\ntype ScopedProps<P> = P & { __scopeRadioGroup?: Scope };\nconst [createRadioGroupContext, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [\n createRovingFocusGroupScope,\n createRadioScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\nconst useRadioScope = createRadioScope();\n\ntype RadioGroupContextValue = {\n name?: string;\n required: boolean;\n disabled: boolean;\n value: string | null;\n onValueChange(value: string): void;\n};\n\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContext<RadioGroupContextValue>(RADIO_GROUP_NAME);\n\ntype RadioGroupElement = React.ComponentRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface RadioGroupProps extends PrimitiveDivProps {\n name?: RadioGroupContextValue['name'];\n required?: React.ComponentPropsWithoutRef<typeof Radio>['required'];\n disabled?: React.ComponentPropsWithoutRef<typeof Radio>['disabled'];\n dir?: RovingFocusGroupProps['dir'];\n orientation?: RovingFocusGroupProps['orientation'];\n loop?: RovingFocusGroupProps['loop'];\n defaultValue?: string;\n value?: string | null;\n onValueChange?: RadioGroupContextValue['onValueChange'];\n}\n\nconst RadioGroup = React.forwardRef<RadioGroupElement, RadioGroupProps>(\n (props: ScopedProps<RadioGroupProps>, forwardedRef) => {\n const {\n __scopeRadioGroup,\n name,\n defaultValue,\n value: valueProp,\n required = false,\n disabled = false,\n orientation,\n dir,\n loop = true,\n onValueChange,\n ...groupProps\n } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const direction = useDirection(dir);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? null,\n onChange: onValueChange as (value: string | null) => void,\n caller: RADIO_GROUP_NAME,\n });\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n name={name}\n required={required}\n disabled={disabled}\n value={value}\n onValueChange={setValue}\n >\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={orientation}\n dir={direction}\n loop={loop}\n >\n <Primitive.div\n role=\"radiogroup\"\n aria-required={required}\n aria-orientation={orientation}\n data-disabled={disabled ? '' : undefined}\n dir={direction}\n {...groupProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n </RadioGroupProvider>\n );\n },\n);\n\nRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'RadioGroupItem';\nconst ITEM_PROVIDER_NAME = 'RadioGroupItemProvider';\nconst ITEM_TRIGGER_NAME = 'RadioGroupItemTrigger';\nconst ITEM_BUBBLE_INPUT_NAME = 'RadioGroupItemBubbleInput';\n\ninterface RadioGroupItemProviderProps {\n value: string;\n disabled?: boolean;\n children?: React.ReactNode;\n}\n\nfunction RadioGroupItemProvider(props: ScopedProps<RadioGroupItemProviderProps>) {\n const {\n __scopeRadioGroup,\n value,\n disabled,\n children,\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n const context = useRadioGroupContext(ITEM_PROVIDER_NAME, __scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const isDisabled = context.disabled || disabled;\n\n return (\n <RadioProvider\n {...radioScope}\n checked={context.value === value}\n disabled={isDisabled}\n required={context.required}\n name={context.name}\n value={value}\n onCheck={() => context.onValueChange(value)}\n // @ts-expect-error\n internal_do_not_use_render={internal_do_not_use_render}\n >\n {children}\n </RadioProvider>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemTrigger\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemTriggerElement = React.ComponentRef<typeof RadioTrigger>;\ninterface RadioGroupItemTriggerProps extends React.ComponentPropsWithoutRef<typeof RadioTrigger> {}\n\nconst RadioGroupItemTrigger = React.forwardRef<\n RadioGroupItemTriggerElement,\n RadioGroupItemTriggerProps\n>((props: ScopedProps<RadioGroupItemTriggerProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...triggerProps } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const { checked, disabled } = useRadioContext(ITEM_TRIGGER_NAME, radioScope.__scopeRadio);\n const ref = React.useRef<RadioGroupItemTriggerElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const isArrowKeyPressedRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (ARROW_KEYS.includes(event.key)) {\n isArrowKeyPressedRef.current = true;\n }\n };\n const handleKeyUp = () => (isArrowKeyPressedRef.current = false);\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('keyup', handleKeyUp);\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('keyup', handleKeyUp);\n };\n }, []);\n\n return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={checked}\n >\n <RadioTrigger\n {...radioScope}\n {...triggerProps}\n ref={composedRefs}\n onKeyDown={composeEventHandlers(triggerProps.onKeyDown, (event) => {\n // According to WAI ARIA, radio groups don't activate items on enter\n // keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onFocus={composeEventHandlers(triggerProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with\n * arrow keys and we need to \"check\" it in that case. We click it to\n * \"check\" it (instead of updating `context.value`) so that the radio\n * change event fires.\n */\n if (isArrowKeyPressedRef.current) {\n ref.current?.click();\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n});\n\nRadioGroupItemTrigger.displayName = ITEM_TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemElement = React.ComponentRef<typeof Radio>;\ntype RadioProps = React.ComponentPropsWithoutRef<typeof Radio>;\ninterface RadioGroupItemProps extends Omit<RadioProps, 'onCheck' | 'name'> {\n value: string;\n}\n\nconst RadioGroupItem = React.forwardRef<RadioGroupItemElement, RadioGroupItemProps>(\n (props: ScopedProps<RadioGroupItemProps>, forwardedRef) => {\n const { __scopeRadioGroup, value, disabled, ...itemProps } = props;\n\n return (\n <RadioGroupItemProvider\n __scopeRadioGroup={__scopeRadioGroup}\n value={value}\n disabled={disabled}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: { isFormControl: boolean }) => (\n <>\n <RadioGroupItemTrigger\n {...itemProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n {isFormControl && (\n <RadioGroupItemBubbleInput\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\nRadioGroupItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemBubbleInputElement = React.ComponentRef<typeof RadioBubbleInput>;\ninterface RadioGroupItemBubbleInputProps extends React.ComponentPropsWithoutRef<\n typeof RadioBubbleInput\n> {}\n\nconst RadioGroupItemBubbleInput = React.forwardRef<\n RadioGroupItemBubbleInputElement,\n RadioGroupItemBubbleInputProps\n>((props: ScopedProps<RadioGroupItemBubbleInputProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...bubbleProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioBubbleInput {...radioScope} {...bubbleProps} ref={forwardedRef} />;\n});\n\nRadioGroupItemBubbleInput.displayName = ITEM_BUBBLE_INPUT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioGroupIndicator';\n\ntype RadioGroupIndicatorElement = React.ComponentRef<typeof RadioIndicator>;\ntype RadioIndicatorProps = React.ComponentPropsWithoutRef<typeof RadioIndicator>;\ninterface RadioGroupIndicatorProps extends RadioIndicatorProps {}\n\nconst RadioGroupIndicator = React.forwardRef<RadioGroupIndicatorElement, RadioGroupIndicatorProps>(\n (props: ScopedProps<RadioGroupIndicatorProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...indicatorProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioIndicator {...radioScope} {...indicatorProps} ref={forwardedRef} />;\n },\n);\n\nRadioGroupIndicator.displayName = INDICATOR_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupItemProvider,\n RadioGroupItemTrigger,\n RadioGroupItemBubbleInput,\n RadioGroupIndicator,\n //\n RadioGroup as Root,\n RadioGroupItem as Item,\n RadioGroupItemProvider as ItemProvider,\n RadioGroupItemTrigger as ItemTrigger,\n RadioGroupItemBubbleInput as ItemBubbleInput,\n RadioGroupIndicator as Indicator,\n};\nexport type {\n RadioGroupProps,\n RadioGroupItemProps,\n RadioGroupItemProviderProps,\n RadioGroupItemTriggerProps,\n RadioGroupItemBubbleInputProps,\n RadioGroupIndicatorProps,\n};\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst RADIO_NAME = 'Radio';\n\ntype ScopedProps<P> = P & { __scopeRadio?: Scope };\nconst [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);\n\ntype RadioContextValue = {\n checked: boolean;\n disabled: boolean | undefined;\n required: boolean | undefined;\n name: string | undefined;\n form: string | undefined;\n value: string | number | readonly string[];\n control: HTMLButtonElement | null;\n setControl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;\n hasConsumerStoppedPropagationRef: React.RefObject<boolean>;\n isFormControl: boolean;\n bubbleInput: HTMLInputElement | null;\n setBubbleInput: React.Dispatch<React.SetStateAction<HTMLInputElement | null>>;\n onCheck(): void;\n};\n\nconst [RadioProviderImpl, useRadioContext] = createRadioContext<RadioContextValue>(RADIO_NAME);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface RadioProviderProps {\n checked?: boolean;\n required?: boolean;\n disabled?: boolean;\n name?: string;\n form?: string;\n value?: string | number | readonly string[];\n onCheck?(): void;\n children?: React.ReactNode;\n}\n\nfunction RadioProvider(props: ScopedProps<RadioProviderProps>) {\n const {\n __scopeRadio,\n checked = false,\n children,\n disabled,\n form,\n name,\n onCheck,\n required,\n value = 'on',\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n\n const [control, setControl] = React.useState<HTMLButtonElement | null>(null);\n const [bubbleInput, setBubbleInput] = React.useState<HTMLInputElement | null>(null);\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = control\n ? !!form || !!control.closest('form')\n : // We set this to true by default so that events bubble to forms without JS (SSR)\n true;\n\n const context: RadioContextValue = {\n checked,\n disabled,\n required,\n name,\n form,\n value,\n control,\n setControl,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n setBubbleInput,\n onCheck: () => onCheck?.(),\n };\n\n return (\n <RadioProviderImpl scope={__scopeRadio} {...context}>\n {isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children}\n </RadioProviderImpl>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'RadioTrigger';\n\ninterface RadioTriggerProps extends Omit<\n React.ComponentPropsWithoutRef<typeof Primitive.button>,\n keyof RadioProviderProps\n> {\n children?: React.ReactNode;\n}\n\nconst RadioTrigger = React.forwardRef<HTMLButtonElement, RadioTriggerProps>(\n ({ __scopeRadio, onClick, ...radioProps }: ScopedProps<RadioTriggerProps>, forwardedRef) => {\n const {\n checked,\n disabled,\n value,\n setControl,\n onCheck,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n } = useRadioContext(TRIGGER_NAME, __scopeRadio);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n return (\n <Primitive.button\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...radioProps}\n ref={composedRefs}\n onClick={composeEventHandlers(onClick, (event) => {\n // radios cannot be unchecked so we only communicate a checked state\n if (!checked) onCheck();\n if (bubbleInput && isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if radio has a bubble input and is a form control, stop propagation\n // from the button so that we only propagate one click event (from the\n // input). We propagate changes from an input so that native form\n // validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n );\n },\n);\n\nRadioTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * Radio\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface RadioProps extends Omit<PrimitiveButtonProps, 'checked'> {\n checked?: boolean;\n required?: boolean;\n onCheck?(): void;\n}\n\nconst Radio = React.forwardRef<RadioElement, RadioProps>(\n (props: ScopedProps<RadioProps>, forwardedRef) => {\n const { __scopeRadio, name, checked, required, disabled, value, onCheck, form, ...radioProps } =\n props;\n\n return (\n <RadioProvider\n __scopeRadio={__scopeRadio}\n checked={checked}\n disabled={disabled}\n required={required}\n onCheck={onCheck}\n name={name}\n form={form}\n value={value}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: RadioContextValue) => (\n <>\n <RadioTrigger\n {...radioProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n {isFormControl && (\n <RadioBubbleInput\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\nRadio.displayName = RADIO_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioIndicator';\n\ntype RadioIndicatorElement = React.ComponentRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\nexport interface RadioIndicatorProps extends PrimitiveSpanProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst RadioIndicator = React.forwardRef<RadioIndicatorElement, RadioIndicatorProps>(\n (props: ScopedProps<RadioIndicatorProps>, forwardedRef) => {\n const { __scopeRadio, forceMount, ...indicatorProps } = props;\n const context = useRadioContext(INDICATOR_NAME, __scopeRadio);\n return (\n <Presence present={forceMount || context.checked}>\n <Primitive.span\n data-state={getState(context.checked)}\n data-disabled={context.disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n />\n </Presence>\n );\n },\n);\n\nRadioIndicator.displayName = INDICATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst BUBBLE_INPUT_NAME = 'RadioBubbleInput';\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface RadioBubbleInputProps extends Omit<InputProps, 'checked'> {}\n\nconst RadioBubbleInput = React.forwardRef<HTMLInputElement, RadioBubbleInputProps>(\n ({ __scopeRadio, ...props }: ScopedProps<RadioBubbleInputProps>, forwardedRef) => {\n const {\n control,\n checked,\n required,\n disabled,\n name,\n value,\n form,\n bubbleInput,\n setBubbleInput,\n hasConsumerStoppedPropagationRef,\n } = useRadioContext(BUBBLE_INPUT_NAME, __scopeRadio);\n\n const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = bubbleInput;\n if (!input) return;\n\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked',\n ) as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n const bubbles = !hasConsumerStoppedPropagationRef.current;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);\n\n const defaultCheckedRef = React.useRef(checked);\n return (\n <Primitive.input\n type=\"radio\"\n aria-hidden\n defaultChecked={defaultCheckedRef.current}\n required={required}\n disabled={disabled}\n name={name}\n value={value}\n form={form}\n {...props}\n tabIndex={-1}\n ref={composedRefs}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n transform: 'translateX(-100%)',\n }}\n />\n );\n },\n);\n\nRadioBubbleInput.displayName = BUBBLE_INPUT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction isFunction(value: unknown): value is (...args: any[]) => any {\n return typeof value === 'function';\n}\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nexport {\n createRadioScope,\n useRadioContext,\n //\n Radio,\n RadioProvider,\n RadioTrigger,\n RadioIndicator,\n RadioBubbleInput,\n};\nexport type { RadioProps, RadioProviderProps, RadioTriggerProps, RadioBubbleInputProps };\n"],
|
|
5
|
-
"mappings": ";;;AAAA,YAAYA,YAAW;AACvB,SAAS,wBAAAC,6BAA4B;AACrC,SAAS,mBAAAC,wBAAuB;AAChC,SAAS,sBAAAC,2BAA0B;AACnC,SAAS,aAAAC,kBAAiB;AAC1B,YAAY,sBAAsB;AAClC,SAAS,mC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AAA,QACL,eAAW;AAAA,QACX,gBAAgB,kBAAkB;AAAA,QAClC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QACJ,UAAU;AAAA,QACV,KAAK;AAAA,QACL,OAAO;AAAA,UACL,GAAG,MAAM;AAAA,UACT,GAAG;AAAA,UACH,UAAU;AAAA,UACV,eAAe;AAAA,UACf,SAAS;AAAA,UACT,QAAQ;AAAA;AAAA;AAAA;AAAA,UAIR,WAAW;AAAA,QACb;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,iBAAiB,cAAc;AAI/B,SAAS,WAAW,OAAkD;AACpE,SAAO,OAAO,UAAU;AAC1B;AAEA,SAAS,SAAS,SAAkB;AAClC,SAAO,UAAU,YAAY;AAC/B;;;
|
|
6
|
-
"names": ["React", "composeEventHandlers", "useComposedRefs", "createContextScope", "Primitive", "Fragment", "jsx", "jsxs", "createContextScope", "
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useDirection } from '@radix-ui/react-direction';\nimport {\n type Radio,\n RadioProvider,\n RadioTrigger,\n RadioBubbleInput,\n RadioIndicator,\n createRadioScope,\n useRadioContext,\n} from './radio';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroup\n * -----------------------------------------------------------------------------------------------*/\nconst RADIO_GROUP_NAME = 'RadioGroup';\n\ntype ScopedProps<P> = P & { __scopeRadioGroup?: Scope };\nconst [createRadioGroupContext, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [\n createRovingFocusGroupScope,\n createRadioScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\nconst useRadioScope = createRadioScope();\n\ntype RadioGroupContextValue = {\n name?: string;\n form?: string;\n required: boolean;\n disabled: boolean;\n value: string | null;\n onValueChange(value: string): void;\n};\n\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContext<RadioGroupContextValue>(RADIO_GROUP_NAME);\n\ntype RadioGroupElement = React.ComponentRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface RadioGroupProps extends PrimitiveDivProps {\n name?: RadioGroupContextValue['name'];\n form?: React.ComponentPropsWithoutRef<typeof Radio>['form'];\n required?: React.ComponentPropsWithoutRef<typeof Radio>['required'];\n disabled?: React.ComponentPropsWithoutRef<typeof Radio>['disabled'];\n dir?: RovingFocusGroupProps['dir'];\n orientation?: RovingFocusGroupProps['orientation'];\n loop?: RovingFocusGroupProps['loop'];\n defaultValue?: string;\n value?: string | null;\n onValueChange?: RadioGroupContextValue['onValueChange'];\n}\n\nconst RadioGroup = React.forwardRef<RadioGroupElement, RadioGroupProps>(\n (props: ScopedProps<RadioGroupProps>, forwardedRef) => {\n const {\n __scopeRadioGroup,\n name,\n form,\n defaultValue,\n value: valueProp,\n required = false,\n disabled = false,\n orientation,\n dir,\n loop = true,\n onValueChange,\n ...groupProps\n } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const direction = useDirection(dir);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? null,\n onChange: onValueChange as (value: string | null) => void,\n caller: RADIO_GROUP_NAME,\n });\n const [control, setControl] = React.useState<RadioGroupElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n const initialValueRef = React.useRef(value);\n React.useEffect(() => {\n const associatedForm = form\n ? control?.ownerDocument.getElementById(form)\n : control?.closest('form');\n if (associatedForm instanceof HTMLFormElement) {\n const reset = () => setValue(initialValueRef.current);\n associatedForm.addEventListener('reset', reset);\n return () => associatedForm.removeEventListener('reset', reset);\n }\n }, [control, form, setValue]);\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n name={name}\n form={form}\n required={required}\n disabled={disabled}\n value={value}\n onValueChange={setValue}\n >\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={orientation}\n dir={direction}\n loop={loop}\n >\n <Primitive.div\n role=\"radiogroup\"\n aria-required={required}\n aria-orientation={orientation}\n data-disabled={disabled ? '' : undefined}\n dir={direction}\n {...groupProps}\n ref={composedRefs}\n />\n </RovingFocusGroup.Root>\n </RadioGroupProvider>\n );\n },\n);\n\nRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'RadioGroupItem';\nconst ITEM_PROVIDER_NAME = 'RadioGroupItemProvider';\nconst ITEM_TRIGGER_NAME = 'RadioGroupItemTrigger';\nconst ITEM_BUBBLE_INPUT_NAME = 'RadioGroupItemBubbleInput';\n\ninterface RadioGroupItemProviderProps {\n value: string;\n disabled?: boolean;\n children?: React.ReactNode;\n}\n\nfunction RadioGroupItemProvider(props: ScopedProps<RadioGroupItemProviderProps>) {\n const {\n __scopeRadioGroup,\n value,\n disabled,\n children,\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n const context = useRadioGroupContext(ITEM_PROVIDER_NAME, __scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const isDisabled = context.disabled || disabled;\n\n return (\n <RadioProvider\n {...radioScope}\n checked={context.value === value}\n disabled={isDisabled}\n required={context.required}\n name={context.name}\n form={context.form}\n value={value}\n onCheck={() => context.onValueChange(value)}\n // @ts-expect-error\n internal_do_not_use_render={internal_do_not_use_render}\n >\n {children}\n </RadioProvider>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemTrigger\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemTriggerElement = React.ComponentRef<typeof RadioTrigger>;\ninterface RadioGroupItemTriggerProps extends React.ComponentPropsWithoutRef<typeof RadioTrigger> {}\n\nconst RadioGroupItemTrigger = React.forwardRef<\n RadioGroupItemTriggerElement,\n RadioGroupItemTriggerProps\n>((props: ScopedProps<RadioGroupItemTriggerProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...triggerProps } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const { checked, disabled } = useRadioContext(ITEM_TRIGGER_NAME, radioScope.__scopeRadio);\n const ref = React.useRef<RadioGroupItemTriggerElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const isArrowKeyPressedRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (ARROW_KEYS.includes(event.key)) {\n isArrowKeyPressedRef.current = true;\n }\n };\n const handleKeyUp = () => (isArrowKeyPressedRef.current = false);\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('keyup', handleKeyUp);\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('keyup', handleKeyUp);\n };\n }, []);\n\n return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={checked}\n >\n <RadioTrigger\n {...radioScope}\n {...triggerProps}\n ref={composedRefs}\n onKeyDown={composeEventHandlers(triggerProps.onKeyDown, (event) => {\n // According to WAI ARIA, radio groups don't activate items on enter\n // keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onFocus={composeEventHandlers(triggerProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with\n * arrow keys and we need to \"check\" it in that case. We click it to\n * \"check\" it (instead of updating `context.value`) so that the radio\n * change event fires.\n */\n if (isArrowKeyPressedRef.current) {\n ref.current?.click();\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n});\n\nRadioGroupItemTrigger.displayName = ITEM_TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemElement = React.ComponentRef<typeof Radio>;\ntype RadioProps = React.ComponentPropsWithoutRef<typeof Radio>;\ninterface RadioGroupItemProps extends Omit<RadioProps, 'onCheck' | 'name'> {\n value: string;\n}\n\nconst RadioGroupItem = React.forwardRef<RadioGroupItemElement, RadioGroupItemProps>(\n (props: ScopedProps<RadioGroupItemProps>, forwardedRef) => {\n const { __scopeRadioGroup, value, disabled, ...itemProps } = props;\n\n return (\n <RadioGroupItemProvider\n __scopeRadioGroup={__scopeRadioGroup}\n value={value}\n disabled={disabled}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: { isFormControl: boolean }) => (\n <>\n <RadioGroupItemTrigger\n {...itemProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n {isFormControl && (\n <RadioGroupItemBubbleInput\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\nRadioGroupItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemBubbleInputElement = React.ComponentRef<typeof RadioBubbleInput>;\ninterface RadioGroupItemBubbleInputProps extends React.ComponentPropsWithoutRef<\n typeof RadioBubbleInput\n> {}\n\nconst RadioGroupItemBubbleInput = React.forwardRef<\n RadioGroupItemBubbleInputElement,\n RadioGroupItemBubbleInputProps\n>((props: ScopedProps<RadioGroupItemBubbleInputProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...bubbleProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioBubbleInput {...radioScope} {...bubbleProps} ref={forwardedRef} />;\n});\n\nRadioGroupItemBubbleInput.displayName = ITEM_BUBBLE_INPUT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioGroupIndicator';\n\ntype RadioGroupIndicatorElement = React.ComponentRef<typeof RadioIndicator>;\ntype RadioIndicatorProps = React.ComponentPropsWithoutRef<typeof RadioIndicator>;\ninterface RadioGroupIndicatorProps extends RadioIndicatorProps {}\n\nconst RadioGroupIndicator = React.forwardRef<RadioGroupIndicatorElement, RadioGroupIndicatorProps>(\n (props: ScopedProps<RadioGroupIndicatorProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...indicatorProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioIndicator {...radioScope} {...indicatorProps} ref={forwardedRef} />;\n },\n);\n\nRadioGroupIndicator.displayName = INDICATOR_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupItemProvider,\n RadioGroupItemTrigger,\n RadioGroupItemBubbleInput,\n RadioGroupIndicator,\n //\n RadioGroup as Root,\n RadioGroupItem as Item,\n RadioGroupItemProvider as ItemProvider,\n RadioGroupItemTrigger as ItemTrigger,\n RadioGroupItemBubbleInput as ItemBubbleInput,\n RadioGroupIndicator as Indicator,\n};\nexport type {\n RadioGroupProps,\n RadioGroupItemProps,\n RadioGroupItemProviderProps,\n RadioGroupItemTriggerProps,\n RadioGroupItemBubbleInputProps,\n RadioGroupIndicatorProps,\n};\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst RADIO_NAME = 'Radio';\n\ntype ScopedProps<P> = P & { __scopeRadio?: Scope };\nconst [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);\n\ntype RadioContextValue = {\n checked: boolean;\n disabled: boolean | undefined;\n required: boolean | undefined;\n name: string | undefined;\n form: string | undefined;\n value: string | number | readonly string[];\n control: HTMLButtonElement | null;\n setControl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;\n hasConsumerStoppedPropagationRef: React.RefObject<boolean>;\n isFormControl: boolean;\n bubbleInput: HTMLInputElement | null;\n setBubbleInput: React.Dispatch<React.SetStateAction<HTMLInputElement | null>>;\n onCheck(): void;\n};\n\nconst [RadioProviderImpl, useRadioContext] = createRadioContext<RadioContextValue>(RADIO_NAME);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface RadioProviderProps {\n checked?: boolean;\n required?: boolean;\n disabled?: boolean;\n name?: string;\n form?: string;\n value?: string | number | readonly string[];\n onCheck?(): void;\n children?: React.ReactNode;\n}\n\nfunction RadioProvider(props: ScopedProps<RadioProviderProps>) {\n const {\n __scopeRadio,\n checked = false,\n children,\n disabled,\n form,\n name,\n onCheck,\n required,\n value = 'on',\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n\n const [control, setControl] = React.useState<HTMLButtonElement | null>(null);\n const [bubbleInput, setBubbleInput] = React.useState<HTMLInputElement | null>(null);\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = control\n ? !!form || !!control.closest('form')\n : // We set this to true by default so that events bubble to forms without JS (SSR)\n true;\n\n const context: RadioContextValue = {\n checked,\n disabled,\n required,\n name,\n form,\n value,\n control,\n setControl,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n setBubbleInput,\n onCheck: () => onCheck?.(),\n };\n\n return (\n <RadioProviderImpl scope={__scopeRadio} {...context}>\n {isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children}\n </RadioProviderImpl>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'RadioTrigger';\n\ninterface RadioTriggerProps extends Omit<\n React.ComponentPropsWithoutRef<typeof Primitive.button>,\n keyof RadioProviderProps\n> {\n children?: React.ReactNode;\n}\n\nconst RadioTrigger = React.forwardRef<HTMLButtonElement, RadioTriggerProps>(\n ({ __scopeRadio, onClick, ...radioProps }: ScopedProps<RadioTriggerProps>, forwardedRef) => {\n const {\n checked,\n disabled,\n value,\n setControl,\n onCheck,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n } = useRadioContext(TRIGGER_NAME, __scopeRadio);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n return (\n <Primitive.button\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...radioProps}\n ref={composedRefs}\n onClick={composeEventHandlers(onClick, (event) => {\n // radios cannot be unchecked so we only communicate a checked state\n if (!checked) onCheck();\n if (bubbleInput && isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if radio has a bubble input and is a form control, stop propagation\n // from the button so that we only propagate one click event (from the\n // input). We propagate changes from an input so that native form\n // validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n );\n },\n);\n\nRadioTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * Radio\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface RadioProps extends Omit<PrimitiveButtonProps, 'checked'> {\n checked?: boolean;\n required?: boolean;\n onCheck?(): void;\n}\n\nconst Radio = React.forwardRef<RadioElement, RadioProps>(\n (props: ScopedProps<RadioProps>, forwardedRef) => {\n const { __scopeRadio, name, checked, required, disabled, value, onCheck, form, ...radioProps } =\n props;\n\n return (\n <RadioProvider\n __scopeRadio={__scopeRadio}\n checked={checked}\n disabled={disabled}\n required={required}\n onCheck={onCheck}\n name={name}\n form={form}\n value={value}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: RadioContextValue) => (\n <>\n <RadioTrigger\n {...radioProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n {isFormControl && (\n <RadioBubbleInput\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\nRadio.displayName = RADIO_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioIndicator';\n\ntype RadioIndicatorElement = React.ComponentRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\nexport interface RadioIndicatorProps extends PrimitiveSpanProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst RadioIndicator = React.forwardRef<RadioIndicatorElement, RadioIndicatorProps>(\n (props: ScopedProps<RadioIndicatorProps>, forwardedRef) => {\n const { __scopeRadio, forceMount, ...indicatorProps } = props;\n const context = useRadioContext(INDICATOR_NAME, __scopeRadio);\n return (\n <Presence present={forceMount || context.checked}>\n <Primitive.span\n data-state={getState(context.checked)}\n data-disabled={context.disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n />\n </Presence>\n );\n },\n);\n\nRadioIndicator.displayName = INDICATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst BUBBLE_INPUT_NAME = 'RadioBubbleInput';\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface RadioBubbleInputProps extends Omit<InputProps, 'checked'> {}\n\nconst RadioBubbleInput = React.forwardRef<HTMLInputElement, RadioBubbleInputProps>(\n ({ __scopeRadio, ...props }: ScopedProps<RadioBubbleInputProps>, forwardedRef) => {\n const {\n control,\n checked,\n required,\n disabled,\n name,\n value,\n form,\n bubbleInput,\n setBubbleInput,\n hasConsumerStoppedPropagationRef,\n } = useRadioContext(BUBBLE_INPUT_NAME, __scopeRadio);\n\n const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = bubbleInput;\n if (!input) return;\n\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked',\n ) as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n const bubbles = !hasConsumerStoppedPropagationRef.current;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);\n\n const defaultCheckedRef = React.useRef(checked);\n return (\n <Primitive.input\n type=\"radio\"\n aria-hidden\n defaultChecked={defaultCheckedRef.current}\n required={required}\n disabled={disabled}\n name={name}\n value={value}\n form={form}\n {...props}\n tabIndex={-1}\n ref={composedRefs}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n transform: 'translateX(-100%)',\n }}\n />\n );\n },\n);\n\nRadioBubbleInput.displayName = BUBBLE_INPUT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction isFunction(value: unknown): value is (...args: any[]) => any {\n return typeof value === 'function';\n}\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nexport {\n createRadioScope,\n useRadioContext,\n //\n Radio,\n RadioProvider,\n RadioTrigger,\n RadioIndicator,\n RadioBubbleInput,\n};\nexport type { RadioProps, RadioProviderProps, RadioTriggerProps, RadioBubbleInputProps };\n"],
|
|
5
|
+
"mappings": ";;;AAAA,YAAYA,YAAW;AACvB,SAAS,wBAAAC,6BAA4B;AACrC,SAAS,mBAAAC,wBAAuB;AAChC,SAAS,sBAAAC,2BAA0B;AACnC,SAAS,aAAAC,kBAAiB;AAC1B,YAAY,sBAAsB;AAClC,SAAS,mCAAmC;AAC5C,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;;;ACR7B,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAkFtB,SA4FM,UA5FN,KA4FM,YA5FN;AA9EJ,IAAM,aAAa;AAGnB,IAAM,CAAC,oBAAoB,gBAAgB,IAAI,mBAAmB,UAAU;AAkB5E,IAAM,CAAC,mBAAmB,eAAe,IAAI,mBAAsC,UAAU;AAiB7F,SAAS,cAAc,OAAwC;AAC7D,QAAM;AAAA,IACJ;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA;AAAA,IAER;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,SAAS,UAAU,IAAU,eAAmC,IAAI;AAC3E,QAAM,CAAC,aAAa,cAAc,IAAU,eAAkC,IAAI;AAClF,QAAM,mCAAyC,aAAO,KAAK;AAC3D,QAAM,gBAAgB,UAClB,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,QAAQ,MAAM;AAAA;AAAA,IAElC;AAAA;AAEJ,QAAM,UAA6B;AA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,WAEJ;AAAA;AAAA,IAEJ;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;AAW7B,IAAM,4BAAkC,kBAGtC,CAAC,OAAoD,iBAAiB;AACtE,QAAM,EAAE,mBAAmB,GAAG,YAAY,IAAI;AAC9C,QAAM,aAAa,cAAc,iBAAiB;AAClD,SAAO,gBAAAA,KAAC,oBAAkB,GAAG,YAAa,GAAG,aAAa,KAAK,cAAc;AAC/E,CAAC;AAED,0BAA0B,cAAc;AAMxC,IAAMM,kBAAiB;AAMvB,IAAM,sBAA4B;AAAA,EAChC,CAAC,OAA8C,iBAAiB;AAC9D,UAAM,EAAE,mBAAmB,GAAG,eAAe,IAAI;AACjD,UAAM,aAAa,cAAc,iBAAiB;AAClD,WAAO,gBAAAN,KAAC,kBAAgB,GAAG,YAAa,GAAG,gBAAgB,KAAK,cAAc;AAAA,EAChF;AACF;AAEA,oBAAoB,cAAcM;",
|
|
6
|
+
"names": ["React", "composeEventHandlers", "useComposedRefs", "createContextScope", "Primitive", "Fragment", "jsx", "jsxs", "createContextScope", "useComposedRefs", "Primitive", "composeEventHandlers", "INDICATOR_NAME"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-radio-group",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3-rc.1783030075339",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
],
|
|
12
12
|
"sideEffects": false,
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@radix-ui/react-compose-refs": "1.1.3",
|
|
15
14
|
"@radix-ui/primitive": "1.1.4",
|
|
15
|
+
"@radix-ui/react-compose-refs": "1.1.3",
|
|
16
16
|
"@radix-ui/react-direction": "1.1.2",
|
|
17
|
-
"@radix-ui/react-
|
|
18
|
-
"@radix-ui/react-
|
|
17
|
+
"@radix-ui/react-context": "1.2.0-rc.1783030075339",
|
|
18
|
+
"@radix-ui/react-presence": "1.1.7-rc.1783030075339",
|
|
19
19
|
"@radix-ui/react-primitive": "2.1.7",
|
|
20
|
-
"@radix-ui/react-roving-focus": "1.1.14",
|
|
21
20
|
"@radix-ui/react-use-controllable-state": "1.2.3",
|
|
22
21
|
"@radix-ui/react-use-size": "1.1.2",
|
|
22
|
+
"@radix-ui/react-roving-focus": "1.1.15-rc.1783030075339",
|
|
23
23
|
"@radix-ui/react-use-previous": "1.1.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|