amis-core 2.9.0 → 3.1.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 (331) hide show
  1. package/esm/Root.d.ts +89 -4
  2. package/esm/Root.js +15 -4
  3. package/esm/RootRenderer.d.ts +3 -1
  4. package/esm/RootRenderer.js +9 -3
  5. package/esm/SchemaRenderer.d.ts +4 -2
  6. package/esm/SchemaRenderer.js +32 -24
  7. package/esm/Scoped.d.ts +8 -0
  8. package/esm/Scoped.js +20 -5
  9. package/esm/StatusScoped.d.ts +58 -0
  10. package/esm/StatusScoped.js +54 -0
  11. package/esm/WithRootStore.d.ts +2 -2
  12. package/esm/WithRootStore.js +1 -1
  13. package/esm/WithStore.js +6 -2
  14. package/esm/actions/Action.d.ts +1 -0
  15. package/esm/actions/Action.js +19 -5
  16. package/esm/actions/AjaxAction.js +1 -1
  17. package/esm/actions/BreakAction.js +1 -1
  18. package/esm/actions/BroadcastAction.js +1 -1
  19. package/esm/actions/CmptAction.js +8 -7
  20. package/esm/actions/ContinueAction.js +1 -1
  21. package/esm/actions/CopyAction.js +1 -1
  22. package/esm/actions/CustomAction.js +4 -4
  23. package/esm/actions/DialogAction.d.ts +16 -2
  24. package/esm/actions/DialogAction.js +23 -7
  25. package/esm/actions/DrawerAction.js +1 -1
  26. package/esm/actions/EmailAction.js +1 -1
  27. package/esm/actions/LinkAction.js +1 -1
  28. package/esm/actions/LoopAction.js +1 -1
  29. package/esm/actions/PageAction.js +1 -1
  30. package/esm/actions/ParallelAction.js +1 -1
  31. package/esm/actions/SwitchAction.js +1 -1
  32. package/esm/actions/ToastAction.js +1 -1
  33. package/esm/components/CustomStyle.d.ts +13 -0
  34. package/esm/components/CustomStyle.js +18 -0
  35. package/esm/components/LazyComponent.d.ts +1 -1
  36. package/esm/components/LazyComponent.js +1 -1
  37. package/esm/components/Overlay.d.ts +3 -3
  38. package/esm/components/Overlay.js +1 -1
  39. package/esm/components/PopOver.d.ts +2 -2
  40. package/esm/components/PopOver.js +1 -1
  41. package/esm/env.d.ts +10 -2
  42. package/esm/env.js +1 -1
  43. package/esm/envOverwrite.js +1 -5
  44. package/esm/factory.d.ts +5 -3
  45. package/esm/factory.js +3 -3
  46. package/esm/index.d.ts +11 -4
  47. package/esm/index.js +55 -33
  48. package/esm/locale.d.ts +2 -2
  49. package/esm/locale.js +10 -3
  50. package/esm/renderers/Form.d.ts +3 -2
  51. package/esm/renderers/Form.js +216 -180
  52. package/esm/renderers/Item.d.ts +55 -41
  53. package/esm/renderers/Item.js +30 -19
  54. package/esm/renderers/Options.js +11 -4
  55. package/esm/renderers/Placeholder.js +1 -1
  56. package/esm/renderers/builtin.js +1 -1
  57. package/esm/renderers/register.js +1 -1
  58. package/esm/renderers/wrapControl.d.ts +2 -2
  59. package/esm/renderers/wrapControl.js +13 -16
  60. package/esm/store/app.d.ts +1 -0
  61. package/esm/store/app.js +1 -1
  62. package/esm/store/combo.d.ts +3 -0
  63. package/esm/store/combo.js +1 -1
  64. package/esm/store/crud.d.ts +2 -0
  65. package/esm/store/crud.js +31 -9
  66. package/esm/store/form.d.ts +1 -0
  67. package/esm/store/form.js +10 -4
  68. package/esm/store/formItem.js +2 -2
  69. package/esm/store/iRenderer.d.ts +1 -0
  70. package/esm/store/iRenderer.js +54 -13
  71. package/esm/store/index.js +1 -1
  72. package/esm/store/list.d.ts +1 -0
  73. package/esm/store/list.js +7 -3
  74. package/esm/store/manager.js +1 -1
  75. package/esm/store/modal.d.ts +1 -0
  76. package/esm/store/modal.js +1 -1
  77. package/esm/store/node.js +1 -1
  78. package/esm/store/pagination.d.ts +1 -0
  79. package/esm/store/pagination.js +2 -2
  80. package/esm/store/root.d.ts +4 -6
  81. package/esm/store/root.js +53 -24
  82. package/esm/store/service.d.ts +1 -0
  83. package/esm/store/service.js +1 -1
  84. package/esm/store/status.d.ts +12 -0
  85. package/esm/store/status.js +38 -0
  86. package/esm/store/table.d.ts +28 -23
  87. package/esm/store/table.js +26 -5
  88. package/esm/store/table2.d.ts +7 -6
  89. package/esm/store/table2.js +27 -23
  90. package/esm/theme.d.ts +1 -1
  91. package/esm/theme.js +1 -1
  92. package/esm/types.d.ts +7 -1
  93. package/esm/utils/Animation.js +1 -1
  94. package/esm/utils/ColorScale.js +1 -1
  95. package/esm/utils/DataSchema.js +1 -1
  96. package/esm/utils/DataScope.d.ts +3 -5
  97. package/esm/utils/DataScope.js +88 -31
  98. package/esm/utils/RootClose.js +1 -1
  99. package/esm/utils/SimpleMap.js +1 -1
  100. package/esm/utils/api.js +14 -5
  101. package/esm/utils/attachmentAdpator.js +2 -2
  102. package/esm/utils/autobind.js +1 -1
  103. package/esm/utils/columnsSplit.js +1 -1
  104. package/esm/utils/dataMapping.js +1 -1
  105. package/esm/utils/date.d.ts +7 -0
  106. package/esm/utils/date.js +34 -2
  107. package/esm/utils/debug.js +4 -4
  108. package/esm/utils/decodeEntity.js +1 -1
  109. package/esm/utils/dom.d.ts +3 -0
  110. package/esm/utils/dom.js +47 -10
  111. package/esm/utils/errors.js +1 -1
  112. package/esm/utils/escapeHtml.js +1 -1
  113. package/esm/utils/filter-schema.js +1 -1
  114. package/esm/utils/filter.js +1 -1
  115. package/esm/utils/formatDuration.js +1 -1
  116. package/esm/utils/formula.js +2 -2
  117. package/esm/utils/getVariable.js +1 -1
  118. package/esm/utils/grammar.js +3 -3
  119. package/esm/utils/handleAction.js +1 -1
  120. package/esm/utils/helper.d.ts +9 -2
  121. package/esm/utils/helper.js +52 -20
  122. package/esm/utils/highlight.js +1 -1
  123. package/esm/utils/icon.d.ts +6 -1
  124. package/esm/utils/icon.js +6 -1
  125. package/esm/utils/image.js +1 -1
  126. package/esm/utils/isPureVariable.js +3 -3
  127. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  128. package/esm/utils/keyToPath.js +1 -1
  129. package/esm/utils/makeSorter.js +1 -1
  130. package/esm/utils/memoryParse.d.ts +17 -0
  131. package/esm/utils/memoryParse.js +26 -0
  132. package/esm/utils/normalizeLink.js +1 -1
  133. package/esm/utils/normalizeOptions.js +4 -2
  134. package/esm/utils/object.d.ts +2 -0
  135. package/esm/utils/object.js +27 -2
  136. package/esm/utils/offset.js +1 -1
  137. package/esm/utils/offsetParent.js +1 -1
  138. package/esm/utils/optionValueCompare.js +1 -1
  139. package/esm/utils/position.js +1 -1
  140. package/esm/utils/prettyBytes.js +1 -1
  141. package/esm/utils/renderer-event.js +35 -32
  142. package/esm/utils/replaceText.js +1 -1
  143. package/esm/utils/resize-sensor.js +1 -1
  144. package/esm/utils/resolveCondition.d.ts +1 -0
  145. package/esm/utils/resolveCondition.js +19 -4
  146. package/esm/utils/resolveVariable.js +4 -3
  147. package/esm/utils/resolveVariableAndFilter.js +1 -1
  148. package/esm/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
  149. package/esm/utils/resolveVariableAndFilterForAsync.js +23 -5
  150. package/esm/utils/scrollPosition.js +1 -1
  151. package/esm/utils/string2regExp.js +1 -1
  152. package/esm/utils/stripNumber.js +1 -1
  153. package/esm/utils/style-helper.d.ts +12 -4
  154. package/esm/utils/style-helper.js +96 -19
  155. package/esm/utils/style.js +2 -2
  156. package/esm/utils/toNumber.js +1 -1
  157. package/esm/utils/tokenize.js +1 -1
  158. package/esm/utils/tpl-builtin.d.ts +2 -1
  159. package/esm/utils/tpl-builtin.js +19 -2
  160. package/esm/utils/tpl-lodash.js +3 -2
  161. package/esm/utils/tpl.d.ts +2 -0
  162. package/esm/utils/tpl.js +24 -2
  163. package/esm/utils/uncontrollable.js +1 -1
  164. package/esm/utils/validations.d.ts +4 -1
  165. package/esm/utils/validations.js +27 -12
  166. package/lib/Root.d.ts +89 -4
  167. package/lib/Root.js +15 -4
  168. package/lib/RootRenderer.d.ts +3 -1
  169. package/lib/RootRenderer.js +8 -2
  170. package/lib/SchemaRenderer.d.ts +4 -2
  171. package/lib/SchemaRenderer.js +32 -23
  172. package/lib/Scoped.d.ts +8 -0
  173. package/lib/Scoped.js +20 -4
  174. package/lib/StatusScoped.d.ts +58 -0
  175. package/lib/StatusScoped.js +63 -0
  176. package/lib/WithRootStore.d.ts +2 -2
  177. package/lib/WithRootStore.js +1 -1
  178. package/lib/WithStore.js +6 -2
  179. package/lib/actions/Action.d.ts +1 -0
  180. package/lib/actions/Action.js +19 -5
  181. package/lib/actions/AjaxAction.js +1 -1
  182. package/lib/actions/BreakAction.js +1 -1
  183. package/lib/actions/BroadcastAction.js +1 -1
  184. package/lib/actions/CmptAction.js +8 -7
  185. package/lib/actions/ContinueAction.js +1 -1
  186. package/lib/actions/CopyAction.js +1 -1
  187. package/lib/actions/CustomAction.js +4 -4
  188. package/lib/actions/DialogAction.d.ts +16 -2
  189. package/lib/actions/DialogAction.js +23 -7
  190. package/lib/actions/DrawerAction.js +1 -1
  191. package/lib/actions/EmailAction.js +1 -1
  192. package/lib/actions/LinkAction.js +1 -1
  193. package/lib/actions/LoopAction.js +1 -1
  194. package/lib/actions/PageAction.js +1 -1
  195. package/lib/actions/ParallelAction.js +1 -1
  196. package/lib/actions/SwitchAction.js +1 -1
  197. package/lib/actions/ToastAction.js +1 -1
  198. package/lib/components/CustomStyle.d.ts +13 -0
  199. package/lib/components/CustomStyle.js +22 -0
  200. package/lib/components/LazyComponent.d.ts +1 -1
  201. package/lib/components/LazyComponent.js +1 -1
  202. package/lib/components/Overlay.d.ts +3 -3
  203. package/lib/components/Overlay.js +1 -1
  204. package/lib/components/PopOver.d.ts +2 -2
  205. package/lib/components/PopOver.js +1 -1
  206. package/lib/env.d.ts +10 -2
  207. package/lib/env.js +1 -1
  208. package/lib/envOverwrite.js +1 -5
  209. package/lib/factory.d.ts +5 -3
  210. package/lib/factory.js +3 -3
  211. package/lib/index.d.ts +11 -4
  212. package/lib/index.js +61 -23
  213. package/lib/locale.d.ts +2 -2
  214. package/lib/locale.js +10 -3
  215. package/lib/renderers/Form.d.ts +3 -2
  216. package/lib/renderers/Form.js +215 -179
  217. package/lib/renderers/Item.d.ts +55 -41
  218. package/lib/renderers/Item.js +30 -19
  219. package/lib/renderers/Options.js +11 -4
  220. package/lib/renderers/Placeholder.js +1 -1
  221. package/lib/renderers/builtin.js +1 -1
  222. package/lib/renderers/register.js +1 -1
  223. package/lib/renderers/wrapControl.d.ts +2 -2
  224. package/lib/renderers/wrapControl.js +12 -15
  225. package/lib/store/app.d.ts +1 -0
  226. package/lib/store/app.js +1 -1
  227. package/lib/store/combo.d.ts +3 -0
  228. package/lib/store/combo.js +1 -1
  229. package/lib/store/crud.d.ts +2 -0
  230. package/lib/store/crud.js +31 -9
  231. package/lib/store/form.d.ts +1 -0
  232. package/lib/store/form.js +10 -4
  233. package/lib/store/formItem.js +2 -2
  234. package/lib/store/iRenderer.d.ts +1 -0
  235. package/lib/store/iRenderer.js +53 -12
  236. package/lib/store/index.js +1 -1
  237. package/lib/store/list.d.ts +1 -0
  238. package/lib/store/list.js +7 -3
  239. package/lib/store/manager.js +1 -1
  240. package/lib/store/modal.d.ts +1 -0
  241. package/lib/store/modal.js +1 -1
  242. package/lib/store/node.js +1 -1
  243. package/lib/store/pagination.d.ts +1 -0
  244. package/lib/store/pagination.js +2 -2
  245. package/lib/store/root.d.ts +4 -6
  246. package/lib/store/root.js +52 -23
  247. package/lib/store/service.d.ts +1 -0
  248. package/lib/store/service.js +1 -1
  249. package/lib/store/status.d.ts +12 -0
  250. package/lib/store/status.js +42 -0
  251. package/lib/store/table.d.ts +28 -23
  252. package/lib/store/table.js +26 -5
  253. package/lib/store/table2.d.ts +7 -6
  254. package/lib/store/table2.js +27 -23
  255. package/lib/theme.d.ts +1 -1
  256. package/lib/theme.js +1 -1
  257. package/lib/types.d.ts +7 -1
  258. package/lib/utils/Animation.js +1 -1
  259. package/lib/utils/ColorScale.js +1 -1
  260. package/lib/utils/DataSchema.js +1 -1
  261. package/lib/utils/DataScope.d.ts +3 -5
  262. package/lib/utils/DataScope.js +86 -29
  263. package/lib/utils/RootClose.js +1 -1
  264. package/lib/utils/SimpleMap.js +1 -1
  265. package/lib/utils/api.js +13 -4
  266. package/lib/utils/attachmentAdpator.js +2 -2
  267. package/lib/utils/autobind.js +1 -1
  268. package/lib/utils/columnsSplit.js +1 -1
  269. package/lib/utils/dataMapping.js +1 -1
  270. package/lib/utils/date.d.ts +7 -0
  271. package/lib/utils/date.js +34 -1
  272. package/lib/utils/debug.js +4 -4
  273. package/lib/utils/decodeEntity.js +1 -1
  274. package/lib/utils/dom.d.ts +3 -0
  275. package/lib/utils/dom.js +48 -9
  276. package/lib/utils/errors.js +1 -1
  277. package/lib/utils/escapeHtml.js +1 -1
  278. package/lib/utils/filter-schema.js +1 -1
  279. package/lib/utils/filter.js +1 -1
  280. package/lib/utils/formatDuration.js +1 -1
  281. package/lib/utils/formula.js +2 -2
  282. package/lib/utils/getVariable.js +1 -1
  283. package/lib/utils/grammar.js +3 -3
  284. package/lib/utils/handleAction.js +1 -1
  285. package/lib/utils/helper.d.ts +9 -2
  286. package/lib/utils/helper.js +53 -19
  287. package/lib/utils/highlight.js +1 -1
  288. package/lib/utils/icon.d.ts +6 -1
  289. package/lib/utils/icon.js +6 -1
  290. package/lib/utils/image.js +1 -1
  291. package/lib/utils/isPureVariable.js +3 -3
  292. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  293. package/lib/utils/keyToPath.js +1 -1
  294. package/lib/utils/makeSorter.js +1 -1
  295. package/lib/utils/memoryParse.d.ts +17 -0
  296. package/lib/utils/memoryParse.js +30 -0
  297. package/lib/utils/normalizeLink.js +1 -1
  298. package/lib/utils/normalizeOptions.js +4 -2
  299. package/lib/utils/object.d.ts +2 -0
  300. package/lib/utils/object.js +28 -1
  301. package/lib/utils/offset.js +1 -1
  302. package/lib/utils/offsetParent.js +1 -1
  303. package/lib/utils/optionValueCompare.js +1 -1
  304. package/lib/utils/position.js +1 -1
  305. package/lib/utils/prettyBytes.js +1 -1
  306. package/lib/utils/renderer-event.js +35 -32
  307. package/lib/utils/replaceText.js +1 -1
  308. package/lib/utils/resize-sensor.js +1 -1
  309. package/lib/utils/resolveCondition.d.ts +1 -0
  310. package/lib/utils/resolveCondition.js +19 -3
  311. package/lib/utils/resolveVariable.js +3 -2
  312. package/lib/utils/resolveVariableAndFilter.js +1 -1
  313. package/lib/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
  314. package/lib/utils/resolveVariableAndFilterForAsync.js +22 -3
  315. package/lib/utils/scrollPosition.js +1 -1
  316. package/lib/utils/string2regExp.js +1 -1
  317. package/lib/utils/stripNumber.js +1 -1
  318. package/lib/utils/style-helper.d.ts +12 -4
  319. package/lib/utils/style-helper.js +101 -18
  320. package/lib/utils/style.js +2 -2
  321. package/lib/utils/toNumber.js +1 -1
  322. package/lib/utils/tokenize.js +1 -1
  323. package/lib/utils/tpl-builtin.d.ts +2 -1
  324. package/lib/utils/tpl-builtin.js +19 -2
  325. package/lib/utils/tpl-lodash.js +3 -2
  326. package/lib/utils/tpl.d.ts +2 -0
  327. package/lib/utils/tpl.js +24 -1
  328. package/lib/utils/uncontrollable.js +1 -1
  329. package/lib/utils/validations.d.ts +4 -1
  330. package/lib/utils/validations.js +27 -12
  331. package/package.json +3 -3
