@form-create/element-ui 2.5.26 → 2.5.28

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,6 +1,6 @@
1
1
  /*!
2
- * @form-create/element-ui v2.5.26
3
- * (c) 2018-2022 xaboy
2
+ * @form-create/element-ui v2.5.28
3
+ * (c) 2018-2023 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
6
6
  */
@@ -1620,7 +1620,7 @@
1620
1620
  if (index === 0) {
1621
1621
  return [this.max !== 0 && total >= this.max ? null : this.addIcon(key), this.min === 0 || total > this.min ? this.delIcon(index, key) : null];
1622
1622
  }
1623
- if (index >= this.min) {
1623
+ if (total > this.min) {
1624
1624
  return this.delIcon(index, key);
1625
1625
  }
1626
1626
  },
@@ -2187,6 +2187,7 @@
2187
2187
  on: {},
2188
2188
  options: [],
2189
2189
  children: [],
2190
+ effect: {},
2190
2191
  hidden: false,
2191
2192
  display: true,
2192
2193
  value: undefined
@@ -2545,7 +2546,7 @@
2545
2546
  $set(ctx.rule, '$' + attr, value);
2546
2547
  }
2547
2548
  if (!hasProperty(ctx.rule, 'effect')) {
2548
- ctx.rule.effect = {};
2549
+ $set(ctx.rule, 'effect', {});
2549
2550
  }
2550
2551
  $set(ctx.rule.effect, attr, value);
2551
2552
  }
@@ -2662,6 +2663,9 @@
2662
2663
  this.clearCacheAll();
2663
2664
  },
2664
2665
  clearCache: function clearCache(ctx) {
2666
+ if (ctx.rule.cache) {
2667
+ return;
2668
+ }
2665
2669
  if (!this.cache[ctx.id]) {
2666
2670
  ctx.parent && this.clearCache(ctx.parent);
2667
2671
  return;
@@ -2717,7 +2721,7 @@
2717
2721
 
2718
2722
  var id = 0;
2719
2723
  function uniqueId() {
2720
- return Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now()).concat(++id)).toString(36);
2724
+ return 'F' + Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now()).concat(++id)).toString(36);
2721
2725
  }
2722
2726
 
2723
2727
  function deepSet(data, idx, val) {
@@ -3414,7 +3418,7 @@
3414
3418
  var _this = this;
3415
3419
  var rule = _objectSpread2({}, this.rule);
3416
3420
  delete rule.children;
3417
- this.prop = mergeProps([rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3421
+ this.prop = mergeRule({}, [rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3418
3422
  return _this.payload[k];
3419
3423
  })), [this.computed]));
3420
3424
  },
@@ -3506,6 +3510,73 @@
3506
3510
  }
3507
3511
  });
3508
3512
 
