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