CalendarDay.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. var __defProp = Object.defineProperty;
  2. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  3. var __getOwnPropNames = Object.getOwnPropertyNames;
  4. var __hasOwnProp = Object.prototype.hasOwnProperty;
  5. var __export = (target, all) => {
  6. for (var name2 in all)
  7. __defProp(target, name2, { get: all[name2], enumerable: true });
  8. };
  9. var __copyProps = (to, from, except, desc) => {
  10. if (from && typeof from === "object" || typeof from === "function") {
  11. for (let key of __getOwnPropNames(from))
  12. if (!__hasOwnProp.call(to, key) && key !== except)
  13. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  14. }
  15. return to;
  16. };
  17. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  18. var stdin_exports = {};
  19. __export(stdin_exports, {
  20. default: () => stdin_default
  21. });
  22. module.exports = __toCommonJS(stdin_exports);
  23. var import_vue = require("vue");
  24. var import_vue2 = require("vue");
  25. var import_utils = require("../utils");
  26. var import_utils2 = require("./utils");
  27. const [name] = (0, import_utils.createNamespace)("calendar-day");
  28. var stdin_default = (0, import_vue2.defineComponent)({
  29. name,
  30. props: {
  31. item: (0, import_utils.makeRequiredProp)(Object),
  32. color: String,
  33. index: Number,
  34. offset: (0, import_utils.makeNumberProp)(0),
  35. rowHeight: String
  36. },
  37. emits: ["click"],
  38. setup(props, {
  39. emit,
  40. slots
  41. }) {
  42. const style = (0, import_vue2.computed)(() => {
  43. var _a;
  44. const {
  45. item,
  46. index,
  47. color,
  48. offset,
  49. rowHeight
  50. } = props;
  51. const style2 = {
  52. height: rowHeight
  53. };
  54. if (item.type === "placeholder") {
  55. style2.width = "100%";
  56. return style2;
  57. }
  58. if (index === 0) {
  59. style2.marginLeft = `${100 * offset / 7}%`;
  60. }
  61. if (color) {
  62. switch (item.type) {
  63. case "end":
  64. case "start":
  65. case "start-end":
  66. case "multiple-middle":
  67. case "multiple-selected":
  68. style2.background = color;
  69. break;
  70. case "middle":
  71. style2.color = color;
  72. break;
  73. }
  74. }
  75. if (offset + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
  76. style2.marginBottom = 0;
  77. }
  78. return style2;
  79. });
  80. const onClick = () => {
  81. if (props.item.type !== "disabled") {
  82. emit("click", props.item);
  83. }
  84. };
  85. const renderTopInfo = () => {
  86. const {
  87. topInfo
  88. } = props.item;
  89. if (topInfo || slots["top-info"]) {
  90. return (0, import_vue.createVNode)("div", {
  91. "class": (0, import_utils2.bem)("top-info")
  92. }, [slots["top-info"] ? slots["top-info"](props.item) : topInfo]);
  93. }
  94. };
  95. const renderBottomInfo = () => {
  96. const {
  97. bottomInfo
  98. } = props.item;
  99. if (bottomInfo || slots["bottom-info"]) {
  100. return (0, import_vue.createVNode)("div", {
  101. "class": (0, import_utils2.bem)("bottom-info")
  102. }, [slots["bottom-info"] ? slots["bottom-info"](props.item) : bottomInfo]);
  103. }
  104. };
  105. const renderContent = () => {
  106. const {
  107. item,
  108. color,
  109. rowHeight
  110. } = props;
  111. const {
  112. type,
  113. text
  114. } = item;
  115. const Nodes = [renderTopInfo(), text, renderBottomInfo()];
  116. if (type === "selected") {
  117. return (0, import_vue.createVNode)("div", {
  118. "class": (0, import_utils2.bem)("selected-day"),
  119. "style": {
  120. width: rowHeight,
  121. height: rowHeight,
  122. background: color
  123. }
  124. }, [Nodes]);
  125. }
  126. return Nodes;
  127. };
  128. return () => {
  129. const {
  130. type,
  131. className
  132. } = props.item;
  133. if (type === "placeholder") {
  134. return (0, import_vue.createVNode)("div", {
  135. "class": (0, import_utils2.bem)("day"),
  136. "style": style.value
  137. }, null);
  138. }
  139. return (0, import_vue.createVNode)("div", {
  140. "role": "gridcell",
  141. "style": style.value,
  142. "class": [(0, import_utils2.bem)("day", type), className],
  143. "tabindex": type === "disabled" ? void 0 : -1,
  144. "onClick": onClick
  145. }, [renderContent()]);
  146. };
  147. }
  148. });