(options: DateOptionsReq)
| 1878 | } |
| 1879 | |
| 1880 | const handleDateProcess = (options: DateOptionsReq) => { |
| 1881 | return (input: Terminal.UserInput, state: DateState) => { |
| 1882 | switch (input.key.name) { |
| 1883 | case "left": { |
| 1884 | return Effect.succeed(processDateCursorLeft(state)) |
| 1885 | } |
| 1886 | case "right": { |
| 1887 | return Effect.succeed(processDateCursorRight(state)) |
| 1888 | } |
| 1889 | case "k": |
| 1890 | case "up": { |
| 1891 | return Effect.succeed(processUp(state)) |
| 1892 | } |
| 1893 | case "j": |
| 1894 | case "down": { |
| 1895 | return Effect.succeed(processDown(state)) |
| 1896 | } |
| 1897 | case "tab": { |
| 1898 | return Effect.succeed(processDateNext(state)) |
| 1899 | } |
| 1900 | case "enter": |
| 1901 | case "return": { |
| 1902 | return Effect.match(options.validate(state.value), { |
| 1903 | onFailure: (error) => |
| 1904 | Action.NextFrame({ |
| 1905 | state: { |
| 1906 | ...state, |
| 1907 | error: Option.some(error) |
| 1908 | } |
| 1909 | }), |
| 1910 | onSuccess: (value) => Action.Submit({ value }) |
| 1911 | }) |
| 1912 | } |
| 1913 | default: { |
| 1914 | return Effect.succeed(defaultDateProcessor(Option.getOrElse(input.input, () => ""), state)) |
| 1915 | } |
| 1916 | } |
| 1917 | } |
| 1918 | } |
| 1919 | |
| 1920 | const DATE_PART_REGEXP = |
| 1921 | /\\(.)|"((?:\\["\\]|[^"])+)"|(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