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