-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7dbca7f
commit fdbeb07
Showing
19 changed files
with
169 additions
and
205 deletions.
There are no files selected for viewing
14 changes: 0 additions & 14 deletions
14
packages/web-ui/src/components/BaseRadioGroup/BaseRadioGroup.context.ts
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
packages/web-ui/src/components/BaseRadioGroup/BaseRadioGroup.props.ts
This file was deleted.
Oops, something went wrong.
112 changes: 0 additions & 112 deletions
112
packages/web-ui/src/components/BaseRadioGroup/BaseRadioGroup.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export { FormFieldGroup } from './FormFieldGroup'; | ||
export type { FormFieldGroupProps } from './FormFieldGroup.props'; | ||
export { | ||
FormFieldGroupContext, | ||
FormFieldGroupProvider, | ||
useFormFieldGroup, | ||
} from './FormFieldGroup.context'; | ||
export type { FormFieldGroupContextValue } from './FormFieldGroup.context'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 26 additions & 5 deletions
31
packages/web-ui/src/components/RadioGridGroup/RadioGridGroup.props.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
import { BaseRadioGroupProps } from '../BaseRadioGroup'; | ||
import { StackProps } from '../Stack'; | ||
import { RadioGridGroupRootProps } from './RadioGridGroupRoot.props'; | ||
|
||
export interface RadioGridGroupProps extends Omit<BaseRadioGroupProps, 'direction'> { | ||
/** Sets the number of columns to display the contents in. */ | ||
columns?: StackProps['spacing']; | ||
import { FormFieldGroupProps } from '../FormFieldGroup'; | ||
|
||
export interface RadioGridGroupProps | ||
extends Pick< | ||
RadioGridGroupRootProps, | ||
'columns' | 'loop' | 'defaultValue' | 'value' | 'onValueChange' | 'required' | ||
>, | ||
Pick< | ||
FormFieldGroupProps, | ||
| 'className' | ||
| 'name' | ||
| 'disabled' | ||
| 'label' | ||
| 'helperText' | ||
| 'helperTextPosition' | ||
| 'showHelperTextIcon' | ||
| 'error' | ||
| 'errorMessage' | ||
| 'showErrorMessageIcon' | ||
> { | ||
/** | ||
* Set the container width of the RadioGroup children, independent to the width of the | ||
* parent RadioGroup. | ||
*/ | ||
contentWidth?: RadioGridGroupRootProps['width']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/web-ui/src/components/RadioGridGroup/RadioGridGroupRoot.props.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { type RadioGroupProps as RadixRadioGroupProps } from '@radix-ui/react-radio-group'; | ||
|
||
import { BoxProps } from '../Box'; | ||
import { StackProps } from '../Stack'; | ||
|
||
export interface RadioGridGroupRootProps extends Omit<RadixRadioGroupProps, 'dir' | 'orientation'> { | ||
/** Sets the number of columns to display the contents in. */ | ||
columns?: StackProps['spacing']; // TODO: use responsive CSS classes to implement this | ||
width?: BoxProps['width']; | ||
} |
53 changes: 53 additions & 0 deletions
53
packages/web-ui/src/components/RadioGridGroup/RadioGridGroupRoot.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as React from 'react'; | ||
|
||
import clsx from 'clsx'; | ||
|
||
import { Root } from '@radix-ui/react-radio-group'; | ||
|
||
import type { RadioGridGroupProps } from './RadioGridGroup.props'; | ||
|
||
import { Box } from '../Box'; | ||
|
||
import { getColumns } from '../../helpers'; | ||
import type { PropsWithSx } from '../../types'; | ||
import { withGlobalPrefix } from '../../utils'; | ||
|
||
const componentName = 'RadioGridGroupRoot'; | ||
const componentClassName = withGlobalPrefix(componentName); | ||
|
||
/** | ||
* The `RadioGridGroup` provides an accessible way to group and control a set | ||
* of `Radio` or `RadioTile` components, displayed in a grid layout, allowing | ||
* the user to select one option from a set. For displaying radios in a column | ||
* or row, please use the `RadioGroup` component. The `RadioGridGroup` is | ||
* responsible for handling the value, helper text, error state, error message, | ||
* and disabled state, as well as determining the presentation and selection of | ||
* the items in the list. Follows the [WAI-ARIA Radio Group Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/radio/) for radio groups not contained in a toolbar. | ||
*/ | ||
export const RadioGridGroupRoot = React.forwardRef< | ||
HTMLDivElement, | ||
PropsWithSx<RadioGridGroupProps> | ||
>(({ id, disabled, children, width, columns = 2, className, ...props }, ref) => { | ||
return ( | ||
<Root | ||
ref={ref} | ||
asChild | ||
{...props} | ||
disabled={disabled} | ||
id={id} | ||
className={clsx(componentClassName, className)} | ||
> | ||
<Box | ||
display="grid" | ||
gap={2} | ||
gridTemplateColumns={getColumns(columns)} | ||
minWidth="fit-content" | ||
width={width} | ||
> | ||
{children} | ||
</Box> | ||
</Root> | ||
); | ||
}); | ||
|
||
RadioGridGroupRoot.displayName = componentName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export { RadioGridGroup } from './RadioGridGroup'; | ||
export type { RadioGridGroupProps } from './RadioGridGroup.props'; | ||
export { RadioGridGroupRoot } from './RadioGridGroupRoot'; | ||
export type { RadioGridGroupRootProps } from './RadioGridGroupRoot.props'; |
Oops, something went wrong.