date-table.mjs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import '../../../utils/index.mjs';
  2. import '../../time-picker/index.mjs';
  3. import { rangeArr } from '../../time-picker/src/utils.mjs';
  4. import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
  5. import { isObject } from '@vue/shared';
  6. const getPrevMonthLastDays = (date, count) => {
  7. const lastDay = date.subtract(1, "month").endOf("month").date();
  8. return rangeArr(count).map((_, index) => lastDay - (count - index - 1));
  9. };
  10. const getMonthDays = (date) => {
  11. const days = date.daysInMonth();
  12. return rangeArr(days).map((_, index) => index + 1);
  13. };
  14. const toNestedArr = (days) => rangeArr(days.length / 7).map((index) => {
  15. const start = index * 7;
  16. return days.slice(start, start + 7);
  17. });
  18. const dateTableProps = buildProps({
  19. selectedDay: {
  20. type: definePropType(Object)
  21. },
  22. range: {
  23. type: definePropType(Array)
  24. },
  25. date: {
  26. type: definePropType(Object),
  27. required: true
  28. },
  29. hideHeader: {
  30. type: Boolean
  31. }
  32. });
  33. const dateTableEmits = {
  34. pick: (value) => isObject(value)
  35. };
  36. export { dateTableEmits, dateTableProps, getMonthDays, getPrevMonthLastDays, toNestedArr };
  37. //# sourceMappingURL=date-table.mjs.map