Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | export const castEventToInt = ( event: React.ChangeEvent<HTMLInputElement>, fallbackValue: number ): number => { const el = event && event.currentTarget; let value = parseInt(el.value, 10); Iif (!el.value || Number.isNaN(value)) { value = fallbackValue; } Iif (value !== undefined && el && el.type === "number") { Iif (value && (!el.step || el.step === "1")) { value = Math.round(value); } Iif (typeof el.min !== "undefined" && value < Number(el.min)) { const min = parseInt(el.min); Iif (!Number.isNaN(min)) { return min; } } Iif (typeof el.max !== "undefined" && value > Number(el.max)) { const max = parseInt(el.max); Iif (!Number.isNaN(max)) { return max; } } } return value; }; export const castEventToFloat = ( event: React.ChangeEvent<HTMLInputElement>, fallbackValue: number ): number => { const el = event && event.currentTarget; let value = parseFloat(el.value); Iif (!el.value || Number.isNaN(value)) { value = fallbackValue; } Iif (value !== undefined && el && el.type === "number") { Iif (value && (!el.step || el.step === "1")) { value = Math.round(value); } Iif (typeof el.min !== "undefined" && value < Number(el.min)) { const min = parseFloat(el.min); Iif (!Number.isNaN(min)) { return min; } } Iif (typeof el.max !== "undefined" && value > Number(el.max)) { const max = parseFloat(el.max); Iif (!Number.isNaN(max)) { return max; } } } return value; }; export const castEventToBool = ( event: React.ChangeEvent<HTMLInputElement> ): boolean => { const el = event && event.currentTarget; Iif (el && el.type === "checkbox") { return el.checked; } return false; }; |