@form-create/element-ui 3.1.31 → 3.1.33

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.31
2
+ * @form-create/element-ui v3.1.33
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -209,6 +209,10 @@
209
209
  }, []);
210
210
  }
211
211
 
212
+ function toArray(value) {
213
+ return Array.isArray(value) ? value : [null, undefined, ''].indexOf(value) > -1 ? [] : [value];
214
+ }
215
+
212
216
  var NAME$9 = 'fcCheckbox';
213
217
  var Checkbox = vue.defineComponent({
214
218
  name: NAME$9,
@@ -221,22 +225,72 @@
221
225
  return [];
222
226
  }
223
227
  },
224
- type: String
228
+ type: String,
229
+ input: Boolean,
230
+ inputValue: String
225
231
  },
226
232
  emits: ['update:modelValue', 'fc.el'],
227
233
  setup: function setup(props, _) {
228
234
  var options = vue.toRef(props.formCreateInject, 'options', []);
229
235
  var value = vue.toRef(props, 'modelValue');
236
+ var inputValue = vue.toRef(props, 'inputValue', '');
237
+ var customValue = vue.ref(inputValue.value);
238
+ var input = vue.toRef(props, 'input', false);
239
+
240
+ var updateCustomValue = function updateCustomValue(n) {
241
+ var _value = _toConsumableArray(toArray(value.value));
242
+
243
+ var idx = _value.indexOf(customValue.value);
244
+
245
+ customValue.value = n;
246
+
247
+ if (idx > -1) {
248
+ _value.splice(idx, 1);
249
+
250
+ _value.push(n);
251
+
252
+ onInput(_value);
253
+ }
254
+ };
255
+
256
+ vue.watch(inputValue, function (n) {
257
+ if (!input.value) {
258
+ customValue.value = n;
259
+ return undefined;
260
+ }
261
+
262
+ updateCustomValue(n);
263
+ });
230
264
 
231
265
  var _options = function _options() {
232
266
  return Array.isArray(options.value) ? options.value : [];
233
267
  };
234
268
 
269
+ var onInput = function onInput(n) {
270
+ _.emit('update:modelValue', n);
271
+ };
272
+
235
273
  return {
236
274
  options: _options,
237
275
  value: value,
238
- onInput: function onInput(n) {
239
- _.emit('update:modelValue', n);
276
+ onInput: onInput,
277
+ updateCustomValue: updateCustomValue,
278
+ makeInput: function makeInput(Type) {
279
+ if (!input.value) {
280
+ return undefined;
281
+ }
282
+
283
+ return vue.createVNode(Type, {
284
+ "value": customValue.value,
285
+ "label": customValue.value
286
+ }, {
287
+ "default": function _default() {
288
+ return [vue.createVNode(vue.resolveComponent("ElInput"), {
289
+ "modelValue": customValue.value,
290
+ "onUpdate:modelValue": updateCustomValue
291
+ }, null)];
292
+ }
293
+ });
240
294
  }
241
295
  };
242
296
  },
@@ -261,7 +315,7 @@
261
315
  delete props.value;
262
316
  delete props.label;
263
317
  return vue.createVNode(Type, vue.mergeProps(props, {
264
- "label": label,
318
+ "label": value,
265
319
  "value": value,
266
320
  "key": name + index + '-' + value
267
321
  }), {
@@ -269,7 +323,7 @@
269
323
  return [label || value || ''];
270
324
  }
271
325
  });
272
- }), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
326
+ }), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots), _this.makeInput(Type)];
273
327
  }
274
328
  }, getSlot(this.$slots, ['default'])));
275
329
  },
@@ -278,10 +332,6 @@
278
332
  }
279
333
  });
280
334
 
281
- function toArray(value) {
282
- return Array.isArray(value) ? value : [null, undefined, ''].indexOf(value) > -1 ? [] : [value];
283
- }
284
-
285
335
  // https://github.com/developit/mitt
286
336
  function Mitt(all) {
287
337
  all = all || new Map();
@@ -968,22 +1018,66 @@
968
1018
  type: [String, Number, Boolean],
969
1019
  "default": ''
970
1020
  },