3513
+ var condition = {
3514
+ '==': function _(b) {
3515
+ return function (a) {
3516
+ return a === b;
3517
+ };
3518
+ },
3519
+ '!=': function _(b) {
3520
+ return function (a) {
3521
+ return a !== b;
3522
+ };
3523
+ },
3524
+ '<>': function _(b) {
3525
+ return function (a) {
3526
+ return a !== b;
3527
+ };
3528
+ },
3529
+ '>': function _(b) {
3530
+ return function (a) {
3531
+ return a > b;
3532
+ };
3533
+ },
3534
+ '>=': function _(b) {
3535
+ return function (a) {
3536
+ return a >= b;
3537
+ };
3538
+ },
3539
+ '<': function _(b) {
3540
+ return function (a) {
3541
+ return a < b;
3542
+ };
3543
+ },
3544
+ '<=': function _(b) {
3545
+ return function (a) {
3546
+ return a <= b;
3547
+ };
3548
+ },
3549
+ 'in': function _in(b) {
3550
+ return function (a) {
3551
+ return b && b.indexOf && b.indexOf(a) > -1;
3552
+ };
3553
+ },
3554
+ 'on': function on(b) {
3555
+ return function (a) {
3556
+ return a && a.indexOf && a.indexOf(b) > -1;
3557
+ };
3558
+ },
3559
+ 'notIn': function notIn(b) {
3560
+ return function (a) {
3561
+ return !condition["in"](b)(a);
3562
+ };
3563
+ },
3564
+ 'notOn': function notOn(b) {
3565
+ return function (a) {
3566
+ return !condition.on(b)(a);
3567
+ };
3568
+ },
3569
+ 'between': function between(b) {
3570
+ return function (a) {
3571
+ return a > b[0] && a < b[1];
3572
+ };
3573
+ },
3574
+ 'notBetween': function notBetween(b) {
3575
+ return function (a) {
3576
+ return a < b[0] || a > b[1];
3577
+ };
3578
+ }
3579
+ };
3509
3580
  function useLoader(Handler) {
3510
3581
  extend(Handler.prototype, {
3511
3582
  nextRefresh: function nextRefresh(fn) {
@@ -3613,7 +3684,7 @@
3613
3684
  }
3614
3685
  };
3615
3686
  rules.map(function (_rule, index) {
3616
- if (parent && (is.String(_rule) || is.Undef(_rule))) return;
3687
+ if (parent && !is.Object(_rule)) return;
3617
3688
  if (!_this6.pageEnd && !parent && index >= _this6.first) return;
3618
3689
  if (_rule.__fc__ && _rule.__fc__.root === rules && _this6.ctxs[_rule.__fc__.id]) {
3619
3690
  loadChildren(_rule.__fc__.rule.children, _rule.__fc__);
@@ -3709,9 +3780,7 @@
3709
3780
  if (!controls.length) return false;
3710
3781
  var _loop = function _loop(i) {
3711
3782
  var control = controls[i],
3712
- handleFn = control.handle || function (val) {
3713
- return val === control.value;
3714
- };
3783
+ handleFn = control.handle || (condition[control.condition || '=='] || condition['=='])(control.value);
3715
3784
  if (!is.trueArray(control.rule)) return "continue";
3716
3785
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
3717
3786
  valid: invoke(function () {
@@ -3738,7 +3807,8 @@
3738
3807
  prepend = _ref.prepend,
3739
3808
  append = _ref.append,
3740
3809
  child = _ref.child,
3741
- ctrl = _ref.ctrl;
3810
+ ctrl = _ref.ctrl,
3811
+ method = _ref.method;
3742
3812
  if (isHidden) {
3743
3813
  valid ? ctx.ctrlRule.push({
3744
3814
  __ctrl: true,
@@ -3746,7 +3816,20 @@
3746
3816
  valid: valid
3747
3817
  }) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3748
3818
  hideLst[valid ? 'push' : 'unshift'](function () {
3749
- _this7.api.hidden(!valid, rule);
3819
+ if (method === 'disabled') {
3820
+ _this7.api.disabled(!valid, rule);
3821
+ } else if (method === 'display') {
3822
+ _this7.api.display(valid, rule);
3823
+ } else if (method === 'required') {
3824
+ rule.forEach(function (item) {
3825
+ _this7.api.setEffect(item, 'required', valid);
3826
+ });
3827
+ if (!valid) {
3828
+ _this7.api.clearValidateState(rule);
3829
+ }
3830
+ } else {
3831
+ _this7.api.hidden(!valid, rule);
3832
+ }
3750
3833
  });
3751
3834
  return;
3752
3835
  }
@@ -4123,7 +4206,7 @@
4123
4206
  var _flag = is.trueArray(n);
4124
4207
  _this.deferSyncValue(function () {
4125
4208
  if (n !== o) {
4126
- _this.rmSub(o);
4209
+ _this.rmSub(o, ctx);
4127
4210
  _this.$render.initOrgChildren();
4128
4211
  }
4129
4212
  _flag && _this.loadChildren(n, ctx);
@@ -4131,6 +4214,7 @@
4131
4214
  });
4132
4215
  }
4133
4216
  _this.$render.clearCache(ctx);
4217
+ _this.refresh();
4134
4218
  _this.watching = false;
4135
4219
  }, {
4136
4220
  deep: !flag,
@@ -4139,10 +4223,10 @@
4139
4223
  });
4140
4224
  this.watchEffect(ctx);
4141
4225
  },
4142
- rmSub: function rmSub(sub) {
4226
+ rmSub: function rmSub(sub, ctx) {
4143
4227
  var _this2 = this;
4144
4228
  is.trueArray(sub) && sub.forEach(function (r) {
4145
- r && r.__fc__ && _this2.rmCtx(r.__fc__);
4229
+ r && r.__fc__ && r.__fc__.parent === ctx && _this2.rmCtx(r.__fc__);
4146
4230
  });
4147
4231
  },
4148
4232
  rmCtx: function rmCtx(ctx) {
@@ -4254,7 +4338,12 @@
4254
4338
  watchEffect: function watchEffect(ctx) {
4255
4339
  var _this3 = this;
4256
4340
  var vm = this.vm;
4257
- var effect = {};
4341
+ var effect = {
4342
+ required: function required() {
4343
+ var _ctx$rule, _ctx$rule$effect;
4344
+ return (hasProperty(ctx.rule, '$required') ? ctx.rule['$required'] : (_ctx$rule = ctx.rule) === null || _ctx$rule === void 0 ? void 0 : (_ctx$rule$effect = _ctx$rule.effect) === null || _ctx$rule$effect === void 0 ? void 0 : _ctx$rule$effect.required) || false;
4345
+ }
4346
+ };
4258
4347
  Object.keys(ctx.rule.effect || {}).forEach(function (k) {
4259
4348
  effect[k] = function () {
4260
4349
  return ctx.rule.effect[k];
@@ -4337,7 +4426,7 @@
4337
4426
  return ctx.clearEffectData(attr);
4338
4427
  };
4339
4428
  data.mergeProp = function (prop) {
4340
- return mergeProps([prop], data.getProp());
4429
+ return mergeRule(data.getProp(), [prop]);
4341
4430
  };
4342
4431
  }
4343
4432
  _this4.bus.$emit("p:".concat(attr, ":").concat(_type, ":").concat(p.input ? 1 : 0), event, [data, rule, _this4.api]);
@@ -4720,6 +4809,10 @@
4720
4809
  return {
4721
4810
  message: val
4722
4811
  };
4812
+ } else if (is.Undef(val)) {
4813
+ return {
4814
+ required: false
4815
+ };
4723
4816
  } else if (is.Function(val)) {
4724
4817
  return {
4725
4818
  validator: val
@@ -5840,7 +5933,7 @@
5840
5933
  function elmFormCreate() {
5841
5934
  return FormCreateFactory({
5842
5935
  ui: "".concat("element-ui"),
5843
- version: "".concat("2.5.26"),
5936
+ version: "".concat("2.5.28"),
5844
5937
  manager: manager,
5845
5938
  extendApi: extendApi,
5846
5939
  install: install,