(options: DateOptions)
| 838 | * @since 4.0.0 |
| 839 | */ |
| 840 | export const date = (options: DateOptions): Prompt<Date> => { |
| 841 | const opts: Required<DateOptions> = { |
| 842 | initial: new Date(), |
| 843 | dateMask: "YYYY-MM-DD HH:mm:ss", |
| 844 | validate: Effect.succeed, |
| 845 | ...options, |
| 846 | locales: { |
| 847 | ...defaultLocales, |
| 848 | ...options.locales |
| 849 | } |
| 850 | } |
| 851 | const dateParts = makeDateParts(opts.dateMask, opts.initial, opts.locales) |
| 852 | const initialCursorPosition = dateParts.findIndex((part) => !part.isToken()) |
| 853 | const initialState: DateState = { |
| 854 | dateParts, |
| 855 | typed: "", |
| 856 | cursor: initialCursorPosition, |
| 857 | value: opts.initial, |
| 858 | error: Option.none() |
| 859 | } |
| 860 | return custom(initialState, { |
| 861 | render: handleDateRender(opts), |
| 862 | process: handleDateProcess(opts), |
| 863 | clear: handleDateClear(opts) |
| 864 | }) |
| 865 | } |
| 866 | |
| 867 | /** |
| 868 | * Creates a file-system selection prompt and returns the selected path. |
nothing calls this directly
no test coverage detected