@form-create/element-ui 3.1.20 → 3.1.22

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.1.20
2
+ * @form-create/element-ui v3.1.22
3
3
  * (c) 2018-2023 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -1961,9 +1961,11 @@ var getRuleInject = function getRuleInject(vm, parent) {
1961
1961
  }
1962
1962
  };
1963
1963
 
1964
- function $FormCreate(FormCreate) {
1964
+ function $FormCreate(FormCreate, components, directives) {
1965
1965
  return defineComponent({
1966
1966
  name: NAME$1,
1967
+ components: components,
1968
+ directives: directives,
1967
1969
  props: {
1968
1970
  rule: {
1969
1971
  type: Array,
@@ -1988,7 +1990,7 @@ function $FormCreate(FormCreate) {
1988
1990
  },
1989
1991
  inFor: Boolean
1990
1992
  },
1991
- emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update'],
1993
+ emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update', 'validate-field-fail', 'validate-fail'],
1992
1994
  render: function render() {
1993
1995
  return this.fc.render();
1994
1996
  },
@@ -2957,7 +2959,6 @@ function useCache(Render) {
2957
2959
  }
2958
2960
 
2959
2961
  if (!this.cache[ctx.id]) {
2960
- ctx.parent && this.clearCache(ctx.parent);
2961
2962
  return;
2962
2963
  }
2963
2964
 
@@ -2965,9 +2966,7 @@ function useCache(Render) {
2965
2966
  this.$handle.refresh();
2966
2967
  }
2967
2968
 
2968
- var parent = this.cache[ctx.id].parent;
2969
2969
  this.cache[ctx.id] = null;
2970
- parent && this.clearCache(parent);
2971
2970
  },
2972
2971
  clearCacheAll: function clearCacheAll() {
2973
2972
  this.cache = {};
@@ -3035,12 +3034,18 @@ function useRender$1(Render) {
3035
3034
  initRender: function initRender() {
3036
3035
  this.cacheConfig = {};
3037
3036
  },
3038
- getTypeSlot: function getTypeSlot(type) {
3039
- var name = 'type-' + toLine(type);
3040
-
3037
+ getTypeSlot: function getTypeSlot(ctx) {
3041
3038
  var _fn = function _fn(vm) {
3042
3039
  if (vm) {
3043
- var slot = vm.slots[name] || vm.slots['type-' + type];
3040
+ var slot = undefined;
3041
+
3042
+ if (ctx.rule.field) {
3043
+ slot = vm.slots['field-' + toLine(ctx.rule.field)] || vm.slots['field-' + ctx.rule.field];
3044
+ }
3045
+
3046
+ if (!slot) {
3047
+ slot = vm.slots['type-' + toLine(ctx.type)] || vm.slots['type-' + ctx.type];
3048
+ }
3044
3049
 
3045
3050
  if (slot) {
3046
3051
  return slot;
@@ -3118,12 +3123,16 @@ function useRender$1(Render) {
3118
3123
  deepSet(ctx.prop, str, deep[str]);
3119
3124
  });
3120
3125
  },
3121
- parseSide: function parseSide(side) {
3122
- return is.Object(side) ? mergeRule({}, side) : side;
3126
+ parseSide: function parseSide(side, ctx) {
3127
+ return is.Object(side) ? mergeRule({
3128
+ props: {
3129
+ formCreateInject: ctx.prop.props.formCreateInject
3130
+ }
3131
+ }, side) : side;
3123
3132
  },
3124
3133
  renderSides: function renderSides(vn, ctx, temp) {
3125
3134
  var prop = ctx[temp ? 'rule' : 'prop'];
3126
- return [this.renderRule(this.parseSide(prop.prefix)), vn, this.renderRule(this.parseSide(prop.suffix))];
3135
+ return [this.renderRule(this.parseSide(prop.prefix, ctx)), vn, this.renderRule(this.parseSide(prop.suffix, ctx))];
3127
3136
  },
3128
3137
  renderId: function renderId(name, type) {
3129
3138
  var _this3 = this;
@@ -3190,7 +3199,7 @@ function useRender$1(Render) {
3190
3199
  children = _this4.renderChildren(_load, ctx);
3191
3200
  }
3192
3201
 
3193
- var slot = _this4.getTypeSlot(ctx.type);
3202
+ var slot = _this4.getTypeSlot(ctx);
3194
3203
 
3195
3204
  var _vn;
3196
3205
 
@@ -3225,6 +3234,8 @@ function useRender$1(Render) {
3225
3234
 
3226
3235
  if (cache) {
3227
3236
  return cache.apply(void 0, arguments);
3237
+ } else if (_this4.cache[ctx.id]) {
3238
+ return;
3228
3239
  }
3229
3240
 
3230
3241
  var _vn = _this4.renderCtx(ctx, ctx.parent);
@@ -4235,7 +4246,7 @@ function useLoader(Handler) {
4235
4246
 
4236
4247
  if (is.Function(r.update)) {
4237
4248
  _this6.bus.$once('load-end', function () {
4238
- _this6.refreshUpdate(ctx, r.value);
4249
+ _this6.refreshUpdate(ctx, r.value, 'init');
4239
4250
  });
4240
4251
  }
4241
4252
 
@@ -4508,12 +4519,14 @@ function useInput(Handler) {
4508
4519
  isQuote: function isQuote(ctx, value) {
4509
4520
  return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
4510
4521
  },
4511
- refreshUpdate: function refreshUpdate(ctx, val) {
4522
+ refreshUpdate: function refreshUpdate(ctx, val, origin) {
4512
4523
  var _this2 = this;
4513
4524
 
4514
4525
  if (is.Function(ctx.rule.update)) {
4515
4526
  var state = invoke(function () {
4516
- return ctx.rule.update(val, ctx.origin, _this2.api);
4527
+ return ctx.rule.update(val, ctx.origin, _this2.api, {
4528
+ origin: origin || 'change'
4529
+ });
4517
4530
  });
4518
4531
  if (state === undefined) return;
4519
4532
  ctx.rule.hidden = state === true;
@@ -4523,7 +4536,7 @@ function useInput(Handler) {
4523
4536
  this.refreshRule(ctx, val);
4524
4537
  this.bus.$emit('change-' + ctx.field, val);
4525
4538
  },
4526
- refreshRule: function refreshRule(ctx, val) {
4539
+ refreshRule: function refreshRule(ctx, val, origin) {
4527
4540
  if (this.refreshControl(ctx)) {
4528
4541
  this.$render.clearCacheAll();
4529
4542
  this.loadRule();
@@ -4531,7 +4544,7 @@ function useInput(Handler) {
4531
4544
  this.refresh();
4532
4545
  }
4533
4546
 
4534
- this.refreshUpdate(ctx, val);
4547
+ this.refreshUpdate(ctx, val, origin);
4535
4548
  },
4536
4549
  appendLink: function appendLink(ctx) {
4537
4550
  var _this3 = this;
@@ -4539,7 +4552,7 @@ function useInput(Handler) {
4539
4552
  var link = ctx.rule.link;
4540
4553
  is.trueArray(link) && link.forEach(function (field) {
4541
4554
  var fn = function fn() {
4542
- return _this3.refreshRule(ctx, ctx.rule.value);
4555
+ return _this3.refreshRule(ctx, ctx.rule.value, 'link');
4543
4556
  };
4544
4557
 
4545
4558
  _this3.bus.$on('change-' + field, fn);
@@ -5358,6 +5371,39 @@ extend(Manager.prototype, {
5358
5371
  render: function render(children) {}
5359
5372
  });
5360
5373
 
5374
+ var componentValidate = {
5375
+ name: 'componentValidate',
5376
+ load: function load(attr, rule, api) {
5377
+ var method = attr.getValue();
5378
+
5379
+ if (!method) {
5380
+ attr.clearProp();
5381
+ api.clearValidateState([rule.field]);
5382
+ } else {
5383
+ attr.getProp().validate = [{
5384
+ validator: function validator() {
5385
+ var ctx = byCtx(rule);
5386
+
5387
+ if (ctx) {
5388
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5389
+ args[_key] = arguments[_key];
5390
+ }
5391
+
5392
+ return api.exec.apply(api, [ctx.id, method === true ? 'formCreateValidate' : method].concat(args, [{
5393
+ attr: attr,
5394
+ rule: rule,
5395
+ api: api
5396
+ }]));
5397
+ }
5398
+ }
5399
+ }];
5400
+ }
5401
+ },
5402
+ watch: function watch() {
5403
+ componentValidate.load.apply(componentValidate, arguments);
5404
+ }
5405
+ };
5406
+
5361
5407
  var fetch = function fetch(fc) {
5362
5408
  function parseOpt(option) {
5363
5409
  if (is.String(option)) {
@@ -5454,7 +5500,8 @@ var fetch = function fetch(fc) {
5454
5500
  };
5455
5501
 
5456
5502
  var $provider = {
5457
- fetch: fetch
5503
+ fetch: fetch,
5504
+ componentValidate: componentValidate
5458
5505
  };
5459
5506
 
5460
5507
  var name$6 = 'html';
@@ -5585,7 +5632,7 @@ function FormCreateFactory(config) {
5585
5632
  }
5586
5633
 
5587
5634
  function $form() {
5588
- return $FormCreate(FormCreate);
5635
+ return $FormCreate(FormCreate, components, directives);
5589
5636
  }
5590
5637
 
5591
5638
  function createFormApp(rule, option) {
@@ -6485,7 +6532,7 @@ function useFrame(maker) {
6485
6532
  return maker;
6486
6533
  }
6487
6534
 
6488
- var css_248z = ".form-create .form-create .el-form-item{margin-bottom:22px}.form-create .form-create .el-form-item .el-form-item{margin-bottom:0}.form-create{width:100%}";
6535
+ var css_248z = ".form-create .form-create .el-form-item{margin-bottom:22px}.form-create{width:100%}";
6489
6536
  styleInject(css_248z);
6490
6537
 
6491
6538
  function tidyBtnProp(btn, def) {
@@ -6512,6 +6559,9 @@ function extendApi(api, h) {
6512
6559
  })["catch"](function (e) {
6513
6560
  reject(e);
6514
6561
  callback && callback(e);
6562
+ h.vm.emit('validate-fail', e, {
6563
+ api: api
6564
+ });
6515
6565
  });
6516
6566
  });
6517
6567
  },
@@ -6530,6 +6580,10 @@ function extendApi(api, h) {
6530
6580
  })["catch"](function (e) {
6531
6581
  reject(e);
6532
6582
  callback && callback(e);
6583
+ h.vm.emit('validate-field-fail', e, {
6584
+ field: field,
6585
+ api: api
6586
+ });
6533
6587
  });
6534
6588
  });
6535
6589
  },
@@ -6723,7 +6777,7 @@ function install(FormCreate) {
6723
6777
  function elmFormCreate() {
6724
6778
  return FormCreateFactory({
6725
6779
  ui: 'element-ui',
6726
- version: '3.1.20',
6780
+ version: '3.1.22',
6727
6781
  manager: manager,
6728
6782
  extendApi: extendApi,
6729
6783
  install: install,