package/esm/Root.d.ts CHANGED
@@ -1,15 +1,19 @@
1
+ /// <reference types="hoist-non-react-statics" />
1
2
  import React from 'react';
2
3
  import { RendererEnv } from './env';
3
4
  import { RendererProps } from './factory';
4
5
  import { TranslateFn } from './locale';
5
6
  import { IRendererStore } from './store';
6
7
  import { SchemaNode } from './types';
8
+ import { StatusScopedProps } from './StatusScoped';
7
9
  export interface RootRenderProps {
8
10
  location?: Location;
9
11
  theme?: string;
12
+ data?: Record<string, any>;
13
+ locale?: string;
10
14
  [propName: string]: any;
11
15
  }
12
- export interface RootProps {
16
+ export interface RootProps extends StatusScopedProps {
13
17
  schema: SchemaNode;
14
18
  rootStore: IRendererStore;
15
19
  env: RendererEnv;
@@ -25,22 +29,103 @@ export interface RootWrapperProps {
25
29
  schema: SchemaNode;
26
30
  rootStore: IRendererStore;
27
31
  theme: string;
32
+ data?: Record<string, any>;
33
+ context?: Record<string, any>;
28
34
  [propName: string]: any;
29
35
  }
30
36
  export declare function addRootWrapper(fn: (props: RootWrapperProps) => React.ReactNode): void;
31
37
  export declare class Root extends React.Component<RootProps> {
32
38
  resolveDefinitions(name: string): {} | undefined;
33
- render(): JSX.Element;
39
+ render(): React.JSX.Element;
34
40
  }
35
- export interface renderChildProps extends Partial<RendererProps> {
41
+ export interface renderChildProps extends Partial<Omit<RendererProps, 'statusStore'>>, StatusScopedProps {
36
42
  env: RendererEnv;
37
43
  }
38
44
  export type ReactElement = React.ReactNode[] | JSX.Element | null | false;
39
45
  export declare function renderChildren(prefix: string, node: SchemaNode, props: renderChildProps): ReactElement;
40
46
  export declare function renderChild(prefix: string, node: SchemaNode, props: renderChildProps): ReactElement;
41
- declare const _default: React.ComponentType<RootProps & {
47
+ declare const _default: {
48
+ new (props: Omit<RootProps & {
49
+ scopeRef?: ((ref: any) => void) | undefined;
50
+ }, "statusStore">): {
51
+ store?: ({
52
+ visibleState: any;
53
+ disableState: any;
54
+ staticState: any;
55
+ } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
56
+ setVisible(key: string, value?: boolean | undefined): void;
57
+ setDisable(key: string, value?: boolean | undefined): void;
58
+ setStatic(key: string, value?: boolean | undefined): void;
59
+ resetAll(): void;
60
+ } & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
61
+ visibleState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
62
+ disableState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
63
+ staticState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
64
+ }, {
65
+ setVisible(key: string, value?: boolean | undefined): void;
66
+ setDisable(key: string, value?: boolean | undefined): void;
67
+ setStatic(key: string, value?: boolean | undefined): void;
68
+ resetAll(): void;
69
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>) | undefined;
70
+ ref: any;
71
+ childRef(ref: any): void;
72
+ getWrappedInstance(): any;
73
+ componentWillUnmount(): void;
74
+ render(): React.JSX.Element;
75
+ context: unknown;
76
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<Omit<RootProps & {
77
+ scopeRef?: ((ref: any) => void) | undefined;
78
+ }, "statusStore">>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
79
+ forceUpdate(callback?: (() => void) | undefined): void;
80
+ readonly props: Readonly<Omit<RootProps & {
81
+ scopeRef?: ((ref: any) => void) | undefined;
82
+ }, "statusStore">>;
83
+ state: Readonly<{}>;
84
+ refs: {
85
+ [key: string]: React.ReactInstance;
86
+ };
87
+ componentDidMount?(): void;
88
+ shouldComponentUpdate?(nextProps: Readonly<Omit<RootProps & {
89
+ scopeRef?: ((ref: any) => void) | undefined;
90
+ }, "statusStore">>, nextState: Readonly<{}>, nextContext: any): boolean;
91
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
92
+ getSnapshotBeforeUpdate?(prevProps: Readonly<Omit<RootProps & {
93
+ scopeRef?: ((ref: any) => void) | undefined;
94
+ }, "statusStore">>, prevState: Readonly<{}>): any;
95
+ componentDidUpdate?(prevProps: Readonly<Omit<RootProps & {
96
+ scopeRef?: ((ref: any) => void) | undefined;
97
+ }, "statusStore">>, prevState: Readonly<{}>, snapshot?: any): void;
98
+ componentWillMount?(): void;
99
+ UNSAFE_componentWillMount?(): void;
100
+ componentWillReceiveProps?(nextProps: Readonly<Omit<RootProps & {
101
+ scopeRef?: ((ref: any) => void) | undefined;
102
+ }, "statusStore">>, nextContext: any): void;
103
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<Omit<RootProps & {
104
+ scopeRef?: ((ref: any) => void) | undefined;
105
+ }, "statusStore">>, nextContext: any): void;
106
+ componentWillUpdate?(nextProps: Readonly<Omit<RootProps & {
107
+ scopeRef?: ((ref: any) => void) | undefined;
108
+ }, "statusStore">>, nextState: Readonly<{}>, nextContext: any): void;
109
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<Omit<RootProps & {
110
+ scopeRef?: ((ref: any) => void) | undefined;
111
+ }, "statusStore">>, nextState: Readonly<{}>, nextContext: any): void;
112
+ };
113
+ displayName: string;
114
+ ComposedComponent: React.ComponentType<React.ComponentType<RootProps & {
115
+ scopeRef?: ((ref: any) => void) | undefined;
116
+ }> & {
117
+ ComposedComponent: React.ComponentType<RootProps>;
118
+ }>;
119
+ contextType?: React.Context<any> | undefined;
120
+ } & import("hoist-non-react-statics").NonReactStatics<React.ComponentType<RootProps & {
42
121
  scopeRef?: ((ref: any) => void) | undefined;
43
122
  }> & {
44
123
  ComposedComponent: React.ComponentType<RootProps>;
124
+ }, {}> & {
125
+ ComposedComponent: React.ComponentType<RootProps & {
126
+ scopeRef?: ((ref: any) => void) | undefined;
127
+ }> & {
128
+ ComposedComponent: React.ComponentType<RootProps>;
129
+ };
45
130
  };
46
131
  export default _default;
package/esm/Root.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -13,6 +13,7 @@ import { HocScoped } from './Scoped.js';
13
13
  import { ThemeContext } from './theme.js';
14
14
  import { isEmpty, autobind } from './utils/helper.js';
15
15
  import { RootStoreContext } from './WithRootStore.js';
16
+ import { StatusScoped } from './StatusScoped.js';
16
17
 
17
18
  var rootWrappers = [];
18
19
  function addRootWrapper(fn) {
@@ -31,7 +32,7 @@ var Root = /** @class */ (function (_super) {
31
32
  return definitions && definitions[name];
32
33
  };
33
34
  Root.prototype.render = function () {
34
- var _a = this.props, schema = _a.schema, rootStore = _a.rootStore, env = _a.env, pathPrefix = _a.pathPrefix, location = _a.location, data = _a.data, locale = _a.locale, translate = _a.translate, rest = __rest(_a, ["schema", "rootStore", "env", "pathPrefix", "location", "data", "locale", "translate"]);
35
+ var _a = this.props, schema = _a.schema, rootStore = _a.rootStore, env = _a.env, pathPrefix = _a.pathPrefix, location = _a.location, data = _a.data, context = _a.context, locale = _a.locale, translate = _a.translate, rest = __rest(_a, ["schema", "rootStore", "env", "pathPrefix", "location", "data", "context", "locale", "translate"]);
35
36
  var theme = env.theme;
36
37
  var themeName = this.props.theme || 'cxd';
37
38
  if (themeName === 'default') {
@@ -43,7 +44,7 @@ var Root = /** @class */ (function (_super) {
43
44
  return __assign(__assign({}, props), { children: wrapper(props) });
44
45
  }, __assign(__assign({ pathPrefix: pathPrefix || '', schema: isPlainObject(schema)
45
46
  ? __assign({ type: 'page' }, schema) : schema }, rest), { render: renderChild, rootStore: rootStore, resolveDefinitions: this.resolveDefinitions, location: location, data: data, env: env, classnames: theme.classnames, classPrefix: theme.classPrefix, locale: locale, translate: translate, children: (React.createElement(RootRenderer, __assign({ pathPrefix: pathPrefix || '', schema: isPlainObject(schema)
46
- ? __assign({ type: 'page' }, schema) : schema }, rest, { render: renderChild, rootStore: rootStore, resolveDefinitions: this.resolveDefinitions, location: location, data: data, env: env, classnames: theme.classnames, classPrefix: theme.classPrefix, locale: locale, translate: translate }))) })).children))));
47
+ ? __assign({ type: 'page' }, schema) : schema }, rest, { render: renderChild, rootStore: rootStore, resolveDefinitions: this.resolveDefinitions, location: location, data: data, context: context, env: env, classnames: theme.classnames, classPrefix: theme.classPrefix, locale: locale, translate: translate }))) })).children))));
47
48
  };
