Fix default props.

new-frontend
Icedream 2023-01-09 02:31:33 +01:00
parent dd773852f9
commit cad0003676
Signed by: icedream
GPG Key ID: 468BBEEBB9EC6AEA
5 changed files with 43 additions and 16 deletions

View File

@ -25,21 +25,21 @@ import { Overlay, Tooltip } from 'react-bootstrap';
import type { IconProp } from '@fortawesome/fontawesome-svg-core'; import type { IconProp } from '@fortawesome/fontawesome-svg-core';
import { FormattedMessage } from './localization'; import { FormattedMessage } from './localization';
const CopyField = ({ function CopyField({
children, children,
copyIcon = 'copy', copyIcon,
icon = null, icon,
}: { }: {
children: string, children: string,
copyIcon?: IconProp, copyIcon?: IconProp,
icon?: IconProp, icon?: IconProp,
}) => { }) {
const [show, setShow] = useState(false); const [show, setShow] = useState(false);
const target = useRef(null); const target = useRef(null);
const textbox = useRef(null); const textbox = useRef(null);
let timer: NodeJS.Timeout = null; let timer: NodeJS.Timeout = null;
function doCopy() { const doCopy = () => {
if (timer !== null) { if (timer !== null) {
clearTimeout(timer); clearTimeout(timer);
} }
@ -52,7 +52,7 @@ const CopyField = ({
setShow(false); setShow(false);
}, 3000); }, 3000);
return false; return false;
} };
return ( return (
<InputGroup> <InputGroup>
@ -83,6 +83,11 @@ const CopyField = ({
</Button> </Button>
</InputGroup> </InputGroup>
); );
}
CopyField.defaultProps = {
copyIcon: 'copy',
icon: null,
}; };
export default CopyField; export default CopyField;

View File

@ -25,10 +25,10 @@ import {
import { FormattedMessage } from './localization'; import { FormattedMessage } from './localization';
export default function DarkToggler({ export default function DarkToggler({
isDarkEnabled = false, isDarkEnabled,
onChangeDarkMode = null, onChangeDarkMode,
disabled = false, disabled,
showLoading = false, showLoading,
}: { }: {
isDarkEnabled?: boolean, isDarkEnabled?: boolean,
onChangeDarkMode?: (value: boolean) => void, onChangeDarkMode?: (value: boolean) => void,
@ -55,3 +55,10 @@ export default function DarkToggler({
</Button> </Button>
); );
} }
DarkToggler.defaultProps = {
isDarkEnabled: false,
onChangeDarkMode: null,
disabled: false,
showLoading: false,
};

View File

@ -23,7 +23,7 @@ import { getDownloadURL } from 'util/api';
import { FormattedMessage } from './localization'; import { FormattedMessage } from './localization';
export default function DownloadButton({ export default function DownloadButton({
icon = 'download', icon,
id, id,
fileName, fileName,
}: { }: {
@ -42,3 +42,7 @@ export default function DownloadButton({
</Button> </Button>
); );
} }
DownloadButton.defaultProps = {
icon: 'download',
};

View File

@ -21,7 +21,7 @@ import React from 'react';
export default function Filter<T, U extends React.ReactNode>({ export default function Filter<T, U extends React.ReactNode>({
items, items,
query = '', query = '',
isCaseSensitive = false, isCaseSensitive,
keys, keys,
output, output,
}: { }: {
@ -50,3 +50,7 @@ export default function Filter<T, U extends React.ReactNode>({
</> </>
); );
} }
Filter.defaultProps = {
isCaseSensitive: false,
};

View File

@ -24,10 +24,10 @@ import { FormattedMessage } from './localization';
import { availableLocales, defaultLocale, localeDescriptions } from '../util/localization'; import { availableLocales, defaultLocale, localeDescriptions } from '../util/localization';
export default function LocaleSwitcher({ export default function LocaleSwitcher({
locale = defaultLocale, locale,
onChangeLocale = null, onChangeLocale,
disabled = false, disabled,
showLoading = false, showLoading,
}: { }: {
locale?: string, locale?: string,
onChangeLocale?: (value: string) => void, onChangeLocale?: (value: string) => void,
@ -76,3 +76,10 @@ export default function LocaleSwitcher({
</DropdownButton> </DropdownButton>
); );
} }
LocaleSwitcher.defaultProps = {
locale: defaultLocale,
onChangeLocale: null,
disabled: false,
showLoading: false,
};