@workday/canvas-kit-preview-react
Version:
Canvas Kit Preview is made up of components that have the full design and a11y review, are part of the DS ecosystem and are approved for use in product. The API's could be subject to change, but not without strong communication and migration strategies.
48 lines (47 loc) • 2.14 kB
JavaScript
import React from 'react';
import { createSubcomponent } from '@workday/canvas-kit-react/common';
import { useRadioModel } from './hooks/useRadioModel';
import { Flex, mergeStyles } from '@workday/canvas-kit-react/layout';
import { RadioInput } from './RadioInput';
import { RadioText } from './RadioText';
import { createStencil } from '@workday/canvas-kit-styling';
import { system } from '@workday/canvas-tokens-web';
const radioLabelStencil = createStencil({
base: { name: "xrlqv", styles: "box-sizing:border-box;align-items:flex-start;min-height:var(--cnvs-sys-space-x6);position:relative;gap:var(--cnvs-sys-space-x3);" }
}, "radio-label-0cca27");
export const RadioLabelContext = React.createContext({});
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
* <RadioGroup name"pizza-crust" value="deep-dish">
* <RadioGroup.Label>
* <RadioGroup.Label.Input value="deep-dish" />
* <RadioGroup.Label.Text>Deep dish</RadioGroup.Label.Text>
* </RadioGroup.Label>
* </RadioGroup>
* ```
*/
Input: RadioInput,
/**
* Use `RadioGroup.Label.Text` within a `RadioGroup.Label` to render the label text portion of a radio button.
*
* ```tsx
* <RadioGroup name"pizza-crust" value="deep-dish">
* <RadioGroup.Label>
* <RadioGroup.Label.Input value="deep-dish" />
* <RadioGroup.Label.Text>Deep dish</RadioGroup.Label.Text>
* </RadioGroup.Label>
* </RadioGroup>
* ```
*/
Text: RadioText,
},
})(({ children, variant, disabled, value, ...elemProps }, Element) => {
return (React.createElement(RadioLabelContext.Provider, { value: { variant, disabled } },
React.createElement(Flex, { as: Element, ...mergeStyles(elemProps, radioLabelStencil({ variant })) }, children)));
});