amis-core 1.0.0-beta.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.
Files changed (211) hide show
  1. package/dist/Root.js +94 -0
  2. package/dist/RootRenderer.js +288 -0
  3. package/dist/SchemaRenderer.js +323 -0
  4. package/dist/Scoped.js +252 -0
  5. package/dist/WithRootStore.js +44 -0
  6. package/dist/WithStore.js +179 -0
  7. package/dist/__tests__/compat.test.d.ts +1 -0
  8. package/dist/__tests__/factory.test.d.ts +1 -0
  9. package/dist/__tests__/filter.test.d.ts +1 -0
  10. package/dist/__tests__/helper.d.ts +13 -0
  11. package/dist/__tests__/tokenize.test.d.ts +1 -0
  12. package/dist/actions/Action.js +119 -0
  13. package/dist/actions/AjaxAction.js +96 -0
  14. package/dist/actions/BreakAction.js +35 -0
  15. package/dist/actions/BroadcastAction.js +49 -0
  16. package/dist/actions/CmptAction.js +60 -0
  17. package/dist/actions/ContinueAction.js +35 -0
  18. package/dist/actions/CopyAction.js +43 -0
  19. package/dist/actions/CustomAction.js +49 -0
  20. package/dist/actions/DialogAction.js +104 -0
  21. package/dist/actions/DrawerAction.js +66 -0
  22. package/dist/actions/EmailAction.js +48 -0
  23. package/dist/actions/LinkAction.js +52 -0
  24. package/dist/actions/LoopAction.js +107 -0
  25. package/dist/actions/PageAction.js +80 -0
  26. package/dist/actions/ParallelAction.js +40 -0
  27. package/dist/actions/SwitchAction.js +52 -0
  28. package/dist/actions/ToastAction.js +35 -0
  29. package/dist/components/LazyComponent.js +99 -0
  30. package/dist/env.js +20 -0
  31. package/dist/envOverwrite.js +43 -0
  32. package/dist/factory.js +308 -0
  33. package/dist/index.js +218 -0
  34. package/dist/index2.js +255 -0
  35. package/dist/locale.js +114 -0
  36. package/dist/renderers/Form.js +1162 -0
  37. package/dist/renderers/Item.js +636 -0
  38. package/dist/renderers/Options.js +881 -0
  39. package/dist/renderers/Placeholder.js +31 -0
  40. package/dist/renderers/builtin.js +27 -0
  41. package/dist/renderers/wrapControl.js +507 -0
  42. package/dist/src/Root.d.ts +37 -0
  43. package/dist/src/RootRenderer.d.ts +27 -0
  44. package/dist/src/SchemaRenderer.d.ts +37 -0
  45. package/dist/src/Scoped.d.ts +38 -0
  46. package/dist/src/WithRootStore.d.ts +737 -0
  47. package/dist/src/WithStore.d.ts +5 -0
  48. package/dist/src/actions/Action.d.ts +38 -0
  49. package/dist/src/actions/AjaxAction.d.ts +25 -0
  50. package/dist/src/actions/BreakAction.d.ts +15 -0
  51. package/dist/src/actions/BroadcastAction.d.ts +16 -0
  52. package/dist/src/actions/CmptAction.d.ts +20 -0
  53. package/dist/src/actions/ContinueAction.d.ts +15 -0
  54. package/dist/src/actions/CopyAction.d.ts +20 -0
  55. package/dist/src/actions/CustomAction.d.ts +17 -0
  56. package/dist/src/actions/Decorators.d.ts +25 -0
  57. package/dist/src/actions/DialogAction.d.ts +57 -0
  58. package/dist/src/actions/DrawerAction.d.ts +30 -0
  59. package/dist/src/actions/EmailAction.d.ts +23 -0
  60. package/dist/src/actions/LinkAction.d.ts +24 -0
  61. package/dist/src/actions/LoopAction.d.ts +19 -0
  62. package/dist/src/actions/PageAction.d.ts +39 -0
  63. package/dist/src/actions/ParallelAction.d.ts +8 -0
  64. package/dist/src/actions/SwitchAction.d.ts +11 -0
  65. package/dist/src/actions/ToastAction.d.ts +19 -0
  66. package/dist/src/actions/index.d.ts +21 -0
  67. package/dist/src/components/LazyComponent.d.ts +32 -0
  68. package/dist/src/env.d.ts +172 -0
  69. package/dist/src/envOverwrite.d.ts +4 -0
  70. package/dist/src/factory.d.ts +78 -0
  71. package/dist/src/index.d.ts +25 -0
  72. package/dist/src/locale.d.ts +82 -0
  73. package/dist/src/renderers/Form.d.ts +352 -0
  74. package/dist/src/renderers/Item.d.ts +795 -0
  75. package/dist/src/renderers/Options.d.ts +150 -0
  76. package/dist/src/renderers/Placeholder.d.ts +6 -0
  77. package/dist/src/renderers/builtin.d.ts +1 -0
  78. package/dist/src/renderers/wrapControl.d.ts +446 -0
  79. package/dist/src/schema.d.ts +369 -0
  80. package/dist/src/store/app.d.ts +89 -0
  81. package/dist/src/store/combo.d.ts +8504 -0
  82. package/dist/src/store/crud.d.ts +124 -0
  83. package/dist/src/store/form.d.ts +3394 -0
  84. package/dist/src/store/formItem.d.ts +130 -0
  85. package/dist/src/store/iRenderer.d.ts +46 -0
  86. package/dist/src/store/index.d.ts +105 -0
  87. package/dist/src/store/list.d.ts +270 -0
  88. package/dist/src/store/manager.d.ts +115 -0
  89. package/dist/src/store/modal.d.ts +84 -0
  90. package/dist/src/store/node.d.ts +22 -0
  91. package/dist/src/store/pagination.d.ts +58 -0
  92. package/dist/src/store/root.d.ts +79 -0
  93. package/dist/src/store/service.d.ts +71 -0
  94. package/dist/src/store/table-v2.d.ts +309 -0
  95. package/dist/src/store/table.d.ts +8334 -0
  96. package/dist/src/theme.d.ts +83 -0
  97. package/dist/src/types.d.ts +217 -0
  98. package/dist/src/utils/Animation.d.ts +22 -0
  99. package/dist/src/utils/ColorScale.d.ts +19 -0
  100. package/dist/src/utils/DataSchema.d.ts +25 -0
  101. package/dist/src/utils/DataScope.d.ts +23 -0
  102. package/dist/src/utils/RootClose.d.ts +4 -0
  103. package/dist/src/utils/SimpleMap.d.ts +8 -0
  104. package/dist/src/utils/api.d.ts +27 -0
  105. package/dist/src/utils/attachmentAdpator.d.ts +7 -0
  106. package/dist/src/utils/autobind.d.ts +7 -0
  107. package/dist/src/utils/columnsSplit.d.ts +1 -0
  108. package/dist/src/utils/dataMapping.d.ts +3 -0
  109. package/dist/src/utils/date.d.ts +4 -0
  110. package/dist/src/utils/debug.d.ts +26 -0
  111. package/dist/src/utils/dom.d.ts +13 -0
  112. package/dist/src/utils/errors.d.ts +6 -0
  113. package/dist/src/utils/escapeHtml.d.ts +1 -0
  114. package/dist/src/utils/filter-schema.d.ts +12 -0
  115. package/dist/src/utils/filter.d.ts +1 -0
  116. package/dist/src/utils/formatDuration.d.ts +1 -0
  117. package/dist/src/utils/formula.d.ts +16 -0
  118. package/dist/src/utils/getVariable.d.ts +3 -0
  119. package/dist/src/utils/grammar.d.ts +4 -0
  120. package/dist/src/utils/handleAction.d.ts +6 -0
  121. package/dist/src/utils/helper.d.ts +286 -0
  122. package/dist/src/utils/icon.d.ts +12 -0
  123. package/dist/src/utils/image.d.ts +17 -0
  124. package/dist/src/utils/index.d.ts +12 -0
  125. package/dist/src/utils/isPureVariable.d.ts +1 -0
  126. package/dist/src/utils/json-schema-2-amis-schema.d.ts +6 -0
  127. package/dist/src/utils/keyToPath.d.ts +6 -0
  128. package/dist/src/utils/makeSorter.d.ts +1 -0
  129. package/dist/src/utils/markdown.d.ts +5 -0
  130. package/dist/src/utils/normalizeLink.d.ts +1 -0
  131. package/dist/src/utils/normalizeOptions.d.ts +7 -0
  132. package/dist/src/utils/object.d.ts +15 -0
  133. package/dist/src/utils/offset.d.ts +14 -0
  134. package/dist/src/utils/offsetParent.d.ts +4 -0
  135. package/dist/src/utils/optionValueCompare.d.ts +3 -0
  136. package/dist/src/utils/position.d.ts +15 -0
  137. package/dist/src/utils/prettyBytes.d.ts +1 -0
  138. package/dist/src/utils/renderer-event.d.ts +44 -0
  139. package/dist/src/utils/replaceText.d.ts +6 -0
  140. package/dist/src/utils/resize-sensor.d.ts +6 -0
  141. package/dist/src/utils/resolveVariable.d.ts +1 -0
  142. package/dist/src/utils/resolveVariableAndFilter.d.ts +1 -0
  143. package/dist/src/utils/scrollPosition.d.ts +6 -0
  144. package/dist/src/utils/string2regExp.d.ts +1 -0
  145. package/dist/src/utils/stripNumber.d.ts +1 -0
  146. package/dist/src/utils/style.d.ts +10 -0
  147. package/dist/src/utils/tokenize.d.ts +1 -0
  148. package/dist/src/utils/tpl-builtin.d.ts +18 -0
  149. package/dist/src/utils/tpl-lodash.d.ts +4 -0
  150. package/dist/src/utils/tpl.d.ts +11 -0
  151. package/dist/src/utils/validations.d.ts +39 -0
  152. package/dist/store/app.js +190 -0
  153. package/dist/store/combo.js +154 -0
  154. package/dist/store/crud.js +413 -0
  155. package/dist/store/form.js +579 -0
  156. package/dist/store/formItem.js +846 -0
  157. package/dist/store/iRenderer.js +189 -0
  158. package/dist/store/index.js +103 -0
  159. package/dist/store/list.js +248 -0
  160. package/dist/store/manager.js +56 -0
  161. package/dist/store/modal.js +54 -0
  162. package/dist/store/node.js +93 -0
  163. package/dist/store/pagination.js +60 -0
  164. package/dist/store/root.js +45 -0
  165. package/dist/store/service.js +415 -0
  166. package/dist/store/table-v2.js +471 -0
  167. package/dist/store/table.js +1105 -0
  168. package/dist/theme.js +93 -0
  169. package/dist/tsconfig.tsbuildinfo +1 -0
  170. package/dist/utils/Animation.js +290 -0
  171. package/dist/utils/DataSchema.js +120 -0
  172. package/dist/utils/DataScope.js +151 -0
  173. package/dist/utils/SimpleMap.js +46 -0
  174. package/dist/utils/api.js +555 -0
  175. package/dist/utils/autobind.js +94 -0
  176. package/dist/utils/dataMapping.js +136 -0
  177. package/dist/utils/date.js +90 -0
  178. package/dist/utils/debug.js +343 -0
  179. package/dist/utils/errors.js +23 -0
  180. package/dist/utils/escapeHtml.js +24 -0
  181. package/dist/utils/filter-schema.js +75 -0
  182. package/dist/utils/filter.js +481 -0
  183. package/dist/utils/formatDuration.js +27 -0
  184. package/dist/utils/formula.js +165 -0
  185. package/dist/utils/getVariable.js +29 -0
  186. package/dist/utils/grammar.js +54 -0
  187. package/dist/utils/helper.js +1283 -0
  188. package/dist/utils/isPureVariable.js +16 -0
  189. package/dist/utils/keyToPath.js +34 -0
  190. package/dist/utils/makeSorter.js +30 -0
  191. package/dist/utils/normalizeLink.js +47 -0
  192. package/dist/utils/normalizeOptions.js +92 -0
  193. package/dist/utils/object.js +156 -0
  194. package/dist/utils/offset.js +36 -0
  195. package/dist/utils/offsetParent.js +27 -0
  196. package/dist/utils/optionValueCompare.js +25 -0
  197. package/dist/utils/position.js +50 -0
  198. package/dist/utils/prettyBytes.js +28 -0
  199. package/dist/utils/renderer-event.js +131 -0
  200. package/dist/utils/replaceText.js +35 -0
  201. package/dist/utils/resize-sensor.js +177 -0
  202. package/dist/utils/resolveVariable.js +39 -0
  203. package/dist/utils/resolveVariableAndFilter.js +37 -0
  204. package/dist/utils/string2regExp.js +18 -0
  205. package/dist/utils/stripNumber.js +20 -0
  206. package/dist/utils/tokenize.js +33 -0
  207. package/dist/utils/tpl-builtin.js +71 -0
  208. package/dist/utils/tpl-lodash.js +71 -0
  209. package/dist/utils/tpl.js +140 -0
  210. package/dist/utils/validations.js +377 -0
  211. package/package.json +121 -0
