(options: DateOptionsReq)
| 1716 | } |
| 1717 | |
| 1718 | const handleDateProcess = (options: DateOptionsReq) => { |
| 1719 | return (input: Terminal.UserInput, state: DateState) => { |
| 1720 | switch (input.key.name) { |
| 1721 | case "left": { |
| 1722 | return Effect.succeed(processDateCursorLeft(state)) |
| 1723 | } |
| 1724 | case "right": { |
| 1725 | return Effect.succeed(processDateCursorRight(state)) |
| 1726 | } |
| 1727 | case "k": |
| 1728 | case "up": { |
| 1729 | return Effect.succeed(processUp(state)) |
| 1730 | } |
| 1731 | case "j": |
| 1732 | case "down": { |
| 1733 | return Effect.succeed(processDown(state)) |
| 1734 | } |
| 1735 | case "tab": { |
| 1736 | return Effect.succeed(processDateNext(state)) |
| 1737 | } |
| 1738 | case "enter": |
| 1739 | case "return": { |
| 1740 | return Effect.match(options.validate(state.value), { |
| 1741 | onFailure: (error) => |
| 1742 | Action.NextFrame({ |
| 1743 | state: { |
| 1744 | ...state, |
| 1745 | error: Option.some(error) |
| 1746 | } |
| 1747 | }), |
| 1748 | onSuccess: (value) => Action.Submit({ value }) |
| 1749 | }) |
| 1750 | } |
| 1751 | default: { |
| 1752 | return Effect.succeed(defaultDateProcessor(Option.getOrElse(input.input, () => ""), state)) |
| 1753 | } |
| 1754 | } |
| 1755 | } |
| 1756 | } |
| 1757 | |
| 1758 | const DATE_PART_REGEXP = |
| 1759 | /\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g |
no test coverage detected