@blueking/bkui-form 0.0.4 → 0.0.5
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/bkui-form-umd-min.js +7 -7
- package/dist/bkui-form-umd.js +69 -18
- package/dist/bkui-form-umd.js.map +1 -1
- package/dist/bkui-form.css +38 -0
- package/dist/types/bkui-form.d.ts +1 -1
- package/package.json +1 -1
package/dist/bkui-form-umd.js
CHANGED
|
@@ -9322,7 +9322,7 @@
|
|
|
9322
9322
|
var formItem = widgetTree.widgetMap[path];
|
|
9323
9323
|
if (!formItem) return true;
|
|
9324
9324
|
var instance = formItem.instance;
|
|
9325
|
-
var ownSchema = instance.schema; // json schema
|
|
9325
|
+
var ownSchema = instance.schema; // json schema 规则校验
|
|
9326
9326
|
|
|
9327
9327
|
var schemaValidate = ajv.compile(ownSchema);
|
|
9328
9328
|
var value = instance.value === undefined ? initializationValue(ownSchema.type, {
|
|
@@ -9334,20 +9334,19 @@
|
|
|
9334
9334
|
if (!schemaValid) {
|
|
9335
9335
|
var _schemaValidate$error;
|
|
9336
9336
|
|
|
9337
|
-
instance.setState('error', true);
|
|
9338
|
-
instance.setErrorTips((_schemaValidate$error = schemaValidate.errors) === null || _schemaValidate$error === void 0 ? void 0 : _schemaValidate$error.map(function (err) {
|
|
9337
|
+
instance === null || instance === void 0 ? void 0 : instance.setState('error', true);
|
|
9338
|
+
instance === null || instance === void 0 ? void 0 : instance.setErrorTips((_schemaValidate$error = schemaValidate.errors) === null || _schemaValidate$error === void 0 ? void 0 : _schemaValidate$error.map(function (err) {
|
|
9339
9339
|
return err.message;
|
|
9340
9340
|
}));
|
|
9341
9341
|
return false;
|
|
9342
9342
|
}
|
|
9343
9343
|
|
|
9344
|
-
var customRules = (_instance$schema = instance.schema) === null || _instance$schema === void 0 ? void 0 : _instance$schema[OWN_RULE_PROPERTY]; //
|
|
9344
|
+
var customRules = (_instance$schema = instance.schema) === null || _instance$schema === void 0 ? void 0 : _instance$schema[OWN_RULE_PROPERTY]; // 如果不存在自定义规则校验,不进行校验
|
|
9345
9345
|
|
|
9346
9346
|
if (!customRules) {
|
|
9347
|
-
instance.setState('error', false);
|
|
9348
|
-
instance.setErrorTips('');
|
|
9349
9347
|
return true;
|
|
9350
9348
|
}
|
|
9349
|
+
|
|
9351
9350
|
var isError = false;
|
|
9352
9351
|
var errorMsg = '';
|
|
9353
9352
|
|
|
@@ -9371,8 +9370,27 @@
|
|
|
9371
9370
|
_iterator.f();
|
|
9372
9371
|
}
|
|
9373
9372
|
|
|
9374
|
-
instance.setState('error', isError);
|
|
9375
|
-
instance.setErrorTips(errorMsg);
|
|
9373
|
+
instance === null || instance === void 0 ? void 0 : instance.setState('error', isError);
|
|
9374
|
+
instance === null || instance === void 0 ? void 0 : instance.setErrorTips(errorMsg); // 如果实例属于某个组,则沿着 path 向上查找,如果找到组且组的 verifiable 设置为 true,则通过实例的校验状态改变组的校验状态
|
|
9375
|
+
// TODO submit 时校验,change 时去掉错误
|
|
9376
|
+
|
|
9377
|
+
var widgetPaths = path.split('.');
|
|
9378
|
+
var fieldTitleBreadcrumb = [];
|
|
9379
|
+
widgetPaths.forEach(function (thePath, thePathIndex) {
|
|
9380
|
+
var currentPaths = widgetPaths.slice(0, widgetPaths.length - thePathIndex);
|
|
9381
|
+
var widgetPath = currentPaths.join('.');
|
|
9382
|
+
var theWidget = widgetTree.widgetMap[widgetPath];
|
|
9383
|
+
fieldTitleBreadcrumb.push(theWidget.instance.schema.title || currentPaths.pop());
|
|
9384
|
+
|
|
9385
|
+
if (theWidget.instance.verifiable && theWidget.type === 'group') {
|
|
9386
|
+
if (isError) {
|
|
9387
|
+
var groupErrors = "".concat(fieldTitleBreadcrumb.reverse().join('-'), ": ").concat(errorMsg);
|
|
9388
|
+
theWidget.instance.setGroupErrorTips(path, groupErrors);
|
|
9389
|
+
} else {
|
|
9390
|
+
theWidget.instance.removeGroupErrorTips(path);
|
|
9391
|
+
}
|
|
9392
|
+
}
|
|
9393
|
+
});
|
|
9376
9394
|
return !isError;
|
|
9377
9395
|
};
|
|
9378
9396
|
/**
|
|
@@ -9381,13 +9399,7 @@
|
|
|
9381
9399
|
|
|
9382
9400
|
var validateForm = function validateForm() {
|
|
9383
9401
|
var isValid = true;
|
|
9384
|
-
Object.keys(widgetTree.widgetMap).
|
|
9385
|
-
var _ref = widgetTree.widgetMap[path] || {},
|
|
9386
|
-
type = _ref.type; // todo 组类型校验
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
return type === 'node';
|
|
9390
|
-
}).forEach(function (path) {
|
|
9402
|
+
Object.keys(widgetTree.widgetMap).forEach(function (path) {
|
|
9391
9403
|
if (!validateFormItem(path)) isValid = false;
|
|
9392
9404
|
});
|
|
9393
9405
|
return isValid;
|
|
@@ -10150,8 +10162,17 @@
|
|
|
10150
10162
|
border: {
|
|
10151
10163
|
type: Boolean,
|
|
10152
10164
|
default: false
|
|
10165
|
+
},
|
|
10166
|
+
verifiable: {
|
|
10167
|
+
type: Boolean,
|
|
10168
|
+
default: false
|
|
10153
10169
|
}
|
|
10154
10170
|
}),
|
|
10171
|
+
data: function data() {
|
|
10172
|
+
return {
|
|
10173
|
+
groupErrorTips: {}
|
|
10174
|
+
};
|
|
10175
|
+
},
|
|
10155
10176
|
created: function created() {
|
|
10156
10177
|
// 注册widget TreeNode
|
|
10157
10178
|
widgetTree.addWidgetNode(this.path, this, 'group');
|
|
@@ -10159,8 +10180,20 @@
|
|
|
10159
10180
|
beforeDestroy: function beforeDestroy() {
|
|
10160
10181
|
widgetTree.removeWidgetNode(this.path, this);
|
|
10161
10182
|
},
|
|
10183
|
+
methods: {
|
|
10184
|
+
setGroupErrorTips: function setGroupErrorTips(widgetPath, errorTips) {
|
|
10185
|
+
this.$set(this.groupErrorTips, widgetPath, errorTips);
|
|
10186
|
+
},
|
|
10187
|
+
removeGroupErrorTips: function removeGroupErrorTips(widgetPath) {
|
|
10188
|
+
this.$delete(this.groupErrorTips, widgetPath);
|
|
10189
|
+
}
|
|
10190
|
+
},
|
|
10162
10191
|
render: function render(h) {
|
|
10163
|
-
var _this$layout,
|
|
10192
|
+
var _this$layout,
|
|
10193
|
+
_this$layout2,
|
|
10194
|
+
_this$schema,
|
|
10195
|
+
_this$layout3,
|
|
10196
|
+
_this = this;
|
|
10164
10197
|
|
|
10165
10198
|
var schemaFormStyle = _objectSpread2({
|
|
10166
10199
|
position: 'relative',
|
|
@@ -10193,12 +10226,22 @@
|
|
|
10193
10226
|
};
|
|
10194
10227
|
|
|
10195
10228
|
var title = ((_this$schema = this.schema) === null || _this$schema === void 0 ? void 0 : _this$schema.title) || ((_this$layout3 = this.layout) === null || _this$layout3 === void 0 ? void 0 : _this$layout3.prop);
|
|
10229
|
+
var groupErrorTipsContent = Object.keys(this.groupErrorTips).map(function (widgetPath) {
|
|
10230
|
+
return h("p", [_this.groupErrorTips[widgetPath]]);
|
|
10231
|
+
});
|
|
10232
|
+
var hasError = JSON.stringify(this.groupErrorTips) !== '{}';
|
|
10196
10233
|
return h("div", {
|
|
10197
|
-
"class": ['bk-schema-form-group', this.type
|
|
10234
|
+
"class": ['bk-schema-form-group', this.type, {
|
|
10235
|
+
'bk-schema-form-group--error': hasError
|
|
10236
|
+
}],
|
|
10198
10237
|
"style": schemaFormStyle
|
|
10199
10238
|
}, [title && this.showTitle ? h("span", {
|
|
10200
10239
|
"class": ['bk-schema-form-group-title', this.type]
|
|
10201
|
-
}, [title
|
|
10240
|
+
}, [title, hasError ? h("span", {
|
|
10241
|
+
"class": "bk-schema-form-group__error-tips"
|
|
10242
|
+
}, [h("span", {
|
|
10243
|
+
"class": "bk-schema-form-group__error-tips-popover"
|
|
10244
|
+
}, [groupErrorTipsContent])]) : null]) : null, h("div", {
|
|
10202
10245
|
"style": groupContentStyle,
|
|
10203
10246
|
"class": "bk-schema-form-group-content"
|
|
10204
10247
|
}, [this.$slots.default]), this.removeable && renderDelete()]);
|
|
@@ -10387,6 +10430,10 @@
|
|
|
10387
10430
|
border: {
|
|
10388
10431
|
type: Boolean,
|
|
10389
10432
|
default: false
|
|
10433
|
+
},
|
|
10434
|
+
verifiable: {
|
|
10435
|
+
type: Boolean,
|
|
10436
|
+
default: false
|
|
10390
10437
|
}
|
|
10391
10438
|
}),
|
|
10392
10439
|
render: function render(h) {
|
|
@@ -10463,6 +10510,10 @@
|
|
|
10463
10510
|
default: function _default() {
|
|
10464
10511
|
return [];
|
|
10465
10512
|
}
|
|
10513
|
+
},
|
|
10514
|
+
verifiable: {
|
|
10515
|
+
type: Boolean,
|
|
10516
|
+
default: false
|
|
10466
10517
|
}
|
|
10467
10518
|
}),
|
|
10468
10519
|
data: function data() {
|