Header.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.default = void 0;
  4. var _utils = require("../../utils");
  5. var _utils2 = require("../utils");
  6. var _createNamespace = (0, _utils.createNamespace)('calendar-header'),
  7. createComponent = _createNamespace[0];
  8. var _default = createComponent({
  9. props: {
  10. title: String,
  11. subtitle: String,
  12. showTitle: Boolean,
  13. showSubtitle: Boolean,
  14. firstDayOfWeek: Number
  15. },
  16. methods: {
  17. genTitle: function genTitle() {
  18. var h = this.$createElement;
  19. if (this.showTitle) {
  20. var title = this.slots('title') || this.title || (0, _utils2.t)('title');
  21. return h("div", {
  22. "class": (0, _utils2.bem)('header-title')
  23. }, [title]);
  24. }
  25. },
  26. genSubtitle: function genSubtitle() {
  27. var h = this.$createElement;
  28. if (this.showSubtitle) {
  29. return h("div", {
  30. "class": (0, _utils2.bem)('header-subtitle')
  31. }, [this.subtitle]);
  32. }
  33. },
  34. genWeekDays: function genWeekDays() {
  35. var h = this.$createElement;
  36. var weekdays = (0, _utils2.t)('weekdays');
  37. var firstDayOfWeek = this.firstDayOfWeek;
  38. var renderWeekDays = [].concat(weekdays.slice(firstDayOfWeek, 7), weekdays.slice(0, firstDayOfWeek));
  39. return h("div", {
  40. "class": (0, _utils2.bem)('weekdays')
  41. }, [renderWeekDays.map(function (item) {
  42. return h("span", {
  43. "class": (0, _utils2.bem)('weekday')
  44. }, [item]);
  45. })]);
  46. }
  47. },
  48. render: function render() {
  49. var h = arguments[0];
  50. return h("div", {
  51. "class": (0, _utils2.bem)('header')
  52. }, [this.genTitle(), this.genSubtitle(), this.genWeekDays()]);
  53. }
  54. });
  55. exports.default = _default;