calendar.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "/dist/";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = 58);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 0:
  90. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91. "use strict";
  92. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
  93. /* globals __VUE_SSR_CONTEXT__ */
  94. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  95. // This module is a runtime utility for cleaner component module output and will
  96. // be included in the final webpack user bundle.
  97. function normalizeComponent (
  98. scriptExports,
  99. render,
  100. staticRenderFns,
  101. functionalTemplate,
  102. injectStyles,
  103. scopeId,
  104. moduleIdentifier, /* server only */
  105. shadowMode /* vue-cli only */
  106. ) {
  107. // Vue.extend constructor export interop
  108. var options = typeof scriptExports === 'function'
  109. ? scriptExports.options
  110. : scriptExports
  111. // render functions
  112. if (render) {
  113. options.render = render
  114. options.staticRenderFns = staticRenderFns
  115. options._compiled = true
  116. }
  117. // functional template
  118. if (functionalTemplate) {
  119. options.functional = true
  120. }
  121. // scopedId
  122. if (scopeId) {
  123. options._scopeId = 'data-v-' + scopeId
  124. }
  125. var hook
  126. if (moduleIdentifier) { // server build
  127. hook = function (context) {
  128. // 2.3 injection
  129. context =
  130. context || // cached call
  131. (this.$vnode && this.$vnode.ssrContext) || // stateful
  132. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  133. // 2.2 with runInNewContext: true
  134. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  135. context = __VUE_SSR_CONTEXT__
  136. }
  137. // inject component styles
  138. if (injectStyles) {
  139. injectStyles.call(this, context)
  140. }
  141. // register component module identifier for async chunk inferrence
  142. if (context && context._registeredComponents) {
  143. context._registeredComponents.add(moduleIdentifier)
  144. }
  145. }
  146. // used by ssr in case component is cached and beforeCreate
  147. // never gets called
  148. options._ssrRegister = hook
  149. } else if (injectStyles) {
  150. hook = shadowMode
  151. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  152. : injectStyles
  153. }
  154. if (hook) {
  155. if (options.functional) {
  156. // for template-only hot-reload because in that case the render fn doesn't
  157. // go through the normalizer
  158. options._injectStyles = hook
  159. // register for functioal component in vue file
  160. var originalRender = options.render
  161. options.render = function renderWithStyleInjection (h, context) {
  162. hook.call(context)
  163. return originalRender(h, context)
  164. }
  165. } else {
  166. // inject component registration as beforeCreate hook
  167. var existing = options.beforeCreate
  168. options.beforeCreate = existing
  169. ? [].concat(existing, hook)
  170. : [hook]
  171. }
  172. }
  173. return {
  174. exports: scriptExports,
  175. options: options
  176. }
  177. }
  178. /***/ }),
  179. /***/ 1:
  180. /***/ (function(module, exports) {
  181. module.exports = require("element-ui/lib/utils/date-util");
  182. /***/ }),
  183. /***/ 21:
  184. /***/ (function(module, exports) {
  185. module.exports = require("element-ui/lib/utils/date");
  186. /***/ }),
  187. /***/ 58:
  188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  189. "use strict";
  190. __webpack_require__.r(__webpack_exports__);
  191. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/calendar/src/main.vue?vue&type=template&id=6d9756be&
  192. var render = function() {
  193. var _vm = this
  194. var _h = _vm.$createElement
  195. var _c = _vm._self._c || _h
  196. return _c("div", { staticClass: "el-calendar" }, [
  197. _c("div", { staticClass: "el-calendar__header" }, [
  198. _c("div", { staticClass: "el-calendar__title" }, [
  199. _vm._v("\n " + _vm._s(_vm.i18nDate) + "\n ")
  200. ]),
  201. _vm.validatedRange.length === 0
  202. ? _c(
  203. "div",
  204. { staticClass: "el-calendar__button-group" },
  205. [
  206. _c(
  207. "el-button-group",
  208. [
  209. _c(
  210. "el-button",
  211. {
  212. attrs: { type: "plain", size: "mini" },
  213. on: {
  214. click: function($event) {
  215. _vm.selectDate("prev-month")
  216. }
  217. }
  218. },
  219. [
  220. _vm._v(
  221. "\n " +
  222. _vm._s(_vm.t("el.datepicker.prevMonth")) +
  223. "\n "
  224. )
  225. ]
  226. ),
  227. _c(
  228. "el-button",
  229. {
  230. attrs: { type: "plain", size: "mini" },
  231. on: {
  232. click: function($event) {
  233. _vm.selectDate("today")
  234. }
  235. }
  236. },
  237. [
  238. _vm._v(
  239. "\n " +
  240. _vm._s(_vm.t("el.datepicker.today")) +
  241. "\n "
  242. )
  243. ]
  244. ),
  245. _c(
  246. "el-button",
  247. {
  248. attrs: { type: "plain", size: "mini" },
  249. on: {
  250. click: function($event) {
  251. _vm.selectDate("next-month")
  252. }
  253. }
  254. },
  255. [
  256. _vm._v(
  257. "\n " +
  258. _vm._s(_vm.t("el.datepicker.nextMonth")) +
  259. "\n "
  260. )
  261. ]
  262. )
  263. ],
  264. 1
  265. )
  266. ],
  267. 1
  268. )
  269. : _vm._e()
  270. ]),
  271. _vm.validatedRange.length === 0
  272. ? _c(
  273. "div",
  274. { key: "no-range", staticClass: "el-calendar__body" },
  275. [
  276. _c("date-table", {
  277. attrs: { date: _vm.date, "selected-day": _vm.realSelectedDay },
  278. on: { pick: _vm.pickDay }
  279. })
  280. ],
  281. 1
  282. )
  283. : _c(
  284. "div",
  285. { key: "has-range", staticClass: "el-calendar__body" },
  286. _vm._l(_vm.validatedRange, function(range, index) {
  287. return _c("date-table", {
  288. key: index,
  289. attrs: {
  290. date: range[0],
  291. "selected-day": _vm.realSelectedDay,
  292. range: range,
  293. "hide-header": index !== 0
  294. },
  295. on: { pick: _vm.pickDay }
  296. })
  297. }),
  298. 1
  299. )
  300. ])
  301. }
  302. var staticRenderFns = []
  303. render._withStripped = true
  304. // CONCATENATED MODULE: ./packages/calendar/src/main.vue?vue&type=template&id=6d9756be&
  305. // EXTERNAL MODULE: external "element-ui/lib/mixins/locale"
  306. var locale_ = __webpack_require__(7);
  307. var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
  308. // EXTERNAL MODULE: external "element-ui/lib/utils/date"
  309. var date_ = __webpack_require__(21);
  310. var date_default = /*#__PURE__*/__webpack_require__.n(date_);
  311. // EXTERNAL MODULE: external "element-ui/lib/utils/date-util"
  312. var date_util_ = __webpack_require__(1);
  313. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/calendar/src/date-table.vue?vue&type=script&lang=js&
  314. /* harmony default export */ var date_tablevue_type_script_lang_js_ = ({
  315. props: {
  316. selectedDay: String, // formated date yyyy-MM-dd
  317. range: {
  318. type: Array,
  319. validator: function validator(val) {
  320. if (!(val && val.length)) return true;
  321. var start = val[0],
  322. end = val[1];
  323. return Object(date_util_["validateRangeInOneMonth"])(start, end);
  324. }
  325. },
  326. date: Date,
  327. hideHeader: Boolean
  328. },
  329. inject: ['elCalendar'],
  330. methods: {
  331. toNestedArr: function toNestedArr(days) {
  332. return Object(date_util_["range"])(days.length / 7).map(function (_, index) {
  333. var start = index * 7;
  334. return days.slice(start, start + 7);
  335. });
  336. },
  337. getFormateDate: function getFormateDate(day, type) {
  338. if (!day || ['prev', 'current', 'next'].indexOf(type) === -1) {
  339. throw new Error('invalid day or type');
  340. }
  341. var prefix = this.curMonthDatePrefix;
  342. if (type === 'prev') {
  343. prefix = this.prevMonthDatePrefix;
  344. } else if (type === 'next') {
  345. prefix = this.nextMonthDatePrefix;
  346. }
  347. day = ('00' + day).slice(-2);
  348. return prefix + '-' + day;
  349. },
  350. getCellClass: function getCellClass(_ref) {
  351. var text = _ref.text,
  352. type = _ref.type;
  353. var classes = [type];
  354. if (type === 'current') {
  355. var date = this.getFormateDate(text, type);
  356. if (date === this.selectedDay) {
  357. classes.push('is-selected');
  358. }
  359. if (date === this.formatedToday) {
  360. classes.push('is-today');
  361. }
  362. }
  363. return classes;
  364. },
  365. pickDay: function pickDay(_ref2) {
  366. var text = _ref2.text,
  367. type = _ref2.type;
  368. var date = this.getFormateDate(text, type);
  369. this.$emit('pick', date);
  370. },
  371. cellRenderProxy: function cellRenderProxy(_ref3) {
  372. var text = _ref3.text,
  373. type = _ref3.type;
  374. var h = this.$createElement;
  375. var render = this.elCalendar.$scopedSlots.dateCell;
  376. if (!render) return h('span', [text]);
  377. var day = this.getFormateDate(text, type);
  378. var date = new Date(day);
  379. var data = {
  380. isSelected: this.selectedDay === day,
  381. type: type + '-month',
  382. day: day
  383. };
  384. return render({ date: date, data: data });
  385. }
  386. },
  387. computed: {
  388. prevMonthDatePrefix: function prevMonthDatePrefix() {
  389. var temp = new Date(this.date.getTime());
  390. temp.setDate(0);
  391. return date_default.a.format(temp, 'yyyy-MM');
  392. },
  393. curMonthDatePrefix: function curMonthDatePrefix() {
  394. return date_default.a.format(this.date, 'yyyy-MM');
  395. },
  396. nextMonthDatePrefix: function nextMonthDatePrefix() {
  397. var temp = new Date(this.date.getFullYear(), this.date.getMonth() + 1, 1);
  398. return date_default.a.format(temp, 'yyyy-MM');
  399. },
  400. formatedToday: function formatedToday() {
  401. return this.elCalendar.formatedToday;
  402. },
  403. isInRange: function isInRange() {
  404. return this.range && this.range.length;
  405. },
  406. rows: function rows() {
  407. var days = [];
  408. // if range exists, should render days in range.
  409. if (this.isInRange) {
  410. var _range = this.range,
  411. start = _range[0],
  412. end = _range[1];
  413. var currentMonthRange = Object(date_util_["range"])(end.getDate() - start.getDate() + 1).map(function (_, index) {
  414. return {
  415. text: start.getDate() + index,
  416. type: 'current'
  417. };
  418. });
  419. var remaining = currentMonthRange.length % 7;
  420. remaining = remaining === 0 ? 0 : 7 - remaining;
  421. var nextMonthRange = Object(date_util_["range"])(remaining).map(function (_, index) {
  422. return {
  423. text: index + 1,
  424. type: 'next'
  425. };
  426. });
  427. days = currentMonthRange.concat(nextMonthRange);
  428. } else {
  429. var date = this.date;
  430. var firstDay = Object(date_util_["getFirstDayOfMonth"])(date);
  431. var prevMonthDays = Object(date_util_["getPrevMonthLastDays"])(date, firstDay - 1).map(function (day) {
  432. return {
  433. text: day,
  434. type: 'prev'
  435. };
  436. });
  437. var currentMonthDays = Object(date_util_["getMonthDays"])(date).map(function (day) {
  438. return {
  439. text: day,
  440. type: 'current'
  441. };
  442. });
  443. days = [].concat(prevMonthDays, currentMonthDays);
  444. var nextMonthDays = Object(date_util_["range"])(42 - days.length).map(function (_, index) {
  445. return {
  446. text: index + 1,
  447. type: 'next'
  448. };
  449. });
  450. days = days.concat(nextMonthDays);
  451. }
  452. return this.toNestedArr(days);
  453. }
  454. },
  455. data: function data() {
  456. var dayNames = Object(date_util_["getI18nSettings"])().dayNames;
  457. return {
  458. DAYS: dayNames.slice(1).concat(dayNames[0])
  459. };
  460. },
  461. render: function render() {
  462. var _this = this;
  463. var h = arguments[0];
  464. var thead = this.hideHeader ? null : h('thead', [this.DAYS.map(function (day) {
  465. return h(
  466. 'th',
  467. { key: day },
  468. [day]
  469. );
  470. })]);
  471. return h(
  472. 'table',
  473. {
  474. 'class': {
  475. 'el-calendar-table': true,
  476. 'is-range': this.isInRange
  477. },
  478. attrs: { cellspacing: '0',
  479. cellpadding: '0' }
  480. },
  481. [thead, h('tbody', [this.rows.map(function (row, index) {
  482. return h(
  483. 'tr',
  484. {
  485. 'class': {
  486. 'el-calendar-table__row': true,
  487. 'el-calendar-table__row--hide-border': index === 0 && _this.hideHeader
  488. },
  489. key: index },
  490. [row.map(function (cell, key) {
  491. return h(
  492. 'td',
  493. { key: key,
  494. 'class': _this.getCellClass(cell),
  495. on: {
  496. 'click': _this.pickDay.bind(_this, cell)
  497. }
  498. },
  499. [h(
  500. 'div',
  501. { 'class': 'el-calendar-day' },
  502. [_this.cellRenderProxy(cell)]
  503. )]
  504. );
  505. })]
  506. );
  507. })])]
  508. );
  509. }
  510. });
  511. // CONCATENATED MODULE: ./packages/calendar/src/date-table.vue?vue&type=script&lang=js&
  512. /* harmony default export */ var src_date_tablevue_type_script_lang_js_ = (date_tablevue_type_script_lang_js_);
  513. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  514. var componentNormalizer = __webpack_require__(0);
  515. // CONCATENATED MODULE: ./packages/calendar/src/date-table.vue
  516. var date_table_render, date_table_staticRenderFns
  517. /* normalize component */
  518. var component = Object(componentNormalizer["a" /* default */])(
  519. src_date_tablevue_type_script_lang_js_,
  520. date_table_render,
  521. date_table_staticRenderFns,
  522. false,
  523. null,
  524. null,
  525. null
  526. )
  527. /* hot reload */
  528. if (false) { var api; }
  529. component.options.__file = "packages/calendar/src/date-table.vue"
  530. /* harmony default export */ var date_table = (component.exports);
  531. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/calendar/src/main.vue?vue&type=script&lang=js&
  532. //
  533. //
  534. //
  535. //
  536. //
  537. //
  538. //
  539. //
  540. //
  541. //
  542. //
  543. //
  544. //
  545. //
  546. //
  547. //
  548. //
  549. //
  550. //
  551. //
  552. //
  553. //
  554. //
  555. //
  556. //
  557. //
  558. //
  559. //
  560. //
  561. //
  562. //
  563. //
  564. //
  565. //
  566. //
  567. //
  568. //
  569. //
  570. //
  571. //
  572. //
  573. //
  574. //
  575. //
  576. //
  577. //
  578. //
  579. //
  580. //
  581. //
  582. //
  583. //
  584. //
  585. //
  586. //
  587. //
  588. var validTypes = ['prev-month', 'today', 'next-month'];
  589. var oneDay = 86400000;
  590. /* harmony default export */ var mainvue_type_script_lang_js_ = ({
  591. name: 'ElCalendar',
  592. mixins: [locale_default.a],
  593. components: {
  594. DateTable: date_table
  595. },
  596. props: {
  597. value: [Date, String, Number],
  598. range: {
  599. type: Array,
  600. validator: function validator(range) {
  601. if (Array.isArray(range)) {
  602. return range.length === 2 && range.every(function (item) {
  603. return typeof item === 'string' || typeof item === 'number' || item instanceof Date;
  604. });
  605. } else {
  606. return true;
  607. }
  608. }
  609. }
  610. },
  611. provide: function provide() {
  612. return {
  613. elCalendar: this
  614. };
  615. },
  616. methods: {
  617. pickDay: function pickDay(day) {
  618. this.realSelectedDay = day;
  619. },
  620. selectDate: function selectDate(type) {
  621. if (validTypes.indexOf(type) === -1) {
  622. throw new Error('invalid type ' + type);
  623. }
  624. var day = '';
  625. if (type === 'prev-month') {
  626. day = this.prevMonthDatePrefix + '-01';
  627. } else if (type === 'next-month') {
  628. day = this.nextMonthDatePrefix + '-01';
  629. } else {
  630. day = this.formatedToday;
  631. }
  632. if (day === this.formatedDate) return;
  633. this.pickDay(day);
  634. },
  635. toDate: function toDate(val) {
  636. if (!val) {
  637. throw new Error('invalid val');
  638. }
  639. return val instanceof Date ? val : new Date(val);
  640. }
  641. },
  642. computed: {
  643. prevMonthDatePrefix: function prevMonthDatePrefix() {
  644. var temp = new Date(this.date.getTime());
  645. temp.setDate(0);
  646. return date_default.a.format(temp, 'yyyy-MM');
  647. },
  648. curMonthDatePrefix: function curMonthDatePrefix() {
  649. return date_default.a.format(this.date, 'yyyy-MM');
  650. },
  651. nextMonthDatePrefix: function nextMonthDatePrefix() {
  652. var temp = new Date(this.date.getFullYear(), this.date.getMonth() + 1, 1);
  653. return date_default.a.format(temp, 'yyyy-MM');
  654. },
  655. formatedDate: function formatedDate() {
  656. return date_default.a.format(this.date, 'yyyy-MM-dd');
  657. },
  658. i18nDate: function i18nDate() {
  659. var year = this.formatedDate.slice(0, 4);
  660. var month = this.formatedDate.slice(5, 7).replace('0', '');
  661. return year + ' ' + this.t('el.datepicker.year') + ' ' + this.t('el.datepicker.month' + month);
  662. },
  663. formatedToday: function formatedToday() {
  664. return date_default.a.format(this.now, 'yyyy-MM-dd');
  665. },
  666. realSelectedDay: {
  667. get: function get() {
  668. if (!this.value) return this.selectedDay;
  669. return this.formatedDate;
  670. },
  671. set: function set(val) {
  672. this.selectedDay = val;
  673. var date = new Date(val);
  674. this.$emit('input', date);
  675. }
  676. },
  677. date: function date() {
  678. if (!this.value) {
  679. if (this.realSelectedDay) {
  680. return new Date(this.selectedDay);
  681. } else if (this.validatedRange.length) {
  682. return this.validatedRange[0][0];
  683. }
  684. return this.now;
  685. } else {
  686. return this.toDate(this.value);
  687. }
  688. },
  689. // if range is valid, we get a two-digit array
  690. validatedRange: function validatedRange() {
  691. var _this = this;
  692. var range = this.range;
  693. if (!range) return [];
  694. var expetedMap = {
  695. 0: {
  696. value: 1,
  697. message: 'start of range should be Monday.'
  698. },
  699. 1: {
  700. value: 0,
  701. message: 'end of range should be Sunday.'
  702. }
  703. };
  704. range = range.reduce(function (prev, val, index) {
  705. var date = _this.toDate(val);
  706. if (date.getDay() !== expetedMap[index].value) {
  707. console.warn('[ElementCalendar]', expetedMap[index].message, ' invalid range will be ignored');
  708. } else {
  709. prev = prev.concat(date);
  710. }
  711. return prev;
  712. }, []);
  713. if (range.length === 2) {
  714. var _range = range,
  715. start = _range[0],
  716. end = _range[1];
  717. if (start > end) {
  718. console.warn('[ElementCalendar]end time should be greater than start time');
  719. return [];
  720. }
  721. // start time and end time in one month
  722. if (Object(date_util_["validateRangeInOneMonth"])(start, end)) {
  723. return [[start, end]];
  724. }
  725. var data = [];
  726. var startDay = new Date(start.getFullYear(), start.getMonth() + 1, 1);
  727. var lastDay = this.toDate(startDay.getTime() - oneDay);
  728. if (!Object(date_util_["validateRangeInOneMonth"])(startDay, end)) {
  729. console.warn('[ElementCalendar]start time and end time interval must not exceed two months');
  730. return [];
  731. }
  732. data.push([start, lastDay]);
  733. var interval = startDay.getDay();
  734. interval = interval <= 1 ? Math.abs(interval - 1) : 8 - interval;
  735. startDay = this.toDate(startDay.getTime() + interval * oneDay);
  736. if (startDay.getDate() < end.getDate()) {
  737. data.push([startDay, end]);
  738. }
  739. return data;
  740. }
  741. return [];
  742. }
  743. },
  744. data: function data() {
  745. return {
  746. selectedDay: '',
  747. now: new Date()
  748. };
  749. }
  750. });
  751. // CONCATENATED MODULE: ./packages/calendar/src/main.vue?vue&type=script&lang=js&
  752. /* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_);
  753. // CONCATENATED MODULE: ./packages/calendar/src/main.vue
  754. /* normalize component */
  755. var main_component = Object(componentNormalizer["a" /* default */])(
  756. src_mainvue_type_script_lang_js_,
  757. render,
  758. staticRenderFns,
  759. false,
  760. null,
  761. null,
  762. null
  763. )
  764. /* hot reload */
  765. if (false) { var main_api; }
  766. main_component.options.__file = "packages/calendar/src/main.vue"
  767. /* harmony default export */ var main = (main_component.exports);
  768. // CONCATENATED MODULE: ./packages/calendar/index.js
  769. /* istanbul ignore next */
  770. main.install = function (Vue) {
  771. Vue.component(main.name, main);
  772. };
  773. /* harmony default export */ var calendar = __webpack_exports__["default"] = (main);
  774. /***/ }),
  775. /***/ 7:
  776. /***/ (function(module, exports) {
  777. module.exports = require("element-ui/lib/mixins/locale");
  778. /***/ })
  779. /******/ });