UNPKG

17.3 kBJavaScriptView Raw
1module.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, {
41/******/ configurable: false,
42/******/ enumerable: true,
43/******/ get: getter
44/******/ });
45/******/ }
46/******/ };
47/******/
48/******/ // getDefaultExport function for compatibility with non-harmony modules
49/******/ __webpack_require__.n = function(module) {
50/******/ var getter = module && module.__esModule ?
51/******/ function getDefault() { return module['default']; } :
52/******/ function getModuleExports() { return module; };
53/******/ __webpack_require__.d(getter, 'a', getter);
54/******/ return getter;
55/******/ };
56/******/
57/******/ // Object.prototype.hasOwnProperty.call
58/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
59/******/
60/******/ // __webpack_public_path__
61/******/ __webpack_require__.p = "/dist/";
62/******/
63/******/ // Load entry module and return exports
64/******/ return __webpack_require__(__webpack_require__.s = 227);
65/******/ })
66/************************************************************************/
67/******/ ({
68
69/***/ 0:
70/***/ (function(module, exports) {
71
72/* globals __VUE_SSR_CONTEXT__ */
73
74// IMPORTANT: Do NOT use ES2015 features in this file.
75// This module is a runtime utility for cleaner component module output and will
76// be included in the final webpack user bundle.
77
78module.exports = function normalizeComponent (
79 rawScriptExports,
80 compiledTemplate,
81 functionalTemplate,
82 injectStyles,
83 scopeId,
84 moduleIdentifier /* server only */
85) {
86 var esModule
87 var scriptExports = rawScriptExports = rawScriptExports || {}
88
89 // ES6 modules interop
90 var type = typeof rawScriptExports.default
91 if (type === 'object' || type === 'function') {
92 esModule = rawScriptExports
93 scriptExports = rawScriptExports.default
94 }
95
96 // Vue.extend constructor export interop
97 var options = typeof scriptExports === 'function'
98 ? scriptExports.options
99 : scriptExports
100
101 // render functions
102 if (compiledTemplate) {
103 options.render = compiledTemplate.render
104 options.staticRenderFns = compiledTemplate.staticRenderFns
105 options._compiled = true
106 }
107
108 // functional template
109 if (functionalTemplate) {
110 options.functional = true
111 }
112
113 // scopedId
114 if (scopeId) {
115 options._scopeId = scopeId
116 }
117
118 var hook
119 if (moduleIdentifier) { // server build
120 hook = function (context) {
121 // 2.3 injection
122 context =
123 context || // cached call
124 (this.$vnode && this.$vnode.ssrContext) || // stateful
125 (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
126 // 2.2 with runInNewContext: true
127 if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
128 context = __VUE_SSR_CONTEXT__
129 }
130 // inject component styles
131 if (injectStyles) {
132 injectStyles.call(this, context)
133 }
134 // register component module identifier for async chunk inferrence
135 if (context && context._registeredComponents) {
136 context._registeredComponents.add(moduleIdentifier)
137 }
138 }
139 // used by ssr in case component is cached and beforeCreate
140 // never gets called
141 options._ssrRegister = hook
142 } else if (injectStyles) {
143 hook = injectStyles
144 }
145
146 if (hook) {
147 var functional = options.functional
148 var existing = functional
149 ? options.render
150 : options.beforeCreate
151
152 if (!functional) {
153 // inject component registration as beforeCreate hook
154 options.beforeCreate = existing
155 ? [].concat(existing, hook)
156 : [hook]
157 } else {
158 // for template-only hot-reload because in that case the render fn doesn't
159 // go through the normalizer
160 options._injectStyles = hook
161 // register for functioal component in vue file
162 options.render = function renderWithStyleInjection (h, context) {
163 hook.call(context)
164 return existing(h, context)
165 }
166 }
167 }
168
169 return {
170 esModule: esModule,
171 exports: scriptExports,
172 options: options
173 }
174}
175
176
177/***/ }),
178
179/***/ 1:
180/***/ (function(module, exports) {
181
182module.exports = require("element-ui/lib/mixins/emitter");
183
184/***/ }),
185
186/***/ 2:
187/***/ (function(module, exports) {
188
189module.exports = require("element-ui/lib/utils/util");
190
191/***/ }),
192
193/***/ 227:
194/***/ (function(module, exports, __webpack_require__) {
195
196"use strict";
197
198
199exports.__esModule = true;
200
201var _formItem = __webpack_require__(228);
202
203var _formItem2 = _interopRequireDefault(_formItem);
204
205function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
206
207/* istanbul ignore next */
208_formItem2.default.install = function (Vue) {
209 Vue.component(_formItem2.default.name, _formItem2.default);
210};
211
212exports.default = _formItem2.default;
213
214/***/ }),
215
216/***/ 228:
217/***/ (function(module, __webpack_exports__, __webpack_require__) {
218
219"use strict";
220Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
221/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_form_item_vue__ = __webpack_require__(229);
222/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_form_item_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_form_item_vue__);
223/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_5f25e5e7_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_form_item_vue__ = __webpack_require__(231);
224var normalizeComponent = __webpack_require__(0)
225/* script */
226
227/* template */
228
229/* template functional */
230 var __vue_template_functional__ = false
231/* styles */
232var __vue_styles__ = null
233/* scopeId */
234var __vue_scopeId__ = null
235/* moduleIdentifier (server only) */
236var __vue_module_identifier__ = null
237var Component = normalizeComponent(
238 __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_form_item_vue___default.a,
239 __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_5f25e5e7_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_form_item_vue__["a" /* default */],
240 __vue_template_functional__,
241 __vue_styles__,
242 __vue_scopeId__,
243 __vue_module_identifier__
244)
245
246/* harmony default export */ __webpack_exports__["default"] = (Component.exports);
247
248
249/***/ }),
250
251/***/ 229:
252/***/ (function(module, exports, __webpack_require__) {
253
254"use strict";
255
256
257exports.__esModule = true;
258
259var _asyncValidator = __webpack_require__(230);
260
261var _asyncValidator2 = _interopRequireDefault(_asyncValidator);
262
263var _emitter = __webpack_require__(1);
264
265var _emitter2 = _interopRequireDefault(_emitter);
266
267var _merge = __webpack_require__(9);
268
269var _merge2 = _interopRequireDefault(_merge);
270
271var _util = __webpack_require__(2);
272
273function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
311exports.default = {
312 name: 'ElFormItem',
313
314 componentName: 'ElFormItem',
315
316 mixins: [_emitter2.default],
317
318 provide: function provide() {
319 return {
320 elFormItem: this
321 };
322 },
323
324
325 inject: ['elForm'],
326
327 props: {
328 label: String,
329 labelWidth: String,
330 prop: String,
331 required: {
332 type: Boolean,
333 default: undefined
334 },
335 rules: [Object, Array],
336 error: String,
337 validateStatus: String,
338 for: String,
339 inlineMessage: {
340 type: [String, Boolean],
341 default: ''
342 },
343 showMessage: {
344 type: Boolean,
345 default: true
346 },
347 size: String
348 },
349 watch: {
350 error: {
351 immediate: true,
352 handler: function handler(value) {
353 this.validateMessage = value;
354 this.validateState = value ? 'error' : '';
355 }
356 },
357 validateStatus: function validateStatus(value) {
358 this.validateState = value;
359 }
360 },
361 computed: {
362 labelFor: function labelFor() {
363 return this.for || this.prop;
364 },
365 labelStyle: function labelStyle() {
366 var ret = {};
367 if (this.form.labelPosition === 'top') return ret;
368 var labelWidth = this.labelWidth || this.form.labelWidth;
369 if (labelWidth) {
370 ret.width = labelWidth;
371 }
372 return ret;
373 },
374 contentStyle: function contentStyle() {
375 var ret = {};
376 var label = this.label;
377 if (this.form.labelPosition === 'top' || this.form.inline) return ret;
378 if (!label && !this.labelWidth && this.isNested) return ret;
379 var labelWidth = this.labelWidth || this.form.labelWidth;
380 if (labelWidth) {
381 ret.marginLeft = labelWidth;
382 }
383 return ret;
384 },
385 form: function form() {
386 var parent = this.$parent;
387 var parentName = parent.$options.componentName;
388 while (parentName !== 'ElForm') {
389 if (parentName === 'ElFormItem') {
390 this.isNested = true;
391 }
392 parent = parent.$parent;
393 parentName = parent.$options.componentName;
394 }
395 return parent;
396 },
397 fieldValue: function fieldValue() {
398 var model = this.form.model;
399 if (!model || !this.prop) {
400 return;
401 }
402
403 var path = this.prop;
404 if (path.indexOf(':') !== -1) {
405 path = path.replace(/:/, '.');
406 }
407
408 return (0, _util.getPropByPath)(model, path, true).v;
409 },
410 isRequired: function isRequired() {
411 var rules = this.getRules();
412 var isRequired = false;
413
414 if (rules && rules.length) {
415 rules.every(function (rule) {
416 if (rule.required) {
417 isRequired = true;
418 return false;
419 }
420 return true;
421 });
422 }
423 return isRequired;
424 },
425 _formSize: function _formSize() {
426 return this.elForm.size;
427 },
428 elFormItemSize: function elFormItemSize() {
429 return this.size || this._formSize;
430 },
431 sizeClass: function sizeClass() {
432 return this.elFormItemSize || (this.$ELEMENT || {}).size;
433 }
434 },
435 data: function data() {
436 return {
437 validateState: '',
438 validateMessage: '',
439 validateDisabled: false,
440 validator: {},
441 isNested: false
442 };
443 },
444
445 methods: {
446 validate: function validate(trigger) {
447 var _this = this;
448
449 var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _util.noop;
450
451 this.validateDisabled = false;
452 var rules = this.getFilteredRule(trigger);
453 if ((!rules || rules.length === 0) && this.required === undefined) {
454 callback();
455 return true;
456 }
457
458 this.validateState = 'validating';
459
460 var descriptor = {};
461 if (rules && rules.length > 0) {
462 rules.forEach(function (rule) {
463 delete rule.trigger;
464 });
465 }
466 descriptor[this.prop] = rules;
467
468 var validator = new _asyncValidator2.default(descriptor);
469 var model = {};
470
471 model[this.prop] = this.fieldValue;
472
473 validator.validate(model, { firstFields: true }, function (errors, invalidFields) {
474 _this.validateState = !errors ? 'success' : 'error';
475 _this.validateMessage = errors ? errors[0].message : '';
476
477 callback(_this.validateMessage, invalidFields);
478 _this.elForm && _this.elForm.$emit('validate', _this.prop, !errors);
479 });
480 },
481 clearValidate: function clearValidate() {
482 this.validateState = '';
483 this.validateMessage = '';
484 this.validateDisabled = false;
485 },
486 resetField: function resetField() {
487 this.validateState = '';
488 this.validateMessage = '';
489
490 var model = this.form.model;
491 var value = this.fieldValue;
492 var path = this.prop;
493 if (path.indexOf(':') !== -1) {
494 path = path.replace(/:/, '.');
495 }
496
497 var prop = (0, _util.getPropByPath)(model, path, true);
498
499 this.validateDisabled = true;
500 if (Array.isArray(value)) {
501 prop.o[prop.k] = [].concat(this.initialValue);
502 } else {
503 prop.o[prop.k] = this.initialValue;
504 }
505
506 this.broadcast('ElTimeSelect', 'fieldReset', this.initialValue);
507 },
508 getRules: function getRules() {
509 var formRules = this.form.rules;
510 var selfRules = this.rules;
511 var requiredRule = this.required !== undefined ? { required: !!this.required } : [];
512
513 var prop = (0, _util.getPropByPath)(formRules, this.prop || '');
514 formRules = formRules ? prop.o[this.prop || ''] || prop.v : [];
515
516 return [].concat(selfRules || formRules || []).concat(requiredRule);
517 },
518 getFilteredRule: function getFilteredRule(trigger) {
519 var rules = this.getRules();
520
521 return rules.filter(function (rule) {
522 if (!rule.trigger || trigger === '') return true;
523 if (Array.isArray(rule.trigger)) {
524 return rule.trigger.indexOf(trigger) > -1;
525 } else {
526 return rule.trigger === trigger;
527 }
528 }).map(function (rule) {
529 return (0, _merge2.default)({}, rule);
530 });
531 },
532 onFieldBlur: function onFieldBlur() {
533 this.validate('blur');
534 },
535 onFieldChange: function onFieldChange() {
536 if (this.validateDisabled) {
537 this.validateDisabled = false;
538 return;
539 }
540
541 this.validate('change');
542 }
543 },
544 mounted: function mounted() {
545 if (this.prop) {
546 this.dispatch('ElForm', 'el.form.addField', [this]);
547
548 var initialValue = this.fieldValue;
549 if (Array.isArray(initialValue)) {
550 initialValue = [].concat(initialValue);
551 }
552 Object.defineProperty(this, 'initialValue', {
553 value: initialValue
554 });
555
556 var rules = this.getRules();
557
558 if (rules.length || this.required !== undefined) {
559 this.$on('el.form.blur', this.onFieldBlur);
560 this.$on('el.form.change', this.onFieldChange);
561 }
562 }
563 },
564 beforeDestroy: function beforeDestroy() {
565 this.dispatch('ElForm', 'el.form.removeField', [this]);
566 }
567};
568
569/***/ }),
570
571/***/ 230:
572/***/ (function(module, exports) {
573
574module.exports = require("async-validator");
575
576/***/ }),
577
578/***/ 231:
579/***/ (function(module, __webpack_exports__, __webpack_require__) {
580
581"use strict";
582var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"el-form-item",class:[{
583 'el-form-item--feedback': _vm.elForm && _vm.elForm.statusIcon,
584 'is-error': _vm.validateState === 'error',
585 'is-validating': _vm.validateState === 'validating',
586 'is-success': _vm.validateState === 'success',
587 'is-required': _vm.isRequired || _vm.required
588 },
589 _vm.sizeClass ? 'el-form-item--' + _vm.sizeClass : ''
590]},[(_vm.label || _vm.$slots.label)?_c('label',{staticClass:"el-form-item__label",style:(_vm.labelStyle),attrs:{"for":_vm.labelFor}},[_vm._t("label",[_vm._v(_vm._s(_vm.label + _vm.form.labelSuffix))])],2):_vm._e(),_c('div',{staticClass:"el-form-item__content",style:(_vm.contentStyle)},[_vm._t("default"),_c('transition',{attrs:{"name":"el-zoom-in-top"}},[(_vm.validateState === 'error' && _vm.showMessage && _vm.form.showMessage)?_vm._t("error",[_c('div',{staticClass:"el-form-item__error",class:{
591 'el-form-item__error--inline': typeof _vm.inlineMessage === 'boolean'
592 ? _vm.inlineMessage
593 : (_vm.elForm && _vm.elForm.inlineMessage || false)
594 }},[_vm._v("\n "+_vm._s(_vm.validateMessage)+"\n ")])],{error:_vm.validateMessage}):_vm._e()],2)],2)])}
595var staticRenderFns = []
596var esExports = { render: render, staticRenderFns: staticRenderFns }
597/* harmony default export */ __webpack_exports__["a"] = (esExports);
598
599/***/ }),
600
601/***/ 9:
602/***/ (function(module, exports) {
603
604module.exports = require("element-ui/lib/utils/merge");
605
606/***/ })
607
608/******/ });
\No newline at end of file