@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.
@@ -2648,6 +2648,68 @@ function convertFieldToConditions(field) {
2648
2648
  });
2649
2649
  return conditions.join(' && ');
2650
2650
  }
2651
+ function parseTemplateToTree(template) {
2652
+ var tokens = [];
2653
+ var current = '';
2654
+ var depth = 0;
2655
+
2656
+ for (var i = 0; i < template.length; i++) {
2657
+ var _char = template[i];
2658
+
2659
+ if (_char === '[') {
2660
+ if (depth === 0 && current) {
2661
+ tokens.push({
2662
+ type: 'key',
2663
+ value: current
2664
+ });
2665
+ current = '';
2666
+ }
2667
+
2668
+ depth++;
2669
+ current += _char;
2670
+ } else if (_char === ']') {
2671
+ depth--;
2672
+ current += _char;
2673
+
2674
+ if (depth === 0) {
2675
+ tokens.push({
2676
+ type: 'bracket',
2677
+ value: parseTemplateToTree(current.slice(1, -1))
2678
+ });
2679
+ current = '';
2680
+ }
2681
+ } else if (_char === '.' && depth === 0) {
2682
+ if (current) {
2683
+ tokens.push({
2684
+ type: 'key',
2685
+ value: current
2686
+ });
2687
+ current = '';
2688
+ }
2689
+ } else {
2690
+ current += _char;
2691
+ }
2692
+ }
2693
+
2694
+ if (current) {
2695
+ tokens.push({
2696
+ type: 'key',
2697
+ value: current
2698
+ });
2699
+ }
2700
+
2701
+ return tokens.map(function (token) {
2702
+ if (token.type === 'key') {
2703
+ return {
2704
+ key: token.value
2705
+ };
2706
+ } else {
2707
+ return {
2708
+ children: token.value
2709
+ };
2710
+ }
2711
+ });
2712
+ }
2651
2713
 
2652
2714
  var _getGroupInject = function getGroupInject(vm, parent) {
2653
2715
  if (!vm || vm === parent) {
@@ -2844,10 +2906,10 @@ function $FormCreate(FormCreate, components, directives) {
2844
2906
  fapi.scope.bus.$off('$loadData.$scopeForm', emit$scopeForm);
2845
2907
  }
2846
2908
 
2847
- styleEl && document.head.removeChild(styleEl);
2848
2909
  rmSubForm();
2849
2910
  data.destroyed = true;
2850
2911
  fc.unmount();
2912
+ styleEl && (styleEl.parentNode || styleEl.parentElement) && document.head.removeChild(styleEl);
2851
2913
  });
