refactor: small tweaks and fixes

This commit is contained in:
Carlos Valente
2024-03-06 22:42:20 +01:00
committed by GitHub
parent 8196ea584d
commit d22cc48565
61 changed files with 401 additions and 198 deletions
@@ -91,9 +91,6 @@ export default function TimeInput<T extends string>(props: TimeInputProps<T>) {
(event: KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'Enter') {
inputRef.current?.blur();
validateAndSubmit((event.target as HTMLInputElement).value);
} else if (event.key === 'Tab') {
validateAndSubmit((event.target as HTMLInputElement).value);
}
if (event.key === 'Escape') {
ignoreChange.current = true;
@@ -101,7 +98,7 @@ export default function TimeInput<T extends string>(props: TimeInputProps<T>) {
resetValue();
}
},
[resetValue, validateAndSubmit],
[resetValue],
);
const onBlurHandler = useCallback(
@@ -1,7 +1,7 @@
.emptyContainer {
width: 100%;
text-align: center;
color: $gray-1350;
color: $white-10;
.empty {
width: 100%;
@@ -5,7 +5,7 @@ import EmptyImage from '../../../assets/images/empty.svg?react';
import style from './Empty.module.scss';
interface EmptyProps {
text: string;
text?: string;
style?: CSSProperties;
}
@@ -14,7 +14,7 @@ export default function Empty(props: EmptyProps) {
return (
<div className={style.emptyContainer} {...rest}>
<EmptyImage className={style.empty} />
<span className={style.text}>{text}</span>
{text && <span className={style.text}>{text}</span>}
</div>
);
}
@@ -14,6 +14,7 @@ describe('test forgivingStringToMillis()', () => {
{ value: '1h0m0s', expect: 1000 * 60 * 60 },
{ value: '23h0m0s', expect: 1000 * 60 * 60 * 23 },
{ value: '12h12m12s', expect: 12 * 1000 + 12 * 60 * 1000 + 12 * 1000 * 60 * 60 },
{ value: '12H12M12S', expect: 12 * 1000 + 12 * 60 * 1000 + 12 * 1000 * 60 * 60 },
{ value: '2m', expect: 2 * 60 * 1000 },
{ value: '1h5s', expect: 1000 * 60 * 60 + 1000 * 5 },
{ value: '1h2m', expect: 1000 * 60 * 60 + 1000 * 60 * 2 },
+3 -3
View File
@@ -46,13 +46,13 @@ function checkAmPm(value: string) {
* @param {string} value
*/
function checkMatchers(value: string) {
const hoursMatch = /(\d+)h/.exec(value);
const hoursMatch = /(\d+)h/i.exec(value);
const hoursMatchValue = hoursMatch ? parse(hoursMatch[1]) : 0;
const minutesMatch = /(\d+)m/.exec(value);
const minutesMatch = /(\d+)m/i.exec(value);
const minutesMatchValue = minutesMatch ? parse(minutesMatch[1]) : 0;
const secondsMatch = /(\d+)s/.exec(value);
const secondsMatch = /(\d+)s/i.exec(value);
const secondsMatchValue = secondsMatch ? parse(secondsMatch[1]) : 0;
if (hoursMatchValue > 0 || minutesMatchValue > 0 || secondsMatchValue > 0) {