import {
ErrorType,
Themeable,
cornerShapeStencil,
createContainer,
} from '@workday/canvas-kit-react/common';
import {FlexProps, mergeStyles} from '@workday/canvas-kit-react/layout';
import {CSProps, calc, createStencil, px2rem} from '@workday/canvas-kit-styling';
import {base, system} from '@workday/canvas-tokens-web';
import {RadioButton} from './RadioButton';
import {RadioLabel} from './RadioLabel';
import {useRadioModel} from './hooks/useRadioModel';
export interface RadioGroupProps extends Themeable, CSProps, FlexProps {
/**
* The type of error associated with the RadioGroup (if applicable).
*/
error?: ErrorType;
}
/**
* Styles for RadioGroup
*/
const radioGroupStencil = createStencil({
extends: cornerShapeStencil,
base: {
[cornerShapeStencil.vars.shape]: system.legacy.shape.lg,
display: 'flex',
flexDirection: 'column',
gap: system.legacy.gap.sm,
padding: `${system.legacy.padding.xs} ${system.legacy.padding.sm}`,
margin: `0 ${calc.negate(base.legacy.size150)}`,
transition: '100ms box-shadow',
width: 'fit-content',
},
modifiers: {
error: {
error: {
boxShadow: `inset 0 0 0 ${px2rem(2)} ${system.legacy.color.brand.border.critical}`,
},
caution: {
boxShadow: `inset 0 0 0 ${px2rem(1)} ${system.legacy.color.brand.focus.caution.inner}, inset 0 0 0 ${px2rem(3)} ${system.legacy.color.brand.border.caution}`,
},
},
},
});
/**
* Use `RadioGroup` to group a collection of `RadioGroup.RadioButton` components under a common `name`.
*
* ```tsx
*
* Deep dish
* Thin
*
* ```
*/
export const RadioGroup = createContainer('div')({
displayName: 'RadioGroup',
modelHook: useRadioModel,
subComponents: {
/**
* `RadioGroup.RadioButton` renders an `` and its associated `