@form-create/element-ui 3.2.23 → 3.2.25

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.23
2
+ * @form-create/element-ui v3.2.25
3
3
  * (c) 2018-2025 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -2652,6 +2652,68 @@
2652
2652
  });
2653
2653
  return conditions.join(' && ');
2654
2654
  }
2655
+ function parseTemplateToTree(template) {
2656
+ var tokens = [];
2657
+ var current = '';
2658
+ var depth = 0;
2659
+
2660
+ for (var i = 0; i < template.length; i++) {
2661
+ var _char = template[i];
2662
+
2663
+ if (_char === '[') {
2664
+ if (depth === 0 && current) {
2665
+ tokens.push({
2666
+ type: 'key',
2667
+ value: current
2668
+ });
2669
+ current = '';
2670
+ }
2671
+
2672
+ depth++;
2673
+ current += _char;
2674
+ } else if (_char === ']') {
2675
+ depth--;
2676
+ current += _char;
2677
+
2678
+ if (depth === 0) {
2679
+ tokens.push({
2680
+ type: 'bracket',
2681
+ value: parseTemplateToTree(current.slice(1, -1))
2682
+ });
2683
+ current = '';
2684
+ }
2685
+ } else if (_char === '.' && depth === 0) {
2686
+ if (current) {
2687
+ tokens.push({
2688
+ type: 'key',
2689
+ value: current
2690
+ });
2691
+ current = '';
2692
+ }
2693
+ } else {
2694
+ current += _char;
2695
+ }
2696
+ }
2697
+
2698
+ if (current) {
2699
+ tokens.push({
2700
+ type: 'key',
2701
+ value: current
2702
+ });
2703
+ }
2704
+
2705
+ return tokens.map(function (token) {
2706
+ if (token.type === 'key') {
2707
+ return {
2708
+ key: token.value
2709
+ };
2710
+ } else {
2711
+ return {
2712
+ children: token.value
2713
+ };
2714
+ }
2715
+ });
2716
+ }
2655
2717
 
2656
2718
  var _getGroupInject = function getGroupInject(vm, parent) {
2657
2719
  if (!vm || vm === parent) {
@@ -2848,10 +2910,10 @@
2848
2910
  fapi.scope.bus.$off('$loadData.$scopeForm', emit$scopeForm);
2849
2911
  }
2850
2912
 
2851
- styleEl && document.head.removeChild(styleEl);
2852
2913
  rmSubForm();
2853
2914
  data.destroyed = true;
2854
2915
  fc.unmount();
2916
+ styleEl && (styleEl.parentNode || styleEl.parentElement) && document.head.removeChild(styleEl);
2855
2917
  });
