(input: string, state: NumberState)
| 3102 | } |
| 3103 | |
| 3104 | const defaultFloatProcessor = (input: string, state: NumberState) => { |
| 3105 | if (input === "." && state.value.includes(".")) { |
| 3106 | return Effect.succeed(Action.Beep()) |
| 3107 | } |
| 3108 | if (state.value.length === 0 && input === "-") { |
| 3109 | return Effect.succeed(Action.NextFrame({ |
| 3110 | state: { ...state, value: "-", error: Option.none() } |
| 3111 | })) |
| 3112 | } |
| 3113 | |
| 3114 | const parsed = globalThis.Number.parseFloat(state.value + input) |
| 3115 | if (globalThis.Number.isNaN(parsed)) { |
| 3116 | return Effect.succeed(Action.Beep()) |
| 3117 | } else { |
| 3118 | return Effect.succeed(Action.NextFrame({ |
| 3119 | state: { |
| 3120 | ...state, |
| 3121 | value: input === "." |
| 3122 | ? `${formatNumberInput(parsed)}.` |
| 3123 | : state.value.includes(".") && /^\d$/.test(input) |
| 3124 | ? state.value + input |
| 3125 | : formatNumberInput(parsed), |
| 3126 | error: Option.none() |
| 3127 | } |
| 3128 | })) |
| 3129 | } |
| 3130 | } |
| 3131 | |
| 3132 | const handleRenderInteger = (options: IntOptionsReq) => { |
| 3133 | return (state: NumberState, action: Action<NumberState, number>) => { |
no test coverage detected