@form-create/element-ui 3.2.20 → 3.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @form-create/element-ui v3.2.20
2
+ * @form-create/element-ui v3.2.21
3
3
  * (c) 2018-2025 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -2165,424 +2165,122 @@
2165
2165
  return str.replace(str[0], str[0].toLocaleUpperCase());
2166
2166
  }
2167
2167
 
2168
- var _getGroupInject = function getGroupInject(vm, parent) {
2169
- if (!vm || vm === parent) {
2170
- return;
2171
- }
2172
-
2173
- if (vm.props.formCreateInject) {
2174
- return vm.props.formCreateInject;
2175
- }
2176
-
2177
- if (vm.parent) {
2178
- return _getGroupInject(vm.parent, parent);
2179
- }
2180
- };
2168
+ var normalMerge = ['props'];
2169
+ var toArrayMerge = ['class', 'style', 'directives'];
2170
+ var functionalMerge = ['on', 'hook'];
2181
2171
 
2182
- function $FormCreate(FormCreate, components, directives) {
2183
- return vue.defineComponent({
2184
- name: 'FormCreate' + (FormCreate.isMobile ? 'Mobile' : ''),
2185
- components: components,
2186
- directives: directives,
2187
- props: {
2188
- rule: {
2189
- type: Array,
2190
- required: true,
2191
- "default": function _default() {
2192
- return [];
2193
- }
2194
- },
2195
- option: {
2196
- type: Object,
2197
- "default": function _default() {
2198
- return {};
2199
- }
2200
- },
2201
- extendOption: Boolean,
2202
- driver: [String, Object],
2203
- modelValue: Object,
2204
- disabled: {
2205
- type: Boolean,
2206
- "default": undefined
2207
- },
2208
- preview: {
2209
- type: Boolean,
2210
- "default": undefined
2211
- },
2212
- index: [String, Number],
2213
- api: Object,
2214
- locale: [String, Object],
2215
- name: String,
2216
- subForm: {
2217
- type: Boolean,
2218
- "default": true
2219
- },
2220
- inFor: Boolean
2221
- },
2222
- emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'reset', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update', 'validate-field-fail', 'validate-fail', 'created'],
2223
- render: function render() {
2224
- return this.fc.render();
2225
- },
2226
- setup: function setup(props) {
2227
- var vm = vue.getCurrentInstance();
2228
- vue.provide('parentFC', vm);
2229
- var parent = vue.inject('parentFC', null);
2230
- var top = parent;
2172
+ var mergeProps = function mergeProps(objects) {
2173
+ var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2174
+ var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2231
2175
 
2232
- if (parent) {
2233
- while (top.setupState.parent) {
2234
- top = top.setupState.parent;
2235
- }
2236
- } else {
2237
- top = vm;
2238
- }
2176
+ var _normalMerge = [].concat(normalMerge, _toConsumableArray(opt['normal'] || []));
2239
2177
 
2240
- var _toRefs = vue.toRefs(props),
2241
- rule = _toRefs.rule,
2242
- modelValue = _toRefs.modelValue,
2243
- subForm = _toRefs.subForm,
2244
- inFor = _toRefs.inFor;
2178
+ var _toArrayMerge = [].concat(toArrayMerge, _toConsumableArray(opt['array'] || []));
2245
2179
 
2246
- var data = vue.reactive({
2247
- ctxInject: {},
2248
- destroyed: false,
2249
- isShow: true,
2250
- unique: 1,
2251
- renderRule: _toConsumableArray(rule.value || []),
2252
- updateValue: JSON.stringify(modelValue.value || {})
2253
- });
2254
- var fc = new FormCreate(vm);
2255
- var fapi = fc.api();
2256
- var isMore = inFor.value;
2180
+ var _functionalMerge = [].concat(functionalMerge, _toConsumableArray(opt['functional'] || []));
2257
2181
 
2258
- var addSubForm = function addSubForm() {
2259
- if (parent) {
2260
- var _inject = _getGroupInject(vm, parent);
2182
+ var propsMerge = opt['props'] || [];
2183
+ return objects.reduce(function (a, b) {
2184
+ for (var key in b) {
2185
+ if (a[key]) {
2186
+ if (propsMerge.indexOf(key) > -1) {
2187
+ a[key] = mergeProps([b[key]], a[key]);
2188
+ } else if (_normalMerge.indexOf(key) > -1) {
2189
+ a[key] = _objectSpread2(_objectSpread2({}, a[key]), b[key]);
2190
+ } else if (_toArrayMerge.indexOf(key) > -1) {
2191
+ var arrA = a[key] instanceof Array ? a[key] : [a[key]];
2192
+ var arrB = b[key] instanceof Array ? b[key] : [b[key]];
2193
+ a[key] = [].concat(_toConsumableArray(arrA), _toConsumableArray(arrB));
2194
+ } else if (_functionalMerge.indexOf(key) > -1) {
2195
+ for (var event in b[key]) {
2196
+ if (a[key][event]) {
2197
+ var _arrA = a[key][event] instanceof Array ? a[key][event] : [a[key][event]];
2261
2198
 
2262
- if (_inject) {
2263
- var sub;
2199
+ var _arrB = b[key][event] instanceof Array ? b[key][event] : [b[key][event]];
2264
2200
 
2265
- if (isMore) {
2266
- sub = toArray(_inject.getSubForm());
2267
- sub.push(fapi);
2201
+ a[key][event] = [].concat(_toConsumableArray(_arrA), _toConsumableArray(_arrB));
2268
2202
  } else {
2269
- sub = fapi;
2203
+ a[key][event] = b[key][event];
2270
2204
  }
2271
-
2272
- _inject.subForm(sub);
2273
2205
  }
2274
- }
2275
- };
2276
-
2277
- var rmSubForm = function rmSubForm() {
2278
- var inject = _getGroupInject(vm, parent);
2279
-
2280
- if (inject) {
2281
- if (isMore) {
2282
- var sub = toArray(inject.getSubForm());
2283
- var idx = sub.indexOf(fapi);
2284
-
2285
- if (idx > -1) {
2286
- sub.splice(idx, 1);
2206
+ } else if (key === 'hook') {
2207
+ for (var hook in b[key]) {
2208
+ if (a[key][hook]) {
2209
+ a[key][hook] = mergeFn(a[key][hook], b[key][hook]);
2210
+ } else {
2211
+ a[key][hook] = b[key][hook];
2287
2212
  }
2288
- } else {
2289
- inject.subForm();
2290
2213
  }
2214
+ } else {
2215
+ a[key] = b[key];
2291
2216
  }
2292
- };
2217
+ } else {
2218
+ if (_normalMerge.indexOf(key) > -1 || _functionalMerge.indexOf(key) > -1 || propsMerge.indexOf(key) > -1) {
2219
+ a[key] = _objectSpread2({}, b[key]);
2220
+ } else if (_toArrayMerge.indexOf(key) > -1) {
2221
+ a[key] = b[key] instanceof Array ? _toConsumableArray(b[key]) : _typeof(b[key]) === 'object' ? _objectSpread2({}, b[key]) : b[key];
2222
+ } else a[key] = b[key];
2223
+ }
2224
+ }
2293
2225
 
2294
- var styleEl = null;
2295
- vue.onBeforeMount(function () {
2296
- vue.watchEffect(function () {
2297
- var content = '';
2298
- var globalClass = props.option && props.option.globalClass || {};
2299
- Object.keys(globalClass).forEach(function (k) {
2300
- var subCss = '';
2301
- globalClass[k].style && Object.keys(globalClass[k].style).forEach(function (key) {
2302
- subCss += toLine(key) + ':' + globalClass[k].style[key] + ';';
2303
- });
2226
+ return a;
2227
+ }, initial);
2228
+ };
2304
2229
 
2305
- if (globalClass[k].content) {
2306
- subCss += globalClass[k].content + ';';
2307
- }
2230
+ var mergeFn = function mergeFn(fn1, fn2) {
2231
+ return function () {
2232
+ fn1 && fn1.apply(this, arguments);
2233
+ fn2 && fn2.apply(this, arguments);
2234
+ };
2235
+ };
2308
2236
 
2309
- if (subCss) {
2310
- content += ".".concat(k, "{").concat(subCss, "}");
2311
- }
2312
- });
2237
+ var keyAttrs = ['type', 'slot', 'ignore', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate', 'computed', 'preview', 'component', 'cache', 'modelEmit'];
2238
+ var arrayAttrs = ['validate', 'children', 'control'];
2239
+ var normalAttrs = ['effect', 'deep', 'renderSlots'];
2240
+ function attrs() {
2241
+ return [].concat(keyAttrs, _toConsumableArray(normalMerge), _toConsumableArray(toArrayMerge), _toConsumableArray(functionalMerge), arrayAttrs, normalAttrs);
2242
+ }
2313
2243
 
2314
- if (props.option && props.option.style) {
2315
- content += props.option.style;
2316
- }
2244
+ function format(type, msg, rule) {
2245
+ return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
2246
+ }
2247
+ function err(msg, rule) {
2248
+ console.error(format('err', msg, rule));
2249
+ }
2250
+ function logError(e) {
2251
+ err(e.toString());
2252
+ console.error(e);
2253
+ }
2317
2254
 
2318
- if (!styleEl) {
2319
- styleEl = document.createElement('style');
2320
- styleEl.type = 'text/css';
2321
- document.head.appendChild(styleEl);
2322
- }
2255
+ function toCase(str) {
2256
+ var to = str.replace(/(-[a-z])/g, function (v) {
2257
+ return v.replace('-', '').toLocaleUpperCase();
2258
+ });
2259
+ return lower(to);
2260
+ }
2261
+ function lower(str) {
2262
+ return str.replace(str[0], str[0].toLowerCase());
2263
+ }
2323
2264
 
2324
- styleEl.innerHTML = content || '';
2325
- });
2326
- });
2327
- var emit$topForm = debounce(function () {
2328
- fc.bus.$emit('$loadData.$topForm');
2329
- }, 100);
2330
- var emit$scopeForm = debounce(function () {
2331
- fc.bus.$emit('$loadData.$scopeForm');
2332
- }, 100);
2333
- var emit$form = debounce(function () {
2334
- fc.bus.$emit('$loadData.$form');
2335
- }, 100);
2265
+ var PREFIX = '[[FORM-CREATE-PREFIX-';
2266
+ var SUFFIX = '-FORM-CREATE-SUFFIX]]';
2267
+ function toJson(obj, space) {
2268
+ return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
2269
+ if (val && val._isVue === true) return undefined;
2336
2270
 
2337
- var emit$change = function emit$change(field) {
2338
- fc.bus.$emit('change-$form.' + field);
2339
- };
2271
+ if (typeof val !== 'function') {
2272
+ return val;
2273
+ }
2340
2274
 
2341
- vue.onMounted(function () {
2342
- if (parent) {
2343
- fapi.top.bus.$on('$loadData.$form', emit$topForm);
2344
- fapi.top.bus.$on('change', emit$change);
2345
- }
2275
+ if (val.__json) {
2276
+ return val.__json;
2277
+ }
2346
2278
 
2347
- if (fapi !== fapi.scope) {
2348
- fapi.scope.bus.$on('$loadData.$scopeForm', emit$scopeForm);
2349
- }
2350
-
2351
- fc.mounted();
2352
- });
2353
- vue.onBeforeUnmount(function () {
2354
- if (parent) {
2355
- fapi.top.bus.$off('$loadData.$form', emit$topForm);
2356
- fapi.top.bus.$off('change', emit$change);
2357
- }
2358
-
2359
- if (fapi !== fapi.scope) {
2360
- fapi.scope.bus.$off('$loadData.$scopeForm', emit$scopeForm);
2361
- }
2362
-
2363
- styleEl && document.head.removeChild(styleEl);
2364
- rmSubForm();
2365
- data.destroyed = true;
2366
- fc.unmount();
2367
- });
2368
- vue.onUpdated(function () {
2369
- fc.updated();
2370
- });
2371
- vue.watch(subForm, function (n) {
2372
- n ? addSubForm() : rmSubForm();
2373
- }, {
2374
- immediate: true
2375
- });
2376
- vue.watch(function () {
2377
- return props.option;
2378
- }, function () {
2379
- fc.initOptions();
2380
- fapi.refresh();
2381
- }, {
2382
- deep: true
2383
- });
2384
- vue.watch(function () {
2385
- return _toConsumableArray(rule.value);
2386
- }, function (n) {
2387
- if (fc.$handle.isBreakWatch() || n.length === data.renderRule.length && n.every(function (v) {
2388
- return data.renderRule.indexOf(v) > -1;
2389
- })) return;
2390
- fc.$handle.updateAppendData();
2391
- fc.$handle.reloadRule(rule.value);
2392
- vm.setupState.renderRule();
2393
- });
2394
- vue.watch(function () {
2395
- return [props.disabled, props.preview];
2396
- }, function () {
2397
- fapi.refresh();
2398
- });
2399
- vue.watch(modelValue, function (n) {
2400
- if (JSON.stringify(n || {}) === data.updateValue) return;
2401
-
2402
- if (fapi.config.forceCoverValue) {
2403
- fapi.coverValue(n || {});
2404
- } else {
2405
- fapi.setValue(n || {});
2406
- }
2407
- }, {
2408
- deep: true,
2409
- flush: 'post'
2410
- });
2411
- vue.watch(function () {
2412
- return props.index;
2413
- }, function () {
2414
- fapi.coverValue({});
2415
- fc.$handle.updateAppendData();
2416
- vue.nextTick(function () {
2417
- vue.nextTick(function () {
2418
- fapi.clearValidateState();
2419
- });
2420
- });
2421
- }, {
2422
- flush: 'sync'
2423
- });
2424
- return _objectSpread2(_objectSpread2({
2425
- fc: vue.markRaw(fc),
2426
- parent: parent ? vue.markRaw(parent) : parent,
2427
- top: vue.markRaw(top),
2428
- fapi: vue.markRaw(fapi)
2429
- }, vue.toRefs(data)), {}, {
2430
- getGroupInject: function getGroupInject() {
2431
- return _getGroupInject(vm, parent);
2432
- },
2433
- refresh: function refresh() {
2434
- ++data.unique;
2435
- },
2436
- renderRule: function renderRule() {
2437
- data.renderRule = _toConsumableArray(rule.value || []);
2438
- },
2439
- updateValue: function updateValue(value) {
2440
- if (data.destroyed) return;
2441
- var json = JSON.stringify(value);
2442
-
2443
- if (data.updateValue === json) {
2444
- return;
2445
- }
2446
-
2447
- data.updateValue = json;
2448
- vm.emit('update:modelValue', value);
2449
- vue.nextTick(function () {
2450
- emit$form();
2451
-
2452
- if (!parent) {
2453
- emit$topForm();
2454
- emit$scopeForm();
2455
- } else if (!subForm.value) {
2456
- emit$scopeForm();
2457
- }
2458
- });
2459
- }
2460
- });
2461
- },
2462
- created: function created() {
2463
- var vm = vue.getCurrentInstance();
2464
- vm.emit('update:api', vm.setupState.fapi);
2465
- vm.setupState.fc.init();
2466
- }
2467
- });
2468
- }
2469
-
2470
- var normalMerge = ['props'];
2471
- var toArrayMerge = ['class', 'style', 'directives'];
2472
- var functionalMerge = ['on', 'hook'];
2473
-
2474
- var mergeProps = function mergeProps(objects) {
2475
- var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2476
- var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2477
-
2478
- var _normalMerge = [].concat(normalMerge, _toConsumableArray(opt['normal'] || []));
2479
-
2480
- var _toArrayMerge = [].concat(toArrayMerge, _toConsumableArray(opt['array'] || []));
2481
-
2482
- var _functionalMerge = [].concat(functionalMerge, _toConsumableArray(opt['functional'] || []));
2483
-
2484
- var propsMerge = opt['props'] || [];
2485
- return objects.reduce(function (a, b) {
2486
- for (var key in b) {
2487
- if (a[key]) {
2488
- if (propsMerge.indexOf(key) > -1) {
2489
- a[key] = mergeProps([b[key]], a[key]);
2490
- } else if (_normalMerge.indexOf(key) > -1) {
2491
- a[key] = _objectSpread2(_objectSpread2({}, a[key]), b[key]);
2492
- } else if (_toArrayMerge.indexOf(key) > -1) {
2493
- var arrA = a[key] instanceof Array ? a[key] : [a[key]];
2494
- var arrB = b[key] instanceof Array ? b[key] : [b[key]];
2495
- a[key] = [].concat(_toConsumableArray(arrA), _toConsumableArray(arrB));
2496
- } else if (_functionalMerge.indexOf(key) > -1) {
2497
- for (var event in b[key]) {
2498
- if (a[key][event]) {
2499
- var _arrA = a[key][event] instanceof Array ? a[key][event] : [a[key][event]];
2500
-
2501
- var _arrB = b[key][event] instanceof Array ? b[key][event] : [b[key][event]];
2502
-
2503
- a[key][event] = [].concat(_toConsumableArray(_arrA), _toConsumableArray(_arrB));
2504
- } else {
2505
- a[key][event] = b[key][event];
2506
- }
2507
- }
2508
- } else if (key === 'hook') {
2509
- for (var hook in b[key]) {
2510
- if (a[key][hook]) {
2511
- a[key][hook] = mergeFn(a[key][hook], b[key][hook]);
2512
- } else {
2513
- a[key][hook] = b[key][hook];
2514
- }
2515
- }
2516
- } else {
2517
- a[key] = b[key];
2518
- }
2519
- } else {
2520
- if (_normalMerge.indexOf(key) > -1 || _functionalMerge.indexOf(key) > -1 || propsMerge.indexOf(key) > -1) {
2521
- a[key] = _objectSpread2({}, b[key]);
2522
- } else if (_toArrayMerge.indexOf(key) > -1) {
2523
- a[key] = b[key] instanceof Array ? _toConsumableArray(b[key]) : _typeof(b[key]) === 'object' ? _objectSpread2({}, b[key]) : b[key];
2524
- } else a[key] = b[key];
2525
- }
2526
- }
2527
-
2528
- return a;
2529
- }, initial);
2530
- };
2531
-
2532
- var mergeFn = function mergeFn(fn1, fn2) {
2533
- return function () {
2534
- fn1 && fn1.apply(this, arguments);
2535
- fn2 && fn2.apply(this, arguments);
2536
- };
2537
- };
2538
-
2539
- var keyAttrs = ['type', 'slot', 'ignore', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate', 'computed', 'preview', 'component', 'cache', 'modelEmit'];
2540
- var arrayAttrs = ['validate', 'children', 'control'];
2541
- var normalAttrs = ['effect', 'deep', 'renderSlots'];
2542
- function attrs() {
2543
- return [].concat(keyAttrs, _toConsumableArray(normalMerge), _toConsumableArray(toArrayMerge), _toConsumableArray(functionalMerge), arrayAttrs, normalAttrs);
2544
- }
2545
-
2546
- function format(type, msg, rule) {
2547
- return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
2548
- }
2549
- function err(msg, rule) {
2550
- console.error(format('err', msg, rule));
2551
- }
2552
- function logError(e) {
2553
- err(e.toString());
2554
- console.error(e);
2555
- }
2556
-
2557
- function toCase(str) {
2558
- var to = str.replace(/(-[a-z])/g, function (v) {
2559
- return v.replace('-', '').toLocaleUpperCase();
2560
- });
2561
- return lower(to);
2562
- }
2563
- function lower(str) {
2564
- return str.replace(str[0], str[0].toLowerCase());
2565
- }
2566
-
2567
- var PREFIX = '[[FORM-CREATE-PREFIX-';
2568
- var SUFFIX = '-FORM-CREATE-SUFFIX]]';
2569
- function toJson(obj, space) {
2570
- return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
2571
- if (val && val._isVue === true) return undefined;
2572
-
2573
- if (typeof val !== 'function') {
2574
- return val;
2575
- }
2576
-
2577
- if (val.__json) {
2578
- return val.__json;
2579
- }
2580
-
2581
- if (val.__origin) val = val.__origin;
2582
- if (val.__emit) return undefined;
2583
- return PREFIX + val + SUFFIX;
2584
- }, space);
2585
- }
2279
+ if (val.__origin) val = val.__origin;
2280
+ if (val.__emit) return undefined;
2281
+ return PREFIX + val + SUFFIX;
2282
+ }, space);
2283
+ }
2586
2284
 
2587
2285
  function makeFn(fn) {
2588
2286
  return new Function('return ' + fn)();
@@ -2754,170 +2452,468 @@
2754
2452
  children.push(fn);
2755
2453
  }
2756
2454
  });
2757
- return children;
2758
- },
2759
- getSlots: function getSlots() {
2760
- var _this = this;
2455
+ return children;
2456
+ },
2457
+ getSlots: function getSlots() {
2458
+ var _this = this;
2459
+
2460
+ var slots = {};
2461
+ Object.keys(slotBag).forEach(function (k) {
2462
+ slots[k] = function () {
2463
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2464
+ args[_key] = arguments[_key];
2465
+ }
2466
+
2467
+ return _this.getSlot(k, args);
2468
+ };
2469
+ });
2470
+ return slots;
2471
+ },
2472
+ slotLen: function slotLen(slot) {
2473
+ slot = slotName(slot);
2474
+ return slotBag[slot] ? slotBag[slot].length : 0;
2475
+ },
2476
+ mergeBag: function mergeBag(bag) {
2477
+ var _this2 = this;
2478
+
2479
+ if (!bag) return this;
2480
+ var slots = is.Function(bag.getSlots) ? bag.getSlots() : bag;
2481
+
2482
+ if (Array.isArray(bag) || vue.isVNode(bag)) {
2483
+ this.setSlot(undefined, function () {
2484
+ return bag;
2485
+ });
2486
+ } else {
2487
+ Object.keys(slots).forEach(function (k) {
2488
+ _this2.setSlot(k, slots[k]);
2489
+ });
2490
+ }
2491
+
2492
+ return this;
2493
+ }
2494
+ };
2495
+ }
2496
+ function toProps(rule) {
2497
+ var prop = _objectSpread2({}, rule.props || {});
2498
+
2499
+ Object.keys(rule.on || {}).forEach(function (k) {
2500
+ if (k.indexOf('-') > 0) {
2501
+ k = toCase(k);
2502
+ }
2503
+
2504
+ var name = "on".concat(upper(k));
2505
+
2506
+ if (Array.isArray(prop[name])) {
2507
+ prop[name] = [].concat(_toConsumableArray(prop[name]), [rule.on[k]]);
2508
+ } else if (prop[name]) {
2509
+ prop[name] = [prop[name], rule.on[k]];
2510
+ } else {
2511
+ prop[name] = rule.on[k];
2512
+ }
2513
+ });
2514
+ prop.key = rule.key;
2515
+ prop.ref = rule.ref;
2516
+ prop["class"] = rule["class"];
2517
+ prop.id = rule.id;
2518
+ prop.style = rule.style;
2519
+ if (prop.slot) delete prop.slot;
2520
+ return prop;
2521
+ }
2522
+ function setPrototypeOf(o, proto) {
2523
+ Object.setPrototypeOf(o, proto);
2524
+ return o;
2525
+ }
2526
+
2527
+ var changeType = function changeType(a, b) {
2528
+ if (typeof a === 'string') {
2529
+ return String(b);
2530
+ } else if (typeof a === 'number') {
2531
+ return Number(b);
2532
+ }
2533
+
2534
+ return b;
2535
+ };
2536
+
2537
+ var condition = {
2538
+ '==': function _(a, b) {
2539
+ return JSON.stringify(a) === JSON.stringify(changeType(a, b));
2540
+ },
2541
+ '!=': function _(a, b) {
2542
+ return !condition['=='](a, b);
2543
+ },
2544
+ '>': function _(a, b) {
2545
+ return a > b;
2546
+ },
2547
+ '>=': function _(a, b) {
2548
+ return a >= b;
2549
+ },
2550
+ '<': function _(a, b) {
2551
+ return a < b;
2552
+ },
2553
+ '<=': function _(a, b) {
2554
+ return a <= b;
2555
+ },
2556
+ on: function on(a, b) {
2557
+ return a && a.indexOf && a.indexOf(changeType(a[0], b)) > -1;
2558
+ },
2559
+ notOn: function notOn(a, b) {
2560
+ return !condition.on(a, b);
2561
+ },
2562
+ "in": function _in(a, b) {
2563
+ return b && b.indexOf && b.indexOf(a) > -1;
2564
+ },
2565
+ notIn: function notIn(a, b) {
2566
+ return !condition["in"](a, b);
2567
+ },
2568
+ between: function between(a, b) {
2569
+ return a > b[0] && a < b[1];
2570
+ },
2571
+ notBetween: function notBetween(a, b) {
2572
+ return a < b[0] || a > b[1];
2573
+ },
2574
+ empty: function empty(a) {
2575
+ return is.empty(a);
2576
+ },
2577
+ notEmpty: function notEmpty(a) {
2578
+ return !is.empty(a);
2579
+ },
2580
+ pattern: function pattern(a, b) {
2581
+ return new RegExp(b, 'g').test(a);
2582
+ }
2583
+ };
2584
+ function deepGet(val, split) {
2585
+ (Array.isArray(split) ? split : (split || '').split('.')).forEach(function (k) {
2586
+ if (val != null) {
2587
+ val = val[k];
2588
+ }
2589
+ });
2590
+ return val;
2591
+ }
2592
+ function extractVar(str) {
2593
+ var regex = /{{\s*(.*?)\s*}}/g;
2594
+ var match;
2595
+ var matches = {};
2596
+
2597
+ while ((match = regex.exec(str)) !== null) {
2598
+ if (match[1]) {
2599
+ matches[match[1]] = true;
2600
+ }
2601
+ }
2602
+
2603
+ return Object.keys(matches);
2604
+ }
2605
+ function convertFieldToConditions(field) {
2606
+ var parts = field.split('.');
2607
+ var conditions = [];
2608
+ var currentCondition = '';
2609
+ parts.forEach(function (part, index) {
2610
+ if (index === 0) {
2611
+ currentCondition = part;
2612
+ } else {
2613
+ currentCondition += '.' + part;
2614
+ }
2615
+
2616
+ conditions.push(currentCondition);
2617
+ });
2618
+ return conditions.join(' && ');
2619
+ }
2620
+
2621
+ var _getGroupInject = function getGroupInject(vm, parent) {
2622
+ if (!vm || vm === parent) {
2623
+ return;
2624
+ }
2625
+
2626
+ if (vm.props.formCreateInject) {
2627
+ return vm.props.formCreateInject;
2628
+ }
2629
+
2630
+ if (vm.parent) {
2631
+ return _getGroupInject(vm.parent, parent);
2632
+ }
2633
+ };
2634
+
2635
+ function $FormCreate(FormCreate, components, directives) {
2636
+ return vue.defineComponent({
2637
+ name: 'FormCreate' + (FormCreate.isMobile ? 'Mobile' : ''),
2638
+ components: components,
2639
+ directives: directives,
2640
+ props: {
2641
+ rule: {
2642
+ type: Array,
2643
+ required: true,
2644
+ "default": function _default() {
2645
+ return [];
2646
+ }
2647
+ },
2648
+ option: {
2649
+ type: Object,
2650
+ "default": function _default() {
2651
+ return {};
2652
+ }
2653
+ },
2654
+ extendOption: Boolean,
2655
+ driver: [String, Object],
2656
+ modelValue: Object,
2657
+ disabled: {
2658
+ type: Boolean,
2659
+ "default": undefined
2660
+ },
2661
+ preview: {
2662
+ type: Boolean,
2663
+ "default": undefined
2664
+ },
2665
+ index: [String, Number],
2666
+ api: Object,
2667
+ locale: [String, Object],
2668
+ name: String,
2669
+ subForm: {
2670
+ type: Boolean,
2671
+ "default": true
2672
+ },
2673
+ inFor: Boolean
2674
+ },
2675
+ emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'reset', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update', 'validate-field-fail', 'validate-fail', 'created'],
2676
+ render: function render() {
2677
+ return this.fc.render();
2678
+ },
2679
+ setup: function setup(props) {
2680
+ var vm = vue.getCurrentInstance();
2681
+ vue.provide('parentFC', vm);
2682
+ var parent = vue.inject('parentFC', null);
2683
+ var top = parent;
2684
+
2685
+ if (parent) {
2686
+ while (top.setupState.parent) {
2687
+ top = top.setupState.parent;
2688
+ }
2689
+ } else {
2690
+ top = vm;
2691
+ }
2692
+
2693
+ var _toRefs = vue.toRefs(props),
2694
+ rule = _toRefs.rule,
2695
+ modelValue = _toRefs.modelValue,
2696
+ subForm = _toRefs.subForm,
2697
+ inFor = _toRefs.inFor;
2698
+
2699
+ var data = vue.reactive({
2700
+ ctxInject: {},
2701
+ destroyed: false,
2702
+ isShow: true,
2703
+ unique: 1,
2704
+ renderRule: _toConsumableArray(rule.value || []),
2705
+ updateValue: JSON.stringify(modelValue.value || {})
2706
+ });
2707
+ var fc = new FormCreate(vm);
2708
+ var fapi = fc.api();
2709
+ var isMore = inFor.value;
2710
+
2711
+ var addSubForm = function addSubForm() {
2712
+ if (parent) {
2713
+ var _inject = _getGroupInject(vm, parent);
2714
+
2715
+ if (_inject) {
2716
+ var sub;
2717
+
2718
+ if (isMore) {
2719
+ sub = toArray(_inject.getSubForm());
2720
+ sub.push(fapi);
2721
+ } else {
2722
+ sub = fapi;
2723
+ }
2724
+
2725
+ _inject.subForm(sub);
2726
+ }
2727
+ }
2728
+ };
2729
+
2730
+ var rmSubForm = function rmSubForm() {
2731
+ var inject = _getGroupInject(vm, parent);
2732
+
2733
+ if (inject) {
2734
+ if (isMore) {
2735
+ var sub = toArray(inject.getSubForm());
2736
+ var idx = sub.indexOf(fapi);
2737
+
2738
+ if (idx > -1) {
2739
+ sub.splice(idx, 1);
2740
+ }
2741
+ } else {
2742
+ inject.subForm();
2743
+ }
2744
+ }
2745
+ };
2746
+
2747
+ var styleEl = null;
2748
+ vue.onBeforeMount(function () {
2749
+ vue.watchEffect(function () {
2750
+ var content = '';
2751
+ var globalClass = props.option && props.option.globalClass || {};
2752
+ Object.keys(globalClass).forEach(function (k) {
2753
+ var subCss = '';
2754
+ globalClass[k].style && Object.keys(globalClass[k].style).forEach(function (key) {
2755
+ subCss += toLine(key) + ':' + globalClass[k].style[key] + ';';
2756
+ });
2757
+
2758
+ if (globalClass[k].content) {
2759
+ subCss += globalClass[k].content + ';';
2760
+ }
2761
+
2762
+ if (subCss) {
2763
+ content += ".".concat(k, "{").concat(subCss, "}");
2764
+ }
2765
+ });
2766
+
2767
+ if (props.option && props.option.style) {
2768
+ content += props.option.style;
2769
+ }
2770
+
2771
+ if (!styleEl) {
2772
+ styleEl = document.createElement('style');
2773
+ styleEl.type = 'text/css';
2774
+ document.head.appendChild(styleEl);
2775
+ }
2776
+
2777
+ styleEl.innerHTML = content || '';
2778
+ });
2779
+ });
2780
+ var emit$topForm = debounce(function () {
2781
+ fc.bus.$emit('$loadData.$topForm');
2782
+ }, 100);
2783
+ var emit$scopeForm = debounce(function () {
2784
+ fc.bus.$emit('$loadData.$scopeForm');
2785
+ }, 100);
2786
+ var emit$form = debounce(function () {
2787
+ fc.bus.$emit('$loadData.$form');
2788
+ }, 100);
2789
+
2790
+ var emit$change = function emit$change(field) {
2791
+ fc.bus.$emit('change-$form.' + field);
2792
+ };
2793
+
2794
+ vue.onMounted(function () {
2795
+ if (parent) {
2796
+ fapi.top.bus.$on('$loadData.$form', emit$topForm);
2797
+ fapi.top.bus.$on('change', emit$change);
2798
+ }
2799
+
2800
+ if (fapi !== fapi.scope) {
2801
+ fapi.scope.bus.$on('$loadData.$scopeForm', emit$scopeForm);
2802
+ }
2803
+
2804
+ fc.mounted();
2805
+ });
2806
+ vue.onBeforeUnmount(function () {
2807
+ if (parent) {
2808
+ fapi.top.bus.$off('$loadData.$form', emit$topForm);
2809
+ fapi.top.bus.$off('change', emit$change);
2810
+ }
2811
+
2812
+ if (fapi !== fapi.scope) {
2813
+ fapi.scope.bus.$off('$loadData.$scopeForm', emit$scopeForm);
2814
+ }
2815
+
2816
+ styleEl && document.head.removeChild(styleEl);
2817
+ rmSubForm();
2818
+ data.destroyed = true;
2819
+ fc.unmount();
2820
+ });
2821
+ vue.onUpdated(function () {
2822
+ fc.updated();
2823
+ });
2824
+ addSubForm();
2825
+ vue.watch(function () {
2826
+ return props.option;
2827
+ }, function () {
2828
+ fc.initOptions();
2829
+ fapi.refresh();
2830
+ }, {
2831
+ deep: true
2832
+ });
2833
+ vue.watch(function () {
2834
+ return _toConsumableArray(rule.value);
2835
+ }, function (n) {
2836
+ if (fc.$handle.isBreakWatch() || n.length === data.renderRule.length && n.every(function (v) {
2837
+ return data.renderRule.indexOf(v) > -1;
2838
+ })) return;
2839
+ fc.$handle.updateAppendData();
2840
+ fc.$handle.reloadRule(rule.value);
2841
+ vm.setupState.renderRule();
2842
+ });
2843
+ vue.watch(function () {
2844
+ return [props.disabled, props.preview];
2845
+ }, function () {
2846
+ fapi.refresh();
2847
+ });
2848
+ vue.watch(modelValue, function (n) {
2849
+ if (toJson(n || {}) === data.updateValue) return;
2850
+
2851
+ if (fapi.config.forceCoverValue) {
2852
+ fapi.coverValue(n || {});
2853
+ } else {
2854
+ fapi.setValue(n || {});
2855
+ }
2856
+ }, {
2857
+ deep: true,
2858
+ flush: 'post'
2859
+ });
2860
+ vue.watch(function () {
2861
+ return props.index;
2862
+ }, function () {
2863
+ fapi.coverValue({});
2864
+ fc.$handle.updateAppendData();
2865
+ vue.nextTick(function () {
2866
+ vue.nextTick(function () {
2867
+ fapi.clearValidateState();
2868
+ });
2869
+ });
2870
+ }, {
2871
+ flush: 'sync'
2872
+ });
2873
+ return _objectSpread2(_objectSpread2({
2874
+ fc: vue.markRaw(fc),
2875
+ parent: parent ? vue.markRaw(parent) : parent,
2876
+ top: vue.markRaw(top),
2877
+ fapi: vue.markRaw(fapi)
2878
+ }, vue.toRefs(data)), {}, {
2879
+ getGroupInject: function getGroupInject() {
2880
+ return _getGroupInject(vm, parent);
2881
+ },
2882
+ refresh: function refresh() {
2883
+ ++data.unique;
2884
+ },
2885
+ renderRule: function renderRule() {
2886
+ data.renderRule = _toConsumableArray(rule.value || []);
2887
+ },
2888
+ updateValue: function updateValue(value) {
2889
+ if (data.destroyed) return;
2890
+ var json = toJson(value);
2761
2891
 
2762
- var slots = {};
2763
- Object.keys(slotBag).forEach(function (k) {
2764
- slots[k] = function () {
2765
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2766
- args[_key] = arguments[_key];
2892
+ if (data.updateValue === json) {
2893
+ return;
2767
2894
  }
2768
2895
 
2769
- return _this.getSlot(k, args);
2770
- };
2896
+ data.updateValue = json;
2897
+ vm.emit('update:modelValue', value);
2898
+ vue.nextTick(function () {
2899
+ emit$form();
2900
+
2901
+ if (!parent) {
2902
+ emit$topForm();
2903
+ emit$scopeForm();
2904
+ } else if (!subForm.value) {
2905
+ emit$scopeForm();
2906
+ }
2907
+ });
2908
+ }
2771
2909
  });
2772
- return slots;
2773
- },
2774
- slotLen: function slotLen(slot) {
2775
- slot = slotName(slot);
2776
- return slotBag[slot] ? slotBag[slot].length : 0;
2777
2910
  },
2778
- mergeBag: function mergeBag(bag) {
2779
- var _this2 = this;
2780
-
2781
- if (!bag) return this;
2782
- var slots = is.Function(bag.getSlots) ? bag.getSlots() : bag;
2783
-
2784
- if (Array.isArray(bag) || vue.isVNode(bag)) {
2785
- this.setSlot(undefined, function () {
2786
- return bag;
2787
- });
2788
- } else {
2789
- Object.keys(slots).forEach(function (k) {
2790
- _this2.setSlot(k, slots[k]);
2791
- });
2792
- }
2793
-
2794
- return this;
2795
- }
2796
- };
2797
- }
2798
- function toProps(rule) {
2799
- var prop = _objectSpread2({}, rule.props || {});
2800
-
2801
- Object.keys(rule.on || {}).forEach(function (k) {
2802
- if (k.indexOf('-') > 0) {
2803
- k = toCase(k);
2804
- }
2805
-
2806
- var name = "on".concat(upper(k));
2807
-
2808
- if (Array.isArray(prop[name])) {
2809
- prop[name] = [].concat(_toConsumableArray(prop[name]), [rule.on[k]]);
2810
- } else if (prop[name]) {
2811
- prop[name] = [prop[name], rule.on[k]];
2812
- } else {
2813
- prop[name] = rule.on[k];
2814
- }
2815
- });
2816
- prop.key = rule.key;
2817
- prop.ref = rule.ref;
2818
- prop["class"] = rule["class"];
2819
- prop.id = rule.id;
2820
- prop.style = rule.style;
2821
- if (prop.slot) delete prop.slot;
2822
- return prop;
2823
- }
2824
- function setPrototypeOf(o, proto) {
2825
- Object.setPrototypeOf(o, proto);
2826
- return o;
2827
- }
2828
-
2829
- var changeType = function changeType(a, b) {
2830
- if (typeof a === 'string') {
2831
- return String(b);
2832
- } else if (typeof a === 'number') {
2833
- return Number(b);
2834
- }
2835
-
2836
- return b;
2837
- };
2838
-
2839
- var condition = {
2840
- '==': function _(a, b) {
2841
- return JSON.stringify(a) === JSON.stringify(changeType(a, b));
2842
- },
2843
- '!=': function _(a, b) {
2844
- return !condition['=='](a, b);
2845
- },
2846
- '>': function _(a, b) {
2847
- return a > b;
2848
- },
2849
- '>=': function _(a, b) {
2850
- return a >= b;
2851
- },
2852
- '<': function _(a, b) {
2853
- return a < b;
2854
- },
2855
- '<=': function _(a, b) {
2856
- return a <= b;
2857
- },
2858
- on: function on(a, b) {
2859
- return a && a.indexOf && a.indexOf(changeType(a[0], b)) > -1;
2860
- },
2861
- notOn: function notOn(a, b) {
2862
- return !condition.on(a, b);
2863
- },
2864
- "in": function _in(a, b) {
2865
- return b && b.indexOf && b.indexOf(a) > -1;
2866
- },
2867
- notIn: function notIn(a, b) {
2868
- return !condition["in"](a, b);
2869
- },
2870
- between: function between(a, b) {
2871
- return a > b[0] && a < b[1];
2872
- },
2873
- notBetween: function notBetween(a, b) {
2874
- return a < b[0] || a > b[1];
2875
- },
2876
- empty: function empty(a) {
2877
- return is.empty(a);
2878
- },
2879
- notEmpty: function notEmpty(a) {
2880
- return !is.empty(a);
2881
- },
2882
- pattern: function pattern(a, b) {
2883
- return new RegExp(b, 'g').test(a);
2884
- }
2885
- };
2886
- function deepGet(val, split) {
2887
- (Array.isArray(split) ? split : (split || '').split('.')).forEach(function (k) {
2888
- if (val != null) {
2889
- val = val[k];
2890
- }
2891
- });
2892
- return val;
2893
- }
2894
- function extractVar(str) {
2895
- var regex = /{{\s*(.*?)\s*}}/g;
2896
- var match;
2897
- var matches = {};
2898
-
2899
- while ((match = regex.exec(str)) !== null) {
2900
- if (match[1]) {
2901
- matches[match[1]] = true;
2902
- }
2903
- }
2904
-
2905
- return Object.keys(matches);
2906
- }
2907
- function convertFieldToConditions(field) {
2908
- var parts = field.split('.');
2909
- var conditions = [];
2910
- var currentCondition = '';
2911
- parts.forEach(function (part, index) {
2912
- if (index === 0) {
2913
- currentCondition = part;
2914
- } else {
2915
- currentCondition += '.' + part;
2911
+ created: function created() {
2912
+ var vm = vue.getCurrentInstance();
2913
+ vm.emit('update:api', vm.setupState.fapi);
2914
+ vm.setupState.fc.init();
2916
2915
  }
2917
-
2918
- conditions.push(currentCondition);
2919
2916
  });
2920
- return conditions.join(' && ');
2921
2917
  }
2922
2918
 
2923
2919
  function baseRule() {
@@ -3125,8 +3121,15 @@
3125
3121
  }
3126
3122
 
3127
3123
  function props(fields, key, val) {
3128
- tidyFields(fields).forEach(function (field) {
3129
- h.getCtxs(field).forEach(function (ctx) {
3124
+ if (is.Undef(fields)) {
3125
+ fields = Object.keys(_objectSpread2(_objectSpread2({}, h.fieldCtx), h.nameCtx));
3126
+ } else if (!Array.isArray(fields)) {
3127
+ fields = [fields];
3128
+ }
3129
+
3130
+ fields.forEach(function (field) {
3131
+ var ctxs = h.fieldCtx[field] || h.nameCtx[field];
3132
+ ctxs && ctxs.forEach(function (ctx) {
3130
3133
  $set(ctx.rule, key, val);
3131
3134
  h.$render.clearCache(ctx);
3132
3135
  });
@@ -3144,6 +3147,14 @@
3144
3147
  }
3145
3148
 
3146
3149
  var api = {
3150
+ get isScope() {
3151
+ return h.vm.props.subForm === false;
3152
+ },
3153
+
3154
+ get isPreview() {
3155
+ return h.preview;
3156
+ },
3157
+
3147
3158
  get config() {
3148
3159
  return h.options;
3149
3160
  },
@@ -5655,7 +5666,7 @@
5655
5666
  return JSON.stringify(this.getFormData(ctx), strFn) !== JSON.stringify(value, strFn);
5656
5667
  },
5657
5668
  isQuote: function isQuote(ctx, value) {
5658
- return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
5669
+ return (value instanceof Function || is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
5659
5670
  },
5660
5671
  refreshUpdate: function refreshUpdate(ctx, val, origin, field) {
5661
5672
  var _this5 = this;
@@ -6071,7 +6082,7 @@
6071
6082
  field = JSON.stringify(_this2.fc.getLoadData(one.variable) || '');
6072
6083
  } else if (one.field) {
6073
6084
  field = convertFieldToConditions(one.field || '');
6074
- } else {
6085
+ } else if (!one.mode) {
6075
6086
  return {
6076
6087
  v: true
6077
6088
  };
@@ -6142,6 +6153,8 @@
6142
6153
  return invoke(fn, undefined);
6143
6154
  },
6144
6155
  computeValue: function computeValue(str, ctx, group) {
6156
+ var _this3 = this;
6157
+
6145
6158
  var that = this;
6146
6159
  var formulas = Object.keys(this.fc.formulas).reduce(function (obj, k) {
6147
6160
  obj[k] = function () {
@@ -6161,34 +6174,36 @@
6161
6174
 
6162
6175
  return obj;
6163
6176
  }, {});
6164
- return new Function('$formulas', '$form', '$scope', '$group', '$rule', '$api', "with($form){with($scope){with(this){with($group){with($formulas){ return ".concat(str, " }}}}}")).call(this.api.form, formulas, this.api.top.form, this.api.top === this.api.scope ? {} : this.api.scope.form, group ? this.subRuleData[group.id] || {} : {}, ctx.rule, this.api);
6177
+ return invoke(function () {
6178
+ return new Function('$formulas', '$form', '$scope', '$group', '$rule', '$api', "with($form){with($scope){with(this){with($group){with($formulas){ return ".concat(str, " }}}}}")).call(_this3.api.form, formulas, _this3.api.top.form, _this3.api.top === _this3.api.scope ? {} : _this3.api.scope.form, group ? _this3.subRuleData[group.id] || {} : {}, ctx.rule, _this3.api);
6179
+ }, undefined);
6165
6180
  },
6166
6181
  updateChildren: function updateChildren(ctx, n, o) {
6167
- var _this3 = this;
6182
+ var _this4 = this;
6168
6183
 
6169
6184
  this.deferSyncValue(function () {
6170
6185
  o && o.forEach(function (child) {
6171
6186
  if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx) {
6172
- _this3.rmCtx(child.__fc__);
6187
+ _this4.rmCtx(child.__fc__);
6173
6188
  }
6174
6189
  });
6175
6190
 
6176
6191
  if (is.trueArray(n)) {
6177
- _this3.loadChildren(n, ctx);
6192
+ _this4.loadChildren(n, ctx);
6178
6193
 
6179
- _this3.bus.$emit('update', _this3.api);
6194
+ _this4.bus.$emit('update', _this4.api);
6180
6195
  }
6181
6196
  });
6182
6197
  },
6183
6198
  rmSub: function rmSub(sub) {
6184
- var _this4 = this;
6199
+ var _this5 = this;
6185
6200
 
6186
6201
  is.trueArray(sub) && sub.forEach(function (r) {
6187
- r && r.__fc__ && _this4.rmCtx(r.__fc__);
6202
+ r && r.__fc__ && _this5.rmCtx(r.__fc__);
6188
6203
  });
6189
6204
  },
6190
6205
  rmCtx: function rmCtx(ctx) {
6191
- var _this5 = this;
6206
+ var _this6 = this;
6192
6207
 
6193
6208
  if (ctx.deleted) return;
6194
6209
  var id = ctx.id,
@@ -6217,19 +6232,19 @@
6217
6232
  }
6218
6233
 
6219
6234
  this.deferSyncValue(function () {
6220
- if (!_this5.reloading) {
6235
+ if (!_this6.reloading) {
6221
6236
  if (ctx.parser.loadChildren !== false) {
6222
6237
  var children = ctx.getPending('children', ctx.rule.children);
6223
6238
 
6224
6239
  if (is.trueArray(children)) {
6225
6240
  children.forEach(function (h) {
6226
- return h.__fc__ && _this5.rmCtx(h.__fc__);
6241
+ return h.__fc__ && _this6.rmCtx(h.__fc__);
6227
6242
  });
6228
6243
  }
6229
6244
  }
6230
6245
 
6231
- if (ctx.root === _this5.rules) {
6232
- _this5.vm.setupState.renderRule();
6246
+ if (ctx.root === _this6.rules) {
6247
+ _this6.vm.setupState.renderRule();
6233
6248
  }
6234
6249
  }
6235
6250
  }, input);
@@ -6491,7 +6506,13 @@
6491
6506
  return fc.bus;
6492
6507
  },
6493
6508
  preview: function preview() {
6494
- return fc.vm.props.preview != null ? fc.vm.props.preview : fc.options.value.preview || false;
6509
+ if (fc.vm.props.preview != null) {
6510
+ return fc.vm.props.preview;
6511
+ } else if (fc.vm.setupState.parent && fc.vm.setupState.parent.props.preview != null) {
6512
+ return fc.vm.setupState.parent.props.preview;
6513
+ }
6514
+
6515
+ return fc.options.value.preview || false;
6495
6516
  }
6496
6517
  });
6497
6518
  extend(this, {
@@ -6596,7 +6617,7 @@
6596
6617
  }
6597
6618
  }).then(function () {
6598
6619
  return _this3.globalBeforeFetch(opt);
6599
- });
6620
+ })["catch"](function () {});
6600
6621
  }
6601
6622
  });
6602
6623
  useInject(Handler);
@@ -6798,57 +6819,61 @@
6798
6819
  var loadData = {
6799
6820
  name: 'loadData',
6800
6821
  _fn: [],
6801
- mounted: function mounted(inject, rule, api) {
6802
- this.deleted(inject);
6803
- var attrs = toArray(inject.getValue());
6804
- var unwatchs = [];
6805
- attrs.forEach(function (attr) {
6806
- if (attr && (attr.attr || attr.template)) {
6807
- var fn = function fn(get) {
6808
- var value;
6822
+ loaded: function loaded(inject, rule, api) {
6823
+ var _this = this;
6809
6824
 
6810
- if (attr.template) {
6811
- value = fc.$handle.loadStrVar(attr.template, get);
6812
- } else if (attr.handler && is.Function(attr.handler)) {
6813
- value = attr.handler(get, rule, api);
6814
- } else {
6815
- value = get(attr.attr, attr["default"]);
6816
- }
6825
+ this.deleted(inject);
6826
+ vue.nextTick(function () {
6827
+ var attrs = toArray(inject.getValue());
6828
+ var unwatchs = [];
6829
+ attrs.forEach(function (attr) {
6830
+ if (attr && (attr.attr || attr.template)) {
6831
+ var fn = function fn(get) {
6832
+ var value;
6833
+
6834
+ if (attr.template) {
6835
+ value = fc.$handle.loadStrVar(attr.template, get);
6836
+ } else if (attr.handler && is.Function(attr.handler)) {
6837
+ value = attr.handler(get, rule, api);
6838
+ } else {
6839
+ value = get(attr.attr, attr["default"]);
6840
+ }
6817
6841
 
6818
- if (attr.copy !== false) {
6819
- value = deepCopy(value);
6820
- }
6842
+ if (attr.copy !== false) {
6843
+ value = deepCopy(value);
6844
+ }
6821
6845
 
6822
- var _rule = attr.modify ? rule : inject.getProp();
6846
+ var _rule = attr.modify ? rule : inject.getProp();
6823
6847
 
6824
- if (attr.to === 'child') {
6825
- if (_rule.children) {
6826
- _rule.children[0] = value;
6848
+ if (attr.to === 'child') {
6849
+ if (_rule.children) {
6850
+ _rule.children[0] = value;
6851
+ } else {
6852
+ _rule.children = [value];
6853
+ }
6827
6854
  } else {
6828
- _rule.children = [value];
6855
+ deepSet(_rule, attr.to || 'options', value);
6829
6856
  }
6830
- } else {
6831
- deepSet(_rule, attr.to || 'options', value);
6832
- }
6833
6857
 
6834
- api.sync(rule);
6835
- };
6858
+ api.sync(rule);
6859
+ };
6836
6860
 
6837
- var callback = function callback(get) {
6838
- return fn(get);
6839
- };
6861
+ var callback = function callback(get) {
6862
+ return fn(get);
6863
+ };
6840
6864
 
6841
- var unwatch = fc.watchLoadData(callback);
6842
- fn = debounce(fn, attr.wait || 300);
6865
+ var unwatch = fc.watchLoadData(callback);
6866
+ fn = debounce(fn, attr.wait || 300);
6843
6867
 
6844
- if (attr.watch !== false) {
6845
- unwatchs.push(unwatch);
6846
- } else {
6847
- unwatch();
6868
+ if (attr.watch !== false) {
6869
+ unwatchs.push(unwatch);
6870
+ } else {
6871
+ unwatch();
6872
+ }
6848
6873
  }
6849
- }
6874
+ });
6875
+ _this._fn[inject.id] = unwatchs;
6850
6876
  });
6851
- this._fn[inject.id] = unwatchs;
6852
6877
  },
6853
6878
  deleted: function deleted(inject) {
6854
6879
  if (this._fn[inject.id]) {
@@ -6862,7 +6887,7 @@
6862
6887
  inject.clearProp();
6863
6888
  }
6864
6889
  };
6865
- loadData.watch = loadData.mounted;
6890
+ loadData.watch = loadData.loaded;
6866
6891
  return loadData;
6867
6892
  };
6868
6893
 
@@ -7075,7 +7100,6 @@
7075
7100
  }
7076
7101
 
7077
7102
  set(fn(body, rule, api));
7078
- api.sync(rule);
7079
7103
  },
7080
7104
  onError: function onError(e) {
7081
7105
  set(undefined);
@@ -7792,7 +7816,7 @@
7792
7816
  }
7793
7817
  });
7794
7818
  this.unwatch.push(unwatch);
7795
- return val;
7819
+ return deepGet(val, split);
7796
7820
  }
7797
7821
  }
7798
7822
  },
@@ -8787,7 +8811,9 @@
8787
8811
  return new Promise(function (resolve, reject) {
8788
8812
  var forms = api.children;
8789
8813
  var all = [h.$manager.validate()];
8790
- forms.forEach(function (v) {
8814
+ forms.filter(function (v) {
8815
+ return !v.isScope;
8816
+ }).forEach(function (v) {
8791
8817
  all.push(v.validate());
8792
8818
  });
8793
8819
  Promise.all(all).then(function () {
@@ -8808,7 +8834,9 @@
8808
8834
  if (!ctx) return;
8809
8835
  var sub = h.subForm[ctx.id];
8810
8836
  var all = [h.$manager.validateField(ctx.id)];
8811
- toArray(sub).forEach(function (v) {
8837
+ toArray(sub).filter(function (v) {
8838
+ return !v.isScope;
8839
+ }).forEach(function (v) {
8812
8840
  all.push(v.validate());
8813
8841
  });
8814
8842
  Promise.all(all).then(function () {
@@ -8911,7 +8939,8 @@
8911
8939
  },
8912
8940
  submit: function submit(successFn, failFn) {
8913
8941
  return new Promise(function (resolve, reject) {
8914
- api.validate().then(function () {
8942
+ var promise = h.options.validateOnSubmit === false ? Promise.resolve() : api.validate();
8943
+ promise.then(function () {
8915
8944
  var formData = api.formData();
8916
8945
  is.Function(successFn) && invoke(function () {
8917
8946
  return successFn(formData, api);
@@ -9027,7 +9056,7 @@
9027
9056
  function elmFormCreate() {
9028
9057
  return FormCreateFactory({
9029
9058
  ui: 'element-ui',
9030
- version: '3.2.20',
9059
+ version: '3.2.21',
9031
9060
  manager: manager,
9032
9061
  extendApi: extendApi,
9033
9062
  install: install,