Skip to content

Commit 83e6c1e

Browse files
committed
fix(Text): types
1 parent 63cf53a commit 83e6c1e

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

.changeset/bright-rabbits-walk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Allow text wrapping in labels.

src/components/content/Paragraph.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ export interface CubeParagraphProps
2222
extends CubeTextProps,
2323
ContainerStyleProps {}
2424

25-
export const Paragraph = forwardRef(function Paragraph(
26-
props: CubeParagraphProps,
27-
ref,
28-
) {
29-
const styles = extractStyles(props, STYLE_PROPS, DEFAULT_STYLES);
25+
export const Paragraph = forwardRef<HTMLElement, CubeParagraphProps>(
26+
function Paragraph(props, ref) {
27+
const styles = extractStyles(props, STYLE_PROPS, DEFAULT_STYLES);
3028

31-
return <Text as="p" qa="Paragraph" {...props} ref={ref} styles={styles} />;
32-
});
29+
return <Text as="p" qa="Paragraph" {...props} ref={ref} styles={styles} />;
30+
},
31+
);

src/components/content/Text.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { CSSProperties, forwardRef } from 'react';
1+
import {
2+
CSSProperties,
3+
forwardRef,
4+
ForwardRefExoticComponent,
5+
RefAttributes,
6+
} from 'react';
27

38
import {
49
AllBaseProps,
@@ -141,23 +146,28 @@ const PlaceholderText = tasty(Text, {
141146
},
142147
});
143148

144-
const _Text = Object.assign(Text, {
145-
Minor: MinorText,
146-
Danger: DangerText,
147-
Success: SuccessText,
148-
Strong: StrongText,
149-
Emphasis: EmphasisText,
150-
Selection: SelectionText,
151-
Placeholder: PlaceholderText,
152-
}) as typeof Text & {
149+
export interface TextComponent
150+
extends ForwardRefExoticComponent<
151+
CubeTextProps & RefAttributes<HTMLElement>
152+
> {
153153
Minor: typeof MinorText;
154154
Danger: typeof DangerText;
155155
Success: typeof SuccessText;
156156
Strong: typeof StrongText;
157157
Emphasis: typeof EmphasisText;
158158
Selection: typeof SelectionText;
159159
Placeholder: typeof PlaceholderText;
160-
};
160+
}
161+
162+
const _Text: TextComponent = Object.assign(Text, {
163+
Minor: MinorText,
164+
Danger: DangerText,
165+
Success: SuccessText,
166+
Strong: StrongText,
167+
Emphasis: EmphasisText,
168+
Selection: SelectionText,
169+
Placeholder: PlaceholderText,
170+
});
161171

162172
_Text.displayName = 'Text';
163173

src/components/form/Label.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const INLINE_LABEL_STYLES: Styles = {
5454
'': '#dark-02',
5555
invalid: '#danger-text',
5656
},
57-
whiteSpace: 'nowrap',
5857
} as const;
5958

6059
export const LABEL_STYLES: Styles = {
@@ -67,7 +66,6 @@ export const LABEL_STYLES: Styles = {
6766
'': '#dark',
6867
invalid: '#danger-text',
6968
},
70-
whiteSpace: 'nowrap',
7169
width: {
7270
'': 'initial',
7371
side: '($label-width, initial)',

0 commit comments

Comments
 (0)