@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.
@@ -1012,6 +1012,48 @@ var Radio = defineComponent({
1012
1012
  }
1013
1013
  });
1014
1014
 
1015
+ var is = {
1016
+ type: function type(arg, _type) {
1017
+ return Object.prototype.toString.call(arg) === '[object ' + _type + ']';
1018
+ },
1019
+ Undef: function Undef(v) {
1020
+ return v === undefined || v === null;
1021
+ },
1022
+ Element: function Element(arg) {
1023
+ return _typeof(arg) === 'object' && arg !== null && arg.nodeType === 1 && !is.Object(arg);
1024
+ },
1025
+ trueArray: function trueArray(data) {
1026
+ return Array.isArray(data) && data.length > 0;
1027
+ },
1028
+ Function: function Function(v) {
1029
+ var type = this.getType(v);
1030
+ return type === 'Function' || type === 'AsyncFunction';
1031
+ },
1032
+ getType: function getType(v) {
1033
+ var str = Object.prototype.toString.call(v);
1034
+ return /^\[object (.*)\]$/.exec(str)[1];
1035
+ },
1036
+ empty: function empty(value) {
1037
+ if (value === undefined || value === null) {
1038
+ return true;
1039
+ }
1040
+
1041
+ if (Array.isArray(value) && Array.isArray(value) && !value.length) {
1042
+ return true;
1043
+ }
1044
+
1045
+ return typeof value === 'string' && !value;
1046
+ }
1047
+ };
1048
+ ['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
1049
+ is[t] = function (arg) {
1050
+ return is.type(arg, t);
1051
+ };
1052
+ });
1053
+ function hasProperty(rule, k) {
1054
+ return {}.hasOwnProperty.call(rule, k);
1055
+ }
1056
+
1015
1057
  var NAME$6 = 'fcSelect';
