@form-create/element-ui 2.5.12 → 2.5.13
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.
- package/dist/form-create.js +73 -59
- package/dist/form-create.min.js +2 -2
- package/dist/form-create.min.js.map +1 -1
- package/package.json +6 -6
- package/src/core/manager.js +16 -21
package/dist/form-create.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/element-ui v2.5.
|
|
2
|
+
* @form-create/element-ui v2.5.13
|
|
3
3
|
* (c) 2018-2021 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
@@ -277,15 +277,13 @@
|
|
|
277
277
|
trueValue: []
|
|
278
278
|
};
|
|
279
279
|
},
|
|
280
|
-
|
|
280
|
+
methods: {
|
|
281
281
|
options: function options() {
|
|
282
282
|
var opt = this.formCreateInject.options;
|
|
283
283
|
return Array.isArray(opt) ? opt : [];
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
methods: {
|
|
284
|
+
},
|
|
287
285
|
onInput: function onInput(n) {
|
|
288
|
-
this.$emit('input', this.options.filter(function (opt) {
|
|
286
|
+
this.$emit('input', this.options().filter(function (opt) {
|
|
289
287
|
return n.indexOf(opt.label) !== -1;
|
|
290
288
|
}).map(function (opt) {
|
|
291
289
|
return opt.value;
|
|
@@ -296,7 +294,7 @@
|
|
|
296
294
|
update: function update() {
|
|
297
295
|
var _this = this;
|
|
298
296
|
|
|
299
|
-
this.trueValue = this.value ? this.options.filter(function (opt) {
|
|
297
|
+
this.trueValue = this.value ? this.options().filter(function (opt) {
|
|
300
298
|
return _this.value.indexOf(opt.value) !== -1;
|
|
301
299
|
}).map(function (option) {
|
|
302
300
|
return option.label;
|
|
@@ -317,7 +315,7 @@
|
|
|
317
315
|
"on": {
|
|
318
316
|
"input": this.onInput
|
|
319
317
|
}
|
|
320
|
-
}]), [this.options.map(function (opt, index) {
|
|
318
|
+
}]), [this.options().map(function (opt, index) {
|
|
321
319
|
var props = _objectSpread2({}, opt);
|
|
322
320
|
|
|
323
321
|
var Type = _this2.type === 'button' ? 'ElCheckboxButton' : 'ElCheckbox';
|
|
@@ -870,15 +868,13 @@
|
|
|
870
868
|
trueValue: []
|
|
871
869
|
};
|
|
872
870
|
},
|
|
873
|
-
|
|
871
|
+
methods: {
|
|
874
872
|
options: function options() {
|
|
875
873
|
var opt = this.formCreateInject.options;
|
|
876
874
|
return Array.isArray(opt) ? opt : [];
|
|
877
|
-
}
|
|
878
|
-
},
|
|
879
|
-
methods: {
|
|
875
|
+
},
|
|
880
876
|
onInput: function onInput(n) {
|
|
881
|
-
this.$emit('input', this.options.filter(function (opt) {
|
|
877
|
+
this.$emit('input', this.options().filter(function (opt) {
|
|
882
878
|
return opt.label === n;
|
|
883
879
|
}).reduce(function (initial, opt) {
|
|
884
880
|
return opt.value;
|
|
@@ -887,7 +883,7 @@
|
|
|
887
883
|
update: function update() {
|
|
888
884
|
var _this = this;
|
|
889
885
|
|
|
890
|
-
this.trueValue = this.options.filter(function (opt) {
|
|
886
|
+
this.trueValue = this.options().filter(function (opt) {
|
|
891
887
|
return opt.value === _this.value;
|
|
892
888
|
}).reduce(function (initial, opt) {
|
|
893
889
|
return opt.label;
|
|
@@ -908,7 +904,7 @@
|
|
|
908
904
|
"on": {
|
|
909
905
|
"input": this.onInput
|
|
910
906
|
}
|
|
911
|
-
}]), [this.options.map(function (opt, index) {
|
|
907
|
+
}]), [this.options().map(function (opt, index) {
|
|
912
908
|
var props = _objectSpread2({}, opt);
|
|
913
909
|
|
|
914
910
|
var Type = _this2.type === 'button' ? 'ElRadioButton' : 'ElRadio';
|
|
@@ -1921,6 +1917,7 @@
|
|
|
1921
1917
|
Object.keys(this.formCreate.prop).forEach(function (k) {
|
|
1922
1918
|
extend(_this2.$options[k], _this2.formCreate.prop[k]);
|
|
1923
1919
|
});
|
|
1920
|
+
this.$emit('beforeCreate', this.formCreate.api());
|
|
1924
1921
|
}
|
|
1925
1922
|
};
|
|
1926
1923
|
}
|
|
@@ -2333,11 +2330,6 @@
|
|
|
2333
2330
|
}
|
|
2334
2331
|
|
|
2335
2332
|
var api = {
|
|
2336
|
-
helper: {
|
|
2337
|
-
tidyFields: tidyFields,
|
|
2338
|
-
props: props
|
|
2339
|
-
},
|
|
2340
|
-
|
|
2341
2333
|
get config() {
|
|
2342
2334
|
return h.options;
|
|
2343
2335
|
},
|
|
@@ -2481,6 +2473,12 @@
|
|
|
2481
2473
|
});
|
|
2482
2474
|
h.refresh();
|
|
2483
2475
|
},
|
|
2476
|
+
all: function all(origin) {
|
|
2477
|
+
return Object.keys(h.ctxs).map(function (k) {
|
|
2478
|
+
var ctx = h.ctxs[k];
|
|
2479
|
+
return origin ? ctx.origin : ctx.rule;
|
|
2480
|
+
});
|
|
2481
|
+
},
|
|
2484
2482
|
model: function model(origin) {
|
|
2485
2483
|
return h.fields().reduce(function (initial, key) {
|
|
2486
2484
|
var ctx = h.fieldCtx[key][0];
|
|
@@ -2668,13 +2666,26 @@
|
|
|
2668
2666
|
nextRefresh: function nextRefresh(fn) {
|
|
2669
2667
|
h.nextRefresh();
|
|
2670
2668
|
fn && invoke(fn);
|
|
2669
|
+
},
|
|
2670
|
+
emit: function emit(name) {
|
|
2671
|
+
var _h$vm;
|
|
2672
|
+
|
|
2673
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
2674
|
+
args[_key3 - 1] = arguments[_key3];
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
(_h$vm = h.vm).$emit.apply(_h$vm, [name].concat(args));
|
|
2678
|
+
},
|
|
2679
|
+
helper: {
|
|
2680
|
+
tidyFields: tidyFields,
|
|
2681
|
+
props: props
|
|
2671
2682
|
}
|
|
2672
2683
|
};
|
|
2673
2684
|
['on', 'once', 'off', 'set'].forEach(function (n) {
|
|
2674
2685
|
api[n] = function () {
|
|
2675
|
-
var _h$
|
|
2686
|
+
var _h$vm2;
|
|
2676
2687
|
|
|
2677
|
-
(_h$
|
|
2688
|
+
(_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
|
|
2678
2689
|
};
|
|
2679
2690
|
});
|
|
2680
2691
|
api.changeValue = api.changeField = api.setValue;
|
|
@@ -2899,6 +2910,7 @@
|
|
|
2899
2910
|
renderCtx: function renderCtx(ctx, parent) {
|
|
2900
2911
|
if (ctx.type === 'hidden') return;
|
|
2901
2912
|
var rule = ctx.rule;
|
|
2913
|
+
var preview = this.options.preview || false;
|
|
2902
2914
|
|
|
2903
2915
|
if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
|
|
2904
2916
|
var vn;
|
|
@@ -2949,12 +2961,13 @@
|
|
|
2949
2961
|
vn = this.vm.$scopedSlots[slot]({
|
|
2950
2962
|
rule: rule,
|
|
2951
2963
|
prop: prop,
|
|
2964
|
+
preview: preview,
|
|
2952
2965
|
children: children,
|
|
2953
2966
|
api: this.$handle.api,
|
|
2954
2967
|
model: prop.model || {}
|
|
2955
2968
|
});
|
|
2956
2969
|
} else {
|
|
2957
|
-
vn = ctx.parser.render(children, ctx);
|
|
2970
|
+
vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
|
|
2958
2971
|
}
|
|
2959
2972
|
}
|
|
2960
2973
|
|
|
@@ -3019,20 +3032,22 @@
|
|
|
3019
3032
|
var _this7 = this;
|
|
3020
3033
|
|
|
3021
3034
|
if (!this.vm.ctxInject[ctx.id]) {
|
|
3022
|
-
$set(this.vm.ctxInject, ctx.id, {
|
|
3035
|
+
$set(this.vm.ctxInject, ctx.id, {
|
|
3036
|
+
api: this.$handle.api,
|
|
3037
|
+
form: this.fc.create,
|
|
3038
|
+
subForm: function subForm(_subForm) {
|
|
3039
|
+
_this7.$handle.addSubForm(ctx, _subForm);
|
|
3040
|
+
},
|
|
3041
|
+
field: ctx.field,
|
|
3042
|
+
rule: ctx.rule
|
|
3043
|
+
});
|
|
3023
3044
|
}
|
|
3024
3045
|
|
|
3025
3046
|
var inject = this.vm.ctxInject[ctx.id];
|
|
3026
3047
|
extend(inject, {
|
|
3027
|
-
|
|
3028
|
-
form: this.fc.create,
|
|
3029
|
-
subForm: function subForm(_subForm) {
|
|
3030
|
-
_this7.$handle.addSubForm(ctx, _subForm);
|
|
3031
|
-
},
|
|
3032
|
-
field: ctx.field,
|
|
3048
|
+
preview: this.options.preview || false,
|
|
3033
3049
|
options: ctx.prop.options,
|
|
3034
3050
|
children: ctx.rule.children,
|
|
3035
|
-
rule: ctx.rule,
|
|
3036
3051
|
prop: function () {
|
|
3037
3052
|
var temp = _objectSpread2({}, ctx.prop);
|
|
3038
3053
|
|
|
@@ -3942,6 +3957,7 @@
|
|
|
3942
3957
|
this.refresh();
|
|
3943
3958
|
this.bus.$off('next-tick', this.nextReload);
|
|
3944
3959
|
this.bus.$once('next-tick', this.nextReload);
|
|
3960
|
+
this.vm.$emit('update', this.api);
|
|
3945
3961
|
},
|
|
3946
3962
|
//todo 组件生成全部通过 alias
|
|
3947
3963
|
refresh: function refresh() {
|
|
@@ -3977,7 +3993,7 @@
|
|
|
3977
3993
|
function useInput(Handler) {
|
|
3978
3994
|
extend(Handler.prototype, {
|
|
3979
3995
|
getValue: function getValue(ctx) {
|
|
3980
|
-
if (
|
|
3996
|
+
if (is.Undef(ctx.cacheValue)) {
|
|
3981
3997
|
ctx.cacheValue = ctx.parser.toValue(this.getFormData(ctx), ctx);
|
|
3982
3998
|
}
|
|
3983
3999
|
|
|
@@ -4122,6 +4138,7 @@
|
|
|
4122
4138
|
if (this.refreshControl(ctx)) {
|
|
4123
4139
|
this.$render.clearCacheAll();
|
|
4124
4140
|
this.loadRule();
|
|
4141
|
+
this.vm.$emit('update', this.api);
|
|
4125
4142
|
this.refresh();
|
|
4126
4143
|
}
|
|
4127
4144
|
|
|
@@ -4167,6 +4184,9 @@
|
|
|
4167
4184
|
render: function render(children, ctx) {
|
|
4168
4185
|
return ctx.$render.defaultRender(ctx, children);
|
|
4169
4186
|
},
|
|
4187
|
+
preview: function preview(children, ctx) {
|
|
4188
|
+
return ctx.$render.defaultRender(ctx, children);
|
|
4189
|
+
},
|
|
4170
4190
|
mergeProp: function mergeProp(ctx) {}
|
|
4171
4191
|
};
|
|
4172
4192
|
|
|
@@ -4293,6 +4313,8 @@
|
|
|
4293
4313
|
}
|
|
4294
4314
|
|
|
4295
4315
|
_flag && _this.loadChildren(n, ctx);
|
|
4316
|
+
|
|
4317
|
+
_this.vm.$emit('update', _this.api);
|
|
4296
4318
|
});
|
|
4297
4319
|
}
|
|
4298
4320
|
|
|
@@ -5128,6 +5150,7 @@
|
|
|
5128
5150
|
},
|
|
5129
5151
|
created: function created() {
|
|
5130
5152
|
this.$handle.init();
|
|
5153
|
+
this.vm.$emit('created', this.api());
|
|
5131
5154
|
},
|
|
5132
5155
|
api: function api() {
|
|
5133
5156
|
return this.$handle.api;
|
|
@@ -5571,32 +5594,13 @@
|
|
|
5571
5594
|
return !(!title.title && !title["native"] || isFalse(title.show));
|
|
5572
5595
|
},
|
|
5573
5596
|
makeInfo: function makeInfo(rule, uni) {
|
|
5574
|
-
var _this = this;
|
|
5575
|
-
|
|
5576
5597
|
var titleProp = rule.title;
|
|
5577
5598
|
var infoProp = rule.info;
|
|
5578
5599
|
var isTip = isTooltip(infoProp);
|
|
5579
5600
|
var form = this.options.form;
|
|
5580
5601
|
var children = [(titleProp.title || '') + (form.labelSuffix || form['label-suffix'] || '')];
|
|
5581
5602
|
|
|
5582
|
-
|
|
5583
|
-
return _this.$r(mergeProps([titleProp, {
|
|
5584
|
-
props: titleProp,
|
|
5585
|
-
slot: titleProp.slot || (pop ? isTip ? 'default' : 'reference' : 'label'),
|
|
5586
|
-
key: "".concat(uni, "tit"),
|
|
5587
|
-
type: titleProp.type || 'span'
|
|
5588
|
-
}]), children);
|
|
5589
|
-
};
|
|
5590
|
-
|
|
5591
|
-
if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"])) {
|
|
5592
|
-
if (infoProp.icon !== false) {
|
|
5593
|
-
children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r({
|
|
5594
|
-
type: 'i',
|
|
5595
|
-
"class": infoProp.icon === true ? 'el-icon-warning' : infoProp.icon,
|
|
5596
|
-
key: "".concat(uni, "i")
|
|
5597
|
-
}));
|
|
5598
|
-
}
|
|
5599
|
-
|
|
5603
|
+
if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
|
|
5600
5604
|
var prop = {
|
|
5601
5605
|
type: infoProp.type || 'popover',
|
|
5602
5606
|
props: _objectSpread2({}, infoProp),
|
|
@@ -5609,10 +5613,20 @@
|
|
|
5609
5613
|
prop.props[field] = infoProp.info;
|
|
5610
5614
|
}
|
|
5611
5615
|
|
|
5612
|
-
|
|
5616
|
+
children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), [this.$r({
|
|
5617
|
+
type: 'i',
|
|
5618
|
+
slot: isTip ? 'default' : 'reference',
|
|
5619
|
+
"class": infoProp.icon === true ? 'el-icon-warning' : infoProp.icon,
|
|
5620
|
+
key: "".concat(uni, "i")
|
|
5621
|
+
})]));
|
|
5613
5622
|
}
|
|
5614
5623
|
|
|
5615
|
-
return
|
|
5624
|
+
return this.$r(mergeProps([titleProp, {
|
|
5625
|
+
props: titleProp,
|
|
5626
|
+
slot: titleProp.slot || 'label',
|
|
5627
|
+
key: "".concat(uni, "tit"),
|
|
5628
|
+
type: titleProp.type || 'span'
|
|
5629
|
+
}]), children);
|
|
5616
5630
|
},
|
|
5617
5631
|
makeCol: function makeCol(rule, uni, children) {
|
|
5618
5632
|
var col = rule.col;
|
|
@@ -5662,7 +5676,7 @@
|
|
|
5662
5676
|
}, [item]);
|
|
5663
5677
|
},
|
|
5664
5678
|
makeResetBtn: function makeResetBtn() {
|
|
5665
|
-
var
|
|
5679
|
+
var _this = this;
|
|
5666
5680
|
|
|
5667
5681
|
var resetBtn = this.options.resetBtn;
|
|
5668
5682
|
return this.$r({
|
|
@@ -5673,7 +5687,7 @@
|
|
|
5673
5687
|
},
|
|
5674
5688
|
on: {
|
|
5675
5689
|
click: function click() {
|
|
5676
|
-
var fApi =
|
|
5690
|
+
var fApi = _this.$handle.api;
|
|
5677
5691
|
resetBtn.click ? resetBtn.click(fApi) : fApi.resetFields();
|
|
5678
5692
|
}
|
|
5679
5693
|
},
|
|
@@ -5681,7 +5695,7 @@
|
|
|
5681
5695
|
}, [resetBtn.innerText]);
|
|
5682
5696
|
},
|
|
5683
5697
|
makeSubmitBtn: function makeSubmitBtn() {
|
|
5684
|
-
var
|
|
5698
|
+
var _this2 = this;
|
|
5685
5699
|
|
|
5686
5700
|
var submitBtn = this.options.submitBtn;
|
|
5687
5701
|
return this.$r({
|
|
@@ -5692,7 +5706,7 @@
|
|
|
5692
5706
|
},
|
|
5693
5707
|
on: {
|
|
5694
5708
|
click: function click() {
|
|
5695
|
-
var fApi =
|
|
5709
|
+
var fApi = _this2.$handle.api;
|
|
5696
5710
|
submitBtn.click ? submitBtn.click(fApi) : fApi.submit();
|
|
5697
5711
|
}
|
|
5698
5712
|
},
|
|
@@ -6023,7 +6037,7 @@
|
|
|
6023
6037
|
function elmFormCreate() {
|
|
6024
6038
|
return FormCreateFactory({
|
|
6025
6039
|
ui: "".concat("element-ui"),
|
|
6026
|
-
version: "".concat("2.5.
|
|
6040
|
+
version: "".concat("2.5.13"),
|
|
6027
6041
|
manager: manager,
|
|
6028
6042
|
extendApi: extendApi,
|
|
6029
6043
|
install: install,
|