榆山
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
8.9 KiB

"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames=_interopRequireDefault(require("../helpers/classNames")),_index=_interopRequireDefault(require("./locales/index")),_props=require("./props");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(a,!0).forEach(function(e){_defineProperty(t,e,a[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):ownKeys(a).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))})}return t}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function _construct(e,t,a){return(_construct=isNativeReflectConstruct()?Reflect.construct:function(e,t,a){var r=[null];r.push.apply(r,t);var n=new(Function.bind.apply(e,r));return a&&_setPrototypeOf(n,a.prototype),n}).apply(null,arguments)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var t=0,a=new Array(e.length);t<e.length;t++)a[t]=e[t];return a}}var DATETIME="datetime",DATE="date",TIME="time",MONTH="month",YEAR="year",ONE_DAY=864e5;function fomartArray(e,t){for(var a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1,r=e,n=[];r<=t;)n.push(r),r+=a;return n}function getDaysInMonth(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function pad(e){return e<10?"0".concat(e):e+""}function cloneDate(e){return new Date(+e)}function setMonth(e,t){e.setDate(Math.min(e.getDate(),getDaysInMonth(new Date(e.getFullYear(),t)))),e.setMonth(t)}function valueToDate(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!Array.isArray(e))return"string"==typeof e&&(e=e.replace(/\-/g,"/")),isNaN(Number(e))||(e=Number(e)),new Date(e);var a=t.mode,r=t.use12Hours,n=new Date,i=n.getFullYear(),u=n.getMonth(),o=n.getDate(),s=e.map(function(e){return Number(e)});if(r&&[DATETIME,TIME].includes(a)){var l=a===DATETIME?3:0,c=s.length-1,h=Number(s[c]),f=Number(s[l]);f=1===h?(f<=12&&(f+=12),24<=f?0:f):(0===f&&(f=12),12<f&&(f-=12),12<=f?0:f),s.splice(l,1,f),s.splice(c,1)}for(a===TIME?(s.unshift(o),s.unshift(u),s.unshift(i)):a===MONTH?s.push(o):a===YEAR&&(s.push(u),s.push(o));s.length<=6;)s.push(0);return _construct(Date,_toConsumableArray(s))}(0,_baseComponent.default)({properties:_props.props,data:{inputValue:[],options:[]},observers:_defineProperty({inputValue:function(){this.updatedCols()},value:function(e){this.setValue(e)}},"mode, minuteStep, use12Hours, minDate, maxDate, minHour, maxHour, minMinute, maxMinute, lang",function(){this.setValue(this.data.inputValue)}),methods:{getDefaultMinDate:function(){return this.defaultMinDate||(this.defaultMinDate=new Date(2e3,1,1,0,0,0)),this.defaultMinDate},getDefaultMaxDate:function(){return this.defaultMaxDate||(this.defaultMaxDate=new Date(2030,1,1,23,59,59)),this.defaultMaxDate},getMinDate:function(){return this.data.minDate?valueToDate(this.data.minDate,this.data):this.getDefaultMinDate()},getMaxDate:function(){