amis-core 6.11.0-beta.1 → 6.11.0-beta.2
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.d.ts +3 -0
- package/esm/Root.js +1 -1
- package/esm/RootRenderer.js +14 -8
- package/esm/SchemaRenderer.d.ts +2 -0
- package/esm/SchemaRenderer.js +32 -9
- package/esm/Scoped.js +1 -1
- package/esm/StatusScoped.js +1 -1
- package/esm/StyleManager.js +1 -1
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +1 -1
- package/esm/actions/Action.js +1 -1
- package/esm/actions/AjaxAction.js +1 -1
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.js +6 -2
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- 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/EventAction.js +1 -1
- package/esm/actions/LinkAction.js +1 -1
- package/esm/actions/LoopAction.js +1 -1
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/PrintAction.js +1 -1
- package/esm/actions/StatusAction.js +1 -1
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/actions/WaitAction.js +1 -1
- package/esm/components/Animations.js +1 -1
- package/esm/components/CustomStyle.js +1 -1
- package/esm/components/ErrorBoundary.js +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.js +1 -1
- package/esm/components/PopOver.js +1 -1
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.d.ts +1 -0
- package/esm/factory.js +1 -1
- package/esm/globalVar.d.ts +173 -0
- package/esm/globalVar.js +122 -0
- package/esm/globalVarClientHandler.d.ts +1 -0
- package/esm/globalVarClientHandler.js +65 -0
- package/esm/globalVarDefaultValueHandler.d.ts +1 -0
- package/esm/globalVarDefaultValueHandler.js +28 -0
- package/esm/index.d.ts +3 -0
- package/esm/index.js +8 -5
- package/esm/locale.js +1 -1
- package/esm/polyfills.js +1 -1
- package/esm/renderers/Form.d.ts +3 -1
- package/esm/renderers/Form.js +39 -24
- package/esm/renderers/Item.d.ts +11 -19
- package/esm/renderers/Item.js +17 -2
- package/esm/renderers/Options.js +1 -1
- 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 +1 -1
- package/esm/store/app.js +1 -1
- package/esm/store/combo.js +1 -1
- package/esm/store/crud.d.ts +8 -0
- package/esm/store/crud.js +24 -17
- package/esm/store/form.js +14 -5
- package/esm/store/formItem.js +1 -1
- package/esm/store/iRenderer.js +1 -1
- package/esm/store/index.js +1 -1
- package/esm/store/list.d.ts +14 -1
- package/esm/store/list.js +45 -17
- 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.d.ts +14 -0
- package/esm/store/root.js +483 -12
- package/esm/store/service.js +1 -1
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +16 -2
- package/esm/store/table.js +83 -26
- package/esm/store/table2.js +1 -1
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +3 -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/animations.js +1 -1
- package/esm/utils/api.d.ts +1 -0
- package/esm/utils/api.js +18 -6
- package/esm/utils/arraySlice.js +1 -1
- package/esm/utils/attachmentAdpator.js +1 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/browser.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/concatData.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.js +1 -1
- 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 +5 -0
- package/esm/utils/helper.js +3 -2
- 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/labelToString.js +1 -1
- package/esm/utils/loopTooMuch.js +1 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/math.js +1 -1
- 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 +1 -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/printElement.js +1 -1
- package/esm/utils/renderer-event.js +1 -1
- 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 +1 -1
- package/esm/utils/style.js +1 -1
- 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/validateId.js +1 -1
- package/esm/utils/validations.js +1 -1
- package/esm/utils/visitedCache.js +1 -1
- package/lib/Root.d.ts +3 -0
- package/lib/Root.js +1 -1
- package/lib/RootRenderer.js +13 -7
- package/lib/SchemaRenderer.d.ts +2 -0
- package/lib/SchemaRenderer.js +32 -9
- package/lib/Scoped.js +1 -1
- package/lib/StatusScoped.js +1 -1
- package/lib/StyleManager.js +1 -1
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +1 -1
- package/lib/actions/Action.js +1 -1
- package/lib/actions/AjaxAction.js +1 -1
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.js +6 -2
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- 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/EventAction.js +1 -1
- package/lib/actions/LinkAction.js +1 -1
- package/lib/actions/LoopAction.js +1 -1
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/PrintAction.js +1 -1
- package/lib/actions/StatusAction.js +1 -1
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/actions/WaitAction.js +1 -1
- package/lib/components/Animations.js +1 -1
- package/lib/components/CustomStyle.js +1 -1
- package/lib/components/ErrorBoundary.js +1 -1
- package/lib/components/LazyComponent.js +1 -1
- package/lib/components/Overlay.js +1 -1
- package/lib/components/PopOver.js +1 -1
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.d.ts +1 -0
- package/lib/factory.js +1 -1
- package/lib/globalVar.d.ts +173 -0
- package/lib/globalVar.js +130 -0
- package/lib/globalVarClientHandler.d.ts +1 -0
- package/lib/globalVarClientHandler.js +67 -0
- package/lib/globalVarDefaultValueHandler.d.ts +1 -0
- package/lib/globalVarDefaultValueHandler.js +30 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +13 -4
- package/lib/locale.js +1 -1
- package/lib/polyfills.js +1 -1
- package/lib/renderers/Form.d.ts +3 -1
- package/lib/renderers/Form.js +37 -21
- package/lib/renderers/Item.d.ts +11 -19
- package/lib/renderers/Item.js +17 -2
- package/lib/renderers/Options.js +1 -1
- 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 +1 -1
- package/lib/store/app.js +1 -1
- package/lib/store/combo.d.ts +24 -24
- package/lib/store/combo.js +1 -1
- package/lib/store/crud.d.ts +8 -0
- package/lib/store/crud.js +23 -16
- package/lib/store/form.d.ts +10 -10
- package/lib/store/form.js +14 -5
- package/lib/store/formItem.js +1 -1
- package/lib/store/iRenderer.js +1 -1
- package/lib/store/index.js +1 -1
- package/lib/store/list.d.ts +14 -1
- package/lib/store/list.js +44 -16
- 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.d.ts +13 -0
- package/lib/store/root.js +487 -11
- package/lib/store/service.js +1 -1
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +36 -22
- package/lib/store/table.js +82 -25
- package/lib/store/table2.js +1 -1
- package/lib/theme.js +1 -1
- package/lib/types.d.ts +3 -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/animations.js +1 -1
- package/lib/utils/api.d.ts +1 -0
- package/lib/utils/api.js +18 -5
- package/lib/utils/arraySlice.js +1 -1
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/browser.js +1 -1
- package/lib/utils/columnsSplit.js +1 -1
- package/lib/utils/concatData.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.js +1 -1
- 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 +5 -0
- package/lib/utils/helper.js +3 -2
- 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/labelToString.js +1 -1
- package/lib/utils/loopTooMuch.js +1 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/math.js +1 -1
- 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 +1 -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/printElement.js +1 -1
- package/lib/utils/renderer-event.js +1 -1
- 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 +1 -1
- package/lib/utils/style.js +1 -1
- 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/validateId.js +1 -1
- package/lib/utils/validations.js +1 -1
- package/lib/utils/visitedCache.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全局变量
|
|
3
|
+
*
|
|
4
|
+
* 用于实现跨组件、跨页面的数据共享,支持持久化。
|
|
5
|
+
*/
|
|
6
|
+
import { JSONSchema } from './types';
|
|
7
|
+
import { IRootStore } from './store/root';
|
|
8
|
+
/**
|
|
9
|
+
* 全局变量的定义
|
|
10
|
+
*/
|
|
11
|
+
export interface GlobalVariableItem {
|
|
12
|
+
id?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 设计态属性。
|
|
15
|
+
* 全局变量类型,不是数据体类型,而是用于区分不同的配置方式。
|
|
16
|
+
* 这个字段运行时无含义,主要用于编辑器中的分类。
|
|
17
|
+
*
|
|
18
|
+
* 比如平台可能扩充:应用级别、页面级别、用户级别、数据字典关联、数据模型关联等。
|
|
19
|
+
* amis 中内置了:builtin 为简单的客户端存储,服务端存储需要外部扩充。
|
|
20
|
+
*
|
|
21
|
+
* @default builtin
|
|
22
|
+
*/
|
|
23
|
+
type?: string | 'builtin';
|
|
24
|
+
/**
|
|
25
|
+
* 变量名
|
|
26
|
+
*/
|
|
27
|
+
key: string;
|
|
28
|
+
/**
|
|
29
|
+
* 变量标题
|
|
30
|
+
*/
|
|
31
|
+
label?: string;
|
|
32
|
+
/**
|
|
33
|
+
* 变量描述
|
|
34
|
+
*/
|
|
35
|
+
description?: string;
|
|
36
|
+
/**
|
|
37
|
+
* 默认值
|
|
38
|
+
*/
|
|
39
|
+
defaultValue?: string;
|
|
40
|
+
/**
|
|
41
|
+
* 值的数据类型定义
|
|
42
|
+
*/
|
|
43
|
+
valueSchema?: JSONSchema;
|
|
44
|
+
/**
|
|
45
|
+
* 数据作用域
|
|
46
|
+
*/
|
|
47
|
+
scope?: 'page' | 'app';
|
|
48
|
+
/**
|
|
49
|
+
* 数据存储方式
|
|
50
|
+
*/
|
|
51
|
+
storageOn?: 'client' | 'server' | 'session';
|
|
52
|
+
/**
|
|
53
|
+
* 是否只读,不允许修改,运行态属性。
|
|
54
|
+
*/
|
|
55
|
+
readonly?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* @default true
|
|
58
|
+
* 是否自动保存,如果不特殊配置,会自动保存
|
|
59
|
+
*/
|
|
60
|
+
autoSave?: boolean;
|
|
61
|
+
validationErrors?: any;
|
|
62
|
+
validations?: any;
|
|
63
|
+
[propName: string]: any;
|
|
64
|
+
}
|
|
65
|
+
export type GlobalVarGetter = (variable: GlobalVariableItem, context: GlobalVarContext) => Promise<any>;
|
|
66
|
+
export type GlobalVarBulkGetter = (context: GlobalVarContext) => Promise<Record<string, any>> | Record<string, any>;
|
|
67
|
+
export type GlobalVarSetter = (variable: GlobalVariableItem, value: Record<string, any>, context: GlobalVarContext) => Promise<any>;
|
|
68
|
+
export type GlobalVarBulkSetter = (values: Record<string, any>, context: GlobalVarContext) => Promise<any> | any;
|
|
69
|
+
export interface GlobalVariableItemFull extends GlobalVariableItem {
|
|
70
|
+
/**
|
|
71
|
+
* 校验数值是否合法
|
|
72
|
+
* @param value
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
validate?: (value: any, values: Record<string, any>) => string | void;
|
|
76
|
+
/**
|
|
77
|
+
* 权重,用于排序
|
|
78
|
+
*/
|
|
79
|
+
order?: number;
|
|
80
|
+
/**
|
|
81
|
+
* 单个数据初始化获取
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
getter?: GlobalVarGetter;
|
|
85
|
+
/**
|
|
86
|
+
* 批量数据初始化获取
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
bulkGetter?: GlobalVarBulkGetter;
|
|
90
|
+
/**
|
|
91
|
+
* 当个数据修改保存
|
|
92
|
+
* @param value
|
|
93
|
+
* @returns
|
|
94
|
+
*/
|
|
95
|
+
setter?: GlobalVarSetter;
|
|
96
|
+
/**
|
|
97
|
+
* 批量全局变量数据保存,多个变量一起保存
|
|
98
|
+
* @param values
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
bulkSetter?: GlobalVarBulkSetter;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 全局变量的状态
|
|
105
|
+
*/
|
|
106
|
+
export interface GlobalVariableState {
|
|
107
|
+
/**
|
|
108
|
+
* 当前值
|
|
109
|
+
*/
|
|
110
|
+
value: any;
|
|
111
|
+
/**
|
|
112
|
+
* 原始值
|
|
113
|
+
*/
|
|
114
|
+
pristine: any;
|
|
115
|
+
/**
|
|
116
|
+
* 是否正在加载, 或者说正在获取
|
|
117
|
+
*/
|
|
118
|
+
busy?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* 是否已经初始化
|
|
121
|
+
*/
|
|
122
|
+
initialized: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* 数据是否合法
|
|
125
|
+
*/
|
|
126
|
+
valid: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* 错误馨馨
|
|
129
|
+
*/
|
|
130
|
+
errorMessages: string[];
|
|
131
|
+
/**
|
|
132
|
+
* 是否有变更
|
|
133
|
+
*/
|
|
134
|
+
touched: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* 是否有保存
|
|
137
|
+
*/
|
|
138
|
+
saved: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface GlobalVarContext {
|
|
141
|
+
variables: Array<GlobalVariableItem>;
|
|
142
|
+
[propName: string]: any;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 全局变量处理器, 可以处理全变量的初始化、校验、存储等操作
|
|
146
|
+
*/
|
|
147
|
+
export type GlobalVariableHandler = (variable: GlobalVariableItem | GlobalVariableItemFull, context: GlobalVarContext) => GlobalVariableItemFull | void | ((variable: GlobalVariableItem | GlobalVariableItemFull, context: GlobalVarContext) => GlobalVariableItemFull | void);
|
|
148
|
+
/**
|
|
149
|
+
* 注册全局变量处理器
|
|
150
|
+
* @param handler
|
|
151
|
+
*/
|
|
152
|
+
export declare function registerGlobalVariableHandler(handler: GlobalVariableHandler): void;
|
|
153
|
+
/**
|
|
154
|
+
* 通过处理器构建全局变量细节对象,用于后续的初始化、校验、存储等操作
|
|
155
|
+
* @param variable
|
|
156
|
+
* @param context
|
|
157
|
+
* @returns
|
|
158
|
+
*/
|
|
159
|
+
export declare function buildGlobalVariable(variable: GlobalVariableItem | GlobalVariableItemFull, context: GlobalVarContext): GlobalVariableItemFull;
|
|
160
|
+
/**
|
|
161
|
+
* 构建变量初始状态
|
|
162
|
+
* @returns
|
|
163
|
+
*/
|
|
164
|
+
export declare function createGlobalVarState(): GlobalVariableState;
|
|
165
|
+
export declare function isGlobalVarExpression(value: string): boolean;
|
|
166
|
+
/**
|
|
167
|
+
* 监控组件的全局变量
|
|
168
|
+
* @param schema
|
|
169
|
+
* @param topStore
|
|
170
|
+
* @param callback
|
|
171
|
+
* @returns
|
|
172
|
+
*/
|
|
173
|
+
export declare function observeGlobalVars(schema: any, topStore: IRootStore, callback: () => void): () => void;
|
package/esm/globalVar.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.11.0-beta.2
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { isExpression } from './utils/formula.js';
|
|
7
|
+
import { reaction } from 'mobx';
|
|
8
|
+
import { resolveVariableAndFilter } from './utils/resolveVariableAndFilter.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 全局变量
|
|
12
|
+
*
|
|
13
|
+
* 用于实现跨组件、跨页面的数据共享,支持持久化。
|
|
14
|
+
*/
|
|
15
|
+
var handlers = [];
|
|
16
|
+
/**
|
|
17
|
+
* 注册全局变量处理器
|
|
18
|
+
* @param handler
|
|
19
|
+
*/
|
|
20
|
+
function registerGlobalVariableHandler(handler) {
|
|
21
|
+
handlers.push(handler);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 通过处理器构建全局变量细节对象,用于后续的初始化、校验、存储等操作
|
|
25
|
+
* @param variable
|
|
26
|
+
* @param context
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
function buildGlobalVariable(variable, context) {
|
|
30
|
+
var postHandlers = [];
|
|
31
|
+
var result = handlers.reduce(function (item, handler) {
|
|
32
|
+
var result = handler(item, context);
|
|
33
|
+
if (typeof result === 'function') {
|
|
34
|
+
postHandlers.push(result);
|
|
35
|
+
}
|
|
36
|
+
return (result !== null && result !== void 0 ? result : item);
|
|
37
|
+
}, variable);
|
|
38
|
+
result = postHandlers.reduce(function (item, handler) { var _a; return (_a = handler(item, context)) !== null && _a !== void 0 ? _a : item; }, result);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 构建变量初始状态
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
function createGlobalVarState() {
|
|
46
|
+
return {
|
|
47
|
+
value: undefined,
|
|
48
|
+
pristine: undefined,
|
|
49
|
+
initialized: false,
|
|
50
|
+
valid: true,
|
|
51
|
+
errorMessages: [],
|
|
52
|
+
touched: false,
|
|
53
|
+
saved: false
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// 前两个是历史遗留,后两个是新的
|
|
57
|
+
var globalVarFields = ['__page.', 'appVariables.', 'global.', 'globalState.'];
|
|
58
|
+
function isGlobalVarExpression(value) {
|
|
59
|
+
return (typeof value === 'string' &&
|
|
60
|
+
isExpression(value) &&
|
|
61
|
+
globalVarFields.some(function (k) { return value.includes(k); }));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 监控组件的全局变量
|
|
65
|
+
* @param schema
|
|
66
|
+
* @param topStore
|
|
67
|
+
* @param callback
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
function observeGlobalVars(schema, topStore, callback) {
|
|
71
|
+
var expressions = [];
|
|
72
|
+
Object.keys(schema).forEach(function (key) {
|
|
73
|
+
var value = schema[key];
|
|
74
|
+
if (isGlobalVarExpression(value)) {
|
|
75
|
+
expressions.push({
|
|
76
|
+
key: key,
|
|
77
|
+
value: value
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else if ([
|
|
81
|
+
'items',
|
|
82
|
+
'body',
|
|
83
|
+
'buttons',
|
|
84
|
+
'header',
|
|
85
|
+
'columns',
|
|
86
|
+
'tabs',
|
|
87
|
+
'footer',
|
|
88
|
+
'actions',
|
|
89
|
+
'toolbar'
|
|
90
|
+
].includes(key)) {
|
|
91
|
+
var items = Array.isArray(value) ? value : [value];
|
|
92
|
+
items.forEach(function (item) {
|
|
93
|
+
if (isGlobalVarExpression(item === null || item === void 0 ? void 0 : item.visibleOn)) {
|
|
94
|
+
expressions.push({
|
|
95
|
+
key: "".concat(key, ".x.visibleOn"),
|
|
96
|
+
value: item.visibleOn
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else if (isGlobalVarExpression(item === null || item === void 0 ? void 0 : item.hiddenOn)) {
|
|
100
|
+
expressions.push({
|
|
101
|
+
key: "".concat(key, ".x.hiddenOn"),
|
|
102
|
+
value: item.hiddenOn
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (!expressions.length) {
|
|
109
|
+
return function () { };
|
|
110
|
+
}
|
|
111
|
+
var unReaction = reaction(function () {
|
|
112
|
+
return expressions
|
|
113
|
+
.map(function (exp) {
|
|
114
|
+
return "".concat(exp.key, ":").concat(resolveVariableAndFilter(exp.value, topStore.downStream, '| json' // 如果用了复杂对象,要靠这个来比较
|
|
115
|
+
));
|
|
116
|
+
})
|
|
117
|
+
.join(',');
|
|
118
|
+
}, callback);
|
|
119
|
+
return unReaction;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { buildGlobalVariable, createGlobalVarState, isGlobalVarExpression, observeGlobalVars, registerGlobalVariableHandler };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.11.0-beta.2
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { __assign } from 'tslib';
|
|
7
|
+
import { registerGlobalVariableHandler } from './globalVar.js';
|
|
8
|
+
|
|
9
|
+
function loadClientData(key, variables) {
|
|
10
|
+
var str = localStorage.getItem(key);
|
|
11
|
+
var data = {};
|
|
12
|
+
try {
|
|
13
|
+
data = JSON.parse(str || '{}');
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
console.error("parse localstorage \"".concat(key, " error\""), e);
|
|
17
|
+
}
|
|
18
|
+
var filterData = {};
|
|
19
|
+
variables.forEach(function (item) {
|
|
20
|
+
if (data.hasOwnProperty(item.key)) {
|
|
21
|
+
filterData[item.key] = data[item.key];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return filterData;
|
|
25
|
+
}
|
|
26
|
+
function saveClientData(key, values, variables) {
|
|
27
|
+
var str = localStorage.getItem(key);
|
|
28
|
+
var data = {};
|
|
29
|
+
try {
|
|
30
|
+
data = JSON.parse(str || '{}');
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
console.error("parse localstorage \"".concat(key, " error\""), e);
|
|
34
|
+
}
|
|
35
|
+
Object.assign(data, values);
|
|
36
|
+
localStorage.setItem(key, JSON.stringify(data));
|
|
37
|
+
}
|
|
38
|
+
function bulkClientGetter(_a) {
|
|
39
|
+
var variables = _a.variables;
|
|
40
|
+
return loadClientData('amis-client-vars', variables);
|
|
41
|
+
}
|
|
42
|
+
function bulkClientSetter(values, context) {
|
|
43
|
+
return saveClientData('amis-client-vars', values, context.variables);
|
|
44
|
+
}
|
|
45
|
+
function pageBulkClientGetter(context) {
|
|
46
|
+
var variables = context.variables;
|
|
47
|
+
var key = "amis-client-vars-".concat(context.pageId || location.pathname);
|
|
48
|
+
return loadClientData(key, variables);
|
|
49
|
+
}
|
|
50
|
+
function pageBulkClientSetter(values, context) {
|
|
51
|
+
var key = "amis-client-vars-".concat(context.pageId || location.pathname);
|
|
52
|
+
return saveClientData(key, values, context.variables);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 注册全局变量处理器,用来处理 storageOn 为 client 的变量
|
|
56
|
+
*
|
|
57
|
+
* 并且根据变量的 scope 来决定是 page 还是全局的
|
|
58
|
+
*
|
|
59
|
+
* 将数据存入 localStorage
|
|
60
|
+
*/
|
|
61
|
+
registerGlobalVariableHandler(function (variable, context) {
|
|
62
|
+
if (variable.storageOn === 'client') {
|
|
63
|
+
return __assign(__assign({}, variable), { bulkGetter: variable.scope === 'page' ? pageBulkClientGetter : bulkClientGetter, bulkSetter: variable.scope === 'page' ? pageBulkClientSetter : bulkClientSetter });
|
|
64
|
+
}
|
|
65
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.11.0-beta.2
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { __assign } from 'tslib';
|
|
7
|
+
import { registerGlobalVariableHandler } from './globalVar.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 格式化默认值
|
|
11
|
+
*/
|
|
12
|
+
registerGlobalVariableHandler(function (variable, context) {
|
|
13
|
+
var _a;
|
|
14
|
+
if (variable.defaultValue && typeof variable.defaultValue === 'string') {
|
|
15
|
+
var defaultValue = variable.defaultValue;
|
|
16
|
+
try {
|
|
17
|
+
var value = defaultValue;
|
|
18
|
+
var valueType = (_a = variable.valueSchema) === null || _a === void 0 ? void 0 : _a.type;
|
|
19
|
+
if (valueType && ['number', 'array', 'object'].includes(valueType)) {
|
|
20
|
+
value = JSON.parse(defaultValue);
|
|
21
|
+
}
|
|
22
|
+
return __assign(__assign({}, variable), { defaultValue: value });
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
// do nothing
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
package/esm/index.d.ts
CHANGED
|
@@ -15,7 +15,10 @@ export * from './utils/index';
|
|
|
15
15
|
export * from './utils/animations';
|
|
16
16
|
export * from './types';
|
|
17
17
|
export * from './store';
|
|
18
|
+
export * from './globalVar';
|
|
18
19
|
import * as utils from './utils/helper';
|
|
20
|
+
import './globalVarClientHandler';
|
|
21
|
+
import './globalVarDefaultValueHandler';
|
|
19
22
|
import { RegisterStore, registerStore } from './store';
|
|
20
23
|
import type { IColumn, IColumn2, IRow, IRow2 } from './store';
|
|
21
24
|
import { setDefaultLocale, getDefaultLocale, makeTranslator, register as registerLocale, extendLocale, removeLocaleData, localeable } from './locale';
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.11.0-beta.
|
|
2
|
+
* amis-core v6.11.0-beta.2
|
|
3
3
|
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ import './polyfills.js';
|
|
|
10
10
|
import './renderers/builtin.js';
|
|
11
11
|
import './renderers/register.js';
|
|
12
12
|
import { wrapFetcher } from './utils/api.js';
|
|
13
|
-
export { addApiRequestAdaptor, addApiResponseAdaptor, addApiResponseAdator, buildApi, callStrFunction, clearApiCache, getApiCache, isApiOutdated, isApiOutdatedWithData, isEffectiveApi, isSameApi, isValidApi, jsFetcher, jsonpFetcher, normalizeApi, normalizeApiResponseData, removeApiRequestAdaptor, removeApiResponseAdaptor, responseAdaptor, setApiCache, str2AsyncFunction, str2function, wrapAdaptor, wrapFetcher } from './utils/api.js';
|
|
13
|
+
export { addApiRequestAdaptor, addApiResponseAdaptor, addApiResponseAdator, buildApi, callStrFunction, clearApiCache, getApiCache, isApiOutdated, isApiOutdatedWithData, isEffectiveApi, isSameApi, isValidApi, jsFetcher, jsonpFetcher, normalizeApi, normalizeApiResponseData, removeApiRequestAdaptor, removeApiResponseAdaptor, responseAdaptor, setApiCache, shouldBlockedBySendOnApi, str2AsyncFunction, str2function, wrapAdaptor, wrapFetcher } from './utils/api.js';
|
|
14
14
|
export { attachmentAdpator } from './utils/attachmentAdpator.js';
|
|
15
15
|
export { autobindMethod, bind } from './utils/autobind.js';
|
|
16
16
|
export { chromeVersion, isSafari } from './utils/browser.js';
|
|
@@ -81,6 +81,9 @@ export { default as animation } from './utils/Animation.js';
|
|
|
81
81
|
export { createAnimationStyle } from './utils/animations.js';
|
|
82
82
|
import { RendererStore } from './store/index.js';
|
|
83
83
|
export { RegisterStore, RendererStore, registerStore } from './store/index.js';
|
|
84
|
+
export { buildGlobalVariable, createGlobalVarState, isGlobalVarExpression, observeGlobalVars, registerGlobalVariableHandler } from './globalVar.js';
|
|
85
|
+
import './globalVarClientHandler.js';
|
|
86
|
+
import './globalVarDefaultValueHandler.js';
|
|
84
87
|
import { getEnv } from 'mobx-state-tree';
|
|
85
88
|
import { getDefaultLocale, makeTranslator } from './locale.js';
|
|
86
89
|
export { extendLocale, getDefaultLocale, localeable, makeTranslator, register as registerLocale, removeLocaleData, setDefaultLocale } from './locale.js';
|
|
@@ -151,10 +154,10 @@ export { StoreNode } from './store/node.js';
|
|
|
151
154
|
*/
|
|
152
155
|
var classPrefix = getClassPrefix();
|
|
153
156
|
// @ts-ignore
|
|
154
|
-
var version = '6.11.0-beta.
|
|
157
|
+
var version = '6.11.0-beta.2';
|
|
155
158
|
window.amisVersionInfo = {
|
|
156
|
-
version: '6.11.0-beta.
|
|
157
|
-
buildTime: '2024-12-
|
|
159
|
+
version: '6.11.0-beta.2',
|
|
160
|
+
buildTime: '2024-12-24T03:28:24.148Z'
|
|
158
161
|
};
|
|
159
162
|
function render(schema, props, options, pathPrefix) {
|
|
160
163
|
if (props === void 0) { props = {}; }
|
package/esm/locale.js
CHANGED
package/esm/polyfills.js
CHANGED
package/esm/renderers/Form.d.ts
CHANGED
|
@@ -381,7 +381,7 @@ export default class Form extends React.Component<FormProps, object> {
|
|
|
381
381
|
renderBody(): React.JSX.Element;
|
|
382
382
|
render(): JSX.Element;
|
|
383
383
|
}
|
|
384
|
-
export declare class
|
|
384
|
+
export declare class FormRendererBase extends Form {
|
|
385
385
|
static contextType: React.Context<IScopedContext>;
|
|
386
386
|
constructor(props: FormProps, context: IScopedContext);
|
|
387
387
|
componentDidMount(): void;
|
|
@@ -397,3 +397,5 @@ export declare class FormRenderer extends Form {
|
|
|
397
397
|
setData(values: object, replace?: boolean): void;
|
|
398
398
|
getData(): any;
|
|
399
399
|
}
|
|
400
|
+
export declare class FormRenderer extends FormRendererBase {
|
|
401
|
+
}
|
package/esm/renderers/Form.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.11.0-beta.
|
|
2
|
+
* amis-core v6.11.0-beta.2
|
|
3
3
|
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __extends, __awaiter, __generator, __assign, __values, __decorate
|
|
6
|
+
import { __extends, __awaiter, __generator, __assign, __values, __decorate } from 'tslib';
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { Renderer } from '../factory.js';
|
|
9
9
|
import { FormStore } from '../store/form.js';
|
|
@@ -21,7 +21,7 @@ import '../utils/memoryParse.js';
|
|
|
21
21
|
import '@rc-component/mini-decimal';
|
|
22
22
|
import { dataMapping } from '../utils/dataMapping.js';
|
|
23
23
|
import '../utils/filter.js';
|
|
24
|
-
import { isEffectiveApi, isApiOutdated } from '../utils/api.js';
|
|
24
|
+
import { isEffectiveApi, isApiOutdated, shouldBlockedBySendOnApi } from '../utils/api.js';
|
|
25
25
|
import themedLazyComponent from '../components/LazyComponent.js';
|
|
26
26
|
import { isAlive } from 'mobx-state-tree';
|
|
27
27
|
import '../utils/browser.js';
|
|
@@ -750,7 +750,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
750
750
|
_b.label = 2;
|
|
751
751
|
case 2:
|
|
752
752
|
// 走到这里代表校验成功了
|
|
753
|
-
dispatchEvent_2('validateSucc', this.props.data);
|
|
753
|
+
dispatchEvent_2('validateSucc', createObject(this.props.data, values));
|
|
754
754
|
if (target) {
|
|
755
755
|
this.submitToTarget(filterTarget(target, values), values);
|
|
756
756
|
/** 可能配置页面跳转事件,页面路由变化导致persistKey不一致,无法清除持久化数据,所以提交成功事件之前先清理一下 */
|
|
@@ -868,6 +868,10 @@ var Form = /** @class */ (function (_super) {
|
|
|
868
868
|
});
|
|
869
869
|
}); })];
|
|
870
870
|
}
|
|
871
|
+
else if (shouldBlockedBySendOnApi(action.api || api, values)) {
|
|
872
|
+
// api存在,但是不满足sendOn时,走这里,不派发submitSucc事件
|
|
873
|
+
return [2 /*return*/];
|
|
874
|
+
}
|
|
871
875
|
else {
|
|
872
876
|
clearPersistDataAfterSubmit && store.clearLocalPersistData();
|
|
873
877
|
// type为submit,但是没有配api以及target时,只派发事件
|
|
@@ -1476,15 +1480,15 @@ var Form = /** @class */ (function (_super) {
|
|
|
1476
1480
|
];
|
|
1477
1481
|
return Form;
|
|
1478
1482
|
}(React.Component));
|
|
1479
|
-
var
|
|
1480
|
-
__extends(
|
|
1481
|
-
function
|
|
1483
|
+
var FormRendererBase = /** @class */ (function (_super) {
|
|
1484
|
+
__extends(FormRendererBase, _super);
|
|
1485
|
+
function FormRendererBase(props, context) {
|
|
1482
1486
|
var _this = _super.call(this, props) || this;
|
|
1483
1487
|
var scoped = context;
|
|
1484
1488
|
scoped.registerComponent(_this);
|
|
1485
1489
|
return _this;
|
|
1486
1490
|
}
|
|
1487
|
-
|
|
1491
|
+
FormRendererBase.prototype.componentDidMount = function () {
|
|
1488
1492
|
_super.prototype.componentDidMount.call(this);
|
|
1489
1493
|
if (this.props.autoFocus) {
|
|
1490
1494
|
var scoped = this.context;
|
|
@@ -1493,17 +1497,17 @@ var FormRenderer = /** @class */ (function (_super) {
|
|
|
1493
1497
|
focuableInput_1 && setTimeout(function () { return focuableInput_1.focus(); }, 200);
|
|
1494
1498
|
}
|
|
1495
1499
|
};
|
|
1496
|
-
|
|
1500
|
+
FormRendererBase.prototype.componentWillUnmount = function () {
|
|
1497
1501
|
var scoped = this.context;
|
|
1498
1502
|
scoped.unRegisterComponent(this);
|
|
1499
1503
|
_super.prototype.componentWillUnmount.call(this);
|
|
1500
1504
|
};
|
|
1501
|
-
|
|
1505
|
+
FormRendererBase.prototype.doAction = function (action, data, throwErrors) {
|
|
1502
1506
|
if (data === void 0) { data = this.props.store.data; }
|
|
1503
1507
|
if (throwErrors === void 0) { throwErrors = false; }
|
|
1504
1508
|
return this.handleAction(undefined, action, data, throwErrors);
|
|
1505
1509
|
};
|
|
1506
|
-
|
|
1510
|
+
FormRendererBase.prototype.handleAction = function (e, action, ctx, throwErrors, delegate) {
|
|
1507
1511
|
if (throwErrors === void 0) { throwErrors = false; }
|
|
1508
1512
|
return __awaiter(this, void 0, void 0, function () {
|
|
1509
1513
|
var scoped_1;
|
|
@@ -1521,13 +1525,16 @@ var FormRenderer = /** @class */ (function (_super) {
|
|
|
1521
1525
|
target.doAction(__assign(__assign({}, action), { target: undefined }), ctx, throwErrors));
|
|
1522
1526
|
}))];
|
|
1523
1527
|
}
|
|
1528
|
+
else if (action.actionType === 'clearError') {
|
|
1529
|
+
return [2 /*return*/, _super.prototype.clearErrors.call(this)];
|
|
1530
|
+
}
|
|
1524
1531
|
else {
|
|
1525
1532
|
return [2 /*return*/, _super.prototype.handleAction.call(this, e, action, ctx, throwErrors, delegate)];
|
|
1526
1533
|
}
|
|
1527
1534
|
});
|
|
1528
1535
|
});
|
|
1529
1536
|
};
|
|
1530
|
-
|
|
1537
|
+
FormRendererBase.prototype.handleDialogConfirm = function (values, action, ctx, targets) {
|
|
1531
1538
|
_super.prototype.handleDialogConfirm.call(this, values, action, ctx, targets);
|
|
1532
1539
|
var store = this.props.store;
|
|
1533
1540
|
var scoped = this.context;
|
|
@@ -1538,19 +1545,19 @@ var FormRenderer = /** @class */ (function (_super) {
|
|
|
1538
1545
|
scoped.reload(store.action.reload, ctx);
|
|
1539
1546
|
}
|
|
1540
1547
|
};
|
|
1541
|
-
|
|
1548
|
+
FormRendererBase.prototype.submitToTarget = function (target, values) {
|
|
1542
1549
|
var scoped = this.context;
|
|
1543
1550
|
scoped.send(target, values);
|
|
1544
1551
|
};
|
|
1545
|
-
|
|
1552
|
+
FormRendererBase.prototype.reloadTarget = function (target, data) {
|
|
1546
1553
|
var scoped = this.context;
|
|
1547
1554
|
scoped.reload(target, data);
|
|
1548
1555
|
};
|
|
1549
|
-
|
|
1556
|
+
FormRendererBase.prototype.closeTarget = function (target) {
|
|
1550
1557
|
var scoped = this.context;
|
|
1551
1558
|
scoped.close(target);
|
|
1552
1559
|
};
|
|
1553
|
-
|
|
1560
|
+
FormRendererBase.prototype.reload = function (target, query, ctx, silent, replace) {
|
|
1554
1561
|
return __awaiter(this, void 0, void 0, function () {
|
|
1555
1562
|
var scoped, subPath, idx, subQuery, idx2, component, components;
|
|
1556
1563
|
return __generator(this, function (_a) {
|
|
@@ -1592,7 +1599,7 @@ var FormRenderer = /** @class */ (function (_super) {
|
|
|
1592
1599
|
});
|
|
1593
1600
|
});
|
|
1594
1601
|
};
|
|
1595
|
-
|
|
1602
|
+
FormRendererBase.prototype.receive = function (values, name, replace) {
|
|
1596
1603
|
return __awaiter(this, void 0, void 0, function () {
|
|
1597
1604
|
var scoped, idx, subPath, component;
|
|
1598
1605
|
return __generator(this, function (_a) {
|
|
@@ -1612,17 +1619,25 @@ var FormRenderer = /** @class */ (function (_super) {
|
|
|
1612
1619
|
});
|
|
1613
1620
|
});
|
|
1614
1621
|
};
|
|
1615
|
-
|
|
1622
|
+
FormRendererBase.prototype.setData = function (values, replace) {
|
|
1616
1623
|
var _a = this.props, onChange = _a.onChange, store = _a.store;
|
|
1617
1624
|
_super.prototype.setValues.call(this, values, replace);
|
|
1618
1625
|
// 触发表单change
|
|
1619
1626
|
onChange &&
|
|
1620
1627
|
onChange(store.data, difference(store.data, store.pristine), this.props);
|
|
1621
1628
|
};
|
|
1622
|
-
|
|
1629
|
+
FormRendererBase.prototype.getData = function () {
|
|
1623
1630
|
return this.getValues();
|
|
1624
1631
|
};
|
|
1625
|
-
|
|
1632
|
+
FormRendererBase.contextType = ScopedContext;
|
|
1633
|
+
return FormRendererBase;
|
|
1634
|
+
}(Form));
|
|
1635
|
+
var FormRenderer = /** @class */ (function (_super) {
|
|
1636
|
+
__extends(FormRenderer, _super);
|
|
1637
|
+
// 装饰器装饰后的类无法继承父类上的方法,所以多包了一层FormRendererBase用来继承
|
|
1638
|
+
function FormRenderer() {
|
|
1639
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1640
|
+
}
|
|
1626
1641
|
FormRenderer = __decorate([
|
|
1627
1642
|
Renderer({
|
|
1628
1643
|
type: 'form',
|
|
@@ -1641,10 +1656,10 @@ var FormRenderer = /** @class */ (function (_super) {
|
|
|
1641
1656
|
}
|
|
1642
1657
|
return undefined;
|
|
1643
1658
|
}
|
|
1644
|
-
})
|
|
1645
|
-
|
|
1659
|
+
})
|
|
1660
|
+
// 装饰器装饰后的类无法继承父类上的方法,所以多包了一层FormRendererBase用来继承
|
|
1646
1661
|
], FormRenderer);
|
|
1647
1662
|
return FormRenderer;
|
|
1648
|
-
}(
|
|
1663
|
+
}(FormRendererBase));
|
|
1649
1664
|
|
|
1650
|
-
export { FormRenderer, Form as default };
|
|
1665
|
+
export { FormRenderer, FormRendererBase, Form as default };
|