(event)
| 299 | }, |
| 300 | |
| 301 | onClickDay(event) { |
| 302 | if (this.data.readonly) { |
| 303 | return; |
| 304 | } |
| 305 | |
| 306 | let { date } = event.detail; |
| 307 | const { type, currentDate, allowSameDay } = this.data; |
| 308 | |
| 309 | if (type === 'range') { |
| 310 | // @ts-ignore |
| 311 | const [startDay, endDay] = currentDate; |
| 312 | |
| 313 | if (startDay && !endDay) { |
| 314 | const compareToStart = compareDay(date, startDay); |
| 315 | |
| 316 | if (compareToStart === 1) { |
| 317 | const { days } = this.selectComponent('.month').data; |
| 318 | days.some((day: Day, index) => { |
| 319 | const isDisabled = |
| 320 | day.type === 'disabled' && |
| 321 | getTime(startDay) < getTime(day.date) && |
| 322 | getTime(day.date) < getTime(date); |
| 323 | if (isDisabled) { |
| 324 | ({ date } = days[index - 1]); |
| 325 | } |
| 326 | return isDisabled; |
| 327 | }); |
| 328 | this.select([startDay, date], true); |
| 329 | } else if (compareToStart === -1) { |
| 330 | this.select([date, null]); |
| 331 | } else if (allowSameDay) { |
| 332 | this.select([date, date], true); |
| 333 | } |
| 334 | } else { |
| 335 | this.select([date, null]); |
| 336 | } |
| 337 | } else if (type === 'multiple') { |
| 338 | let selectedIndex: number; |
| 339 | |
| 340 | // @ts-ignore |
| 341 | const selected = currentDate.some((dateItem: number, index: number) => { |
| 342 | const equal = compareDay(dateItem, date) === 0; |
| 343 | if (equal) { |
| 344 | selectedIndex = index; |
| 345 | } |
| 346 | return equal; |
| 347 | }); |
| 348 | |
| 349 | if (selected) { |
| 350 | // @ts-ignore |
| 351 | const cancelDate = currentDate.splice(selectedIndex, 1); |
| 352 | this.setData({ currentDate }); |
| 353 | this.unselect(cancelDate); |
| 354 | } else { |
| 355 | // @ts-ignore |
| 356 | this.select([...currentDate, date]); |
| 357 | } |
| 358 | } else { |
nothing calls this directly
no test coverage detected