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,920 +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 api = require('../utils/api.js');
12
- var mobxStateTree = require('mobx-state-tree');
13
- var helper = require('../utils/helper.js');
14
- var mobx = require('mobx');
15
- var Item = require('./Item.js');
16
- var React = require('react');
17
- require('amis-formula');
18
- require('moment');
19
- var object = require('../utils/object.js');
20
- var isPureVariable = require('../utils/isPureVariable.js');
21
- var getVariable = require('../utils/getVariable.js');
22
- var resolveVariableAndFilter = require('../utils/resolveVariableAndFilter.js');
23
- var dataMapping = require('../utils/dataMapping.js');
24
- require('../utils/filter.js');
25
- var tpl = require('../utils/tpl.js');
26
- var findIndex = require('lodash/findIndex');
27
- var isPlainObject = require('lodash/isPlainObject');
28
- var normalizeOptions = require('../utils/normalizeOptions.js');
29
- var optionValueCompare = require('../utils/optionValueCompare.js');
30
- require('../utils/ColorScale.js');
31
- require('lodash/chunk');
32
- require('../utils/DataSchema.js');
33
- require('../utils/DataScope.js');
34
- require('../utils/debug.js');
35
- require('react-dom');
36
- require('../utils/errors.js');
37
- require('classnames');
38
- require('lodash/isObject');
39
- require('lodash/isString');
40
- require('lodash/isBoolean');
41
- require('lodash');
42
- require('../utils/image.js');
43
- var keyToPath = require('../utils/keyToPath.js');
44
- var rendererEvent = require('../utils/renderer-event.js');
45
- require('lodash/cloneDeep');
46
- require('../utils/resize-sensor.js');
47
- require('react-overlays/useRootClose');
48
- require('../utils/SimpleMap.js');
49
- require('lodash/mapValues');
50
- require('lodash/camelCase');
51
- require('uncontrollable');
52
- require('hoist-non-react-statics');
53
- require('../utils/validations.js');
54
- require('../utils/Animation.js');
55
-
56
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
57
-
58
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
59
- var findIndex__default = /*#__PURE__*/_interopDefaultLegacy(findIndex);
60
- var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject);
61
-
62
- var detectProps = Item.detectProps.concat([
63
- 'value',
64
- 'options',
65
- 'size',
66
- 'buttons',
67
- 'columnsCount',
68
- 'multiple',
69
- 'hideRoot',
70
- 'checkAll',
71
- 'defaultCheckAll',
72
- 'showIcon',
73
- 'showRadio',
74
- 'btnDisabled',
75
- 'joinValues',
76
- 'extractValue',
77
- 'borderMode',
78
- 'hideSelected'
79
- ]);
80
- function registerOptionsControl(config) {
81
- var Control = config.component;
82
- var FormOptionsItem = /** @class */ (function (_super) {
83
- tslib.__extends(FormOptionsItem, _super);
84
- function FormOptionsItem(props) {
85
- var _this = this;
86
- var _a;
87
- _this = _super.call(this, props) || this;
88
- _this.toDispose = [];
89
- _this.mounted = false;
90
- var initFetch = props.initFetch, formItem = props.formItem, source = props.source, data = props.data, setPrinstineValue = props.setPrinstineValue, defaultValue = props.defaultValue, multiple = props.multiple, joinValues = props.joinValues, extractValue = props.extractValue, addHook = props.addHook, formInited = props.formInited, valueField = props.valueField, options = props.options, value = props.value, defaultCheckAll = props.defaultCheckAll;
91
- if (formItem) {
92
- formItem.setOptions(normalizeOptions.normalizeOptions(options, undefined, valueField), _this.changeOptionValue, data);
93
- _this.toDispose.push(mobx.reaction(function () { return JSON.stringify([formItem.loading, formItem.filteredOptions]); }, function () { return _this.mounted && _this.forceUpdate(); }));
94
- _this.toDispose.push(mobx.reaction(function () {
95
- return JSON.stringify(formItem.getSelectedOptions(formItem.tmpValue));
96
- }, function () {
97
- return _this.mounted &&
98
- _this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue));
99
- }));
100
- // 默认全选。这里会和默认值\回填值逻辑冲突,所以如果有配置source则不执行默认全选
101
- if (multiple &&
102
- defaultCheckAll &&
103
- ((_a = formItem.filteredOptions) === null || _a === void 0 ? void 0 : _a.length) &&
104
- !source) {
105
- _this.defaultCheckAll();
106
- }
107
- }
108
- var loadOptions = initFetch !== false;
109
- if (formItem && joinValues === false && defaultValue) {
110
- var selectedOptions = extractValue
111
- ? formItem
112
- .getSelectedOptions(value)
113
- .map(function (selectedOption) {
114
- return selectedOption[valueField || 'value'];
115
- })
116
- : formItem.getSelectedOptions(value);
117
- setPrinstineValue(multiple ? selectedOptions.concat() : selectedOptions[0]);
118
- }
119
- loadOptions &&
120
- config.autoLoadOptionsFromSource !== false &&
121
- (formInited || !addHook
122
- ? _this.reload()
123
- : addHook && addHook(_this.initOptions, 'init'));
124
- return _this;
125
- }
126
- FormOptionsItem.prototype.componentDidMount = function () {
127
- this.mounted = true;
128
- this.normalizeValue();
129
- };
130
- FormOptionsItem.prototype.shouldComponentUpdate = function (nextProps) {
131
- var _a, _b;
132
- if (config.strictMode === false || nextProps.strictMode === false) {
133
- return true;
134
- }
135
- else if (nextProps.source || nextProps.autoComplete) {
136
- return true;
137
- }
138
- else if ((_a = nextProps.formItem) === null || _a === void 0 ? void 0 : _a.expressionsInOptions) {
139
- return true;
140
- }
141
- else if ((_b = nextProps.formItem) === null || _b === void 0 ? void 0 : _b.filteredOptions) {
142
- return true;
143
- }
144
- if (helper.anyChanged(detectProps, this.props, nextProps)) {
145
- return true;
146
- }
147
- return false;
148
- };
149
- FormOptionsItem.prototype.componentDidUpdate = function (prevProps) {
150
- var _this = this;
151
- var props = this.props;
152
- var formItem = props.formItem;
153
- if (prevProps.options !== props.options && formItem) {
154
- formItem.setOptions(normalizeOptions.normalizeOptions(props.options || [], undefined, props.valueField), this.changeOptionValue, props.data);
155
- this.normalizeValue();
156
- }
157
- else if (config.autoLoadOptionsFromSource !== false &&
158
- (props.formInited || typeof props.formInited === 'undefined') &&
159
- props.source &&
160
- formItem &&
161
- (prevProps.source !== props.source || prevProps.data !== props.data)) {
162
- if (isPureVariable.isPureVariable(props.source)) {
163
- var prevOptions = resolveVariableAndFilter.resolveVariableAndFilter(prevProps.source, prevProps.data, '| raw');
164
- var options = resolveVariableAndFilter.resolveVariableAndFilter(props.source, props.data, '| raw');
165
- if (prevOptions !== options) {
166
- formItem.setOptions(normalizeOptions.normalizeOptions(options || [], undefined, props.valueField || 'value'), this.changeOptionValue, props.data);
167
- this.normalizeValue();
168
- }
169
- }
170
- else if (api.isEffectiveApi(props.source, props.data) &&
171
- api.isApiOutdated(prevProps.source, props.source, prevProps.data, props.data)) {
172
- formItem
173
- .loadOptions(props.source, props.data, undefined, true, this.changeOptionValue)
174
- .then(function () { return _this.normalizeValue(); });
175
- }
176
- }
177
- if (prevProps.value !== props.value || (formItem === null || formItem === void 0 ? void 0 : formItem.expressionsInOptions)) {
178
- formItem === null || formItem === void 0 ? void 0 : formItem.syncOptions(undefined, props.data);
179
- }
180
- };
181
- FormOptionsItem.prototype.componentWillUnmount = function () {
182
- var _a, _b;
183
- (_b = (_a = this.props).removeHook) === null || _b === void 0 ? void 0 : _b.call(_a, this.reload, 'init');
184
- this.toDispose.forEach(function (fn) { return fn(); });
185
- this.toDispose = [];
186
- };
187
- FormOptionsItem.prototype.dispatchOptionEvent = function (eventName, eventData) {
188
- if (eventData === void 0) { eventData = ''; }
189
- return tslib.__awaiter(this, void 0, void 0, function () {
190
- var _a, dispatchEvent, options, rendererEvent$1;
191
- return tslib.__generator(this, function (_b) {
192
- switch (_b.label) {
193
- case 0:
194
- _a = this.props, dispatchEvent = _a.dispatchEvent, options = _a.options;
195
- return [4 /*yield*/, dispatchEvent(eventName, rendererEvent.resolveEventData(this.props, { value: eventData, options: options, items: options }, // 为了保持名字统一
196
- 'value'))];
197
- case 1:
198
- rendererEvent$1 = _b.sent();
199
- // 返回阻塞标识
200
- return [2 /*return*/, !!(rendererEvent$1 === null || rendererEvent$1 === void 0 ? void 0 : rendererEvent$1.prevented)];
201
- }
202
- });
203
- });
204
- };
205
- FormOptionsItem.prototype.doAction = function (action, data, throwErrors) {
206
- var _a = this.props, resetValue = _a.resetValue, onChange = _a.onChange;
207
- var actionType = action === null || action === void 0 ? void 0 : action.actionType;
208
- if (actionType === 'clear') {
209
- onChange === null || onChange === void 0 ? void 0 : onChange('');
210
- }
211
- else if (actionType === 'reset') {
212
- onChange === null || onChange === void 0 ? void 0 : onChange(resetValue !== null && resetValue !== void 0 ? resetValue : '');
213
- }
214
- };
215
- FormOptionsItem.prototype.syncAutoFill = function (selectedOptions) {
216
- var _a = this.props, autoFill = _a.autoFill, multiple = _a.multiple, onBulkChange = _a.onBulkChange, data = _a.data;
217
- var formItem = this.props.formItem;
218
- // 参照录入|自动填充
219
- if (autoFill === null || autoFill === void 0 ? void 0 : autoFill.hasOwnProperty('api')) {
220
- return;
221
- }
222
- if (onBulkChange &&
223
- autoFill &&
224
- !helper.isEmpty(autoFill) &&
225
- formItem.filteredOptions.length) {
226
- var toSync_1 = dataMapping.dataMapping(autoFill, multiple
227
- ? {
228
- items: selectedOptions.map(function (item) {
229
- return object.createObject(tslib.__assign(tslib.__assign({}, data), { ancestors: helper.getTreeAncestors(formItem.filteredOptions, item, true) }), item);
230
- })
231
- }
232
- : object.createObject(tslib.__assign(tslib.__assign({}, data), { ancestors: helper.getTreeAncestors(formItem.filteredOptions, selectedOptions[0], true) }), selectedOptions[0]));
233
- var tmpData_1 = tslib.__assign({}, data);
234
- var result_1 = tslib.__assign({}, toSync_1);
235
- Object.keys(autoFill).forEach(function (key) {
236
- var keys = keyToPath.keyToPath(key);
237
- // 如果左边的 key 是一个路径
238
- // 这里不希望直接把原始对象都给覆盖没了
239
- // 而是保留原始的对象,只修改指定的属性
240
- if (keys.length > 1 && isPlainObject__default["default"](tmpData_1[keys[0]])) {
241
- var value = getVariable.getVariable(toSync_1, key);
242
- // 存在情况:依次更新同一子路径的多个key,eg: a.b.c1 和 a.b.c2,所以需要同步更新data
243
- object.setVariable(tmpData_1, key, value);
244
- result_1[keys[0]] = tmpData_1[keys[0]];
245
- }
246
- });
247
- onBulkChange(result_1);
248
- }
249
- };
250
- // 当前值,跟设置预期的值格式不一致时自动转换。
251
- FormOptionsItem.prototype.normalizeValue = function () {
252
- var _a = this.props, joinValues = _a.joinValues, extractValue = _a.extractValue, value = _a.value, multiple = _a.multiple, formItem = _a.formItem, valueField = _a.valueField; _a.enableNodePath; _a.pathSeparator; var onChange = _a.onChange;
253
- if (!formItem || joinValues !== false || !formItem.options.length) {
254
- return;
255
- }
256
- if (extractValue === false &&
257
- (typeof value === 'string' || typeof value === 'number')) {
258
- var selectedOptions = formItem.getSelectedOptions(value);
259
- onChange === null || onChange === void 0 ? void 0 : onChange(multiple ? selectedOptions.concat() : selectedOptions[0]);
260
- }
261
- else if (extractValue === true &&
262
- value &&
263
- !((Array.isArray(value) &&
264
- value.every(function (val) { return typeof val === 'string' || typeof val === 'number'; })) ||
265
- typeof value === 'string' ||
266
- typeof value === 'number')) {
267
- var selectedOptions = formItem
268
- .getSelectedOptions(value)
269
- .map(function (selectedOption) { return selectedOption[valueField || 'value']; });
270
- onChange === null || onChange === void 0 ? void 0 : onChange(multiple ? selectedOptions.concat() : selectedOptions[0]);
271
- }
272
- };
273
- FormOptionsItem.prototype.getWrappedInstance = function () {
274
- return this.input;
275
- };
276
- FormOptionsItem.prototype.inputRef = function (ref) {
277
- this.input = ref;
278
- };
279
- FormOptionsItem.prototype.handleToggle = function (option, submitOnChange, changeImmediately) {
280
- return tslib.__awaiter(this, void 0, void 0, function () {
281
- var _a, onChange, formItem, value, newValue, isPrevented;
282
- return tslib.__generator(this, function (_b) {
283
- switch (_b.label) {
284
- case 0:
285
- _a = this.props, onChange = _a.onChange, formItem = _a.formItem, value = _a.value;
286
- if (!formItem) {
287
- return [2 /*return*/];
288
- }
289
- newValue = this.toggleValue(option, value);
290
- return [4 /*yield*/, this.dispatchOptionEvent('change', newValue)];
291
- case 1:
292
- isPrevented = _b.sent();
293
- isPrevented ||
294
- (onChange && onChange(newValue, submitOnChange, changeImmediately));
295
- return [2 /*return*/];
296
- }
297
- });
298
- });
299
- };
300
- /**
301
- * 初始化时处理默认全选逻辑
302
- */
303
- FormOptionsItem.prototype.defaultCheckAll = function () {
304
- var _a = this.props, value = _a.value, formItem = _a.formItem, setPrinstineValue = _a.setPrinstineValue;
305
- // 如果有默认值\回填值直接返回
306
- if (!formItem || formItem.getSelectedOptions(value).length) {
307
- return;
308
- }
309
- var valueArray = formItem.filteredOptions.concat();
310
- var newValue = this.formatValueArray(valueArray);
311
- setPrinstineValue === null || setPrinstineValue === void 0 ? void 0 : setPrinstineValue(newValue);
312
- };
313
- /**
314
- * 选中的值经过joinValues和delimiter等规则处理输出规定格式的值
315
- * @param valueArray 选中值的数组
316
- * @returns 通过joinValues和delimiter等规则输出规定格式的值
317
- */
318
- FormOptionsItem.prototype.formatValueArray = function (valueArray) {
319
- var _a = this.props, joinValues = _a.joinValues, extractValue = _a.extractValue, valueField = _a.valueField, delimiter = _a.delimiter, resetValue = _a.resetValue, multiple = _a.multiple;
320
- var newValue = '';
321
- if (multiple) {
322
- /** 兼容tree数据结构 */
323
- newValue =
324
- helper.getTreeDepth(valueArray) > 1 ? helper.flattenTree(valueArray) : valueArray;
325
- if (joinValues) {
326
- newValue = newValue
327
- .map(function (item) { return item[valueField || 'value']; })
328
- .filter(function (item) { return item != null; }) /** tree的父节点可能没有value值 */
329
- .join(delimiter);
330
- }
331
- else if (extractValue) {
332
- newValue = newValue
333
- .map(function (item) { return item[valueField || 'value']; })
334
- .filter(function (item) { return item != null; });
335
- }
336
- }
337
- else {
338
- newValue = valueArray[0] || resetValue;
339
- if (joinValues && newValue) {
340
- newValue = newValue[valueField || 'value'];
341
- }
342
- }
343
- return newValue;
344
- };
345
- FormOptionsItem.prototype.handleToggleAll = function () {
346
- return tslib.__awaiter(this, void 0, void 0, function () {
347
- var _a, value, onChange, formItem, valueField, selectedOptions, filteredOptions, valueArray, newValue, isPrevented;
348
- return tslib.__generator(this, function (_b) {
349
- switch (_b.label) {
350
- case 0:
351
- _a = this.props, value = _a.value, onChange = _a.onChange, formItem = _a.formItem, valueField = _a.valueField;
352
- if (!formItem) {
353
- return [2 /*return*/];
354
- }
355
- selectedOptions = formItem.getSelectedOptions(value);
356
- filteredOptions = helper.flattenTree(formItem.filteredOptions.concat()).filter(function (item) { return item != null && item[valueField || 'value'] != null; });
357
- valueArray = selectedOptions.length === filteredOptions.length
358
- ? []
359
- : formItem.filteredOptions.concat();
360
- newValue = this.formatValueArray(valueArray);
361
- return [4 /*yield*/, this.dispatchOptionEvent('change', newValue)];
362
- case 1:
363
- isPrevented = _b.sent();
364
- isPrevented || (onChange && onChange(newValue));
365
- return [2 /*return*/];
366
- }
367
- });
368
- });
369
- };
370
- FormOptionsItem.prototype.toggleValue = function (option, originValue) {
371
- var _a = this.props, joinValues = _a.joinValues, extractValue = _a.extractValue, valueField = _a.valueField, delimiter = _a.delimiter, clearable = _a.clearable, resetValue = _a.resetValue, multiple = _a.multiple, formItem = _a.formItem;
372
- var valueArray = originValue !== undefined
373
- ? formItem.getSelectedOptions(originValue).concat()
374
- : [];
375
- var idx = findIndex__default["default"](valueArray, optionValueCompare.optionValueCompare(option[valueField || 'value'], valueField || 'value'));
376
- var newValue = '';
377
- if (multiple) {
378
- if (~idx) {
379
- valueArray.splice(idx, 1);
380
- }
381
- else {
382
- valueArray.push(option);
383
- }
384
- newValue = valueArray;
385
- if (joinValues) {
386
- newValue = newValue
387
- .map(function (item) { return item[valueField || 'value']; })
388
- .join(delimiter);
389
- }
390
- else if (extractValue) {
391
- newValue = newValue.map(function (item) { return item[valueField || 'value']; });
392
- }
393
- }
394
- else {
395
- if (~idx && clearable) {
396
- valueArray.splice(idx, 1);
397
- }
398
- else {
399
- valueArray = [option];
400
- }
401
- newValue = valueArray[0] || resetValue;
402
- if ((joinValues || extractValue) && newValue) {
403
- newValue = newValue[valueField || 'value'];
404
- }
405
- }
406
- return newValue;
407
- };
408
- // 当有 action 触发,如果指定了 reload 目标组件,有可能会来到这里面来
409
- FormOptionsItem.prototype.reload = function () {
410
- return this.reloadOptions();
411
- };
412
- FormOptionsItem.prototype.reloadOptions = function (setError, isInit) {
413
- if (isInit === void 0) { isInit = false; }
414
- var _a = this.props, source = _a.source, formItem = _a.formItem, data = _a.data, onChange = _a.onChange, setPrinstineValue = _a.setPrinstineValue, valueField = _a.valueField;
415
- if (formItem && isPureVariable.isPureVariable(source)) {
416
- mobxStateTree.isAlive(formItem) &&
417
- formItem.setOptions(normalizeOptions.normalizeOptions(resolveVariableAndFilter.resolveVariableAndFilter(source, data, '| raw') || [], undefined, valueField), this.changeOptionValue, data);
418
- return;
419
- }
420
- else if (!formItem || !api.isEffectiveApi(source, data)) {
421
- return;
422
- }
423
- return formItem.loadOptions(source, data, undefined, false, isInit ? setPrinstineValue : onChange, setError);
424
- };
425
- FormOptionsItem.prototype.deferLoad = function (option) {
426
- return tslib.__awaiter(this, void 0, void 0, function () {
427
- var _a, deferApi, source, env, formItem, data, api, json;
428
- return tslib.__generator(this, function (_b) {
429
- switch (_b.label) {
430
- case 0:
431
- _a = this.props, deferApi = _a.deferApi, source = _a.source, env = _a.env, formItem = _a.formItem, data = _a.data;
432
- api = option.deferApi || deferApi || source;
433
- if (!api) {
434
- env.notify('error', '请在选项中设置 `deferApi` 或者表单项中设置 `deferApi`,用来加载子选项。');
435
- return [2 /*return*/];
436
- }
437
- return [4 /*yield*/, (formItem === null || formItem === void 0 ? void 0 : formItem.deferLoadOptions(option, api, object.createObject(data, option)))];
438
- case 1:
439
- json = _b.sent();
440
- // 触发事件通知,加载完成
441
- this.dispatchOptionEvent('loadFinished', json);
442
- return [2 /*return*/];
443
- }
444
- });
445
- });
446
- };
447
- FormOptionsItem.prototype.leftDeferLoad = function (option, leftOptions) {
448
- var _a = this.props, deferApi = _a.deferApi, source = _a.source, env = _a.env, formItem = _a.formItem, data = _a.data;
449
- var api = option.deferApi || deferApi || source;
450
- if (!api) {
451
- env.notify('error', '请在选项中设置 `deferApi` 或者表单项中设置 `deferApi`,用来加载子选项。');
452
- return;
453
- }
454
- formItem === null || formItem === void 0 ? void 0 : formItem.deferLoadLeftOptions(option, leftOptions, api, object.createObject(data, option));
455
- };
456
- FormOptionsItem.prototype.expandTreeOptions = function (nodePathArr) {
457
- var _a = this.props, deferApi = _a.deferApi, source = _a.source, env = _a.env, formItem = _a.formItem, data = _a.data;
458
- var api = deferApi || source;
459
- if (!api) {
460
- env.notify('error', '请在选项中设置 `deferApi` 或者表单项中设置 `deferApi`,用来加载子选项。');
461
- return;
462
- }
463
- formItem === null || formItem === void 0 ? void 0 : formItem.expandTreeOptions(nodePathArr, api, object.createObject(data));
464
- };
465
- FormOptionsItem.prototype.initOptions = function (data) {
466
- var _a;
467
- return tslib.__awaiter(this, void 0, void 0, function () {
468
- var _b, formItem, name, multiple, defaultCheckAll;
469
- return tslib.__generator(this, function (_c) {
470
- switch (_c.label) {
471
- case 0: return [4 /*yield*/, this.reloadOptions(false, true)];
472
- case 1:
473
- _c.sent();
474
- _b = this.props, formItem = _b.formItem, name = _b.name, multiple = _b.multiple, defaultCheckAll = _b.defaultCheckAll;
475
- if (!formItem) {
476
- return [2 /*return*/];
477
- }
478
- if (mobxStateTree.isAlive(formItem) && formItem.value) {
479
- object.setVariable(data, name, formItem.value);
480
- }
481
- // 默认全选
482
- if (multiple && defaultCheckAll && ((_a = formItem.filteredOptions) === null || _a === void 0 ? void 0 : _a.length)) {
483
- this.defaultCheckAll();
484
- }
485
- return [2 /*return*/];
486
- }
487
- });
488
- });
489
- };
490
- FormOptionsItem.prototype.focus = function () {
491
- this.input && this.input.focus && this.input.focus();
492
- };
493
- FormOptionsItem.prototype.changeOptionValue = function (value) {
494
- var _a = this.props, onChange = _a.onChange, formInited = _a.formInited, setPrinstineValue = _a.setPrinstineValue, originValue = _a.value;
495
- if (formInited === false) {
496
- originValue === undefined && (setPrinstineValue === null || setPrinstineValue === void 0 ? void 0 : setPrinstineValue(value));
497
- }
498
- else {
499
- onChange === null || onChange === void 0 ? void 0 : onChange(value);
500
- }
501
- };
502
- FormOptionsItem.prototype.setOptions = function (options, skipNormalize) {
503
- if (skipNormalize === void 0) { skipNormalize = false; }
504
- var formItem = this.props.formItem;
505
- formItem &&
506
- formItem.setOptions(skipNormalize
507
- ? options
508
- : normalizeOptions.normalizeOptions(options || [], undefined, this.props.valueField), this.changeOptionValue, this.props.data);
509
- };
510
- FormOptionsItem.prototype.syncOptions = function () {
511
- var formItem = this.props.formItem;
512
- formItem && formItem.syncOptions(undefined, this.props.data);
513
- };
514
- FormOptionsItem.prototype.setLoading = function (value) {
515
- var formItem = this.props.formItem;
516
- formItem && formItem.setLoading(value);
517
- };
518
- FormOptionsItem.prototype.handleOptionAdd = function (idx, value, skipForm) {
519
- var _a, _b;
520
- if (idx === void 0) { idx = -1; }
521
- if (skipForm === void 0) { skipForm = false; }
522
- return tslib.__awaiter(this, void 0, void 0, function () {
523
- var _c, addControls, addDialog, disabled, labelField, onOpenDialog, optionLabel, addApi, source, data, valueField, model, createBtnLabel, env, __, parent, ctx, result, _d, payload, e_1, isPrevented, options;
524
- var _e;
525
- return tslib.__generator(this, function (_f) {
526
- switch (_f.label) {
527
- case 0:
528
- _c = this.props, addControls = _c.addControls, addDialog = _c.addDialog, disabled = _c.disabled, labelField = _c.labelField, onOpenDialog = _c.onOpenDialog, optionLabel = _c.optionLabel, addApi = _c.addApi, source = _c.source, data = _c.data, valueField = _c.valueField, model = _c.formItem, createBtnLabel = _c.createBtnLabel, env = _c.env, __ = _c.translate;
529
- // 禁用或者没有配置 name
530
- if (disabled || !model) {
531
- return [2 /*return*/];
532
- }
533
- // 用户没有配置表单项,则自动创建一个 label 输入
534
- if (!skipForm && (!Array.isArray(addControls) || !addControls.length)) {
535
- addControls = [
536
- {
537
- type: 'text',
538
- name: labelField || 'label',
539
- label: false,
540
- required: true,
541
- placeholder: __('Options.addPlaceholder')
542
- }
543
- ];
544
- }
545
- parent = Array.isArray(idx)
546
- ? helper.getTree(model.options, idx.slice(0, -1))
547
- : undefined;
548
- ctx = object.createObject(data, Array.isArray(idx)
549
- ? tslib.__assign({ parent: parent }, value) : value);
550
- if (!skipForm) return [3 /*break*/, 1];
551
- _d = ctx;
552
- return [3 /*break*/, 3];
553
- case 1: return [4 /*yield*/, onOpenDialog(tslib.__assign(tslib.__assign({ type: 'dialog', title: createBtnLabel || "\u65B0\u589E".concat(optionLabel || '选项') }, addDialog), { body: {
554
- type: 'form',
555
- api: addApi,
556
- controls: tslib.__spreadArray([
557
- {
558
- type: 'hidden',
559
- name: 'idx',
560
- value: idx
561
- },
562
- {
563
- type: 'hidden',
564
- name: 'parent',
565
- value: parent
566
- }
567
- ], (addControls || []), true)
568
- } }), ctx)];
569
- case 2:
570
- _d = _f.sent();
571
- _f.label = 3;
572
- case 3:
573
- result = _d;
574
- if (!(skipForm && addApi)) return [3 /*break*/, 7];
575
- _f.label = 4;
576
- case 4:
577
- _f.trys.push([4, 6, , 7]);
578
- return [4 /*yield*/, env.fetcher(addApi, result, {
579
- method: 'post'
580
- })];
581
- case 5:
582
- payload = _f.sent();
583
- if (!payload.ok) {
584
- env.notify('error', (_b = (_a = addApi === null || addApi === void 0 ? void 0 : addApi.messages) === null || _a === void 0 ? void 0 : _a.failed) !== null && _b !== void 0 ? _b : (payload.msg || __('Options.createFailed')));
585
- result = null;
586
- }
587
- else {
588
- result = payload.data || result;
589
- }
590
- return [3 /*break*/, 7];
591
- case 6:
592
- e_1 = _f.sent();
593
- result = null;
594
- console.error(e_1);
595
- env.notify('error', e_1.message);
596
- return [3 /*break*/, 7];
597
- case 7:
598
- // 有 result 说明弹框点了确认。否则就是取消了。
599
- if (!result) {
600
- return [2 /*return*/];
601
- }
602
- // 没走服务端的。
603
- if (!result.hasOwnProperty(valueField || 'value')) {
604
- result = tslib.__assign(tslib.__assign({}, result), (_e = {}, _e[valueField || 'value'] = result[labelField || 'label'], _e));
605
- }
606
- return [4 /*yield*/, this.dispatchOptionEvent('add', tslib.__assign(tslib.__assign({}, result), { idx: idx }))];
607
- case 8:
608
- isPrevented = _f.sent();
609
- if (isPrevented) {
610
- return [2 /*return*/];
611
- }
612
- if (!(parent === null || parent === void 0 ? void 0 : parent.defer)) return [3 /*break*/, 10];
613
- return [4 /*yield*/, this.deferLoad(parent)];
614
- case 9:
615
- _f.sent();
616
- return [3 /*break*/, 11];
617
- case 10:
618
- if (source && addApi) {
619
- // 如果配置了 source 且配置了 addApi 直接重新拉取接口就够了
620
- // 不能不判断 addApi 就刷新,因为有些场景就是临时添加的。
621
- this.reload();
622
- }
623
- else {
624
- options = model.options.concat();
625
- if (Array.isArray(idx)) {
626
- options = helper.spliceTree(options, idx, 0, tslib.__assign({}, result));
627
- }
628
- else {
629
- ~idx
630
- ? options.splice(idx, 0, tslib.__assign({}, result))
631
- : options.push(tslib.__assign({}, result));
632
- }
633
- model.setOptions(options, this.changeOptionValue, data);
634
- }
635
- _f.label = 11;
636
- case 11: return [2 /*return*/];
637
- }
638
- });
639
- });
640
- };
641
- FormOptionsItem.prototype.handleOptionEdit = function (value, origin, skipForm) {
642
- var _a, _b;
643
- if (origin === void 0) { origin = value; }
644
- if (skipForm === void 0) { skipForm = false; }
645
- return tslib.__awaiter(this, void 0, void 0, function () {
646
- var _c, editControls, editDialog, disabled, labelField, onOpenDialog, editApi, editInitApi, env, source, data, model, optionLabel, __, result, _d, payload, e_2, isPrevented, indexes;
647
- return tslib.__generator(this, function (_e) {
648
- switch (_e.label) {
649
- case 0:
650
- _c = this.props, editControls = _c.editControls, editDialog = _c.editDialog, disabled = _c.disabled, labelField = _c.labelField, onOpenDialog = _c.onOpenDialog, editApi = _c.editApi, editInitApi = _c.editInitApi, env = _c.env, source = _c.source, data = _c.data, model = _c.formItem, optionLabel = _c.optionLabel, __ = _c.translate;
651
- if (disabled || !model) {
652
- return [2 /*return*/];
653
- }
654
- if (!skipForm && (!Array.isArray(editControls) || !editControls.length)) {
655
- editControls = [
656
- {
657
- type: 'text',
658
- name: labelField || 'label',
659
- label: false,
660
- placeholder: __('Options.addPlaceholder')
661
- }
662
- ];
663
- }
664
- if (!skipForm) return [3 /*break*/, 1];
665
- _d = value;
666
- return [3 /*break*/, 3];
667
- case 1: return [4 /*yield*/, onOpenDialog(tslib.__assign(tslib.__assign({ type: 'dialog', title: __('Options.editLabel', {
668
- label: optionLabel || __('Options.label')
669
- }) }, editDialog), { body: {
670
- type: 'form',
671
- initApi: editInitApi,
672
- api: editApi,
673
- controls: editControls
674
- } }), object.createObject(data, value))];
675
- case 2:
676
- _d = _e.sent();
677
- _e.label = 3;
678
- case 3:
679
- result = _d;
680
- if (!(skipForm && editApi)) return [3 /*break*/, 7];
681
- _e.label = 4;
682
- case 4:
683
- _e.trys.push([4, 6, , 7]);
684
- return [4 /*yield*/, env.fetcher(editApi, object.createObject(data, result), {
685
- method: 'post'
686
- })];
687
- case 5:
688
- payload = _e.sent();
689
- if (!payload.ok) {
690
- env.notify('error', (_b = (_a = editApi === null || editApi === void 0 ? void 0 : editApi.messages) === null || _a === void 0 ? void 0 : _a.failed) !== null && _b !== void 0 ? _b : (payload.msg || __('saveFailed')));
691
- result = null;
692
- }
693
- else {
694
- result = payload.data || result;
695
- }
696
- return [3 /*break*/, 7];
697
- case 6:
698
- e_2 = _e.sent();
699
- result = null;
700
- console.error(e_2);
701
- env.notify('error', e_2.message);
702
- return [3 /*break*/, 7];
703
- case 7:
704
- // 没有结果,说明取消了。
705
- if (!result) {
706
- return [2 /*return*/];
707
- }
708
- return [4 /*yield*/, this.dispatchOptionEvent('edit', result)];
709
- case 8:
710
- isPrevented = _e.sent();
711
- if (isPrevented) {
712
- return [2 /*return*/];
713
- }
714
- if (source && editApi) {
715
- this.reload();
716
- }
717
- else {
718
- indexes = helper.findTreeIndex(model.options, function (item) { return item === origin; });
719
- if (indexes) {
720
- model.setOptions(helper.spliceTree(model.options, indexes, 1, tslib.__assign(tslib.__assign({}, origin), result)), this.changeOptionValue, data);
721
- }
722
- }
723
- return [2 /*return*/];
724
- }
725
- });
726
- });
727
- };
728
- FormOptionsItem.prototype.handleOptionDelete = function (value) {
729
- var _a, _b;
730
- return tslib.__awaiter(this, void 0, void 0, function () {
731
- var _c, deleteConfirmText, disabled, data, deleteApi, onDelete, env, model, source, valueField, __, ctx, confirmed, _d, isPrevented, result, options, indexes, e_3;
732
- return tslib.__generator(this, function (_e) {
733
- switch (_e.label) {
734
- case 0:
735
- _c = this.props, deleteConfirmText = _c.deleteConfirmText, disabled = _c.disabled, data = _c.data, deleteApi = _c.deleteApi, onDelete = _c.onDelete, env = _c.env, model = _c.formItem, source = _c.source, valueField = _c.valueField, __ = _c.translate;
736
- if (disabled || !model) {
737
- return [2 /*return*/];
738
- }
739
- ctx = object.createObject(data, value);
740
- if (!deleteConfirmText) return [3 /*break*/, 2];
741
- return [4 /*yield*/, env.confirm(tpl.filter(__(deleteConfirmText), ctx))];
742
- case 1:
743
- _d = _e.sent();
744
- return [3 /*break*/, 3];
745
- case 2:
746
- _d = true;
747
- _e.label = 3;
748
- case 3:
749
- confirmed = _d;
750
- if (!confirmed) {
751
- return [2 /*return*/];
752
- }
753
- return [4 /*yield*/, this.dispatchOptionEvent('delete', ctx)];
754
- case 4:
755
- isPrevented = _e.sent();
756
- if (isPrevented) {
757
- return [2 /*return*/];
758
- }
759
- _e.label = 5;
760
- case 5:
761
- _e.trys.push([5, 8, , 9]);
762
- if (!deleteApi) return [3 /*break*/, 7];
763
- return [4 /*yield*/, env.fetcher(deleteApi, ctx, {
764
- method: 'delete'
765
- })];
766
- case 6:
767
- result = _e.sent();
768
- if (!result.ok) {
769
- env.notify('error', (_b = (_a = deleteApi === null || deleteApi === void 0 ? void 0 : deleteApi.messages) === null || _a === void 0 ? void 0 : _a.failed) !== null && _b !== void 0 ? _b : (result.msg || __('deleteFailed')));
770
- return [2 /*return*/];
771
- }
772
- _e.label = 7;
773
- case 7:
774
- // 由外部代码实现删除逻辑
775
- if (onDelete) {
776
- onDelete(ctx);
777
- }
778
- if (source) {
779
- this.reload();
780
- }
781
- else {
782
- options = model.options.concat();
783
- indexes = helper.findTreeIndex(options, function (item) { return item[valueField || 'value'] == value[valueField || 'value']; });
784
- if (indexes) {
785
- model.setOptions(helper.spliceTree(options, indexes, 1), this.changeOptionValue, data);
786
- }
787
- }
788
- return [3 /*break*/, 9];
789
- case 8:
790
- e_3 = _e.sent();
791
- console.error(e_3);
792
- env.notify('error', e_3.message);
793
- return [3 /*break*/, 9];
794
- case 9: return [2 /*return*/];
795
- }
796
- });
797
- });
798
- };
799
- FormOptionsItem.prototype.render = function () {
800
- var _a = this.props, value = _a.value, formItem = _a.formItem, addApi = _a.addApi, editApi = _a.editApi, deleteApi = _a.deleteApi, creatable = _a.creatable, editable = _a.editable, removable = _a.removable, enableNodePath = _a.enableNodePath, pathSeparator = _a.pathSeparator, _b = _a.delimiter, delimiter = _b === void 0 ? ',' : _b, _c = _a.labelField, labelField = _c === void 0 ? 'label' : _c, _d = _a.valueField, valueField = _d === void 0 ? 'value' : _d, __ = _a.translate;
801
- var _e = helper.normalizeNodePath(value, enableNodePath, labelField, valueField, pathSeparator, delimiter), nodePathArray = _e.nodePathArray, nodeValueArray = _e.nodeValueArray;
802
- return (React__default["default"].createElement(Control, tslib.__assign({}, this.props, { placeholder: __(this.props.placeholder), ref: this.inputRef, options: formItem ? formItem.filteredOptions : [], onToggle: this.handleToggle, onToggleAll: this.handleToggleAll, selectedOptions: formItem
803
- ? formItem.getSelectedOptions(value, enableNodePath ? nodeValueArray : undefined)
804
- : [], nodePath: nodePathArray, loading: formItem ? formItem.loading : false, setLoading: this.setLoading, setOptions: this.setOptions, syncOptions: this.syncOptions, reloadOptions: this.reload, deferLoad: this.deferLoad, leftDeferLoad: this.leftDeferLoad, expandTreeOptions: this.expandTreeOptions, creatable: creatable !== false && api.isEffectiveApi(addApi) ? true : creatable, editable: editable || (editable !== false && api.isEffectiveApi(editApi)), removable: removable || (removable !== false && api.isEffectiveApi(deleteApi)), onAdd: this.handleOptionAdd, onEdit: this.handleOptionEdit, onDelete: this.handleOptionDelete })));
805
- };
806
- FormOptionsItem.displayName = "OptionsControl(".concat(config.type, ")");
807
- FormOptionsItem.defaultProps = tslib.__assign({ delimiter: ',', labelField: 'label', valueField: 'value', joinValues: true, extractValue: false, multiple: false, placeholder: 'Select.placeholder', resetValue: '', deleteConfirmText: 'deleteConfirm' }, Control.defaultProps);
808
- FormOptionsItem.propsList = Control.propsList
809
- ? tslib.__spreadArray([], Control.propsList, true) : [];
810
- FormOptionsItem.ComposedComponent = Control;
811
- tslib.__decorate([
812
- helper.autobind,
813
- tslib.__metadata("design:type", Function),
814
- tslib.__metadata("design:paramtypes", [Object]),
815
- tslib.__metadata("design:returntype", void 0)
816
- ], FormOptionsItem.prototype, "inputRef", null);
817
- tslib.__decorate([
818
- helper.autobind,
819
- tslib.__metadata("design:type", Function),
820
- tslib.__metadata("design:paramtypes", [Object, Boolean, Boolean]),
821
- tslib.__metadata("design:returntype", Promise)
822
- ], FormOptionsItem.prototype, "handleToggle", null);
823
- tslib.__decorate([
824
- helper.autobind,
825
- tslib.__metadata("design:type", Function),
826
- tslib.__metadata("design:paramtypes", []),
827
- tslib.__metadata("design:returntype", Promise)
828
- ], FormOptionsItem.prototype, "handleToggleAll", null);
829
- tslib.__decorate([
830
- helper.autobind,
831
- tslib.__metadata("design:type", Function),
832
- tslib.__metadata("design:paramtypes", []),
833
- tslib.__metadata("design:returntype", void 0)
834
- ], FormOptionsItem.prototype, "reload", null);
835
- tslib.__decorate([
836
- helper.autobind,
837
- tslib.__metadata("design:type", Function),
838
- tslib.__metadata("design:paramtypes", [Boolean, Object]),
839
- tslib.__metadata("design:returntype", void 0)
840
- ], FormOptionsItem.prototype, "reloadOptions", null);
841
- tslib.__decorate([
842
- helper.autobind,
843
- tslib.__metadata("design:type", Function),
844
- tslib.__metadata("design:paramtypes", [Object]),
845
- tslib.__metadata("design:returntype", Promise)
846
- ], FormOptionsItem.prototype, "deferLoad", null);
847
- tslib.__decorate([
848
- helper.autobind,
849
- tslib.__metadata("design:type", Function),
850
- tslib.__metadata("design:paramtypes", [Object, Object]),
851
- tslib.__metadata("design:returntype", void 0)
852
- ], FormOptionsItem.prototype, "leftDeferLoad", null);
853
- tslib.__decorate([
854
- helper.autobind,
855
- tslib.__metadata("design:type", Function),
856
- tslib.__metadata("design:paramtypes", [Array]),
857
- tslib.__metadata("design:returntype", void 0)
858
- ], FormOptionsItem.prototype, "expandTreeOptions", null);
859
- tslib.__decorate([
860
- helper.autobind,
861
- tslib.__metadata("design:type", Function),
862
- tslib.__metadata("design:paramtypes", [Object]),
863
- tslib.__metadata("design:returntype", Promise)
864
- ], FormOptionsItem.prototype, "initOptions", null);
865
- tslib.__decorate([
866
- helper.autobind,
867
- tslib.__metadata("design:type", Function),
868
- tslib.__metadata("design:paramtypes", [Object]),
869
- tslib.__metadata("design:returntype", void 0)
870
- ], FormOptionsItem.prototype, "changeOptionValue", null);
871
- tslib.__decorate([
872
- helper.autobind,
873
- tslib.__metadata("design:type", Function),
874
- tslib.__metadata("design:paramtypes", [Array, Object]),
875
- tslib.__metadata("design:returntype", void 0)
876
- ], FormOptionsItem.prototype, "setOptions", null);
877
- tslib.__decorate([
878
- helper.autobind,
879
- tslib.__metadata("design:type", Function),
880
- tslib.__metadata("design:paramtypes", []),
881
- tslib.__metadata("design:returntype", void 0)
882
- ], FormOptionsItem.prototype, "syncOptions", null);
883
- tslib.__decorate([
884
- helper.autobind,
885
- tslib.__metadata("design:type", Function),
886
- tslib.__metadata("design:paramtypes", [Boolean]),
887
- tslib.__metadata("design:returntype", void 0)
888
- ], FormOptionsItem.prototype, "setLoading", null);
889
- tslib.__decorate([
890
- helper.autobind,
891
- tslib.__metadata("design:type", Function),
892
- tslib.__metadata("design:paramtypes", [Object, Object, Boolean]),
893
- tslib.__metadata("design:returntype", Promise)
894
- ], FormOptionsItem.prototype, "handleOptionAdd", null);
895
- tslib.__decorate([
896
- helper.autobind,
897
- tslib.__metadata("design:type", Function),
898
- tslib.__metadata("design:paramtypes", [Object, Object, Boolean]),
899
- tslib.__metadata("design:returntype", Promise)
900
- ], FormOptionsItem.prototype, "handleOptionEdit", null);
901
- tslib.__decorate([
902
- helper.autobind,
903
- tslib.__metadata("design:type", Function),
904
- tslib.__metadata("design:paramtypes", [Object]),
905
- tslib.__metadata("design:returntype", Promise)
906
- ], FormOptionsItem.prototype, "handleOptionDelete", null);
907
- return FormOptionsItem;
908
- }(React__default["default"].Component));
909
- return Item.registerFormItem(tslib.__assign(tslib.__assign({}, config), { strictMode: false, component: FormOptionsItem }));
910
- }
911
- function OptionsControl(config) {
912
- return function (component) {
913
- var renderer = registerOptionsControl(tslib.__assign(tslib.__assign({}, config), { component: component }));
914
- return renderer.component;
915
- };
916
- }
917
-
918
- exports.OptionsControl = OptionsControl;
919
- exports.detectProps = detectProps;
920
- exports.registerOptionsControl = registerOptionsControl;