971
- type: String
1021
+ type: String,
1022
+ input: Boolean,
1023
+ inputValue: String
972
1024
  },
973
1025
  emits: ['update:modelValue', 'fc.el'],
974
1026
  setup: function setup(props, _) {
975
1027
  var options = vue.toRef(props.formCreateInject, 'options', []);
976
1028
  var value = vue.toRef(props, 'modelValue');
1029
+ var inputValue = vue.toRef(props, 'inputValue', '');
1030
+ var customValue = vue.ref(inputValue.value);
1031
+ var input = vue.toRef(props, 'input', false);
977
1032
 
978
1033
  var _options = function _options() {
979
1034
  return Array.isArray(options.value) ? options.value : [];
980
1035
  };
981
1036
 
1037
+ vue.watch(inputValue, function (n) {
1038
+ if (!input.value) {
1039
+ customValue.value = n;
1040
+ return undefined;
1041
+ }
1042
+
1043
+ updateCustomValue(n);
1044
+ });
1045
+
1046
+ var onInput = function onInput(n) {
1047
+ _.emit('update:modelValue', n);
1048
+ };
1049
+
1050
+ var updateCustomValue = function updateCustomValue(n) {
1051
+ var o = customValue.value;
1052
+ customValue.value = n;
1053
+
1054
+ if (value.value === o) {
1055
+ onInput(n);
1056
+ }
1057
+ };
1058
+
982
1059
  return {
983
1060
  options: _options,
984
1061
  value: value,
985
- onInput: function onInput(n) {
986
- _.emit('update:modelValue', n);
1062
+ onInput: onInput,
1063
+ updateCustomValue: updateCustomValue,
1064
+ customValue: customValue,
1065
+ makeInput: function makeInput(Type) {
1066
+ if (!input.value) {
1067
+ return undefined;
1068
+ }
1069
+
1070
+ return vue.createVNode(Type, {
1071
+ "value": customValue.value,
1072
+ "label": customValue.value
1073
+ }, {
1074
+ "default": function _default() {
1075
+ return [vue.createVNode(vue.resolveComponent("ElInput"), {
1076
+ "modelValue": customValue.value,
1077
+ "onUpdate:modelValue": updateCustomValue
1078
+ }, null)];
1079
+ }
1080
+ });
987
1081
  }
988
1082
  };
989
1083
  },
@@ -1008,7 +1102,7 @@
1008
1102
  delete props.value;
1009
1103
  delete props.label;
1010
1104
  return vue.createVNode(Type, vue.mergeProps(props, {
1011
- "label": label,
1105
+ "label": value,
1012
1106
  "value": value,
1013
1107
  "key": name + index + '-' + value
1014
1108
  }), {
@@ -1016,7 +1110,7 @@
1016
1110
  return [label || value || ''];
1017
1111
  }
1018
1112
  });
1019
- }), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
1113
+ }), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots), _this.makeInput(Type)];
1020
1114
  }
1021
1115
  }, getSlot(this.$slots, ['default'])));
1022
1116
  },
@@ -2144,6 +2238,10 @@
2144
2238
  type: Boolean,
2145
2239
  "default": undefined
2146
2240
  },
2241
+ preview: {
2242
+ type: Boolean,
2243
+ "default": undefined
2244
+ },
2147
2245
  api: Object,
2148
2246
  name: String,
2149
2247
  subForm: {
@@ -2234,6 +2332,10 @@
2234
2332
  }
2235
2333
  });
2236
2334
 
2335
+ if (props.option && props.option.style) {
2336
+ content += props.option.style;
2337
+ }
2338
+
2237
2339
  if (content) {
2238
2340
  styleEl = document.createElement('style');
2239
2341
  styleEl.type = 'text/css';
@@ -2276,7 +2378,7 @@
2276
2378
  deep: true
2277
2379
  });
2278
2380
  vue.watch(function () {
2279
- return props.disabled;
2381
+ return [props.disabled, props.preview];
2280
2382
  }, function () {
2281
2383
  fapi.refresh();
2282
2384
  });
@@ -2555,6 +2657,64 @@
2555
2657
  return o;
2556
2658
  }