48
49
  __decorate([
49
50
  autobind,
@@ -53,6 +54,7 @@ var Root = /** @class */ (function (_super) {
53
54
  ], Root.prototype, "resolveDefinitions", null);
54
55
  return Root;
55
56
  }(React.Component));
57
+ var StatusScopedSchemaRenderer = StatusScoped(SchemaRenderer);
56
58
  function renderChildren(prefix, node, props) {
57
59
  if (Array.isArray(node)) {
58
60
  var elemKey = props.key || props.propKey || props.id || '';
@@ -82,8 +84,17 @@ function renderChild(prefix, node, props) {
82
84
  delete props.propsTransform;
83
85
  props = transform(props);
84
86
  }
87
+ if (['dialog', 'drawer'].includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
88
+ !(schema === null || schema === void 0 ? void 0 : schema.component) &&
89
+ !(schema === null || schema === void 0 ? void 0 : schema.children)) {
90
+ // 因为状态判断实在 SchemaRenderer 里面判断的
91
+ // 找渲染器也是在那,所以没办法在之前根据渲染器信息来包裹个组件下发 statusStore
92
+ // 所以这里先根据 type 来处理一下
93
+ // 等后续把状态处理再抽一层,可以把此处放到 SchemaRenderer 里面去
94
+ return (React.createElement(StatusScopedSchemaRenderer, __assign({ render: renderChild }, props, { schema: schema, propKey: schema.key, "$path": "".concat(prefix ? "".concat(prefix, "/") : '').concat((schema && schema.type) || '') })));
95
+ }
85
96
  return (React.createElement(SchemaRenderer, __assign({ render: renderChild }, props, { schema: schema, propKey: schema.key, "$path": "".concat(prefix ? "".concat(prefix, "/") : '').concat((schema && schema.type) || '') })));
86
97
  }
87
- var ScopedRootRenderer = HocScoped(Root);
98
+ var ScopedRootRenderer = StatusScoped(HocScoped(Root));
88
99
 
89
100
  export { Root, addRootWrapper, ScopedRootRenderer as default, renderChild, renderChildren };
@@ -5,6 +5,8 @@ import { IRootStore } from './store/root';
5
5
  import { ActionObject } from './types';
6
6
  export interface RootRendererProps extends RootProps {
7
7
  location?: any;
8
+ data?: Record<string, any>;
9
+ context?: Record<string, any>;
8
10
  render: (region: string, schema: any, props: any) => React.ReactNode;
9
11
  }
10
12
  export declare class RootRenderer extends React.Component<RootRendererProps> {
@@ -23,5 +25,5 @@ export declare class RootRenderer extends React.Component<RootRendererProps> {
23
25
  handleDrawerClose(): void;
24
26
  openFeedback(dialog: any, ctx: any): Promise<unknown>;
25
27
  reloadTarget(scoped: IScopedContext, target: string, data?: any): void;
26
- render(): string | number | boolean | JSX.Element | React.ReactFragment | null | undefined;
28
+ render(): string | number | boolean | React.JSX.Element | React.ReactFragment | null | undefined;
27
29
  }
@@ -1,12 +1,12 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends, __assign, __awaiter, __generator, __spreadArray, __read, __rest, __decorate, __metadata } from 'tslib';
7
7
  import { observer } from 'mobx-react';
8
8
  import React from 'react';
9
- import { ScopedContext } from './Scoped.js';
9
+ import { filterTarget, ScopedContext } from './Scoped.js';
10
10
  import { RootStore } from './store/root.js';
11
11
  import { guid, bulkBindFunctions, isVisible } from './utils/helper.js';
12
12
  import { filter } from './utils/tpl.js';
@@ -28,6 +28,7 @@ var RootRenderer = /** @class */ (function (_super) {
28
28
  storeType: RootStore.name,
29
29
  parentId: ''
30
30
  });
31
+ _this.store.setContext(props.context);
31
32
  _this.store.initData(props.data);
32
33
  _this.store.updateLocation(props.location, (_a = _this.props.env) === null || _a === void 0 ? void 0 : _a.parseLocation);
33
34
  bulkBindFunctions(_this, [
@@ -51,8 +52,13 @@ var RootRenderer = /** @class */ (function (_super) {
51
52
  if (props.location !== prevProps.location) {
52
53
  this.store.updateLocation(props.location);
53
54
  }
55
+ if (props.context !== prevProps.context) {
56
+ this.store.setContext(props.context);
57
+ }
54
58
  };
55
59
  RootRenderer.prototype.componentDidCatch = function (error, errorInfo) {
60
+ var _a, _b;
61
+ (_b = (_a = this.props.env) === null || _a === void 0 ? void 0 : _a.errorCatcher) === null || _b === void 0 ? void 0 : _b.call(_a, error, errorInfo);
56
62
  this.store.setRuntimeError(error, errorInfo);
57
63
  };
58
64
  RootRenderer.prototype.componentWillUnmount = function () {
@@ -149,7 +155,7 @@ var RootRenderer = /** @class */ (function (_super) {
149
155
  redirect = action.redirect && filter(action.redirect, store.data);
150
156
  redirect && env.jumpTo(redirect, action);
151
157
  action.reload &&
152
- this.reloadTarget(delegate || this.context, filter(action.reload, ctx), store.data);
158
+ this.reloadTarget(delegate || this.context, filterTarget(action.reload, ctx), store.data);
153
159
  return [2 /*return*/];
154
160
  }
155
161
  });
@@ -3,11 +3,13 @@ import { RendererConfig, RendererEnv, RendererProps } from './factory';
3
3
  import { IScopedContext } from './Scoped';
4
4
  import { Schema, SchemaNode } from './types';
5
5
  import { RendererEvent } from './utils/renderer-event';
6
- interface SchemaRendererProps extends Partial<RendererProps> {
6
+ import { StatusScopedProps } from './StatusScoped';
7
+ interface SchemaRendererProps extends Partial<Omit<RendererProps, 'statusStore'>>, StatusScopedProps {
7
8
  schema: Schema;
8
9
  $path: string;
9
10
  env: RendererEnv;
10
11
  }
12
+ export declare const RENDERER_TRANSMISSION_OMIT_PROPS: string[];
11
13
  export declare class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
12
14
  static displayName: string;
13
15
  static contextType: React.Context<IScopedContext>;
@@ -31,7 +33,7 @@ export declare class SchemaRenderer extends React.Component<SchemaRendererProps,
31
33
  renderChild(region: string, node?: SchemaNode, subProps?: {
32
34
  data?: object;
33
35
  [propName: string]: any;
34
- }): JSX.Element;
36
+ }): any;
35
37
  reRender(): void;
36
38
  render(): JSX.Element | null;
37
39
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -24,8 +24,9 @@ import 'lodash/isPlainObject';
24
24
  import { resolveVariableAndFilter } from './utils/resolveVariableAndFilter.js';
25
25
  import './utils/filter.js';
26
26
  import { buildStyle } from './utils/style.js';
27
+ import { filter } from './utils/tpl.js';
27
28
 
28
- var defaultOmitList = [
29
+ var RENDERER_TRANSMISSION_OMIT_PROPS = [
29
30
  'type',
30
31
  'name',
31
32
  '$ref',
@@ -50,7 +51,9 @@ var defaultOmitList = [
50
51
  'mode',
51
52
  'body',
52
53
  'id',
53
- 'inputOnly'
54
+ 'inputOnly',
55
+ 'label',
56
+ 'renderLabel'
54
57
  ];
55
58
  var componentCache = new SimpleMap();
56
59
  var SchemaRenderer = /** @class */ (function (_super) {
@@ -64,9 +67,12 @@ var SchemaRenderer = /** @class */ (function (_super) {
64
67
  _this.reRender = _this.reRender.bind(_this);
65
68
  _this.resolveRenderer(_this.props);
66
69
  _this.dispatchEvent = _this.dispatchEvent.bind(_this);
67
- // 监听topStore更新
70
+ // 监听statusStore更新
68
71
  _this.reaction = reaction(function () {
69
- return "".concat(props.topStore.visibleState[props.schema.id || props.$path]).concat(props.topStore.disableState[props.schema.id || props.$path]).concat(props.topStore.staticState[props.schema.id || props.$path]);
72
+ var _a, _b, _c;
73
+ var id = filter(props.schema.id, props.data);
74
+ var name = filter(props.schema.name, props.data);
75
+ return "".concat((_a = props.statusStore.visibleState[id]) !== null && _a !== void 0 ? _a : props.statusStore.visibleState[name]).concat((_b = props.statusStore.disableState[id]) !== null && _b !== void 0 ? _b : props.statusStore.disableState[name]).concat((_c = props.statusStore.staticState[id]) !== null && _c !== void 0 ? _c : props.statusStore.staticState[name]);
70
76
  }, function () { return _this.forceUpdate(); });
71
77
  return _this;
72
78
  }
@@ -168,7 +174,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
168
174
  if (subProps === void 0) { subProps = {}; }
169
175
  var _a = this.props; _a.schema; _a.$path; var env = _a.env, render = _a.render, rest = __rest(_a, ["schema", "$path", "env", "render"]);
170
176
  var $path = this.resolveRenderer(this.props).path;
171
- var omitList = defaultOmitList.concat();
177
+ var omitList = RENDERER_TRANSMISSION_OMIT_PROPS.concat();
172
178
  if (this.renderer) {
173
179
  var Component = this.renderer.component;
174
180
  Component.propsList &&
@@ -183,12 +189,12 @@ var SchemaRenderer = /** @class */ (function (_super) {
183
189
  SchemaRenderer.prototype.render = function () {
184
190
  var e_1, _a;
185
191
  var _this = this;
186
- var _b, _c, _d;
187
- var _e = this.props; _e.$path; var __ = _e.schema, rootStore = _e.rootStore, topStore = _e.topStore, render = _e.render, rest = __rest(_e, ["$path", "schema", "rootStore", "topStore", "render"]);
192
+ var _b, _c, _d, _e, _f, _g;
193
+ var _h = this.props; _h.$path; var __ = _h.schema, rootStore = _h.rootStore, statusStore = _h.statusStore, render = _h.render, rest = __rest(_h, ["$path", "schema", "rootStore", "statusStore", "render"]);
188
194
  if (__ == null) {
189
195
  return null;
190
196
  }
191
- var _f = this.resolveRenderer(this.props), $path = _f.path, schema = _f.schema;
197
+ var _j = this.resolveRenderer(this.props), $path = _j.path, schema = _j.schema;
192
198
  var theme = this.props.env.theme;
193
199
  if (Array.isArray(schema)) {
194
200
  return render($path, schema, rest);
@@ -199,14 +205,16 @@ var SchemaRenderer = /** @class */ (function (_super) {
199
205
  ? getExprProperties(schema, detectData, undefined, rest)
200
206
  : {};
201
207
  // 控制显隐
202
- var visible = isAlive(topStore)
203
- ? topStore.visibleState[schema.id || $path]
208
+ var id = filter(schema.id, rest.data);
209
+ var name = filter(schema.name, rest.data);
210
+ var visible = isAlive(statusStore)
211
+ ? (_b = statusStore.visibleState[id]) !== null && _b !== void 0 ? _b : statusStore.visibleState[name]
204
212
  : undefined;
205
- var disable = isAlive(topStore)
206
- ? topStore.disableState[schema.id || $path]
213
+ var disable = isAlive(statusStore)
214
+ ? (_c = statusStore.disableState[id]) !== null && _c !== void 0 ? _c : statusStore.disableState[name]
207
215
  : undefined;
208
- var isStatic = isAlive(topStore)
209
- ? topStore.staticState[schema.id || $path]
216
+ var isStatic = isAlive(statusStore)
217
+ ? (_d = statusStore.staticState[id]) !== null && _d !== void 0 ? _d : statusStore.staticState[name]
210
218
  : undefined;
211
219
  if (visible === false ||
212
220
  (visible !== true &&
@@ -224,7 +232,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
224
232
  ? null
225
233
  : React.isValidElement(schema.children)
226
234
  ? schema.children
227
- : schema.children(__assign(__assign(__assign({}, rest), exprProps), { $path: $path, $schema: schema, render: this.renderChild, forwardedRef: this.refFn, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent }));
235
+ : schema.children(__assign(__assign(__assign({}, rest), exprProps), { $path: $path, $schema: schema, render: this.renderChild, forwardedRef: this.refFn, rootStore: rootStore, statusStore: statusStore, dispatchEvent: this.dispatchEvent }));
228
236
  }
229
237
  else if (typeof schema.component === 'function') {
230
238
  var isSFC = !(schema.component.prototype instanceof React.Component);
@@ -234,7 +242,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
234
242
  ? null
235
243
  : React.createElement(schema.component, __assign(__assign(__assign(__assign({}, rest), restSchema_1), exprProps), {
236
244
  // value: defaultValue, // 备注: 此处并没有将value传递给渲染器
237
- defaultData: defaultData_1, defaultValue: defaultValue_1, defaultActiveKey: defaultActiveKey_1, propKey: propKey_1, $path: $path, $schema: schema, ref: isSFC ? undefined : this.refFn, forwardedRef: isSFC ? this.refFn : undefined, render: this.renderChild, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent }));
245
+ defaultData: defaultData_1, defaultValue: defaultValue_1, defaultActiveKey: defaultActiveKey_1, propKey: propKey_1, $path: $path, $schema: schema, ref: isSFC ? undefined : this.refFn, forwardedRef: isSFC ? this.refFn : undefined, render: this.renderChild, rootStore: rootStore, statusStore: statusStore, dispatchEvent: this.dispatchEvent }));
238
246
  }
239
247
  else if (Object.keys(schema).length === 0) {
240
248
  return null;
@@ -257,7 +265,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
257
265
  return [2 /*return*/, function () { return loadRenderer(schema, $path); }];
258
266
  }
259
267
  });
260
- }); }, "$path": $path, "$schema": schema, retry: this.reRender, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent })));
268
+ }); }, "$path": $path, "$schema": schema, retry: this.reRender, rootStore: rootStore, statusStore: statusStore, dispatchEvent: this.dispatchEvent })));
261
269
  }
