date.py 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. from typing import Any, Callable, Optional
  2. from .mixins.disableable_element import DisableableElement
  3. from .mixins.value_element import ValueElement
  4. class Date(ValueElement, DisableableElement):
  5. EVENT_ARGS = None
  6. def __init__(self,
  7. value: Optional[str] = None,
  8. *,
  9. mask: str = 'YYYY-MM-DD',
  10. on_change: Optional[Callable[..., Any]] = None) -> None:
  11. """Date Input
  12. This element is based on Quasar's `QDate <https://quasar.dev/vue-components/date>`_ component.
  13. The date is a string in the format defined by the `mask` parameter.
  14. You can also use the `range` or `multiple` props to select a range of dates or multiple dates::
  15. ui.date({'from': '2023-01-01', 'to': '2023-01-05'}).props('range')
  16. ui.date(['2023-01-01', '2023-01-02', '2023-01-03']).props('multiple')
  17. ui.date([{'from': '2023-01-01', 'to': '2023-01-05'}, '2023-01-07']).props('multiple range')
  18. :param value: the initial date
  19. :param mask: the format of the date string (default: 'YYYY-MM-DD')
  20. :param on_change: callback to execute when changing the date
  21. """
  22. super().__init__(tag='q-date', value=value, on_value_change=on_change)
  23. self._props['mask'] = mask