@form-create/element-ui 3.2.18 → 3.2.19

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.18
2
+ * @form-create/element-ui v3.2.19
3
3
  * (c) 2018-2025 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -1783,7 +1783,7 @@ var Group = defineComponent({
1783
1783
  return;
1784
1784
  }
1785
1785
 
1786
- this.cacheRule[key].$f && this.cacheRule[key].$f.setValue(value);
1786
+ this.cacheRule[key].$f && this.cacheRule[key].$f.coverValue(value);
1787
1787
  this.cache(key, value);
1788
1788
  },
1789
1789
  addRule: function addRule(i, emit) {
@@ -3017,10 +3017,12 @@ function fetch$1(option) {
3017
3017
  if (option.query) {
3018
3018
  var queryString = new URLSearchParams(option.query).toString();
3019
3019
 
3020
- if (action.includes('?')) {
3021
- action += "&".concat(queryString);
3022
- } else {
3023
- action += "?".concat(queryString);
3020
+ if (queryString) {
3021
+ if (action.includes('?')) {
3022
+ action += "&".concat(queryString);
3023
+ } else {
3024
+ action += "?".concat(queryString);
3025
+ }
3024
3026
  }
3025
3027
  }
3026
3028
 
@@ -3668,6 +3670,16 @@ function Api(h) {
3668
3670
  }
3669
3671
  });
3670
3672
  },
