[ESLint] Prefer named exports (#427)
This commit is contained in:
@@ -13,8 +13,6 @@ interface IProps extends CheckboxProps {
|
||||
label?: string;
|
||||
}
|
||||
|
||||
const CheckboxInput: React.FC<IProps> = ({ label, sx, ...rest }) => (
|
||||
export const CheckboxInput: React.FC<IProps> = ({ label, sx, ...rest }) => (
|
||||
<FormControlLabel control={<Checkbox {...rest} />} label={label} sx={sx} />
|
||||
);
|
||||
|
||||
export default CheckboxInput;
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { CircularProgress, IconButton, IconButtonProps } from '@mui/material';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
interface IProps extends Omit<IconButtonProps, 'onClick'> {
|
||||
loading?: boolean;
|
||||
onClick: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => Promise<any>;
|
||||
}
|
||||
|
||||
const LoadingIconButton = ({ onClick, children, loading: iLoading, ...rest }: IProps) => {
|
||||
const [sLoading, setLoading] = useState(false);
|
||||
const loading = sLoading || iLoading;
|
||||
|
||||
const handleClick = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
|
||||
setLoading(true);
|
||||
onClick(e).finally(() => setLoading(false));
|
||||
};
|
||||
|
||||
return (
|
||||
<IconButton disabled={loading} {...rest} onClick={handleClick}>
|
||||
{loading ? <CircularProgress size={24} /> : children}
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
LoadingIconButton.defaultProps = {
|
||||
loading: false,
|
||||
};
|
||||
|
||||
export default LoadingIconButton;
|
||||
@@ -13,8 +13,6 @@ export interface RadioInputProps extends RadioProps {
|
||||
label?: string;
|
||||
}
|
||||
|
||||
const RadioInput: React.FC<RadioInputProps> = ({ label, sx, ...rest }) => (
|
||||
export const RadioInput: React.FC<RadioInputProps> = ({ label, sx, ...rest }) => (
|
||||
<FormControlLabel control={<Radio {...rest} />} label={label} sx={sx} />
|
||||
);
|
||||
|
||||
export default RadioInput;
|
||||
|
||||
@@ -9,17 +9,15 @@
|
||||
import ArrowDownward from '@mui/icons-material/ArrowDownward';
|
||||
import ArrowUpward from '@mui/icons-material/ArrowUpward';
|
||||
import { memo } from 'react';
|
||||
import RadioInput, { RadioInputProps } from '@/components/atoms/RadioInput';
|
||||
import { RadioInput, RadioInputProps } from '@/components/atoms/RadioInput';
|
||||
|
||||
interface IProps extends RadioInputProps {
|
||||
sortDescending?: boolean | null | undefined;
|
||||
}
|
||||
|
||||
const SortRadioInput = memo(({ sortDescending, ...rest }: IProps) => (
|
||||
export const SortRadioInput = memo(({ sortDescending, ...rest }: IProps) => (
|
||||
<RadioInput
|
||||
checkedIcon={sortDescending ? <ArrowDownward color="primary" /> : <ArrowUpward color="primary" />}
|
||||
{...rest}
|
||||
/>
|
||||
));
|
||||
|
||||
export default SortRadioInput;
|
||||
|
||||
@@ -28,7 +28,7 @@ export interface ThreeStateCheckboxProps extends Omit<CheckboxProps, 'checked' |
|
||||
* When checked is false, checkbox contains cross
|
||||
* When checked is null or undefined, checkbox is empty
|
||||
*/
|
||||
const ThreeStateCheckbox: React.FC<ThreeStateCheckboxProps> = ({ checked, onChange, ...rest }) => {
|
||||
export const ThreeStateCheckbox: React.FC<ThreeStateCheckboxProps> = ({ checked, onChange, ...rest }) => {
|
||||
const handleChange = useCallback(() => {
|
||||
if (onChange) {
|
||||
const newState = nextState(checked);
|
||||
@@ -46,4 +46,3 @@ const ThreeStateCheckbox: React.FC<ThreeStateCheckboxProps> = ({ checked, onChan
|
||||
/>
|
||||
);
|
||||
};
|
||||
export default ThreeStateCheckbox;
|
||||
|
||||
@@ -8,14 +8,12 @@
|
||||
|
||||
import { FormControlLabel } from '@mui/material';
|
||||
import React from 'react';
|
||||
import ThreeStateCheckbox, { ThreeStateCheckboxProps } from '@/components/atoms/ThreeStateCheckbox';
|
||||
import { ThreeStateCheckbox, ThreeStateCheckboxProps } from '@/components/atoms/ThreeStateCheckbox';
|
||||
|
||||
interface IProps extends ThreeStateCheckboxProps {
|
||||
label?: string;
|
||||
}
|
||||
|
||||
const ThreeStateCheckboxInput: React.FC<IProps> = ({ label, sx, ...rest }) => (
|
||||
export const ThreeStateCheckboxInput: React.FC<IProps> = ({ label, sx, ...rest }) => (
|
||||
<FormControlLabel control={<ThreeStateCheckbox {...rest} />} label={label} sx={sx} />
|
||||
);
|
||||
|
||||
export default ThreeStateCheckboxInput;
|
||||
|
||||
Reference in New Issue
Block a user