time-select.js 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736
  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 = 75);
  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. /***/ 10:
  184. /***/ (function(module, exports) {
  185. module.exports = require("element-ui/lib/input");
  186. /***/ }),
  187. /***/ 12:
  188. /***/ (function(module, exports) {
  189. module.exports = require("element-ui/lib/utils/clickoutside");
  190. /***/ }),
  191. /***/ 15:
  192. /***/ (function(module, exports) {
  193. module.exports = require("element-ui/lib/scrollbar");
  194. /***/ }),
  195. /***/ 31:
  196. /***/ (function(module, exports) {
  197. module.exports = require("element-ui/lib/utils/scroll-into-view");
  198. /***/ }),
  199. /***/ 32:
  200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  201. "use strict";
  202. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/date-picker/src/picker.vue?vue&type=template&id=79ae069f&
  203. var render = function() {
  204. var _vm = this
  205. var _h = _vm.$createElement
  206. var _c = _vm._self._c || _h
  207. return !_vm.ranged
  208. ? _c(
  209. "el-input",
  210. _vm._b(
  211. {
  212. directives: [
  213. {
  214. name: "clickoutside",
  215. rawName: "v-clickoutside",
  216. value: _vm.handleClose,
  217. expression: "handleClose"
  218. }
  219. ],
  220. ref: "reference",
  221. staticClass: "el-date-editor",
  222. class: "el-date-editor--" + _vm.type,
  223. attrs: {
  224. readonly:
  225. !_vm.editable ||
  226. _vm.readonly ||
  227. _vm.type === "dates" ||
  228. _vm.type === "week",
  229. disabled: _vm.pickerDisabled,
  230. size: _vm.pickerSize,
  231. name: _vm.name,
  232. placeholder: _vm.placeholder,
  233. value: _vm.displayValue,
  234. validateEvent: false
  235. },
  236. on: {
  237. focus: _vm.handleFocus,
  238. input: function(value) {
  239. return (_vm.userInput = value)
  240. },
  241. change: _vm.handleChange
  242. },
  243. nativeOn: {
  244. keydown: function($event) {
  245. return _vm.handleKeydown($event)
  246. },
  247. mouseenter: function($event) {
  248. return _vm.handleMouseEnter($event)
  249. },
  250. mouseleave: function($event) {
  251. _vm.showClose = false
  252. }
  253. }
  254. },
  255. "el-input",
  256. _vm.firstInputId,
  257. false
  258. ),
  259. [
  260. _c("i", {
  261. staticClass: "el-input__icon",
  262. class: _vm.triggerClass,
  263. attrs: { slot: "prefix" },
  264. on: { click: _vm.handleFocus },
  265. slot: "prefix"
  266. }),
  267. _vm.haveTrigger
  268. ? _c("i", {
  269. staticClass: "el-input__icon",
  270. class: [_vm.showClose ? "" + _vm.clearIcon : ""],
  271. attrs: { slot: "suffix" },
  272. on: { click: _vm.handleClickIcon },
  273. slot: "suffix"
  274. })
  275. : _vm._e()
  276. ]
  277. )
  278. : _c(
  279. "div",
  280. {
  281. directives: [
  282. {
  283. name: "clickoutside",
  284. rawName: "v-clickoutside",
  285. value: _vm.handleClose,
  286. expression: "handleClose"
  287. }
  288. ],
  289. ref: "reference",
  290. staticClass: "el-date-editor el-range-editor el-input__inner",
  291. class: [
  292. "el-date-editor--" + _vm.type,
  293. _vm.pickerSize ? "el-range-editor--" + _vm.pickerSize : "",
  294. _vm.pickerDisabled ? "is-disabled" : "",
  295. _vm.pickerVisible ? "is-active" : ""
  296. ],
  297. on: {
  298. click: _vm.handleRangeClick,
  299. mouseenter: _vm.handleMouseEnter,
  300. mouseleave: function($event) {
  301. _vm.showClose = false
  302. },
  303. keydown: _vm.handleKeydown
  304. }
  305. },
  306. [
  307. _c("i", {
  308. class: ["el-input__icon", "el-range__icon", _vm.triggerClass]
  309. }),
  310. _c(
  311. "input",
  312. _vm._b(
  313. {
  314. staticClass: "el-range-input",
  315. attrs: {
  316. autocomplete: "off",
  317. placeholder: _vm.startPlaceholder,
  318. disabled: _vm.pickerDisabled,
  319. readonly: !_vm.editable || _vm.readonly,
  320. name: _vm.name && _vm.name[0]
  321. },
  322. domProps: { value: _vm.displayValue && _vm.displayValue[0] },
  323. on: {
  324. input: _vm.handleStartInput,
  325. change: _vm.handleStartChange,
  326. focus: _vm.handleFocus
  327. }
  328. },
  329. "input",
  330. _vm.firstInputId,
  331. false
  332. )
  333. ),
  334. _vm._t("range-separator", [
  335. _c("span", { staticClass: "el-range-separator" }, [
  336. _vm._v(_vm._s(_vm.rangeSeparator))
  337. ])
  338. ]),
  339. _c(
  340. "input",
  341. _vm._b(
  342. {
  343. staticClass: "el-range-input",
  344. attrs: {
  345. autocomplete: "off",
  346. placeholder: _vm.endPlaceholder,
  347. disabled: _vm.pickerDisabled,
  348. readonly: !_vm.editable || _vm.readonly,
  349. name: _vm.name && _vm.name[1]
  350. },
  351. domProps: { value: _vm.displayValue && _vm.displayValue[1] },
  352. on: {
  353. input: _vm.handleEndInput,
  354. change: _vm.handleEndChange,
  355. focus: _vm.handleFocus
  356. }
  357. },
  358. "input",
  359. _vm.secondInputId,
  360. false
  361. )
  362. ),
  363. _vm.haveTrigger
  364. ? _c("i", {
  365. staticClass: "el-input__icon el-range__close-icon",
  366. class: [_vm.showClose ? "" + _vm.clearIcon : ""],
  367. on: { click: _vm.handleClickIcon }
  368. })
  369. : _vm._e()
  370. ],
  371. 2
  372. )
  373. }
  374. var staticRenderFns = []
  375. render._withStripped = true
  376. // CONCATENATED MODULE: ./packages/date-picker/src/picker.vue?vue&type=template&id=79ae069f&
  377. // EXTERNAL MODULE: external "vue"
  378. var external_vue_ = __webpack_require__(7);
  379. var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
  380. // EXTERNAL MODULE: external "element-ui/lib/utils/clickoutside"
  381. var clickoutside_ = __webpack_require__(12);
  382. var clickoutside_default = /*#__PURE__*/__webpack_require__.n(clickoutside_);
  383. // EXTERNAL MODULE: external "element-ui/lib/utils/date-util"
  384. var date_util_ = __webpack_require__(1);
  385. // EXTERNAL MODULE: external "element-ui/lib/utils/vue-popper"
  386. var vue_popper_ = __webpack_require__(5);
  387. var vue_popper_default = /*#__PURE__*/__webpack_require__.n(vue_popper_);
  388. // EXTERNAL MODULE: external "element-ui/lib/mixins/emitter"
  389. var emitter_ = __webpack_require__(4);
  390. var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
  391. // EXTERNAL MODULE: external "element-ui/lib/input"
  392. var input_ = __webpack_require__(10);
  393. var input_default = /*#__PURE__*/__webpack_require__.n(input_);
  394. // EXTERNAL MODULE: external "element-ui/lib/utils/merge"
  395. var merge_ = __webpack_require__(9);
  396. var merge_default = /*#__PURE__*/__webpack_require__.n(merge_);
  397. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/date-picker/src/picker.vue?vue&type=script&lang=js&
  398. //
  399. //
  400. //
  401. //
  402. //
  403. //
  404. //
  405. //
  406. //
  407. //
  408. //
  409. //
  410. //
  411. //
  412. //
  413. //
  414. //
  415. //
  416. //
  417. //
  418. //
  419. //
  420. //
  421. //
  422. //
  423. //
  424. //
  425. //
  426. //
  427. //
  428. //
  429. //
  430. //
  431. //
  432. //
  433. //
  434. //
  435. //
  436. //
  437. //
  438. //
  439. //
  440. //
  441. //
  442. //
  443. //
  444. //
  445. //
  446. //
  447. //
  448. //
  449. //
  450. //
  451. //
  452. //
  453. //
  454. //
  455. //
  456. //
  457. //
  458. //
  459. //
  460. //
  461. //
  462. //
  463. //
  464. //
  465. //
  466. //
  467. //
  468. //
  469. //
  470. //
  471. //
  472. //
  473. //
  474. //
  475. //
  476. //
  477. //
  478. //
  479. //
  480. //
  481. //
  482. //
  483. var NewPopper = {
  484. props: {
  485. appendToBody: vue_popper_default.a.props.appendToBody,
  486. offset: vue_popper_default.a.props.offset,
  487. boundariesPadding: vue_popper_default.a.props.boundariesPadding,
  488. arrowOffset: vue_popper_default.a.props.arrowOffset,
  489. placement: vue_popper_default.a.props.placement,
  490. transformOrigin: vue_popper_default.a.props.transformOrigin
  491. },
  492. methods: vue_popper_default.a.methods,
  493. data: function data() {
  494. return merge_default()({ visibleArrow: true }, vue_popper_default.a.data);
  495. },
  496. beforeDestroy: vue_popper_default.a.beforeDestroy
  497. };
  498. var DEFAULT_FORMATS = {
  499. date: 'yyyy-MM-dd',
  500. month: 'yyyy-MM',
  501. datetime: 'yyyy-MM-dd HH:mm:ss',
  502. time: 'HH:mm:ss',
  503. week: 'yyyywWW',
  504. timerange: 'HH:mm:ss',
  505. daterange: 'yyyy-MM-dd',
  506. monthrange: 'yyyy-MM',
  507. datetimerange: 'yyyy-MM-dd HH:mm:ss',
  508. year: 'yyyy'
  509. };
  510. var HAVE_TRIGGER_TYPES = ['date', 'datetime', 'time', 'time-select', 'week', 'month', 'year', 'daterange', 'monthrange', 'timerange', 'datetimerange', 'dates'];
  511. var pickervue_type_script_lang_js_DATE_FORMATTER = function DATE_FORMATTER(value, format) {
  512. if (format === 'timestamp') return value.getTime();
  513. return Object(date_util_["formatDate"])(value, format);
  514. };
  515. var pickervue_type_script_lang_js_DATE_PARSER = function DATE_PARSER(text, format) {
  516. if (format === 'timestamp') return new Date(Number(text));
  517. return Object(date_util_["parseDate"])(text, format);
  518. };
  519. var RANGE_FORMATTER = function RANGE_FORMATTER(value, format) {
  520. if (Array.isArray(value) && value.length === 2) {
  521. var start = value[0];
  522. var end = value[1];
  523. if (start && end) {
  524. return [pickervue_type_script_lang_js_DATE_FORMATTER(start, format), pickervue_type_script_lang_js_DATE_FORMATTER(end, format)];
  525. }
  526. }
  527. return '';
  528. };
  529. var RANGE_PARSER = function RANGE_PARSER(array, format, separator) {
  530. if (!Array.isArray(array)) {
  531. array = array.split(separator);
  532. }
  533. if (array.length === 2) {
  534. var range1 = array[0];
  535. var range2 = array[1];
  536. return [pickervue_type_script_lang_js_DATE_PARSER(range1, format), pickervue_type_script_lang_js_DATE_PARSER(range2, format)];
  537. }
  538. return [];
  539. };
  540. var TYPE_VALUE_RESOLVER_MAP = {
  541. default: {
  542. formatter: function formatter(value) {
  543. if (!value) return '';
  544. return '' + value;
  545. },
  546. parser: function parser(text) {
  547. if (text === undefined || text === '') return null;
  548. return text;
  549. }
  550. },
  551. week: {
  552. formatter: function formatter(value, format) {
  553. var week = Object(date_util_["getWeekNumber"])(value);
  554. var month = value.getMonth();
  555. var trueDate = new Date(value);
  556. if (week === 1 && month === 11) {
  557. trueDate.setHours(0, 0, 0, 0);
  558. trueDate.setDate(trueDate.getDate() + 3 - (trueDate.getDay() + 6) % 7);
  559. }
  560. var date = Object(date_util_["formatDate"])(trueDate, format);
  561. date = /WW/.test(date) ? date.replace(/WW/, week < 10 ? '0' + week : week) : date.replace(/W/, week);
  562. return date;
  563. },
  564. parser: function parser(text, format) {
  565. // parse as if a normal date
  566. return TYPE_VALUE_RESOLVER_MAP.date.parser(text, format);
  567. }
  568. },
  569. date: {
  570. formatter: pickervue_type_script_lang_js_DATE_FORMATTER,
  571. parser: pickervue_type_script_lang_js_DATE_PARSER
  572. },
  573. datetime: {
  574. formatter: pickervue_type_script_lang_js_DATE_FORMATTER,
  575. parser: pickervue_type_script_lang_js_DATE_PARSER
  576. },
  577. daterange: {
  578. formatter: RANGE_FORMATTER,
  579. parser: RANGE_PARSER
  580. },
  581. monthrange: {
  582. formatter: RANGE_FORMATTER,
  583. parser: RANGE_PARSER
  584. },
  585. datetimerange: {
  586. formatter: RANGE_FORMATTER,
  587. parser: RANGE_PARSER
  588. },
  589. timerange: {
  590. formatter: RANGE_FORMATTER,
  591. parser: RANGE_PARSER
  592. },
  593. time: {
  594. formatter: pickervue_type_script_lang_js_DATE_FORMATTER,
  595. parser: pickervue_type_script_lang_js_DATE_PARSER
  596. },
  597. month: {
  598. formatter: pickervue_type_script_lang_js_DATE_FORMATTER,
  599. parser: pickervue_type_script_lang_js_DATE_PARSER
  600. },
  601. year: {
  602. formatter: pickervue_type_script_lang_js_DATE_FORMATTER,
  603. parser: pickervue_type_script_lang_js_DATE_PARSER
  604. },
  605. number: {
  606. formatter: function formatter(value) {
  607. if (!value) return '';
  608. return '' + value;
  609. },
  610. parser: function parser(text) {
  611. var result = Number(text);
  612. if (!isNaN(text)) {
  613. return result;
  614. } else {
  615. return null;
  616. }
  617. }
  618. },
  619. dates: {
  620. formatter: function formatter(value, format) {
  621. return value.map(function (date) {
  622. return pickervue_type_script_lang_js_DATE_FORMATTER(date, format);
  623. });
  624. },
  625. parser: function parser(value, format) {
  626. return (typeof value === 'string' ? value.split(', ') : value).map(function (date) {
  627. return date instanceof Date ? date : pickervue_type_script_lang_js_DATE_PARSER(date, format);
  628. });
  629. }
  630. }
  631. };
  632. var PLACEMENT_MAP = {
  633. left: 'bottom-start',
  634. center: 'bottom',
  635. right: 'bottom-end'
  636. };
  637. var parseAsFormatAndType = function parseAsFormatAndType(value, customFormat, type) {
  638. var rangeSeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '-';
  639. if (!value) return null;
  640. var parser = (TYPE_VALUE_RESOLVER_MAP[type] || TYPE_VALUE_RESOLVER_MAP['default']).parser;
  641. var format = customFormat || DEFAULT_FORMATS[type];
  642. return parser(value, format, rangeSeparator);
  643. };
  644. var formatAsFormatAndType = function formatAsFormatAndType(value, customFormat, type) {
  645. if (!value) return null;
  646. var formatter = (TYPE_VALUE_RESOLVER_MAP[type] || TYPE_VALUE_RESOLVER_MAP['default']).formatter;
  647. var format = customFormat || DEFAULT_FORMATS[type];
  648. return formatter(value, format);
  649. };
  650. /*
  651. * Considers:
  652. * 1. Date object
  653. * 2. date string
  654. * 3. array of 1 or 2
  655. */
  656. var valueEquals = function valueEquals(a, b) {
  657. // considers Date object and string
  658. var dateEquals = function dateEquals(a, b) {
  659. var aIsDate = a instanceof Date;
  660. var bIsDate = b instanceof Date;
  661. if (aIsDate && bIsDate) {
  662. return a.getTime() === b.getTime();
  663. }
  664. if (!aIsDate && !bIsDate) {
  665. return a === b;
  666. }
  667. return false;
  668. };
  669. var aIsArray = a instanceof Array;
  670. var bIsArray = b instanceof Array;
  671. if (aIsArray && bIsArray) {
  672. if (a.length !== b.length) {
  673. return false;
  674. }
  675. return a.every(function (item, index) {
  676. return dateEquals(item, b[index]);
  677. });
  678. }
  679. if (!aIsArray && !bIsArray) {
  680. return dateEquals(a, b);
  681. }
  682. return false;
  683. };
  684. var isString = function isString(val) {
  685. return typeof val === 'string' || val instanceof String;
  686. };
  687. var validator = function validator(val) {
  688. // either: String, Array of String, null / undefined
  689. return val === null || val === undefined || isString(val) || Array.isArray(val) && val.length === 2 && val.every(isString);
  690. };
  691. /* harmony default export */ var pickervue_type_script_lang_js_ = ({
  692. mixins: [emitter_default.a, NewPopper],
  693. inject: {
  694. elForm: {
  695. default: ''
  696. },
  697. elFormItem: {
  698. default: ''
  699. }
  700. },
  701. props: {
  702. size: String,
  703. format: String,
  704. valueFormat: String,
  705. readonly: Boolean,
  706. placeholder: String,
  707. startPlaceholder: String,
  708. endPlaceholder: String,
  709. prefixIcon: String,
  710. clearIcon: {
  711. type: String,
  712. default: 'el-icon-circle-close'
  713. },
  714. name: {
  715. default: '',
  716. validator: validator
  717. },
  718. disabled: Boolean,
  719. clearable: {
  720. type: Boolean,
  721. default: true
  722. },
  723. id: {
  724. default: '',
  725. validator: validator
  726. },
  727. popperClass: String,
  728. editable: {
  729. type: Boolean,
  730. default: true
  731. },
  732. align: {
  733. type: String,
  734. default: 'left'
  735. },
  736. value: {},
  737. defaultValue: {},
  738. defaultTime: {},
  739. rangeSeparator: {
  740. default: '-'
  741. },
  742. pickerOptions: {},
  743. unlinkPanels: Boolean,
  744. validateEvent: {
  745. type: Boolean,
  746. default: true
  747. }
  748. },
  749. components: { ElInput: input_default.a },
  750. directives: { Clickoutside: clickoutside_default.a },
  751. data: function data() {
  752. return {
  753. pickerVisible: false,
  754. showClose: false,
  755. userInput: null,
  756. valueOnOpen: null, // value when picker opens, used to determine whether to emit change
  757. unwatchPickerOptions: null
  758. };
  759. },
  760. watch: {
  761. pickerVisible: function pickerVisible(val) {
  762. if (this.readonly || this.pickerDisabled) return;
  763. if (val) {
  764. this.showPicker();
  765. this.valueOnOpen = Array.isArray(this.value) ? [].concat(this.value) : this.value;
  766. } else {
  767. this.hidePicker();
  768. this.emitChange(this.value);
  769. this.userInput = null;
  770. if (this.validateEvent) {
  771. this.dispatch('ElFormItem', 'el.form.blur');
  772. }
  773. this.$emit('blur', this);
  774. this.blur();
  775. }
  776. },
  777. parsedValue: {
  778. immediate: true,
  779. handler: function handler(val) {
  780. if (this.picker) {
  781. this.picker.value = val;
  782. }
  783. }
  784. },
  785. defaultValue: function defaultValue(val) {
  786. // NOTE: should eventually move to jsx style picker + panel ?
  787. if (this.picker) {
  788. this.picker.defaultValue = val;
  789. }
  790. },
  791. value: function value(val, oldVal) {
  792. if (!valueEquals(val, oldVal) && !this.pickerVisible && this.validateEvent) {
  793. this.dispatch('ElFormItem', 'el.form.change', val);
  794. }
  795. }
  796. },
  797. computed: {
  798. ranged: function ranged() {
  799. return this.type.indexOf('range') > -1;
  800. },
  801. reference: function reference() {
  802. var reference = this.$refs.reference;
  803. return reference.$el || reference;
  804. },
  805. refInput: function refInput() {
  806. if (this.reference) {
  807. return [].slice.call(this.reference.querySelectorAll('input'));
  808. }
  809. return [];
  810. },
  811. valueIsEmpty: function valueIsEmpty() {
  812. var val = this.value;
  813. if (Array.isArray(val)) {
  814. for (var i = 0, len = val.length; i < len; i++) {
  815. if (val[i]) {
  816. return false;
  817. }
  818. }
  819. } else {
  820. if (val) {
  821. return false;
  822. }
  823. }
  824. return true;
  825. },
  826. triggerClass: function triggerClass() {
  827. return this.prefixIcon || (this.type.indexOf('time') !== -1 ? 'el-icon-time' : 'el-icon-date');
  828. },
  829. selectionMode: function selectionMode() {
  830. if (this.type === 'week') {
  831. return 'week';
  832. } else if (this.type === 'month') {
  833. return 'month';
  834. } else if (this.type === 'year') {
  835. return 'year';
  836. } else if (this.type === 'dates') {
  837. return 'dates';
  838. }
  839. return 'day';
  840. },
  841. haveTrigger: function haveTrigger() {
  842. if (typeof this.showTrigger !== 'undefined') {
  843. return this.showTrigger;
  844. }
  845. return HAVE_TRIGGER_TYPES.indexOf(this.type) !== -1;
  846. },
  847. displayValue: function displayValue() {
  848. var formattedValue = formatAsFormatAndType(this.parsedValue, this.format, this.type, this.rangeSeparator);
  849. if (Array.isArray(this.userInput)) {
  850. return [this.userInput[0] || formattedValue && formattedValue[0] || '', this.userInput[1] || formattedValue && formattedValue[1] || ''];
  851. } else if (this.userInput !== null) {
  852. return this.userInput;
  853. } else if (formattedValue) {
  854. return this.type === 'dates' ? formattedValue.join(', ') : formattedValue;
  855. } else {
  856. return '';
  857. }
  858. },
  859. parsedValue: function parsedValue() {
  860. if (!this.value) return this.value; // component value is not set
  861. if (this.type === 'time-select') return this.value; // time-select does not require parsing, this might change in next major version
  862. var valueIsDateObject = Object(date_util_["isDateObject"])(this.value) || Array.isArray(this.value) && this.value.every(date_util_["isDateObject"]);
  863. if (valueIsDateObject) {
  864. return this.value;
  865. }
  866. if (this.valueFormat) {
  867. return parseAsFormatAndType(this.value, this.valueFormat, this.type, this.rangeSeparator) || this.value;
  868. }
  869. // NOTE: deal with common but incorrect usage, should remove in next major version
  870. // user might provide string / timestamp without value-format, coerce them into date (or array of date)
  871. return Array.isArray(this.value) ? this.value.map(function (val) {
  872. return new Date(val);
  873. }) : new Date(this.value);
  874. },
  875. _elFormItemSize: function _elFormItemSize() {
  876. return (this.elFormItem || {}).elFormItemSize;
  877. },
  878. pickerSize: function pickerSize() {
  879. return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
  880. },
  881. pickerDisabled: function pickerDisabled() {
  882. return this.disabled || (this.elForm || {}).disabled;
  883. },
  884. firstInputId: function firstInputId() {
  885. var obj = {};
  886. var id = void 0;
  887. if (this.ranged) {
  888. id = this.id && this.id[0];
  889. } else {
  890. id = this.id;
  891. }
  892. if (id) obj.id = id;
  893. return obj;
  894. },
  895. secondInputId: function secondInputId() {
  896. var obj = {};
  897. var id = void 0;
  898. if (this.ranged) {
  899. id = this.id && this.id[1];
  900. }
  901. if (id) obj.id = id;
  902. return obj;
  903. }
  904. },
  905. created: function created() {
  906. // vue-popper
  907. this.popperOptions = {
  908. boundariesPadding: 0,
  909. gpuAcceleration: false
  910. };
  911. this.placement = PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left;
  912. this.$on('fieldReset', this.handleFieldReset);
  913. },
  914. methods: {
  915. focus: function focus() {
  916. if (!this.ranged) {
  917. this.$refs.reference.focus();
  918. } else {
  919. this.handleFocus();
  920. }
  921. },
  922. blur: function blur() {
  923. this.refInput.forEach(function (input) {
  924. return input.blur();
  925. });
  926. },
  927. // {parse, formatTo} Value deals maps component value with internal Date
  928. parseValue: function parseValue(value) {
  929. var isParsed = Object(date_util_["isDateObject"])(value) || Array.isArray(value) && value.every(date_util_["isDateObject"]);
  930. if (this.valueFormat && !isParsed) {
  931. return parseAsFormatAndType(value, this.valueFormat, this.type, this.rangeSeparator) || value;
  932. } else {
  933. return value;
  934. }
  935. },
  936. formatToValue: function formatToValue(date) {
  937. var isFormattable = Object(date_util_["isDateObject"])(date) || Array.isArray(date) && date.every(date_util_["isDateObject"]);
  938. if (this.valueFormat && isFormattable) {
  939. return formatAsFormatAndType(date, this.valueFormat, this.type, this.rangeSeparator);
  940. } else {
  941. return date;
  942. }
  943. },
  944. // {parse, formatTo} String deals with user input
  945. parseString: function parseString(value) {
  946. var type = Array.isArray(value) ? this.type : this.type.replace('range', '');
  947. return parseAsFormatAndType(value, this.format, type);
  948. },
  949. formatToString: function formatToString(value) {
  950. var type = Array.isArray(value) ? this.type : this.type.replace('range', '');
  951. return formatAsFormatAndType(value, this.format, type);
  952. },
  953. handleMouseEnter: function handleMouseEnter() {
  954. if (this.readonly || this.pickerDisabled) return;
  955. if (!this.valueIsEmpty && this.clearable) {
  956. this.showClose = true;
  957. }
  958. },
  959. handleChange: function handleChange() {
  960. if (this.userInput) {
  961. var value = this.parseString(this.displayValue);
  962. if (value) {
  963. this.picker.value = value;
  964. if (this.isValidValue(value)) {
  965. this.emitInput(value);
  966. this.userInput = null;
  967. }
  968. }
  969. }
  970. if (this.userInput === '') {
  971. this.emitInput(null);
  972. this.emitChange(null);
  973. this.userInput = null;
  974. }
  975. },
  976. handleStartInput: function handleStartInput(event) {
  977. if (this.userInput) {
  978. this.userInput = [event.target.value, this.userInput[1]];
  979. } else {
  980. this.userInput = [event.target.value, null];
  981. }
  982. },
  983. handleEndInput: function handleEndInput(event) {
  984. if (this.userInput) {
  985. this.userInput = [this.userInput[0], event.target.value];
  986. } else {
  987. this.userInput = [null, event.target.value];
  988. }
  989. },
  990. handleStartChange: function handleStartChange(event) {
  991. var value = this.parseString(this.userInput && this.userInput[0]);
  992. if (value) {
  993. this.userInput = [this.formatToString(value), this.displayValue[1]];
  994. var newValue = [value, this.picker.value && this.picker.value[1]];
  995. this.picker.value = newValue;
  996. if (this.isValidValue(newValue)) {
  997. this.emitInput(newValue);
  998. this.userInput = null;
  999. }
  1000. }
  1001. },
  1002. handleEndChange: function handleEndChange(event) {
  1003. var value = this.parseString(this.userInput && this.userInput[1]);
  1004. if (value) {
  1005. this.userInput = [this.displayValue[0], this.formatToString(value)];
  1006. var newValue = [this.picker.value && this.picker.value[0], value];
  1007. this.picker.value = newValue;
  1008. if (this.isValidValue(newValue)) {
  1009. this.emitInput(newValue);
  1010. this.userInput = null;
  1011. }
  1012. }
  1013. },
  1014. handleClickIcon: function handleClickIcon(event) {
  1015. if (this.readonly || this.pickerDisabled) return;
  1016. if (this.showClose) {
  1017. this.valueOnOpen = this.value;
  1018. event.stopPropagation();
  1019. this.emitInput(null);
  1020. this.emitChange(null);
  1021. this.showClose = false;
  1022. if (this.picker && typeof this.picker.handleClear === 'function') {
  1023. this.picker.handleClear();
  1024. }
  1025. } else {
  1026. this.pickerVisible = !this.pickerVisible;
  1027. }
  1028. },
  1029. handleClose: function handleClose() {
  1030. if (!this.pickerVisible) return;
  1031. this.pickerVisible = false;
  1032. if (this.type === 'dates') {
  1033. // restore to former value
  1034. var oldValue = parseAsFormatAndType(this.valueOnOpen, this.valueFormat, this.type, this.rangeSeparator) || this.valueOnOpen;
  1035. this.emitInput(oldValue);
  1036. }
  1037. },
  1038. handleFieldReset: function handleFieldReset(initialValue) {
  1039. this.userInput = initialValue === '' ? null : initialValue;
  1040. },
  1041. handleFocus: function handleFocus() {
  1042. var type = this.type;
  1043. if (HAVE_TRIGGER_TYPES.indexOf(type) !== -1 && !this.pickerVisible) {
  1044. this.pickerVisible = true;
  1045. }
  1046. this.$emit('focus', this);
  1047. },
  1048. handleKeydown: function handleKeydown(event) {
  1049. var _this = this;
  1050. var keyCode = event.keyCode;
  1051. // ESC
  1052. if (keyCode === 27) {
  1053. this.pickerVisible = false;
  1054. event.stopPropagation();
  1055. return;
  1056. }
  1057. // Tab
  1058. if (keyCode === 9) {
  1059. if (!this.ranged) {
  1060. this.handleChange();
  1061. this.pickerVisible = this.picker.visible = false;
  1062. this.blur();
  1063. event.stopPropagation();
  1064. } else {
  1065. // user may change focus between two input
  1066. setTimeout(function () {
  1067. if (_this.refInput.indexOf(document.activeElement) === -1) {
  1068. _this.pickerVisible = false;
  1069. _this.blur();
  1070. event.stopPropagation();
  1071. }
  1072. }, 0);
  1073. }
  1074. return;
  1075. }
  1076. // Enter
  1077. if (keyCode === 13) {
  1078. if (this.userInput === '' || this.isValidValue(this.parseString(this.displayValue))) {
  1079. this.handleChange();
  1080. this.pickerVisible = this.picker.visible = false;
  1081. this.blur();
  1082. }
  1083. event.stopPropagation();
  1084. return;
  1085. }
  1086. // if user is typing, do not let picker handle key input
  1087. if (this.userInput) {
  1088. event.stopPropagation();
  1089. return;
  1090. }
  1091. // delegate other keys to panel
  1092. if (this.picker && this.picker.handleKeydown) {
  1093. this.picker.handleKeydown(event);
  1094. }
  1095. },
  1096. handleRangeClick: function handleRangeClick() {
  1097. var type = this.type;
  1098. if (HAVE_TRIGGER_TYPES.indexOf(type) !== -1 && !this.pickerVisible) {
  1099. this.pickerVisible = true;
  1100. }
  1101. this.$emit('focus', this);
  1102. },
  1103. hidePicker: function hidePicker() {
  1104. if (this.picker) {
  1105. this.picker.resetView && this.picker.resetView();
  1106. this.pickerVisible = this.picker.visible = false;
  1107. this.destroyPopper();
  1108. }
  1109. },
  1110. showPicker: function showPicker() {
  1111. var _this2 = this;
  1112. if (this.$isServer) return;
  1113. if (!this.picker) {
  1114. this.mountPicker();
  1115. }
  1116. this.pickerVisible = this.picker.visible = true;
  1117. this.updatePopper();
  1118. this.picker.value = this.parsedValue;
  1119. this.picker.resetView && this.picker.resetView();
  1120. this.$nextTick(function () {
  1121. _this2.picker.adjustSpinners && _this2.picker.adjustSpinners();
  1122. });
  1123. },
  1124. mountPicker: function mountPicker() {
  1125. var _this3 = this;
  1126. this.picker = new external_vue_default.a(this.panel).$mount();
  1127. this.picker.defaultValue = this.defaultValue;
  1128. this.picker.defaultTime = this.defaultTime;
  1129. this.picker.popperClass = this.popperClass;
  1130. this.popperElm = this.picker.$el;
  1131. this.picker.width = this.reference.getBoundingClientRect().width;
  1132. this.picker.showTime = this.type === 'datetime' || this.type === 'datetimerange';
  1133. this.picker.selectionMode = this.selectionMode;
  1134. this.picker.unlinkPanels = this.unlinkPanels;
  1135. this.picker.arrowControl = this.arrowControl || this.timeArrowControl || false;
  1136. this.$watch('format', function (format) {
  1137. _this3.picker.format = format;
  1138. });
  1139. var updateOptions = function updateOptions() {
  1140. var options = _this3.pickerOptions;
  1141. if (options && options.selectableRange) {
  1142. var ranges = options.selectableRange;
  1143. var parser = TYPE_VALUE_RESOLVER_MAP.datetimerange.parser;
  1144. var format = DEFAULT_FORMATS.timerange;
  1145. ranges = Array.isArray(ranges) ? ranges : [ranges];
  1146. _this3.picker.selectableRange = ranges.map(function (range) {
  1147. return parser(range, format, _this3.rangeSeparator);
  1148. });
  1149. }
  1150. for (var option in options) {
  1151. if (options.hasOwnProperty(option) &&
  1152. // 忽略 time-picker 的该配置项
  1153. option !== 'selectableRange') {
  1154. _this3.picker[option] = options[option];
  1155. }
  1156. }
  1157. // main format must prevail over undocumented pickerOptions.format
  1158. if (_this3.format) {
  1159. _this3.picker.format = _this3.format;
  1160. }
  1161. };
  1162. updateOptions();
  1163. this.unwatchPickerOptions = this.$watch('pickerOptions', function () {
  1164. return updateOptions();
  1165. }, { deep: true });
  1166. this.$el.appendChild(this.picker.$el);
  1167. this.picker.resetView && this.picker.resetView();
  1168. this.picker.$on('dodestroy', this.doDestroy);
  1169. this.picker.$on('pick', function () {
  1170. var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  1171. var visible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1172. _this3.userInput = null;
  1173. _this3.pickerVisible = _this3.picker.visible = visible;
  1174. _this3.emitInput(date);
  1175. _this3.picker.resetView && _this3.picker.resetView();
  1176. });
  1177. this.picker.$on('select-range', function (start, end, pos) {
  1178. if (_this3.refInput.length === 0) return;
  1179. if (!pos || pos === 'min') {
  1180. _this3.refInput[0].setSelectionRange(start, end);
  1181. _this3.refInput[0].focus();
  1182. } else if (pos === 'max') {
  1183. _this3.refInput[1].setSelectionRange(start, end);
  1184. _this3.refInput[1].focus();
  1185. }
  1186. });
  1187. },
  1188. unmountPicker: function unmountPicker() {
  1189. if (this.picker) {
  1190. this.picker.$destroy();
  1191. this.picker.$off();
  1192. if (typeof this.unwatchPickerOptions === 'function') {
  1193. this.unwatchPickerOptions();
  1194. }
  1195. this.picker.$el.parentNode.removeChild(this.picker.$el);
  1196. }
  1197. },
  1198. emitChange: function emitChange(val) {
  1199. // determine user real change only
  1200. if (!valueEquals(val, this.valueOnOpen)) {
  1201. this.$emit('change', val);
  1202. this.valueOnOpen = val;
  1203. if (this.validateEvent) {
  1204. this.dispatch('ElFormItem', 'el.form.change', val);
  1205. }
  1206. }
  1207. },
  1208. emitInput: function emitInput(val) {
  1209. var formatted = this.formatToValue(val);
  1210. if (!valueEquals(this.value, formatted)) {
  1211. this.$emit('input', formatted);
  1212. }
  1213. },
  1214. isValidValue: function isValidValue(value) {
  1215. if (!this.picker) {
  1216. this.mountPicker();
  1217. }
  1218. if (this.picker.isValidValue) {
  1219. return value && this.picker.isValidValue(value);
  1220. } else {
  1221. return true;
  1222. }
  1223. }
  1224. }
  1225. });
  1226. // CONCATENATED MODULE: ./packages/date-picker/src/picker.vue?vue&type=script&lang=js&
  1227. /* harmony default export */ var src_pickervue_type_script_lang_js_ = (pickervue_type_script_lang_js_);
  1228. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  1229. var componentNormalizer = __webpack_require__(0);
  1230. // CONCATENATED MODULE: ./packages/date-picker/src/picker.vue
  1231. /* normalize component */
  1232. var component = Object(componentNormalizer["a" /* default */])(
  1233. src_pickervue_type_script_lang_js_,
  1234. render,
  1235. staticRenderFns,
  1236. false,
  1237. null,
  1238. null,
  1239. null
  1240. )
  1241. /* hot reload */
  1242. if (false) { var api; }
  1243. component.options.__file = "packages/date-picker/src/picker.vue"
  1244. /* harmony default export */ var picker = __webpack_exports__["a"] = (component.exports);
  1245. /***/ }),
  1246. /***/ 4:
  1247. /***/ (function(module, exports) {
  1248. module.exports = require("element-ui/lib/mixins/emitter");
  1249. /***/ }),
  1250. /***/ 5:
  1251. /***/ (function(module, exports) {
  1252. module.exports = require("element-ui/lib/utils/vue-popper");
  1253. /***/ }),
  1254. /***/ 7:
  1255. /***/ (function(module, exports) {
  1256. module.exports = require("vue");
  1257. /***/ }),
  1258. /***/ 75:
  1259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1260. "use strict";
  1261. __webpack_require__.r(__webpack_exports__);
  1262. // EXTERNAL MODULE: ./packages/date-picker/src/picker.vue + 4 modules
  1263. var picker = __webpack_require__(32);
  1264. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/date-picker/src/panel/time-select.vue?vue&type=template&id=51ab9320&
  1265. var render = function() {
  1266. var _vm = this
  1267. var _h = _vm.$createElement
  1268. var _c = _vm._self._c || _h
  1269. return _c(
  1270. "transition",
  1271. {
  1272. attrs: { name: "el-zoom-in-top" },
  1273. on: {
  1274. "before-enter": _vm.handleMenuEnter,
  1275. "after-leave": function($event) {
  1276. _vm.$emit("dodestroy")
  1277. }
  1278. }
  1279. },
  1280. [
  1281. _c(
  1282. "div",
  1283. {
  1284. directives: [
  1285. {
  1286. name: "show",
  1287. rawName: "v-show",
  1288. value: _vm.visible,
  1289. expression: "visible"
  1290. }
  1291. ],
  1292. ref: "popper",
  1293. staticClass: "el-picker-panel time-select el-popper",
  1294. class: _vm.popperClass,
  1295. style: { width: _vm.width + "px" }
  1296. },
  1297. [
  1298. _c(
  1299. "el-scrollbar",
  1300. {
  1301. attrs: { noresize: "", "wrap-class": "el-picker-panel__content" }
  1302. },
  1303. _vm._l(_vm.items, function(item) {
  1304. return _c(
  1305. "div",
  1306. {
  1307. key: item.value,
  1308. staticClass: "time-select-item",
  1309. class: {
  1310. selected: _vm.value === item.value,
  1311. disabled: item.disabled,
  1312. default: item.value === _vm.defaultValue
  1313. },
  1314. attrs: { disabled: item.disabled },
  1315. on: {
  1316. click: function($event) {
  1317. _vm.handleClick(item)
  1318. }
  1319. }
  1320. },
  1321. [_vm._v(_vm._s(item.value))]
  1322. )
  1323. }),
  1324. 0
  1325. )
  1326. ],
  1327. 1
  1328. )
  1329. ]
  1330. )
  1331. }
  1332. var staticRenderFns = []
  1333. render._withStripped = true
  1334. // CONCATENATED MODULE: ./packages/date-picker/src/panel/time-select.vue?vue&type=template&id=51ab9320&
  1335. // EXTERNAL MODULE: external "element-ui/lib/scrollbar"
  1336. var scrollbar_ = __webpack_require__(15);
  1337. var scrollbar_default = /*#__PURE__*/__webpack_require__.n(scrollbar_);
  1338. // EXTERNAL MODULE: external "element-ui/lib/utils/scroll-into-view"
  1339. var scroll_into_view_ = __webpack_require__(31);
  1340. var scroll_into_view_default = /*#__PURE__*/__webpack_require__.n(scroll_into_view_);
  1341. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/date-picker/src/panel/time-select.vue?vue&type=script&lang=js&
  1342. //
  1343. //
  1344. //
  1345. //
  1346. //
  1347. //
  1348. //
  1349. //
  1350. //
  1351. //
  1352. //
  1353. //
  1354. //
  1355. //
  1356. //
  1357. //
  1358. //
  1359. //
  1360. //
  1361. //
  1362. var parseTime = function parseTime(time) {
  1363. var values = (time || '').split(':');
  1364. if (values.length >= 2) {
  1365. var hours = parseInt(values[0], 10);
  1366. var minutes = parseInt(values[1], 10);
  1367. return {
  1368. hours: hours,
  1369. minutes: minutes
  1370. };
  1371. }
  1372. /* istanbul ignore next */
  1373. return null;
  1374. };
  1375. var compareTime = function compareTime(time1, time2) {
  1376. var value1 = parseTime(time1);
  1377. var value2 = parseTime(time2);
  1378. var minutes1 = value1.minutes + value1.hours * 60;
  1379. var minutes2 = value2.minutes + value2.hours * 60;
  1380. if (minutes1 === minutes2) {
  1381. return 0;
  1382. }
  1383. return minutes1 > minutes2 ? 1 : -1;
  1384. };
  1385. var formatTime = function formatTime(time) {
  1386. return (time.hours < 10 ? '0' + time.hours : time.hours) + ':' + (time.minutes < 10 ? '0' + time.minutes : time.minutes);
  1387. };
  1388. var nextTime = function nextTime(time, step) {
  1389. var timeValue = parseTime(time);
  1390. var stepValue = parseTime(step);
  1391. var next = {
  1392. hours: timeValue.hours,
  1393. minutes: timeValue.minutes
  1394. };
  1395. next.minutes += stepValue.minutes;
  1396. next.hours += stepValue.hours;
  1397. next.hours += Math.floor(next.minutes / 60);
  1398. next.minutes = next.minutes % 60;
  1399. return formatTime(next);
  1400. };
  1401. /* harmony default export */ var time_selectvue_type_script_lang_js_ = ({
  1402. components: { ElScrollbar: scrollbar_default.a },
  1403. watch: {
  1404. value: function value(val) {
  1405. var _this = this;
  1406. if (!val) return;
  1407. this.$nextTick(function () {
  1408. return _this.scrollToOption();
  1409. });
  1410. }
  1411. },
  1412. methods: {
  1413. handleClick: function handleClick(item) {
  1414. if (!item.disabled) {
  1415. this.$emit('pick', item.value);
  1416. }
  1417. },
  1418. handleClear: function handleClear() {
  1419. this.$emit('pick', null);
  1420. },
  1421. scrollToOption: function scrollToOption() {
  1422. var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '.selected';
  1423. var menu = this.$refs.popper.querySelector('.el-picker-panel__content');
  1424. scroll_into_view_default()(menu, menu.querySelector(selector));
  1425. },
  1426. handleMenuEnter: function handleMenuEnter() {
  1427. var _this2 = this;
  1428. var selected = this.items.map(function (item) {
  1429. return item.value;
  1430. }).indexOf(this.value) !== -1;
  1431. var hasDefault = this.items.map(function (item) {
  1432. return item.value;
  1433. }).indexOf(this.defaultValue) !== -1;
  1434. var option = selected && '.selected' || hasDefault && '.default' || '.time-select-item:not(.disabled)';
  1435. this.$nextTick(function () {
  1436. return _this2.scrollToOption(option);
  1437. });
  1438. },
  1439. scrollDown: function scrollDown(step) {
  1440. var items = this.items;
  1441. var length = items.length;
  1442. var total = items.length;
  1443. var index = items.map(function (item) {
  1444. return item.value;
  1445. }).indexOf(this.value);
  1446. while (total--) {
  1447. index = (index + step + length) % length;
  1448. if (!items[index].disabled) {
  1449. this.$emit('pick', items[index].value, true);
  1450. return;
  1451. }
  1452. }
  1453. },
  1454. isValidValue: function isValidValue(date) {
  1455. return this.items.filter(function (item) {
  1456. return !item.disabled;
  1457. }).map(function (item) {
  1458. return item.value;
  1459. }).indexOf(date) !== -1;
  1460. },
  1461. handleKeydown: function handleKeydown(event) {
  1462. var keyCode = event.keyCode;
  1463. if (keyCode === 38 || keyCode === 40) {
  1464. var mapping = { 40: 1, 38: -1 };
  1465. var offset = mapping[keyCode.toString()];
  1466. this.scrollDown(offset);
  1467. event.stopPropagation();
  1468. return;
  1469. }
  1470. }
  1471. },
  1472. data: function data() {
  1473. return {
  1474. popperClass: '',
  1475. start: '09:00',
  1476. end: '18:00',
  1477. step: '00:30',
  1478. value: '',
  1479. defaultValue: '',
  1480. visible: false,
  1481. minTime: '',
  1482. maxTime: '',
  1483. width: 0
  1484. };
  1485. },
  1486. computed: {
  1487. items: function items() {
  1488. var start = this.start;
  1489. var end = this.end;
  1490. var step = this.step;
  1491. var result = [];
  1492. if (start && end && step) {
  1493. var current = start;
  1494. while (compareTime(current, end) <= 0) {
  1495. result.push({
  1496. value: current,
  1497. disabled: compareTime(current, this.minTime || '-1:-1') <= 0 || compareTime(current, this.maxTime || '100:100') >= 0
  1498. });
  1499. current = nextTime(current, step);
  1500. }
  1501. }
  1502. return result;
  1503. }
  1504. }
  1505. });
  1506. // CONCATENATED MODULE: ./packages/date-picker/src/panel/time-select.vue?vue&type=script&lang=js&
  1507. /* harmony default export */ var panel_time_selectvue_type_script_lang_js_ = (time_selectvue_type_script_lang_js_);
  1508. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  1509. var componentNormalizer = __webpack_require__(0);
  1510. // CONCATENATED MODULE: ./packages/date-picker/src/panel/time-select.vue
  1511. /* normalize component */
  1512. var component = Object(componentNormalizer["a" /* default */])(
  1513. panel_time_selectvue_type_script_lang_js_,
  1514. render,
  1515. staticRenderFns,
  1516. false,
  1517. null,
  1518. null,
  1519. null
  1520. )
  1521. /* hot reload */
  1522. if (false) { var api; }
  1523. component.options.__file = "packages/date-picker/src/panel/time-select.vue"
  1524. /* harmony default export */ var time_select = (component.exports);
  1525. // CONCATENATED MODULE: ./packages/date-picker/src/picker/time-select.js
  1526. /* harmony default export */ var picker_time_select = ({
  1527. mixins: [picker["a" /* default */]],
  1528. name: 'ElTimeSelect',
  1529. componentName: 'ElTimeSelect',
  1530. props: {
  1531. type: {
  1532. type: String,
  1533. default: 'time-select'
  1534. }
  1535. },
  1536. beforeCreate: function beforeCreate() {
  1537. this.panel = time_select;
  1538. }
  1539. });
  1540. // CONCATENATED MODULE: ./packages/time-select/index.js
  1541. /* istanbul ignore next */
  1542. picker_time_select.install = function (Vue) {
  1543. Vue.component(picker_time_select.name, picker_time_select);
  1544. };
  1545. /* harmony default export */ var packages_time_select = __webpack_exports__["default"] = (picker_time_select);
  1546. /***/ }),
  1547. /***/ 9:
  1548. /***/ (function(module, exports) {
  1549. module.exports = require("element-ui/lib/utils/merge");
  1550. /***/ })
  1551. /******/ });