From fe40f4a14efb688634fcad35778963ef2f725574 Mon Sep 17 00:00:00 2001 From: adamviktora <84135613+adamviktora@users.noreply.github.com> Date: Tue, 9 Jan 2024 17:59:38 +0100 Subject: [PATCH] Add support for isLabelWrapped and component in Checkbox / Radio (#9830) * feat(Checkbox): add support for isLabelWrapped and isLabelBeforeButton * feat(Radio): add support for component * refactor(Radio/Checkbox): check isLabelBeforeButton only once * feat(Radio/Checkbox): add support for component === "label" behaving the same as isLabelWrapped * docs(Radio/Checkbox): update props description * test(Checkbox): add unit tests * test(Checkbox): unit test * test(Radio): unit tests --- .../src/components/Checkbox/Checkbox.tsx | 92 +++++++++++++------ .../Checkbox/__tests__/Checkbox.test.tsx | 41 +++++++++ .../react-core/src/components/Radio/Radio.tsx | 77 ++++++++-------- .../components/Radio/__tests__/Radio.test.tsx | 41 +++++++++ 4 files changed, 184 insertions(+), 67 deletions(-) diff --git a/packages/react-core/src/components/Checkbox/Checkbox.tsx b/packages/react-core/src/components/Checkbox/Checkbox.tsx index 699bbe3d3ff..93b9816e4c0 100644 --- a/packages/react-core/src/components/Checkbox/Checkbox.tsx +++ b/packages/react-core/src/components/Checkbox/Checkbox.tsx @@ -8,10 +8,16 @@ import { ASTERISK } from '../../helpers/htmlConstants'; export interface CheckboxProps extends Omit, 'type' | 'onChange' | 'disabled' | 'label'>, OUIAProps { - /** Additional classes added to the checkbox. */ + /** Additional classes added to the checkbox wrapper. This wrapper will be div element by default. It will be a label element if + * isLabelWrapped is true, or it can be overridden by any element specified in the component prop. + */ className?: string; - /** Additional classed added to the radio input */ + /** Additional classes added to the checkbox input. */ inputClassName?: string; + /** Flag to indicate whether the checkbox wrapper element is a