Skip to content

Commit

Permalink
Merge pull request #6086 from tdnl/export-ts-types
Browse files Browse the repository at this point in the history
Export TS types
  • Loading branch information
djhi authored Mar 29, 2021
2 parents d56cf09 + 33d2faa commit fdee4e8
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 65 deletions.
4 changes: 2 additions & 2 deletions packages/ra-ui-materialui/src/button/RefreshIconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import IconButton, { IconButtonProps } from '@material-ui/core/IconButton';
import NavigationRefresh from '@material-ui/icons/Refresh';
import { refreshView, useTranslate } from 'ra-core';

const RefreshIconButton: FC<RefreshIconProps> = ({
const RefreshIconButton: FC<RefreshIconButtonProps> = ({
label = 'ra.action.refresh',
icon = defaultIcon,
onClick,
Expand Down Expand Up @@ -51,7 +51,7 @@ interface Props {
onClick?: (e: MouseEvent) => void;
}

export type RefreshIconProps = Props & IconButtonProps;
export type RefreshIconButtonProps = Props & IconButtonProps;

RefreshIconButton.propTypes = {
className: PropTypes.string,
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/button/SaveButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ interface Props {
undoable?: boolean;
}

type SaveButtonProps = Props & ButtonProps;
export type SaveButtonProps = Props & ButtonProps;

SaveButton.propTypes = {
className: PropTypes.string,
Expand Down
46 changes: 32 additions & 14 deletions packages/ra-ui-materialui/src/button/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
import BulkDeleteButton from './BulkDeleteButton';
import BulkDeleteWithConfirmButton from './BulkDeleteWithConfirmButton';
import BulkDeleteWithUndoButton from './BulkDeleteWithUndoButton';
import BulkExportButton from './BulkExportButton';
import BulkDeleteButton, { BulkDeleteButtonProps } from './BulkDeleteButton';
import BulkDeleteWithConfirmButton, {
BulkDeleteWithConfirmButtonProps,
} from './BulkDeleteWithConfirmButton';
import BulkDeleteWithUndoButton, {
BulkDeleteWithUndoButtonProps,
} from './BulkDeleteWithUndoButton';
import BulkExportButton, { BulkExportButtonProps } from './BulkExportButton';
import Button, { ButtonProps } from './Button';
import CloneButton from './CloneButton';
import CreateButton from './CreateButton';
import CloneButton, { CloneButtonProps } from './CloneButton';
import CreateButton, { CreateButtonProps } from './CreateButton';
import DeleteButton, { DeleteButtonProps } from './DeleteButton';
import DeleteWithConfirmButton, {
DeleteWithConfirmButtonProps,
} from './DeleteWithConfirmButton';
import DeleteWithUndoButton, {
DeleteWithUndoButtonProps,
} from './DeleteWithUndoButton';
import EditButton from './EditButton';
import ExportButton from './ExportButton';
import ListButton from './ListButton';
import SaveButton from './SaveButton';
import ShowButton from './ShowButton';
import SortButton from './SortButton';
import RefreshButton from './RefreshButton';
import RefreshIconButton from './RefreshIconButton';
import EditButton, { EditButtonProps } from './EditButton';
import ExportButton, { ExportButtonProps } from './ExportButton';
import ListButton, { ListButtonProps } from './ListButton';
import SaveButton, { SaveButtonProps } from './SaveButton';
import ShowButton, { ShowButtonProps } from './ShowButton';
import SortButton, { SortButtonProps } from './SortButton';
import RefreshButton, { RefreshButtonProps } from './RefreshButton';
import RefreshIconButton, { RefreshIconButtonProps } from './RefreshIconButton';

export type {
BulkDeleteButtonProps,
BulkDeleteWithConfirmButtonProps,
BulkDeleteWithUndoButtonProps,
BulkExportButtonProps,
ButtonProps,
CloneButtonProps,
CreateButtonProps,
DeleteButtonProps,
DeleteWithConfirmButtonProps,
DeleteWithUndoButtonProps,
EditButtonProps,
ExportButtonProps,
ListButtonProps,
SaveButtonProps,
ShowButtonProps,
SortButtonProps,
RefreshButtonProps,
RefreshIconButtonProps,
};

export {
Expand Down
6 changes: 4 additions & 2 deletions packages/ra-ui-materialui/src/form/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import FormInput from './FormInput';
import FormInput, { FormInputProps } from './FormInput';
import SimpleForm, { SimpleFormProps } from './SimpleForm';
import SimpleFormIterator, {
SimpleFormIteratorProps,
} from './SimpleFormIterator';
import TabbedFormTabs from './TabbedFormTabs';
import TabbedFormTabs, { TabbedFormTabsProps } from './TabbedFormTabs';
import Toolbar, { ToolbarProps } from './Toolbar';
import getFormInitialValues from './getFormInitialValues';
import { SimpleFormView, SimpleFormViewProps } from './SimpleFormView';
Expand All @@ -14,8 +14,10 @@ export * from './FormTab';
export * from './FormTabHeader';

export type {
FormInputProps,
SimpleFormProps,
SimpleFormIteratorProps,
TabbedFormTabsProps,
SimpleFormViewProps,
TabbedFormViewProps,
ToolbarProps,
Expand Down
8 changes: 4 additions & 4 deletions packages/ra-ui-materialui/src/input/BooleanInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import sanitizeInputRestProps from './sanitizeInputRestProps';
import InputHelperText from './InputHelperText';
import InputPropTypes from './InputPropTypes';

const BooleanInput: FunctionComponent<
InputProps<SwitchProps> &
Omit<FormGroupProps, 'defaultValue' | 'onChange' | 'onBlur' | 'onFocus'>
> = ({
const BooleanInput: FunctionComponent<BooleanInputProps> = ({
format,
label,
fullWidth,
Expand Down Expand Up @@ -99,4 +96,7 @@ BooleanInput.defaultProps = {
options: {},
};

export type BooleanInputProps = InputProps<SwitchProps> &
Omit<FormGroupProps, 'defaultValue' | 'onChange' | 'onBlur' | 'onFocus'>;

export default BooleanInput;
7 changes: 4 additions & 3 deletions packages/ra-ui-materialui/src/input/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ const getStringFromDate = (value: string | Date) => {
return convertDateToString(new Date(value));
};

const DateInput: FunctionComponent<
InputProps<TextFieldProps> & Omit<TextFieldProps, 'helperText' | 'label'>
> = ({
const DateInput: FunctionComponent<DateInputProps> = ({
format = getStringFromDate,
label,
options,
Expand Down Expand Up @@ -120,4 +118,7 @@ DateInput.defaultProps = {
options: {},
};

export type DateInputProps = InputProps<TextFieldProps> &
Omit<TextFieldProps, 'helperText' | 'label'>;

export default DateInput;
7 changes: 4 additions & 3 deletions packages/ra-ui-materialui/src/input/DateTimeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ const parseDateTime = (value: string) => new Date(value);
/**
* Input component for entering a date and a time with timezone, using the browser locale
*/
const DateTimeInput: FunctionComponent<
InputProps<TextFieldProps> & Omit<TextFieldProps, 'helperText' | 'label'>
> = ({
const DateTimeInput: FunctionComponent<DateTimeInputProps> = ({
format = formatDateTime,
label,
helperText,
Expand Down Expand Up @@ -141,4 +139,7 @@ DateTimeInput.defaultProps = {
options: {},
};

export type DateTimeInputProps = InputProps<TextFieldProps> &
Omit<TextFieldProps, 'helperText' | 'label'>;

export default DateTimeInput;
4 changes: 3 additions & 1 deletion packages/ra-ui-materialui/src/input/ImageInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const useStyles = makeStyles(
{ name: 'RaImageInput' }
);

const ImageInput = (props: FileInputProps & InputProps<FileInputOptions>) => {
const ImageInput = (props: ImageInputProps) => {
const classes = useStyles(props);

return (
Expand All @@ -51,4 +51,6 @@ const ImageInput = (props: FileInputProps & InputProps<FileInputOptions>) => {
);
};

export type ImageInputProps = FileInputProps & InputProps<FileInputOptions>;

export default ImageInput;
4 changes: 2 additions & 2 deletions packages/ra-ui-materialui/src/input/InputHelperText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import * as React from 'react';
import { FunctionComponent } from 'react';
import { useTranslate, ValidationError, ValidationErrorMessage } from 'ra-core';

interface Props {
export interface InputHelperTextProps {
helperText?: string | boolean;
error?: ValidationErrorMessage;
touched: boolean;
}

const InputHelperText: FunctionComponent<Props> = ({
const InputHelperText: FunctionComponent<InputHelperTextProps> = ({
helperText,
touched,
error,
Expand Down
7 changes: 4 additions & 3 deletions packages/ra-ui-materialui/src/input/RadioButtonGroupInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ const useStyles = makeStyles(
*
* The object passed as `options` props is passed to the material-ui <RadioButtonGroup> component
*/
const RadioButtonGroupInput: FunctionComponent<
ChoicesInputProps<RadioGroupProps> & FormControlProps
> = props => {
const RadioButtonGroupInput: FunctionComponent<RadioButtonGroupInputProps> = props => {
const {
choices = [],
classes: classesOverride,
Expand Down Expand Up @@ -219,4 +217,7 @@ RadioButtonGroupInput.defaultProps = {
translateChoice: true,
};

export type RadioButtonGroupInputProps = ChoicesInputProps<RadioGroupProps> &
FormControlProps;

export default RadioButtonGroupInput;
8 changes: 4 additions & 4 deletions packages/ra-ui-materialui/src/input/ResettableTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import { ClassesOverride } from '../types';
/**
* An override of the default Material-UI TextField which is resettable
*/
function ResettableTextField(
props: InputProps<ResettableTextFieldProps & TextFieldProps>
) {
function ResettableTextField(props: ResettableTextFieldProps) {
const {
classes: classesOverride,
clearAlwaysVisible,
Expand Down Expand Up @@ -213,10 +211,12 @@ ResettableTextField.propTypes = {
value: PropTypes.any.isRequired,
};

interface ResettableTextFieldProps {
interface Props {
classes?: ClassesOverride<typeof useStyles>;
clearAlwaysVisible?: boolean;
resettable?: boolean;
}

export type ResettableTextFieldProps = InputProps<Props & TextFieldProps>;

export default ResettableTextField;
7 changes: 4 additions & 3 deletions packages/ra-ui-materialui/src/input/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ const useStyles = makeStyles(
{ name: 'RaSearchInput' }
);

const SearchInput: FunctionComponent<
InputProps<TextFieldProps> & Omit<TextFieldProps, 'label' | 'helperText'>
> = props => {
const SearchInput: FunctionComponent<SearchInputProps> = props => {
const { classes: classesOverride, ...rest } = props;
const translate = useTranslate();
const classes = useStyles(props);
Expand Down Expand Up @@ -53,4 +51,7 @@ SearchInput.propTypes = {
classes: PropTypes.object,
};

export type SearchInputProps = InputProps<TextFieldProps> &
Omit<TextFieldProps, 'label' | 'helperText'>;

export default SearchInput;
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/input/SelectArrayInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ const SelectArrayInput: FunctionComponent<SelectArrayInputProps> = props => {
);
};

interface SelectArrayInputProps
export interface SelectArrayInputProps
extends Omit<ChoicesProps, 'choices'>,
Omit<InputProps<SelectProps>, 'source'>,
Omit<
Expand Down
8 changes: 4 additions & 4 deletions packages/ra-ui-materialui/src/input/SelectInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,7 @@ const useStyles = makeStyles(
* <SelectInput source="gender" choices={choices} disableValue="not_available" />
*
*/
const SelectInput: FunctionComponent<
ChoicesInputProps<TextFieldProps> &
Omit<TextFieldProps, 'label' | 'helperText'>
> = props => {
const SelectInput: FunctionComponent<SelectInputProps> = props => {
const {
allowEmpty,
choices = [],
Expand Down Expand Up @@ -313,4 +310,7 @@ SelectInput.defaultProps = {
disableValue: 'disabled',
};

export type SelectInputProps = ChoicesInputProps<TextFieldProps> &
Omit<TextFieldProps, 'label' | 'helperText'>;

export default SelectInput;
62 changes: 44 additions & 18 deletions packages/ra-ui-materialui/src/input/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ArrayInput from './ArrayInput';
import ArrayInput, { ArrayInputProps } from './ArrayInput';
import AutocompleteArrayInput, {
AutocompleteArrayInputProps,
} from './AutocompleteArrayInput';
Expand All @@ -7,24 +7,32 @@ import BooleanInput from './BooleanInput';
import CheckboxGroupInput, {
CheckboxGroupInputProps,
} from './CheckboxGroupInput';
import DateInput from './DateInput';
import DateTimeInput from './DateTimeInput';
import FileInput from './FileInput';
import ImageInput from './ImageInput';
import InputHelperText from './InputHelperText';
import DateInput, { DateInputProps } from './DateInput';
import DateTimeInput, { DateTimeInputProps } from './DateTimeInput';
import FileInput, { FileInputProps } from './FileInput';
import ImageInput, { ImageInputProps } from './ImageInput';
import InputHelperText, { InputHelperTextProps } from './InputHelperText';
import InputPropTypes from './InputPropTypes';
import Labeled from './Labeled';
import NullableBooleanInput from './NullableBooleanInput';
import NumberInput from './NumberInput';
import PasswordInput from './PasswordInput';
import RadioButtonGroupInput from './RadioButtonGroupInput';
import ReferenceArrayInput from './ReferenceArrayInput';
import ReferenceInput from './ReferenceInput';
import ResettableTextField from './ResettableTextField';
import SearchInput from './SearchInput';
import SelectArrayInput from './SelectArrayInput';
import SelectInput from './SelectInput';
import TextInput from './TextInput';
import Labeled, { LabeledProps } from './Labeled';
import NullableBooleanInput, {
NullableBooleanInputProps,
} from './NullableBooleanInput';
import NumberInput, { NumberInputProps } from './NumberInput';
import PasswordInput, { PasswordInputProps } from './PasswordInput';
import RadioButtonGroupInput, {
RadioButtonGroupInputProps,
} from './RadioButtonGroupInput';
import ReferenceArrayInput, {
ReferenceArrayInputProps,
} from './ReferenceArrayInput';
import ReferenceInput, { ReferenceInputProps } from './ReferenceInput';
import ResettableTextField, {
ResettableTextFieldProps,
} from './ResettableTextField';
import SearchInput, { SearchInputProps } from './SearchInput';
import SelectArrayInput, { SelectArrayInputProps } from './SelectArrayInput';
import SelectInput, { SelectInputProps } from './SelectInput';
import TextInput, { TextInputProps } from './TextInput';
import sanitizeInputRestProps from './sanitizeInputRestProps';
export * from './TranslatableInputs';
export * from './TranslatableInputsTabContent';
Expand Down Expand Up @@ -59,7 +67,25 @@ export {
};

export type {
ArrayInputProps,
AutocompleteInputProps,
AutocompleteArrayInputProps,
CheckboxGroupInputProps,
DateInputProps,
DateTimeInputProps,
FileInputProps,
ImageInputProps,
InputHelperTextProps,
LabeledProps,
NullableBooleanInputProps,
NumberInputProps,
PasswordInputProps,
RadioButtonGroupInputProps,
ReferenceArrayInputProps,
ReferenceInputProps,
ResettableTextFieldProps,
SearchInputProps,
SelectArrayInputProps,
SelectInputProps,
TextInputProps,
};

0 comments on commit fdee4e8

Please sign in to comment.