Skip to content

Commit b6a4525

Browse files
committed
build(lib): build lib
1 parent 4b7accc commit b6a4525

File tree

4 files changed

+122
-110
lines changed

4 files changed

+122
-110
lines changed

packages/lib/dist/vueJsonSchemaForm.esm.js

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ function localizeZh(errors) {
266266
}
267267
}
268268

269-
/**
270-
* Created by Liu.Jun on 2020/4/30 11:22.
269+
/**
270+
* Created by Liu.Jun on 2020/4/30 11:22.
271271
*/
272272
var i18n = {
273273
$$currentLocalizeFn: localizeZh,
@@ -8246,7 +8246,8 @@ function validateFormDataAndTransformMsg() {
82468246
isOnlyFirstError = _ref2$isOnlyFirstErro === void 0 ? true : _ref2$isOnlyFirstErro;
82478247
// 如果数组类型针对配置了 format 的特殊处理
82488248

8249-
var isEmpty = formData === undefined || schema.type === 'array' && schema.format && Array.isArray(formData) && formData.length === 0;
8249+
var emptyArray = schema.type === 'array' && Array.isArray(formData) && formData.length === 0;
8250+
var isEmpty = formData === undefined || emptyArray;
82508251

82518252
if (required) {
82528253
if (isEmpty) {
@@ -8272,7 +8273,7 @@ function validateFormDataAndTransformMsg() {
82728273

82738274
return [requireErrObj];
82748275
}
8275-
} else if (isEmpty) {
8276+
} else if (isEmpty && !emptyArray) {
82768277
// 非required 为空 校验通过
82778278
return [];
82788279
} // 校验ajv错误信息
@@ -9414,15 +9415,20 @@ var __vue_render__$1 = function() {
94149415
var _c = _vm._self._c || _h;
94159416
return _c(
94169417
"el-checkbox-group",
9417-
{
9418-
model: {
9419-
value: _vm.checkList,
9420-
callback: function($$v) {
9421-
_vm.checkList = $$v;
9422-
},
9423-
expression: "checkList"
9424-
}
9425-
},
9418+
_vm._b(
9419+
{
9420+
model: {
9421+
value: _vm.checkList,
9422+
callback: function($$v) {
9423+
_vm.checkList = $$v;
9424+
},
9425+
expression: "checkList"
9426+
}
9427+
},
9428+
"el-checkbox-group",
9429+
_vm.$attrs,
9430+
false
9431+
),
94269432
_vm._l(_vm.enumOptions, function(item, index) {
94279433
return _c("el-checkbox", { key: index, attrs: { label: item.value } }, [
94289434
_vm._v(_vm._s(item.label))
@@ -9874,7 +9880,6 @@ var UploadWidget = {
98749880
}, [slots.tip]));
98759881
}
98769882

9877-
window.childVNode = childVNode;
98789883
return h('el-upload', data, childVNode);
98799884
}
98809885
};
@@ -10862,8 +10867,18 @@ var ArrayField = {
1086210867

1086310868
if (!schema.hasOwnProperty('items')) {
1086410869
throw new Error("[".concat(schema, "] \u8BF7\u5148\u5B9A\u4E49 items\u5C5E\u6027"));
10870+
} // 多选类型
10871+
10872+
10873+
if (isMultiSelect(schema, rootSchema)) {
10874+
// item 为枚举固定值
10875+
return h(ArrayFieldMultiSelect, {
10876+
props: this.$props,
10877+
class: _defineProperty({}, lowerCase(ArrayFieldMultiSelect.name), true)
10878+
});
1086510879
} // 特殊处理 date datetime time url-upload
10866-
// array 支持配置 ui:widget
10880+
// array 支持配置 ui:widget
10881+
// 时间日期区间 或者 ui:widget 特殊配置
1086710882

1086810883

1086910884
if (schema.format || schema['ui:widget'] || uiSchema['ui:widget']) {
@@ -10872,22 +10887,10 @@ var ArrayField = {
1087210887
class: _defineProperty({}, lowerCase(ArrayFieldSpecialFormat.name), true)
1087310888
});
1087410889
} // https://json-schema.org/understanding-json-schema/reference/array.html#list-validation
10890+
// https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation
1087510891

1087610892

10877-
var CurrentField = ArrayFieldNormal;
10878-
10879-
if (isFixedItems(schema)) {
10880-
// https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation
10881-
CurrentField = ArrayFieldTuple;
10882-
} else if (isMultiSelect(schema, rootSchema)) {
10883-
// item 为枚举固定值
10884-
CurrentField = ArrayFieldMultiSelect;
10885-
return h(ArrayFieldMultiSelect, {
10886-
props: this.$props,
10887-
class: _defineProperty({}, lowerCase(ArrayFieldMultiSelect.name), true)
10888-
});
10889-
}
10890-
10893+
var CurrentField = isFixedItems(schema) ? ArrayFieldTuple : ArrayFieldNormal;
1089110894
return h('div', [h(CurrentField, {
1089210895
props: _objectSpread2({
1089310896
itemsFormData: this.itemsFormData
@@ -10946,8 +10949,8 @@ var SelectLinkageField = {
1094610949

1094710950
return this.curSelectIndex || 0;
1094810951
},
10949-
// 下拉选项 Vnode
10950-
getSelectBoxVnode: function getSelectBoxVnode() {
10952+
// 下拉选项 VNode
10953+
getSelectBoxVNode: function getSelectBoxVNode() {
1095110954
var _this = this;
1095210955

1095310956
// 下拉选项参数
@@ -10985,7 +10988,7 @@ var SelectLinkageField = {
1098510988
};
1098610989
});
1098710990
} // oneOf option 渲染
10988-
// 选择框 vnode
10991+
// 选择框 VNode
1098910992

1099010993

1099110994
return this.$createElement(Widget, {
@@ -11008,35 +11011,38 @@ var SelectLinkageField = {
1100811011
// 如果object 类型 option有添加属性 这里做移除
1100911012
// 对新option计算默认值
1101011013
curSelectIndex: function curSelectIndex(newVal, oldVal) {
11011-
var curFormData = getPathVal(this.rootFormData, this.curNodePath); // 移除旧key
11014+
var curFormData = getPathVal(this.rootFormData, this.curNodePath); // 计算出 新选项默认值
11015+
11016+
var newOptionData = getDefaultFormState(this.selectList[newVal], undefined, this.rootSchema);
11017+
var hasOwn = Object.prototype.hasOwnProperty; // 移除旧key
1101211018

1101311019
if (isObject(curFormData)) {
1101411020
var oldSelectSchema = retrieveSchema(this.selectList[oldVal], this.rootSchema);
1101511021

11016-
if (oldSelectSchema.type === 'object' || oldSelectSchema.properties) {
11022+
if (getSchemaType(oldSelectSchema) === 'object') {
1101711023
// 移除旧schema添加的属性
1101811024
// Object.keys(oldSelectSchema.properties)
1101911025
for (var key in oldSelectSchema.properties) {
11020-
if (Object.prototype.hasOwnProperty.call(oldSelectSchema.properties, key)) {
11026+
if (hasOwn.call(oldSelectSchema.properties, key) && !hasOwn.call(newOptionData, key)) {
1102111027
deletePathVal(curFormData, key); // delete curFormData[key];
1102211028
}
1102311029
}
1102411030
}
1102511031
} // 设置新值
1102611032

1102711033

11028-
var newOptionValue = getDefaultFormState(this.selectList[newVal], undefined, this.rootSchema);
11029-
11030-
if (guessType(newOptionValue) === 'object') {
11031-
Object.entries(newOptionValue).forEach(function (_ref) {
11034+
if (isObject(newOptionData)) {
11035+
Object.entries(newOptionData).forEach(function (_ref) {
1103211036
var _ref2 = _slicedToArray(_ref, 2),
1103311037
key = _ref2[0],
1103411038
value = _ref2[1];
1103511039

11036-
setPathVal(curFormData, key, value);
11040+
if (value !== undefined) {
11041+
setPathVal(curFormData, key, value);
11042+
}
1103711043
});
1103811044
} else {
11039-
setPathVal(this.rootFormData, this.curNodePath, newOptionValue || curFormData);
11045+
setPathVal(this.rootFormData, this.curNodePath, newOptionData || curFormData);
1104011046
}
1104111047
}
1104211048
},
@@ -11047,15 +11053,15 @@ var SelectLinkageField = {
1104711053
var curNodePath = this.$props.curNodePath;
1104811054
var pathClassName = nodePath2ClassName(curNodePath); // object 需要保持原有属性,如果存在原有属性这里单独渲染
1104911055

11050-
var originVnode = null;
11056+
var originVNode = null;
1105111057
var isTypeObject = this.schema.type === 'object' || this.schema.properties;
1105211058

1105311059
if (isTypeObject && !isEmptyObject(this.schema.properties)) {
1105411060
var _class2;
1105511061

1105611062
var origSchema = Object.assign({}, this.schema);
1105711063
delete origSchema[this.combiningType];
11058-
originVnode = h(SchemaField, {
11064+
originVNode = h(SchemaField, {
1105911065
key: "origin_".concat(this.combiningType),
1106011066
class: (_class2 = {}, _defineProperty(_class2, "".concat(this.combiningType, "_originBox"), true), _defineProperty(_class2, "".concat(pathClassName, "-originBox"), true), _class2),
1106111067
props: _objectSpread2(_objectSpread2({}, this.$props), {}, {
@@ -11066,7 +11072,7 @@ var SelectLinkageField = {
1106611072
} // 选择附加的节点
1106711073

1106811074

11069-
var childrenVnodeList = [this.getSelectBoxVnode()]; // 当前选中的 oneOf 附加的节点
11075+
var childrenVNodeList = [this.getSelectBoxVNode()]; // 当前选中的 oneOf 附加的节点
1107011076

1107111077
var curSelectSchema = this.selectList[this.curSelectIndex];
1107211078

@@ -11099,7 +11105,7 @@ var SelectLinkageField = {
1109911105
}), function (key) {
1110011106
return key === _this2.combiningType ? undefined : "err:".concat(key);
1110111107
});
11102-
childrenVnodeList.push(h(SchemaField, {
11108+
childrenVNodeList.push(h(SchemaField, {
1110311109
key: "appendSchema_".concat(this.combiningType),
1110411110
props: _objectSpread2(_objectSpread2({}, this.$props), {}, {
1110511111
schema: _objectSpread2({
@@ -11113,10 +11119,10 @@ var SelectLinkageField = {
1111311119

1111411120
})
1111511121
}));
11116-
} // oneOf 校验 vnode
11122+
} // oneOf 校验 VNode
1111711123

1111811124

11119-
childrenVnodeList.push(h(Widget, {
11125+
childrenVNodeList.push(h(Widget, {
1112011126
class: _defineProperty({
1112111127
validateWidget: true
1112211128
}, "validateWidget-".concat(this.combiningType), true),
@@ -11128,12 +11134,12 @@ var SelectLinkageField = {
1112811134
rootFormData: this.rootFormData
1112911135
}
1113011136
}));
11131-
return h('div', [originVnode, h('div', {
11137+
return h('div', [originVNode, h('div', {
1113211138
key: "appendBox_".concat(this.combiningType),
1113311139
class: (_class4 = {
1113411140
appendCombining_box: true
1113511141
}, _defineProperty(_class4, "".concat(this.combiningType, "_appendBox"), true), _defineProperty(_class4, "".concat(pathClassName, "-appendBox"), true), _class4)
11136-
}, childrenVnodeList)]);
11142+
}, childrenVNodeList)]);
1113711143
}
1113811144
};
1113911145

@@ -11171,8 +11177,8 @@ var OneOfField = {
1117111177
}
1117211178
};
1117311179

11174-
/**
11175-
* Created by Liu.Jun on 2020/4/20 9:55 下午.
11180+
/**
11181+
* Created by Liu.Jun on 2020/4/20 9:55 下午.
1117611182
*/
1117711183

1117811184
var FIELDS_MAPS = {
@@ -11632,8 +11638,8 @@ var formUtils = /*#__PURE__*/Object.freeze({
1163211638
optionsList: optionsList
1163311639
});
1163411640

11635-
/**
11636-
* Created by Liu.Jun on 2020/4/16 10:47 下午.
11641+
/**
11642+
* Created by Liu.Jun on 2020/4/16 10:47 下午.
1163711643
*/
1163811644
var vueProps$1 = {
1163911645
formFooter: {

0 commit comments

Comments
 (0)