262
270
  var renderer = this.renderer;
263
271
  schema = filterSchema(schema, renderer, rest);
@@ -284,11 +292,11 @@ var SchemaRenderer = /** @class */ (function (_super) {
284
292
  // schema.style是readonly属性
285
293
  schema = __assign(__assign({}, schema), { style: buildStyle(schema.style, detectData) });
286
294
  }
287
- var isClassComponent = (_b = Component.prototype) === null || _b === void 0 ? void 0 : _b.isReactComponent;
295
+ var isClassComponent = (_e = Component.prototype) === null || _e === void 0 ? void 0 : _e.isReactComponent;
288
296
  var $schema = __assign(__assign({}, schema), exprProps);
289
297
  var props = __assign(__assign(__assign(__assign(__assign({}, theme.getRendererConfig(renderer.name)), restSchema), chainEvents(rest, restSchema)), exprProps), {
290
298
  // value: defaultValue, // 备注: 此处并没有将value传递给渲染器
291
- defaultData: (_c = restSchema.defaultData) !== null && _c !== void 0 ? _c : defaultData, defaultValue: (_d = restSchema.defaultValue) !== null && _d !== void 0 ? _d : defaultValue, defaultActiveKey: defaultActiveKey, propKey: propKey, $path: $path, $schema: $schema, ref: this.refFn, render: this.renderChild, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent });
299
+ defaultData: (_f = restSchema.defaultData) !== null && _f !== void 0 ? _f : defaultData, defaultValue: (_g = restSchema.defaultValue) !== null && _g !== void 0 ? _g : defaultValue, defaultActiveKey: defaultActiveKey, propKey: propKey, $path: $path, $schema: $schema, ref: this.refFn, render: this.renderChild, rootStore: rootStore, statusStore: statusStore, dispatchEvent: this.dispatchEvent });
292
300
  if (disable !== undefined) {
293
301
  props.disabled = disable;
294
302
  }
