(options: DateOptions)
| 242 | } |
| 243 | |
| 244 | function handleProcess(options: DateOptions) { |
| 245 | return (input: Terminal.UserInput, state: State) => { |
| 246 | switch (input.key.name) { |
| 247 | case "left": { |
| 248 | return Effect.succeed(processCursorLeft(state)) |
| 249 | } |
| 250 | case "right": { |
| 251 | return Effect.succeed(processCursorRight(state)) |
| 252 | } |
| 253 | case "k": |
| 254 | case "up": { |
| 255 | return Effect.succeed(processUp(state)) |
| 256 | } |
| 257 | case "j": |
| 258 | case "down": { |
| 259 | return Effect.succeed(processDown(state)) |
| 260 | } |
| 261 | case "tab": { |
| 262 | return Effect.succeed(processNext(state)) |
| 263 | } |
| 264 | case "enter": |
| 265 | case "return": { |
| 266 | return Effect.match(options.validate(state.value), { |
| 267 | onFailure: (error) => |
| 268 | Action.NextFrame({ |
| 269 | state: { |
| 270 | ...state, |
| 271 | error: Option.some(error) |
| 272 | } |
| 273 | }), |
| 274 | onSuccess: (value) => Action.Submit({ value }) |
| 275 | }) |
| 276 | } |
| 277 | default: { |
| 278 | const value = Option.getOrElse(input.input, () => "") |
| 279 | return Effect.succeed(defaultProcessor(value, state)) |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | /** @internal */ |
| 286 | export const date = (options: Prompt.Prompt.DateOptions): Prompt.Prompt<globalThis.Date> => { |
no test coverage detected
searching dependent graphs…