UNPKG

@neuqb/cus-v-datepicker

Version:

a custom datepicker

1,730 lines (1,538 loc) 404 kB
import Vue from 'vue'; function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function getAugmentedNamespace(n) { if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; var f = n.default; if (typeof f == "function") { var a = function a () { var isInstance = false; try { isInstance = this instanceof a; } catch {} if (isInstance) { return Reflect.construct(f, arguments, this.constructor); } return f.apply(this, arguments); }; a.prototype = f.prototype; } else a = {}; Object.defineProperty(a, '__esModule', {value: true}); Object.keys(n).forEach(function (k) { var d = Object.getOwnPropertyDescriptor(n, k); Object.defineProperty(a, k, d.get ? d : { enumerable: true, get: function () { return n[k]; } }); }); return a; } var button = {exports: {}}; var hasRequiredButton; function requireButton () { if (hasRequiredButton) return button.exports; hasRequiredButton = 1; (function (module) { 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 = "/dist/"; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 96); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ (function(module, __webpack_exports__, __webpack_require__) { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; }); /* 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, 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 functioal 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 } } /***/ }), /***/ 96: /***/ (function(module, __webpack_exports__, __webpack_require__) { __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!./packages/button/src/button.vue?vue&type=template&id=ca859fb4& var render = function() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c( "button", { staticClass: "el-button", class: [ _vm.type ? "el-button--" + _vm.type : "", _vm.buttonSize ? "el-button--" + _vm.buttonSize : "", { "is-disabled": _vm.buttonDisabled, "is-loading": _vm.loading, "is-plain": _vm.plain, "is-round": _vm.round, "is-circle": _vm.circle } ], attrs: { disabled: _vm.buttonDisabled || _vm.loading, autofocus: _vm.autofocus, type: _vm.nativeType }, on: { click: _vm.handleClick } }, [ _vm.loading ? _c("i", { staticClass: "el-icon-loading" }) : _vm._e(), _vm.icon && !_vm.loading ? _c("i", { class: _vm.icon }) : _vm._e(), _vm.$slots.default ? _c("span", [_vm._t("default")], 2) : _vm._e() ] ) }; var staticRenderFns = []; render._withStripped = true; // CONCATENATED MODULE: ./packages/button/src/button.vue?vue&type=template&id=ca859fb4& // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/button/src/button.vue?vue&type=script&lang=js& // // // // // // // // // // // // // // // // // // // // // // // // /* harmony default export */ var buttonvue_type_script_lang_js_ = ({ name: 'ElButton', inject: { elForm: { default: '' }, elFormItem: { default: '' } }, props: { type: { type: String, default: 'default' }, size: String, icon: { type: String, default: '' }, nativeType: { type: String, default: 'button' }, loading: Boolean, disabled: Boolean, plain: Boolean, autofocus: Boolean, round: Boolean, circle: Boolean }, computed: { _elFormItemSize: function _elFormItemSize() { return (this.elFormItem || {}).elFormItemSize; }, buttonSize: function buttonSize() { return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size; }, buttonDisabled: function buttonDisabled() { return this.$options.propsData.hasOwnProperty('disabled') ? this.disabled : (this.elForm || {}).disabled; } }, methods: { handleClick: function handleClick(evt) { this.$emit('click', evt); } } }); // CONCATENATED MODULE: ./packages/button/src/button.vue?vue&type=script&lang=js& /* harmony default export */ var src_buttonvue_type_script_lang_js_ = (buttonvue_type_script_lang_js_); // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(0); // CONCATENATED MODULE: ./packages/button/src/button.vue /* normalize component */ var component = Object(componentNormalizer["a" /* default */])( src_buttonvue_type_script_lang_js_, render, staticRenderFns, false, null, null, null ); component.options.__file = "packages/button/src/button.vue"; /* harmony default export */ var src_button = (component.exports); // CONCATENATED MODULE: ./packages/button/index.js /* istanbul ignore next */ src_button.install = function (Vue) { Vue.component(src_button.name, src_button); }; /* harmony default export */ __webpack_exports__["default"] = (src_button); /***/ }) /******/ }); } (button)); return button.exports; } var buttonExports = requireButton(); var ElButton = /*@__PURE__*/getDefaultExportFromCjs(buttonExports); var defaultLang = { el: { colorpicker: { confirm: '确定', clear: '清空' }, datepicker: { now: '此刻', today: '今天', cancel: '取消', clear: '清空', confirm: '确定', selectDate: '选择日期', selectTime: '选择时间', startDate: '开始日期', startTime: '开始时间', endDate: '结束日期', endTime: '结束时间', prevYear: '前一年', nextYear: '后一年', prevMonth: '上个月', nextMonth: '下个月', year: '年', month1: '1 月', month2: '2 月', month3: '3 月', month4: '4 月', month5: '5 月', month6: '6 月', month7: '7 月', month8: '8 月', month9: '9 月', month10: '10 月', month11: '11 月', month12: '12 月', // week: '周次', weeks: { sun: '日', mon: '一', tue: '二', wed: '三', thu: '四', fri: '五', sat: '六' }, months: { jan: '一月', feb: '二月', mar: '三月', apr: '四月', may: '五月', jun: '六月', jul: '七月', aug: '八月', sep: '九月', oct: '十月', nov: '十一月', dec: '十二月' } }, select: { loading: '加载中', noMatch: '无匹配数据', noData: '无数据', placeholder: '请选择' }, cascader: { noMatch: '无匹配数据', loading: '加载中', placeholder: '请选择', noData: '暂无数据' }, pagination: { goto: '前往', pagesize: '条/页', total: '共 {total} 条', pageClassifier: '页' }, messagebox: { title: '提示', confirm: '确定', cancel: '取消', error: '输入的数据不合法!' }, upload: { deleteTip: '按 delete 键可删除', delete: '删除', preview: '查看图片', continue: '继续上传' }, table: { emptyText: '暂无数据', confirmFilter: '筛选', resetFilter: '重置', clearFilter: '全部', sumText: '合计' }, tree: { emptyText: '暂无数据' }, transfer: { noMatch: '无匹配数据', noData: '无数据', titles: ['列表 1', '列表 2'], filterPlaceholder: '请输入搜索内容', noCheckedFormat: '共 {total} 项', hasCheckedFormat: '已选 {checked}/{total} 项' }, image: { error: '加载失败' }, pageHeader: { title: '返回' }, popconfirm: { confirmButtonText: '确定', cancelButtonText: '取消' }, empty: { description: '暂无数据' } } }; var isMergeableObject = function isMergeableObject(value) { return isNonNullObject(value) && !isSpecial(value) }; function isNonNullObject(value) { return !!value && typeof value === 'object' } function isSpecial(value) { var stringValue = Object.prototype.toString.call(value); return stringValue === '[object RegExp]' || stringValue === '[object Date]' || isReactElement(value) } // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 var canUseSymbol = typeof Symbol === 'function' && Symbol.for; var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; function isReactElement(value) { return value.$$typeof === REACT_ELEMENT_TYPE } function emptyTarget(val) { return Array.isArray(val) ? [] : {} } function cloneIfNecessary(value, optionsArgument) { var clone = optionsArgument && optionsArgument.clone === true; return (clone && isMergeableObject(value)) ? deepmerge(emptyTarget(value), value, optionsArgument) : value } function defaultArrayMerge(target, source, optionsArgument) { var destination = target.slice(); source.forEach(function(e, i) { if (typeof destination[i] === 'undefined') { destination[i] = cloneIfNecessary(e, optionsArgument); } else if (isMergeableObject(e)) { destination[i] = deepmerge(target[i], e, optionsArgument); } else if (target.indexOf(e) === -1) { destination.push(cloneIfNecessary(e, optionsArgument)); } }); return destination } function mergeObject(target, source, optionsArgument) { var destination = {}; if (isMergeableObject(target)) { Object.keys(target).forEach(function(key) { destination[key] = cloneIfNecessary(target[key], optionsArgument); }); } Object.keys(source).forEach(function(key) { if (!isMergeableObject(source[key]) || !target[key]) { destination[key] = cloneIfNecessary(source[key], optionsArgument); } else { destination[key] = deepmerge(target[key], source[key], optionsArgument); } }); return destination } function deepmerge(target, source, optionsArgument) { var sourceIsArray = Array.isArray(source); var targetIsArray = Array.isArray(target); var options = optionsArgument || { arrayMerge: defaultArrayMerge }; var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; if (!sourceAndTargetTypesMatch) { return cloneIfNecessary(source, optionsArgument) } else if (sourceIsArray) { var arrayMerge = options.arrayMerge || defaultArrayMerge; return arrayMerge(target, source, optionsArgument) } else { return mergeObject(target, source, optionsArgument) } } deepmerge.all = function deepmergeAll(array, optionsArgument) { if (!Array.isArray(array) || array.length < 2) { throw new Error('first argument should be an array with at least two elements') } // we are sure there are at least 2 values, so it is safe to have no initial value return array.reduce(function(prev, next) { return deepmerge(prev, next, optionsArgument) }) }; var deepmerge_1 = deepmerge; if (typeof /./ !== 'function' && typeof Int8Array !== 'object' && (Vue.prototype.$isServer || typeof document.childNodes !== 'function')) ; const hasOwnProperty = Object.prototype.hasOwnProperty; function hasOwn(obj, key) { return hasOwnProperty.call(obj, key); } // TODO: use native Array.find, Array.findIndex when IE support is dropped const arrayFindIndex = function(arr, pred) { for (let i = 0; i !== arr.length; ++i) { if (pred(arr[i])) { return i; } } return -1; }; const arrayFind = function(arr, pred) { const idx = arrayFindIndex(arr, pred); return idx !== -1 ? arr[idx] : undefined; }; // coerce truthy value to array const coerceTruthyValueToArray = function(val) { if (Array.isArray(val)) { return val; } else if (val) { return [val]; } else { return []; } }; const kebabCase = function(str) { const hyphenateRE = /([^-])([A-Z])/g; return str .replace(hyphenateRE, '$1-$2') .replace(hyphenateRE, '$1-$2') .toLowerCase(); }; const isMac = function() { return !Vue.prototype.$isServer && /macintosh|mac os x/i.test(navigator.userAgent); }; const RE_NARGS = /(%|)\{([0-9a-zA-Z_]+)\}/g; /** * String format template * - Inspired: * https://github.com/Matt-Esch/string-template/index.js */ function Format(Vue) { /** * template * * @param {String} string * @param {Array} ...args * @return {String} */ function template(string, ...args) { if (args.length === 1 && typeof args[0] === 'object') { args = args[0]; } if (!args || !args.hasOwnProperty) { args = {}; } return string.replace(RE_NARGS, (match, prefix, i, index) => { let result; if (string[index - 1] === '{' && string[index + match.length] === '}') { return i; } else { result = hasOwn(args, i) ? args[i] : null; if (result === null || result === undefined) { return ''; } return result; } }); } return template; } const format = Format(); let lang = defaultLang; let merged = false; let i18nHandler = function() { const vuei18n = Object.getPrototypeOf(this || Vue).$t; if (typeof vuei18n === 'function' && !!Vue.locale) { if (!merged) { merged = true; Vue.locale( Vue.config.lang, deepmerge_1(lang, Vue.locale(Vue.config.lang) || {}, { clone: true }) ); } return vuei18n.apply(this, arguments); } }; const t = function(path, options) { let value = i18nHandler.apply(this, arguments); if (value !== null && value !== undefined) return value; const array = path.split('.'); let current = lang; for (let i = 0, j = array.length; i < j; i++) { const property = array[i]; value = current[property]; if (i === j - 1) return format(value, options); if (!value) return ''; current = value; } return ''; }; var Locale = { methods: { t(...args) { return t.apply(this, args); } } }; /* istanbul ignore next */ const isServer = Vue.prototype.$isServer; /* istanbul ignore next */ const trim = function(string) { return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, ''); }; /* istanbul ignore next */ const on = (function() { if (!isServer && document.addEventListener) { return function(element, event, handler) { if (element && event && handler) { element.addEventListener(event, handler, false); } }; } else { return function(element, event, handler) { if (element && event && handler) { element.attachEvent('on' + event, handler); } }; } })(); /* istanbul ignore next */ const off = (function() { if (!isServer && document.removeEventListener) { return function(element, event, handler) { if (element && event) { element.removeEventListener(event, handler, false); } }; } else { return function(element, event, handler) { if (element && event) { element.detachEvent('on' + event, handler); } }; } })(); /* istanbul ignore next */ const once = function(el, event, fn) { var listener = function() { if (fn) { fn.apply(this, arguments); } off(el, event, listener); }; on(el, event, listener); }; /* istanbul ignore next */ function hasClass(el, cls) { if (!el || !cls) return false; if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.'); if (el.classList) { return el.classList.contains(cls); } else { return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1; } } /* istanbul ignore next */ function addClass(el, cls) { if (!el) return; var curClass = el.className; var classes = (cls || '').split(' '); for (var i = 0, j = classes.length; i < j; i++) { var clsName = classes[i]; if (!clsName) continue; if (el.classList) { el.classList.add(clsName); } else if (!hasClass(el, clsName)) { curClass += ' ' + clsName; } } if (!el.classList) { el.setAttribute('class', curClass); } } /* istanbul ignore next */ function removeClass(el, cls) { if (!el || !cls) return; var classes = cls.split(' '); var curClass = ' ' + el.className + ' '; for (var i = 0, j = classes.length; i < j; i++) { var clsName = classes[i]; if (!clsName) continue; if (el.classList) { el.classList.remove(clsName); } else if (hasClass(el, clsName)) { curClass = curClass.replace(' ' + clsName + ' ', ' '); } } if (!el.classList) { el.setAttribute('class', trim(curClass)); } } const nodeList = []; const ctx = '@@clickoutsideContext'; let startClick; let seed = 0; !Vue.prototype.$isServer && on(document, 'mousedown', e => (startClick = e)); !Vue.prototype.$isServer && on(document, 'mouseup', e => { nodeList.forEach(node => node[ctx].documentHandler(e, startClick)); }); function createDocumentHandler(el, binding, vnode) { return function(mouseup = {}, mousedown = {}) { if (!vnode || !vnode.context || !mouseup.target || !mousedown.target || el.contains(mouseup.target) || el.contains(mousedown.target) || el === mouseup.target || (vnode.context.popperElm && (vnode.context.popperElm.contains(mouseup.target) || vnode.context.popperElm.contains(mousedown.target)))) return; if (binding.expression && el[ctx].methodName && vnode.context[el[ctx].methodName]) { vnode.context[el[ctx].methodName](); } else { el[ctx].bindingFn && el[ctx].bindingFn(); } }; } /** * v-clickoutside * @desc 点击元素外面才会触发的事件 * @example * ```vue * <div v-element-clickoutside="handleClose"> * ``` */ var Clickoutside = { bind(el, binding, vnode) { nodeList.push(el); const id = seed++; el[ctx] = { id, documentHandler: createDocumentHandler(el, binding, vnode), methodName: binding.expression, bindingFn: binding.value }; }, update(el, binding, vnode) { el[ctx].documentHandler = createDocumentHandler(el, binding, vnode); el[ctx].methodName = binding.expression; el[ctx].bindingFn = binding.value; }, unbind(el) { let len = nodeList.length; for (let i = 0; i < len; i++) { if (nodeList[i][ctx].id === el[ctx].id) { nodeList.splice(i, 1); break; } } delete el[ctx]; } }; var date$1 = {exports: {}}; /* Modified from https://github.com/taylorhakes/fecha * * The MIT License (MIT) * * Copyright (c) 2015 Taylor Hakes * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ var date = date$1.exports; var hasRequiredDate; function requireDate () { if (hasRequiredDate) return date$1.exports; hasRequiredDate = 1; (function (module) { /*eslint-disable*/ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd (function (main) { /** * Parse or format dates * @class fecha */ var fecha = {}; var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g; var twoDigits = '\\d\\d?'; var threeDigits = '\\d{3}'; var fourDigits = '\\d{4}'; var word = '[^\\s]+'; var literal = /\[([^]*?)\]/gm; var noop = function () { }; function regexEscape(str) { return str.replace( /[|\\{()[^$+*?.-]/g, '\\$&'); } function shorten(arr, sLen) { var newArr = []; for (var i = 0, len = arr.length; i < len; i++) { newArr.push(arr[i].substr(0, sLen)); } return newArr; } function monthUpdate(arrName) { return function (d, v, i18n) { var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase()); if (~index) { d.month = index; } }; } function pad(val, len) { val = String(val); len = len || 2; while (val.length < len) { val = '0' + val; } return val; } var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; var monthNamesShort = shorten(monthNames, 3); var dayNamesShort = shorten(dayNames, 3); fecha.i18n = { dayNamesShort: dayNamesShort, dayNames: dayNames, monthNamesShort: monthNamesShort, monthNames: monthNames, amPm: ['am', 'pm'], DoFn: function DoFn(D) { return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10]; } }; var formatFlags = { D: function(dateObj) { return dateObj.getDay(); }, DD: function(dateObj) { return pad(dateObj.getDay()); }, Do: function(dateObj, i18n) { return i18n.DoFn(dateObj.getDate()); }, d: function(dateObj) { return dateObj.getDate(); }, dd: function(dateObj) { return pad(dateObj.getDate()); }, ddd: function(dateObj, i18n) { return i18n.dayNamesShort[dateObj.getDay()]; }, dddd: function(dateObj, i18n) { return i18n.dayNames[dateObj.getDay()]; }, M: function(dateObj) { return dateObj.getMonth() + 1; }, MM: function(dateObj) { return pad(dateObj.getMonth() + 1); }, MMM: function(dateObj, i18n) { return i18n.monthNamesShort[dateObj.getMonth()]; }, MMMM: function(dateObj, i18n) { return i18n.monthNames[dateObj.getMonth()]; }, yy: function(dateObj) { return pad(String(dateObj.getFullYear()), 4).substr(2); }, yyyy: function(dateObj) { return pad(dateObj.getFullYear(), 4); }, h: function(dateObj) { return dateObj.getHours() % 12 || 12; }, hh: function(dateObj) { return pad(dateObj.getHours() % 12 || 12); }, H: function(dateObj) { return dateObj.getHours(); }, HH: function(dateObj) { return pad(dateObj.getHours()); }, m: function(dateObj) { return dateObj.getMinutes(); }, mm: function(dateObj) { return pad(dateObj.getMinutes()); }, s: function(dateObj) { return dateObj.getSeconds(); }, ss: function(dateObj) { return pad(dateObj.getSeconds()); }, S: function(dateObj) { return Math.round(dateObj.getMilliseconds() / 100); }, SS: function(dateObj) { return pad(Math.round(dateObj.getMilliseconds() / 10), 2); }, SSS: function(dateObj) { return pad(dateObj.getMilliseconds(), 3); }, a: function(dateObj, i18n) { return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1]; }, A: function(dateObj, i18n) { return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase(); }, ZZ: function(dateObj) { var o = dateObj.getTimezoneOffset(); return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4); } }; var parseFlags = { d: [twoDigits, function (d, v) { d.day = v; }], Do: [twoDigits + word, function (d, v) { d.day = parseInt(v, 10); }], M: [twoDigits, function (d, v) { d.month = v - 1; }], yy: [twoDigits, function (d, v) { var da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2); d.year = '' + (v > 68 ? cent - 1 : cent) + v; }], h: [twoDigits, function (d, v) { d.hour = v; }], m: [twoDigits, function (d, v) { d.minute = v; }], s: [twoDigits, function (d, v) { d.second = v; }], yyyy: [fourDigits, function (d, v) { d.year = v; }], S: ['\\d', function (d, v) { d.millisecond = v * 100; }], SS: ['\\d{2}', function (d, v) { d.millisecond = v * 10; }], SSS: [threeDigits, function (d, v) { d.millisecond = v; }], D: [twoDigits, noop], ddd: [word, noop], MMM: [word, monthUpdate('monthNamesShort')], MMMM: [word, monthUpdate('monthNames')], a: [word, function (d, v, i18n) { var val = v.toLowerCase(); if (val === i18n.amPm[0]) { d.isPm = false; } else if (val === i18n.amPm[1]) { d.isPm = true; } }], ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) { var parts = (v + '').match(/([+-]|\d\d)/gi), minutes; if (parts) { minutes = +(parts[1] * 60) + parseInt(parts[2], 10); d.timezoneOffset = parts[0] === '+' ? minutes : -minutes; } }] }; parseFlags.dd = parseFlags.d; parseFlags.dddd = parseFlags.ddd; parseFlags.DD = parseFlags.D; parseFlags.mm = parseFlags.m; parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h; parseFlags.MM = parseFlags.M; parseFlags.ss = parseFlags.s; parseFlags.A = parseFlags.a; // Some common format strings fecha.masks = { default: 'ddd MMM dd yyyy HH:mm:ss', shortDate: 'M/D/yy', mediumDate: 'MMM d, yyyy', longDate: 'MMMM d, yyyy', fullDate: 'dddd, MMMM d, yyyy', shortTime: 'HH:mm', mediumTime: 'HH:mm:ss', longTime: 'HH:mm:ss.SSS' }; /*** * Format a date * @method format * @param {Date|number} dateObj * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate' */ fecha.format = function (dateObj, mask, i18nSettings) { var i18n = i18nSettings || fecha.i18n; if (typeof dateObj === 'number') { dateObj = new Date(dateObj); } if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) { throw new Error('Invalid Date in fecha.format'); } mask = fecha.masks[mask] || mask || fecha.masks['default']; var literals = []; // Make literals inactive by replacing them with ?? mask = mask.replace(literal, function($0, $1) { literals.push($1); return '@@@'; }); // Apply formatting rules mask = mask.replace(token, function ($0) { return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1); }); // Inline literal values back into the formatted value return mask.replace(/@@@/g, function() { return literals.shift(); }); }; /** * Parse a date string into an object, changes - into / * @method parse * @param {string} dateStr Date string * @param {string} format Date parse format * @returns {Date|boolean} */ fecha.parse = function (dateStr, format, i18nSettings) { var i18n = i18nSettings || fecha.i18n; if (typeof format !== 'string') { throw new Error('Invalid format in fecha.parse'); } format = fecha.masks[format] || format; // Avoid regular expression denial of service, fail early for really long strings // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS if (dateStr.length > 1000) { return null; } var dateInfo = {}; var parseInfo = []; var literals = []; format = format.replace(literal, function($0, $1) { literals.push($1); return '@@@'; }); var newFormat = regexEscape(format).replace(token, function ($0) { if (parseFlags[$0]) { var info = parseFlags[$0]; parseInfo.push(info[1]); return '(' + info[0] + ')'; } return $0; }); newFormat = newFormat.replace(/@@@/g, function() { return literals.shift(); }); var matches = dateStr.match(new RegExp(newFormat, 'i')); if (!matches) { return null; } for (var i = 1; i < matches.length; i++) { parseInfo[i - 1](dateInfo, matches[i], i18n); } var today = new Date(); if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) { dateInfo.hour = +dateInfo.hour + 12; } else if (dateInfo.isPm === false && +dateInfo.hour === 12) { dateInfo.hour = 0; } var date; if (dateInfo.timezoneOffset != null) { dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset; date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0)); } else { date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0); } return date; }; /* istanbul ignore next */ if (module.exports) { module.exports = fecha; } else { main.fecha = fecha; } })(date); } (date$1)); return date$1.exports; } var dateExports = requireDate(); var fecha = /*@__PURE__*/getDefaultExportFromCjs(dateExports); const weeks = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']; const months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; const newArray = function(start, end) { let result = []; for (let i = start; i <= end; i++) { result.push(i); } return result; }; const getI18nSettings = () => { return { dayNamesShort: weeks.map(week => t(`el.datepicker.weeks.${ week }`)), dayNames: weeks.map(week => t(`el.datepicker.weeks.${ week }`)), monthNamesShort: months.map(month => t(`el.datepicker.months.${ month }`)), monthNames: months.map((month, index) => t(`el.datepicker.month${ index + 1 }`)), amPm: ['am', 'pm'] }; }; const toDate = function(date) { return isDate(date) ? new Date(date) : null; }; const isDate = function(date) { if (date === null || date === undefined) return false; if (isNaN(new Date(date).getTime())) return false; if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()` return true; }; const isDateObject = function(val) { return val instanceof Date; }; const formatDate = function(date, format) { date = toDate(date); if (!date) return ''; return fecha.format(date, format || 'yyyy-MM-dd', getI18nSettings()); }; const parseDate = function(string, format) { return fecha.parse(string, format || 'yyyy-MM-dd', getI18nSettings()); }; const getDayCountOfMonth = function(year, month) { if (isNaN(+month)) return 31; return new Date(year, +month + 1, 0).getDate(); }; const getDayCountOfYear = function(year) { const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0); return isLeapYear ? 366 : 365; }; const getFirstDayOfMonth = function(date) { const temp = new Date(date.getTime()); temp.setDate(1); return temp.getDay(); }; // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript // {prev, next} Date should work for Daylight Saving Time // Adding 24 * 60 * 60 * 1000 does not work in the above scenario const prevDate = function(date, amount = 1) { return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount); }; const nextDate = function(date, amount = 1) { return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount); }; const getStartDateOfMonth = function(year, month) { const result = new Date(year, month, 1); const day = result.getDay(); if (day === 0) { return prevDate(result, 7); } else { return prevDate(result, day); } }; const getWeekNumber = function(src) { if (!isDate(src)) return null; const date = new Date(src.getTime()); date.setHours(0, 0, 0, 0); // Thursday in current week decides the year. date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7); // January 4 is always in week 1. const week1 = new Date(date.getFullYear(), 0, 4); // Adjust to Thursday in week 1 and count number of weeks from date to week 1. // Rounding should be fine for Daylight Saving Time. Its shift should never be more than 12 hours. return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7); }; const getRangeHours = function(ranges) { const hours = []; let disabledHours = []; (ranges || []).forEach(range => { const value = range.map(date => date.getHours()); disabledHours = disabledHours.concat(newArray(value[0], value[1])); }); if (disabledHours.length) { for (let i = 0; i < 24; i++) { hours[i] = disabledHours.indexOf(i) === -1; } } else { for (let i = 0; i < 24; i++) { hours[i] = false; } } return hours; }; function setRangeData(arr, start, end, value) { for (let i = start; i < end; i++) { arr[i] = value; } } const getRangeMinutes = function(ranges, hour) { const minutes = new Array(60); if (ranges.length > 0) { ranges.forEach(range => { const start = range[0]; const end = range[1]; const startHour = start.getHours(); const startMinute = start.getMinutes(); const endHour = end.getHours(); const endMinute = end.getMinutes(); if (startHour === hour && endHour !== hour) { setRangeData(minutes, startMinute, 60, true); } else if (startHour === hour && endHour === hour) { setRangeData(minutes, startMinute, endMinute + 1, true); } else if (startHour !== hour && endHour === hour) { setRangeData(minutes, 0, endMinute + 1, true); } else if (startHour < hour && endHour > hour) { setRangeData(minutes, 0, 60, true); } }); } else { setRangeData(minutes, 0, 60, true); } return minutes; }; const range = function(n) { // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n return Array.apply(null, {length: n}).map((_, n) => n); }; const modifyDate = function(date, y, m, d) { return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()); }; const modifyTime = function(date, h, m, s) { return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds()); }; const modifyWithTimeString = (date, time) => { if (date == null || !time) { return date; } time = parseDate(time, 'HH:mm:ss'); return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds()); }; const clearTime = function(date) { return new Date(date.getFullYear(), date.getMonth(), date.getDate()); }; const clearMilliseconds = function(date) { return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0); }; const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') { // TODO: refactory a more elegant solution if (ranges.length === 0) return date; const normalizeDate = date => fecha.parse(fecha.format(date, format), format); const ndate = normalizeDate(date); const nranges = ranges.map(range => range.map(normalizeDate)); if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date; let minDate = nranges[0][0]; let maxDate = nranges[0][0]; nranges.forEach(nrange => { minDate = new Date(Math.min(nrange[0], minDate)); maxDate = new Date(Math.max(nrange[1], minDate)); }); const ret = ndate < minDate ? minDate : maxDate; // preserve Year/Month/Date return modifyDate( ret, date.getFullYear(), date.getMonth(), date.getDate() ); }; const timeWithinRange = function(date, selectableRange, format) { const limitedDate = limitTimeRange(date, selectableRange, format); return limitedDate.getTime() === date.getTime(); }; const changeYearMonthAndClampDate = function(date, year, month) { // clamp date to the number of days in `year`, `month` // eg: (2010-1-31, 2010, 2) => 2010-2-28 const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month)); return modifyDate(date, year, month, monthDate); }; const prevMonth = function(date) { const year = date.getFullYear(); const month = date.getMonth(); return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1); }; const nextMonth = function(date) { const year = date.getFullYear(); const month = date.getMonth(); return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1); }; const prevYear = function(date, amount = 1) { const year = date.getFullYear(); const month = date.getMonth(); return changeYearMonthAndClampDate(date, year - amount, month); }; const nextYear = function(date, amount = 1) { const year = date.getFullYear(); const month = date.getMonth(); return changeYearMonthAndClampDate(date, year + amount, month); }; const extractDateFormat = function(format) { return format .replace(/\W?m{1,2}|\W?ZZ/g, '') .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '') .trim(); }; const extractTimeFormat = function(format) { return format .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '') .trim(); }; function broadcast(componentName, eventName, params) { this.$children.forEach(child => { var name = child.$options.componentName; if (name === componentName) { child.$emit.apply(child, [eventName].concat(params)); } else { broadcast.apply(child, [componentName, eventName].concat([params])); } }); } var Emitter = { methods: { dispatch(componentName, eventName, params) { var parent = this.$parent || this.$root; var name = parent.$options.componentName; while (parent && (!name || name !== componentName)) { parent = parent.$parent; if (parent) { name = parent.$options.componentName; } } if (parent) { parent.$emit.apply(parent, [eventName].concat(params)); } }, broadcast(componentName, eventName, params) { broadcast.call(this, componentName, eventName, params); } } }; /** * Show migrating guide in browser console. * * Usage: * import Migrating from 'element-ui/src/mixins/migrating'; * * mixins: [Migrating] * * add getMigratingConfig method for your component. * getMigratingConfig() { * return { * props: { * 'allow-no-selection': 'allow-no-selection is removed.', * 'selection-mode': 'selection-mode is removed.' * }, * events: { * selectionchange: 'selectionchange is renamed to selection-change.' * } * }; * }, */ var Migrating = { mounted() { if (process.env.NODE_ENV === 'production') return; if (!this.$vnode) return; const { props = {}, events = {} } = this.getMigratingConfig(); const { data, componentOptions } = this.$vnode; const definedProps = data.attrs || {}; const definedEvents = componentOptions.listeners || {}; for (let propName in definedProps) { propName = kebabCase(propName); // compatible with camel case if (props[propName]) { console.warn(`[Element Migrating][${this.$options.name}][Attribute]: ${props[propName]}`); } } for (let eventName in definedEvents) { eventName = kebabCase(eventName); // compatible with camel case if (events[eventName]) { console.warn(`[Element Migrating][${this.$options.name}][Event]: ${events[eventName]}`); } } }, methods: { getMigratingConfig() { return { props: {}, events: {} }; } } }; function merge(target) { for (let i = 1, j = arguments.length; i < j; i++) { let source = arguments[i] || {}; for (let prop in source) { if (source.hasOwnProperty(prop)) { let value = source[prop]; if (value !== undefined) { target[prop] = value; } } } } return target; } function isKorean(text) { const reg = /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi; return reg.test(text); } const defaultArray = []; const emptyString$1 = ''; function adjustCaretPosition({ previousConformedValue = emptyString$1, previousPlaceholder = emptyString$1, currentCaretPosition = 0, conformedValue, rawValue, placeholderChar, placeholder, indexesOfPipedChars = defaultArray, caretTrapIndexes = defaultArray }) { if (currentCaretPosition === 0 || !rawValue.length) { return 0 } // Store lengths for faster performance? const rawValueLength = rawValue.length; const previousConformedValueLength = previousConformedValue.length; const placeholderLength = placeholder.length; const conformedValueLength = conformedValue.length; // This tells us how long the edit is. If user modified input from `(2__)` to `(243__)`, // we know the user in this instance pasted two characters const editLength = rawValueLength - previousConformedValueLength; // If the edit length is positive, that means the user is adding characters, not deleting. const isAddition = editLength > 0; // This is the first raw value the user entered that needs to be conformed to mask const isFirstRawValue = previousConformedValueLength === 0; // A partial multi-character edit happens when the user makes a partial selection in their // input and edits that selection. That is going from `(123) 432-4348` to `() 432-4348` by // selecting the first 3 digits and pressing backspace. // // Such cases can also happen when the user presses the backspace while holding down the ALT // key. const isPartialMultiCharEdit = editLength > 1 && !isAddition && !isFirstRawValue; // This algorithm doesn't support all cases of multi-character edits, so we just return // the current caret position. // // This works fine for most cases. if (isPartialMultiCharEdit) { return currentCaretPosition } // For a mask like (111), if the `previousConformedValue` is (1__) and user attempts to enter // `f` so the `rawValue` becomes (1f__), the new `conformedValue` would be (1__), which is the // same as the original `previousConformedValue`. We handle this case differently for caret // positioning. const