2557
2659
 
2660
+ var changeType = function changeType(a, b) {
2661
+ if (typeof a === 'string') {
2662
+ return String(b);
2663
+ } else if (typeof a === 'number') {
2664
+ return Number(b);
2665
+ }
2666
+
2667
+ return b;
2668
+ };
2669
+
2670
+ var condition = {
2671
+ '==': function _(a, b) {
2672
+ return JSON.stringify(a) === JSON.stringify(changeType(a, b));
2673
+ },
2674
+ '!=': function _(a, b) {
2675
+ return !condition['=='](a, b);
2676
+ },
2677
+ '>': function _(a, b) {
2678
+ return a > b;
2679
+ },
2680
+ '>=': function _(a, b) {
2681
+ return a >= b;
2682
+ },
2683
+ '<': function _(a, b) {
2684
+ return a < b;
2685
+ },
2686
+ '<=': function _(a, b) {
2687
+ return a <= b;
2688
+ },
2689
+ on: function on(a, b) {
2690
+ return a && a.indexOf && a.indexOf(changeType(a[0], b)) > -1;
2691
+ },
2692
+ notOn: function notOn(a, b) {
2693
+ return !condition.on(a, b);
2694
+ },
2695
+ "in": function _in(a, b) {
2696
+ return b && b.indexOf && b.indexOf(a) > -1;
2697
+ },
2698
+ notIn: function notIn(a, b) {
2699
+ return !condition["in"](a, b);
2700
+ },
2701
+ between: function between(a, b) {
2702
+ return a > b[0] && a < b[1];
2703
+ },
2704
+ notBetween: function notBetween(a, b) {
2705
+ return a < b[0] || a > b[1];
2706
+ },
2707
+ empty: function empty(a) {
2708
+ return is.empty(a);
2709
+ },
2710
+ notEmpty: function notEmpty(a) {
2711
+ return !is.empty(a);
2712
+ },
2713
+ pattern: function pattern(a, b) {
2714
+ return new RegExp(b, 'g').test(a);
2715
+ }
2716
+ };
2717
+
2558
2718
  function baseRule() {
2559
2719
  return {
2560
2720
  props: {},
@@ -2807,7 +2967,7 @@
2807
2967
  if (!ctx) return initial;
2808
2968
  initial[ctx.field] = copy(ctx.rule.value);
2809
2969
  return initial;
2810
- }, {});
2970
+ }, h.options.appendValue ? copy(h.appendData) : {});
2811
2971
  },
2812
2972
  getValue: function getValue(field) {
2813
2973
  var ctx = h.getFieldCtx(field);
@@ -3223,10 +3383,7 @@
3223
3383
 
3224
3384
  if (config.type === 'fetch') {
3225
3385
  api.fetch(config).then(function (res) {
3226
- resolve({
3227
- res: res,
3228
- config: config
3229
- });
3386
+ resolve(res);
3230
3387
  })["catch"](inject);
3231
3388
  } else {
3232
3389
  resolve(config.data);
@@ -3470,7 +3627,7 @@
3470
3627
  this.setOptions(ctx);
3471
3628
  this.ctxProp(ctx);
3472
3629
  var prop = ctx.prop;
3473
- prop.preview = !!(hasProperty(prop, 'preview') ? prop.preview : this.options.preview || false);
3630
+ prop.preview = !!(prop.preview != null ? prop.preview : this.vm.props.preview !== undefined ? this.vm.props.preview : this.options.preview || false);
3474
3631
  prop.props.formCreateInject = this.injectProp(ctx);
3475
3632
  var cacheFlag = prop.cache !== false;
3476
3633
  var preview = prop.preview;
@@ -4198,14 +4355,31 @@
4198
4355
  var _this4 = this;
4199
4356
 
4200
4357
  return toArray(this.prop.validate).map(function (item) {
4201
- return _objectSpread2(_objectSpread2({}, item), {}, {
4202
- inject: {
4203
- id: _this4.id,
4204
- field: _this4.field,
4205
- rule: _this4.rule,
4206
- api: _this4.$handle.api
4207
- }
4208
- });
4358
+ if (is.Function(item.validator)) {
4359
+ var temp = _objectSpread2({}, item);
4360
+
4361
+ var that = _this4;
4362
+
4363
+ temp.validator = function () {
4364
+ var _item$validator;
4365
+
4366
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4367
+ args[_key] = arguments[_key];
4368
+ }
4369
+
4370
+ return (_item$validator = item.validator).call.apply(_item$validator, [{
4371
+ that: this,
4372
+ id: that.id,
4373
+ field: that.field,
4374
+ rule: that.rule,
4375
+ api: that.$handle.api
4376
+ }].concat(args));
4377
+ };
4378
+
4379
+ return temp;
4380
+ }
4381
+
4382
+ return item;
4209
4383
  });
4210
4384
  },
