amis-core 3.5.2 → 3.6.0
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/esm/Root.js +1 -1
- package/esm/RootRenderer.d.ts +1 -1
- package/esm/RootRenderer.js +2 -2
- package/esm/SchemaRenderer.js +1 -1
- package/esm/Scoped.d.ts +2 -0
- package/esm/Scoped.js +49 -7
- package/esm/StatusScoped.js +1 -1
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +27 -12
- package/esm/actions/Action.js +30 -22
- package/esm/actions/AjaxAction.js +2 -2
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.js +31 -32
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +3 -3
- package/esm/actions/CustomAction.js +1 -1
- package/esm/actions/DialogAction.js +1 -1
- package/esm/actions/DrawerAction.js +1 -1
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/LinkAction.js +5 -5
- package/esm/actions/LoopAction.js +1 -1
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/StatusAction.js +1 -1
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +3 -3
- package/esm/components/CustomStyle.js +1 -1
- package/esm/components/ErrorBoundary.d.ts +20 -0
- package/esm/components/ErrorBoundary.js +41 -0
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.js +1 -1
- package/esm/components/PopOver.d.ts +4 -0
- package/esm/components/PopOver.js +66 -3
- package/esm/env.d.ts +9 -0
- package/esm/env.js +1 -1
- package/esm/envOverwrite.d.ts +1 -1
- package/esm/envOverwrite.js +15 -35
- package/esm/factory.js +1 -1
- package/esm/index.d.ts +2 -1
- package/esm/index.js +5 -4
- package/esm/locale.js +1 -1
- package/esm/polyfills.js +1 -1
- package/esm/renderers/Form.d.ts +10 -4
- package/esm/renderers/Form.js +64 -32
- package/esm/renderers/Item.d.ts +54 -0
- package/esm/renderers/Item.js +1 -1
- package/esm/renderers/Options.d.ts +5 -1
- package/esm/renderers/Options.js +11 -9
- package/esm/renderers/Placeholder.js +1 -1
- package/esm/renderers/builtin.js +1 -1
- package/esm/renderers/register.js +1 -1
- package/esm/renderers/wrapControl.js +10 -17
- package/esm/store/app.js +1 -1
- package/esm/store/combo.d.ts +1154 -48
- package/esm/store/combo.js +10 -3
- package/esm/store/crud.d.ts +9 -1
- package/esm/store/crud.js +50 -15
- package/esm/store/form.d.ts +480 -20
- package/esm/store/form.js +1 -1
- package/esm/store/formItem.d.ts +23 -1
- package/esm/store/formItem.js +103 -15
- package/esm/store/iRenderer.js +1 -1
- package/esm/store/index.js +1 -1
- package/esm/store/list.js +1 -1
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.js +1 -1
- package/esm/store/root.js +1 -1
- package/esm/store/service.js +1 -1
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +1078 -42
- package/esm/store/table.js +64 -6
- package/esm/store/table2.js +1 -4
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +8 -2
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.js +1 -1
- package/esm/utils/DataScope.js +1 -1
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.js +1 -1
- package/esm/utils/arraySlice.js +1 -1
- package/esm/utils/attachmentAdpator.js +3 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/dataMapping.js +1 -1
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.js +1 -1
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.js +1 -1
- package/esm/utils/errors.js +1 -1
- package/esm/utils/escapeHtml.js +1 -1
- package/esm/utils/filter-schema.d.ts +2 -1
- package/esm/utils/filter-schema.js +14 -5
- package/esm/utils/filter.js +1 -1
- package/esm/utils/formatDuration.js +1 -1
- package/esm/utils/formula.js +1 -1
- package/esm/utils/getVariable.js +1 -1
- package/esm/utils/grammar.js +1 -1
- package/esm/utils/handleAction.js +1 -1
- package/esm/utils/helper.d.ts +2 -2
- package/esm/utils/helper.js +37 -29
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.js +1 -1
- package/esm/utils/image.js +1 -1
- package/esm/utils/isPureVariable.js +1 -1
- package/esm/utils/json-schema-2-amis-schema.js +1 -1
- package/esm/utils/keyToPath.js +1 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/math.js +8 -5
- package/esm/utils/memoryParse.js +1 -1
- package/esm/utils/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.js +15 -1
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +1 -1
- package/esm/utils/position.js +1 -1
- package/esm/utils/prettyBytes.js +1 -1
- package/esm/utils/renderer-event.d.ts +7 -0
- package/esm/utils/renderer-event.js +30 -18
- package/esm/utils/replaceText.js +1 -1
- package/esm/utils/resize-sensor.js +1 -1
- package/esm/utils/resolveCondition.js +1 -1
- package/esm/utils/resolveVariable.js +1 -1
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
- package/esm/utils/scrollPosition.js +1 -1
- package/esm/utils/string2regExp.js +1 -1
- package/esm/utils/stripNumber.js +1 -1
- package/esm/utils/style-helper.js +12 -15
- package/esm/utils/style.js +3 -2
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.js +1 -1
- package/esm/utils/tpl-lodash.js +1 -1
- package/esm/utils/tpl.js +1 -1
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validations.js +1 -1
- package/lib/Root.js +1 -1
- package/lib/RootRenderer.d.ts +1 -1
- package/lib/RootRenderer.js +2 -2
- package/lib/SchemaRenderer.js +1 -1
- package/lib/Scoped.d.ts +2 -0
- package/lib/Scoped.js +48 -6
- package/lib/StatusScoped.js +1 -1
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +26 -11
- package/lib/actions/Action.js +29 -21
- package/lib/actions/AjaxAction.js +2 -2
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.js +31 -32
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +3 -3
- package/lib/actions/CustomAction.js +1 -1
- package/lib/actions/DialogAction.js +1 -1
- package/lib/actions/DrawerAction.js +1 -1
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/LinkAction.js +5 -5
- package/lib/actions/LoopAction.js +1 -1
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/StatusAction.js +1 -1
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +3 -3
- package/lib/components/CustomStyle.js +1 -1
- package/lib/components/ErrorBoundary.d.ts +20 -0
- package/lib/components/ErrorBoundary.js +52 -0
- package/lib/components/LazyComponent.js +1 -1
- package/lib/components/Overlay.js +1 -1
- package/lib/components/PopOver.d.ts +4 -0
- package/lib/components/PopOver.js +64 -1
- package/lib/env.d.ts +9 -0
- package/lib/env.js +1 -1
- package/lib/envOverwrite.d.ts +1 -1
- package/lib/envOverwrite.js +18 -34
- package/lib/factory.js +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -3
- package/lib/locale.js +1 -1
- package/lib/polyfills.js +1 -1
- package/lib/renderers/Form.d.ts +10 -4
- package/lib/renderers/Form.js +64 -32
- package/lib/renderers/Item.d.ts +54 -0
- package/lib/renderers/Item.js +1 -1
- package/lib/renderers/Options.d.ts +5 -1
- package/lib/renderers/Options.js +11 -9
- package/lib/renderers/Placeholder.js +1 -1
- package/lib/renderers/builtin.js +1 -1
- package/lib/renderers/register.js +1 -1
- package/lib/renderers/wrapControl.js +10 -17
- package/lib/store/app.js +1 -1
- package/lib/store/combo.d.ts +1154 -49
- package/lib/store/combo.js +10 -3
- package/lib/store/crud.d.ts +9 -1
- package/lib/store/crud.js +50 -15
- package/lib/store/form.d.ts +480 -21
- package/lib/store/form.js +1 -1
- package/lib/store/formItem.d.ts +23 -1
- package/lib/store/formItem.js +104 -15
- package/lib/store/iRenderer.js +1 -1
- package/lib/store/index.js +1 -1
- package/lib/store/list.js +1 -1
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.js +1 -1
- package/lib/store/root.js +1 -1
- package/lib/store/service.js +1 -1
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +1078 -43
- package/lib/store/table.js +63 -5
- package/lib/store/table2.js +1 -4
- package/lib/theme.js +1 -1
- package/lib/types.d.ts +8 -2
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.js +1 -1
- package/lib/utils/DataScope.js +1 -1
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.js +1 -1
- package/lib/utils/arraySlice.js +1 -1
- package/lib/utils/attachmentAdpator.js +3 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/columnsSplit.js +1 -1
- package/lib/utils/dataMapping.js +1 -1
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.js +1 -1
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.js +1 -1
- package/lib/utils/errors.js +1 -1
- package/lib/utils/escapeHtml.js +1 -1
- package/lib/utils/filter-schema.d.ts +2 -1
- package/lib/utils/filter-schema.js +14 -4
- package/lib/utils/filter.js +1 -1
- package/lib/utils/formatDuration.js +1 -1
- package/lib/utils/formula.js +1 -1
- package/lib/utils/getVariable.js +1 -1
- package/lib/utils/grammar.js +1 -1
- package/lib/utils/handleAction.js +1 -1
- package/lib/utils/helper.d.ts +2 -2
- package/lib/utils/helper.js +36 -28
- package/lib/utils/highlight.js +1 -1
- package/lib/utils/icon.js +1 -1
- package/lib/utils/image.js +1 -1
- package/lib/utils/isPureVariable.js +1 -1
- package/lib/utils/json-schema-2-amis-schema.js +1 -1
- package/lib/utils/keyToPath.js +1 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/math.js +8 -5
- package/lib/utils/memoryParse.js +1 -1
- package/lib/utils/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.js +15 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +1 -1
- package/lib/utils/position.js +1 -1
- package/lib/utils/prettyBytes.js +1 -1
- package/lib/utils/renderer-event.d.ts +7 -0
- package/lib/utils/renderer-event.js +30 -18
- package/lib/utils/replaceText.js +1 -1
- package/lib/utils/resize-sensor.js +1 -1
- package/lib/utils/resolveCondition.js +1 -1
- package/lib/utils/resolveVariable.js +1 -1
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
- package/lib/utils/scrollPosition.js +1 -1
- package/lib/utils/string2regExp.js +1 -1
- package/lib/utils/stripNumber.js +1 -1
- package/lib/utils/style-helper.js +12 -15
- package/lib/utils/style.js +3 -2
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.js +1 -1
- package/lib/utils/tpl-lodash.js +1 -1
- package/lib/utils/tpl.js +1 -1
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validations.js +1 -1
- package/package.json +3 -3
package/esm/Root.js
CHANGED
package/esm/RootRenderer.d.ts
CHANGED
|
@@ -30,5 +30,5 @@ export declare class RootRenderer extends React.Component<RootRendererProps> {
|
|
|
30
30
|
renderError(): React.ReactNode;
|
|
31
31
|
renderDialog(): React.ReactNode;
|
|
32
32
|
renderDrawer(): React.ReactNode;
|
|
33
|
-
render(): React.JSX.Element;
|
|
33
|
+
render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
|
34
34
|
}
|
package/esm/RootRenderer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.6.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -318,7 +318,7 @@ var RootRenderer = /** @class */ (function (_super) {
|
|
|
318
318
|
var _a = this.props, pathPrefix = _a.pathPrefix, schema = _a.schema, render = _a.render, rest = __rest(_a, ["pathPrefix", "schema", "render"]);
|
|
319
319
|
var store = this.store;
|
|
320
320
|
if (store.runtimeError) {
|
|
321
|
-
this.renderRuntimeError();
|
|
321
|
+
return this.renderRuntimeError();
|
|
322
322
|
}
|
|
323
323
|
return (React.createElement(React.Fragment, null,
|
|
324
324
|
render(pathPrefix, schema, __assign(__assign({}, rest), { topStore: this.store, data: this.store.downStream, context: store.context, onAction: this.handleAction })),
|
package/esm/SchemaRenderer.js
CHANGED
package/esm/Scoped.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { RendererEnv, RendererProps } from './factory';
|
|
7
7
|
import { RendererData, ActionObject } from './types';
|
|
8
|
+
import { ListenerAction } from './actions';
|
|
8
9
|
/**
|
|
9
10
|
* target 里面可能包含 ?xxx=xxx,这种情况下,需要把 ?xxx=xxx 保留下来,然后对前面的部分进行 filter
|
|
10
11
|
* 因为后面会对 query 部分做不一样的处理。会保留原始的值。而不是会转成字符串。
|
|
@@ -36,6 +37,7 @@ export interface IScopedContext {
|
|
|
36
37
|
close: (target: string) => void;
|
|
37
38
|
closeById: (target: string) => void;
|
|
38
39
|
getComponentsByRefPath: (session: string, path: string) => ScopedComponentType[];
|
|
40
|
+
doAction: (actions: ListenerAction | ListenerAction[], ctx: any) => void;
|
|
39
41
|
}
|
|
40
42
|
type AliasIScopedContext = IScopedContext;
|
|
41
43
|
export declare const ScopedContext: React.Context<IScopedContext>;
|
package/esm/Scoped.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.6.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __values, __assign, __extends, __rest, __decorate, __metadata } from 'tslib';
|
|
6
|
+
import { __values, __assign, __awaiter, __generator, __extends, __rest, __decorate, __metadata } from 'tslib';
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import find from 'lodash/find';
|
|
9
9
|
import values from 'lodash/values';
|
|
10
10
|
import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
11
11
|
import { registerFunction } from 'amis-formula';
|
|
12
12
|
import 'moment';
|
|
13
|
-
import '
|
|
14
|
-
import { getVariable } from './utils/getVariable.js';
|
|
13
|
+
import { createObject } from './utils/object.js';
|
|
15
14
|
import { isPureVariable } from './utils/isPureVariable.js';
|
|
15
|
+
import { getVariable } from './utils/getVariable.js';
|
|
16
16
|
import { dataMapping } from './utils/dataMapping.js';
|
|
17
17
|
import './utils/filter.js';
|
|
18
18
|
import { findTree, eachTree, qsparse, qsstringify, parseQuery, autobind } from './utils/helper.js';
|
|
@@ -25,13 +25,13 @@ import './utils/debug.js';
|
|
|
25
25
|
import 'react-dom';
|
|
26
26
|
import './utils/errors.js';
|
|
27
27
|
import { filter } from './utils/tpl.js';
|
|
28
|
+
import 'lodash/isPlainObject';
|
|
28
29
|
import 'lodash/isObject';
|
|
29
30
|
import 'lodash/isString';
|
|
30
31
|
import 'lodash/isBoolean';
|
|
31
32
|
import './utils/image.js';
|
|
32
33
|
import 'lodash/isEqual';
|
|
33
|
-
import './
|
|
34
|
-
import 'lodash/debounce';
|
|
34
|
+
import { createRendererEvent } from './utils/renderer-event.js';
|
|
35
35
|
import 'lodash/cloneDeep';
|
|
36
36
|
import './utils/resize-sensor.js';
|
|
37
37
|
import 'react-overlays/useRootClose';
|
|
@@ -46,6 +46,24 @@ import './utils/validations.js';
|
|
|
46
46
|
import './utils/resolveCondition.js';
|
|
47
47
|
import 'mobx';
|
|
48
48
|
import './utils/Animation.js';
|
|
49
|
+
import './actions/LoopAction.js';
|
|
50
|
+
import './actions/BreakAction.js';
|
|
51
|
+
import './actions/ContinueAction.js';
|
|
52
|
+
import './actions/SwitchAction.js';
|
|
53
|
+
import './actions/ParallelAction.js';
|
|
54
|
+
import './actions/CustomAction.js';
|
|
55
|
+
import './actions/BroadcastAction.js';
|
|
56
|
+
import './actions/CmptAction.js';
|
|
57
|
+
import './actions/StatusAction.js';
|
|
58
|
+
import './actions/AjaxAction.js';
|
|
59
|
+
import './actions/CopyAction.js';
|
|
60
|
+
import './actions/DialogAction.js';
|
|
61
|
+
import './actions/DrawerAction.js';
|
|
62
|
+
import './actions/EmailAction.js';
|
|
63
|
+
import './actions/LinkAction.js';
|
|
64
|
+
import './actions/ToastAction.js';
|
|
65
|
+
import './actions/PageAction.js';
|
|
66
|
+
import { runActions } from './actions/Action.js';
|
|
49
67
|
|
|
50
68
|
/**
|
|
51
69
|
* @file 用来创建一个域,在这个域里面会把里面的运行时实例注册进来,方便组件之间的通信。
|
|
@@ -236,7 +254,7 @@ function createScopedTools(path, parent, env, rendererType) {
|
|
|
236
254
|
}
|
|
237
255
|
}
|
|
238
256
|
else {
|
|
239
|
-
var component = scoped.getComponentByName(name);
|
|
257
|
+
var component = scoped.getComponentByName(name) || scoped.getComponentById(name);
|
|
240
258
|
component &&
|
|
241
259
|
component.reload &&
|
|
242
260
|
component.reload(subPath, query, ctx);
|
|
@@ -298,6 +316,30 @@ function createScopedTools(path, parent, env, rendererType) {
|
|
|
298
316
|
if (component && component.props.show) {
|
|
299
317
|
closeDialog(component);
|
|
300
318
|
}
|
|
319
|
+
},
|
|
320
|
+
doAction: function (actions, ctx) {
|
|
321
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
+
var renderer, rendererEvent;
|
|
323
|
+
return __generator(this, function (_a) {
|
|
324
|
+
switch (_a.label) {
|
|
325
|
+
case 0:
|
|
326
|
+
renderer = this.getComponents()[0];
|
|
327
|
+
rendererEvent = createRendererEvent('embed', {
|
|
328
|
+
env: env,
|
|
329
|
+
nativeEvent: undefined,
|
|
330
|
+
data: createObject(renderer.props.data, ctx),
|
|
331
|
+
scoped: this
|
|
332
|
+
});
|
|
333
|
+
return [4 /*yield*/, runActions(actions, renderer, rendererEvent)];
|
|
334
|
+
case 1:
|
|
335
|
+
_a.sent();
|
|
336
|
+
if (rendererEvent.prevented) {
|
|
337
|
+
return [2 /*return*/];
|
|
338
|
+
}
|
|
339
|
+
return [2 /*return*/];
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
});
|
|
301
343
|
}
|
|
302
344
|
};
|
|
303
345
|
registerFunction('GETRENDERERDATA', function (componentId, path, scoped) {
|
package/esm/StatusScoped.js
CHANGED
package/esm/WithRootStore.js
CHANGED
package/esm/WithStore.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.6.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ import { reaction } from 'mobx';
|
|
|
9
9
|
import { observer } from 'mobx-react';
|
|
10
10
|
import { isAlive } from 'mobx-state-tree';
|
|
11
11
|
import React from 'react';
|
|
12
|
-
import { getExprProperties } from './utils/filter-schema.js';
|
|
12
|
+
import { getExprProperties, hasExprPropertiesChanged } from './utils/filter-schema.js';
|
|
13
13
|
import { guid, isObjectShallowModified, isSuperDataModified, syncDataFromSuper } from './utils/helper.js';
|
|
14
14
|
import 'amis-formula';
|
|
15
15
|
import 'moment';
|
|
@@ -60,12 +60,10 @@ function HocStoreFactory(renderer) {
|
|
|
60
60
|
var detectField = props.detectField, rest = __rest(props, ["detectField"]);
|
|
61
61
|
var exprProps = {};
|
|
62
62
|
if (!detectField || detectField === 'data') {
|
|
63
|
-
exprProps = getExprProperties(rest, store.data
|
|
63
|
+
exprProps = getExprProperties(rest, store.data);
|
|
64
64
|
_this.state = __assign({}, exprProps);
|
|
65
|
-
_this.unReaction = reaction(function () {
|
|
66
|
-
return
|
|
67
|
-
}, function () {
|
|
68
|
-
return _this.setState(__assign({}, getExprProperties(_this.props, store.data, undefined, _this.props)));
|
|
65
|
+
_this.unReaction = reaction(function () { return JSON.stringify(getExprProperties(_this.props, store.data)); }, function () {
|
|
66
|
+
return _this.setState(__assign({}, getExprProperties(_this.props, store.data)));
|
|
69
67
|
});
|
|
70
68
|
}
|
|
71
69
|
return _this;
|
|
@@ -85,10 +83,24 @@ function HocStoreFactory(renderer) {
|
|
|
85
83
|
return data;
|
|
86
84
|
};
|
|
87
85
|
StoreFactory.prototype.componentDidUpdate = function (prevProps) {
|
|
88
|
-
var
|
|
86
|
+
var _this = this;
|
|
87
|
+
var _a, _b, _c, _d;
|
|
89
88
|
var props = this.props;
|
|
90
89
|
var store = this.store;
|
|
91
|
-
|
|
90
|
+
// dialog 场景下 schema 是显示的时候更新的,
|
|
91
|
+
// 所以 schema 里面有表达式属性其实是监听不到变化的
|
|
92
|
+
// 所以这里需要根据新属性重新 reaction 一下
|
|
93
|
+
if ((!props.detectField || props.detectField === 'data') &&
|
|
94
|
+
hasExprPropertiesChanged(this.props, prevProps)) {
|
|
95
|
+
var state = getExprProperties(this.props, store.data);
|
|
96
|
+
isObjectShallowModified(state, this.state) && this.setState(state);
|
|
97
|
+
// 需要重新监听
|
|
98
|
+
(_a = this.unReaction) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
99
|
+
this.unReaction = reaction(function () { return JSON.stringify(getExprProperties(props, store.data)); }, function () {
|
|
100
|
+
return _this.setState(__assign({}, getExprProperties(_this.props, store.data)));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
var shouldSync = (_b = renderer.shouldSyncSuperStore) === null || _b === void 0 ? void 0 : _b.call(renderer, store, props, prevProps);
|
|
92
104
|
if (shouldSync === false) {
|
|
93
105
|
return;
|
|
94
106
|
}
|
|
@@ -123,10 +135,13 @@ function HocStoreFactory(renderer) {
|
|
|
123
135
|
? __assign({}, store.data) : syncDataFromSuper(store.data, props.store.data, prevProps.scope, store, props.syncSuperStore === true)), props.updatePristineAfterStoreDataReInit === false);
|
|
124
136
|
}
|
|
125
137
|
else if (props.data && props.data.__super) {
|
|
126
|
-
store.initData(extendObject(props.data,
|
|
138
|
+
store.initData(extendObject(props.data,
|
|
139
|
+
// 有远程数据
|
|
140
|
+
// 或者顶级 store
|
|
141
|
+
store.hasRemoteData || !store.path.includes('/')
|
|
127
142
|
? __assign(__assign({}, store.data), props.data) : // combo 不需要同步,如果要同步,在 Combo.tsx 里面已经实现了相关逻辑
|
|
128
143
|
// 目前主要的问题是,如果 combo 中表单项名字和 combo 本身的名字一样,会导致里面的值会被覆盖成数组
|
|
129
|
-
((
|
|
144
|
+
((_c = props.store) === null || _c === void 0 ? void 0 : _c.storeType) === 'ComboStore'
|
|
130
145
|
? undefined
|
|
131
146
|
: syncDataFromSuper(props.data, props.data.__super, prevProps.data.__super, store, false)), props.updatePristineAfterStoreDataReInit === false);
|
|
132
147
|
}
|
|
@@ -143,7 +158,7 @@ function HocStoreFactory(renderer) {
|
|
|
143
158
|
isObjectShallowModified(props.data.__super, prevProps.data.__super, false)) {
|
|
144
159
|
store.initData(createObject(props.data.__super, __assign(__assign({}, props.data), store.data)), props.updatePristineAfterStoreDataReInit === false ||
|
|
145
160
|
(store.storeType === 'FormStore' &&
|
|
146
|
-
((
|
|
161
|
+
((_d = prevProps.store) === null || _d === void 0 ? void 0 : _d.storeType) === 'CRUDStore'));
|
|
147
162
|
}
|
|
148
163
|
// nextProps.data.__super !== props.data.__super) &&
|
|
149
164
|
}
|
package/esm/actions/Action.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.6.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __awaiter, __generator, __values, __assign } from 'tslib';
|
|
6
|
+
import { __awaiter, __generator, __values, __assign, __spreadArray, __read } from 'tslib';
|
|
7
7
|
import omit from 'lodash/omit';
|
|
8
8
|
import '../utils/helper.js';
|
|
9
9
|
import { evalExpressionWithConditionBuilder } from '../utils/tpl.js';
|
|
@@ -181,10 +181,10 @@ var runActions = function (actions, renderer, event) { return __awaiter(void 0,
|
|
|
181
181
|
}); };
|
|
182
182
|
// 执行动作,与原有动作处理打通
|
|
183
183
|
var runAction = function (actionInstrance, actionConfig, renderer, event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
184
|
-
var additional, action, mergeData, expression, isStop, preventDefault, key, api, args, afterMappingData, actionData, data, stopped, actionResult, stopPropagation;
|
|
185
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
186
|
-
return __generator(this, function (
|
|
187
|
-
switch (
|
|
184
|
+
var additional, action, mergeData, expression, isStop, preventDefault, key, api, cmptFlag, targetComponent, args, afterMappingData, actionData, data, stopped, actionResult, stopPropagation;
|
|
185
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
186
|
+
return __generator(this, function (_v) {
|
|
187
|
+
switch (_v.label) {
|
|
188
188
|
case 0:
|
|
189
189
|
additional = {
|
|
190
190
|
event: event
|
|
@@ -206,8 +206,8 @@ var runAction = function (actionInstrance, actionConfig, renderer, event) { retu
|
|
|
206
206
|
if (!expression) return [3 /*break*/, 2];
|
|
207
207
|
return [4 /*yield*/, evalExpressionWithConditionBuilder(expression, mergeData, true)];
|
|
208
208
|
case 1:
|
|
209
|
-
isStop = !(
|
|
210
|
-
|
|
209
|
+
isStop = !(_v.sent());
|
|
210
|
+
_v.label = 2;
|
|
211
211
|
case 2:
|
|
212
212
|
if (isStop) {
|
|
213
213
|
return [2 /*return*/];
|
|
@@ -216,8 +216,8 @@ var runAction = function (actionInstrance, actionConfig, renderer, event) { retu
|
|
|
216
216
|
if (!action.preventDefault) return [3 /*break*/, 4];
|
|
217
217
|
return [4 /*yield*/, evalExpressionWithConditionBuilder(action.preventDefault, mergeData, false)];
|
|
218
218
|
case 3:
|
|
219
|
-
preventDefault =
|
|
220
|
-
|
|
219
|
+
preventDefault = _v.sent();
|
|
220
|
+
_v.label = 4;
|
|
221
221
|
case 4:
|
|
222
222
|
key = {
|
|
223
223
|
componentId: dataMapping(action.componentId, mergeData),
|
|
@@ -241,14 +241,22 @@ var runAction = function (actionInstrance, actionConfig, renderer, event) { retu
|
|
|
241
241
|
(_q = action.args) === null || _q === void 0 ? true : delete _q.options;
|
|
242
242
|
(_r = action.args) === null || _r === void 0 ? true : delete _r.messages;
|
|
243
243
|
}
|
|
244
|
+
cmptFlag = key.componentId || key.componentName;
|
|
245
|
+
targetComponent = cmptFlag
|
|
246
|
+
? (_s = event.context.scoped) === null || _s === void 0 ? void 0 : _s[action.componentId ? 'getComponentById' : 'getComponentByName'](cmptFlag)
|
|
247
|
+
: renderer;
|
|
244
248
|
args = dataMapping(action.args, mergeData, function (key) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
'responseAdaptor',
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
'condition'
|
|
251
|
-
|
|
249
|
+
var _a;
|
|
250
|
+
var actionIgnoreKey = {
|
|
251
|
+
ajax: ['adaptor', 'responseAdaptor', 'requestAdaptor', 'responseData']
|
|
252
|
+
};
|
|
253
|
+
var cmptIgnoreMap = {
|
|
254
|
+
'input-table': ['condition']
|
|
255
|
+
};
|
|
256
|
+
var curCmptType = (_a = targetComponent === null || targetComponent === void 0 ? void 0 : targetComponent.props) === null || _a === void 0 ? void 0 : _a.type;
|
|
257
|
+
var curActionType = action.actionType;
|
|
258
|
+
var ignoreKey = __spreadArray(__spreadArray([], __read((actionIgnoreKey[curActionType] || [])), false), __read((cmptIgnoreMap[curCmptType] || [])), false);
|
|
259
|
+
return ignoreKey.includes(key);
|
|
252
260
|
});
|
|
253
261
|
afterMappingData = dataMapping(action.data, mergeData);
|
|
254
262
|
actionData = args && Object.keys(args).length
|
|
@@ -258,12 +266,12 @@ var runAction = function (actionInstrance, actionConfig, renderer, event) { retu
|
|
|
258
266
|
!['ajax', 'download', 'dialog', 'drawer'].includes(action.actionType) // 避免非法配置影响对actionData的判断,导致动作配置中的数据映射失败
|
|
259
267
|
? actionData
|
|
260
268
|
: mergeData;
|
|
261
|
-
(
|
|
269
|
+
(_t = console.group) === null || _t === void 0 ? void 0 : _t.call(console, "run action ".concat(action.actionType));
|
|
262
270
|
console.debug("[".concat(action.actionType, "] action args, data"), args, data);
|
|
263
271
|
stopped = false;
|
|
264
272
|
return [4 /*yield*/, actionInstrance.run(__assign(__assign(__assign({}, action), { args: args, data: action.actionType === 'reload' ? actionData : data }), key), renderer, event, mergeData)];
|
|
265
273
|
case 5:
|
|
266
|
-
actionResult =
|
|
274
|
+
actionResult = _v.sent();
|
|
267
275
|
// 二次确认弹窗如果取消,则终止后续动作
|
|
268
276
|
if ((action === null || action === void 0 ? void 0 : action.actionType) === 'confirmDialog' && !actionResult) {
|
|
269
277
|
stopped = true;
|
|
@@ -273,11 +281,11 @@ var runAction = function (actionInstrance, actionConfig, renderer, event) { retu
|
|
|
273
281
|
if (!action.stopPropagation) return [3 /*break*/, 7];
|
|
274
282
|
return [4 /*yield*/, evalExpressionWithConditionBuilder(action.stopPropagation, mergeData, false)];
|
|
275
283
|
case 6:
|
|
276
|
-
stopPropagation =
|
|
277
|
-
|
|
284
|
+
stopPropagation = _v.sent();
|
|
285
|
+
_v.label = 7;
|
|
278
286
|
case 7:
|
|
279
287
|
console.debug("[".concat(action.actionType, "] action end event"), event);
|
|
280
|
-
(
|
|
288
|
+
(_u = console.groupEnd) === null || _u === void 0 ? void 0 : _u.call(console);
|
|
281
289
|
// 阻止原有动作执行
|
|
282
290
|
preventDefault && event.preventDefault();
|
|
283
291
|
// 阻止后续动作执行
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.6.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -30,7 +30,7 @@ var AjaxAction = /** @class */ (function () {
|
|
|
30
30
|
return __generator(this, function (_p) {
|
|
31
31
|
switch (_p.label) {
|
|
32
32
|
case 0:
|
|
33
|
-
if (!((_a =
|
|
33
|
+
if (!((_a = event.context.env) === null || _a === void 0 ? void 0 : _a.fetcher)) {
|
|
34
34
|
throw new Error('env.fetcher is required!');
|
|
35
35
|
}
|
|
36
36
|
if (!action.api) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.6.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -21,16 +21,29 @@ var CmptAction = /** @class */ (function () {
|
|
|
21
21
|
CmptAction.prototype.run = function (action, renderer, event) {
|
|
22
22
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
23
23
|
return __awaiter(this, void 0, void 0, function () {
|
|
24
|
-
var key, dataMergeMode,
|
|
24
|
+
var key, dataMergeMode, path, beforeSetData, res, component, msg, result, e_1;
|
|
25
25
|
var _t, _u;
|
|
26
26
|
return __generator(this, function (_v) {
|
|
27
27
|
switch (_v.label) {
|
|
28
28
|
case 0:
|
|
29
29
|
key = action.componentId || action.componentName;
|
|
30
30
|
dataMergeMode = action.dataMergeMode || 'merge';
|
|
31
|
+
path = (_a = action.args) === null || _a === void 0 ? void 0 : _a.path;
|
|
32
|
+
if (!(action.actionType === 'setValue' && path && typeof path === 'string')) return [3 /*break*/, 2];
|
|
33
|
+
beforeSetData = (_c = (_b = event === null || event === void 0 ? void 0 : event.context) === null || _b === void 0 ? void 0 : _b.env) === null || _c === void 0 ? void 0 : _c.beforeSetData;
|
|
34
|
+
if (!(beforeSetData && typeof beforeSetData === 'function')) return [3 /*break*/, 2];
|
|
35
|
+
return [4 /*yield*/, beforeSetData(renderer, action, event)];
|
|
36
|
+
case 1:
|
|
37
|
+
res = _v.sent();
|
|
38
|
+
if (res === false) {
|
|
39
|
+
return [2 /*return*/];
|
|
40
|
+
}
|
|
41
|
+
_v.label = 2;
|
|
42
|
+
case 2:
|
|
31
43
|
component = key
|
|
32
|
-
? (
|
|
33
|
-
:
|
|
44
|
+
? (_d = event.context.scoped) === null || _d === void 0 ? void 0 : _d[action.componentId ? 'getComponentById' : 'getComponentByName'](key)
|
|
45
|
+
: renderer;
|
|
46
|
+
// 如果key指定了,但是没找到组件,则报错
|
|
34
47
|
if (key && !component) {
|
|
35
48
|
msg = '尝试执行一个不存在的目标组件动作,请检查目标组件非隐藏状态,且正确指定了componentId或componentName';
|
|
36
49
|
if (action.ignoreError === false) {
|
|
@@ -40,37 +53,23 @@ var CmptAction = /** @class */ (function () {
|
|
|
40
53
|
console.warn(msg);
|
|
41
54
|
}
|
|
42
55
|
}
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return [4 /*yield*/, beforeSetData(renderer, action, event)];
|
|
51
|
-
case 1:
|
|
52
|
-
res = _v.sent();
|
|
53
|
-
if (res === false) {
|
|
54
|
-
return [2 /*return*/];
|
|
55
|
-
}
|
|
56
|
-
_v.label = 2;
|
|
57
|
-
case 2:
|
|
58
|
-
if (component === null || component === void 0 ? void 0 : component.setData) {
|
|
59
|
-
return [2 /*return*/, component === null || component === void 0 ? void 0 : component.setData((_e = action.args) === null || _e === void 0 ? void 0 : _e.value, dataMergeMode === 'override', (_f = action.args) === null || _f === void 0 ? void 0 : _f.index, (_g = action.args) === null || _g === void 0 ? void 0 : _g.condition)];
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
return [2 /*return*/, (_j = component === null || component === void 0 ? void 0 : (_h = component.props).onChange) === null || _j === void 0 ? void 0 : _j.call(_h, (_k = action.args) === null || _k === void 0 ? void 0 : _k.value)];
|
|
56
|
+
if (action.actionType === 'setValue') {
|
|
57
|
+
if (component === null || component === void 0 ? void 0 : component.setData) {
|
|
58
|
+
return [2 /*return*/, component === null || component === void 0 ? void 0 : component.setData((_e = action.args) === null || _e === void 0 ? void 0 : _e.value, dataMergeMode === 'override', (_f = action.args) === null || _f === void 0 ? void 0 : _f.index, (_g = action.args) === null || _g === void 0 ? void 0 : _g.condition)];
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return [2 /*return*/, (_j = component === null || component === void 0 ? void 0 : (_h = component.props).onChange) === null || _j === void 0 ? void 0 : _j.call(_h, (_k = action.args) === null || _k === void 0 ? void 0 : _k.value)];
|
|
62
|
+
}
|
|
63
63
|
}
|
|
64
|
-
case 3:
|
|
65
64
|
// 刷新
|
|
66
65
|
if (action.actionType === 'reload') {
|
|
67
66
|
return [2 /*return*/, (_l = component === null || component === void 0 ? void 0 : component.reload) === null || _l === void 0 ? void 0 : _l.call(component, undefined, action.data, undefined, undefined, dataMergeMode === 'override', action.args)];
|
|
68
67
|
}
|
|
69
|
-
_v.label =
|
|
70
|
-
case
|
|
71
|
-
_v.trys.push([
|
|
68
|
+
_v.label = 3;
|
|
69
|
+
case 3:
|
|
70
|
+
_v.trys.push([3, 5, , 6]);
|
|
72
71
|
return [4 /*yield*/, ((_m = component === null || component === void 0 ? void 0 : component.doAction) === null || _m === void 0 ? void 0 : _m.call(component, action, action.args, true))];
|
|
73
|
-
case
|
|
72
|
+
case 4:
|
|
74
73
|
result = _v.sent();
|
|
75
74
|
if (['validate', 'submit'].includes(action.actionType)) {
|
|
76
75
|
event.setData(createObject(event.data, (_t = {},
|
|
@@ -82,7 +81,7 @@ var CmptAction = /** @class */ (function () {
|
|
|
82
81
|
_t)));
|
|
83
82
|
}
|
|
84
83
|
return [2 /*return*/, result];
|
|
85
|
-
case
|
|
84
|
+
case 5:
|
|
86
85
|
e_1 = _v.sent();
|
|
87
86
|
event.setData(createObject(event.data, (_u = {},
|
|
88
87
|
_u[action.outputVar || "".concat(action.actionType, "Result")] = {
|
|
@@ -91,8 +90,8 @@ var CmptAction = /** @class */ (function () {
|
|
|
91
90
|
payload: (_s = (_r = component === null || component === void 0 ? void 0 : component.props) === null || _r === void 0 ? void 0 : _r.store) === null || _s === void 0 ? void 0 : _s.data
|
|
92
91
|
},
|
|
93
92
|
_u)));
|
|
94
|
-
return [3 /*break*/,
|
|
95
|
-
case
|
|
93
|
+
return [3 /*break*/, 6];
|
|
94
|
+
case 6: return [2 /*return*/];
|
|
96
95
|
}
|
|
97
96
|
});
|
|
98
97
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.6.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -20,11 +20,11 @@ var CopyAction = /** @class */ (function () {
|
|
|
20
20
|
var _a, _b, _c, _d, _e, _f;
|
|
21
21
|
return __awaiter(this, void 0, void 0, function () {
|
|
22
22
|
return __generator(this, function (_g) {
|
|
23
|
-
if (!((_a =
|
|
23
|
+
if (!((_a = event.context.env) === null || _a === void 0 ? void 0 : _a.copy)) {
|
|
24
24
|
throw new Error('env.copy is required!');
|
|
25
25
|
}
|
|
26
26
|
if ((_b = action.args) === null || _b === void 0 ? void 0 : _b.content) {
|
|
27
|
-
(_d = (_c =
|
|
27
|
+
(_d = (_c = event.context.env) === null || _c === void 0 ? void 0 : _c.copy) === null || _d === void 0 ? void 0 : _d.call(_c, action.args.content, {
|
|
28
28
|
format: (_f = (_e = action.args) === null || _e === void 0 ? void 0 : _e.copyFormat) !== null && _f !== void 0 ? _f : 'text/html'
|
|
29
29
|
});
|
|
30
30
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.6.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -18,11 +18,11 @@ var LinkAction = /** @class */ (function () {
|
|
|
18
18
|
function LinkAction() {
|
|
19
19
|
}
|
|
20
20
|
LinkAction.prototype.run = function (action, renderer, event) {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
21
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
22
22
|
return __awaiter(this, void 0, void 0, function () {
|
|
23
23
|
var urlObj;
|
|
24
|
-
return __generator(this, function (
|
|
25
|
-
if (!((_a =
|
|
24
|
+
return __generator(this, function (_j) {
|
|
25
|
+
if (!((_a = event.context.env) === null || _a === void 0 ? void 0 : _a.jumpTo)) {
|
|
26
26
|
throw new Error('env.jumpTo is required!');
|
|
27
27
|
}
|
|
28
28
|
urlObj = buildApi({
|
|
@@ -31,7 +31,7 @@ var LinkAction = /** @class */ (function () {
|
|
|
31
31
|
}, __assign(__assign({}, ((_e = (_d = action.args) === null || _d === void 0 ? void 0 : _d.params) !== null && _e !== void 0 ? _e : {})), ((_f = action.data) !== null && _f !== void 0 ? _f : {})), {
|
|
32
32
|
autoAppend: true
|
|
33
33
|
});
|
|
34
|
-
|
|
34
|
+
(_g = event.context.env) === null || _g === void 0 ? void 0 : _g.jumpTo(urlObj.url, __assign({ actionType: action.actionType, type: 'button' }, action.args), (_h = action.data) !== null && _h !== void 0 ? _h : {});
|
|
35
35
|
return [2 /*return*/];
|
|
36
36
|
});
|
|
37
37
|
});
|