2852
2914
  onUpdated(function () {
2853
2915
  fc.updated();
@@ -3740,9 +3802,7 @@ function Api(h) {
3740
3802
 
3741
3803
  if (!config) {
3742
3804
  resolve(h.fc.loadData[name]);
3743
- }
3744
-
3745
- if (config.type === 'fetch') {
3805
+ } else if (config.type === 'fetch') {
3746
3806
  api.fetch(config).then(function (res) {
3747
3807
  resolve(res);
3748
3808
  })["catch"](inject);
@@ -4611,6 +4671,58 @@ function useInject(Handler) {
4611
4671
  if (str && typeof str === 'string' && str.indexOf('{{') > -1 && str.indexOf('}}') > -1) {
4612
4672
  var tmp = str;
4613
4673
  var vars = extractVar(str);
4674
+
4675
+ var getValue = function getValue(field) {
4676
+ var flag = false;
4677
+ var val;
4678
+
4679
+ if (group && field.indexOf('$form.') === 0) {
4680
+ var _split = field.split('.');
4681
+
4682
+ _split.shift();
4683
+
4684
+ if (hasProperty(group.value, _split[0])) {
4685
+ flag = true;
4686
+ val = get ? get({
4687
+ id: '$form.' + _split[0] + '_' + group.rule.__fc__.id,
4688
+ getValue: function getValue() {
4689
+ return deepGet(group.value, _split);
4690
+ }
4691
+ }) : deepGet(group.value, _split);
4692
+ }
4693
+ }
4694
+
4695
+ if (!flag) {
4696
+ val = get ? get(field) : _this3.fc.getLoadData(field);
4697
+ }
4698
+
4699
+ return val;
4700
+ };
4701
+
4702
+ var treeToVal = function treeToVal(tree) {
4703
+ var fields = [];
4704
+ tree.forEach(function (item) {
4705
+ if (item.key) {
4706
+ fields.push(item.key);
4707
+ } else if (item.children) {
4708
+ fields.push(treeToVal(item.children));
4709
+ }
4710
+ });
4711
+ var flag = false;
4712
+ fields.forEach(function (field, idx) {
4713
+ if (field != null && (field.indexOf('\'') === 0 || field.indexOf('"') === 0)) {
4714
+ fields[idx] = field.slice(1, -1);
4715
+ flag = true;
4716
+ }
4717
+ });
4718
+
4719
+ if (fields.length === 1 && (flag || !isNaN(Number(fields[0])))) {
4720
+ return fields[0];
4721
+ }
4722
+
4723
+ return getValue(fields.join('.'));
4724
+ };
4725
+
4614
4726
  var lastVal;
4615
4727
  vars.forEach(function (v) {
4616
4728
  var split = v.split('||');
@@ -4618,27 +4730,13 @@ function useInject(Handler) {
4618
4730
 
4619
4731
  if (field) {
4620
4732
  var def = (split[1] || '').trim();
4621
- var val;
4622
- var flag = false;
4623
-
4624
- if (group && field.indexOf('$form.') === 0) {
4625
- var _split = field.split('.');
4626
-
4627
- _split.shift();
4628
-
4629
- if (hasProperty(group.value, _split[0])) {
4630
- flag = true;
4631
- val = get ? get({
4632
- id: '$form.' + _split[0] + '_' + group.rule.__fc__.id,
4633
- getValue: function getValue() {
4634
- return deepGet(group.value, _split);
4635
- }
4636
- }) : deepGet(group.value, _split);
4637
- }
4638
- }
4733
+ var tree = parseTemplateToTree(field);
4734
+ var val = invoke(function () {
4735
+ return treeToVal(tree);
4736
+ });
4639
4737
 
4640
- if (!flag) {
4641
- val = get ? get(field, def) : _this3.fc.getLoadData(field, def);
4738
+ if ((val == null || val === '') && split.length > 1) {
4739
+ val = def;
4642
4740
  }
4643
4741
 
4644
4742
  lastVal = val;
@@ -4963,6 +5061,9 @@ extend(RuleContext.prototype, {
4963
5061
  initNone: function initNone() {
4964
5062
  this.none = !(is.Undef(this.prop.display) || !!this.prop.display);
4965
5063
  },
5064
+ hasHidden: function hasHidden() {
5065
+ return !!this.rule.hidden || (this.parent ? this.parent.hasHidden() : false);
5066
+ },
4966
5067
  injectValidate: function injectValidate() {
4967
5068
  return this.prop.validate;
4968
5069
  },
@@ -5638,10 +5739,11 @@ function useInput(Handler) {
5638
5739
 
5639
5740
  fields.reduce(function (initial, field) {
5640
5741
  var ctx = (_this3.fieldCtx[field] || []).filter(function (ctx) {
5641
- return !_this3.isIgnore(ctx.rule);
5642
- })[0] || _this3.fieldCtx[field][0];
5742
+ return !_this3.isIgnore(ctx);
5743
+ })[0];
5643
5744
 
5644
- if (_this3.isIgnore(ctx.rule)) {
5745
+ if (!ctx) {
5746
+ ctx = _this3.fieldCtx[field][0];
5645
5747
  ignoreFields.push(field);
5646
5748
  }
5647
5749
 
@@ -5652,8 +5754,8 @@ function useInput(Handler) {
5652
5754
  this.ignoreFields = ignoreFields;
5653
5755
  this.syncValue();
5654
5756
  },
5655
- isIgnore: function isIgnore(rule) {
5656
- return rule.ignore === true || rule.ignore === 'hidden' && rule.hidden || this.options.ignoreHiddenFields && rule.hidden;
5757
+ isIgnore: function isIgnore(ctx) {
5758
+ return ctx.rule.ignore === true || (ctx.rule.ignore === 'hidden' || this.options.ignoreHiddenFields) && ctx.hasHidden();
5657
5759
  },
5658
5760
  appendValue: function appendValue(rule) {
5659
5761
  if ((!rule.field || !hasProperty(this.appendData, rule.field)) && !this.options.forceCoverValue) {
@@ -6581,7 +6683,7 @@ function useContext(Handler) {
6581
6683
 
6582
6684
  if (is.trueArray(children)) {
6583
6685
  children.forEach(function (h) {
6584
- return h.__fc__ && _this8.rmCtx(h.__fc__);
6686
+ return h && h.__fc__ && _this8.rmCtx(h.__fc__);
6585
6687
  });
6586
6688
  }
6587
6689
  }
@@ -6655,19 +6757,34 @@ function useLifecycle(Handler) {
6655
6757
 
6656
6758
  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];
6657
6759
 
6658
- if (hook) {
6659
- hook = Array.isArray(hook) ? hook : [hook];
6660
- hook.forEach(function (fn) {
6661
- invoke(function () {
6662
- return fn(_objectSpread2(_objectSpread2({}, args || {}), {}, {
6663
- self: ctx.rule,
6664
- rule: ctx.rule,
6665
- $f: _this2.api,
6666
- api: _this2.api,
6667
- option: _this2.vm.props.option
6668
- }));
6760
+ var run = function run(on, p) {
6761
+ if (on) {
6762
+ on = Array.isArray(on) ? on : [on];
6763
+ on.forEach(function (fn) {
6764
+ invoke(function () {
6765
+ return fn(_objectSpread2(_objectSpread2({}, args || {}), {}, {
6766
+ self: ctx.rule,
6767
+ rule: ctx.rule,
6768
+ parent: p === null || p === void 0 ? void 0 : p.rule,
6769
+ $f: _this2.api,
6770
+ api: _this2.api,
6771
+ option: _this2.vm.props.option
6772
+ }));
6773
+ });
6669
6774
  });
6670
- });
6775
+ }
6776
+ };
6777
+
6778
+ run(hook);
6779
+ var deepName = 'deep' + upper(name);
6780
+ var parent = ctx.parent;
6781
+
6782
+ while (parent) {
6783
+ var _parent$prop, _parent$prop$hook;
6784
+
6785
+ 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];
6786
+ run(deepHook, parent);
6787
+ parent = parent.parent;
6671
6788
  }
6672
6789
  }
6673
6790
  });
@@ -7028,7 +7145,9 @@ function makeDirective(data, vn) {
7028
7145
  function CreateNodeFactory() {
7029
7146
  var aliasMap = {};
7030
7147
 
7031
- function CreateNode() {}
7148
+ function CreateNode(vm) {
7149
+ this.vm = vm;
7150
+ }
7032
7151
 
7033
7152
  extend(CreateNode.prototype, {
7034
7153
  make: function make(tag, data, children) {
@@ -7043,7 +7162,8 @@ function CreateNodeFactory() {
7043
7162
  }
7044
7163
  },
7045
7164
  h: function h(tag, data, children) {
7046
- var isNativeTag = getCurrentInstance().appContext.config.isNativeTag(tag);
7165
+ var vm = this.vm || getCurrentInstance();
7166
+ var isNativeTag = vm.appContext.config.isNativeTag(tag);
7047
7167
 
7048
7168
  if (isNativeTag) {
7049
7169
  delete data.formCreateInject;
@@ -8357,7 +8477,7 @@ function FormCreateFactory(config) {
8357
8477
 
8358
8478
  if (!unwatch[id]) {
8359
8479
  return;
8360
- } else if (JSON.stringify(temp) !== JSON.stringify(unwatch[id].val)) {
8480
+ } else if ((temp instanceof Function || is.Object(temp) || Array.isArray(temp)) && temp === unwatch[id].val || JSON.stringify(temp) !== JSON.stringify(unwatch[id].val)) {
8361
8481
  unwatch[id].val = temp;
8362
8482
  run(true);
8363
8483
  }
@@ -9499,7 +9619,7 @@ function install(FormCreate) {
9499
9619
  function elmFormCreate() {
9500
9620
  return FormCreateFactory({
9501
9621
  ui: 'element-ui',
9502
- version: '3.2.23',
9622
+ version: '3.2.25',
9503
9623
  manager: manager,
9504
9624
  extendApi: extendApi,
9505
9625
  install: install,