@form-create/iview 2.5.27 → 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/iview v2.5.27
3
- * (c) 2018-2022 xaboy
2
+ * @form-create/iview 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
  */
@@ -1615,7 +1615,7 @@
1615
1615
  if (index === 0) {
1616
1616
  return [this.max !== 0 && total >= this.max ? null : this.addIcon(key), this.min === 0 || total > this.min ? this.delIcon(index, key) : null];
1617
1617
  }
1618
- if (index >= this.min) {
1618
+ if (total > this.min) {
1619
1619
  return this.delIcon(index, key);
1620
1620
  }
1621
1621
  },
@@ -2194,6 +2194,7 @@
2194
2194
  on: {},
2195
2195
  options: [],
2196
2196
  children: [],
2197
+ effect: {},
2197
2198
  hidden: false,
2198
2199
  display: true,
2199
2200
  value: undefined
@@ -2552,7 +2553,7 @@
2552
2553
  $set(ctx.rule, '$' + attr, value);
2553
2554
  }
2554
2555
  if (!hasProperty(ctx.rule, 'effect')) {
2555
- ctx.rule.effect = {};
2556
+ $set(ctx.rule, 'effect', {});
2556
2557
  }
2557
2558
  $set(ctx.rule.effect, attr, value);
2558
2559
  }
@@ -2669,6 +2670,9 @@
2669
2670
  this.clearCacheAll();
2670
2671
  },
2671
2672
  clearCache: function clearCache(ctx) {
2673
+ if (ctx.rule.cache) {
2674
+ return;
2675
+ }
2672
2676
  if (!this.cache[ctx.id]) {
2673
2677
  ctx.parent && this.clearCache(ctx.parent);
2674
2678
  return;
@@ -3421,7 +3425,7 @@
3421
3425
  var _this = this;
3422
3426
  var rule = _objectSpread2({}, this.rule);
3423
3427
  delete rule.children;
3424
- this.prop = mergeProps([rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3428
+ this.prop = mergeRule({}, [rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3425
3429
  return _this.payload[k];
3426
3430
  })), [this.computed]));
3427
3431
  },
@@ -3513,6 +3517,73 @@
3513
3517
  }
3514
3518
  });
3515
3519
 
