cy-element-ui 1.0.78 → 1.0.80
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/lib/element-ui.common.js +98 -117
- package/lib/form-item.js +92 -111
- package/lib/index.js +1 -1
- package/package.json +2 -2
- package/packages/form/src/form-item.vue +364 -403
- package/src/index.js +1 -1
package/lib/element-ui.common.js
CHANGED
|
@@ -34499,8 +34499,8 @@ src_form.install = function (Vue) {
|
|
|
34499
34499
|
};
|
|
34500
34500
|
|
|
34501
34501
|
/* harmony default export */ var packages_form = (src_form);
|
|
34502
|
-
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/vue-loader/lib??vue-loader-options!./packages/form/src/form-item.vue?vue&type=template&id=
|
|
34503
|
-
var
|
|
34502
|
+
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/vue-loader/lib??vue-loader-options!./packages/form/src/form-item.vue?vue&type=template&id=90ab37fe
|
|
34503
|
+
var form_itemvue_type_template_id_90ab37fe_render = function render() {
|
|
34504
34504
|
var _vm = this,
|
|
34505
34505
|
_c = _vm._self._c
|
|
34506
34506
|
return _c(
|
|
@@ -34520,33 +34520,54 @@ var form_itemvue_type_template_id_b7de1e82_render = function render() {
|
|
|
34520
34520
|
],
|
|
34521
34521
|
},
|
|
34522
34522
|
[
|
|
34523
|
-
|
|
34524
|
-
|
|
34525
|
-
|
|
34526
|
-
|
|
34527
|
-
|
|
34528
|
-
|
|
34529
|
-
|
|
34530
|
-
|
|
34531
|
-
|
|
34532
|
-
|
|
34533
|
-
|
|
34534
|
-
|
|
34535
|
-
|
|
34536
|
-
|
|
34537
|
-
|
|
34538
|
-
|
|
34539
|
-
|
|
34540
|
-
|
|
34541
|
-
|
|
34542
|
-
|
|
34543
|
-
|
|
34544
|
-
|
|
34545
|
-
|
|
34546
|
-
|
|
34547
|
-
|
|
34548
|
-
|
|
34549
|
-
|
|
34523
|
+
_vm.labelStyle && _vm.labelStyle.width === "auto"
|
|
34524
|
+
? [
|
|
34525
|
+
_c(
|
|
34526
|
+
"div",
|
|
34527
|
+
{
|
|
34528
|
+
staticClass: "el-form-item__label-wrap",
|
|
34529
|
+
style: _vm.labelWrapStyle,
|
|
34530
|
+
},
|
|
34531
|
+
[
|
|
34532
|
+
_vm.label || _vm.$slots.label
|
|
34533
|
+
? _c(
|
|
34534
|
+
"label",
|
|
34535
|
+
{
|
|
34536
|
+
staticClass: "el-form-item__label",
|
|
34537
|
+
style: _vm.labelStyle,
|
|
34538
|
+
attrs: { for: _vm.labelFor },
|
|
34539
|
+
},
|
|
34540
|
+
[
|
|
34541
|
+
_vm._t("label", function () {
|
|
34542
|
+
return [
|
|
34543
|
+
_vm._v(_vm._s(_vm.label + _vm.form.labelSuffix)),
|
|
34544
|
+
]
|
|
34545
|
+
}),
|
|
34546
|
+
],
|
|
34547
|
+
2
|
|
34548
|
+
)
|
|
34549
|
+
: _vm._e(),
|
|
34550
|
+
]
|
|
34551
|
+
),
|
|
34552
|
+
]
|
|
34553
|
+
: [
|
|
34554
|
+
_vm.label || _vm.$slots.label
|
|
34555
|
+
? _c(
|
|
34556
|
+
"label",
|
|
34557
|
+
{
|
|
34558
|
+
staticClass: "el-form-item__label",
|
|
34559
|
+
style: _vm.labelStyle,
|
|
34560
|
+
attrs: { for: _vm.labelFor },
|
|
34561
|
+
},
|
|
34562
|
+
[
|
|
34563
|
+
_vm._t("label", function () {
|
|
34564
|
+
return [_vm._v(_vm._s(_vm.label + _vm.form.labelSuffix))]
|
|
34565
|
+
}),
|
|
34566
|
+
],
|
|
34567
|
+
2
|
|
34568
|
+
)
|
|
34569
|
+
: _vm._e(),
|
|
34570
|
+
],
|
|
34550
34571
|
_c(
|
|
34551
34572
|
"div",
|
|
34552
34573
|
{ staticClass: "el-form-item__content", style: _vm.contentStyle },
|
|
@@ -34595,14 +34616,14 @@ var form_itemvue_type_template_id_b7de1e82_render = function render() {
|
|
|
34595
34616
|
2
|
|
34596
34617
|
),
|
|
34597
34618
|
],
|
|
34598
|
-
|
|
34619
|
+
2
|
|
34599
34620
|
)
|
|
34600
34621
|
}
|
|
34601
|
-
var
|
|
34602
|
-
|
|
34622
|
+
var form_itemvue_type_template_id_90ab37fe_staticRenderFns = []
|
|
34623
|
+
form_itemvue_type_template_id_90ab37fe_render._withStripped = true
|
|
34603
34624
|
|
|
34604
34625
|
|
|
34605
|
-
// CONCATENATED MODULE: ./packages/form/src/form-item.vue?vue&type=template&id=
|
|
34626
|
+
// CONCATENATED MODULE: ./packages/form/src/form-item.vue?vue&type=template&id=90ab37fe
|
|
34606
34627
|
|
|
34607
34628
|
// EXTERNAL MODULE: external "async-validator"
|
|
34608
34629
|
var external_async_validator_ = __webpack_require__(11);
|
|
@@ -34615,81 +34636,6 @@ var external_async_validator_default = /*#__PURE__*/__webpack_require__.n(extern
|
|
|
34615
34636
|
|
|
34616
34637
|
|
|
34617
34638
|
|
|
34618
|
-
var LabelWrap = {
|
|
34619
|
-
props: {
|
|
34620
|
-
isAutoWidth: Boolean,
|
|
34621
|
-
updateAll: Boolean
|
|
34622
|
-
},
|
|
34623
|
-
|
|
34624
|
-
inject: ['elForm', 'elFormItem'],
|
|
34625
|
-
|
|
34626
|
-
render: function render(h) {
|
|
34627
|
-
var slots = this.$slots.default;
|
|
34628
|
-
if (!slots) return null;
|
|
34629
|
-
if (this.isAutoWidth) {
|
|
34630
|
-
var autoLabelWidth = this.elForm.autoLabelWidth;
|
|
34631
|
-
var style = {};
|
|
34632
|
-
if (autoLabelWidth && autoLabelWidth !== 'auto') {
|
|
34633
|
-
var marginLeft = parseInt(autoLabelWidth, 10) - this.computedWidth;
|
|
34634
|
-
if (marginLeft) {
|
|
34635
|
-
style.marginLeft = marginLeft + 'px';
|
|
34636
|
-
}
|
|
34637
|
-
}
|
|
34638
|
-
return h('div', { 'class': 'el-form-item__label-wrap', style: style }, [slots]);
|
|
34639
|
-
} else {
|
|
34640
|
-
return slots[0];
|
|
34641
|
-
}
|
|
34642
|
-
},
|
|
34643
|
-
|
|
34644
|
-
methods: {
|
|
34645
|
-
getLabelWidth: function getLabelWidth() {
|
|
34646
|
-
if (this.$el && this.$el.firstElementChild) {
|
|
34647
|
-
var computedWidth = window.getComputedStyle(this.$el.firstElementChild).width;
|
|
34648
|
-
return Math.ceil(parseFloat(computedWidth));
|
|
34649
|
-
} else {
|
|
34650
|
-
return 0;
|
|
34651
|
-
}
|
|
34652
|
-
},
|
|
34653
|
-
updateLabelWidth: function updateLabelWidth(action) {
|
|
34654
|
-
action = action || 'update';
|
|
34655
|
-
if (this.$slots.default && this.isAutoWidth && this.$el.firstElementChild) {
|
|
34656
|
-
if (action === 'update') {
|
|
34657
|
-
this.computedWidth = this.getLabelWidth();
|
|
34658
|
-
} else if (action === 'remove') {
|
|
34659
|
-
this.elForm.deregisterLabelWidth(this.computedWidth);
|
|
34660
|
-
}
|
|
34661
|
-
}
|
|
34662
|
-
}
|
|
34663
|
-
},
|
|
34664
|
-
|
|
34665
|
-
watch: {
|
|
34666
|
-
computedWidth: function computedWidth(val, oldVal) {
|
|
34667
|
-
if (this.updateAll) {
|
|
34668
|
-
this.elForm.registerLabelWidth(val, oldVal);
|
|
34669
|
-
this.elFormItem.updateComputedLabelWidth(val);
|
|
34670
|
-
}
|
|
34671
|
-
}
|
|
34672
|
-
},
|
|
34673
|
-
|
|
34674
|
-
data: function data() {
|
|
34675
|
-
return {
|
|
34676
|
-
computedWidth: 0
|
|
34677
|
-
};
|
|
34678
|
-
},
|
|
34679
|
-
|
|
34680
|
-
mounted: function mounted() {
|
|
34681
|
-
this.updateLabelWidth('update');
|
|
34682
|
-
},
|
|
34683
|
-
|
|
34684
|
-
updated: function updated() {
|
|
34685
|
-
this.updateLabelWidth('update');
|
|
34686
|
-
},
|
|
34687
|
-
|
|
34688
|
-
beforeDestroy: function beforeDestroy() {
|
|
34689
|
-
this.updateLabelWidth('remove');
|
|
34690
|
-
}
|
|
34691
|
-
};
|
|
34692
|
-
|
|
34693
34639
|
/* harmony default export */ var form_itemvue_type_script_lang_js = ({
|
|
34694
34640
|
name: 'ElFormItem',
|
|
34695
34641
|
|
|
@@ -34728,10 +34674,6 @@ var LabelWrap = {
|
|
|
34728
34674
|
},
|
|
34729
34675
|
size: String
|
|
34730
34676
|
},
|
|
34731
|
-
components: {
|
|
34732
|
-
// use this component to calculate auto width
|
|
34733
|
-
LabelWrap: LabelWrap
|
|
34734
|
-
},
|
|
34735
34677
|
watch: {
|
|
34736
34678
|
error: {
|
|
34737
34679
|
immediate: true,
|
|
@@ -34747,6 +34689,11 @@ var LabelWrap = {
|
|
|
34747
34689
|
if ((!value || value.length === 0) && this.required === undefined) {
|
|
34748
34690
|
this.clearValidate();
|
|
34749
34691
|
}
|
|
34692
|
+
},
|
|
34693
|
+
computedLabelWidth: function computedLabelWidth(val, oldVal) {
|
|
34694
|
+
if (this.form.labelWidth === 'auto') {
|
|
34695
|
+
this.elForm.registerLabelWidth(val, oldVal);
|
|
34696
|
+
}
|
|
34750
34697
|
}
|
|
34751
34698
|
},
|
|
34752
34699
|
computed: {
|
|
@@ -34762,6 +34709,17 @@ var LabelWrap = {
|
|
|
34762
34709
|
}
|
|
34763
34710
|
return ret;
|
|
34764
34711
|
},
|
|
34712
|
+
labelWrapStyle: function labelWrapStyle() {
|
|
34713
|
+
var style = {};
|
|
34714
|
+
var autoLabelWidth = this.elForm.autoLabelWidth;
|
|
34715
|
+
if (autoLabelWidth && autoLabelWidth !== 'auto') {
|
|
34716
|
+
var marginLeft = parseInt(autoLabelWidth, 10) - this.computedLabelWidth;
|
|
34717
|
+
if (marginLeft) {
|
|
34718
|
+
style.marginLeft = marginLeft + 'px';
|
|
34719
|
+
}
|
|
34720
|
+
}
|
|
34721
|
+
return style;
|
|
34722
|
+
},
|
|
34765
34723
|
contentStyle: function contentStyle() {
|
|
34766
34724
|
var ret = {};
|
|
34767
34725
|
var label = this.label;
|
|
@@ -34836,11 +34794,30 @@ var LabelWrap = {
|
|
|
34836
34794
|
validateDisabled: false,
|
|
34837
34795
|
validator: {},
|
|
34838
34796
|
isNested: false,
|
|
34839
|
-
computedLabelWidth:
|
|
34797
|
+
computedLabelWidth: 0
|
|
34840
34798
|
};
|
|
34841
34799
|
},
|
|
34842
34800
|
|
|
34843
34801
|
methods: {
|
|
34802
|
+
getLabelWidth: function getLabelWidth() {
|
|
34803
|
+
if (this.$el && this.$el.querySelector('.el-form-item__label')) {
|
|
34804
|
+
var labelEl = this.$el.querySelector('.el-form-item__label');
|
|
34805
|
+
var computedWidth = window.getComputedStyle(labelEl).width;
|
|
34806
|
+
return Math.ceil(parseFloat(computedWidth));
|
|
34807
|
+
} else {
|
|
34808
|
+
return 0;
|
|
34809
|
+
}
|
|
34810
|
+
},
|
|
34811
|
+
updateLabelWidth: function updateLabelWidth(action) {
|
|
34812
|
+
action = action || 'update';
|
|
34813
|
+
if ((this.label || this.$slots.label) && this.form.labelWidth === 'auto') {
|
|
34814
|
+
if (action === 'update') {
|
|
34815
|
+
this.computedLabelWidth = this.getLabelWidth();
|
|
34816
|
+
} else if (action === 'remove') {
|
|
34817
|
+
this.elForm.deregisterLabelWidth(this.computedLabelWidth);
|
|
34818
|
+
}
|
|
34819
|
+
}
|
|
34820
|
+
},
|
|
34844
34821
|
validate: function validate(trigger) {
|
|
34845
34822
|
var _this = this;
|
|
34846
34823
|
|
|
@@ -34903,7 +34880,6 @@ var LabelWrap = {
|
|
|
34903
34880
|
prop.o[prop.k] = this.initialValue;
|
|
34904
34881
|
}
|
|
34905
34882
|
|
|
34906
|
-
// reset validateDisabled after onFieldChange triggered
|
|
34907
34883
|
this.$nextTick(function () {
|
|
34908
34884
|
_this2.validateDisabled = false;
|
|
34909
34885
|
});
|
|
@@ -34961,6 +34937,7 @@ var LabelWrap = {
|
|
|
34961
34937
|
}
|
|
34962
34938
|
},
|
|
34963
34939
|
mounted: function mounted() {
|
|
34940
|
+
this.updateLabelWidth('update');
|
|
34964
34941
|
if (this.prop) {
|
|
34965
34942
|
this.dispatch('ElForm', 'el.form.addField', [this]);
|
|
34966
34943
|
|
|
@@ -34975,7 +34952,11 @@ var LabelWrap = {
|
|
|
34975
34952
|
this.addValidateEvents();
|
|
34976
34953
|
}
|
|
34977
34954
|
},
|
|
34955
|
+
updated: function updated() {
|
|
34956
|
+
this.updateLabelWidth('update');
|
|
34957
|
+
},
|
|
34978
34958
|
beforeDestroy: function beforeDestroy() {
|
|
34959
|
+
this.updateLabelWidth('remove');
|
|
34979
34960
|
this.dispatch('ElForm', 'el.form.removeField', [this]);
|
|
34980
34961
|
}
|
|
34981
34962
|
});
|
|
@@ -34991,8 +34972,8 @@ var LabelWrap = {
|
|
|
34991
34972
|
|
|
34992
34973
|
var form_item_component = normalizeComponent(
|
|
34993
34974
|
src_form_itemvue_type_script_lang_js,
|
|
34994
|
-
|
|
34995
|
-
|
|
34975
|
+
form_itemvue_type_template_id_90ab37fe_render,
|
|
34976
|
+
form_itemvue_type_template_id_90ab37fe_staticRenderFns,
|
|
34996
34977
|
false,
|
|
34997
34978
|
null,
|
|
34998
34979
|
null,
|
|
@@ -54518,7 +54499,7 @@ if (typeof window !== 'undefined' && window.Vue) {
|
|
|
54518
54499
|
}
|
|
54519
54500
|
|
|
54520
54501
|
/* harmony default export */ var src_0 = __webpack_exports__["default"] = ({
|
|
54521
|
-
version: '1.0.
|
|
54502
|
+
version: '1.0.80',
|
|
54522
54503
|
locale: locale.use,
|
|
54523
54504
|
i18n: locale.i18n,
|
|
54524
54505
|
install: src_install,
|
package/lib/form-item.js
CHANGED
|
@@ -619,7 +619,7 @@ function _broadcast(componentName, eventName, params) {
|
|
|
619
619
|
// ESM COMPAT FLAG
|
|
620
620
|
__webpack_require__.r(__webpack_exports__);
|
|
621
621
|
|
|
622
|
-
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/vue-loader/lib??vue-loader-options!./packages/form/src/form-item.vue?vue&type=template&id=
|
|
622
|
+
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/vue-loader/lib??vue-loader-options!./packages/form/src/form-item.vue?vue&type=template&id=90ab37fe
|
|
623
623
|
var render = function render() {
|
|
624
624
|
var _vm = this,
|
|
625
625
|
_c = _vm._self._c
|
|
@@ -640,33 +640,54 @@ var render = function render() {
|
|
|
640
640
|
],
|
|
641
641
|
},
|
|
642
642
|
[
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
643
|
+
_vm.labelStyle && _vm.labelStyle.width === "auto"
|
|
644
|
+
? [
|
|
645
|
+
_c(
|
|
646
|
+
"div",
|
|
647
|
+
{
|
|
648
|
+
staticClass: "el-form-item__label-wrap",
|
|
649
|
+
style: _vm.labelWrapStyle,
|
|
650
|
+
},
|
|
651
|
+
[
|
|
652
|
+
_vm.label || _vm.$slots.label
|
|
653
|
+
? _c(
|
|
654
|
+
"label",
|
|
655
|
+
{
|
|
656
|
+
staticClass: "el-form-item__label",
|
|
657
|
+
style: _vm.labelStyle,
|
|
658
|
+
attrs: { for: _vm.labelFor },
|
|
659
|
+
},
|
|
660
|
+
[
|
|
661
|
+
_vm._t("label", function () {
|
|
662
|
+
return [
|
|
663
|
+
_vm._v(_vm._s(_vm.label + _vm.form.labelSuffix)),
|
|
664
|
+
]
|
|
665
|
+
}),
|
|
666
|
+
],
|
|
667
|
+
2
|
|
668
|
+
)
|
|
669
|
+
: _vm._e(),
|
|
670
|
+
]
|
|
671
|
+
),
|
|
672
|
+
]
|
|
673
|
+
: [
|
|
674
|
+
_vm.label || _vm.$slots.label
|
|
675
|
+
? _c(
|
|
676
|
+
"label",
|
|
677
|
+
{
|
|
678
|
+
staticClass: "el-form-item__label",
|
|
679
|
+
style: _vm.labelStyle,
|
|
680
|
+
attrs: { for: _vm.labelFor },
|
|
681
|
+
},
|
|
682
|
+
[
|
|
683
|
+
_vm._t("label", function () {
|
|
684
|
+
return [_vm._v(_vm._s(_vm.label + _vm.form.labelSuffix))]
|
|
685
|
+
}),
|
|
686
|
+
],
|
|
687
|
+
2
|
|
688
|
+
)
|
|
689
|
+
: _vm._e(),
|
|
690
|
+
],
|
|
670
691
|
_c(
|
|
671
692
|
"div",
|
|
672
693
|
{ staticClass: "el-form-item__content", style: _vm.contentStyle },
|
|
@@ -715,14 +736,14 @@ var render = function render() {
|
|
|
715
736
|
2
|
|
716
737
|
),
|
|
717
738
|
],
|
|
718
|
-
|
|
739
|
+
2
|
|
719
740
|
)
|
|
720
741
|
}
|
|
721
742
|
var staticRenderFns = []
|
|
722
743
|
render._withStripped = true
|
|
723
744
|
|
|
724
745
|
|
|
725
|
-
// CONCATENATED MODULE: ./packages/form/src/form-item.vue?vue&type=template&id=
|
|
746
|
+
// CONCATENATED MODULE: ./packages/form/src/form-item.vue?vue&type=template&id=90ab37fe
|
|
726
747
|
|
|
727
748
|
// EXTERNAL MODULE: external "async-validator"
|
|
728
749
|
var external_async_validator_ = __webpack_require__(58);
|
|
@@ -744,81 +765,6 @@ var util = __webpack_require__(3);
|
|
|
744
765
|
|
|
745
766
|
|
|
746
767
|
|
|
747
|
-
var LabelWrap = {
|
|
748
|
-
props: {
|
|
749
|
-
isAutoWidth: Boolean,
|
|
750
|
-
updateAll: Boolean
|
|
751
|
-
},
|
|
752
|
-
|
|
753
|
-
inject: ['elForm', 'elFormItem'],
|
|
754
|
-
|
|
755
|
-
render: function render(h) {
|
|
756
|
-
var slots = this.$slots.default;
|
|
757
|
-
if (!slots) return null;
|
|
758
|
-
if (this.isAutoWidth) {
|
|
759
|
-
var autoLabelWidth = this.elForm.autoLabelWidth;
|
|
760
|
-
var style = {};
|
|
761
|
-
if (autoLabelWidth && autoLabelWidth !== 'auto') {
|
|
762
|
-
var marginLeft = parseInt(autoLabelWidth, 10) - this.computedWidth;
|
|
763
|
-
if (marginLeft) {
|
|
764
|
-
style.marginLeft = marginLeft + 'px';
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
return h('div', { 'class': 'el-form-item__label-wrap', style: style }, [slots]);
|
|
768
|
-
} else {
|
|
769
|
-
return slots[0];
|
|
770
|
-
}
|
|
771
|
-
},
|
|
772
|
-
|
|
773
|
-
methods: {
|
|
774
|
-
getLabelWidth: function getLabelWidth() {
|
|
775
|
-
if (this.$el && this.$el.firstElementChild) {
|
|
776
|
-
var computedWidth = window.getComputedStyle(this.$el.firstElementChild).width;
|
|
777
|
-
return Math.ceil(parseFloat(computedWidth));
|
|
778
|
-
} else {
|
|
779
|
-
return 0;
|
|
780
|
-
}
|
|
781
|
-
},
|
|
782
|
-
updateLabelWidth: function updateLabelWidth(action) {
|
|
783
|
-
action = action || 'update';
|
|
784
|
-
if (this.$slots.default && this.isAutoWidth && this.$el.firstElementChild) {
|
|
785
|
-
if (action === 'update') {
|
|
786
|
-
this.computedWidth = this.getLabelWidth();
|
|
787
|
-
} else if (action === 'remove') {
|
|
788
|
-
this.elForm.deregisterLabelWidth(this.computedWidth);
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
},
|
|
793
|
-
|
|
794
|
-
watch: {
|
|
795
|
-
computedWidth: function computedWidth(val, oldVal) {
|
|
796
|
-
if (this.updateAll) {
|
|
797
|
-
this.elForm.registerLabelWidth(val, oldVal);
|
|
798
|
-
this.elFormItem.updateComputedLabelWidth(val);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
},
|
|
802
|
-
|
|
803
|
-
data: function data() {
|
|
804
|
-
return {
|
|
805
|
-
computedWidth: 0
|
|
806
|
-
};
|
|
807
|
-
},
|
|
808
|
-
|
|
809
|
-
mounted: function mounted() {
|
|
810
|
-
this.updateLabelWidth('update');
|
|
811
|
-
},
|
|
812
|
-
|
|
813
|
-
updated: function updated() {
|
|
814
|
-
this.updateLabelWidth('update');
|
|
815
|
-
},
|
|
816
|
-
|
|
817
|
-
beforeDestroy: function beforeDestroy() {
|
|
818
|
-
this.updateLabelWidth('remove');
|
|
819
|
-
}
|
|
820
|
-
};
|
|
821
|
-
|
|
822
768
|
/* harmony default export */ var form_itemvue_type_script_lang_js = ({
|
|
823
769
|
name: 'ElFormItem',
|
|
824
770
|
|
|
@@ -857,10 +803,6 @@ var LabelWrap = {
|
|
|
857
803
|
},
|
|
858
804
|
size: String
|
|
859
805
|
},
|
|
860
|
-
components: {
|
|
861
|
-
// use this component to calculate auto width
|
|
862
|
-
LabelWrap: LabelWrap
|
|
863
|
-
},
|
|
864
806
|
watch: {
|
|
865
807
|
error: {
|
|
866
808
|
immediate: true,
|
|
@@ -876,6 +818,11 @@ var LabelWrap = {
|
|
|
876
818
|
if ((!value || value.length === 0) && this.required === undefined) {
|
|
877
819
|
this.clearValidate();
|
|
878
820
|
}
|
|
821
|
+
},
|
|
822
|
+
computedLabelWidth: function computedLabelWidth(val, oldVal) {
|
|
823
|
+
if (this.form.labelWidth === 'auto') {
|
|
824
|
+
this.elForm.registerLabelWidth(val, oldVal);
|
|
825
|
+
}
|
|
879
826
|
}
|
|
880
827
|
},
|
|
881
828
|
computed: {
|
|
@@ -891,6 +838,17 @@ var LabelWrap = {
|
|
|
891
838
|
}
|
|
892
839
|
return ret;
|
|
893
840
|
},
|
|
841
|
+
labelWrapStyle: function labelWrapStyle() {
|
|
842
|
+
var style = {};
|
|
843
|
+
var autoLabelWidth = this.elForm.autoLabelWidth;
|
|
844
|
+
if (autoLabelWidth && autoLabelWidth !== 'auto') {
|
|
845
|
+
var marginLeft = parseInt(autoLabelWidth, 10) - this.computedLabelWidth;
|
|
846
|
+
if (marginLeft) {
|
|
847
|
+
style.marginLeft = marginLeft + 'px';
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
return style;
|
|
851
|
+
},
|
|
894
852
|
contentStyle: function contentStyle() {
|
|
895
853
|
var ret = {};
|
|
896
854
|
var label = this.label;
|
|
@@ -965,11 +923,30 @@ var LabelWrap = {
|
|
|
965
923
|
validateDisabled: false,
|
|
966
924
|
validator: {},
|
|
967
925
|
isNested: false,
|
|
968
|
-
computedLabelWidth:
|
|
926
|
+
computedLabelWidth: 0
|
|
969
927
|
};
|
|
970
928
|
},
|
|
971
929
|
|
|
972
930
|
methods: {
|
|
931
|
+
getLabelWidth: function getLabelWidth() {
|
|
932
|
+
if (this.$el && this.$el.querySelector('.el-form-item__label')) {
|
|
933
|
+
var labelEl = this.$el.querySelector('.el-form-item__label');
|
|
934
|
+
var computedWidth = window.getComputedStyle(labelEl).width;
|
|
935
|
+
return Math.ceil(parseFloat(computedWidth));
|
|
936
|
+
} else {
|
|
937
|
+
return 0;
|
|
938
|
+
}
|
|
939
|
+
},
|
|
940
|
+
updateLabelWidth: function updateLabelWidth(action) {
|
|
941
|
+
action = action || 'update';
|
|
942
|
+
if ((this.label || this.$slots.label) && this.form.labelWidth === 'auto') {
|
|
943
|
+
if (action === 'update') {
|
|
944
|
+
this.computedLabelWidth = this.getLabelWidth();
|
|
945
|
+
} else if (action === 'remove') {
|
|
946
|
+
this.elForm.deregisterLabelWidth(this.computedLabelWidth);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
},
|
|
973
950
|
validate: function validate(trigger) {
|
|
974
951
|
var _this = this;
|
|
975
952
|
|
|
@@ -1032,7 +1009,6 @@ var LabelWrap = {
|
|
|
1032
1009
|
prop.o[prop.k] = this.initialValue;
|
|
1033
1010
|
}
|
|
1034
1011
|
|
|
1035
|
-
// reset validateDisabled after onFieldChange triggered
|
|
1036
1012
|
this.$nextTick(function () {
|
|
1037
1013
|
_this2.validateDisabled = false;
|
|
1038
1014
|
});
|
|
@@ -1090,6 +1066,7 @@ var LabelWrap = {
|
|
|
1090
1066
|
}
|
|
1091
1067
|
},
|
|
1092
1068
|
mounted: function mounted() {
|
|
1069
|
+
this.updateLabelWidth('update');
|
|
1093
1070
|
if (this.prop) {
|
|
1094
1071
|
this.dispatch('ElForm', 'el.form.addField', [this]);
|
|
1095
1072
|
|
|
@@ -1104,7 +1081,11 @@ var LabelWrap = {
|
|
|
1104
1081
|
this.addValidateEvents();
|
|
1105
1082
|
}
|
|
1106
1083
|
},
|
|
1084
|
+
updated: function updated() {
|
|
1085
|
+
this.updateLabelWidth('update');
|
|
1086
|
+
},
|
|
1107
1087
|
beforeDestroy: function beforeDestroy() {
|
|
1088
|
+
this.updateLabelWidth('remove');
|
|
1108
1089
|
this.dispatch('ElForm', 'el.form.removeField', [this]);
|
|
1109
1090
|
}
|
|
1110
1091
|
});
|