input.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/ // Check if module is in cache
  8. /******/ if(installedModules[moduleId])
  9. /******/ return installedModules[moduleId].exports;
  10. /******/ // Create a new module (and put it into the cache)
  11. /******/ var module = installedModules[moduleId] = {
  12. /******/ exports: {},
  13. /******/ id: moduleId,
  14. /******/ loaded: false
  15. /******/ };
  16. /******/ // Execute the module function
  17. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  18. /******/ // Flag the module as loaded
  19. /******/ module.loaded = true;
  20. /******/ // Return the exports of the module
  21. /******/ return module.exports;
  22. /******/ }
  23. /******/ // expose the modules object (__webpack_modules__)
  24. /******/ __webpack_require__.m = modules;
  25. /******/ // expose the module cache
  26. /******/ __webpack_require__.c = installedModules;
  27. /******/ // __webpack_public_path__
  28. /******/ __webpack_require__.p = "/dist/";
  29. /******/ // Load entry module and return exports
  30. /******/ return __webpack_require__(0);
  31. /******/ })
  32. /************************************************************************/
  33. /******/ ({
  34. /***/ 0:
  35. /***/ function(module, exports, __webpack_require__) {
  36. module.exports = __webpack_require__(160);
  37. /***/ },
  38. /***/ 3:
  39. /***/ function(module, exports) {
  40. module.exports = function normalizeComponent (
  41. rawScriptExports,
  42. compiledTemplate,
  43. scopeId,
  44. cssModules
  45. ) {
  46. var esModule
  47. var scriptExports = rawScriptExports = rawScriptExports || {}
  48. // ES6 modules interop
  49. var type = typeof rawScriptExports.default
  50. if (type === 'object' || type === 'function') {
  51. esModule = rawScriptExports
  52. scriptExports = rawScriptExports.default
  53. }
  54. // Vue.extend constructor export interop
  55. var options = typeof scriptExports === 'function'
  56. ? scriptExports.options
  57. : scriptExports
  58. // render functions
  59. if (compiledTemplate) {
  60. options.render = compiledTemplate.render
  61. options.staticRenderFns = compiledTemplate.staticRenderFns
  62. }
  63. // scopedId
  64. if (scopeId) {
  65. options._scopeId = scopeId
  66. }
  67. // inject cssModules
  68. if (cssModules) {
  69. var computed = options.computed || (options.computed = {})
  70. Object.keys(cssModules).forEach(function (key) {
  71. var module = cssModules[key]
  72. computed[key] = function () { return module }
  73. })
  74. }
  75. return {
  76. esModule: esModule,
  77. exports: scriptExports,
  78. options: options
  79. }
  80. }
  81. /***/ },
  82. /***/ 14:
  83. /***/ function(module, exports) {
  84. module.exports = require("element-ui/lib/mixins/emitter");
  85. /***/ },
  86. /***/ 160:
  87. /***/ function(module, exports, __webpack_require__) {
  88. 'use strict';
  89. exports.__esModule = true;
  90. var _input = __webpack_require__(161);
  91. var _input2 = _interopRequireDefault(_input);
  92. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  93. /* istanbul ignore next */
  94. _input2.default.install = function (Vue) {
  95. Vue.component(_input2.default.name, _input2.default);
  96. };
  97. exports.default = _input2.default;
  98. /***/ },
  99. /***/ 161:
  100. /***/ function(module, exports, __webpack_require__) {
  101. var Component = __webpack_require__(3)(
  102. /* script */
  103. __webpack_require__(162),
  104. /* template */
  105. __webpack_require__(165),
  106. /* scopeId */
  107. null,
  108. /* cssModules */
  109. null
  110. )
  111. module.exports = Component.exports
  112. /***/ },
  113. /***/ 162:
  114. /***/ function(module, exports, __webpack_require__) {
  115. 'use strict';
  116. exports.__esModule = true;
  117. var _emitter = __webpack_require__(14);
  118. var _emitter2 = _interopRequireDefault(_emitter);
  119. var _calcTextareaHeight = __webpack_require__(163);
  120. var _calcTextareaHeight2 = _interopRequireDefault(_calcTextareaHeight);
  121. var _merge = __webpack_require__(164);
  122. var _merge2 = _interopRequireDefault(_merge);
  123. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  124. exports.default = {
  125. name: 'ElInput',
  126. componentName: 'ElInput',
  127. mixins: [_emitter2.default],
  128. data: function data() {
  129. return {
  130. currentValue: this.value,
  131. textareaCalcStyle: {}
  132. };
  133. },
  134. props: {
  135. value: [String, Number],
  136. placeholder: String,
  137. size: String,
  138. resize: String,
  139. readonly: Boolean,
  140. autofocus: Boolean,
  141. icon: String,
  142. disabled: Boolean,
  143. type: {
  144. type: String,
  145. default: 'text'
  146. },
  147. name: String,
  148. autosize: {
  149. type: [Boolean, Object],
  150. default: false
  151. },
  152. rows: {
  153. type: Number,
  154. default: 2
  155. },
  156. autoComplete: {
  157. type: String,
  158. default: 'off'
  159. },
  160. form: String,
  161. maxlength: Number,
  162. minlength: Number,
  163. max: {},
  164. min: {},
  165. step: {},
  166. validateEvent: {
  167. type: Boolean,
  168. default: true
  169. },
  170. onIconClick: Function
  171. },
  172. computed: {
  173. validating: function validating() {
  174. return this.$parent.validateState === 'validating';
  175. },
  176. textareaStyle: function textareaStyle() {
  177. return (0, _merge2.default)({}, this.textareaCalcStyle, { resize: this.resize });
  178. }
  179. },
  180. watch: {
  181. 'value': function value(val, oldValue) {
  182. this.setCurrentValue(val);
  183. }
  184. },
  185. methods: {
  186. handleBlur: function handleBlur(event) {
  187. this.$emit('blur', event);
  188. if (this.validateEvent) {
  189. this.dispatch('ElFormItem', 'el.form.blur', [this.currentValue]);
  190. }
  191. },
  192. inputSelect: function inputSelect() {
  193. this.$refs.input.select();
  194. },
  195. resizeTextarea: function resizeTextarea() {
  196. if (this.$isServer) return;
  197. var autosize = this.autosize,
  198. type = this.type;
  199. if (!autosize || type !== 'textarea') return;
  200. var minRows = autosize.minRows;
  201. var maxRows = autosize.maxRows;
  202. this.textareaCalcStyle = (0, _calcTextareaHeight2.default)(this.$refs.textarea, minRows, maxRows);
  203. },
  204. handleFocus: function handleFocus(event) {
  205. this.$emit('focus', event);
  206. },
  207. handleInput: function handleInput(event) {
  208. var value = event.target.value;
  209. this.$emit('input', value);
  210. this.setCurrentValue(value);
  211. this.$emit('change', value);
  212. },
  213. handleIconClick: function handleIconClick(event) {
  214. if (this.onIconClick) {
  215. this.onIconClick(event);
  216. }
  217. this.$emit('click', event);
  218. },
  219. setCurrentValue: function setCurrentValue(value) {
  220. var _this = this;
  221. if (value === this.currentValue) return;
  222. this.$nextTick(function (_) {
  223. _this.resizeTextarea();
  224. });
  225. this.currentValue = value;
  226. if (this.validateEvent) {
  227. this.dispatch('ElFormItem', 'el.form.change', [value]);
  228. }
  229. }
  230. },
  231. created: function created() {
  232. this.$on('inputSelect', this.inputSelect);
  233. },
  234. mounted: function mounted() {
  235. this.resizeTextarea();
  236. }
  237. }; //
  238. //
  239. //
  240. //
  241. //
  242. //
  243. //
  244. //
  245. //
  246. //
  247. //
  248. //
  249. //
  250. //
  251. //
  252. //
  253. //
  254. //
  255. //
  256. //
  257. //
  258. //
  259. //
  260. //
  261. //
  262. //
  263. //
  264. //
  265. //
  266. //
  267. //
  268. //
  269. //
  270. //
  271. //
  272. //
  273. //
  274. //
  275. //
  276. //
  277. //
  278. //
  279. //
  280. //
  281. //
  282. //
  283. //
  284. //
  285. //
  286. //
  287. //
  288. //
  289. //
  290. //
  291. //
  292. //
  293. //
  294. //
  295. //
  296. //
  297. //
  298. //
  299. //
  300. //
  301. //
  302. //
  303. //
  304. //
  305. //
  306. //
  307. //
  308. //
  309. //
  310. //
  311. //
  312. //
  313. /***/ },
  314. /***/ 163:
  315. /***/ function(module, exports) {
  316. 'use strict';
  317. exports.__esModule = true;
  318. exports.default = calcTextareaHeight;
  319. var hiddenTextarea = void 0;
  320. var HIDDEN_STYLE = '\n height:0 !important;\n visibility:hidden !important;\n overflow:hidden !important;\n position:absolute !important;\n z-index:-1000 !important;\n top:0 !important;\n right:0 !important\n';
  321. var CONTEXT_STYLE = ['letter-spacing', 'line-height', 'padding-top', 'padding-bottom', 'font-family', 'font-weight', 'font-size', 'text-rendering', 'text-transform', 'width', 'text-indent', 'padding-left', 'padding-right', 'border-width', 'box-sizing'];
  322. function calculateNodeStyling(node) {
  323. var style = window.getComputedStyle(node);
  324. var boxSizing = style.getPropertyValue('box-sizing');
  325. var paddingSize = parseFloat(style.getPropertyValue('padding-bottom')) + parseFloat(style.getPropertyValue('padding-top'));
  326. var borderSize = parseFloat(style.getPropertyValue('border-bottom-width')) + parseFloat(style.getPropertyValue('border-top-width'));
  327. var contextStyle = CONTEXT_STYLE.map(function (name) {
  328. return name + ':' + style.getPropertyValue(name);
  329. }).join(';');
  330. return { contextStyle: contextStyle, paddingSize: paddingSize, borderSize: borderSize, boxSizing: boxSizing };
  331. }
  332. function calcTextareaHeight(targetNode) {
  333. var minRows = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  334. var maxRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  335. if (!hiddenTextarea) {
  336. hiddenTextarea = document.createElement('textarea');
  337. document.body.appendChild(hiddenTextarea);
  338. }
  339. var _calculateNodeStyling = calculateNodeStyling(targetNode),
  340. paddingSize = _calculateNodeStyling.paddingSize,
  341. borderSize = _calculateNodeStyling.borderSize,
  342. boxSizing = _calculateNodeStyling.boxSizing,
  343. contextStyle = _calculateNodeStyling.contextStyle;
  344. hiddenTextarea.setAttribute('style', contextStyle + ';' + HIDDEN_STYLE);
  345. hiddenTextarea.value = targetNode.value || targetNode.placeholder || '';
  346. var height = hiddenTextarea.scrollHeight;
  347. if (boxSizing === 'border-box') {
  348. height = height + borderSize;
  349. } else if (boxSizing === 'content-box') {
  350. height = height - paddingSize;
  351. }
  352. hiddenTextarea.value = '';
  353. var singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
  354. if (minRows !== null) {
  355. var minHeight = singleRowHeight * minRows;
  356. if (boxSizing === 'border-box') {
  357. minHeight = minHeight + paddingSize + borderSize;
  358. }
  359. height = Math.max(minHeight, height);
  360. }
  361. if (maxRows !== null) {
  362. var maxHeight = singleRowHeight * maxRows;
  363. if (boxSizing === 'border-box') {
  364. maxHeight = maxHeight + paddingSize + borderSize;
  365. }
  366. height = Math.min(maxHeight, height);
  367. }
  368. return { height: height + 'px' };
  369. };
  370. /***/ },
  371. /***/ 164:
  372. /***/ function(module, exports) {
  373. module.exports = require("element-ui/lib/utils/merge");
  374. /***/ },
  375. /***/ 165:
  376. /***/ function(module, exports) {
  377. module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  378. return _c('div', {
  379. class: [
  380. _vm.type === 'textarea' ? 'el-textarea' : 'el-input',
  381. _vm.size ? 'el-input--' + _vm.size : '', {
  382. 'is-disabled': _vm.disabled,
  383. 'el-input-group': _vm.$slots.prepend || _vm.$slots.append,
  384. 'el-input-group--append': _vm.$slots.append,
  385. 'el-input-group--prepend': _vm.$slots.prepend
  386. }
  387. ]
  388. }, [(_vm.type !== 'textarea') ? [(_vm.$slots.prepend) ? _c('div', {
  389. staticClass: "el-input-group__prepend"
  390. }, [_vm._t("prepend")], 2) : _vm._e(), _vm._t("icon", [(_vm.icon) ? _c('i', {
  391. staticClass: "el-input__icon",
  392. class: [
  393. 'el-icon-' + _vm.icon,
  394. _vm.onIconClick ? 'is-clickable' : ''
  395. ],
  396. on: {
  397. "click": _vm.handleIconClick
  398. }
  399. }) : _vm._e()]), (_vm.type !== 'textarea') ? _c('input', {
  400. ref: "input",
  401. staticClass: "el-input__inner",
  402. attrs: {
  403. "type": _vm.type,
  404. "name": _vm.name,
  405. "placeholder": _vm.placeholder,
  406. "disabled": _vm.disabled,
  407. "readonly": _vm.readonly,
  408. "maxlength": _vm.maxlength,
  409. "minlength": _vm.minlength,
  410. "autocomplete": _vm.autoComplete,
  411. "autofocus": _vm.autofocus,
  412. "min": _vm.min,
  413. "max": _vm.max,
  414. "step": _vm.step,
  415. "form": _vm.form
  416. },
  417. domProps: {
  418. "value": _vm.currentValue
  419. },
  420. on: {
  421. "input": _vm.handleInput,
  422. "focus": _vm.handleFocus,
  423. "blur": _vm.handleBlur
  424. }
  425. }) : _vm._e(), (_vm.validating) ? _c('i', {
  426. staticClass: "el-input__icon el-icon-loading"
  427. }) : _vm._e(), (_vm.$slots.append) ? _c('div', {
  428. staticClass: "el-input-group__append"
  429. }, [_vm._t("append")], 2) : _vm._e()] : _c('textarea', {
  430. ref: "textarea",
  431. staticClass: "el-textarea__inner",
  432. style: (_vm.textareaStyle),
  433. attrs: {
  434. "name": _vm.name,
  435. "placeholder": _vm.placeholder,
  436. "disabled": _vm.disabled,
  437. "readonly": _vm.readonly,
  438. "rows": _vm.rows,
  439. "form": _vm.form,
  440. "autofocus": _vm.autofocus,
  441. "maxlength": _vm.maxlength,
  442. "minlength": _vm.minlength
  443. },
  444. domProps: {
  445. "value": _vm.currentValue
  446. },
  447. on: {
  448. "input": _vm.handleInput,
  449. "focus": _vm.handleFocus,
  450. "blur": _vm.handleBlur
  451. }
  452. })], 2)
  453. },staticRenderFns: []}
  454. /***/ }
  455. /******/ });