time-select.js 48 KB

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