1016
1058
  var Select = defineComponent({
1017
1059
  name: NAME$6,
@@ -1043,6 +1085,26 @@ var Select = defineComponent({
1043
1085
  _this$$slots$default,
1044
1086
  _this$$slots;
1045
1087
 
1088
+ var makeOption = function makeOption(props, index) {
1089
+ return createVNode(resolveComponent("ElOption"), mergeProps$1(props, {
1090
+ "key": '' + index + '-' + props.value
1091
+ }), null);
1092
+ };
1093
+
1094
+ var makeOptionGroup = function makeOptionGroup(props, index) {
1095
+ return createVNode(resolveComponent("ElOptionGroup"), {
1096
+ "label": props.label,
1097
+ "key": '' + index + '-' + props.label
1098
+ }, {
1099
+ "default": function _default() {
1100
+ return [is.trueArray(props.options) && props.options.map(function (v, index) {
1101
+ return makeOption(v, index);
1102
+ })];
1103
+ }
1104
+ });
1105
+ };
1106
+
1107
+ var options = this.options();
1046
1108
  return createVNode(resolveComponent("ElSelect"), mergeProps$1(this.$attrs, {
1047
1109
  "modelValue": this.value,
1048
1110
  "onUpdate:modelValue": function onUpdateModelValue(v) {
@@ -1051,10 +1113,8 @@ var Select = defineComponent({
1051
1113
  "ref": "el"
1052
1114
  }), _objectSpread2({
1053
1115
  "default": function _default() {
1054
- return [_this.options().map(function (props, index) {
1055
- return createVNode(resolveComponent("ElOption"), mergeProps$1(props, {
1056
- "key": '' + index + '-' + props.value
1057
- }), null);
1116
+ return [options.map(function (props, index) {
1117
+ return hasProperty(props || '', 'options') ? makeOptionGroup(props, index) : makeOption(props, index);
1058
1118
  }), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
1059
1119
  }
1060
1120
  }, getSlot(this.$slots, ['default'])));
@@ -1278,48 +1338,6 @@ var Upload = defineComponent({
1278
1338
  }
1279
1339
  });
1280
1340
 
1281
- var is = {
1282
- type: function type(arg, _type) {
1283
- return Object.prototype.toString.call(arg) === '[object ' + _type + ']';
1284
- },
1285
- Undef: function Undef(v) {
1286
- return v === undefined || v === null;
1287
- },
1288
- Element: function Element(arg) {
1289
- return _typeof(arg) === 'object' && arg !== null && arg.nodeType === 1 && !is.Object(arg);
1290
- },
1291
- trueArray: function trueArray(data) {
1292
- return Array.isArray(data) && data.length > 0;
1293
- },
1294
- Function: function Function(v) {
1295
- var type = this.getType(v);
1296
- return type === 'Function' || type === 'AsyncFunction';
1297
- },
1298
- getType: function getType(v) {
1299
- var str = Object.prototype.toString.call(v);
1300
- return /^\[object (.*)\]$/.exec(str)[1];
1301
- },
1302
- empty: function empty(value) {
1303
- if (value === undefined || value === null) {
1304
- return true;
1305
- }
1306
-
1307
- if (Array.isArray(value) && Array.isArray(value) && !value.length) {
1308
- return true;
1309
- }
1310
-
1311
- return typeof value === 'string' && !value;
1312
- }
1313
- };
1314
- ['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
1315
- is[t] = function (arg) {
1316
- return is.type(arg, t);
1317
- };
1318
- });
1319
- function hasProperty(rule, k) {
1320
- return {}.hasOwnProperty.call(rule, k);
1321
- }
1322
-
1323
1341
  function $set(target, field, value) {
1324
1342
  target[field] = value;
1325
1343
  }
@@ -3932,7 +3950,8 @@ extend(RuleContext.prototype, {
3932
3950
  vm: handle.vm,
3933
3951
  trueType: handle.getType(this.originType),
3934
3952
  vNode: handle.$render.vNode,
3935
- updated: false
3953
+ updated: false,
3954
+ cacheValue: this.rule.value
3936
3955
  });
3937
3956
  !init && this.unwatch();
3938
3957
  this.watchTo();
@@ -5474,6 +5493,15 @@ var fetch = function fetch(fc) {
5474
5493
  function run(inject, rule, api) {
5475
5494
  var option = inject.value;
5476
5495
 
5496
+ var set = function set(val) {
5497
+ if (val === undefined) {
5498
+ inject.clearProp();
5499
+ api.sync(rule);
5500
+ } else {
5501
+ deepSet(inject.getProp(), option.to || 'options', val);
5502
+ }
5503
+ };
5504
+
5477
5505
  if (is.Function(option)) {
5478
5506
  option = option(rule, api);
5479
5507
  }
@@ -5481,7 +5509,8 @@ var fetch = function fetch(fc) {
5481
5509
  option = parseOpt(option);
5482
5510
 
5483
5511
  if (!option || !option.action) {
5484
- return false;
5512
+ set(undefined);
5513
+ return;
5485
5514
  }
5486
5515
 
5487
5516
  if (!option.to) {
@@ -5498,55 +5527,65 @@ var fetch = function fetch(fc) {
5498
5527
  }
5499
5528
  };
5500
5529
 
5501
- var set = function set(val) {
5502
- if (val === undefined) {
5503
- inject.clearProp();
5504
- api.sync(rule);
5505
- } else {
5506
- deepSet(inject.getProp(), option.to, val);
5507
- }
5508
- };
5530
+ var config = _objectSpread2(_objectSpread2({
5531
+ headers: {}
5532
+ }, option), {}, {
5533
+ onSuccess: function onSuccess(body, flag) {
5534
+ if (check()) return;
5509
5535
 
5510
- invoke(function () {
5511
- return fc.create.fetch(_objectSpread2(_objectSpread2({}, option), {}, {
5512
- onSuccess: function onSuccess(body) {
5513
- if (check()) return;
5536
+ var fn = function fn(v) {
5537
+ return flag ? v : v.data;
5538
+ };
5514
5539
 
5515
- var fn = function fn(v) {
5516
- return v.data;
5540
+ if (is.Function(option.parse)) {
5541
+ fn = option.parse;
5542
+ } else if (option.parse && is.String(option.parse)) {
5543
+ fn = function fn(v) {
5544
+ option.parse.split('.').forEach(function (k) {
5545
+ if (v) {
5546
+ v = v[k];
5547
+ }
5548
+ });
5549
+ return v;
5517
5550
  };
5551
+ }
5518
5552
 
5519
- if (is.Function(option.parse)) {
5520
- fn = option.parse;
5521
- } else if (option.parse && is.String(option.parse)) {
5522
- fn = function fn(v) {
5523
- option.parse.split('.').forEach(function (k) {
5524
- if (v) {
5525
- v = v[k];
5526
- }
5527
- });
5528
- return v;
5529
- };
5530
- }
5553
+ set(fn(body, rule, api));
5554
+ api.sync(rule);
5555
+ },
5556
+ onError: function onError(e) {
5557
+ set(undefined);
5558
+ if (check()) return;
5531
5559
 
5532
- set(fn(body, rule, api));
5533
- api.sync(rule);
5534
- },
5535
- onError: function onError(e) {
5536
- set(undefined);
5537
- if (check()) return;
5560
+ (_onError || function (e) {
5561
+ return err(e.message || 'fetch fail ' + option.action);
5562
+ })(e, rule, api);
5563
+ }
5564
+ });
5538
5565
 
5539
- (_onError || function (e) {
5540
- return err(e.message || 'fetch fail ' + option.action);
5541
- })(e, rule, api);
5542
- }
5543
- }), {
5566
+ fc.options.beforeFetch && invoke(function () {
5567
+ return fc.options.beforeFetch(config, {
5568
+ rule: rule,
5569
+ api: api
5570
+ });
5571
+ });
5572
+
5573
+ if (is.Function(option.action)) {
5574
+ option.action(rule, api).then(function (val) {
5575
+ config.onSuccess(val, true);
5576
+ })["catch"](function (e) {
5577
+ config.onError(e);
5578
+ });
5579
+ return;
5580
+ }
5581
+
5582
+ invoke(function () {
5583
+ return fc.create.fetch(config, {
5544
5584
  inject: inject,
5545
5585
  rule: rule,
5546
5586
  api: api
5547
5587
  });
5548
5588
  });
5549
- return true;
5550
5589
  }
5551
5590
 
5552
5591
  return {
@@ -5554,11 +5593,8 @@ var fetch = function fetch(fc) {
5554
5593
  loaded: function loaded() {
5555
5594
  run.apply(void 0, arguments);
5556
5595
  },
5557
- watch: function watch(inject, rule, api) {
5558
- if (!run(inject, rule, api)) {
5559
- inject.clearProp();
5560
- api.sync(rule);
5561
- }
5596
+ watch: function watch() {
5597
+ run.apply(void 0, arguments);
5562
5598
  }
5563
5599
  };
5564
5600
  };
@@ -6879,7 +6915,7 @@ function install(FormCreate) {
6879
6915
  function elmFormCreate() {
6880
6916
  return FormCreateFactory({
6881
6917
  ui: 'element-ui',
6882
- version: '3.1.24',
6918
+ version: '3.1.25',
6883
6919
  manager: manager,
6884
6920
  extendApi: extendApi,
6885
6921
  install: install,