@form-create/element-ui 3.1.24 → 3.1.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.1.24
2
+ * @form-create/element-ui v3.1.25
3
3
  * (c) 2018-2023 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -1016,6 +1016,48 @@
1016
1016
  }
1017
1017
  });
1018
1018
 
1019
+ var is = {
1020
+ type: function type(arg, _type) {
1021
+ return Object.prototype.toString.call(arg) === '[object ' + _type + ']';
1022
+ },
1023
+ Undef: function Undef(v) {
1024
+ return v === undefined || v === null;
1025
+ },
1026
+ Element: function Element(arg) {
1027
+ return _typeof(arg) === 'object' && arg !== null && arg.nodeType === 1 && !is.Object(arg);
1028
+ },
1029
+ trueArray: function trueArray(data) {
1030
+ return Array.isArray(data) && data.length > 0;
1031
+ },
1032
+ Function: function Function(v) {
1033
+ var type = this.getType(v);
1034
+ return type === 'Function' || type === 'AsyncFunction';
1035
+ },
1036
+ getType: function getType(v) {
1037
+ var str = Object.prototype.toString.call(v);
1038
+ return /^\[object (.*)\]$/.exec(str)[1];
1039
+ },
1040
+ empty: function empty(value) {
1041
+ if (value === undefined || value === null) {
1042
+ return true;
1043
+ }
1044
+
1045
+ if (Array.isArray(value) && Array.isArray(value) && !value.length) {
1046
+ return true;
1047
+ }
1048
+
1049
+ return typeof value === 'string' && !value;
1050
+ }
1051
+ };
1052
+ ['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
1053
+ is[t] = function (arg) {
1054
+ return is.type(arg, t);
1055
+ };
1056
+ });
1057
+ function hasProperty(rule, k) {
1058
+ return {}.hasOwnProperty.call(rule, k);
1059
+ }
1060
+
1019
1061
  var NAME$6 = 'fcSelect';
