amis-core 2.6.0 → 2.7.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 (451) hide show
  1. package/package.json +2 -2
  2. package/esm/Root.d.ts +0 -46
  3. package/esm/Root.js +0 -89
  4. package/esm/RootRenderer.d.ts +0 -27
  5. package/esm/RootRenderer.js +0 -279
  6. package/esm/SchemaRenderer.d.ts +0 -37
  7. package/esm/SchemaRenderer.js +0 -332
  8. package/esm/Scoped.d.ts +0 -38
  9. package/esm/Scoped.js +0 -262
  10. package/esm/WithRootStore.d.ts +0 -719
  11. package/esm/WithRootStore.js +0 -34
  12. package/esm/WithStore.d.ts +0 -5
  13. package/esm/WithStore.js +0 -181
  14. package/esm/actions/Action.d.ts +0 -40
  15. package/esm/actions/Action.js +0 -186
  16. package/esm/actions/AjaxAction.d.ts +0 -27
  17. package/esm/actions/AjaxAction.js +0 -96
  18. package/esm/actions/BreakAction.d.ts +0 -15
  19. package/esm/actions/BreakAction.js +0 -31
  20. package/esm/actions/BroadcastAction.d.ts +0 -19
  21. package/esm/actions/BroadcastAction.js +0 -46
  22. package/esm/actions/CmptAction.d.ts +0 -21
  23. package/esm/actions/CmptAction.js +0 -66
  24. package/esm/actions/ContinueAction.d.ts +0 -15
  25. package/esm/actions/ContinueAction.js +0 -31
  26. package/esm/actions/CopyAction.d.ts +0 -20
  27. package/esm/actions/CopyAction.js +0 -39
  28. package/esm/actions/CustomAction.d.ts +0 -22
  29. package/esm/actions/CustomAction.js +0 -74
  30. package/esm/actions/DialogAction.d.ts +0 -60
  31. package/esm/actions/DialogAction.js +0 -101
  32. package/esm/actions/DrawerAction.d.ts +0 -33
  33. package/esm/actions/DrawerAction.js +0 -65
  34. package/esm/actions/EmailAction.d.ts +0 -23
  35. package/esm/actions/EmailAction.js +0 -39
  36. package/esm/actions/LinkAction.d.ts +0 -24
  37. package/esm/actions/LinkAction.js +0 -43
  38. package/esm/actions/LoopAction.d.ts +0 -19
  39. package/esm/actions/LoopAction.js +0 -103
  40. package/esm/actions/PageAction.d.ts +0 -39
  41. package/esm/actions/PageAction.js +0 -74
  42. package/esm/actions/ParallelAction.d.ts +0 -8
  43. package/esm/actions/ParallelAction.js +0 -36
  44. package/esm/actions/SwitchAction.d.ts +0 -11
  45. package/esm/actions/SwitchAction.js +0 -48
  46. package/esm/actions/ToastAction.d.ts +0 -19
  47. package/esm/actions/ToastAction.js +0 -31
  48. package/esm/actions/index.d.ts +0 -20
  49. package/esm/components/LazyComponent.d.ts +0 -32
  50. package/esm/components/LazyComponent.js +0 -90
  51. package/esm/components/Overlay.d.ts +0 -44
  52. package/esm/components/Overlay.js +0 -255
  53. package/esm/components/PopOver.d.ts +0 -90
  54. package/esm/components/PopOver.js +0 -120
  55. package/esm/env.d.ts +0 -176
  56. package/esm/env.js +0 -12
  57. package/esm/envOverwrite.d.ts +0 -4
  58. package/esm/envOverwrite.js +0 -39
  59. package/esm/factory.d.ts +0 -85
  60. package/esm/factory.js +0 -301
  61. package/esm/index.d.ts +0 -44
  62. package/esm/index.js +0 -174
  63. package/esm/locale.d.ts +0 -84
  64. package/esm/locale.js +0 -117
  65. package/esm/renderers/Form.d.ts +0 -389
  66. package/esm/renderers/Form.js +0 -1221
  67. package/esm/renderers/Item.d.ts +0 -906
  68. package/esm/renderers/Item.js +0 -863
  69. package/esm/renderers/Options.d.ts +0 -158
  70. package/esm/renderers/Options.js +0 -908
  71. package/esm/renderers/Placeholder.d.ts +0 -6
  72. package/esm/renderers/Placeholder.js +0 -23
  73. package/esm/renderers/builtin.d.ts +0 -1
  74. package/esm/renderers/builtin.js +0 -25
  75. package/esm/renderers/register.d.ts +0 -6
  76. package/esm/renderers/register.js +0 -79
  77. package/esm/renderers/wrapControl.d.ts +0 -437
  78. package/esm/renderers/wrapControl.js +0 -509
  79. package/esm/store/app.d.ts +0 -92
  80. package/esm/store/app.js +0 -189
  81. package/esm/store/combo.d.ts +0 -10223
  82. package/esm/store/combo.js +0 -149
  83. package/esm/store/crud.d.ts +0 -128
  84. package/esm/store/crud.js +0 -447
  85. package/esm/store/form.d.ts +0 -4252
  86. package/esm/store/form.js +0 -650
  87. package/esm/store/formItem.d.ts +0 -133
  88. package/esm/store/formItem.js +0 -847
  89. package/esm/store/iRenderer.d.ts +0 -46
  90. package/esm/store/iRenderer.js +0 -185
  91. package/esm/store/index.d.ts +0 -125
  92. package/esm/store/index.js +0 -90
  93. package/esm/store/list.d.ts +0 -272
  94. package/esm/store/list.js +0 -246
  95. package/esm/store/manager.d.ts +0 -115
  96. package/esm/store/manager.js +0 -49
  97. package/esm/store/modal.d.ts +0 -84
  98. package/esm/store/modal.js +0 -50
  99. package/esm/store/node.d.ts +0 -22
  100. package/esm/store/node.js +0 -89
  101. package/esm/store/pagination.d.ts +0 -58
  102. package/esm/store/pagination.js +0 -56
  103. package/esm/store/root.d.ts +0 -85
  104. package/esm/store/root.js +0 -53
  105. package/esm/store/service.d.ts +0 -71
  106. package/esm/store/service.js +0 -411
  107. package/esm/store/table.d.ts +0 -10085
  108. package/esm/store/table.js +0 -1136
  109. package/esm/store/table2.d.ts +0 -474
  110. package/esm/store/table2.js +0 -560
  111. package/esm/theme.d.ts +0 -89
  112. package/esm/theme.js +0 -127
  113. package/esm/types.d.ts +0 -489
  114. package/esm/utils/Animation.d.ts +0 -22
  115. package/esm/utils/Animation.js +0 -285
  116. package/esm/utils/ColorScale.d.ts +0 -19
  117. package/esm/utils/ColorScale.js +0 -100
  118. package/esm/utils/DataSchema.d.ts +0 -25
  119. package/esm/utils/DataSchema.js +0 -112
  120. package/esm/utils/DataScope.d.ts +0 -26
  121. package/esm/utils/DataScope.js +0 -158
  122. package/esm/utils/RootClose.d.ts +0 -4
  123. package/esm/utils/RootClose.js +0 -22
  124. package/esm/utils/SimpleMap.d.ts +0 -8
  125. package/esm/utils/SimpleMap.js +0 -37
  126. package/esm/utils/api.d.ts +0 -34
  127. package/esm/utils/api.js +0 -595
  128. package/esm/utils/attachmentAdpator.d.ts +0 -8
  129. package/esm/utils/attachmentAdpator.js +0 -86
  130. package/esm/utils/autobind.d.ts +0 -7
  131. package/esm/utils/autobind.js +0 -89
  132. package/esm/utils/columnsSplit.d.ts +0 -1
  133. package/esm/utils/columnsSplit.js +0 -42
  134. package/esm/utils/dataMapping.d.ts +0 -9
  135. package/esm/utils/dataMapping.js +0 -141
  136. package/esm/utils/date.d.ts +0 -4
  137. package/esm/utils/date.js +0 -80
  138. package/esm/utils/debug.d.ts +0 -29
  139. package/esm/utils/debug.js +0 -379
  140. package/esm/utils/decodeEntity.d.ts +0 -5
  141. package/esm/utils/decodeEntity.js +0 -16
  142. package/esm/utils/dom.d.ts +0 -13
  143. package/esm/utils/dom.js +0 -188
  144. package/esm/utils/errors.d.ts +0 -6
  145. package/esm/utils/errors.js +0 -19
  146. package/esm/utils/escapeHtml.d.ts +0 -1
  147. package/esm/utils/escapeHtml.js +0 -20
  148. package/esm/utils/filter-schema.d.ts +0 -13
  149. package/esm/utils/filter-schema.js +0 -68
  150. package/esm/utils/filter.d.ts +0 -1
  151. package/esm/utils/filter.js +0 -493
  152. package/esm/utils/formatDuration.d.ts +0 -1
  153. package/esm/utils/formatDuration.js +0 -23
  154. package/esm/utils/formula.d.ts +0 -16
  155. package/esm/utils/formula.js +0 -219
  156. package/esm/utils/getVariable.d.ts +0 -3
  157. package/esm/utils/getVariable.js +0 -25
  158. package/esm/utils/grammar.d.ts +0 -4
  159. package/esm/utils/grammar.js +0 -50
  160. package/esm/utils/handleAction.d.ts +0 -7
  161. package/esm/utils/handleAction.js +0 -34
  162. package/esm/utils/helper.d.ts +0 -323
  163. package/esm/utils/helper.js +0 -1261
  164. package/esm/utils/highlight.d.ts +0 -1
  165. package/esm/utils/highlight.js +0 -44
  166. package/esm/utils/icon.d.ts +0 -16
  167. package/esm/utils/icon.js +0 -35
  168. package/esm/utils/image.d.ts +0 -18
  169. package/esm/utils/image.js +0 -47
  170. package/esm/utils/index.d.ts +0 -55
  171. package/esm/utils/isPureVariable.d.ts +0 -1
  172. package/esm/utils/isPureVariable.js +0 -22
  173. package/esm/utils/json-schema-2-amis-schema.d.ts +0 -6
  174. package/esm/utils/json-schema-2-amis-schema.js +0 -56
  175. package/esm/utils/keyToPath.d.ts +0 -6
  176. package/esm/utils/keyToPath.js +0 -30
  177. package/esm/utils/makeSorter.d.ts +0 -1
  178. package/esm/utils/makeSorter.js +0 -26
  179. package/esm/utils/normalizeLink.d.ts +0 -1
  180. package/esm/utils/normalizeLink.js +0 -43
  181. package/esm/utils/normalizeOptions.d.ts +0 -7
  182. package/esm/utils/normalizeOptions.js +0 -84
  183. package/esm/utils/object.d.ts +0 -15
  184. package/esm/utils/object.js +0 -142
  185. package/esm/utils/offset.d.ts +0 -15
  186. package/esm/utils/offset.js +0 -32
  187. package/esm/utils/offsetParent.d.ts +0 -5
  188. package/esm/utils/offsetParent.js +0 -23
  189. package/esm/utils/optionValueCompare.d.ts +0 -3
  190. package/esm/utils/optionValueCompare.js +0 -25
  191. package/esm/utils/position.d.ts +0 -26
  192. package/esm/utils/position.js +0 -54
  193. package/esm/utils/prettyBytes.d.ts +0 -1
  194. package/esm/utils/prettyBytes.js +0 -25
  195. package/esm/utils/renderer-event.d.ts +0 -62
  196. package/esm/utils/renderer-event.js +0 -206
  197. package/esm/utils/replaceText.d.ts +0 -3
  198. package/esm/utils/replaceText.js +0 -38
  199. package/esm/utils/resize-sensor.d.ts +0 -6
  200. package/esm/utils/resize-sensor.js +0 -172
  201. package/esm/utils/resolveVariable.d.ts +0 -1
  202. package/esm/utils/resolveVariable.js +0 -35
  203. package/esm/utils/resolveVariableAndFilter.d.ts +0 -1
  204. package/esm/utils/resolveVariableAndFilter.js +0 -33
  205. package/esm/utils/scrollPosition.d.ts +0 -16
  206. package/esm/utils/scrollPosition.js +0 -33
  207. package/esm/utils/string2regExp.d.ts +0 -1
  208. package/esm/utils/string2regExp.js +0 -14
  209. package/esm/utils/stripNumber.d.ts +0 -1
  210. package/esm/utils/stripNumber.js +0 -16
  211. package/esm/utils/style.d.ts +0 -10
  212. package/esm/utils/style.js +0 -58
  213. package/esm/utils/toNumber.d.ts +0 -7
  214. package/esm/utils/toNumber.js +0 -18
  215. package/esm/utils/tokenize.d.ts +0 -1
  216. package/esm/utils/tokenize.js +0 -29
  217. package/esm/utils/tpl-builtin.d.ts +0 -18
  218. package/esm/utils/tpl-builtin.js +0 -59
  219. package/esm/utils/tpl-lodash.d.ts +0 -4
  220. package/esm/utils/tpl-lodash.js +0 -62
  221. package/esm/utils/tpl.d.ts +0 -11
  222. package/esm/utils/tpl.js +0 -131
  223. package/esm/utils/uncontrollable.d.ts +0 -4
  224. package/esm/utils/uncontrollable.js +0 -14
  225. package/esm/utils/validations.d.ts +0 -39
  226. package/esm/utils/validations.js +0 -440
  227. package/lib/Root.d.ts +0 -46
  228. package/lib/Root.js +0 -102
  229. package/lib/RootRenderer.d.ts +0 -27
  230. package/lib/RootRenderer.js +0 -290
  231. package/lib/SchemaRenderer.d.ts +0 -37
  232. package/lib/SchemaRenderer.js +0 -342
  233. package/lib/Scoped.d.ts +0 -38
  234. package/lib/Scoped.js +0 -274
  235. package/lib/WithRootStore.d.ts +0 -719
  236. package/lib/WithRootStore.js +0 -44
  237. package/lib/WithStore.d.ts +0 -5
  238. package/lib/WithStore.js +0 -190
  239. package/lib/actions/Action.d.ts +0 -40
  240. package/lib/actions/Action.js +0 -197
  241. package/lib/actions/AjaxAction.d.ts +0 -27
  242. package/lib/actions/AjaxAction.js +0 -100
  243. package/lib/actions/BreakAction.d.ts +0 -15
  244. package/lib/actions/BreakAction.js +0 -35
  245. package/lib/actions/BroadcastAction.d.ts +0 -19
  246. package/lib/actions/BroadcastAction.js +0 -50
  247. package/lib/actions/CmptAction.d.ts +0 -21
  248. package/lib/actions/CmptAction.js +0 -70
  249. package/lib/actions/ContinueAction.d.ts +0 -15
  250. package/lib/actions/ContinueAction.js +0 -35
  251. package/lib/actions/CopyAction.d.ts +0 -20
  252. package/lib/actions/CopyAction.js +0 -43
  253. package/lib/actions/CustomAction.d.ts +0 -22
  254. package/lib/actions/CustomAction.js +0 -78
  255. package/lib/actions/DialogAction.d.ts +0 -60
  256. package/lib/actions/DialogAction.js +0 -108
  257. package/lib/actions/DrawerAction.d.ts +0 -33
  258. package/lib/actions/DrawerAction.js +0 -70
  259. package/lib/actions/EmailAction.d.ts +0 -23
  260. package/lib/actions/EmailAction.js +0 -48
  261. package/lib/actions/LinkAction.d.ts +0 -24
  262. package/lib/actions/LinkAction.js +0 -47
  263. package/lib/actions/LoopAction.d.ts +0 -19
  264. package/lib/actions/LoopAction.js +0 -107
  265. package/lib/actions/PageAction.d.ts +0 -39
  266. package/lib/actions/PageAction.js +0 -80
  267. package/lib/actions/ParallelAction.d.ts +0 -8
  268. package/lib/actions/ParallelAction.js +0 -40
  269. package/lib/actions/SwitchAction.d.ts +0 -11
  270. package/lib/actions/SwitchAction.js +0 -52
  271. package/lib/actions/ToastAction.d.ts +0 -19
  272. package/lib/actions/ToastAction.js +0 -35
  273. package/lib/actions/index.d.ts +0 -20
  274. package/lib/components/LazyComponent.d.ts +0 -32
  275. package/lib/components/LazyComponent.js +0 -99
  276. package/lib/components/Overlay.d.ts +0 -44
  277. package/lib/components/Overlay.js +0 -266
  278. package/lib/components/PopOver.d.ts +0 -90
  279. package/lib/components/PopOver.js +0 -129
  280. package/lib/env.d.ts +0 -176
  281. package/lib/env.js +0 -20
  282. package/lib/envOverwrite.d.ts +0 -4
  283. package/lib/envOverwrite.js +0 -43
  284. package/lib/factory.d.ts +0 -85
  285. package/lib/factory.js +0 -324
  286. package/lib/index.d.ts +0 -44
  287. package/lib/index.js +0 -460
  288. package/lib/locale.d.ts +0 -84
  289. package/lib/locale.js +0 -133
  290. package/lib/renderers/Form.d.ts +0 -389
  291. package/lib/renderers/Form.js +0 -1234
  292. package/lib/renderers/Item.d.ts +0 -906
  293. package/lib/renderers/Item.js +0 -879
  294. package/lib/renderers/Options.d.ts +0 -158
  295. package/lib/renderers/Options.js +0 -920
  296. package/lib/renderers/Placeholder.d.ts +0 -6
  297. package/lib/renderers/Placeholder.js +0 -31
  298. package/lib/renderers/builtin.d.ts +0 -1
  299. package/lib/renderers/builtin.js +0 -27
  300. package/lib/renderers/register.d.ts +0 -6
  301. package/lib/renderers/register.js +0 -83
  302. package/lib/renderers/wrapControl.d.ts +0 -437
  303. package/lib/renderers/wrapControl.js +0 -520
  304. package/lib/store/app.d.ts +0 -92
  305. package/lib/store/app.js +0 -193
  306. package/lib/store/combo.d.ts +0 -10223
  307. package/lib/store/combo.js +0 -154
  308. package/lib/store/crud.d.ts +0 -128
  309. package/lib/store/crud.js +0 -455
  310. package/lib/store/form.d.ts +0 -4252
  311. package/lib/store/form.js +0 -664
  312. package/lib/store/formItem.d.ts +0 -133
  313. package/lib/store/formItem.js +0 -858
  314. package/lib/store/iRenderer.d.ts +0 -46
  315. package/lib/store/iRenderer.js +0 -189
  316. package/lib/store/index.d.ts +0 -125
  317. package/lib/store/index.js +0 -101
  318. package/lib/store/list.d.ts +0 -272
  319. package/lib/store/list.js +0 -256
  320. package/lib/store/manager.d.ts +0 -115
  321. package/lib/store/manager.js +0 -56
  322. package/lib/store/modal.d.ts +0 -84
  323. package/lib/store/modal.js +0 -54
  324. package/lib/store/node.d.ts +0 -22
  325. package/lib/store/node.js +0 -93
  326. package/lib/store/pagination.d.ts +0 -58
  327. package/lib/store/pagination.js +0 -60
  328. package/lib/store/root.d.ts +0 -85
  329. package/lib/store/root.js +0 -57
  330. package/lib/store/service.d.ts +0 -71
  331. package/lib/store/service.js +0 -415
  332. package/lib/store/table.d.ts +0 -10085
  333. package/lib/store/table.js +0 -1148
  334. package/lib/store/table2.d.ts +0 -474
  335. package/lib/store/table2.js +0 -571
  336. package/lib/theme.d.ts +0 -89
  337. package/lib/theme.js +0 -145
  338. package/lib/types.d.ts +0 -489
  339. package/lib/utils/Animation.d.ts +0 -22
  340. package/lib/utils/Animation.js +0 -290
  341. package/lib/utils/ColorScale.d.ts +0 -19
  342. package/lib/utils/ColorScale.js +0 -105
  343. package/lib/utils/DataSchema.d.ts +0 -25
  344. package/lib/utils/DataSchema.js +0 -116
  345. package/lib/utils/DataScope.d.ts +0 -26
  346. package/lib/utils/DataScope.js +0 -162
  347. package/lib/utils/RootClose.d.ts +0 -4
  348. package/lib/utils/RootClose.js +0 -30
  349. package/lib/utils/SimpleMap.d.ts +0 -8
  350. package/lib/utils/SimpleMap.js +0 -46
  351. package/lib/utils/api.d.ts +0 -34
  352. package/lib/utils/api.js +0 -621
  353. package/lib/utils/attachmentAdpator.d.ts +0 -8
  354. package/lib/utils/attachmentAdpator.js +0 -91
  355. package/lib/utils/autobind.d.ts +0 -7
  356. package/lib/utils/autobind.js +0 -94
  357. package/lib/utils/columnsSplit.d.ts +0 -1
  358. package/lib/utils/columnsSplit.js +0 -51
  359. package/lib/utils/dataMapping.d.ts +0 -9
  360. package/lib/utils/dataMapping.js +0 -151
  361. package/lib/utils/date.d.ts +0 -4
  362. package/lib/utils/date.js +0 -90
  363. package/lib/utils/debug.d.ts +0 -29
  364. package/lib/utils/debug.js +0 -392
  365. package/lib/utils/decodeEntity.d.ts +0 -5
  366. package/lib/utils/decodeEntity.js +0 -20
  367. package/lib/utils/dom.d.ts +0 -13
  368. package/lib/utils/dom.js +0 -199
  369. package/lib/utils/errors.d.ts +0 -6
  370. package/lib/utils/errors.js +0 -23
  371. package/lib/utils/escapeHtml.d.ts +0 -1
  372. package/lib/utils/escapeHtml.js +0 -24
  373. package/lib/utils/filter-schema.d.ts +0 -13
  374. package/lib/utils/filter-schema.js +0 -78
  375. package/lib/utils/filter.d.ts +0 -1
  376. package/lib/utils/filter.js +0 -503
  377. package/lib/utils/formatDuration.d.ts +0 -1
  378. package/lib/utils/formatDuration.js +0 -27
  379. package/lib/utils/formula.d.ts +0 -16
  380. package/lib/utils/formula.js +0 -234
  381. package/lib/utils/getVariable.d.ts +0 -3
  382. package/lib/utils/getVariable.js +0 -29
  383. package/lib/utils/grammar.d.ts +0 -4
  384. package/lib/utils/grammar.js +0 -54
  385. package/lib/utils/handleAction.d.ts +0 -7
  386. package/lib/utils/handleAction.js +0 -39
  387. package/lib/utils/helper.d.ts +0 -323
  388. package/lib/utils/helper.js +0 -1361
  389. package/lib/utils/highlight.d.ts +0 -1
  390. package/lib/utils/highlight.js +0 -52
  391. package/lib/utils/icon.d.ts +0 -16
  392. package/lib/utils/icon.js +0 -43
  393. package/lib/utils/image.d.ts +0 -18
  394. package/lib/utils/image.js +0 -56
  395. package/lib/utils/index.d.ts +0 -55
  396. package/lib/utils/isPureVariable.d.ts +0 -1
  397. package/lib/utils/isPureVariable.js +0 -26
  398. package/lib/utils/json-schema-2-amis-schema.d.ts +0 -6
  399. package/lib/utils/json-schema-2-amis-schema.js +0 -60
  400. package/lib/utils/keyToPath.d.ts +0 -6
  401. package/lib/utils/keyToPath.js +0 -34
  402. package/lib/utils/makeSorter.d.ts +0 -1
  403. package/lib/utils/makeSorter.js +0 -30
  404. package/lib/utils/normalizeLink.d.ts +0 -1
  405. package/lib/utils/normalizeLink.js +0 -47
  406. package/lib/utils/normalizeOptions.d.ts +0 -7
  407. package/lib/utils/normalizeOptions.js +0 -92
  408. package/lib/utils/object.d.ts +0 -15
  409. package/lib/utils/object.js +0 -156
  410. package/lib/utils/offset.d.ts +0 -15
  411. package/lib/utils/offset.js +0 -37
  412. package/lib/utils/offsetParent.d.ts +0 -5
  413. package/lib/utils/offsetParent.js +0 -28
  414. package/lib/utils/optionValueCompare.d.ts +0 -3
  415. package/lib/utils/optionValueCompare.js +0 -30
  416. package/lib/utils/position.d.ts +0 -26
  417. package/lib/utils/position.js +0 -59
  418. package/lib/utils/prettyBytes.d.ts +0 -1
  419. package/lib/utils/prettyBytes.js +0 -29
  420. package/lib/utils/renderer-event.d.ts +0 -62
  421. package/lib/utils/renderer-event.js +0 -218
  422. package/lib/utils/replaceText.d.ts +0 -3
  423. package/lib/utils/replaceText.js +0 -46
  424. package/lib/utils/resize-sensor.d.ts +0 -6
  425. package/lib/utils/resize-sensor.js +0 -177
  426. package/lib/utils/resolveVariable.d.ts +0 -1
  427. package/lib/utils/resolveVariable.js +0 -39
  428. package/lib/utils/resolveVariableAndFilter.d.ts +0 -1
  429. package/lib/utils/resolveVariableAndFilter.js +0 -37
  430. package/lib/utils/scrollPosition.d.ts +0 -16
  431. package/lib/utils/scrollPosition.js +0 -37
  432. package/lib/utils/string2regExp.d.ts +0 -1
  433. package/lib/utils/string2regExp.js +0 -18
  434. package/lib/utils/stripNumber.d.ts +0 -1
  435. package/lib/utils/stripNumber.js +0 -20
  436. package/lib/utils/style.d.ts +0 -10
  437. package/lib/utils/style.js +0 -67
  438. package/lib/utils/toNumber.d.ts +0 -7
  439. package/lib/utils/toNumber.js +0 -22
  440. package/lib/utils/tokenize.d.ts +0 -1
  441. package/lib/utils/tokenize.js +0 -33
  442. package/lib/utils/tpl-builtin.d.ts +0 -18
  443. package/lib/utils/tpl-builtin.js +0 -75
  444. package/lib/utils/tpl-lodash.d.ts +0 -4
  445. package/lib/utils/tpl-lodash.js +0 -71
  446. package/lib/utils/tpl.d.ts +0 -11
  447. package/lib/utils/tpl.js +0 -140
  448. package/lib/utils/uncontrollable.d.ts +0 -4
  449. package/lib/utils/uncontrollable.js +0 -22
  450. package/lib/utils/validations.d.ts +0 -39
  451. package/lib/utils/validations.js +0 -455
