Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RA-OSS-20 - Some Inputs with choices in their props do not accept ReadonlyArray<T> #9162

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/ra-core/src/form/useChoices.tsx
Expand Up @@ -12,8 +12,8 @@ export type OptionTextElement = ReactElement<{
export type OptionTextFunc = (choice: any) => React.ReactNode;
export type OptionText = OptionTextElement | OptionTextFunc | string;

export interface ChoicesProps {
choices?: any[];
export interface ChoicesProps<T> {
choices?: T[];
isFetching?: boolean;
isLoading?: boolean;
optionValue?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/field/SelectField.tsx
Expand Up @@ -148,6 +148,6 @@ export const SelectField = genericMemo(SelectFieldImpl);

export interface SelectFieldProps<
RecordType extends Record<string, unknown> = Record<string, any>
> extends ChoicesProps,
> extends ChoicesProps<any>,
FieldProps<RecordType>,
Omit<TypographyProps, 'textAlign'> {}
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/input/AutocompleteInput.tsx
Expand Up @@ -682,7 +682,7 @@ export interface AutocompleteInputProps<
DisableClearable extends boolean | undefined = false,
SupportCreate extends boolean | undefined = false
> extends Omit<CommonInputProps, 'source'>,
ChoicesProps,
ChoicesProps<any>,
UseSuggestionsOptions,
Omit<SupportCreateSuggestionOptions, 'handleChange' | 'optionText'>,
Omit<
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/input/CheckboxGroupInput.tsx
Expand Up @@ -284,7 +284,7 @@ CheckboxGroupInput.propTypes = {
};

export type CheckboxGroupInputProps = Omit<CommonInputProps, 'source'> &
ChoicesProps &
ChoicesProps<any> &
CheckboxProps &
FormControlProps & {
options?: CheckboxProps;
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/input/DatagridInput.tsx
Expand Up @@ -160,7 +160,7 @@ export const DatagridInput = (props: DatagridInputProps) => {
};

export type DatagridInputProps = Omit<CommonInputProps, 'source'> &
ChoicesProps &
ChoicesProps<any> &
Omit<SupportCreateSuggestionOptions, 'handleChange'> &
DatagridProps & {
children?: ReactNode;
Expand Down
Expand Up @@ -269,7 +269,7 @@ const sanitizeRestProps = ({
}: any) => sanitizeInputRestProps(rest);

export type RadioButtonGroupInputProps = Omit<CommonInputProps, 'source'> &
ChoicesProps &
ChoicesProps<any> &
FormControlProps &
RadioGroupProps & {
options?: RadioGroupProps;
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/input/SelectArrayInput.tsx
Expand Up @@ -358,7 +358,7 @@ export const SelectArrayInput = (props: SelectArrayInputProps) => {
);
};

export type SelectArrayInputProps = ChoicesProps &
export type SelectArrayInputProps = ChoicesProps<any> &
Omit<SupportCreateSuggestionOptions, 'handleChange'> &
Omit<CommonInputProps, 'source'> &
Omit<FormControlProps, 'defaultValue' | 'onBlur' | 'onChange'> & {
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/input/SelectInput.tsx
Expand Up @@ -423,7 +423,7 @@ const StyledResettableTextField = styled(ResettableTextField, {
}));

export type SelectInputProps = Omit<CommonInputProps, 'source'> &
ChoicesProps &
ChoicesProps<any> &
Omit<SupportCreateSuggestionOptions, 'handleChange'> &
Omit<TextFieldProps, 'label' | 'helperText' | 'classes' | 'onChange'> & {
disableValue?: string;
Expand Down