|
12 | 12 |
|
13 | 13 | // Use this for testing purposes only |
14 | 14 | export let parsedDate: string = ''; |
15 | | - // let inputElement: HTMLInputElement; |
16 | | - // let flatpickrInstance: any; |
17 | | - // |
18 | | - // const dispatch = createEventDispatcher(); |
19 | | - // |
20 | | - // const iconCalendarDays = (node: HTMLElement) => { |
21 | | - // // For a more general implementation, see: |
22 | | - // // https://github.com/joethei/obsidian-rss/blob/b600e2ead2505d58aa3e4c7898795bbf58fa3cdc/src/view/IconComponent.svelte |
23 | | - // setIcon(node, 'calendar-days'); |
24 | | - // }; |
25 | 15 |
|
26 | 16 | let pickedDate = ''; |
27 | 17 |
|
|
43 | 33 |
|
44 | 34 | // 'weekend' abbreviation omitted due to lack of space. |
45 | 35 | const datePlaceholder = "Try 'Mon' or 'tm' then space"; |
46 | | -
|
47 | | - /** |
48 | | - * A calendar date picker which is not tied to any particular date field. |
49 | | - * |
50 | | - * See also {@link promptForDate} |
51 | | - */ |
52 | | - // function openDatePicker() { |
53 | | - // if (inputElement) { |
54 | | - // if (flatpickrInstance) { |
55 | | - // flatpickrInstance.destroy(); // Destroy any existing instance to avoid conflicts |
56 | | - // } |
57 | | - // |
58 | | - // const options: Record<string, any> = { |
59 | | - // enableTime: false, |
60 | | - // dateFormat: 'Y-m-d', |
61 | | - // locale: { |
62 | | - // firstDayOfWeek: 1, |
63 | | - // }, |
64 | | - // onClose: (selectedDates: Date[]) => { |
65 | | - // dispatch('close', { instance: flatpickrInstance }); // Notify parent about close |
66 | | - // |
67 | | - // if (selectedDates.length > 0) { |
68 | | - // const selectedDate = selectedDates[0]; |
69 | | - // date = window.moment(selectedDate).format('YYYY-MM-DD'); |
70 | | - // } |
71 | | - // |
72 | | - // flatpickrInstance.destroy(); // Destroy the instance after the date is selected |
73 | | - // flatpickrInstance = null; |
74 | | - // }, |
75 | | - // allowInput: true, // Allow manual input to keep the field empty if no selection is made |
76 | | - // defaultDate: undefined, // Explicitly define defaultDate with undefined |
77 | | - // }; |
78 | | - // |
79 | | - // // We don't use parseDate() here as we want to strictly only match exact dates, |
80 | | - // // and not words like 'today' or 'tomorrow', to make sure we really |
81 | | - // // are using the already-parsed date in the Modal UI: |
82 | | - // const dateMatcher = /^\d{4}-\d{2}-\d{2}$/; |
83 | | - // if (parsedDate.match(dateMatcher)) { |
84 | | - // // This is where the user had typed, for example, 'tomorrow' in the input |
85 | | - // // field, and chrono has converted that to an exact date. |
86 | | - // options.defaultDate = new Date(parsedDate); |
87 | | - // } else if (date.match(dateMatcher)) { |
88 | | - // // This is a precaution, for the unlikely event that the input field |
89 | | - // // contains a parsed date, but the parsedDate does not. |
90 | | - // // It's possible that it is unreachable, but we would need tests to confirm that. |
91 | | - // options.defaultDate = new Date(date); |
92 | | - // } |
93 | | - // |
94 | | - // flatpickrInstance = flatpickr(inputElement, options); |
95 | | - // dispatch('open', { instance: flatpickrInstance }); // Notify parent about open |
96 | | - // |
97 | | - // flatpickrInstance.open(); // Directly open the date picker |
98 | | - // } |
99 | | - // } |
100 | 36 | </script> |
101 | 37 |
|
102 | 38 | <label for={id}>{@html labelContentWithAccessKey(id, accesskey)}</label> |
|
111 | 47 | {accesskey} |
112 | 48 | /> |
113 | 49 |
|
114 | | -<!--<button--> |
115 | | -<!-- class="tasks-modal-calendar-button"--> |
116 | | -<!-- use:iconCalendarDays--> |
117 | | -<!-- on:click={openDatePicker}--> |
118 | | -<!-- aria-label="Open date picker"--> |
119 | | -<!-- style="background: none; border: none; padding: 0; cursor: pointer;"--> |
120 | | -<!--/>--> |
121 | 50 | {#if isDateValid} |
122 | 51 | <div class="tasks-modal-parsed-date"> |
123 | 52 | {dateSymbol}<input |
|
0 commit comments