2856
2918
  vue.onUpdated(function () {
2857
2919
  fc.updated();
@@ -3744,9 +3806,7 @@
3744
3806
 
3745
3807
  if (!config) {
3746
3808
  resolve(h.fc.loadData[name]);
3747
- }
3748
-
3749
- if (config.type === 'fetch') {
3809
+ } else if (config.type === 'fetch') {
3750
3810
  api.fetch(config).then(function (res) {
3751
3811
  resolve(res);
3752
3812
  })["catch"](inject);
@@ -4615,6 +4675,58 @@
4615
4675
  if (str && typeof str === 'string' && str.indexOf('{{') > -1 && str.indexOf('}}') > -1) {
4616
4676
  var tmp = str;
4617
4677
  var vars = extractVar(str);
4678
+
4679
+ var getValue = function getValue(field) {
4680
+ var flag = false;
4681
+ var val;
4682
+
4683
+ if (group && field.indexOf('$form.') === 0) {
4684
+ var _split = field.split('.');
4685
+
4686
+ _split.shift();
4687
+
4688
+ if (hasProperty(group.value, _split[0])) {
4689
+ flag = true;
4690
+ val = get ? get({
4691
+ id: '$form.' + _split[0] + '_' + group.rule.__fc__.id,
4692
+ getValue: function getValue() {
4693
+ return deepGet(group.value, _split);
4694
+ }
4695
+ }) : deepGet(group.value, _split);
4696
+ }
4697
+ }
4698
+
4699
+ if (!flag) {
4700
+ val = get ? get(field) : _this3.fc.getLoadData(field);
4701
+ }
4702
+
4703
+ return val;
4704
+ };
4705
+
4706
+ var treeToVal = function treeToVal(tree) {
4707
+ var fields = [];
4708
+ tree.forEach(function (item) {
4709
+ if (item.key) {
4710
+ fields.push(item.key);
4711
+ } else if (item.children) {
4712
+ fields.push(treeToVal(item.children));
4713
+ }
4714
+ });
4715
+ var flag = false;
4716
+ fields.forEach(function (field, idx) {
4717
+ if (field != null && (field.indexOf('\'') === 0 || field.indexOf('"') === 0)) {
4718
+ fields[idx] = field.slice(1, -1);
4719
+ flag = true;
4720
+ }
4721
+ });
4722
+
4723
+ if (fields.length === 1 && (flag || !isNaN(Number(fields[0])))) {
4724
+ return fields[0];
4725
+ }
4726
+
4727
+ return getValue(fields.join('.'));
4728
+ };
4729
+
4618
4730
  var lastVal;
4619
4731
  vars.forEach(function (v) {
4620
4732
  var split = v.split('||');
@@ -4622,27 +4734,13 @@
4622
4734
 
4623
4735
  if (field) {
4624
4736
  var def = (split[1] || '').trim();
4625
- var val;
4626
- var flag = false;
4627
-
4628
- if (group && field.indexOf('$form.') === 0) {
4629
- var _split = field.split('.');
4630
-
4631
- _split.shift();
4632
-
4633
- if (hasProperty(group.value, _split[0])) {
4634
- flag = true;
4635
- val = get ? get({
4636
- id: '$form.' + _split[0] + '_' + group.rule.__fc__.id,
4637
- getValue: function getValue() {
4638
- return deepGet(group.value, _split);
4639
- }
4640
- }) : deepGet(group.value, _split);
4641
- }
4642
- }
4737
+ var tree = parseTemplateToTree(field);
4738
+ var val = invoke(function () {
4739
+ return treeToVal(tree);
4740
+ });
4643
4741
 
4644
- if (!flag) {
4645
- val = get ? get(field, def) : _this3.fc.getLoadData(field, def);
4742
+ if ((val == null || val === '') && split.length > 1) {
4743
+ val = def;
4646
4744
  }
4647
4745
 
4648
4746
  lastVal = val;
@@ -4967,6 +5065,9 @@
4967
5065
  initNone: function initNone() {
4968
5066
  this.none = !(is.Undef(this.prop.display) || !!this.prop.display);
4969
5067
  },
5068
+ hasHidden: function hasHidden() {
5069
+ return !!this.rule.hidden || (this.parent ? this.parent.hasHidden() : false);
5070
+ },
4970
5071
  injectValidate: function injectValidate() {
4971
5072
  return this.prop.validate;
4972
5073
  },
@@ -5642,10 +5743,11 @@
5642
5743
 
5643
5744
  fields.reduce(function (initial, field) {
5644
5745
  var ctx = (_this3.fieldCtx[field] || []).filter(function (ctx) {
5645
- return !_this3.isIgnore(ctx.rule);
5646
- })[0] || _this3.fieldCtx[field][0];
5746
+ return !_this3.isIgnore(ctx);
5747
+ })[0];
5647
5748
 
5648
- if (_this3.isIgnore(ctx.rule)) {
5749
+ if (!ctx) {
5750
+ ctx = _this3.fieldCtx[field][0];
5649
5751
  ignoreFields.push(field);
5650
5752
  }
5651
5753
 
@@ -5656,8 +5758,8 @@
5656
5758
  this.ignoreFields = ignoreFields;
5657
5759
  this.syncValue();
5658
5760
  },
5659
- isIgnore: function isIgnore(rule) {
5660
- return rule.ignore === true || rule.ignore === 'hidden' && rule.hidden || this.options.ignoreHiddenFields && rule.hidden;
5761
+ isIgnore: function isIgnore(ctx) {
5762
+ return ctx.rule.ignore === true || (ctx.rule.ignore === 'hidden' || this.options.ignoreHiddenFields) && ctx.hasHidden();
5661
5763
  },
5662
5764
  appendValue: function appendValue(rule) {
5663
5765
  if ((!rule.field || !hasProperty(this.appendData, rule.field)) && !this.options.forceCoverValue) {
@@ -6585,7 +6687,7 @@
6585
6687
 
6586
6688
  if (is.trueArray(children)) {
6587
6689
  children.forEach(function (h) {
6588
- return h.__fc__ && _this8.rmCtx(h.__fc__);
6690
+ return h && h.__fc__ && _this8.rmCtx(h.__fc__);
6589
6691
  });
6590
6692
  }
6591
6693
  }
@@ -6659,19 +6761,34 @@
6659
6761
 
6660
6762
  var hook = (_ctx$prop = ctx.prop) === null || _ctx$prop === void 0 ? void 0 : (_ctx$prop$hook = _ctx$prop.hook) === null || _ctx$prop$hook === void 0 ? void 0 : _ctx$prop$hook[name];
6661
6763
 
6662
- if (hook) {
6663
- hook = Array.isArray(hook) ? hook : [hook];
6664
- hook.forEach(function (fn) {
6665
- invoke(function () {
6666
- return fn(_objectSpread2(_objectSpread2({}, args || {}), {}, {
6667
- self: ctx.rule,
6668
- rule: ctx.rule,
6669
- $f: _this2.api,
6670
- api: _this2.api,
6671
- option: _this2.vm.props.option
6672
- }));
6764
+ var run = function run(on, p) {
6765
+ if (on) {
6766
+ on = Array.isArray(on) ? on : [on];
6767
+ on.forEach(function (fn) {
6768
+ invoke(function () {
6769
+ return fn(_objectSpread2(_objectSpread2({}, args || {}), {}, {
6770
+ self: ctx.rule,
6771
+ rule: ctx.rule,
6772
+ parent: p === null || p === void 0 ? void 0 : p.rule,
6773
+ $f: _this2.api,
6774
+ api: _this2.api,
6775
+ option: _this2.vm.props.option
6776
+ }));
6777
+ });
6673
6778
  });
6674
- });
6779
+ }
6780
+ };
6781
+
6782
+ run(hook);
6783
+ var deepName = 'deep' + upper(name);
6784
+ var parent = ctx.parent;
6785
+
6786
+ while (parent) {
6787
+ var _parent$prop, _parent$prop$hook;
6788
+
6789
+ var deepHook = (_parent$prop = parent.prop) === null || _parent$prop === void 0 ? void 0 : (_parent$prop$hook = _parent$prop.hook) === null || _parent$prop$hook === void 0 ? void 0 : _parent$prop$hook[deepName];
6790
+ run(deepHook, parent);
6791
+ parent = parent.parent;
6675
6792
  }
6676
6793
  }
6677
6794
  });
@@ -7032,7 +7149,9 @@
7032
7149
  function CreateNodeFactory() {
7033
7150
  var aliasMap = {};
7034
7151
 
7035
- function CreateNode() {}
7152
+ function CreateNode(vm) {
7153
+ this.vm = vm;
7154
+ }
7036
7155
 
7037
7156
  extend(CreateNode.prototype, {
7038
7157
  make: function make(tag, data, children) {
@@ -7047,7 +7166,8 @@
7047
7166
  }
7048
7167
  },
7049
7168
  h: function h(tag, data, children) {
7050
- var isNativeTag = vue.getCurrentInstance().appContext.config.isNativeTag(tag);
7169
+ var vm = this.vm || vue.getCurrentInstance();
7170
+ var isNativeTag = vm.appContext.config.isNativeTag(tag);
7051
7171
 
7052
7172
  if (isNativeTag) {
7053
7173
  delete data.formCreateInject;
@@ -8361,7 +8481,7 @@
8361
8481
 
8362
8482
  if (!unwatch[id]) {
8363
8483
  return;
8364
- } else if (JSON.stringify(temp) !== JSON.stringify(unwatch[id].val)) {
8484
+ } else if ((temp instanceof Function || is.Object(temp) || Array.isArray(temp)) && temp === unwatch[id].val || JSON.stringify(temp) !== JSON.stringify(unwatch[id].val)) {
8365
8485
  unwatch[id].val = temp;
8366
8486
  run(true);
8367
8487
  }
@@ -9503,7 +9623,7 @@
9503
9623
  function elmFormCreate() {
9504
9624
  return FormCreateFactory({
9505
9625
  ui: 'element-ui',
9506
- version: '3.2.23',
9626
+ version: '3.2.25',
9507
9627
  manager: manager,
9508
9628
  extendApi: extendApi,
9509
9629
  install: install,