@@ -1,1234 +0,0 @@
1
- /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
4
- */
5
-
6
- 'use strict';
7
-
8
- Object.defineProperty(exports, '__esModule', { value: true });
9
-
10
- var tslib = require('tslib');
11
- var React = require('react');
12
- var extend = require('lodash/extend');
13
- var factory = require('../factory.js');
14
- var form = require('../store/form.js');
15
- var tpl = require('../utils/tpl.js');
16
- var filterSchema = require('../utils/filter-schema.js');
17
- var helper = require('../utils/helper.js');
18
- var debounce = require('lodash/debounce');
19
- var flatten = require('lodash/flatten');
20
- var find = require('lodash/find');
21
- var Scoped = require('../Scoped.js');
22
- require('amis-formula');
23
- require('moment');
24
- var object = require('../utils/object.js');
25
- var getVariable = require('../utils/getVariable.js');
26
- var dataMapping = require('../utils/dataMapping.js');
27
- require('../utils/filter.js');
28
- var api = require('../utils/api.js');
29
- var LazyComponent = require('../components/LazyComponent.js');
30
- var mobxStateTree = require('mobx-state-tree');
31
-
32
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
33
-
34
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
35
- var extend__default = /*#__PURE__*/_interopDefaultLegacy(extend);
36
- var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
37
- var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
38
- var find__default = /*#__PURE__*/_interopDefaultLegacy(find);
39
-
40
- var Form = /** @class */ (function (_super) {
41
- tslib.__extends(Form, _super);
42
- function Form(props) {
43
- var _this = _super.call(this, props) || this;
44
- _this.hooks = {};
45
- _this.shouldLoadInitApi = false;
46
- _this.lazyEmitChange = debounce__default["default"](_this.emitChange.bind(_this), 250, {
47
- trailing: true,
48
- leading: false
49
- });
50
- _this.onInit = _this.onInit.bind(_this);
51
- _this.handleAction = _this.handleAction.bind(_this);
52
- _this.handleQuery = _this.handleQuery.bind(_this);
53
- _this.handleChange = _this.handleChange.bind(_this);
54
- _this.handleDialogConfirm = _this.handleDialogConfirm.bind(_this);
55
- _this.handleDialogClose = _this.handleDialogClose.bind(_this);
56
- _this.handleDrawerConfirm = _this.handleDrawerConfirm.bind(_this);
57
- _this.handleDrawerClose = _this.handleDrawerClose.bind(_this);
58
- _this.handleFormSubmit = _this.handleFormSubmit.bind(_this);
59
- _this.validate = _this.validate.bind(_this);
60
- _this.submit = _this.submit.bind(_this);
61
- _this.addHook = _this.addHook.bind(_this);
62
- _this.removeHook = _this.removeHook.bind(_this);
63
- _this.emitChange = _this.emitChange.bind(_this);
64
- _this.handleBulkChange = _this.handleBulkChange.bind(_this);
65
- _this.renderFormItems = _this.renderFormItems.bind(_this);
66
- _this.reload = _this.reload.bind(_this);
67
- _this.silentReload = _this.silentReload.bind(_this);
68
- _this.initInterval = _this.initInterval.bind(_this);
69
- _this.blockRouting = _this.blockRouting.bind(_this);
70
- _this.beforePageUnload = _this.beforePageUnload.bind(_this);
71
- var store = props.store, canAccessSuperData = props.canAccessSuperData, persistData = props.persistData, simpleMode = props.simpleMode;
72
- store.setCanAccessSuperData(canAccessSuperData !== false);
73
- store.setPersistData(persistData);
74
- if (simpleMode) {
75
- store.setInited(true);
76
- }
77
- if (store &&
78
- store.parentStore &&
79
- store.parentStore.storeType === 'ComboStore') {
80
- var combo = store.parentStore;
81
- combo.addForm(store);
82
- combo.forms.forEach(function (form) {
83
- return form.items.forEach(function (item) { return item.unique && item.syncOptions(undefined, form.data); });
84
- });
85
- }
86
- return _this;
87
- }
88
- Form.prototype.componentDidMount = function () {
89
- var _this = this;
90
- var _a, _b;
91
- var _c = this.props, initApi = _c.initApi, initFetch = _c.initFetch, initFetchOn = _c.initFetchOn, initAsyncApi = _c.initAsyncApi, initFinishedField = _c.initFinishedField, initCheckInterval = _c.initCheckInterval, store = _c.store, _d = _c.messages, fetchSuccess = _d.fetchSuccess, fetchFailed = _d.fetchFailed, onValidate = _c.onValidate, promptPageLeave = _c.promptPageLeave, env = _c.env, rules = _c.rules;
92
- this.mounted = true;
93
- if (onValidate) {
94
- var finalValidate_1 = helper.promisify(onValidate);
95
- this.disposeOnValidate = this.addHook(function () { return tslib.__awaiter(_this, void 0, void 0, function () {
96
- var result;
97
- return tslib.__generator(this, function (_a) {
98
- switch (_a.label) {
99
- case 0: return [4 /*yield*/, finalValidate_1(store.data, store)];
100
- case 1:
101
- result = _a.sent();
102
- if (result && object.isObject(result)) {
103
- Object.keys(result).forEach(function (key) {
104
- var msg = result[key];
105
- var items = store.getItemsByPath(key);
106
- // 没有找到
107
- if (!Array.isArray(items) || !items.length) {
108
- return;
109
- }
110
- // 在setError之前,提前把残留的error信息清除掉,否则每次onValidate后都会一直把报错 append 上去
111
- items.forEach(function (item) { return item.clearError(); });
112
- if (msg) {
113
- msg = Array.isArray(msg) ? msg : [msg];
114
- items.forEach(function (item) { return item.addError(msg); });
115
- }
116
- delete result[key];
117
- });
118
- helper.isEmpty(result)
119
- ? store.clearRestError()
120
- : store.setRestError(Object.keys(result).map(function (key) { return result[key]; }));
121
- }
122
- return [2 /*return*/];
123
- }
124
- });
125
- }); });
126
- }
127
- if (Array.isArray(rules) && rules.length) {
128
- this.disposeRulesValidate = this.addHook(function () {
129
- if (!store.valid) {
130
- return;
131
- }
132
- rules.forEach(function (item) {
133
- return !tpl.evalExpression(item.rule, store.data) &&
134
- store.addRestError(item.message, item.name);
135
- });
136
- });
137
- }
138
- if (api.isEffectiveApi(initApi, store.data, initFetch, initFetchOn)) {
139
- store
140
- .fetchInitData(initApi, store.data, {
141
- successMessage: fetchSuccess,
142
- errorMessage: fetchFailed,
143
- onSuccess: function () {
144
- if (!api.isEffectiveApi(initAsyncApi, store.data) ||
145
- store.data[initFinishedField || 'finished']) {
146
- return;
147
- }
148
- return helper.until(function () { return store.checkRemote(initAsyncApi, store.data); }, function (ret) { return ret && ret[initFinishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); }, initCheckInterval);
149
- }
150
- })
151
- .then(this.initInterval)
152
- .then(this.onInit);
153
- }
154
- else {
155
- setTimeout(this.onInit.bind(this), 4);
156
- }
157
- if (promptPageLeave) {
158
- window.addEventListener('beforeunload', this.beforePageUnload);
159
- this.unBlockRouting = (_b = (_a = env.blockRouting) === null || _a === void 0 ? void 0 : _a.call(env, this.blockRouting)) !== null && _b !== void 0 ? _b : undefined;
160
- }
161
- };
162
- Form.prototype.componentDidUpdate = function (prevProps) {
163
- var props = this.props;
164
- var store = props.store;
165
- if (api.isApiOutdated(prevProps.initApi, props.initApi, prevProps.data, props.data)) {
166
- var fetchSuccess = props.fetchSuccess, fetchFailed = props.fetchFailed;
167
- store[store.hasRemoteData ? 'fetchData' : 'fetchInitData'](props.initApi, store.data, {
168
- successMessage: fetchSuccess,
169
- errorMessage: fetchFailed
170
- }).then(this.initInterval);
171
- }
172
- };
173
- Form.prototype.componentWillUnmount = function () {
174
- var _a;
175
- this.mounted = false;
176
- clearTimeout(this.timer);
177
- // this.lazyHandleChange.flush();
178
- this.lazyEmitChange.cancel();
179
- this.asyncCancel && this.asyncCancel();
180
- this.disposeOnValidate && this.disposeOnValidate();
181
- this.disposeRulesValidate && this.disposeRulesValidate();
182
- window.removeEventListener('beforeunload', this.beforePageUnload);
183
- (_a = this.unBlockRouting) === null || _a === void 0 ? void 0 : _a.call(this);
184
- };
185
- Form.prototype.blockRouting = function () {
186
- var store = this.props.store;
187
- var _a = this.props, promptPageLeaveMessage = _a.promptPageLeaveMessage, promptPageLeave = _a.promptPageLeave;
188
- if (promptPageLeave && store.modified) {
189
- return promptPageLeaveMessage || '新的修改没有保存,确认要离开?';
190
- }
191
- };
192
- Form.prototype.beforePageUnload = function (e) {
193
- var blocked = this.blockRouting();
194
- if (blocked) {
195
- e.preventDefault();
196
- e.returnValue = '';
197
- }
198
- };
199
- Form.prototype.onInit = function () {
200
- return tslib.__awaiter(this, void 0, void 0, function () {
201
- var _a, onInit, store, persistData, submitOnInit, dispatchEvent, data, initedAt, hooks, dispatcher;
202
- return tslib.__generator(this, function (_b) {
203
- switch (_b.label) {
204
- case 0:
205
- _a = this.props, onInit = _a.onInit, store = _a.store, persistData = _a.persistData, submitOnInit = _a.submitOnInit, dispatchEvent = _a.dispatchEvent;
206
- if (!mobxStateTree.isAlive(store)) {
207
- return [2 /*return*/];
208
- }
209
- data = object.cloneObject(store.data);
210
- initedAt = store.initedAt;
211
- store.setInited(true);
212
- hooks = this.hooks['init'] || [];
213
- return [4 /*yield*/, Promise.all(hooks.map(function (hook) { return hook(data); }))];
214
- case 1:
215
- _b.sent();
216
- if (!mobxStateTree.isAlive(store)) {
217
- return [2 /*return*/];
218
- }
219
- if (store.initedAt !== initedAt) {
220
- // 说明,之前的数据已经失效了。
221
- // 比如 combo 一开始设置了初始值,然后 form 的 initApi 又返回了新的值。
222
- // 这个时候 store 的数据应该已经 init 了新的值。但是 data 还是老的,这个时候
223
- // onInit 出去就是错误的。
224
- data = tslib.__assign(tslib.__assign({}, data), store.data);
225
- }
226
- if (persistData) {
227
- store.getLocalPersistData();
228
- data = object.cloneObject(store.data);
229
- }
230
- return [4 /*yield*/, dispatchEvent('inited', object.createObject(this.props.data, data))];
231
- case 2:
232
- dispatcher = _b.sent();
233
- if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
234
- onInit && onInit(data, this.props);
235
- }
236
- submitOnInit &&
237
- this.handleAction(undefined, {
238
- type: 'submit'
239
- }, store.data);
240
- return [2 /*return*/];
241
- }
242
- });
243
- });
244
- };
245
- Form.prototype.reload = function (subPath, query, ctx, silent) {
246
- var _a;
247
- var _this = this;
248
- if (query) {
249
- return this.receive(query);
250
- }
251
- var _b = this.props, store = _b.store, initApi = _b.initApi, initAsyncApi = _b.initAsyncApi, initFinishedField = _b.initFinishedField, _c = _b.messages, fetchSuccess = _c.fetchSuccess, fetchFailed = _c.fetchFailed;
252
- api.isEffectiveApi(initAsyncApi, store.data) &&
253
- store.updateData((_a = {},
254
- _a[initFinishedField || 'finished'] = false,
255
- _a));
256
- api.isEffectiveApi(initApi, store.data)
257
- ? store
258
- .fetchInitData(initApi, store.data, {
259
- successMessage: fetchSuccess,
260
- errorMessage: fetchFailed,
261
- silent: silent,
262
- onSuccess: function () {
263
- if (!api.isEffectiveApi(initAsyncApi, store.data) ||
264
- store.data[initFinishedField || 'finished']) {
265
- return;
266
- }
267
- return helper.until(function () { return store.checkRemote(initAsyncApi, store.data); }, function (ret) { return ret && ret[initFinishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); });
268
- }
269
- })
270
- .then(function (result) {
271
- if (result === null || result === void 0 ? void 0 : result.ok) {
272
- _this.initInterval(result);
273
- store.reset(undefined, false);
274
- }
275
- })
276
- : store.reset(undefined, false);
277
- };
278
- Form.prototype.receive = function (values, name, replace) {
279
- var store = this.props.store;
280
- store.updateData(values, undefined, replace);
281
- this.reload();
282
- };
283
- Form.prototype.silentReload = function (target, query) {
284
- this.reload(target, query, undefined, true);
285
- };
286
- Form.prototype.initInterval = function (value) {
287
- var _a = this.props, interval = _a.interval, silentPolling = _a.silentPolling, stopAutoRefreshWhen = _a.stopAutoRefreshWhen, data = _a.data;
288
- clearTimeout(this.timer);
289
- interval &&
290
- this.mounted &&
291
- (!stopAutoRefreshWhen || !tpl.evalExpression(stopAutoRefreshWhen, data)) &&
292
- (this.timer = setTimeout(silentPolling ? this.silentReload : this.reload, Math.max(interval, 1000)));
293
- return value;
294
- };
295
- Form.prototype.isValidated = function () {
296
- return this.props.store.validated;
297
- };
298
- Form.prototype.validate = function (forceValidate) {
299
- var _a = this.props, store = _a.store, dispatchEvent = _a.dispatchEvent, data = _a.data;
300
- this.flush();
301
- return store
302
- .validate(this.hooks['validate'] || [], forceValidate)
303
- .then(function (result) {
304
- if (result) {
305
- dispatchEvent('validateSucc', data);
306
- }
307
- else {
308
- dispatchEvent('validateError', data);
309
- }
310
- return result;
311
- });
312
- };
313
- Form.prototype.setErrors = function (errors, tag) {
314
- if (tag === void 0) { tag = 'remote'; }
315
- var store = this.props.store;
316
- store.setFormItemErrors(errors, tag);
317
- };
318
- Form.prototype.clearErrors = function () {
319
- var store = this.props.store;
320
- return store.clearErrors();
321
- };
322
- Form.prototype.getValues = function () {
323
- var store = this.props.store;
324
- this.flush();
325
- return store.data;
326
- };
327
- Form.prototype.setValues = function (value, replace) {
328
- var store = this.props.store;
329
- this.flush();
330
- store.setValues(value, undefined, replace);
331
- };
332
- Form.prototype.submit = function (fn) {
333
- var _a = this.props, store = _a.store, messages = _a.messages, __ = _a.translate, dispatchEvent = _a.dispatchEvent, data = _a.data;
334
- this.flush();
335
- var validateErrCb = function () { return dispatchEvent('validateError', data); };
336
- return store.submit(fn, this.hooks['validate'] || [], __(messages && messages.validateFailed), validateErrCb);
337
- };
338
- // 如果开启了 lazyChange,需要一个 flush 方法把队列中值应用上。
339
- Form.prototype.flush = function () {
340
- var hooks = this.hooks['flush'] || [];
341
- hooks.forEach(function (fn) { return fn(); });
342
- this.lazyEmitChange.flush();
343
- };
344
- Form.prototype.reset = function () {
345
- var _a = this.props, store = _a.store, onReset = _a.onReset;
346
- store.reset(onReset);
347
- };
348
- Form.prototype.addHook = function (fn, type) {
349
- var _this = this;
350
- if (type === void 0) { type = 'validate'; }
351
- this.hooks[type] = this.hooks[type] || [];
352
- this.hooks[type].push(type === 'flush' ? fn : helper.promisify(fn));
353
- return function () {
354
- _this.removeHook(fn, type);
355
- fn = helper.noop;
356
- };
357
- };
358
- Form.prototype.removeHook = function (fn, type) {
359
- if (type === void 0) { type = 'validate'; }
360
- var hooks = this.hooks[type];
361
- if (!hooks) {
362
- return;
363
- }
364
- for (var i = 0, len = hooks.length; i < len; i++) {
365
- var hook = hooks[i];
366
- if (hook === fn || hook.raw === fn) {
367
- hooks.splice(i, 1);
368
- len--;
369
- i--;
370
- }
371
- }
372
- };
373
- Form.prototype.handleChange = function (value, name, submit, changePristine) {
374
- if (changePristine === void 0) { changePristine = false; }
375
- var _a = this.props, store = _a.store, formLazyChange = _a.formLazyChange, persistDataKeys = _a.persistDataKeys;
376
- if (typeof name !== 'string') {
377
- return;
378
- }
379
- store.changeValue(name, value, changePristine);
380
- if (!changePristine) {
381
- (formLazyChange === false ? this.emitChange : this.lazyEmitChange)(submit);
382
- }
383
- if (store.persistData && store.inited) {
384
- store.setLocalPersistData(persistDataKeys);
385
- }
386
- };
387
- Form.prototype.formItemDispatchEvent = function (dispatchEvent) {
388
- return function (type, data) {
389
- dispatchEvent(type, data);
390
- };
391
- };
392
- Form.prototype.emitChange = function (submit) {
393
- return tslib.__awaiter(this, void 0, void 0, function () {
394
- var _a, onChange, store, submitOnChange, dispatchEvent, data, dispatcher;
395
- return tslib.__generator(this, function (_b) {
396
- switch (_b.label) {
397
- case 0:
398
- _a = this.props, onChange = _a.onChange, store = _a.store, submitOnChange = _a.submitOnChange, dispatchEvent = _a.dispatchEvent, data = _a.data;
399
- if (!mobxStateTree.isAlive(store)) {
400
- return [2 /*return*/];
401
- }
402
- return [4 /*yield*/, dispatchEvent('change', object.createObject(data, store.data))];
403
- case 1:
404
- dispatcher = _b.sent();
405
- if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
406
- onChange &&
407
- onChange(store.data, helper.difference(store.data, store.pristine), this.props);
408
- }
409
- store.clearRestError();
410
- (submit || (submitOnChange && store.inited)) &&
411
- this.handleAction(undefined, {
412
- type: 'submit'
413
- }, store.data);
414
- return [2 /*return*/];
415
- }
416
- });
417
- });
418
- };
419
- Form.prototype.handleBulkChange = function (values, submit) {
420
- var _a = this.props; _a.onChange; var store = _a.store, formLazyChange = _a.formLazyChange;
421
- store.updateData(values);
422
- store.items.forEach(function (formItem) {
423
- var updatedValue = getVariable.getVariable(values, formItem.name, false);
424
- if (updatedValue !== undefined) {
425
- // 更新验证状态但保留错误信息
426
- formItem.reset(true);
427
- // 这里需要更新value,否则提交时不会使用新的字段值校验
428
- formItem.changeTmpValue(updatedValue);
429
- formItem.validateOnChange && formItem.validate(values);
430
- }
431
- });
432
- (formLazyChange === false ? this.emitChange : this.lazyEmitChange)(submit);
433
- };
434
- Form.prototype.handleFormSubmit = function (e) {
435
- var _a = this.props, preventEnterSubmit = _a.preventEnterSubmit, onActionSensor = _a.onActionSensor;
436
- e.preventDefault();
437
- if (preventEnterSubmit) {
438
- return false;
439
- }
440
- var sensor = this.handleAction(e, {
441
- type: 'submit'
442
- }, this.props.store.data);
443
- // 让外层可以监控这个动作执行结果
444
- onActionSensor === null || onActionSensor === void 0 ? void 0 : onActionSensor(sensor);
445
- return sensor;
446
- };
447
- Form.prototype.handleReset = function (action) {
448
- var onReset = this.props.onReset;
449
- return function (data) {
450
- onReset && onReset(data, action);
451
- };
452
- };
453
- Form.prototype.handleAction = function (e, action, data, throwErrors, delegate) {
454
- if (throwErrors === void 0) { throwErrors = false; }
455
- return tslib.__awaiter(this, void 0, void 0, function () {
456
- var _a, store, onSubmit, api$1, asyncApi, finishedField, checkInterval, _b, saveSuccess, saveFailed, resetAfterSubmit, clearAfterSubmit, onAction, onSaved, onReset, onFinished, onFailed, redirect, reload, target, env, onChange, clearPersistDataAfterSubmit, trimValues, dispatchEvent, __, fields, validationRes, dispatcher;
457
- var _this = this;
458
- return tslib.__generator(this, function (_c) {
459
- switch (_c.label) {
460
- case 0:
461
- _a = this.props, store = _a.store, onSubmit = _a.onSubmit, api$1 = _a.api, asyncApi = _a.asyncApi, finishedField = _a.finishedField, checkInterval = _a.checkInterval, _b = _a.messages, saveSuccess = _b.saveSuccess, saveFailed = _b.saveFailed, resetAfterSubmit = _a.resetAfterSubmit, clearAfterSubmit = _a.clearAfterSubmit, onAction = _a.onAction, onSaved = _a.onSaved, onReset = _a.onReset, onFinished = _a.onFinished, onFailed = _a.onFailed, redirect = _a.redirect, reload = _a.reload, target = _a.target, env = _a.env, onChange = _a.onChange, clearPersistDataAfterSubmit = _a.clearPersistDataAfterSubmit, trimValues = _a.trimValues, dispatchEvent = _a.dispatchEvent, __ = _a.translate;
462
- // 做动作之前,先把数据同步一下。
463
- this.flush();
464
- if (trimValues) {
465
- store.trimValues();
466
- }
467
- // 如果 data 就是当前层,则 flush 一下。
468
- if (data === this.props.data) {
469
- data = store.data;
470
- }
471
- if (!(Array.isArray(action.required) && action.required.length)) return [3 /*break*/, 4];
472
- /** 如果是按钮指定了required,则校验前先清空一下遗留的校验报错 */
473
- store.clearErrors();
474
- fields = action.required.map(function (item) { return ({
475
- name: item,
476
- rules: { isRequired: true }
477
- }); });
478
- return [4 /*yield*/, store.validateFields(fields)];
479
- case 1:
480
- validationRes = _c.sent();
481
- if (!!validationRes) return [3 /*break*/, 3];
482
- return [4 /*yield*/, dispatchEvent('validateError', this.props.data)];
483
- case 2:
484
- dispatcher = _c.sent();
485
- if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
486
- env.notify('error', __('Form.validateFailed'));
487
- }
488
- /** 抛异常是为了在dialog中catch这个错误,避免弹窗直接关闭 */
489
- return [2 /*return*/, Promise.reject(__('Form.validateFailed'))];
490
- case 3:
491
- /** 重置validated状态,保证submit时触发表单中的校验项 */
492
- store.clearErrors();
493
- _c.label = 4;
494
- case 4:
495
- if (action.type === 'submit' ||
496
- action.actionType === 'submit' ||
497
- action.actionType === 'confirm' ||
498
- action.actionType === 'reset-and-submit' ||
499
- action.actionType === 'clear-and-submit') {
500
- store.setCurrentAction(action);
501
- if (action.actionType === 'reset-and-submit') {
502
- store.reset(this.handleReset(action));
503
- }
504
- else if (action.actionType === 'clear-and-submit') {
505
- store.clear(this.handleReset(action));
506
- }
507
- return [2 /*return*/, this.submit(function (values) {
508
- var _a;
509
- if (onSubmit && onSubmit(values, action) === false) {
510
- return Promise.resolve(false);
511
- }
512
- // 走到这里代表校验成功了
513
- dispatchEvent('validateSucc', _this.props.data);
514
- if (target) {
515
- _this.submitToTarget(target, values);
516
- dispatchEvent('submitSucc', object.createObject(_this.props.data, values));
517
- }
518
- else if (action.actionType === 'reload') {
519
- action.target && _this.reloadTarget(action.target, values);
520
- }
521
- else if (action.actionType === 'dialog') {
522
- store.openDialog(data);
523
- }
524
- else if (action.actionType === 'drawer') {
525
- store.openDrawer(data);
526
- }
527
- else if (api.isEffectiveApi(action.api || api$1, values)) {
528
- var finnalAsyncApi_1 = action.asyncApi || asyncApi;
529
- api.isEffectiveApi(finnalAsyncApi_1, store.data) &&
530
- store.updateData((_a = {},
531
- _a[finishedField || 'finished'] = false,
532
- _a));
533
- return store
534
- .saveRemote(action.api || api$1, values, {
535
- successMessage: saveSuccess,
536
- errorMessage: saveFailed,
537
- onSuccess: function (result) { return tslib.__awaiter(_this, void 0, void 0, function () {
538
- var dispatcher, cbResult;
539
- var _this = this;
540
- return tslib.__generator(this, function (_a) {
541
- switch (_a.label) {
542
- case 0: return [4 /*yield*/, dispatchEvent('submitSucc', object.createObject(this.props.data, { result: result }))];
543
- case 1:
544
- dispatcher = _a.sent();
545
- if (!api.isEffectiveApi(finnalAsyncApi_1, store.data) ||
546
- store.data[finishedField || 'finished']) {
547
- return [2 /*return*/, {
548
- cbResult: null,
549
- dispatcher: dispatcher
550
- }];
551
- }
552
- cbResult = helper.until(function () { return store.checkRemote(finnalAsyncApi_1, store.data); }, function (ret) { return ret && ret[finishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); }, checkInterval);
553
- return [2 /*return*/, {
554
- cbResult: cbResult,
555
- dispatcher: dispatcher
556
- }];
557
- }
558
- });
559
- }); },
560
- onFailed: function (result) { return tslib.__awaiter(_this, void 0, void 0, function () {
561
- var dispatcher;
562
- return tslib.__generator(this, function (_a) {
563
- switch (_a.label) {
564
- case 0: return [4 /*yield*/, dispatchEvent('submitFail', object.createObject(this.props.data, { error: result }))];
565
- case 1:
566
- dispatcher = _a.sent();
567
- return [2 /*return*/, {
568
- dispatcher: dispatcher
569
- }];
570
- }
571
- });
572
- }); }
573
- })
574
- .then(function (response) { return tslib.__awaiter(_this, void 0, void 0, function () {
575
- var feedback, confirmed;
576
- return tslib.__generator(this, function (_a) {
577
- switch (_a.label) {
578
- case 0:
579
- onSaved && onSaved(values, response);
580
- feedback = action.feedback || this.props.feedback;
581
- if (!(feedback && helper.isVisible(feedback, store.data))) return [3 /*break*/, 2];
582
- return [4 /*yield*/, this.openFeedback(feedback, store.data)];
583
- case 1:
584
- confirmed = _a.sent();
585
- // 如果 feedback 配置了,取消就跳过原有逻辑。
586
- if (feedback.skipRestOnCancel && !confirmed) {
587
- throw new helper.SkipOperation();
588
- }
589
- else if (feedback.skipRestOnConfirm && confirmed) {
590
- throw new helper.SkipOperation();
591
- }
592
- _a.label = 2;
593
- case 2: return [2 /*return*/];
594
- }
595
- });
596
- }); });
597
- }
598
- else {
599
- // type为submit,但是没有配api以及target时,只派发事件
600
- dispatchEvent('submitSucc', object.createObject(_this.props.data, values));
601
- }
602
- return Promise.resolve(null);
603
- })
604
- .then(function (values) {
605
- // 有可能 onSubmit return false 了,那么后面的就不应该再执行了。
606
- if (values === false) {
607
- return store.data;
608
- }
609
- if (onFinished && onFinished(values, action) === false) {
610
- return values;
611
- }
612
- resetAfterSubmit && store.reset(_this.handleReset(action));
613
- clearAfterSubmit && store.clear(_this.handleReset(action));
614
- clearPersistDataAfterSubmit && store.clearLocalPersistData();
615
- if (action.redirect || redirect) {
616
- var finalRedirect = tpl.filter(action.redirect || redirect, store.data);
617
- finalRedirect && env.jumpTo(finalRedirect, action);
618
- }
619
- else if (action.reload || reload) {
620
- _this.reloadTarget(action.reload || reload, store.data);
621
- }
622
- action.close && _this.closeTarget(action.close);
623
- return values;
624
- })
625
- .catch(function (reason) {
626
- if (reason instanceof helper.SkipOperation) {
627
- return;
628
- }
629
- onFailed && onFailed(reason, store.errors);
630
- if (throwErrors) {
631
- throw reason;
632
- }
633
- })];
634
- }
635
- else if (action.type === 'reset' || action.actionType === 'reset') {
636
- store.setCurrentAction(action);
637
- store.reset(onReset);
638
- }
639
- else if (action.actionType === 'clear') {
640
- store.setCurrentAction(action);
641
- store.clear(onReset);
642
- }
643
- else if (action.actionType === 'validate') {
644
- store.setCurrentAction(action);
645
- this.validate(true);
646
- }
647
- else if (action.actionType === 'dialog') {
648
- store.setCurrentAction(action);
649
- store.openDialog(data);
650
- }
651
- else if (action.actionType === 'drawer') {
652
- store.setCurrentAction(action);
653
- store.openDrawer(data);
654
- }
655
- else if (action.actionType === 'ajax') {
656
- store.setCurrentAction(action);
657
- if (!api.isEffectiveApi(action.api)) {
658
- return [2 /*return*/, env.alert(__("\u5F53 actionType \u4E3A ajax \u65F6\uFF0C\u8BF7\u8BBE\u7F6E api \u5C5E\u6027"))];
659
- }
660
- return [2 /*return*/, store
661
- .saveRemote(action.api, data, {
662
- successMessage: __((action.messages && action.messages.success) || saveSuccess),
663
- errorMessage: __((action.messages && action.messages.failed) || saveFailed)
664
- })
665
- .then(function (response) { return tslib.__awaiter(_this, void 0, void 0, function () {
666
- var redirect;
667
- return tslib.__generator(this, function (_a) {
668
- switch (_a.label) {
669
- case 0:
670
- response &&
671
- onChange &&
672
- onChange(store.data, helper.difference(store.data, store.pristine), this.props);
673
- if (!store.validated) return [3 /*break*/, 2];
674
- return [4 /*yield*/, this.validate(true)];
675
- case 1:
676
- _a.sent();
677
- _a.label = 2;
678
- case 2:
679
- if (!(action.feedback && helper.isVisible(action.feedback, store.data))) return [3 /*break*/, 4];
680
- return [4 /*yield*/, this.openFeedback(action.feedback, store.data)];
681
- case 3:
682
- _a.sent();
683
- _a.label = 4;
684
- case 4:
685
- redirect = action.redirect && tpl.filter(action.redirect, store.data);
686
- redirect && env.jumpTo(redirect, action);
687
- action.reload && this.reloadTarget(action.reload, store.data);
688
- action.close && this.closeTarget(action.close);
689
- return [2 /*return*/];
690
- }
691
- });
692
- }); })
693
- .catch(function (e) {
694
- onFailed && onFailed(e, store.errors);
695
- if (throwErrors || action.countDown) {
696
- throw e;
697
- }
698
- })];
699
- }
700
- else if (action.actionType === 'reload') {
701
- store.setCurrentAction(action);
702
- if (action.target) {
703
- this.reloadTarget(action.target, data);
704
- }
705
- else {
706
- this.receive(data);
707
- }
708
- // action.target && this.reloadTarget(action.target, data);
709
- }
710
- else if (onAction) {
711
- // 不识别的丢给上层去处理。
712
- return [2 /*return*/, onAction(e, action, data, throwErrors, delegate || this.context)];
713
- }
714
- return [2 /*return*/];
715
- }
716
- });
717
- });
718
- };
719
- Form.prototype.handleQuery = function (query) {
720
- var _a, _b;
721
- if (this.props.initApi) {
722
- this.receive(query);
723
- }
724
- else {
725
- (_b = (_a = this.props).onQuery) === null || _b === void 0 ? void 0 : _b.call(_a, query);
726
- }
727
- };
728
- Form.prototype.handleDialogConfirm = function (values, action, ctx, targets) {
729
- var _a = this.props, store = _a.store; _a.onChange;
730
- if ((action.mergeData || store.action.mergeData) &&
731
- values.length === 1 &&
732
- values[0] &&
733
- targets[0].props.type === 'form') {
734
- this.handleBulkChange(values[0], false);
735
- }
736
- store.closeDialog(true);
737
- };
738
- Form.prototype.handleDialogClose = function (confirmed) {
739
- if (confirmed === void 0) { confirmed = false; }
740
- var store = this.props.store;
741
- store.closeDialog(confirmed);
742
- };
743
- Form.prototype.handleDrawerConfirm = function (values, action, ctx, targets) {
744
- var _a = this.props, store = _a.store, onChange = _a.onChange;
745
- if ((action.mergeData || store.action.mergeData) &&
746
- values.length === 1 &&
747
- values[0] &&
748
- targets[0].props.type === 'form') {
749
- store.updateData(values[0]);
750
- onChange &&
751
- onChange(store.data, helper.difference(store.data, store.pristine), this.props);
752
- }
753
- store.closeDrawer(true);
754
- };
755
- Form.prototype.handleDrawerClose = function () {
756
- var store = this.props.store;
757
- store.closeDrawer(false);
758
- };
759
- Form.prototype.submitToTarget = function (target, values) {
760
- // 会被覆写
761
- };
762
- Form.prototype.reloadTarget = function (target, data) {
763
- // 会被覆写
764
- };
765
- Form.prototype.closeTarget = function (target) {
766
- // 会被覆写
767
- };
768
- Form.prototype.openFeedback = function (dialog, ctx) {
769
- var _this = this;
770
- return new Promise(function (resolve) {
771
- var store = _this.props.store;
772
- store.setCurrentAction({
773
- type: 'button',
774
- actionType: 'dialog',
775
- dialog: dialog
776
- });
777
- store.openDialog(ctx, undefined, function (confirmed) {
778
- resolve(confirmed);
779
- });
780
- });
781
- };
782
- Form.prototype.buildActions = function () {
783
- var _a = this.props, actions = _a.actions, submitText = _a.submitText, body = _a.body, __ = _a.translate, loadingConfig = _a.loadingConfig;
784
- if (typeof actions !== 'undefined' ||
785
- !submitText ||
786
- (Array.isArray(body) &&
787
- body.some(function (item) {
788
- var _a, _b, _c;
789
- return item &&
790
- !!~['submit', 'button', 'button-group', 'reset'].indexOf(((_b = (_a = item === null || item === void 0 ? void 0 : item.body) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.type) ||
791
- ((_c = item === null || item === void 0 ? void 0 : item.body) === null || _c === void 0 ? void 0 : _c.type) ||
792
- item.type);
793
- }))) {
794
- return actions;
795
- }
796
- return [
797
- {
798
- type: 'submit',
799
- label: __(submitText),
800
- primary: true,
801
- loadingConfig: loadingConfig
802
- }
803
- ];
804
- };
805
- Form.prototype.renderFormItems = function (schema, region, otherProps) {
806
- if (region === void 0) { region = ''; }
807
- if (otherProps === void 0) { otherProps = {}; }
808
- var body = Array.isArray(schema.body)
809
- ? schema.body
810
- : schema.body
811
- ? [schema.body]
812
- : [];
813
- // 旧用法,让 wrapper 走走 compat 逻辑兼容旧用法
814
- // 后续可以删除。
815
- if (!body.length && schema.controls) {
816
- console.warn('请用 body 代替 controls');
817
- body = [
818
- {
819
- size: 'none',
820
- type: 'wrapper',
821
- wrap: false,
822
- controls: schema.controls
823
- }
824
- ];
825
- }
826
- return this.renderChildren(body, region, otherProps);
827
- };
828
- Form.prototype.renderChildren = function (children, region, otherProps) {
829
- var _this = this;
830
- if (otherProps === void 0) { otherProps = {}; }
831
- children = children || [];
832
- if (!Array.isArray(children)) {
833
- children = [children];
834
- }
835
- if (this.props.mode === 'row') {
836
- this.props.classPrefix;
837
- children = flatten__default["default"](children).filter(function (item) {
838
- if (item.hidden || item.visible === false) {
839
- return false;
840
- }
841
- var exprProps = filterSchema.getExprProperties(item, _this.props.store.data, undefined, _this.props);
842
- if (exprProps.hidden || exprProps.visible === false) {
843
- return false;
844
- }
845
- return true;
846
- });
847
- if (!children.length) {
848
- return null;
849
- }
850
- var cx_1 = this.props.classnames;
851
- return (React__default["default"].createElement("div", { className: cx_1('Form-row') }, children.map(function (control, key) {
852
- return ~['hidden', 'formula'].indexOf(control.type) ||
853
- control.mode === 'inline' ? (_this.renderChild(control, key, otherProps)) : (React__default["default"].createElement("div", { key: key, className: cx_1("Form-col", control.columnClassName) }, _this.renderChild(control, '', tslib.__assign(tslib.__assign({}, otherProps), { mode: 'row' }))));
854
- })));
855
- }
856
- return children.map(function (control, key) {
857
- return _this.renderChild(control, key, otherProps, region);
858
- });
859
- };
860
- Form.prototype.renderChild = function (control, key, otherProps, region) {
861
- if (key === void 0) { key = ''; }
862
- if (otherProps === void 0) { otherProps = {}; }
863
- if (region === void 0) { region = ''; }
864
- if (!control) {
865
- return null;
866
- }
867
- else if (typeof control === 'string') {
868
- control = {
869
- type: 'tpl',
870
- tpl: control
871
- };
872
- }
873
- var props = tslib.__assign(tslib.__assign({}, this.props), otherProps);
874
- var form = this.props.store;
875
- var render = props.render, mode = props.mode, horizontal = props.horizontal, store = props.store, disabled = props.disabled, controlWidth = props.controlWidth, resolveDefinitions = props.resolveDefinitions, lazyChange = props.lazyChange; props.formLazyChange; var dispatchEvent = props.dispatchEvent, labelAlign = props.labelAlign, labelWidth = props.labelWidth, _a = props.static, isStatic = _a === void 0 ? false : _a;
876
- var subProps = {
877
- formStore: form,
878
- data: store.data,
879
- key: "".concat(control.name || '', "-").concat(control.type, "-").concat(key),
880
- formInited: form.inited,
881
- formSubmited: form.submited,
882
- formMode: mode,
883
- formHorizontal: horizontal,
884
- formLabelAlign: labelAlign !== 'left' ? 'right' : labelAlign,
885
- formLabelWidth: labelWidth,
886
- controlWidth: controlWidth,
887
- /**
888
- * form.loading有为true时才下发disabled属性,否则不显性设置disbaled为false
889
- * Form中包含容器类组件时,这些组件会将此处的disbaled继续下发至子组件,导致SchemaRenderer中props.disabled覆盖schema.disabled
890
- */
891
- disabled: disabled ||
892
- control.disabled ||
893
- (form.loading ? true : undefined),
894
- /**
895
- * 静态展示 优先级逻辑
896
- * 1. 表单子项 static: true 始终保持静态
897
- * 2. 表单子项 static: false 或 不配置,跟随父表单
898
- * 3. 动作控制 表单子项 时,无视配置,优先级最高
899
- */
900
- static: control.static || isStatic,
901
- btnDisabled: disabled || form.loading || form.validating,
902
- onAction: this.handleAction,
903
- onQuery: this.handleQuery,
904
- onChange: this.handleChange,
905
- onBulkChange: this.handleBulkChange,
906
- addHook: this.addHook,
907
- removeHook: this.removeHook,
908
- renderFormItems: this.renderFormItems,
909
- formItemDispatchEvent: this.formItemDispatchEvent(dispatchEvent),
910
- formPristine: form.pristine
911
- // value: (control as any)?.name
912
- // ? getVariable(form.data, (control as any)?.name, canAccessSuperData)
913
- // : (control as any)?.value,
914
- // defaultValue: (control as any)?.value
915
- };
916
- var subSchema = tslib.__assign({}, control);
917
- if (subSchema.$ref) {
918
- subSchema = tslib.__assign(tslib.__assign({}, resolveDefinitions(subSchema.$ref)), subSchema);
919
- }
920
- lazyChange === false && (subSchema.changeImmediately = true);
921
- return render("".concat(region ? "".concat(region, "/") : '').concat(key), subSchema, subProps);
922
- };
923
- Form.prototype.renderBody = function () {
924
- var _a = this.props, body = _a.body, mode = _a.mode, className = _a.className, cx = _a.classnames, debug = _a.debug, debugConfig = _a.debugConfig, $path = _a.$path, store = _a.store, columnCount = _a.columnCount, render = _a.render, staticClassName = _a.staticClassName, _b = _a.static, isStatic = _b === void 0 ? false : _b, loadingConfig = _a.loadingConfig;
925
- var restError = store.restError;
926
- var WrapperComponent = this.props.wrapperComponent ||
927
- (/(?:\/|^)form\//.test($path) ? 'div' : 'form');
928
- var padDom = helper.repeatCount(columnCount && Array.isArray(body)
929
- ? columnCount - (body.length % columnCount)
930
- : 0, function (index) { return (React__default["default"].createElement("div", { className: cx("Form-item Form-item--".concat(mode, " is-placeholder")), key: index })); });
931
- return (React__default["default"].createElement(WrapperComponent, { className: cx("Form", "Form--".concat(mode || 'normal'), columnCount ? "Form--column Form--column-".concat(columnCount) : null, staticClassName && isStatic ? staticClassName : className, isStatic ? 'Form--isStatic' : null), onSubmit: this.handleFormSubmit, noValidate: true },
932
- React__default["default"].createElement("input", { type: "submit", style: { display: 'none' } }),
933
- debug
934
- ? render('form-debug-json', extend__default["default"]({
935
- type: 'json',
936
- value: store.data,
937
- ellipsisThreshold: 120,
938
- className: cx('Form--debug')
939
- },
940
- /** 定制debug输出格式 */
941
- object.isObject(debugConfig) ? debugConfig : {}))
942
- : null,
943
- render('spinner', { type: 'spinner' }, {
944
- overlay: true,
945
- show: store.loading,
946
- loadingConfig: loadingConfig
947
- }),
948
- this.renderFormItems({
949
- body: body
950
- }),
951
- padDom,
952
- restError && restError.length ? (React__default["default"].createElement("ul", { className: cx('Form-restError', 'Form-feedback') }, restError.map(function (item, idx) { return (React__default["default"].createElement("li", { key: idx }, item)); }))) : null,
953
- render('modal', tslib.__assign(tslib.__assign({}, (store.action &&
954
- store.action.dialog)), { type: 'dialog' }), {
955
- key: 'dialog',
956
- data: store.dialogData,
957
- onConfirm: this.handleDialogConfirm,
958
- onClose: this.handleDialogClose,
959
- show: store.dialogOpen
960
- }),
961
- render('modal', tslib.__assign(tslib.__assign({}, (store.action &&
962
- store.action.drawer)), { type: 'drawer' }), {
963
- key: 'drawer',
964
- data: store.drawerData,
965
- onConfirm: this.handleDrawerConfirm,
966
- onClose: this.handleDrawerClose,
967
- show: store.drawerOpen
968
- })));
969
- };
970
- Form.prototype.render = function () {
971
- var _a = this.props; _a.$path; _a.$schema; var wrapWithPanel = _a.wrapWithPanel, render = _a.render, title = _a.title, store = _a.store, panelClassName = _a.panelClassName, headerClassName = _a.headerClassName, footerClassName = _a.footerClassName, footerWrapClassName = _a.footerWrapClassName, actionsClassName = _a.actionsClassName, bodyClassName = _a.bodyClassName, cx = _a.classnames, style = _a.style, affixFooter = _a.affixFooter, lazyLoad = _a.lazyLoad, __ = _a.translate, footer = _a.footer;
972
- var body = this.renderBody();
973
- if (wrapWithPanel) {
974
- body = render('body', {
975
- type: 'panel',
976
- title: __(title)
977
- }, {
978
- className: cx(panelClassName, 'Panel--form'),
979
- style: style,
980
- formStore: this.props.store,
981
- children: body,
982
- actions: this.buildActions(),
983
- onAction: this.handleAction,
984
- onQuery: this.handleQuery,
985
- disabled: store.loading,
986
- btnDisabled: store.loading || store.validating,
987
- headerClassName: headerClassName,
988
- footer: footer,
989
- footerClassName: footerClassName,
990
- footerWrapClassName: footerWrapClassName,
991
- actionsClassName: actionsClassName,
992
- bodyClassName: bodyClassName,
993
- affixFooter: affixFooter
994
- });
995
- }
996
- if (lazyLoad) {
997
- body = React__default["default"].createElement(LazyComponent["default"], null, body);
998
- }
999
- return body;
1000
- };
1001
- Form.defaultProps = {
1002
- title: 'Form.title',
1003
- submitText: 'Form.submit',
1004
- initFetch: true,
1005
- wrapWithPanel: true,
1006
- mode: 'normal',
1007
- collapsable: false,
1008
- controlWidth: 'full',
1009
- horizontal: {
1010
- left: 2,
1011
- right: 10,
1012
- offset: 2
1013
- },
1014
- columnCount: 0,
1015
- panelClassName: 'Panel--default',
1016
- messages: {
1017
- fetchFailed: 'fetchFailed',
1018
- saveSuccess: 'saveSuccess',
1019
- saveFailed: 'saveFailed'
1020
- },
1021
- wrapperComponent: '',
1022
- finishedField: 'finished',
1023
- initFinishedField: 'finished',
1024
- labelAlign: 'right'
1025
- };
1026
- Form.propsList = [
1027
- 'title',
1028
- 'header',
1029
- 'controls',
1030
- 'tabs',
1031
- 'fieldSet',
1032
- 'submitText',
1033
- 'initFetch',
1034
- 'wrapWithPanel',
1035
- 'mode',
1036
- 'columnCount',
1037
- 'collapsable',
1038
- 'horizontal',
1039
- 'panelClassName',
1040
- 'messages',
1041
- 'wrapperComponent',
1042
- 'resetAfterSubmit',
1043
- 'clearAfterSubmit',
1044
- 'submitOnInit',
1045
- 'submitOnChange',
1046
- 'onInit',
1047
- 'onReset',
1048
- 'onSubmit',
1049
- 'onChange',
1050
- 'onFailed',
1051
- 'onFinished',
1052
- 'onSaved',
1053
- 'canAccessSuperData',
1054
- 'lazyChange',
1055
- 'formLazyChange',
1056
- 'lazyLoad',
1057
- 'formInited',
1058
- 'simpleMode',
1059
- 'inputOnly',
1060
- 'value',
1061
- 'actions',
1062
- 'multiple'
1063
- ];
1064
- return Form;
1065
- }(React__default["default"].Component));
1066
- var FormRenderer = /** @class */ (function (_super) {
1067
- tslib.__extends(FormRenderer, _super);
1068
- function FormRenderer(props, context) {
1069
- var _this = _super.call(this, props) || this;
1070
- var scoped = context;
1071
- scoped.registerComponent(_this);
1072
- return _this;
1073
- }
1074
- FormRenderer.prototype.componentDidMount = function () {
1075
- _super.prototype.componentDidMount.call(this);
1076
- if (this.props.autoFocus) {
1077
- var scoped = this.context;
1078
- var inputs = scoped.getComponents();
1079
- var focuableInput_1 = find__default["default"](inputs, function (input) { return input.focus; });
1080
- focuableInput_1 && setTimeout(function () { return focuableInput_1.focus(); }, 200);
1081
- }
1082
- };
1083
- FormRenderer.prototype.componentWillUnmount = function () {
1084
- var scoped = this.context;
1085
- scoped.unRegisterComponent(this);
1086
- _super.prototype.componentWillUnmount.call(this);
1087
- };
1088
- FormRenderer.prototype.doAction = function (action, data, throwErrors) {
1089
- if (data === void 0) { data = this.props.store.data; }
1090
- if (throwErrors === void 0) { throwErrors = false; }
1091
- return this.handleAction(undefined, action, data, throwErrors);
1092
- };
1093
- FormRenderer.prototype.handleAction = function (e, action, ctx, throwErrors, delegate) {
1094
- var _a, _b;
1095
- if (throwErrors === void 0) { throwErrors = false; }
1096
- return tslib.__awaiter(this, void 0, void 0, function () {
1097
- var _c, dispatchEvent, onEvent, submitEvent, dispatcher, scoped_1;
1098
- return tslib.__generator(this, function (_d) {
1099
- switch (_d.label) {
1100
- case 0:
1101
- _c = this.props, dispatchEvent = _c.dispatchEvent, onEvent = _c.onEvent;
1102
- submitEvent = (_b = (_a = onEvent === null || onEvent === void 0 ? void 0 : onEvent.submit) === null || _a === void 0 ? void 0 : _a.actions) === null || _b === void 0 ? void 0 : _b.length;
1103
- return [4 /*yield*/, dispatchEvent('submit', this.props.data)];
1104
- case 1:
1105
- dispatcher = _d.sent();
1106
- if ((dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented) || submitEvent) {
1107
- return [2 /*return*/];
1108
- }
1109
- if (action.target && action.actionType !== 'reload') {
1110
- scoped_1 = this.context;
1111
- return [2 /*return*/, Promise.all(action.target.split(',').map(function (name) {
1112
- var target = scoped_1.getComponentByName(name);
1113
- return (target &&
1114
- target.doAction &&
1115
- target.doAction(tslib.__assign(tslib.__assign({}, action), { target: undefined }), ctx, throwErrors));
1116
- }))];
1117
- }
1118
- else {
1119
- return [2 /*return*/, _super.prototype.handleAction.call(this, e, action, ctx, throwErrors, delegate)];
1120
- }
1121
- }
1122
- });
1123
- });
1124
- };
1125
- FormRenderer.prototype.handleDialogConfirm = function (values, action, ctx, targets) {
1126
- _super.prototype.handleDialogConfirm.call(this, values, action, ctx, targets);
1127
- var store = this.props.store;
1128
- var scoped = this.context;
1129
- if (action.reload) {
1130
- scoped.reload(action.reload, ctx);
1131
- }
1132
- else if (store.action && store.action.reload) {
1133
- scoped.reload(store.action.reload, ctx);
1134
- }
1135
- };
1136
- FormRenderer.prototype.submitToTarget = function (target, values) {
1137
- var scoped = this.context;
1138
- scoped.send(target, values);
1139
- };
1140
- FormRenderer.prototype.reloadTarget = function (target, data) {
1141
- var scoped = this.context;
1142
- scoped.reload(target, data);
1143
- };
1144
- FormRenderer.prototype.closeTarget = function (target) {
1145
- var scoped = this.context;
1146
- scoped.close(target);
1147
- };
1148
- FormRenderer.prototype.reload = function (target, query, ctx, silent, replace) {
1149
- if (query) {
1150
- return this.receive(query, undefined, replace);
1151
- }
1152
- var scoped = this.context;
1153
- var subPath = '';
1154
- var idx;
1155
- var subQuery = null;
1156
- if (target && ~(idx = target.indexOf('.'))) {
1157
- subPath = target.substring(idx + 1);
1158
- target = target.substring(0, idx);
1159
- }
1160
- var idx2 = target ? target.indexOf('?') : -1;
1161
- if (~idx2) {
1162
- subQuery = dataMapping.dataMapping(helper.qsparse(target.substring(idx2 + 1)), ctx);
1163
- target = target.substring(0, idx2);
1164
- }
1165
- var component;
1166
- if (target &&
1167
- (component = scoped.getComponentByName(target)) &&
1168
- component.reload) {
1169
- component.reload(subPath, subQuery, ctx);
1170
- }
1171
- else if (target === '*') {
1172
- _super.prototype.reload.call(this, target, query, ctx, silent);
1173
- var components = scoped.getComponents();
1174
- components.forEach(function (component) {
1175
- return component.reload && component.reload('', subQuery, ctx);
1176
- });
1177
- }
1178
- else {
1179
- _super.prototype.reload.call(this, target, query, ctx, silent);
1180
- }
1181
- };
1182
- FormRenderer.prototype.receive = function (values, name, replace) {
1183
- if (name) {
1184
- var scoped = this.context;
1185
- var idx = name.indexOf('.');
1186
- var subPath = '';
1187
- if (~idx) {
1188
- subPath = name.substring(1 + idx);
1189
- name = name.substring(0, idx);
1190
- }
1191
- var component = scoped.getComponentByName(name);
1192
- component && component.receive && component.receive(values, subPath);
1193
- return;
1194
- }
1195
- return _super.prototype.receive.call(this, values, undefined, replace);
1196
- };
1197
- FormRenderer.prototype.setData = function (values, replace) {
1198
- var _a = this.props, onChange = _a.onChange, store = _a.store;
1199
- _super.prototype.setValues.call(this, values);
1200
- // 触发表单change
1201
- onChange &&
1202
- onChange(store.data, helper.difference(store.data, store.pristine), this.props);
1203
- };
1204
- FormRenderer.prototype.getData = function () {
1205
- var store = this.props.store;
1206
- return store.data;
1207
- };
1208
- FormRenderer.contextType = Scoped.ScopedContext;
1209
- FormRenderer = tslib.__decorate([
1210
- factory.Renderer({
1211
- type: 'form',
1212
- storeType: form.FormStore.name,
1213
- isolateScope: true,
1214
- storeExtendsData: function (props) { return props.inheritData; },
1215
- shouldSyncSuperStore: function (store, props, prevProps) {
1216
- var _a, _b;
1217
- // 如果是 QuickEdit,让 store 同步 __super 数据。
1218
- if (props.quickEditFormRef &&
1219
- props.onQuickChange &&
1220
- (helper.isObjectShallowModified(prevProps.data, props.data) ||
1221
- helper.isObjectShallowModified(prevProps.data.__super, props.data.__super) ||
1222
- helper.isObjectShallowModified((_a = prevProps.data.__super) === null || _a === void 0 ? void 0 : _a.__super, (_b = props.data.__super) === null || _b === void 0 ? void 0 : _b.__super))) {
1223
- return true;
1224
- }
1225
- return undefined;
1226
- }
1227
- }),
1228
- tslib.__metadata("design:paramtypes", [Object, Object])
1229
- ], FormRenderer);
1230
- return FormRenderer;
1231
- }(Form));
1232
-
1233
- exports.FormRenderer = FormRenderer;
1234
- exports["default"] = Form;