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
package/lib/env.js
CHANGED
package/lib/envOverwrite.js
CHANGED
package/lib/factory.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface RendererBasicConfig {
|
|
|
20
20
|
defaultProps?: (type: string, schema: any) => any;
|
|
21
21
|
shouldSyncSuperStore?: (store: any, props: any, prevProps: any) => boolean | undefined;
|
|
22
22
|
storeExtendsData?: boolean | ((props: any) => boolean);
|
|
23
|
+
onGlobalVarChanged?: (instance: React.Component, schema: any, data: any) => void | boolean;
|
|
23
24
|
weight?: number;
|
|
24
25
|
isolateScope?: boolean;
|
|
25
26
|
isFormItem?: boolean;
|
package/lib/factory.js
CHANGED
|
@@ -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/lib/globalVar.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.11.0-beta.2
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
+
|
|
10
|
+
var formula = require('./utils/formula.js');
|
|
11
|
+
var mobx = require('mobx');
|
|
12
|
+
var resolveVariableAndFilter = require('./utils/resolveVariableAndFilter.js');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 全局变量
|
|
16
|
+
*
|
|
17
|
+
* 用于实现跨组件、跨页面的数据共享,支持持久化。
|
|
18
|
+
*/
|
|
19
|
+
var handlers = [];
|
|
20
|
+
/**
|
|
21
|
+
* 注册全局变量处理器
|
|
22
|
+
* @param handler
|
|
23
|
+
*/
|
|
24
|
+
function registerGlobalVariableHandler(handler) {
|
|
25
|
+
handlers.push(handler);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 通过处理器构建全局变量细节对象,用于后续的初始化、校验、存储等操作
|
|
29
|
+
* @param variable
|
|
30
|
+
* @param context
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
function buildGlobalVariable(variable, context) {
|
|
34
|
+
var postHandlers = [];
|
|
35
|
+
var result = handlers.reduce(function (item, handler) {
|
|
36
|
+
var result = handler(item, context);
|
|
37
|
+
if (typeof result === 'function') {
|
|
38
|
+
postHandlers.push(result);
|
|
39
|
+
}
|
|
40
|
+
return (result !== null && result !== void 0 ? result : item);
|
|
41
|
+
}, variable);
|
|
42
|
+
result = postHandlers.reduce(function (item, handler) { var _a; return (_a = handler(item, context)) !== null && _a !== void 0 ? _a : item; }, result);
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 构建变量初始状态
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
function createGlobalVarState() {
|
|
50
|
+
return {
|
|
51
|
+
value: undefined,
|
|
52
|
+
pristine: undefined,
|
|
53
|
+
initialized: false,
|
|
54
|
+
valid: true,
|
|
55
|
+
errorMessages: [],
|
|
56
|
+
touched: false,
|
|
57
|
+
saved: false
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// 前两个是历史遗留,后两个是新的
|
|
61
|
+
var globalVarFields = ['__page.', 'appVariables.', 'global.', 'globalState.'];
|
|
62
|
+
function isGlobalVarExpression(value) {
|
|
63
|
+
return (typeof value === 'string' &&
|
|
64
|
+
formula.isExpression(value) &&
|
|
65
|
+
globalVarFields.some(function (k) { return value.includes(k); }));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 监控组件的全局变量
|
|
69
|
+
* @param schema
|
|
70
|
+
* @param topStore
|
|
71
|
+
* @param callback
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
function observeGlobalVars(schema, topStore, callback) {
|
|
75
|
+
var expressions = [];
|
|
76
|
+
Object.keys(schema).forEach(function (key) {
|
|
77
|
+
var value = schema[key];
|
|
78
|
+
if (isGlobalVarExpression(value)) {
|
|
79
|
+
expressions.push({
|
|
80
|
+
key: key,
|
|
81
|
+
value: value
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
else if ([
|
|
85
|
+
'items',
|
|
86
|
+
'body',
|
|
87
|
+
'buttons',
|
|
88
|
+
'header',
|
|
89
|
+
'columns',
|
|
90
|
+
'tabs',
|
|
91
|
+
'footer',
|
|
92
|
+
'actions',
|
|
93
|
+
'toolbar'
|
|
94
|
+
].includes(key)) {
|
|
95
|
+
var items = Array.isArray(value) ? value : [value];
|
|
96
|
+
items.forEach(function (item) {
|
|
97
|
+
if (isGlobalVarExpression(item === null || item === void 0 ? void 0 : item.visibleOn)) {
|
|
98
|
+
expressions.push({
|
|
99
|
+
key: "".concat(key, ".x.visibleOn"),
|
|
100
|
+
value: item.visibleOn
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
else if (isGlobalVarExpression(item === null || item === void 0 ? void 0 : item.hiddenOn)) {
|
|
104
|
+
expressions.push({
|
|
105
|
+
key: "".concat(key, ".x.hiddenOn"),
|
|
106
|
+
value: item.hiddenOn
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
if (!expressions.length) {
|
|
113
|
+
return function () { };
|
|
114
|
+
}
|
|
115
|
+
var unReaction = mobx.reaction(function () {
|
|
116
|
+
return expressions
|
|
117
|
+
.map(function (exp) {
|
|
118
|
+
return "".concat(exp.key, ":").concat(resolveVariableAndFilter.resolveVariableAndFilter(exp.value, topStore.downStream, '| json' // 如果用了复杂对象,要靠这个来比较
|
|
119
|
+
));
|
|
120
|
+
})
|
|
121
|
+
.join(',');
|
|
122
|
+
}, callback);
|
|
123
|
+
return unReaction;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
exports.buildGlobalVariable = buildGlobalVariable;
|
|
127
|
+
exports.createGlobalVarState = createGlobalVarState;
|
|
128
|
+
exports.isGlobalVarExpression = isGlobalVarExpression;
|
|
129
|
+
exports.observeGlobalVars = observeGlobalVars;
|
|
130
|
+
exports.registerGlobalVariableHandler = registerGlobalVariableHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.11.0-beta.2
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
var tslib = require('tslib');
|
|
9
|
+
var globalVar = require('./globalVar.js');
|
|
10
|
+
|
|
11
|
+
function loadClientData(key, variables) {
|
|
12
|
+
var str = localStorage.getItem(key);
|
|
13
|
+
var data = {};
|
|
14
|
+
try {
|
|
15
|
+
data = JSON.parse(str || '{}');
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
console.error("parse localstorage \"".concat(key, " error\""), e);
|
|
19
|
+
}
|
|
20
|
+
var filterData = {};
|
|
21
|
+
variables.forEach(function (item) {
|
|
22
|
+
if (data.hasOwnProperty(item.key)) {
|
|
23
|
+
filterData[item.key] = data[item.key];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return filterData;
|
|
27
|
+
}
|
|
28
|
+
function saveClientData(key, values, variables) {
|
|
29
|
+
var str = localStorage.getItem(key);
|
|
30
|
+
var data = {};
|
|
31
|
+
try {
|
|
32
|
+
data = JSON.parse(str || '{}');
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.error("parse localstorage \"".concat(key, " error\""), e);
|
|
36
|
+
}
|
|
37
|
+
Object.assign(data, values);
|
|
38
|
+
localStorage.setItem(key, JSON.stringify(data));
|
|
39
|
+
}
|
|
40
|
+
function bulkClientGetter(_a) {
|
|
41
|
+
var variables = _a.variables;
|
|
42
|
+
return loadClientData('amis-client-vars', variables);
|
|
43
|
+
}
|
|
44
|
+
function bulkClientSetter(values, context) {
|
|
45
|
+
return saveClientData('amis-client-vars', values, context.variables);
|
|
46
|
+
}
|
|
47
|
+
function pageBulkClientGetter(context) {
|
|
48
|
+
var variables = context.variables;
|
|
49
|
+
var key = "amis-client-vars-".concat(context.pageId || location.pathname);
|
|
50
|
+
return loadClientData(key, variables);
|
|
51
|
+
}
|
|
52
|
+
function pageBulkClientSetter(values, context) {
|
|
53
|
+
var key = "amis-client-vars-".concat(context.pageId || location.pathname);
|
|
54
|
+
return saveClientData(key, values, context.variables);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 注册全局变量处理器,用来处理 storageOn 为 client 的变量
|
|
58
|
+
*
|
|
59
|
+
* 并且根据变量的 scope 来决定是 page 还是全局的
|
|
60
|
+
*
|
|
61
|
+
* 将数据存入 localStorage
|
|
62
|
+
*/
|
|
63
|
+
globalVar.registerGlobalVariableHandler(function (variable, context) {
|
|
64
|
+
if (variable.storageOn === 'client') {
|
|
65
|
+
return tslib.__assign(tslib.__assign({}, variable), { bulkGetter: variable.scope === 'page' ? pageBulkClientGetter : bulkClientGetter, bulkSetter: variable.scope === 'page' ? pageBulkClientSetter : bulkClientSetter });
|
|
66
|
+
}
|
|
67
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.11.0-beta.2
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
var tslib = require('tslib');
|
|
9
|
+
var globalVar = require('./globalVar.js');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 格式化默认值
|
|
13
|
+
*/
|
|
14
|
+
globalVar.registerGlobalVariableHandler(function (variable, context) {
|
|
15
|
+
var _a;
|
|
16
|
+
if (variable.defaultValue && typeof variable.defaultValue === 'string') {
|
|
17
|
+
var defaultValue = variable.defaultValue;
|
|
18
|
+
try {
|
|
19
|
+
var value = defaultValue;
|
|
20
|
+
var valueType = (_a = variable.valueSchema) === null || _a === void 0 ? void 0 : _a.type;
|
|
21
|
+
if (valueType && ['number', 'array', 'object'].includes(valueType)) {
|
|
22
|
+
value = JSON.parse(defaultValue);
|
|
23
|
+
}
|
|
24
|
+
return tslib.__assign(tslib.__assign({}, variable), { defaultValue: value });
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
// do nothing
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
package/lib/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/lib/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
|
|
|
@@ -77,6 +77,9 @@ var math = require('./utils/math.js');
|
|
|
77
77
|
var Animation = require('./utils/Animation.js');
|
|
78
78
|
var animations = require('./utils/animations.js');
|
|
79
79
|
var index = require('./store/index.js');
|
|
80
|
+
var globalVar = require('./globalVar.js');
|
|
81
|
+
require('./globalVarClientHandler.js');
|
|
82
|
+
require('./globalVarDefaultValueHandler.js');
|
|
80
83
|
var mobxStateTree = require('mobx-state-tree');
|
|
81
84
|
var locale = require('./locale.js');
|
|
82
85
|
var Scoped = require('./Scoped.js');
|
|
@@ -142,10 +145,10 @@ var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
|
|
|
142
145
|
(__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
143
146
|
var classPrefix = theme.getClassPrefix();
|
|
144
147
|
// @ts-ignore
|
|
145
|
-
var version = '6.11.0-beta.
|
|
148
|
+
var version = '6.11.0-beta.2';
|
|
146
149
|
window.amisVersionInfo = {
|
|
147
|
-
version: '6.11.0-beta.
|
|
148
|
-
buildTime: '2024-12-
|
|
150
|
+
version: '6.11.0-beta.2',
|
|
151
|
+
buildTime: '2024-12-24T03:28:18.483Z'
|
|
149
152
|
};
|
|
150
153
|
function render(schema, props, options, pathPrefix) {
|
|
151
154
|
if (props === void 0) { props = {}; }
|
|
@@ -251,6 +254,7 @@ exports.removeApiRequestAdaptor = api.removeApiRequestAdaptor;
|
|
|
251
254
|
exports.removeApiResponseAdaptor = api.removeApiResponseAdaptor;
|
|
252
255
|
exports.responseAdaptor = api.responseAdaptor;
|
|
253
256
|
exports.setApiCache = api.setApiCache;
|
|
257
|
+
exports.shouldBlockedBySendOnApi = api.shouldBlockedBySendOnApi;
|
|
254
258
|
exports.str2AsyncFunction = api.str2AsyncFunction;
|
|
255
259
|
exports.str2function = api.str2function;
|
|
256
260
|
exports.wrapAdaptor = api.wrapAdaptor;
|
|
@@ -500,6 +504,11 @@ exports.createAnimationStyle = animations.createAnimationStyle;
|
|
|
500
504
|
exports.RegisterStore = index.RegisterStore;
|
|
501
505
|
exports.RendererStore = index.RendererStore;
|
|
502
506
|
exports.registerStore = index.registerStore;
|
|
507
|
+
exports.buildGlobalVariable = globalVar.buildGlobalVariable;
|
|
508
|
+
exports.createGlobalVarState = globalVar.createGlobalVarState;
|
|
509
|
+
exports.isGlobalVarExpression = globalVar.isGlobalVarExpression;
|
|
510
|
+
exports.observeGlobalVars = globalVar.observeGlobalVars;
|
|
511
|
+
exports.registerGlobalVariableHandler = globalVar.registerGlobalVariableHandler;
|
|
503
512
|
exports.extendLocale = locale.extendLocale;
|
|
504
513
|
exports.getDefaultLocale = locale.getDefaultLocale;
|
|
505
514
|
exports.localeable = locale.localeable;
|
package/lib/locale.js
CHANGED
package/lib/polyfills.js
CHANGED
package/lib/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
|
+
}
|