1020
1062
  var Select = vue.defineComponent({
1021
1063
  name: NAME$6,
@@ -1047,6 +1089,26 @@
1047
1089
  _this$$slots$default,
1048
1090
  _this$$slots;
1049
1091
 
1092
+ var makeOption = function makeOption(props, index) {
1093
+ return vue.createVNode(vue.resolveComponent("ElOption"), vue.mergeProps(props, {
1094
+ "key": '' + index + '-' + props.value
1095
+ }), null);
1096
+ };
1097
+
1098
+ var makeOptionGroup = function makeOptionGroup(props, index) {
1099
+ return vue.createVNode(vue.resolveComponent("ElOptionGroup"), {
1100
+ "label": props.label,
1101
+ "key": '' + index + '-' + props.label
1102
+ }, {
1103
+ "default": function _default() {
1104
+ return [is.trueArray(props.options) && props.options.map(function (v, index) {
1105
+ return makeOption(v, index);
1106
+ })];
1107
+ }
1108
+ });
1109
+ };
1110
+
1111
+ var options = this.options();
1050
1112
  return vue.createVNode(vue.resolveComponent("ElSelect"), vue.mergeProps(this.$attrs, {
1051
1113
  "modelValue": this.value,
1052
1114
  "onUpdate:modelValue": function onUpdateModelValue(v) {
@@ -1055,10 +1117,8 @@
1055
1117
  "ref": "el"
1056
1118
  }), _objectSpread2({
1057
1119
  "default": function _default() {
1058
- return [_this.options().map(function (props, index) {
1059
- return vue.createVNode(vue.resolveComponent("ElOption"), vue.mergeProps(props, {
1060
- "key": '' + index + '-' + props.value
1061
- }), null);
1120
+ return [options.map(function (props, index) {
1121
+ return hasProperty(props || '', 'options') ? makeOptionGroup(props, index) : makeOption(props, index);
1062
1122
  }), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
1063
1123
  }
1064
1124
  }, getSlot(this.$slots, ['default'])));
@@ -1282,48 +1342,6 @@
1282
1342
  }
1283
1343
  });
1284
1344
 
1285
- var is = {
1286
- type: function type(arg, _type) {
1287
- return Object.prototype.toString.call(arg) === '[object ' + _type + ']';
1288
- },
1289
- Undef: function Undef(v) {
1290
- return v === undefined || v === null;
1291
- },
1292
- Element: function Element(arg) {
1293
- return _typeof(arg) === 'object' && arg !== null && arg.nodeType === 1 && !is.Object(arg);
1294
- },
1295
- trueArray: function trueArray(data) {
1296
- return Array.isArray(data) && data.length > 0;
1297
- },
1298
- Function: function Function(v) {
1299
- var type = this.getType(v);
1300
- return type === 'Function' || type === 'AsyncFunction';
1301
- },
1302
- getType: function getType(v) {
1303
- var str = Object.prototype.toString.call(v);
1304
- return /^\[object (.*)\]$/.exec(str)[1];
1305
- },
1306
- empty: function empty(value) {
1307
- if (value === undefined || value === null) {
1308
- return true;
1309
- }
1310
-
1311
- if (Array.isArray(value) && Array.isArray(value) && !value.length) {
1312
- return true;
1313
- }
1314
-
1315
- return typeof value === 'string' && !value;
1316
- }
1317
- };
1318
- ['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
1319
- is[t] = function (arg) {
1320
- return is.type(arg, t);
1321
- };
1322
- });
1323
- function hasProperty(rule, k) {
1324
- return {}.hasOwnProperty.call(rule, k);
1325
- }
1326
-
1327
1345
  function $set(target, field, value) {
1328
1346
  target[field] = value;
1329
1347
  }
@@ -3936,7 +3954,8 @@
3936
3954
  vm: handle.vm,
3937
3955
  trueType: handle.getType(this.originType),
3938
3956
  vNode: handle.$render.vNode,
3939
- updated: false
3957
+ updated: false,
3958
+ cacheValue: this.rule.value
3940
3959
  });
3941
3960
  !init && this.unwatch();
3942
3961
  this.watchTo();
@@ -5478,6 +5497,15 @@
5478
5497
  function run(inject, rule, api) {
5479
5498
  var option = inject.value;
5480
5499
 
5500
+ var set = function set(val) {
5501
+ if (val === undefined) {
5502
+ inject.clearProp();
5503
+ api.sync(rule);
5504
+ } else {
5505
+ deepSet(inject.getProp(), option.to || 'options', val);
5506
+ }
5507
+ };
5508
+
5481
5509
  if (is.Function(option)) {
5482
5510
  option = option(rule, api);
5483
5511
  }
@@ -5485,7 +5513,8 @@
5485
5513
  option = parseOpt(option);
5486
5514
 
5487
5515
  if (!option || !option.action) {
5488
- return false;
5516
+ set(undefined);
5517
+ return;
5489
5518
  }
5490
5519
 
5491
5520
  if (!option.to) {
@@ -5502,55 +5531,65 @@
5502
5531
  }
5503
5532
  };
5504
5533
 
5505
- var set = function set(val) {
5506
- if (val === undefined) {
5507
- inject.clearProp();
5508
- api.sync(rule);
5509
- } else {
5510
- deepSet(inject.getProp(), option.to, val);
5511
- }
5512
- };
5534
+ var config = _objectSpread2(_objectSpread2({
5535
+ headers: {}
5536
+ }, option), {}, {
5537
+ onSuccess: function onSuccess(body, flag) {
5538
+ if (check()) return;
5513
5539
 
5514
- invoke(function () {
5515
- return fc.create.fetch(_objectSpread2(_objectSpread2({}, option), {}, {
5516
- onSuccess: function onSuccess(body) {
5517
- if (check()) return;
5540
+ var fn = function fn(v) {
5541
+ return flag ? v : v.data;
5542
+ };
5518
5543
 
5519
- var fn = function fn(v) {
5520
- return v.data;
5544
+ if (is.Function(option.parse)) {
5545
+ fn = option.parse;
5546
+ } else if (option.parse && is.String(option.parse)) {
5547
+ fn = function fn(v) {
5548
+ option.parse.split('.').forEach(function (k) {
5549
+ if (v) {
5550
+ v = v[k];
5551
+ }
5552
+ });
5553
+ return v;
5521
5554
  };
5555
+ }
5522
5556
 
5523
- if (is.Function(option.parse)) {
5524
- fn = option.parse;
5525
- } else if (option.parse && is.String(option.parse)) {
5526
- fn = function fn(v) {
5527
- option.parse.split('.').forEach(function (k) {
5528
- if (v) {
5529
- v = v[k];
5530
- }
5531
- });
5532
- return v;
5533
- };
5534
- }
5557
+ set(fn(body, rule, api));
5558
+ api.sync(rule);
5559
+ },
5560
+ onError: function onError(e) {
5561
+ set(undefined);
5562
+ if (check()) return;
5535
5563
 
5536
- set(fn(body, rule, api));
5537
- api.sync(rule);
5538
- },
5539
- onError: function onError(e) {
5540
- set(undefined);
5541
- if (check()) return;
5564
+ (_onError || function (e) {
5565
+ return err(e.message || 'fetch fail ' + option.action);
5566
+ })(e, rule, api);
5567
+ }
5568
+ });
5542
5569
 
5543
- (_onError || function (e) {
5544
- return err(e.message || 'fetch fail ' + option.action);
5545
- })(e, rule, api);
5546
- }
5547
- }), {
5570
+ fc.options.beforeFetch && invoke(function () {
5571
+ return fc.options.beforeFetch(config, {
5572
+ rule: rule,
5573
+ api: api
5574
+ });
5575
+ });
5576
+
5577
+ if (is.Function(option.action)) {
5578
+ option.action(rule, api).then(function (val) {
5579
+ config.onSuccess(val, true);
5580
+ })["catch"](function (e) {
5581
+ config.onError(e);
5582
+ });
5583
+ return;
5584
+ }
5585
+
5586
+ invoke(function () {
5587
+ return fc.create.fetch(config, {
5548
5588
  inject: inject,
5549
5589
  rule: rule,
5550
5590
  api: api
5551
5591
  });
5552
5592
  });
5553
- return true;
5554
5593
  }
5555
5594
 
5556
5595
  return {
@@ -5558,11 +5597,8 @@
5558
5597
  loaded: function loaded() {
5559
5598
  run.apply(void 0, arguments);
5560
5599
  },
5561
- watch: function watch(inject, rule, api) {
5562
- if (!run(inject, rule, api)) {
5563
- inject.clearProp();
5564
- api.sync(rule);
5565
- }
5600
+ watch: function watch() {
5601
+ run.apply(void 0, arguments);
5566
5602
  }
5567
5603
  };
5568
5604
  };
@@ -6883,7 +6919,7 @@
6883
6919
  function elmFormCreate() {
6884
6920
  return FormCreateFactory({
6885
6921
  ui: 'element-ui',
6886
- version: '3.1.24',
6922
+ version: '3.1.25',
6887
6923
  manager: manager,
6888
6924
  extendApi: extendApi,
6889
6925
  install: install,