@@ -0,0 +1,172 @@
1
+ /**
2
+ * @file 组件 Env,包括如何发送 ajax,如何通知,如何跳转等等。。
3
+ */
4
+ import React from 'react';
5
+ import { RendererConfig } from './factory';
6
+ import { ThemeInstance } from './theme';
7
+ import { Action, Api, EventTrack, Payload, PlainObject, Schema, ToastConf, ToastLevel } from './types';
8
+ import hoistNonReactStatic from 'hoist-non-react-statics';
9
+ import { IScopedContext } from './Scoped';
10
+ import { RendererEvent } from './utils/renderer-event';
11
+ export interface wsObject {
12
+ url: string;
13
+ responseKey?: string;
14
+ body?: any;
15
+ }
16
+ export interface RendererEnv {
17
+ fetcher: (api: Api, data?: any, options?: object) => Promise<Payload>;
18
+ isCancel: (val: any) => boolean;
19
+ wsFetcher: (ws: wsObject, onMessage: (data: any) => void, onError: (error: any) => void) => void;
20
+ notify: (type: ToastLevel, msg: any, conf?: ToastConf) => void;
21
+ jumpTo: (to: string, action?: Action, ctx?: object) => void;
22
+ alert: (msg: string) => void;
23
+ confirm: (msg: string, title?: string) => Promise<boolean>;
24
+ updateLocation: (location: any, replace?: boolean) => void;
25
+ /**
26
+ * 阻止路由跳转,有时候 form 没有保存,但是路由跳转了,导致页面没有更新,
27
+ * 所以先让用户确认一下。
28
+ *
29
+ * 单页模式需要这个,如果非单页模式,不需要处理这个。
30
+ */
31
+ blockRouting?: (fn: (targetLocation: any) => void | string) => () => void;
32
+ isCurrentUrl: (link: string, ctx?: any) => boolean | {
33
+ params?: object;
34
+ };
35
+ /**
36
+ * 监控路由变化,如果 jssdk 需要做单页跳转需要实现这个。
37
+ */
38
+ watchRouteChange?: (fn: () => void) => () => void;
39
+ tracker: (eventTrack: EventTrack, props?: PlainObject) => void;
40
+ rendererResolver?: (path: string, schema: Schema, props: any) => null | RendererConfig;
41
+ copy?: (contents: string, format?: any) => void;
42
+ getModalContainer?: () => HTMLElement;
43
+ theme: ThemeInstance;
44
+ affixOffsetTop: number;
45
+ affixOffsetBottom: number;
46
+ richTextToken: string;
47
+ loadRenderer: (schema: Schema, path: string, reRender: Function) => Promise<React.ReactType> | React.ReactType | JSX.Element | void;
48
+ loadChartExtends?: () => void | Promise<void>;
49
+ useMobileUI?: boolean;
50
+ /**
51
+ * 过滤 html 标签,可用来添加 xss 保护逻辑
52
+ */
53
+ filterHtml: (input: string) => string;
54
+ beforeDispatchEvent: (e: string | React.ClipboardEvent<any> | React.DragEvent<any> | React.ChangeEvent<any> | React.KeyboardEvent<any> | React.TouchEvent<any> | React.WheelEvent<any> | React.AnimationEvent<any> | React.TransitionEvent<any> | React.MouseEvent<any>, context: any, scoped: IScopedContext, data: any, broadcast?: RendererEvent<any>) => void;
55
+ /**
56
+ * 是否开启 amis 调试
57
+ */
58
+ enableAMISDebug?: boolean;
59
+ /**
60
+ * 替换文本,用于实现 URL 替换、语言替换等
61
+ */
62
+ replaceText?: {
63
+ [propName: string]: any;
64
+ };
65
+ /**
66
+ * 文本替换的黑名单,因为属性太多了所以改成黑名单的 fangs
67
+ */
68
+ replaceTextIgnoreKeys?: String[];
69
+ }
70
+ export declare const EnvContext: React.Context<void | RendererEnv>;
71
+ export interface EnvProps {
72
+ env: RendererEnv;
73
+ }
74
+ export declare function withRendererEnv<T extends React.ComponentType<React.ComponentProps<T> & EnvProps>>(ComposedComponent: T): {
75
+ new (props: (JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
76
+ env?: RendererEnv | undefined;
77
+ }) | Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
78
+ env?: RendererEnv | undefined;
79
+ }>): {
80
+ render(): JSX.Element;
81
+ context: any;
82
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
83
+ env?: RendererEnv | undefined;
84
+ }>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
85
+ forceUpdate(callback?: (() => void) | undefined): void;
86
+ readonly props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
87
+ env?: RendererEnv | undefined;
88
+ }> & Readonly<{
89
+ children?: React.ReactNode;
90
+ }>;
91
+ state: Readonly<{}>;
92
+ refs: {
93
+ [key: string]: React.ReactInstance;
94
+ };
95
+ componentDidMount?(): void;
96
+ shouldComponentUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
97
+ env?: RendererEnv | undefined;
98
+ }>, nextState: Readonly<{}>, nextContext: any): boolean;
99
+ componentWillUnmount?(): void;
100
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
101
+ getSnapshotBeforeUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
102
+ env?: RendererEnv | undefined;
103
+ }>, prevState: Readonly<{}>): any;
104
+ componentDidUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
105
+ env?: RendererEnv | undefined;
106
+ }>, prevState: Readonly<{}>, snapshot?: any): void;
107
+ componentWillMount?(): void;
108
+ UNSAFE_componentWillMount?(): void;
109
+ componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
110
+ env?: RendererEnv | undefined;
111
+ }>, nextContext: any): void;
112
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
113
+ env?: RendererEnv | undefined;
114
+ }>, nextContext: any): void;
115
+ componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
116
+ env?: RendererEnv | undefined;
117
+ }>, nextState: Readonly<{}>, nextContext: any): void;
118
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
119
+ env?: RendererEnv | undefined;
120
+ }>, nextState: Readonly<{}>, nextContext: any): void;
121
+ };
122
+ new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
123
+ env?: RendererEnv | undefined;
124
+ }, context: any): {
125
+ render(): JSX.Element;
126
+ context: any;
127
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
128
+ env?: RendererEnv | undefined;
129
+ }>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
130
+ forceUpdate(callback?: (() => void) | undefined): void;
131
+ readonly props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
132
+ env?: RendererEnv | undefined;
133
+ }> & Readonly<{
134
+ children?: React.ReactNode;
135
+ }>;
136
+ state: Readonly<{}>;
137
+ refs: {
138
+ [key: string]: React.ReactInstance;
139
+ };
140
+ componentDidMount?(): void;
141
+ shouldComponentUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
142
+ env?: RendererEnv | undefined;
143
+ }>, nextState: Readonly<{}>, nextContext: any): boolean;
144
+ componentWillUnmount?(): void;
145
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
146
+ getSnapshotBeforeUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
147
+ env?: RendererEnv | undefined;
148
+ }>, prevState: Readonly<{}>): any;
149
+ componentDidUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
150
+ env?: RendererEnv | undefined;
151
+ }>, prevState: Readonly<{}>, snapshot?: any): void;
152
+ componentWillMount?(): void;
153
+ UNSAFE_componentWillMount?(): void;
154
+ componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
155
+ env?: RendererEnv | undefined;
156
+ }>, nextContext: any): void;
157
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
158
+ env?: RendererEnv | undefined;
159
+ }>, nextContext: any): void;
160
+ componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
161
+ env?: RendererEnv | undefined;
162
+ }>, nextState: Readonly<{}>, nextContext: any): void;
163
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
164
+ env?: RendererEnv | undefined;
165
+ }>, nextState: Readonly<{}>, nextContext: any): void;
166
+ };
167
+ displayName: string;
168
+ contextType: React.Context<void | RendererEnv>;
169
+ ComposedComponent: React.ComponentType<T>;
170
+ } & hoistNonReactStatic.NonReactStatics<T, {}> & {
171
+ ComposedComponent: T;
172
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @file 用于在移动端或不同语言环境下使用不同配置
3
+ */
4
+ export declare const envOverwrite: (schema: any, locale?: string | undefined) => void;
@@ -0,0 +1,78 @@
1
+ import React from 'react';
2
+ import { IRendererStore, IIRendererStore } from './store/index';
3
+ import { fetcherResult, SchemaNode, Schema, PlainObject } from './types';
4
+ import { ThemeProps } from './theme';
5
+ import { LocaleProps } from './locale';
6
+ import { RendererEnv } from './env';
7
+ import { OnEventProps } from './utils/renderer-event';
8
+ export interface TestFunc {
9
+ (path: string, schema?: Schema, resolveRenderer?: (path: string, schema?: Schema, props?: any) => null | RendererConfig): boolean;
10
+ }
11
+ export interface RendererBasicConfig {
12
+ test?: RegExp | TestFunc;
13
+ type?: string;
14
+ name?: string;
15
+ storeType?: string;
16
+ shouldSyncSuperStore?: (store: any, props: any, prevProps: any) => boolean | undefined;
17
+ storeExtendsData?: boolean | ((props: any) => boolean);
18
+ weight?: number;
19
+ isolateScope?: boolean;
20
+ isFormItem?: boolean;
21
+ autoVar?: boolean;
22
+ }
23
+ export interface RendererProps extends ThemeProps, LocaleProps, OnEventProps {
24
+ render: (region: string, node: SchemaNode, props?: PlainObject) => JSX.Element;
25
+ env: RendererEnv;
26
+ $path: string;
27
+ $schema: any;
28
+ store?: IIRendererStore;
29
+ syncSuperStore?: boolean;
30
+ data: {
31
+ [propName: string]: any;
32
+ };
33
+ defaultData?: object;
34
+ className?: any;
35
+ [propName: string]: any;
36
+ }
37
+ export declare type RendererComponent = React.ComponentType<RendererProps> & {
38
+ propsList?: Array<any>;
39
+ };
40
+ export interface RendererConfig extends RendererBasicConfig {
41
+ component: RendererComponent;
42
+ Renderer?: RendererComponent;
43
+ }
44
+ export interface RenderSchemaFilter {
45
+ (schema: Schema, renderer: RendererConfig, props?: any): Schema;
46
+ }
47
+ export interface wsObject {
48
+ url: string;
49
+ responseKey?: string;
50
+ body?: any;
51
+ }
52
+ export interface RenderOptions extends Partial<Omit<RendererEnv, 'fetcher' | 'theme'>> {
53
+ session?: string;
54
+ theme?: string;
55
+ fetcher?: (config: fetcherConfig) => Promise<fetcherResult>;
56
+ }
57
+ export interface fetcherConfig {
58
+ url: string;
59
+ method?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'jsonp';
60
+ data?: any;
61
+ config?: any;
62
+ }
63
+ export declare function addSchemaFilter(fn: RenderSchemaFilter): void;
64
+ export declare function filterSchema(schema: Schema, render: RendererConfig, props?: any): Schema;
65
+ export declare function Renderer(config: RendererBasicConfig): <T extends RendererComponent>(component: T) => T;
66
+ export declare function registerRenderer(config: RendererConfig): RendererConfig;
67
+ export declare function unRegisterRenderer(config: RendererConfig | string): void;
68
+ export declare function loadRenderer(schema: Schema, path: string): JSX.Element;
69
+ export declare const defaultOptions: RenderOptions;
70
+ export declare const stores: {
71
+ [propName: string]: IRendererStore;
72
+ };
73
+ export declare function clearStoresCache(sessions?: Array<string> | string): void;
74
+ export declare function updateEnv(options: Partial<RenderOptions>, session?: string): void;
75
+ export declare function resolveRenderer(path: string, schema?: Schema): null | RendererConfig;
76
+ export declare function getRenderers(): RendererConfig[];
77
+ export declare function getRendererByName(name: string): RendererConfig | undefined;
78
+ export { RendererEnv };
@@ -0,0 +1,25 @@
1
+ /// <reference types="react" />
2
+ /** @license amis v@version
3
+ *
4
+ * Copyright Baidu
5
+ *
6
+ * This source code is licensed under the Apache license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ import { Renderer, getRendererByName, getRenderers, registerRenderer, unRegisterRenderer, resolveRenderer, filterSchema, clearStoresCache, updateEnv, RenderOptions } from './factory';
10
+ import './renderers/builtin';
11
+ export * from './utils/index';
12
+ import * as utils from './utils/helper';
13
+ import { RegisterStore } from './store';
14
+ import { setDefaultLocale, getDefaultLocale, makeTranslator, register as registerLocale, extendLocale, localeable, LocaleProps, TranslateFn } from './locale';
15
+ import Scoped, { ScopedContext } from './Scoped';
16
+ import { classnames, getClassPrefix, setDefaultTheme, theme, getTheme, ThemeProps } from './theme';
17
+ declare const classPrefix: string | undefined;
18
+ import './actions';
19
+ import FormItem, { FormItemWrap, registerFormItem } from './renderers/Item';
20
+ import { OptionsControl, registerOptionsControl } from './renderers/Options';
21
+ import { Schema } from './types';
22
+ import { RootRenderProps } from './Root';
23
+ import { autobind } from './utils/helper';
24
+ export { clearStoresCache, updateEnv, Renderer, RegisterStore, FormItem, FormItemWrap, OptionsControl, utils, getRendererByName, registerRenderer, unRegisterRenderer, getRenderers, registerFormItem, registerOptionsControl, resolveRenderer, filterSchema, Scoped, ScopedContext, setDefaultTheme, theme, ThemeProps, getTheme, classPrefix, getClassPrefix, classnames, getDefaultLocale, setDefaultLocale, registerLocale, makeTranslator, extendLocale, localeable, LocaleProps, TranslateFn, autobind };
25
+ export declare function render(schema: Schema, props?: RootRenderProps, options?: RenderOptions, pathPrefix?: string): JSX.Element;
@@ -0,0 +1,82 @@
1
+ import React from 'react';
2
+ import hoistNonReactStatic from 'hoist-non-react-statics';
3
+ export declare type TranslateFn<T = any> = (str: T, data?: object) => T;
4
+ interface LocaleConfig {
5
+ [propsName: string]: string;
6
+ }
7
+ export declare function register(name: string, config: LocaleConfig): void;
8
+ export declare function extendLocale(name: string, config: LocaleConfig): void;
9
+ export declare function makeTranslator(locale?: string): TranslateFn;
10
+ export declare function getDefaultLocale(): string;
11
+ export declare function setDefaultLocale(loacle: string): void;
12
+ export interface LocaleProps {
13
+ locale: string;
14
+ translate: TranslateFn;
15
+ }
16
+ export declare const LocaleContext: React.Context<string>;
17
+ export declare function localeable<T extends React.ComponentType<React.ComponentProps<T> & LocaleProps>>(ComposedComponent: T): {
18
+ new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, keyof LocaleProps>> & {
19
+ locale?: string | undefined;
20
+ translate?: ((str: string, ...args: any[]) => string) | undefined;
21
+ }): {
22
+ ref: any;
23
+ childRef(ref: any): void;
24
+ getWrappedInstance(): any;
25
+ render(): JSX.Element;
26
+ context: any;
27
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, keyof LocaleProps>> & {
28
+ locale?: string | undefined;
29
+ translate?: ((str: string, ...args: any[]) => string) | undefined;
30
+ }>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
31
+ forceUpdate(callback?: (() => void) | undefined): void;
32
+ readonly props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, keyof LocaleProps>> & {
33
+ locale?: string | undefined;
34
+ translate?: ((str: string, ...args: any[]) => string) | undefined;
35
+ }> & Readonly<{
36
+ children?: React.ReactNode;
37
+ }>;
38
+ state: Readonly<{}>;
39
+ refs: {
40
+ [key: string]: React.ReactInstance;
41
+ };
42
+ componentDidMount?(): void;
43
+ shouldComponentUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, keyof LocaleProps>> & {
44
+ locale?: string | undefined;
45
+ translate?: ((str: string, ...args: any[]) => string) | undefined;
46
+ }>, nextState: Readonly<{}>, nextContext: any): boolean;
47
+ componentWillUnmount?(): void;
48
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
49
+ getSnapshotBeforeUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, keyof LocaleProps>> & {
50
+ locale?: string | undefined;
51
+ translate?: ((str: string, ...args: any[]) => string) | undefined;
52
+ }>, prevState: Readonly<{}>): any;
53
+ componentDidUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, keyof LocaleProps>> & {
54
+ locale?: string | undefined;
55
+ translate?: ((str: string, ...args: any[]) => string) | undefined;
56
+ }>, prevState: Readonly<{}>, snapshot?: any): void;
57
+ componentWillMount?(): void;
58
+ UNSAFE_componentWillMount?(): void;
59
+ componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, keyof LocaleProps>> & {
60
+ locale?: string | undefined;
61
+ translate?: ((str: string, ...args: any[]) => string) | undefined;
62
+ }>, nextContext: any): void;
63
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, keyof LocaleProps>> & {
64
+ locale?: string | undefined;
65
+ translate?: ((str: string, ...args: any[]) => string) | undefined;
66
+ }>, nextContext: any): void;
67
+ componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, keyof LocaleProps>> & {
68
+ locale?: string | undefined;
69
+ translate?: ((str: string, ...args: any[]) => string) | undefined;
70
+ }>, nextState: Readonly<{}>, nextContext: any): void;
71
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, keyof LocaleProps>> & {
72
+ locale?: string | undefined;
73
+ translate?: ((str: string, ...args: any[]) => string) | undefined;
74
+ }>, nextState: Readonly<{}>, nextContext: any): void;
75
+ };
76
+ displayName: string;
77
+ contextType: React.Context<string>;
78
+ ComposedComponent: React.ComponentType<T>;
79
+ } & hoistNonReactStatic.NonReactStatics<T, {}> & {
80
+ ComposedComponent: T;
81
+ };
82
+ export {};