VDateRangeCard.mjs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { createVNode as _createVNode, mergeProps as _mergeProps, Fragment as _Fragment } from "vue";
  2. // Styles
  3. import "./VDateRangeCard.css";
  4. // Components
  5. import { makeVDatePickerControlsProps, VDatePickerControls } from "../VDatePicker/VDatePickerControls.mjs";
  6. import { makeVDatePickerMonthProps, VDatePickerMonth } from "../VDatePicker/VDatePickerMonth.mjs";
  7. import { makeVDatePickerYearsProps, VDatePickerYears } from "../VDatePicker/VDatePickerYears.mjs";
  8. import { VCard } from "../../components/VCard/index.mjs"; // Composables
  9. import { createDatePicker } from "../VDatePicker/composables.mjs";
  10. import { makeTransitionProps } from "../../composables/transition.mjs"; // Utilities
  11. import { ref } from 'vue';
  12. import { defineComponent, propsFactory, useRender } from "../../util/index.mjs"; // Types
  13. import { dateEmits, makeDateProps } from "../VDateInput/composables.mjs";
  14. import { useDate } from "../date/index.mjs";
  15. export const makeVDateRangeCardProps = propsFactory({
  16. ...makeDateProps(),
  17. ...makeVDatePickerControlsProps(),
  18. ...makeVDatePickerMonthProps(),
  19. ...makeVDatePickerYearsProps(),
  20. ...makeTransitionProps({
  21. transition: 'fade'
  22. })
  23. }, 'VDateRangeCard');
  24. export const VDateRangeCard = defineComponent({
  25. name: 'VDateRangeCard',
  26. props: makeVDateRangeCardProps(),
  27. emits: {
  28. ...dateEmits
  29. },
  30. setup(props, _ref) {
  31. let {
  32. emit
  33. } = _ref;
  34. const adapter = useDate();
  35. createDatePicker(props);
  36. const hoverDate = ref(null);
  37. useRender(() => {
  38. const [cardProps] = VCard.filterProps(props);
  39. const [datePickerControlsProps] = VDatePickerControls.filterProps(props);
  40. const [datePickerMonthProps] = VDatePickerMonth.filterProps(props);
  41. const [datePickerYearsProps] = VDatePickerYears.filterProps(props);
  42. return _createVNode(VCard, _mergeProps(cardProps, {
  43. "class": "v-date-range-card"
  44. }), {
  45. default: () => [props.viewMode === 'month' ? _createVNode(_Fragment, null, [_createVNode("div", {
  46. "class": "v-date-range-card__start"
  47. }, [_createVNode(VDatePickerControls, _mergeProps(datePickerControlsProps, {
  48. "onUpdate:displayDate": displayDate => emit('update:displayDate', displayDate),
  49. "onUpdate:viewMode": viewMode => emit('update:viewMode', viewMode),
  50. "range": "start"
  51. }), null), _createVNode(VDatePickerMonth, _mergeProps(datePickerMonthProps, {
  52. "onUpdate:modelValue": modelValue => emit('update:modelValue', modelValue),
  53. "hoverDate": hoverDate.value,
  54. "onUpdate:hoverDate": $event => hoverDate.value = $event,
  55. "multiple": true,
  56. "side": "start"
  57. }), null)]), _createVNode("div", {
  58. "class": "v-date-range-card__divider"
  59. }, null), _createVNode("div", {
  60. "class": "v-date-range-card__end"
  61. }, [_createVNode(VDatePickerControls, _mergeProps(datePickerControlsProps, {
  62. "onUpdate:displayDate": displayDate => emit('update:displayDate', displayDate),
  63. "onUpdate:viewMode": viewMode => emit('update:viewMode', viewMode),
  64. "range": "end"
  65. }), null), _createVNode(VDatePickerMonth, _mergeProps(datePickerMonthProps, {
  66. "onUpdate:modelValue": modelValue => emit('update:modelValue', modelValue),
  67. "displayDate": adapter.addMonths(props.displayDate, 1),
  68. "hoverDate": hoverDate.value,
  69. "onUpdate:hoverDate": $event => hoverDate.value = $event,
  70. "multiple": true,
  71. "side": "end"
  72. }), null)])]) : _createVNode("div", {
  73. "class": "v-date-range-card__years"
  74. }, [_createVNode(VDatePickerControls, _mergeProps(datePickerControlsProps, {
  75. "onUpdate:displayDate": displayDate => emit('update:displayDate', displayDate),
  76. "onUpdate:viewMode": viewMode => emit('update:viewMode', viewMode)
  77. }), null), _createVNode(VDatePickerYears, _mergeProps(datePickerYearsProps, {
  78. "onUpdate:displayDate": displayDate => emit('update:displayDate', displayDate),
  79. "onUpdate:viewMode": viewMode => emit('update:viewMode', viewMode)
  80. }), null)])]
  81. });
  82. });
  83. return {};
  84. }
  85. });
  86. //# sourceMappingURL=VDateRangeCard.mjs.map