import React from 'react'; import {ExtractProps, Themeable, createSubcomponent} from '@workday/canvas-kit-react/common'; import {Flex, mergeStyles} from '@workday/canvas-kit-react/layout'; import {CSProps, createStencil} from '@workday/canvas-kit-styling'; import {system} from '@workday/canvas-tokens-web'; import {RadioInput} from './RadioInput'; import {RadioText} from './RadioText'; import {useRadioModel} from './hooks/useRadioModel'; interface RadioLabelContextInterface { disabled?: boolean | undefined; variant?: 'inverse' | undefined; value?: string | number; } export interface RadioLabelProps extends Themeable, CSProps, ExtractProps, RadioLabelContextInterface { /** * The Radio input and label children of RadioLabel */ children?: React.ReactNode; } const radioLabelStencil = createStencil({ base: { alignItems: 'flex-start', minHeight: system.legacy.size.xxxs, position: 'relative', gap: system.legacy.gap.sm, }, }); export const RadioLabelContext = React.createContext({} as RadioLabelContextInterface); export const RadioLabel = createSubcomponent('label')({ displayName: 'Radio.Label', modelHook: useRadioModel, subComponents: { /** * Use `RadioGroup.Label.Input` within a `RadioGroup.Label` to render the input portion of a radio button. * * ```tsx * * * * Deep dish * * * ``` */ Input: RadioInput, /** * Use `RadioGroup.Label.Text` within a `RadioGroup.Label` to render the label text portion of a radio button. * * ```tsx * * * * Deep dish * * * ``` */ Text: RadioText, }, })(({children, variant, disabled, value, ...elemProps}, Element) => { return ( {children} ); });