diff --git a/src/components/Checkbox/Checkbox.scss b/src/components/Checkbox/Checkbox.scss index 22bca52d1..90baf58bb 100644 --- a/src/components/Checkbox/Checkbox.scss +++ b/src/components/Checkbox/Checkbox.scss @@ -4,7 +4,6 @@ $block: '.#{variables.$ns}checkbox'; #{$block} { &__indicator { - flex-shrink: 0; display: inline-block; position: relative; cursor: inherit; diff --git a/src/components/Checkbox/__stories__/Checkbox.stories.tsx b/src/components/Checkbox/__stories__/Checkbox.stories.tsx index c99878492..67d1aed3c 100644 --- a/src/components/Checkbox/__stories__/Checkbox.stories.tsx +++ b/src/components/Checkbox/__stories__/Checkbox.stories.tsx @@ -37,6 +37,15 @@ const LabelTemplate: Story = (args) => ( +
+ +
+ Full + width + content +
+
+
); export const Label = LabelTemplate.bind({}); diff --git a/src/components/ControlLabel/ControlLabel.scss b/src/components/ControlLabel/ControlLabel.scss index c7149b2ae..114c5c714 100644 --- a/src/components/ControlLabel/ControlLabel.scss +++ b/src/components/ControlLabel/ControlLabel.scss @@ -27,7 +27,12 @@ $block: '.#{variables.$ns}control-label'; line-height: 18px; } + &__indicator { + flex-shrink: 0; + } + &__text { + flex-grow: 1; white-space: normal; #{$block}_disabled & { diff --git a/src/components/ControlLabel/ControlLabel.tsx b/src/components/ControlLabel/ControlLabel.tsx index d16e6b5a8..65635690e 100644 --- a/src/components/ControlLabel/ControlLabel.tsx +++ b/src/components/ControlLabel/ControlLabel.tsx @@ -1,4 +1,4 @@ -import React, {forwardRef} from 'react'; +import React, {forwardRef, cloneElement} from 'react'; import {block} from '../utils/cn'; import {Props} from './types'; @@ -24,6 +24,10 @@ export const ControlLabel = forwardRef( }, ref, ) => { + const clonedControl = cloneElement(control, { + className: b('indicator', control.props.className), + }); + return ( ); diff --git a/src/components/ControlLabel/types.ts b/src/components/ControlLabel/types.ts index 0a8f06bcb..df78bbfa6 100644 --- a/src/components/ControlLabel/types.ts +++ b/src/components/ControlLabel/types.ts @@ -1,4 +1,4 @@ -import {PropsWithChildren, ReactNode} from 'react'; +import {PropsWithChildren, ReactElement} from 'react'; import {DOMProps, QAProps} from '../types'; export type Size = 'm' | 'l'; @@ -8,7 +8,7 @@ export type Props = PropsWithChildren<{ title?: string; disabled?: boolean; size?: Size; - control: ReactNode; + control: ReactElement; }> & DOMProps & QAProps; diff --git a/src/components/Radio/Radio.scss b/src/components/Radio/Radio.scss index 8477c38fd..d757fc88b 100644 --- a/src/components/Radio/Radio.scss +++ b/src/components/Radio/Radio.scss @@ -6,7 +6,6 @@ $discMarginLSize: 6px; #{$block} { &__indicator { - flex-shrink: 0; display: inline-block; position: relative; cursor: inherit; diff --git a/src/components/Switch/Switch.scss b/src/components/Switch/Switch.scss index 7410a4063..ddbc3e5ad 100644 --- a/src/components/Switch/Switch.scss +++ b/src/components/Switch/Switch.scss @@ -11,7 +11,6 @@ $block: '.#{variables.$ns}switch'; } &__indicator { - flex-shrink: 0; display: inline-block; position: relative; diff --git a/src/components/Switch/__stories__/Switch.stories.tsx b/src/components/Switch/__stories__/Switch.stories.tsx index 4b997f512..9657ce750 100644 --- a/src/components/Switch/__stories__/Switch.stories.tsx +++ b/src/components/Switch/__stories__/Switch.stories.tsx @@ -34,6 +34,15 @@ const LabelTemplate: Story = (args) => ( +
+ +
+ Full + width + content +
+
+
); export const Label = LabelTemplate.bind({});