Skip to content

Commit

Permalink
fix: lint and typescript errors
Browse files Browse the repository at this point in the history
affects: @medly-components/core, @medly-components/forms
  • Loading branch information
gmukul01 committed Jun 17, 2024
1 parent bb23bd5 commit 26970ab
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import getMaskedValue from './getMaskedValue';

describe('getMaskedValue function', () => {

// @ts-expect-error
const maskedValue = (value: string, selectionStart?: number, data?: string | null = null) =>
// @ts-expect-error
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/components/TextField/getMaskedValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export const getMaskedValue = (event: React.ChangeEvent<HTMLInputElement>, mask:

const specialCharsRegex = /[^a-zA-Z0-9]/g, //NOSONAR
{ value, selectionStart } = event.target;
//TODO: Need to remove this if, when we handle masking when user deletes from the middle of the text
if (selectionStart !== null && selectionStart < value.length && value.length !== mask.length) {

//TODO: Need to remove this if, when we handle masking when user deletes from the middle of the text
if (selectionStart !== null && selectionStart < value.length && value.length !== mask.length) {
// @ts-expect-error
maskedValue = `${value.slice(0, selectionStart)}${event.nativeEvent?.data === null ? ' ' : ''}${value.slice(selectionStart)}`;
return { maskedValue, selectionStart: specialCharsRegex.test(value[selectionStart]) ? selectionStart : selectionStart + 1 };
return { maskedValue, selectionStart: specialCharsRegex.test(value[selectionStart]) ? selectionStart : selectionStart + 1 };
} else {
maskedValue = value
.replace(specialCharsRegex, '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ export const Component: FC<TimePickerPopupProps> = ({ value, onChange, onReset,
const minutes = Number(time[1]);
const period = hour < 12 ? 0 : 1;
const height = (hourRef.current?.scrollHeight || 1) / 16;
hourRef.current?.scrollTo({ top: (hour % 12) * height, behavior: 'instant' as ScrollBehavior });
minutesRef.current?.scrollTo({ top: minutes * height, behavior: 'instant' as ScrollBehavior });
periodRef.current?.scrollTo({ top: period * height, behavior: 'instant' as ScrollBehavior });
// @ts-ignore
hourRef.current?.scrollTo({ top: (hour % 12) * height, behavior: 'instant' });
// @ts-ignore
minutesRef.current?.scrollTo({ top: minutes * height, behavior: 'instant' });
// @ts-ignore
periodRef.current?.scrollTo({ top: period * height, behavior: 'instant' });
}
}, [open, value]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,12 +669,12 @@ exports[`TimePicker should render properly 1`] = `
-moz-scroll-snap-align: center;
-ms-scroll-snap-align: center;
scroll-snap-align: center;
-webkit-transition: all 200ms ease-in-ease-out;
transition: all 200ms ease-in-ease-out;
font-size: 1.4rem;
font-weight: 400;
line-height: 2.2rem;
color: #546A7F;
-webkit-transition: all 200ms ease-in-ease-out;
transition: all 200ms ease-in-ease-out;
}
.c19:hover {
Expand All @@ -701,12 +701,12 @@ exports[`TimePicker should render properly 1`] = `
-moz-scroll-snap-align: center;
-ms-scroll-snap-align: center;
scroll-snap-align: center;
-webkit-transition: all 200ms ease-in-ease-out;
transition: all 200ms ease-in-ease-out;
font-size: 1.6rem;
font-weight: 600;
line-height: 2.6rem;
color: #3872D2;
-webkit-transition: all 200ms ease-in-ease-out;
transition: all 200ms ease-in-ease-out;
}
.c20:hover {
Expand Down

0 comments on commit 26970ab

Please sign in to comment.