4211
4385
  check: function check(handle) {
@@ -4314,73 +4488,6 @@
4314
4488
  }
4315
4489
  });
4316
4490
 
4317
- var condition = {
4318
- '==': function _(b) {
4319
- return function (a) {
4320
- return a === b;
4321
- };
4322
- },
4323
- '!=': function _(b) {
4324
- return function (a) {
4325
- return a !== b;
4326
- };
4327
- },
4328
- '<>': function _(b) {
4329
- return function (a) {
4330
- return a !== b;
4331
- };
4332
- },
4333
- '>': function _(b) {
4334
- return function (a) {
4335
- return a > b;
4336
- };
4337
- },
4338
- '>=': function _(b) {
4339
- return function (a) {
4340
- return a >= b;
4341
- };
4342
- },
4343
- '<': function _(b) {
4344
- return function (a) {
4345
- return a < b;
4346
- };
4347
- },
4348
- '<=': function _(b) {
4349
- return function (a) {
4350
- return a <= b;
4351
- };
4352
- },
4353
- 'in': function _in(b) {
4354
- return function (a) {
4355
- return b && b.indexOf && b.indexOf(a) > -1;
4356
- };
4357
- },
4358
- 'on': function on(b) {
4359
- return function (a) {
4360
- return a && a.indexOf && a.indexOf(b) > -1;
4361
- };
4362
- },
4363
- 'notIn': function notIn(b) {
4364
- return function (a) {
4365
- return !condition["in"](b)(a);
4366
- };
4367
- },
4368
- 'notOn': function notOn(b) {
4369
- return function (a) {
4370
- return !condition.on(b)(a);
4371
- };
4372
- },
4373
- 'between': function between(b) {
4374
- return function (a) {
4375
- return a > b[0] && a < b[1];
4376
- };
4377
- },
4378
- 'notBetween': function notBetween(b) {
4379
- return function (a) {
4380
- return a < b[0] || a > b[1];
4381
- };
4382
- }
4383
- };
4384
4491
  function useLoader(Handler) {
4385
4492
  extend(Handler.prototype, {
4386
4493
  nextRefresh: function nextRefresh(fn) {
@@ -4570,7 +4677,7 @@
4570
4677
  if (!ctx) {
4571
4678
  var _rule2 = _this6.parseRule(_rule);
4572
4679
 
4573
- ctx = new RuleContext(_this6, _rule2, isInit ? defaultValue : _rule2.value);
4680
+ ctx = new RuleContext(_this6, _rule2, defaultValue);
4574
4681
 
4575
4682
  _this6.bindParser(ctx);
4576
4683
  } else {
@@ -4653,7 +4760,10 @@
4653
4760
 
4654
4761
  var _loop = function _loop(i) {
4655
4762
  var control = controls[i],
4656
- handleFn = control.handle || (condition[control.condition || '=='] || condition['=='])(control.value);
4763
+ handleFn = control.handle || function (val) {
4764
+ return (condition[control.condition || '=='] || condition['=='])(val, control.value);
4765
+ };
4766
+
4657
4767
  if (!is.trueArray(control.rule)) return "continue";
4658
4768
 
4659
4769
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
@@ -4921,7 +5031,7 @@
4921
5031
  return this.deferSyncFn.sync = true;
4922
5032
  }
4923
5033
 
4924
- this.vm.setupState.updateValue(_objectSpread2({}, this.form));
5034
+ this.vm.setupState.updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue ? this.appendData : {}), this.form));
4925
5035
  },
4926
5036
  isChange: function isChange(ctx, value) {
4927
5037
  return JSON.stringify(this.getFormData(ctx), strFn) !== JSON.stringify(value, strFn);
@@ -5175,15 +5285,56 @@
5175
5285
  if (!item) return undefined;
5176
5286
  var fn;
5177
5287
 
5178
- if (is.Function(item)) {
5288
+ if (_typeof(item) === 'object') {
5289
+ var group = ctx.getParentGroup();
5290
+
5291
+ var checkCondition = function checkCondition(item) {
5292
+ item = Array.isArray(item) ? {
5293
+ mode: 'AND',
5294
+ group: item
5295
+ } : item;
5296
+
5297
+ if (!is.trueArray(item.group)) {
5298
+ return true;
5299
+ }
5300
+
5301
+ var or = item.mode === 'OR';
5302
+ var valid = true;
5303
+
5304
+ for (var i = 0; i < item.group.length; i++) {
5305
+ var one = item.group[i];
5306
+ var flag = void 0;
5307
+
5308
+ if (one.mode) {
5309
+ flag = checkCondition(one);
5310
+ } else if (!condition[one.condition]) {
5311
+ flag = false;
5312
+ } else {
5313
+ flag = new Function('_$', '_$val', 'top', 'group', "with(top){with(this){with(group){ return _$['".concat(one.condition, "'](").concat(one.field, ", ").concat(one.compare ? one.compare : '_$val', "); }}}")).call(_this.api.form, condition, one.value, _this.api.top.form, group ? _this.subRuleData[group.id] || {} : {});
5314
+ }
5315
+
5316
+ if (or && flag) {
5317
+ return true;
5318
+ }
5319
+
5320
+ if (!or) {
5321
+ valid = valid && flag;
5322
+ }
5323
+ }
5324
+
5325
+ return or ? false : valid;
5326
+ };
5327
+
5328
+ return checkCondition(item);
5329
+ } else if (is.Function(item)) {
5179
5330
  fn = function fn() {
5180
5331
  return item(_this.api.form, _this.api);
5181
5332
  };
5182
5333
  } else {
5183
- var group = ctx.getParentGroup();
5334
+ var _group = ctx.getParentGroup();
5184
5335
 
5185
5336
  fn = function fn() {
5186
- return new Function('formulas', 'top', 'group', '$rule', '$api', "with(top){with(this){with(group){with(formulas){ return ".concat(item, " }}}}")).call(_this.api.form, _this.fc.formulas, _this.api.top.form, group ? _this.subRuleData[group.id] || {} : {}, ctx.rule, _this.api);
5337
+ return new Function('formulas', 'top', 'group', '$rule', '$api', "with(top){with(this){with(group){with(formulas){ return ".concat(item, " }}}}")).call(_this.api.form, _this.fc.formulas, _this.api.top.form, _group ? _this.subRuleData[_group.id] || {} : {}, ctx.rule, _this.api);
5187
5338
  };
5188
5339
  }
5189
5340
 
@@ -5874,6 +6025,8 @@
5874
6025
  return;
5875
6026
  }
5876
6027
 
6028
+ option = deepCopy(option);
6029
+
5877
6030
  if (!option.to) {
5878
6031
  option.to = 'options';
5879
6032
  }
@@ -6311,7 +6464,7 @@
6311
6464
  },
6312
6465
  mergeOptions: function mergeOptions(target, opt, parent) {
6313
6466
  opt = deepCopy(opt);
6314
- parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el', 'globalClass'].forEach(function (n) {
6467
+ parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el', 'globalClass', 'style'].forEach(function (n) {
6315
6468
  delete opt[n];
6316
6469
  });
6317
6470
 
@@ -7320,7 +7473,7 @@
7320
7473
  function elmFormCreate() {
7321
7474
  return FormCreateFactory({
7322
7475
  ui: 'element-ui',
7323
- version: '3.1.31',
7476
+ version: '3.1.33',
7324
7477
  manager: manager,
7325
7478
  extendApi: extendApi,
7326
7479
  install: install,