3520
+ var condition = {
3521
+ '==': function _(b) {
3522
+ return function (a) {
3523
+ return a === b;
3524
+ };
3525
+ },
3526
+ '!=': function _(b) {
3527
+ return function (a) {
3528
+ return a !== b;
3529
+ };
3530
+ },
3531
+ '<>': function _(b) {
3532
+ return function (a) {
3533
+ return a !== b;
3534
+ };
3535
+ },
3536
+ '>': function _(b) {
3537
+ return function (a) {
3538
+ return a > b;
3539
+ };
3540
+ },
3541
+ '>=': function _(b) {
3542
+ return function (a) {
3543
+ return a >= b;
3544
+ };
3545
+ },
3546
+ '<': function _(b) {
3547
+ return function (a) {
3548
+ return a < b;
3549
+ };
3550
+ },
3551
+ '<=': function _(b) {
3552
+ return function (a) {
3553
+ return a <= b;
3554
+ };
3555
+ },
3556
+ 'in': function _in(b) {
3557
+ return function (a) {
3558
+ return b && b.indexOf && b.indexOf(a) > -1;
3559
+ };
3560
+ },
3561
+ 'on': function on(b) {
3562
+ return function (a) {
3563
+ return a && a.indexOf && a.indexOf(b) > -1;
3564
+ };
3565
+ },
3566
+ 'notIn': function notIn(b) {
3567
+ return function (a) {
3568
+ return !condition["in"](b)(a);
3569
+ };
3570
+ },
3571
+ 'notOn': function notOn(b) {
3572
+ return function (a) {
3573
+ return !condition.on(b)(a);
3574
+ };
3575
+ },
3576
+ 'between': function between(b) {
3577
+ return function (a) {
3578
+ return a > b[0] && a < b[1];
3579
+ };
3580
+ },
3581
+ 'notBetween': function notBetween(b) {
3582
+ return function (a) {
3583
+ return a < b[0] || a > b[1];
3584
+ };
3585
+ }
3586
+ };
3516
3587
  function useLoader(Handler) {
3517
3588
  extend(Handler.prototype, {
3518
3589
  nextRefresh: function nextRefresh(fn) {
@@ -3620,7 +3691,7 @@
3620
3691
  }
3621
3692
  };
3622
3693
  rules.map(function (_rule, index) {
3623
- if (parent && (is.String(_rule) || is.Undef(_rule))) return;
3694
+ if (parent && !is.Object(_rule)) return;
3624
3695
  if (!_this6.pageEnd && !parent && index >= _this6.first) return;
3625
3696
  if (_rule.__fc__ && _rule.__fc__.root === rules && _this6.ctxs[_rule.__fc__.id]) {
3626
3697
  loadChildren(_rule.__fc__.rule.children, _rule.__fc__);
@@ -3716,9 +3787,7 @@
3716
3787
  if (!controls.length) return false;
3717
3788
  var _loop = function _loop(i) {
3718
3789
  var control = controls[i],
3719
- handleFn = control.handle || function (val) {
3720
- return val === control.value;
3721
- };
3790
+ handleFn = control.handle || (condition[control.condition || '=='] || condition['=='])(control.value);
3722
3791
  if (!is.trueArray(control.rule)) return "continue";
3723
3792
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
3724
3793
  valid: invoke(function () {
@@ -3745,7 +3814,8 @@
3745
3814
  prepend = _ref.prepend,
3746
3815
  append = _ref.append,
3747
3816
  child = _ref.child,
3748
- ctrl = _ref.ctrl;
3817
+ ctrl = _ref.ctrl,
3818
+ method = _ref.method;
3749
3819
  if (isHidden) {
3750
3820
  valid ? ctx.ctrlRule.push({
3751
3821
  __ctrl: true,
@@ -3753,7 +3823,20 @@
3753
3823
  valid: valid
3754
3824
  }) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3755
3825
  hideLst[valid ? 'push' : 'unshift'](function () {
3756
- _this7.api.hidden(!valid, rule);
3826
+ if (method === 'disabled') {
3827
+ _this7.api.disabled(!valid, rule);
3828
+ } else if (method === 'display') {
3829
+ _this7.api.display(valid, rule);
3830
+ } else if (method === 'required') {
3831
+ rule.forEach(function (item) {
3832
+ _this7.api.setEffect(item, 'required', valid);
3833
+ });
3834
+ if (!valid) {
3835
+ _this7.api.clearValidateState(rule);
3836
+ }
3837
+ } else {
3838
+ _this7.api.hidden(!valid, rule);
3839
+ }
3757
3840
  });
3758
3841
  return;
3759
3842
  }
@@ -4262,7 +4345,12 @@
4262
4345
  watchEffect: function watchEffect(ctx) {
4263
4346
  var _this3 = this;
4264
4347
  var vm = this.vm;
4265
- var effect = {};
4348
+ var effect = {
4349
+ required: function required() {
4350
+ var _ctx$rule, _ctx$rule$effect;
4351
+ 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;
4352
+ }
4353
+ };
4266
4354
  Object.keys(ctx.rule.effect || {}).forEach(function (k) {
4267
4355
  effect[k] = function () {
4268
4356
  return ctx.rule.effect[k];
@@ -4345,7 +4433,7 @@
4345
4433
  return ctx.clearEffectData(attr);
4346
4434
  };
4347
4435
  data.mergeProp = function (prop) {
4348
- return mergeProps([prop], data.getProp());
4436
+ return mergeRule(data.getProp(), [prop]);
4349
4437
  };
4350
4438
  }
4351
4439
  _this4.bus.$emit("p:".concat(attr, ":").concat(_type, ":").concat(p.input ? 1 : 0), event, [data, rule, _this4.api]);
@@ -4728,6 +4816,10 @@
4728
4816
  return {
4729
4817
  message: val
4730
4818
  };
4819
+ } else if (is.Undef(val)) {
4820
+ return {
4821
+ required: false
4822
+ };
4731
4823
  } else if (is.Function(val)) {
4732
4824
  return {
4733
4825
  validator: val
@@ -5887,7 +5979,7 @@
5887
5979
  function ivuFormCreate() {
5888
5980
  return FormCreateFactory({
5889
5981
  ui: "".concat("iview"),
5890
- version: "".concat("2.5.27"),
5982
+ version: "".concat("2.5.28"),
5891
5983
  manager: manager,
5892
5984
  install: install,
5893
5985
  extendApi: extendApi,