@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
17 lines • 894 B
JavaScript
import cl from "clsx";
import { containsReadMore, useFormField, } from "../useFormField.js";
/**
* Handles props for Fieldset in context with parent Fieldset.
*/
export const useFieldset = (props, legendId) => {
const formField = useFormField(props, "fieldset");
return Object.assign(Object.assign({}, formField), { inputProps: {
// Having both legend and description in labelledby seems to work best, ref. https://mortentollefsen.no/demo/radio-description.html
"aria-labelledby": props["aria-labelledby"] ||
cl(legendId, {
[formField.inputDescriptionId]: props.description && !containsReadMore(props.description),
}),
// We don't include errorId in labelledby/describedby on the fieldset, because it will be included on each input inside.
} });
};
//# sourceMappingURL=useFieldset.js.map