Skip to content

Commit c582d4a

Browse files
authored
Merge pull request #10922 from marmelab/fix-input-label-type
Fix inputs and fields label type
2 parents c78c570 + 468048f commit c582d4a

File tree

8 files changed

+14
-15
lines changed

8 files changed

+14
-15
lines changed

packages/ra-core/src/form/useInput.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactElement, useEffect, useId, FocusEvent } from 'react';
1+
import { useEffect, useId, FocusEvent, ReactNode } from 'react';
22
import {
33
ControllerFieldState,
44
ControllerRenderProps,
@@ -152,8 +152,8 @@ export type InputProps<ValueType = any> = Omit<
152152
format?: (value: ValueType) => any;
153153
id?: string;
154154
isRequired?: boolean;
155-
label?: string | ReactElement | false;
156-
helperText?: string | ReactElement | false;
155+
label?: ReactNode;
156+
helperText?: ReactNode;
157157
name?: string;
158158
onBlur?: (...event: any[]) => void;
159159
onChange?: (...event: any[]) => void;

packages/ra-core/src/i18n/useTranslateLabel.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const TranslateLabel = ({
1313
resource,
1414
}: {
1515
source?: string;
16-
label?: string | false | React.ReactElement;
16+
label?: React.ReactNode;
1717
resource?: string;
1818
}) => {
1919
const translateLabel = useTranslateLabel();

packages/ra-input-rich-text/src/RichTextInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { ReactElement, ReactNode, useEffect } from 'react';
2+
import { ReactNode, useEffect } from 'react';
33
import { FormHelperText } from '@mui/material';
44
import { styled } from '@mui/material/styles';
55
import { Color } from '@tiptap/extension-color';
@@ -289,7 +289,7 @@ export type RichTextInputContentProps = {
289289
className?: string;
290290
editor?: Editor;
291291
error?: any;
292-
helperText?: string | ReactElement | false;
292+
helperText?: ReactNode;
293293
id: string;
294294
isTouched: boolean;
295295
isSubmitted: boolean;

packages/ra-ui-materialui/src/Labeled.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export interface LabeledProps extends StackProps {
101101
fullWidth?: boolean;
102102
htmlFor?: string;
103103
isRequired?: boolean;
104-
label?: string | ReactElement | boolean;
104+
label?: React.ReactNode;
105105
resource?: string;
106106
source?: string;
107107
TypographyProps?: TypographyProps;

packages/ra-ui-materialui/src/field/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactElement } from 'react';
1+
import { ReactNode } from 'react';
22
import { TableCellProps } from '@mui/material/TableCell';
33
import { BaseFieldProps, ExtractRecordPaths, HintedString } from 'ra-core';
44

@@ -38,7 +38,7 @@ export interface FieldProps<
3838
* </List>
3939
* );
4040
*/
41-
label?: string | ReactElement | boolean;
41+
label?: ReactNode;
4242

4343
/**
4444
* Set it to false to disable the click handler on the column header when used inside <Datagrid>.

packages/ra-ui-materialui/src/input/InputHelperText.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { isValidElement, ReactElement } from 'react';
2+
import { isValidElement } from 'react';
33
import { useTranslate, ValidationError, ValidationErrorMessage } from 'ra-core';
44

55
export const InputHelperText = (props: InputHelperTextProps) => {
@@ -33,6 +33,6 @@ export const InputHelperText = (props: InputHelperTextProps) => {
3333
const defaultInnerHTML = { __html: '&#8203;' };
3434

3535
export interface InputHelperTextProps {
36-
helperText?: string | ReactElement | boolean;
36+
helperText?: React.ReactNode;
3737
error?: ValidationErrorMessage;
3838
}

packages/ra-ui-materialui/src/input/LoadingInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export interface LoadingInputProps {
8383
fullWidth?: boolean;
8484
helperText?: React.ReactNode;
8585
margin?: 'normal' | 'none' | 'dense';
86-
label?: string | React.ReactElement | false;
86+
label?: React.ReactNode;
8787
sx?: SxProps<Theme>;
8888
size?: 'medium' | 'small';
8989
timeout?: number;

packages/ra-ui-materialui/src/input/ReferenceArrayInput.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,5 @@ export const ReferenceArrayInput = (props: ReferenceArrayInputProps) => {
9292
const defaultChildren = <AutocompleteArrayInput />;
9393
const defaultOffline = <Offline variant="inline" />;
9494

95-
export interface ReferenceArrayInputProps extends ReferenceArrayInputBaseProps {
96-
label?: string;
97-
}
95+
export interface ReferenceArrayInputProps
96+
extends ReferenceArrayInputBaseProps {}

0 commit comments

Comments
 (0)