( x, y, date = new Date(), minDate = null, maxDate = null )
| 223 | } |
| 224 | |
| 225 | function openDatePicker( |
| 226 | x, |
| 227 | y, |
| 228 | date = new Date(), |
| 229 | minDate = null, |
| 230 | maxDate = null |
| 231 | ) { |
| 232 | return new Promise((resolve) => { |
| 233 | let input = document.createElement("input"); |
| 234 | input.type = "date"; |
| 235 | input.value = formatDate(date); |
| 236 | if (minDate) |
| 237 | input.min = minDate instanceof Date ? formatDate(minDate) : minDate; |
| 238 | if (maxDate) |
| 239 | input.max = maxDate instanceof Date ? formatDate(maxDate) : maxDate; |
| 240 | input.style = `position: fixed; top: ${y}px; left: ${x}px; visibility: hidden;`; |
| 241 | input.addEventListener("change", (e) => { |
| 242 | let selectedDate = new Date(e.target.value); |
| 243 | input.remove(); |
| 244 | resolve(selectedDate); |
| 245 | }); |
| 246 | document.body.appendChild(input); |
| 247 | setTimeout(() => { |
| 248 | input.showPicker(); |
| 249 | function remove() { |
| 250 | resolve(null); |
| 251 | input.remove(); |
| 252 | document.removeEventListener("click", remove); |
| 253 | } |
| 254 | document.addEventListener("click", remove); |
| 255 | }, 10); |
| 256 | }); |
| 257 | } |
| 258 | |
| 259 | function showData({ |
| 260 | fromDate = new Date(), |
no test coverage detected