3673
+ renderRule: function renderRule(id, onInput, force) {
3674
+ var flag = _typeof(id) === 'object';
3675
+ var ctx = flag ? byCtx(id) : h.getCtx(id);
3676
+ return ctx ? h.$render.createRuleVnode(ctx, onInput, force) : undefined;
3677
+ },
3678
+ renderChildren: function renderChildren(id, onInput, force) {
3679
+ var flag = _typeof(id) === 'object';
3680
+ var ctx = flag ? byCtx(id) : h.getCtx(id);
3681
+ return ctx ? h.$render.createChildrenVnodes(ctx, onInput, force) : undefined;
3682
+ },
3671
3683
  nextTick: function nextTick(fn) {
3672
3684
  h.bus.$once('next-tick', fn);
3673
3685
  h.refresh();
@@ -3971,7 +3983,7 @@ function useRender$1(Render) {
3971
3983
  if (ctx.type === 'hidden') return;
3972
3984
  var rule = ctx.rule;
3973
3985
 
3974
- if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
3986
+ if (this.force || !this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
3975
3987
  var vn;
3976
3988
  ctx.initProp();
3977
3989
  this.mergeGlobal(ctx);
@@ -4023,6 +4035,18 @@ function useRender$1(Render) {
4023
4035
 
4024
4036
  Object.keys(prop.renderSlots || {}).forEach(function (key) {
4025
4037
  children[key] = function () {
4038
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
4039
+ args[_key2] = arguments[_key2];
4040
+ }
4041
+
4042
+ if (is.Function(prop.renderSlots[key])) {
4043
+ return invoke(function () {
4044
+ var _prop$renderSlots;
4045
+
4046
+ return (_prop$renderSlots = prop.renderSlots)[key].apply(_prop$renderSlots, args);
4047
+ });
4048
+ }
4049
+
4026
4050
  var rule = _this4.parseSide(prop.renderSlots[key], ctx);
4027
4051
 
4028
4052
  return _this4.renderRule(rule);
@@ -4201,6 +4225,8 @@ function useRender$1(Render) {
4201
4225
  }];
4202
4226
 
4203
4227
  if (ctx.input) {
4228
+ var tmpInput = this.tmpInput;
4229
+
4204
4230
  if (this.vm.props.disabled === true) {
4205
4231
  ctx.prop.props.disabled = true;
4206
4232
  }
@@ -4208,6 +4234,8 @@ function useRender$1(Render) {
4208
4234
  var field = this.getModelField(ctx);
4209
4235
  var model = {
4210
4236
  callback: function callback(value) {
4237
+ tmpInput && tmpInput(ctx.field, value, ctx.rule);
4238
+
4211
4239
  _this7.onInput(ctx, value);
4212
4240
  },
4213
4241
  modelField: field,
@@ -4280,6 +4308,23 @@ function useRender$1(Render) {
4280
4308
  if (this.vNode[ctx.originType]) return this.vNode[ctx.originType](prop, children);
4281
4309
  return this.vNode.make(lower(prop.type), prop, children);
4282
4310
  },
4311
+ createChildrenVnodes: function createChildrenVnodes(ctx, onInput, force) {
4312
+ this.force = force !== false;
4313
+ this.tmpInput = onInput;
4314
+ var res = this.renderChildren(ctx.rule.children, ctx);
4315
+ this.force = false;
4316
+ this.tmpInput = null;
4317
+ return res;
4318
+ },
4319
+ createRuleVnode: function createRuleVnode(ctx, onInput, force) {
4320
+ this.force = force !== false;
4321
+ this.tmpInput = onInput;
4322
+ var slotBag = makeSlotBag();
4323
+ this.renderSlot(slotBag, ctx, ctx.parent);
4324
+ this.force = false;
4325
+ this.tmpInput = null;
4326
+ return slotBag.getSlots();
4327
+ },
4283
4328
  renderRule: function renderRule(rule, children, origin) {
4284
4329
  var _this9 = this;
4285
4330
 
@@ -4327,6 +4372,8 @@ function Render(handle) {
4327
4372
  vm: handle.vm,
4328
4373
  $manager: handle.$manager,
4329
4374
  vNode: new handle.fc.CreateNode(handle.vm),
4375
+ force: false,
4376
+ tmpInput: null,
4330
4377
  id: id$1++
4331
4378
  });
4332
4379
  funcProxy(this, {
@@ -4473,7 +4520,7 @@ function useInject(Handler) {
4473
4520
  fn.__json = _fn.__json;
4474
4521
  return fn;
4475
4522
  },
4476
- loadStrVar: function loadStrVar(str, get) {
4523
+ loadStrVar: function loadStrVar(str, get, group) {
4477
4524
  var _this3 = this;
4478
4525
 
4479
4526
  if (str && typeof str === 'string' && str.indexOf('{{') > -1 && str.indexOf('}}') > -1) {
@@ -4486,7 +4533,29 @@ function useInject(Handler) {
4486
4533
 
4487
4534
  if (field) {
4488
4535
  var def = (split[1] || '').trim();
4489
- var val = get ? get(field, def) : _this3.fc.getLoadData(field, def);
4536
+ var val;
4537
+ var flag = false;
4538
+
4539
+ if (group && field.indexOf('$form.') === 0) {
4540
+ var _split = field.split('.');
4541
+
4542
+ _split.shift();
4543
+
4544
+ if (hasProperty(group.value, _split[0])) {
4545
+ flag = true;
4546
+ val = get ? get({
4547
+ id: '$form.' + _split[0] + '_' + group.rule.__fc__.id,
4548
+ getValue: function getValue() {
4549
+ return deepGet(group.value, _split);
4550
+ }
4551
+ }) : deepGet(group.value, _split);
4552
+ }
4553
+ }
4554
+
4555
+ if (!flag) {
4556
+ val = get ? get(field, def) : _this3.fc.getLoadData(field, def);
4557
+ }
4558
+
4490
4559
  lastVal = val;
4491
4560
  str = str.replaceAll("{{".concat(v, "}}"), val == null ? '' : val);
4492
4561
  }
@@ -4499,11 +4568,20 @@ function useInject(Handler) {
4499
4568
 
4500
4569
  return str;
4501
4570
  },
4502
- loadFetchVar: function loadFetchVar(options, get) {
4571
+ loadFetchVar: function loadFetchVar(options, get, rule) {
4503
4572
  var _this4 = this;
4504
4573
 
4574
+ var group;
4575
+
4576
+ if (rule && rule.__fc__) {
4577
+ group = rule.__fc__.getParentGroup();
4578
+ }
4579
+
4505
4580
  var loadVal = function loadVal(str) {
4506
- return _this4.loadStrVar(str, get);
4581
+ return _this4.loadStrVar(str, get, group ? {
4582
+ rule: rule,
4583
+ value: _this4.subRuleData[group.id] || {}
4584
+ } : null);
4507
4585
  };
4508
4586
 
4509
4587
  options.action = loadVal(options.action || '');
@@ -5974,7 +6052,9 @@ function useContext(Handler) {
5974
6052
  return one.handler(_this2.api, ctx.rule);
5975
6053
  });
5976
6054
  } else {
5977
- flag = new Function('$condition', '$val', '$form', '$group', '$rule', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(compare ? compare : '$val', "); }}}")).call(_this2.api.form, condition, one.value, _this2.api.top.form, group ? _this2.subRuleData[group.id] || {} : {}, ctx.rule);
6055
+ flag = invoke(function () {
6056
+ return new Function('$condition', '$val', '$form', '$group', '$rule', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(compare ? compare : '$val', "); }}}")).call(_this2.api.form, condition, one.value, _this2.api.top.form, group ? _this2.subRuleData[group.id] || {} : {}, ctx.rule);
6057
+ });
5978
6058
  }
5979
6059
 
5980
6060
  if (or && flag) {
@@ -6908,7 +6988,7 @@ var fetch = function fetch(fc) {
6908
6988
  return fetchAttr._fn[inject.id]();
6909
6989
  }
6910
6990
 
6911
- var _option = fc.$handle.loadFetchVar(deepCopy(option), get);
6991
+ var _option = fc.$handle.loadFetchVar(deepCopy(option), get, rule);
6912
6992
 
6913
6993
  var config = _objectSpread2(_objectSpread2({
6914
6994
  headers: {}
@@ -7149,10 +7229,12 @@ function FormCreateFactory(config) {
7149
7229
  var globalConfig = {
7150
7230
  global: {}
7151
7231
  };
7152
- var loadData = reactive({});
7232
+ var isMobile = config.isMobile === true;
7233
+ var loadData = reactive({
7234
+ $mobile: isMobile
7235
+ });
7153
7236
  var CreateNode = CreateNodeFactory();
7154
7237
  var formulas = {};
7155
- var isMobile = config.isMobile === true;
7156
7238
  var prototype = {};
7157
7239
  exportAttrs(config.attrs || {});
7158
7240
 
@@ -7410,7 +7492,6 @@ function FormCreateFactory(config) {
7410
7492
  },
7411
7493
  drivers: drivers,
7412
7494
  renderDriver: null,
7413
- get: null,
7414
7495
  refreshData: refreshData,
7415
7496
  loadData: loadData,
7416
7497
  CreateNode: CreateNode,
@@ -7635,11 +7716,18 @@ function FormCreateFactory(config) {
7635
7716
  var handle = is.Function(option) ? option : parseFn(option.handle);
7636
7717
 
7637
7718
  if (handle) {
7638
- return deepGet(invoke(function () {
7639
- return handle(_this5.get || function () {
7640
- return _this5.getLoadData.apply(_this5, arguments);
7641
- }, _this5.$handle.api);
7642
- }), split);
7719
+ var val;
7720
+ var unwatch = this.watchLoadData(function (get, flag) {
7721
+ if (flag) {
7722
+ _this5.bus.$emit('$loadData.$var.' + key);
7723
+
7724
+ unwatch();
7725
+ } else {
7726
+ val = handle(get, _this5.$handle.api);
7727
+ }
7728
+ });
7729
+ this.unwatch.push(unwatch);
7730
+ return val;
7643
7731
  }
7644
7732
  }
7645
7733
  },
@@ -7676,6 +7764,8 @@ function FormCreateFactory(config) {
7676
7764
  } else if (key === '$t') {
7677
7765
  val = this.globalLanguageDriver(split.join('.'));
7678
7766
  split = [];
7767
+ } else if (key === '$preview') {
7768
+ return this.$handle.preview;
7679
7769
  } else {
7680
7770
  var tmpData = this.vm.setupState.top.setupState.fc.tmpData;
7681
7771
 
@@ -7700,32 +7790,31 @@ function FormCreateFactory(config) {
7700
7790
  var unwatch = {};
7701
7791
 
7702
7792
  var run = function run(flag) {
7703
- if (!_this6.get) {
7704
- _this6.get = get;
7705
- }
7706
-
7707
7793
  invoke(function () {
7708
7794
  fn(get, flag);
7709
7795
  });
7710
-
7711
- if (_this6.get === get) {
7712
- _this6.get = undefined;
7713
- }
7714
7796
  };
7715
7797
 
7716
7798
  var get = function get(id, def) {
7799
+ var getValue;
7800
+
7801
+ if (_typeof(id) === 'object') {
7802
+ getValue = id.getValue;
7803
+ id = id.id;
7804
+ }
7805
+
7717
7806
  if (unwatch[id]) {
7718
7807
  return unwatch[id].val;
7719
7808
  }
7720
7809
 
7721
7810
  var data = computed(function () {
7722
- return _this6.getLoadData(id, def);
7811
+ return getValue ? getValue() : _this6.getLoadData(id, def);
7723
7812
  });
7724
7813
  var split = id.split('.');
7725
7814
  var key = split.shift();
7726
7815
  var key2 = split.shift() || '';
7727
7816
  var callback = debounce(function () {
7728
- var temp = _this6.getLoadData(id, def);
7817
+ var temp = getValue ? getValue() : _this6.getLoadData(id, def);
7729
7818
 
7730
7819
  if (!unwatch[id]) {
7731
7820
  return;
@@ -8859,7 +8948,7 @@ function install(FormCreate) {
8859
8948
  function elmFormCreate() {
8860
8949
  return FormCreateFactory({
8861
8950
  ui: 'element-ui',
8862
- version: '3.2.18',
8951
+ version: '3.2.19',
8863
8952
  manager: manager,
8864
8953
  extendApi: extendApi,
8865
8954
  install: install,