UNPKG

13.7 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, { 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 = 88);
86/******/ })
87/************************************************************************/
88/******/ ({
89
90/***/ 0:
91/***/ (function(module, __webpack_exports__, __webpack_require__) {
92
93"use strict";
94/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
95/* globals __VUE_SSR_CONTEXT__ */
96
97// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
98// This module is a runtime utility for cleaner component module output and will
99// be included in the final webpack user bundle.
100
101function normalizeComponent (
102 scriptExports,
103 render,
104 staticRenderFns,
105 functionalTemplate,
106 injectStyles,
107 scopeId,
108 moduleIdentifier, /* server only */
109 shadowMode /* vue-cli only */
110) {
111 // Vue.extend constructor export interop
112 var options = typeof scriptExports === 'function'
113 ? scriptExports.options
114 : scriptExports
115
116 // render functions
117 if (render) {
118 options.render = render
119 options.staticRenderFns = staticRenderFns
120 options._compiled = true
121 }
122
123 // functional template
124 if (functionalTemplate) {
125 options.functional = true
126 }
127
128 // scopedId
129 if (scopeId) {
130 options._scopeId = 'data-v-' + scopeId
131 }
132
133 var hook
134 if (moduleIdentifier) { // server build
135 hook = function (context) {
136 // 2.3 injection
137 context =
138 context || // cached call
139 (this.$vnode && this.$vnode.ssrContext) || // stateful
140 (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
141 // 2.2 with runInNewContext: true
142 if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
143 context = __VUE_SSR_CONTEXT__
144 }
145 // inject component styles
146 if (injectStyles) {
147 injectStyles.call(this, context)
148 }
149 // register component module identifier for async chunk inferrence
150 if (context && context._registeredComponents) {
151 context._registeredComponents.add(moduleIdentifier)
152 }
153 }
154 // used by ssr in case component is cached and beforeCreate
155 // never gets called
156 options._ssrRegister = hook
157 } else if (injectStyles) {
158 hook = shadowMode
159 ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
160 : injectStyles
161 }
162
163 if (hook) {
164 if (options.functional) {
165 // for template-only hot-reload because in that case the render fn doesn't
166 // go through the normalizer
167 options._injectStyles = hook
168 // register for functioal component in vue file
169 var originalRender = options.render
170 options.render = function renderWithStyleInjection (h, context) {
171 hook.call(context)
172 return originalRender(h, context)
173 }
174 } else {
175 // inject component registration as beforeCreate hook
176 var existing = options.beforeCreate
177 options.beforeCreate = existing
178 ? [].concat(existing, hook)
179 : [hook]
180 }
181 }
182
183 return {
184 exports: scriptExports,
185 options: options
186 }
187}
188
189
190/***/ }),
191
192/***/ 88:
193/***/ (function(module, __webpack_exports__, __webpack_require__) {
194
195"use strict";
196__webpack_require__.r(__webpack_exports__);
197
198// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/form/src/form.vue?vue&type=template&id=a1b5ff34&
199var render = function() {
200 var _vm = this
201 var _h = _vm.$createElement
202 var _c = _vm._self._c || _h
203 return _c(
204 "form",
205 {
206 staticClass: "el-form",
207 class: [
208 _vm.labelPosition ? "el-form--label-" + _vm.labelPosition : "",
209 { "el-form--inline": _vm.inline }
210 ]
211 },
212 [_vm._t("default")],
213 2
214 )
215}
216var staticRenderFns = []
217render._withStripped = true
218
219
220// CONCATENATED MODULE: ./packages/form/src/form.vue?vue&type=template&id=a1b5ff34&
221
222// EXTERNAL MODULE: external "element-ui/lib/utils/merge"
223var merge_ = __webpack_require__(9);
224var merge_default = /*#__PURE__*/__webpack_require__.n(merge_);
225
226// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/form/src/form.vue?vue&type=script&lang=js&
227//
228//
229//
230//
231//
232//
233//
234//
235
236
237
238/* harmony default export */ var formvue_type_script_lang_js_ = ({
239 name: 'ElForm',
240
241 componentName: 'ElForm',
242
243 provide: function provide() {
244 return {
245 elForm: this
246 };
247 },
248
249
250 props: {
251 model: Object,
252 rules: Object,
253 labelPosition: String,
254 labelWidth: String,
255 labelSuffix: {
256 type: String,
257 default: ''
258 },
259 inline: Boolean,
260 inlineMessage: Boolean,
261 statusIcon: Boolean,
262 showMessage: {
263 type: Boolean,
264 default: true
265 },
266 size: String,
267 disabled: Boolean,
268 validateOnRuleChange: {
269 type: Boolean,
270 default: true
271 },
272 hideRequiredAsterisk: {
273 type: Boolean,
274 default: false
275 }
276 },
277 watch: {
278 rules: function rules() {
279 // remove then add event listeners on form-item after form rules change
280 this.fields.forEach(function (field) {
281 field.removeValidateEvents();
282 field.addValidateEvents();
283 });
284
285 if (this.validateOnRuleChange) {
286 this.validate(function () {});
287 }
288 }
289 },
290 computed: {
291 autoLabelWidth: function autoLabelWidth() {
292 if (!this.potentialLabelWidthArr.length) return 0;
293 var max = Math.max.apply(Math, this.potentialLabelWidthArr);
294 return max ? max + 'px' : '';
295 }
296 },
297 data: function data() {
298 return {
299 fields: [],
300 potentialLabelWidthArr: [] // use this array to calculate auto width
301 };
302 },
303 created: function created() {
304 var _this = this;
305
306 this.$on('el.form.addField', function (field) {
307 if (field) {
308 _this.fields.push(field);
309 }
310 });
311 /* istanbul ignore next */
312 this.$on('el.form.removeField', function (field) {
313 if (field.prop) {
314 _this.fields.splice(_this.fields.indexOf(field), 1);
315 }
316 });
317 },
318
319 methods: {
320 resetFields: function resetFields() {
321 if (!this.model) {
322 console.warn('[Element Warn][Form]model is required for resetFields to work.');
323 return;
324 }
325 this.fields.forEach(function (field) {
326 field.resetField();
327 });
328 },
329 clearValidate: function clearValidate() {
330 var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
331
332 var fields = props.length ? typeof props === 'string' ? this.fields.filter(function (field) {
333 return props === field.prop;
334 }) : this.fields.filter(function (field) {
335 return props.indexOf(field.prop) > -1;
336 }) : this.fields;
337 fields.forEach(function (field) {
338 field.clearValidate();
339 });
340 },
341 validate: function validate(callback) {
342 var _this2 = this;
343
344 if (!this.model) {
345 console.warn('[Element Warn][Form]model is required for validate to work!');
346 return;
347 }
348
349 var promise = void 0;
350 // if no callback, return promise
351 if (typeof callback !== 'function' && window.Promise) {
352 promise = new window.Promise(function (resolve, reject) {
353 callback = function callback(valid) {
354 valid ? resolve(valid) : reject(valid);
355 };
356 });
357 }
358
359 var valid = true;
360 var count = 0;
361 // 如果需要验证的fields为空,调用验证时立刻返回callback
362 if (this.fields.length === 0 && callback) {
363 callback(true);
364 }
365 var invalidFields = {};
366 this.fields.forEach(function (field) {
367 field.validate('', function (message, field) {
368 if (message) {
369 valid = false;
370 }
371 invalidFields = merge_default()({}, invalidFields, field);
372 if (typeof callback === 'function' && ++count === _this2.fields.length) {
373 callback(valid, invalidFields);
374 }
375 });
376 });
377
378 if (promise) {
379 return promise;
380 }
381 },
382 validateField: function validateField(props, cb) {
383 props = [].concat(props);
384 var fields = this.fields.filter(function (field) {
385 return props.indexOf(field.prop) !== -1;
386 });
387 if (!fields.length) {
388 console.warn('[Element Warn]please pass correct props!');
389 return;
390 }
391
392 fields.forEach(function (field) {
393 field.validate('', cb);
394 });
395 },
396 getLabelWidthIndex: function getLabelWidthIndex(width) {
397 var index = this.potentialLabelWidthArr.indexOf(width);
398 // it's impossible
399 if (index === -1) {
400 throw new Error('[ElementForm]unpected width ', width);
401 }
402 return index;
403 },
404 registerLabelWidth: function registerLabelWidth(val, oldVal) {
405 if (val && oldVal) {
406 var index = this.getLabelWidthIndex(oldVal);
407 this.potentialLabelWidthArr.splice(index, 1, val);
408 } else if (val) {
409 this.potentialLabelWidthArr.push(val);
410 }
411 },
412 deregisterLabelWidth: function deregisterLabelWidth(val) {
413 var index = this.getLabelWidthIndex(val);
414 this.potentialLabelWidthArr.splice(index, 1);
415 }
416 }
417});
418// CONCATENATED MODULE: ./packages/form/src/form.vue?vue&type=script&lang=js&
419 /* harmony default export */ var src_formvue_type_script_lang_js_ = (formvue_type_script_lang_js_);
420// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
421var componentNormalizer = __webpack_require__(0);
422
423// CONCATENATED MODULE: ./packages/form/src/form.vue
424
425
426
427
428
429/* normalize component */
430
431var component = Object(componentNormalizer["a" /* default */])(
432 src_formvue_type_script_lang_js_,
433 render,
434 staticRenderFns,
435 false,
436 null,
437 null,
438 null
439
440)
441
442/* hot reload */
443if (false) { var api; }
444component.options.__file = "packages/form/src/form.vue"
445/* harmony default export */ var src_form = (component.exports);
446// CONCATENATED MODULE: ./packages/form/index.js
447
448
449/* istanbul ignore next */
450src_form.install = function (Vue) {
451 Vue.component(src_form.name, src_form);
452};
453
454/* harmony default export */ var packages_form = __webpack_exports__["default"] = (src_form);
455
456/***/ }),
457
458/***/ 9:
459/***/ (function(module, exports) {
460
461module.exports = require("element-ui/lib/utils/merge");
462
463/***/ })
464
465/******/ });
\No newline at end of file