UNPKG

ten-design-vue

Version:

ten-vue

602 lines (538 loc) 20.7 kB
module.exports = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 3); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports) { module.exports = require("../util"); /***/ }), /* 1 */ /***/ (function(module, exports) { module.exports = require("../basic/header"); /***/ }), /* 2 */ /***/ (function(module, exports) { module.exports = require("../basic/table"); /***/ }), /* 3 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./src/components/date-picker/panel/date-range.vue?vue&type=template&id=3406c0f9& var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"ten-date-range"},[_c('div',{staticClass:"ten-date"},[_c('ten-date-header',{attrs:{"year":_vm.leftYear,"month":_vm.leftMonth,"type":_vm.leftType},on:{"update:type":[function($event){_vm.leftType=$event},_vm.onTypeChange],"btn-click":function (a, b) { return _vm.onHeaderClick(a, b, _vm.LEFT); }}}),_c('ten-date-table',{attrs:{"type":_vm.leftType,"first-day-of-week":_vm.firstDayOfWeek,"data":_vm.leftData,"on-item-click":_vm.getClickHandler(_vm.LEFT),"on-item-mouse-enter":_vm.onMouseEnter}})],1),_c('div',{staticClass:"ten-date"},[_c('ten-date-header',{attrs:{"year":_vm.rightYear,"month":_vm.rightMonth,"type":_vm.rightType},on:{"update:type":[function($event){_vm.rightType=$event},_vm.onTypeChange],"btn-click":function (a, b) { return _vm.onHeaderClick(a, b, _vm.RIGHT); }}}),_c('ten-date-table',{attrs:{"type":_vm.rightType,"first-day-of-week":_vm.firstDayOfWeek,"data":_vm.rightData,"on-item-click":_vm.getClickHandler(_vm.RIGHT),"on-item-mouse-enter":_vm.onMouseEnter}})],1)])} var staticRenderFns = [] // CONCATENATED MODULE: ./src/components/date-picker/panel/date-range.vue?vue&type=template&id=3406c0f9& // EXTERNAL MODULE: external "../basic/header" var header_ = __webpack_require__(1); var header_default = /*#__PURE__*/__webpack_require__.n(header_); // EXTERNAL MODULE: external "../basic/table" var table_ = __webpack_require__(2); var table_default = /*#__PURE__*/__webpack_require__.n(table_); // EXTERNAL MODULE: external "../util" var external_util_ = __webpack_require__(0); // CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--1!./node_modules/vue-loader/lib??vue-loader-options!./src/components/date-picker/panel/date-range.vue?vue&type=script&lang=js& function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // var TODAY = Object(external_util_["getToday"])(); /* harmony default export */ var date_rangevue_type_script_lang_js_ = ({ name: 'TenDatePickerDateRange', inject: { picker: { from: 'picker', default: undefined } }, components: { TenDateHeader: header_default.a, TenDateTable: table_default.a }, inheritAttrs: false, props: { mode: { type: String, default: 'date', validator: function validator(v) { return ['year', 'month', 'date'].indexOf(v) > -1; } }, value: { type: Array, default: function _default() { return [TODAY, TODAY]; } }, minDate: Date, maxDate: Date, firstDayOfWeek: Number, disabledDate: Function }, data: function data() { return _objectSpread(_objectSpread({}, this.getLeftAndRightDataFromValue(this.value)), {}, { leftType: this.mode, rightType: this.mode, startValue: null, endValue: null }); }, computed: { leftData: function leftData() { return this.getData({ year: this.leftYear, month: this.leftMonth, type: this.leftType }); }, rightData: function rightData() { return this.getData({ year: this.rightYear, month: this.rightMonth, type: this.rightType }); } }, watch: { value: { handler: function handler(value) { var _value = _slicedToArray(value, 2), _value$ = _value[0], startValue = _value$ === void 0 ? TODAY : _value$, _value$2 = _value[1], endValue = _value$2 === void 0 ? TODAY : _value$2; this.startValue = startValue; this.endValue = endValue; }, immediate: true }, mode: function mode(value) { this.leftType = value; this.rightType = value; } }, beforeCreate: function beforeCreate() { this.LEFT = 'left'; this.RIGHT = 'right'; this.isFirstClick = true; this.firstClickValue = TODAY; }, created: function created() { this.picker && this.picker.$on('popupShowChange', this.initialPicker); }, beforeDestroy: function beforeDestroy() { this.picker && this.picker.$off('popupShowChange', this.initialPicker); }, methods: { initialPicker: function initialPicker(popupShow) { if (!popupShow) return; var data = this.getLeftAndRightDataFromValue(this.value); this.leftYear = data.leftYear; this.leftMonth = data.leftMonth; this.rightYear = data.rightYear; this.rightMonth = data.rightMonth; }, getLeftAndRightDataFromValue: function getLeftAndRightDataFromValue(value) { var _ref = value || this.value, _ref2 = _slicedToArray(_ref, 2), _ref2$ = _ref2[0], startValue = _ref2$ === void 0 ? TODAY : _ref2$, _ref2$2 = _ref2[1], endValue = _ref2$2 === void 0 ? TODAY : _ref2$2; var leftYear = startValue.getFullYear(); var leftMonth = startValue.getMonth(); var rightMonth = endValue.getMonth(); var rightYear = endValue.getFullYear(); if (this.mode === 'date' && Object(external_util_["isSame"])(startValue, endValue, 'month')) { var next = Object(external_util_["addMonth"])(endValue, 1); rightMonth = new Date(endValue).getMonth() + 1; rightYear = next.getFullYear(); } if (this.mode === 'month' && Object(external_util_["isSame"])(startValue, endValue, 'year')) { rightYear = leftYear + 1; } if (this.mode === 'year' && Object(external_util_["isSame"])(startValue, endValue, 'year')) { rightYear = leftYear + 10; } return { leftYear: leftYear, leftMonth: leftMonth, rightMonth: rightMonth, rightYear: rightYear }; }, getData: function getData(_ref3) { var year = _ref3.year, month = _ref3.month, type = _ref3.type; var disabledDate = this.disabledDate, minDate = this.minDate, maxDate = this.maxDate, firstDayOfWeek = this.firstDayOfWeek, startValue = this.startValue, endValue = this.endValue; var data; var start = startValue; var end = endValue; var options = { disabledDate: disabledDate, minDate: minDate, maxDate: maxDate, firstDayOfWeek: firstDayOfWeek }; switch (type) { case 'date': data = Object(external_util_["getWeeks"])({ year: year, month: month }, options); break; case 'month': data = Object(external_util_["getMonths"])(year, options); break; case 'year': data = Object(external_util_["getYears"])(year, options); break; default: break; } return Object(external_util_["flagActive"])(data, { start: start, end: end, type: type }); }, getClickHandler: function getClickHandler(direction) { var _this = this; var type = this["".concat(direction, "Type")]; return function (date) { return _this["click".concat(Object(external_util_["firstUpperCase"])(type))](date, direction); }; }, onHeaderClick: function onHeaderClick(btnType, flag) { this.clickHeader(btnType, flag, this.LEFT); this.clickHeader(btnType, flag, this.RIGHT); }, clickHeader: function clickHeader(btnType, flag, direction) { var year = this["".concat(direction, "Year")]; var month = this["".concat(direction, "Month")]; var type = this["".concat(direction, "Type")]; var monthCount; var next; switch (type) { case 'date': monthCount = btnType === 'double' ? 12 : 1; break; case 'month': monthCount = btnType === 'double' ? 60 : 12; break; case 'year': monthCount = btnType === 'double' ? 240 : 120; } var current = new Date(year, month); if (flag === 1) { next = Object(external_util_["addMonth"])(current, monthCount); } else { next = Object(external_util_["subtractMonth"])(current, monthCount); } this["".concat(direction, "Year")] = next.getFullYear(); this["".concat(direction, "Month")] = next.getMonth(); }, clickDate: function clickDate(date) { if (this.isFirstClick) { this.startValue = date; this.endValue = date; this.isFirstClick = false; this.firstClickValue = date; } else { this.$emit('change', [this.startValue, Object(external_util_["setDateTime"])(this.endValue, 23, 59, 59)]); this.isFirstClick = true; } }, clickYear: function clickYear(date, type) { if (this.mode === 'year') { if (this.isFirstClick) { this.startValue = date; this.isFirstClick = false; this.firstClickValue = date; } else { this.$emit('change', [this.startValue, this.endValue]); this.isFirstClick = true; } } else { this["".concat(type, "Type")] = 'month'; this["".concat(type, "Year")] = date.getFullYear(); } }, clickMonth: function clickMonth(date, type) { if (this.mode === 'month') { if (this.isFirstClick) { this.startValue = date; this.isFirstClick = false; this.firstClickValue = date; } else { if (this.endValue < this.startValue) { this.endValue = this.startValue; } this.$emit('change', [this.startValue, this.endValue]); this.isFirstClick = true; } } else { this["".concat(type, "Type")] = 'date'; this["".concat(type, "Month")] = date.getMonth(); this["".concat(type, "Year")] = date.getFullYear(); } }, onMouseEnter: function onMouseEnter(date) { if (this.isFirstClick) { return; } if (this.firstClickValue.getTime() > date.getTime()) { this.startValue = date; this.endValue = this.firstClickValue; } else { this.startValue = this.firstClickValue; this.endValue = date; } }, onTypeChange: function onTypeChange() { this.startValue = this.firstClickValue; this.endValue = this.firstClickValue; } } }); // CONCATENATED MODULE: ./src/components/date-picker/panel/date-range.vue?vue&type=script&lang=js& /* harmony default export */ var panel_date_rangevue_type_script_lang_js_ = (date_rangevue_type_script_lang_js_); // CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js /* globals __VUE_SSR_CONTEXT__ */ // IMPORTANT: Do NOT use ES2015 features in this file (except for modules). // This module is a runtime utility for cleaner component module output and will // be included in the final webpack user bundle. function normalizeComponent ( scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, /* server only */ shadowMode /* vue-cli only */ ) { // Vue.extend constructor export interop var options = typeof scriptExports === 'function' ? scriptExports.options : scriptExports // render functions if (render) { options.render = render options.staticRenderFns = staticRenderFns options._compiled = true } // functional template if (functionalTemplate) { options.functional = true } // scopedId if (scopeId) { options._scopeId = 'data-v-' + scopeId } var hook if (moduleIdentifier) { // server build hook = function (context) { // 2.3 injection context = context || // cached call (this.$vnode && this.$vnode.ssrContext) || // stateful (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional // 2.2 with runInNewContext: true if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { context = __VUE_SSR_CONTEXT__ } // inject component styles if (injectStyles) { injectStyles.call(this, context) } // register component module identifier for async chunk inferrence if (context && context._registeredComponents) { context._registeredComponents.add(moduleIdentifier) } } // used by ssr in case component is cached and beforeCreate // never gets called options._ssrRegister = hook } else if (injectStyles) { hook = shadowMode ? function () { injectStyles.call( this, (options.functional ? this.parent : this).$root.$options.shadowRoot ) } : injectStyles } if (hook) { if (options.functional) { // for template-only hot-reload because in that case the render fn doesn't // go through the normalizer options._injectStyles = hook // register for functional component in vue file var originalRender = options.render options.render = function renderWithStyleInjection (h, context) { hook.call(context) return originalRender(h, context) } } else { // inject component registration as beforeCreate hook var existing = options.beforeCreate options.beforeCreate = existing ? [].concat(existing, hook) : [hook] } } return { exports: scriptExports, options: options } } // CONCATENATED MODULE: ./src/components/date-picker/panel/date-range.vue /* normalize component */ var component = normalizeComponent( panel_date_rangevue_type_script_lang_js_, render, staticRenderFns, false, null, null, null ) /* harmony default export */ var date_range = __webpack_exports__["default"] = (component.exports); /***/ }) /******/ ]);