@@ -298,8 +306,8 @@ var SchemaRenderer = /** @class */ (function (_super) {
298
306
  // 自动解析变量模式,主要是方便直接引入第三方组件库,无需为了支持变量封装一层
299
307
  if (renderer.autoVar) {
300
308
  try {
301
- for (var _g = __values(Object.keys($schema)), _h = _g.next(); !_h.done; _h = _g.next()) {
302
- var key = _h.value;
309
+ for (var _k = __values(Object.keys($schema)), _l = _k.next(); !_l.done; _l = _k.next()) {
310
+ var key = _l.value;
303
311
  if (typeof props[key] === 'string') {
304
312
  props[key] = resolveVariableAndFilter(props[key], props.data, '| raw');
305
313
  }
@@ -308,7 +316,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
308
316
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
309
317
  finally {
310
318
  try {
311
- if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
319
+ if (_l && !_l.done && (_a = _k.return)) _a.call(_k);
312
320
  }
313
321
  finally { if (e_1) throw e_1.error; }
314
322
  }
@@ -341,4 +349,4 @@ var PlaceholderComponent = /** @class */ (function (_super) {
341
349
  return PlaceholderComponent;
342
350
  }(React.Component));
343
351
 
344
- export { SchemaRenderer };
352
+ export { RENDERER_TRANSMISSION_OMIT_PROPS, SchemaRenderer };
package/esm/Scoped.d.ts CHANGED
@@ -5,6 +5,14 @@
5
5
  import React from 'react';
6
6
  import { RendererEnv, RendererProps } from './factory';
7
7
  import { RendererData, ActionObject } from './types';
8
+ /**
9
+ * target 里面可能包含 ?xxx=xxx,这种情况下,需要把 ?xxx=xxx 保留下来,然后对前面的部分进行 filter
10
+ * 因为后面会对 query 部分做不一样的处理。会保留原始的值。而不是会转成字符串。
11
+ * @param target
12
+ * @param data
13
+ * @returns
14
+ */
15
+ export declare function filterTarget(target: string, data: Record<string, any>): string;
8
16
  export interface ScopedComponentType extends React.Component<RendererProps> {
9
17
  focus?: () => void;
10
18
  doAction?: (action: ActionObject, data: RendererData, throwErrors?: boolean) => void;
package/esm/Scoped.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -48,7 +48,22 @@ import './utils/Animation.js';
48
48
  * @file 用来创建一个域,在这个域里面会把里面的运行时实例注册进来,方便组件之间的通信。
49
49
  * @author fex
50
50
  */
51
- var ScopedContext = React.createContext(createScopedTools(''));
51
+ /**
52
+ * target 里面可能包含 ?xxx=xxx,这种情况下,需要把 ?xxx=xxx 保留下来,然后对前面的部分进行 filter
53
+ * 因为后面会对 query 部分做不一样的处理。会保留原始的值。而不是会转成字符串。
54
+ * @param target
55
+ * @param data
56
+ * @returns
57
+ */
58
+ function filterTarget(target, data) {
59
+ var idx = target.indexOf('?');
60
+ if (~idx) {
61
+ return filter(target.slice(0, idx), data) + target.slice(idx);
62
+ }
63
+ return filter(target, data, '| raw');
64
+ }
65
+ var rootScopedContext = createScopedTools('');
66
+ var ScopedContext = React.createContext(rootScopedContext);
52
67
  function createScopedTools(path, parent, env) {
53
68
  var components = [];
54
69
  var self = {
@@ -93,14 +108,14 @@ function createScopedTools(path, parent, env) {
93
108
  getComponentById: function (id) {
94
109
  var root = this;
95
110
  // 找到顶端scoped
96
- while (root.parent) {
111
+ while (root.parent && root.parent !== rootScopedContext) {
97
112
  root = root.parent;
98
113
  }
99
114
  // 向下查找
100
115
  var component = undefined;
101
116
  findTree([root], function (item) {
102
117
  return item.getComponents().find(function (cmpt) {
103
- if (cmpt.props.id === id) {
118
+ if (filter(cmpt.props.id, cmpt.props.data) === id) {
104
119
  component = cmpt;
105
120
  return true;
106
121
  }
@@ -363,4 +378,4 @@ function HocScoped(ComposedComponent) {
363
378
  return ScopedComponent;
364
379
  }
365
380
 
366
- export { HocScoped, ScopedContext, HocScoped as default };
381
+ export { HocScoped, ScopedContext, HocScoped as default, filterTarget };
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import hoistNonReactStatic from 'hoist-non-react-statics';
3
+ import { IStatusStore } from './store/status';
4
+ export interface StatusScopedProps {
5
+ statusStore: IStatusStore;
6
+ }
7
+ export declare function StatusScoped<T extends React.ComponentType<React.ComponentProps<T> & StatusScopedProps>>(ComposedComponent: T): {
8
+ new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}): {
9
+ store?: ({
10
+ visibleState: any;
11
+ disableState: any;
12
+ staticState: any;
13
+ } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
14
+ setVisible(key: string, value?: boolean | undefined): void;
15
+ setDisable(key: string, value?: boolean | undefined): void;
16
+ setStatic(key: string, value?: boolean | undefined): void;
17
+ resetAll(): void;
18
+ } & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
19
+ visibleState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
20
+ disableState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
21
+ staticState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
22
+ }, {
23
+ setVisible(key: string, value?: boolean | undefined): void;
24
+ setDisable(key: string, value?: boolean | undefined): void;
25
+ setStatic(key: string, value?: boolean | undefined): void;
26
+ resetAll(): void;
27
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>) | undefined;
28
+ ref: any;
29
+ childRef(ref: any): void;
30
+ getWrappedInstance(): any;
31
+ componentWillUnmount(): void;
32
+ render(): React.JSX.Element;
33
+ context: unknown;
34
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
35
+ forceUpdate(callback?: (() => void) | undefined): void;
36
+ readonly props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>;
37
+ state: Readonly<{}>;
38
+ refs: {
39
+ [key: string]: React.ReactInstance;
40
+ };
41
+ componentDidMount?(): void;
42
+ shouldComponentUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextState: Readonly<{}>, nextContext: any): boolean;
43
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
44
+ getSnapshotBeforeUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, prevState: Readonly<{}>): any;
45
+ componentDidUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, prevState: Readonly<{}>, snapshot?: any): void;
46
+ componentWillMount?(): void;
47
+ UNSAFE_componentWillMount?(): void;
48
+ componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextContext: any): void;
49
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextContext: any): void;
50
+ componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextState: Readonly<{}>, nextContext: any): void;
51
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextState: Readonly<{}>, nextContext: any): void;
52
+ };
53
+ displayName: string;
54
+ ComposedComponent: React.ComponentType<T>;
55
+ contextType?: React.Context<any> | undefined;
56
+ } & hoistNonReactStatic.NonReactStatics<T, {}> & {
57
+ ComposedComponent: T;
58
+ };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * amis-core v3.1.0
3
+ * Copyright 2018-2023 fex
4
+ */
5
+
6
+ import { __extends, __assign } from 'tslib';
7
+ import React from 'react';
8
+ import hoistNonReactStatic from 'hoist-non-react-statics';
9
+ import { StatusStore } from './store/status.js';
10
+ import { destroy } from 'mobx-state-tree';
11
+
12
+ function StatusScoped(ComposedComponent) {
13
+ var _a;
14
+ var result = hoistNonReactStatic((_a = /** @class */ (function (_super) {
15
+ __extends(class_1, _super);
16
+ function class_1(props) {
17
+ var _this = _super.call(this, props) || this;
18
+ _this.childRef = _this.childRef.bind(_this);
19
+ _this.getWrappedInstance = _this.getWrappedInstance.bind(_this);
20
+ _this.store = StatusStore.create({});
21
+ return _this;
22
+ }
23
+ class_1.prototype.childRef = function (ref) {
24
+ while (ref && ref.getWrappedInstance) {
25
+ ref = ref.getWrappedInstance();
26
+ }
27
+ this.ref = ref;
28
+ };
29
+ class_1.prototype.getWrappedInstance = function () {
30
+ return this.ref;
31
+ };
32
+ class_1.prototype.componentWillUnmount = function () {
33
+ this.store && destroy(this.store);
34
+ delete this.store;
35
+ };
36
+ class_1.prototype.render = function () {
37
+ var _a;
38
+ var injectedProps = {
39
+ statusStore: this.store
40
+ };
41
+ var refConfig = ((_a = ComposedComponent.prototype) === null || _a === void 0 ? void 0 : _a.isReactComponent)
42
+ ? { ref: this.childRef }
43
+ : { forwardedRef: this.childRef };
44
+ return (React.createElement(ComposedComponent, __assign({}, this.props, injectedProps, refConfig)));
45
+ };
46
+ return class_1;
47
+ }(React.Component)),
48
+ _a.displayName = "StatusScoped(".concat(ComposedComponent.displayName || ComposedComponent.name, ")"),
49
+ _a.ComposedComponent = ComposedComponent,
50
+ _a), ComposedComponent);
51
+ return result;
52
+ }
53
+
54
+ export { StatusScoped };
@@ -334,7 +334,7 @@ export declare function withRootStore<T extends React.ComponentType<React.Compon
334
334
  rootStore: IRendererStore;
335
335
  }>>(ComposedComponent: T): {
336
336
  new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">> | Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>): {
337
- render(): JSX.Element;
337
+ render(): React.JSX.Element;
338
338
  context: unknown;
339
339
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
340
340
  forceUpdate(callback?: (() => void) | undefined): void;
@@ -357,7 +357,7 @@ export declare function withRootStore<T extends React.ComponentType<React.Compon
357
357
  UNSAFE_componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>, nextState: Readonly<{}>, nextContext: any): void;
358
358
  };
359
359
  new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>, context: any): {
360
- render(): JSX.Element;
360
+ render(): React.JSX.Element;
361
361
  context: unknown;
362
362
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
363
363
  forceUpdate(callback?: (() => void) | undefined): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5