amis 1.9.1-beta.24 → 1.9.1-beta.27
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/index.js +1 -1
- package/lib/renderers/Dialog.d.ts +147 -169
- package/lib/renderers/Dialog.js.map +2 -2
- package/lib/renderers/Form/index.d.ts +4 -4
- package/lib/renderers/Form/index.js +256 -252
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/utils/helper.js +1 -1
- package/lib/utils/helper.js.map +2 -2
- package/package.json +1 -1
- package/sdk/barcode.js +51 -51
- package/sdk/charts.js +14 -14
- package/sdk/codemirror.js +7 -7
- package/sdk/color-picker.js +65 -65
- package/sdk/cropperjs.js +2 -2
- package/sdk/exceljs.js +1 -1
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +16 -16
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk.js +1639 -1638
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +1 -1
- package/sdk/tinymce.js +57 -57
- package/src/renderers/Dialog.tsx +0 -1
- package/src/renderers/Form/index.tsx +18 -25
- package/src/utils/helper.ts +2 -2
package/src/renderers/Dialog.tsx
CHANGED
@@ -943,13 +943,13 @@ export default class Form extends React.Component<FormProps, object> {
|
|
943
943
|
);
|
944
944
|
}
|
945
945
|
|
946
|
-
handleAction(
|
946
|
+
async handleAction(
|
947
947
|
e: React.UIEvent<any> | void,
|
948
948
|
action: Action,
|
949
949
|
data: object,
|
950
950
|
throwErrors: boolean = false,
|
951
951
|
delegate?: IScopedContext
|
952
|
-
): any {
|
952
|
+
): Promise<any> {
|
953
953
|
const {
|
954
954
|
store,
|
955
955
|
onSubmit,
|
@@ -987,38 +987,31 @@ export default class Form extends React.Component<FormProps, object> {
|
|
987
987
|
if (data === this.props.data) {
|
988
988
|
data = store.data;
|
989
989
|
}
|
990
|
+
|
990
991
|
if (Array.isArray(action.required) && action.required.length) {
|
991
992
|
store.clearErrors(); // 如果是按钮指定了required,则校验前先清空一下遗留的校验报错
|
992
|
-
|
993
993
|
const fields = action.required.map(item => ({
|
994
994
|
name: item,
|
995
995
|
rules: {isRequired: true}
|
996
996
|
}));
|
997
|
+
const validationRes = await store.validateFields(fields);
|
997
998
|
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
);
|
1004
|
-
if (!dispatcher?.prevented) {
|
1005
|
-
env.notify('error', __('Form.validateFailed'));
|
1006
|
-
}
|
999
|
+
if (!validationRes) {
|
1000
|
+
const dispatcher = await dispatchEvent(
|
1001
|
+
'validateError',
|
1002
|
+
this.props.data
|
1003
|
+
);
|
1007
1004
|
|
1008
|
-
|
1009
|
-
|
1010
|
-
} else {
|
1011
|
-
dispatchEvent('validateSucc', this.props.data);
|
1012
|
-
this.handleAction(
|
1013
|
-
e,
|
1014
|
-
{...action, required: undefined},
|
1015
|
-
data,
|
1016
|
-
throwErrors,
|
1017
|
-
delegate
|
1018
|
-
);
|
1019
|
-
return;
|
1005
|
+
if (!dispatcher?.prevented) {
|
1006
|
+
env.notify('error', __('Form.validateFailed'));
|
1020
1007
|
}
|
1021
|
-
|
1008
|
+
|
1009
|
+
/** 抛异常是为了在dialog中catch这个错误,避免弹窗直接关闭 */
|
1010
|
+
return Promise.reject(__('Form.validateFailed'));
|
1011
|
+
} else {
|
1012
|
+
/** 重置validated状态,保证submit时触发表单中的校验项 */
|
1013
|
+
store.clearErrors();
|
1014
|
+
}
|
1022
1015
|
}
|
1023
1016
|
if (
|
1024
1017
|
action.type === 'submit' ||
|
package/src/utils/helper.ts
CHANGED
@@ -22,7 +22,7 @@ import {
|
|
22
22
|
resolveVariable,
|
23
23
|
resolveVariableAndFilter
|
24
24
|
} from 'amis-formula';
|
25
|
-
import {isObservable} from 'mobx';
|
25
|
+
import {isObservable, isObservableArray} from 'mobx';
|
26
26
|
|
27
27
|
export {
|
28
28
|
createObject,
|
@@ -937,7 +937,7 @@ export function everyTree<T extends TreeItem>(
|
|
937
937
|
paths: Array<T> = [],
|
938
938
|
indexes: Array<number> = []
|
939
939
|
): boolean {
|
940
|
-
if (!Array.isArray(tree)) {
|
940
|
+
if (!Array.isArray(tree) && !isObservableArray(tree)) {
|
941
941
|
return false;
|
942
942
|
}
|
943
943
|
return tree.every((item, index) => {
|