@cloudbase/weda-ui 3.2.0 → 3.3.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 (356) hide show
  1. package/dist/cypress/support/commands.d.ts +1 -0
  2. package/dist/cypress/support/commands.js +40 -0
  3. package/dist/cypress/support/e2e.d.ts +24 -0
  4. package/dist/cypress/support/e2e.js +22 -0
  5. package/dist/src/configs/actions/showModal.json +48 -0
  6. package/dist/src/configs/actions/showToast.json +41 -0
  7. package/dist/src/configs/components/auth.json +16 -0
  8. package/dist/src/configs/components/button.json +239 -0
  9. package/dist/src/configs/components/calendar.json +81 -0
  10. package/dist/src/configs/components/carousel.json +292 -0
  11. package/dist/src/configs/components/chart/bar.json +962 -0
  12. package/dist/src/configs/components/chart/line.json +878 -0
  13. package/dist/src/configs/components/chart/pie.json +685 -0
  14. package/dist/src/configs/components/chart/statisticsCard.json +376 -0
  15. package/dist/src/configs/components/container.json +50 -0
  16. package/dist/src/configs/components/dataView.json +247 -0
  17. package/dist/src/configs/components/drawer.json +115 -0
  18. package/dist/src/configs/components/form/checkbox.json +179 -0
  19. package/dist/src/configs/components/form/departTreeSelect.json +124 -0
  20. package/dist/src/configs/components/form/form.json +73 -0
  21. package/dist/src/configs/components/form/input.json +154 -0
  22. package/dist/src/configs/components/form/location.json +216 -0
  23. package/dist/src/configs/components/form/radio.json +203 -0
  24. package/dist/src/configs/components/form/richText.json +133 -0
  25. package/dist/src/configs/components/form/select.json +449 -0
  26. package/dist/src/configs/components/form/switch.json +58 -0
  27. package/dist/src/configs/components/form/textarea.json +116 -0
  28. package/dist/src/configs/components/form/tips.json +34 -0
  29. package/dist/src/configs/components/form/uploader.json +171 -0
  30. package/dist/src/configs/components/form/uploaderFile.json +158 -0
  31. package/dist/src/configs/components/form/userTreeSelect.json +128 -0
  32. package/dist/src/configs/components/formdetail.json +105 -0
  33. package/dist/src/configs/components/graphicCard.json +413 -0
  34. package/dist/src/configs/components/image.json +187 -0
  35. package/dist/src/configs/components/link.json +79 -0
  36. package/dist/src/configs/components/listView.json +378 -0
  37. package/dist/src/configs/components/lottery.json +163 -0
  38. package/dist/src/configs/components/modal.json +72 -0
  39. package/dist/src/configs/components/navLayout.json +368 -0
  40. package/dist/src/configs/components/navigationBar.json +62 -0
  41. package/dist/src/configs/components/richtextview.json +26 -0
  42. package/dist/src/configs/components/scrollVeiw.json +253 -0
  43. package/dist/src/configs/components/slot.json +17 -0
  44. package/dist/src/configs/components/swiper.json +90 -0
  45. package/dist/src/configs/components/tabs.json +122 -0
  46. package/dist/src/configs/components/text.json +95 -0
  47. package/dist/src/configs/components/wedaVideo.json +89 -0
  48. package/dist/src/configs/components/wxOpenApi/phone.json +127 -0
  49. package/dist/src/configs/components/wxOpenApi/phoneCode.json +109 -0
  50. package/dist/src/configs/components/wxOpenApi/share.json +160 -0
  51. package/dist/src/configs/components/wxOpenApi/userInfo.json +156 -0
  52. package/dist/src/configs/index.d.ts +103 -0
  53. package/dist/src/configs/index.js +111 -0
  54. package/dist/src/docs/common/format.d.ts +13 -0
  55. package/dist/src/docs/common/format.js +122 -0
  56. package/dist/src/docs/common/tableView.d.ts +30 -0
  57. package/dist/src/docs/common/tableView.js +156 -0
  58. package/dist/src/index.d.ts +2 -0
  59. package/dist/src/index.js +3 -0
  60. package/dist/src/setupTests.d.ts +2 -0
  61. package/dist/src/setupTests.js +19 -0
  62. package/dist/src/web/actions/index.d.ts +2 -0
  63. package/dist/src/web/actions/index.js +2 -0
  64. package/dist/src/web/actions/showModal/index.d.ts +4 -0
  65. package/dist/src/web/actions/showModal/index.js +66 -0
  66. package/dist/src/web/actions/showToast/index.d.ts +1 -0
  67. package/dist/src/web/actions/showToast/index.js +3 -0
  68. package/dist/src/web/components/button/index.d.ts +32 -0
  69. package/dist/src/web/components/button/index.js +48 -0
  70. package/dist/src/web/components/calendar/index.d.ts +19 -0
  71. package/dist/src/web/components/calendar/index.js +191 -0
  72. package/dist/src/web/components/calendar/util.d.ts +13 -0
  73. package/dist/src/web/components/calendar/util.js +74 -0
  74. package/dist/src/web/components/carousel/index.d.ts +41 -0
  75. package/dist/src/web/components/carousel/index.js +244 -0
  76. package/dist/src/web/components/chart/bar/index.d.ts +3 -0
  77. package/dist/src/web/components/chart/bar/index.js +45 -0
  78. package/dist/src/web/components/chart/bar/index.old.d.ts +40 -0
  79. package/dist/src/web/components/chart/bar/index.old.js +56 -0
  80. package/dist/src/web/components/chart/common/Chart.d.ts +10 -0
  81. package/dist/src/web/components/chart/common/Chart.js +31 -0
  82. package/dist/src/web/components/chart/common/chart-custom-connector.d.ts +6 -0
  83. package/dist/src/web/components/chart/common/chart-custom-connector.js +35 -0
  84. package/dist/src/web/components/chart/common/chart-error.d.ts +2 -0
  85. package/dist/src/web/components/chart/common/chart-error.js +2 -0
  86. package/dist/src/web/components/chart/common/config/bar.d.ts +48 -0
  87. package/dist/src/web/components/chart/common/config/bar.js +49 -0
  88. package/dist/src/web/components/chart/common/config/global.d.ts +13 -0
  89. package/dist/src/web/components/chart/common/config/global.js +16 -0
  90. package/dist/src/web/components/chart/common/config/line.d.ts +46 -0
  91. package/dist/src/web/components/chart/common/config/line.js +49 -0
  92. package/dist/src/web/components/chart/common/config/pie.d.ts +29 -0
  93. package/dist/src/web/components/chart/common/config/pie.js +36 -0
  94. package/dist/src/web/components/chart/common/core/eChartBar.d.ts +66 -0
  95. package/dist/src/web/components/chart/common/core/eChartBar.js +201 -0
  96. package/dist/src/web/components/chart/common/core/eChartBase.d.ts +127 -0
  97. package/dist/src/web/components/chart/common/core/eChartBase.js +394 -0
  98. package/dist/src/web/components/chart/common/core/eChartLine.d.ts +60 -0
  99. package/dist/src/web/components/chart/common/core/eChartLine.js +173 -0
  100. package/dist/src/web/components/chart/common/core/eChartPie.d.ts +48 -0
  101. package/dist/src/web/components/chart/common/core/eChartPie.js +135 -0
  102. package/dist/src/web/components/chart/common/core/type.d.ts +35 -0
  103. package/dist/src/web/components/chart/common/core/type.js +9 -0
  104. package/dist/src/web/components/chart/common/data-transform.d.ts +6 -0
  105. package/dist/src/web/components/chart/common/data-transform.js +248 -0
  106. package/dist/src/web/components/chart/common/echarts.d.ts +5 -0
  107. package/dist/src/web/components/chart/common/echarts.js +24 -0
  108. package/dist/src/web/components/chart/common/error-boundary.d.ts +5 -0
  109. package/dist/src/web/components/chart/common/error-boundary.js +26 -0
  110. package/dist/src/web/components/chart/common/useChart.d.ts +8 -0
  111. package/dist/src/web/components/chart/common/useChart.js +72 -0
  112. package/dist/src/web/components/chart/line/index.d.ts +3 -0
  113. package/dist/src/web/components/chart/line/index.js +42 -0
  114. package/dist/src/web/components/chart/line/index.old.d.ts +38 -0
  115. package/dist/src/web/components/chart/line/index.old.js +53 -0
  116. package/dist/src/web/components/chart/pie/index.d.ts +3 -0
  117. package/dist/src/web/components/chart/pie/index.js +42 -0
  118. package/dist/src/web/components/chart/pie/index.old.d.ts +27 -0
  119. package/dist/src/web/components/chart/pie/index.old.js +40 -0
  120. package/dist/src/web/components/chart/statisticsCard/index.d.ts +85 -0
  121. package/dist/src/web/components/chart/statisticsCard/index.js +203 -0
  122. package/dist/src/web/components/chart/statisticsCard/interface.d.ts +13 -0
  123. package/dist/src/web/components/chart/statisticsCard/interface.js +1 -0
  124. package/dist/src/web/components/common/error-boundary.d.ts +5 -0
  125. package/dist/src/web/components/common/error-boundary.js +33 -0
  126. package/dist/src/web/components/common/portal.d.ts +7 -0
  127. package/dist/src/web/components/common/portal.js +14 -0
  128. package/dist/src/web/components/common/use-loop-render-detect.d.ts +11 -0
  129. package/dist/src/web/components/common/use-loop-render-detect.js +124 -0
  130. package/dist/src/web/components/container/index.d.ts +6 -0
  131. package/dist/src/web/components/container/index.js +6 -0
  132. package/dist/src/web/components/dataView/index.d.ts +6 -0
  133. package/dist/src/web/components/dataView/index.js +8 -0
  134. package/dist/src/web/components/dataView/interface.d.ts +5 -0
  135. package/dist/src/web/components/dataView/interface.js +1 -0
  136. package/dist/src/web/components/drawer/index.d.ts +13 -0
  137. package/dist/src/web/components/drawer/index.js +12 -0
  138. package/dist/src/web/components/form/checkbox/index.d.ts +13 -0
  139. package/dist/src/web/components/form/checkbox/index.js +167 -0
  140. package/dist/src/web/components/form/enumSelect/MultipleSelect.d.ts +78 -0
  141. package/dist/src/web/components/form/enumSelect/MultipleSelect.js +52 -0
  142. package/dist/src/web/components/form/enumSelect/NormalSelect.d.ts +83 -0
  143. package/dist/src/web/components/form/enumSelect/NormalSelect.js +52 -0
  144. package/dist/src/web/components/form/enumSelect/SelectContainer.d.ts +16 -0
  145. package/dist/src/web/components/form/enumSelect/SelectContainer.js +30 -0
  146. package/dist/src/web/components/form/enumSelect/index.d.ts +82 -0
  147. package/dist/src/web/components/form/enumSelect/index.js +6 -0
  148. package/dist/src/web/components/form/enumSelect/props/defaultProps.d.ts +34 -0
  149. package/dist/src/web/components/form/enumSelect/props/defaultProps.js +40 -0
  150. package/dist/src/web/components/form/enumSelect/props/propsTypes.d.ts +39 -0
  151. package/dist/src/web/components/form/enumSelect/props/propsTypes.js +47 -0
  152. package/dist/src/web/components/form/form/index.d.ts +32 -0
  153. package/dist/src/web/components/form/form/index.js +150 -0
  154. package/dist/src/web/components/form/formcell/index.d.ts +8 -0
  155. package/dist/src/web/components/form/formcell/index.js +40 -0
  156. package/dist/src/web/components/form/input/index.d.ts +14 -0
  157. package/dist/src/web/components/form/input/index.js +94 -0
  158. package/dist/src/web/components/form/location/common/mapChoose.d.ts +15 -0
  159. package/dist/src/web/components/form/location/common/mapChoose.js +496 -0
  160. package/dist/src/web/components/form/location/common/mapView.d.ts +19 -0
  161. package/dist/src/web/components/form/location/common/mapView.js +175 -0
  162. package/dist/src/web/components/form/location/common/propsConfig.d.ts +59 -0
  163. package/dist/src/web/components/form/location/common/propsConfig.js +50 -0
  164. package/dist/src/web/components/form/location/common/selectModal.d.ts +21 -0
  165. package/dist/src/web/components/form/location/common/selectModal.js +44 -0
  166. package/dist/src/web/components/form/location/common/tmap.d.ts +3 -0
  167. package/dist/src/web/components/form/location/common/tmap.js +21 -0
  168. package/dist/src/web/components/form/location/common/useLocationInfo.d.ts +36 -0
  169. package/dist/src/web/components/form/location/common/useLocationInfo.js +105 -0
  170. package/dist/src/web/components/form/location/components/LocationH5/location.h5.d.ts +8 -0
  171. package/dist/src/web/components/form/location/components/LocationH5/location.h5.js +328 -0
  172. package/dist/src/web/components/form/location/components/LocationPC/Header.d.ts +12 -0
  173. package/dist/src/web/components/form/location/components/LocationPC/Header.js +43 -0
  174. package/dist/src/web/components/form/location/components/LocationPC/location.PC.d.ts +8 -0
  175. package/dist/src/web/components/form/location/components/LocationPC/location.PC.js +228 -0
  176. package/dist/src/web/components/form/location/constants.d.ts +2 -0
  177. package/dist/src/web/components/form/location/constants.js +3 -0
  178. package/dist/src/web/components/form/location/index.d.ts +1 -0
  179. package/dist/src/web/components/form/location/index.js +24 -0
  180. package/dist/src/web/components/form/radio/index.d.ts +11 -0
  181. package/dist/src/web/components/form/radio/index.js +115 -0
  182. package/dist/src/web/components/form/renderDecorator.d.ts +6 -0
  183. package/dist/src/web/components/form/renderDecorator.js +20 -0
  184. package/dist/src/web/components/form/select/allTimePicker/calendar.d.ts +13 -0
  185. package/dist/src/web/components/form/select/allTimePicker/calendar.js +104 -0
  186. package/dist/src/web/components/form/select/allTimePicker/dataUtils.d.ts +24 -0
  187. package/dist/src/web/components/form/select/allTimePicker/dataUtils.js +265 -0
  188. package/dist/src/web/components/form/select/allTimePicker/index.d.ts +14 -0
  189. package/dist/src/web/components/form/select/allTimePicker/index.js +944 -0
  190. package/dist/src/web/components/form/select/dropdown-select/ui.d.ts +15 -0
  191. package/dist/src/web/components/form/select/dropdown-select/ui.js +55 -0
  192. package/dist/src/web/components/form/select/h5.d.ts +16 -0
  193. package/dist/src/web/components/form/select/h5.js +466 -0
  194. package/dist/src/web/components/form/select/index.d.ts +66 -0
  195. package/dist/src/web/components/form/select/index.js +255 -0
  196. package/dist/src/web/components/form/select/region/index.d.ts +6 -0
  197. package/dist/src/web/components/form/select/region/index.js +147 -0
  198. package/dist/src/web/components/form/select/time.d.ts +9 -0
  199. package/dist/src/web/components/form/select/time.js +146 -0
  200. package/dist/src/web/components/form/select/use-options.d.ts +26 -0
  201. package/dist/src/web/components/form/select/use-options.js +103 -0
  202. package/dist/src/web/components/form/select/year.d.ts +7 -0
  203. package/dist/src/web/components/form/select/year.js +72 -0
  204. package/dist/src/web/components/form/switch/index.d.ts +6 -0
  205. package/dist/src/web/components/form/switch/index.js +58 -0
  206. package/dist/src/web/components/form/textarea/index.d.ts +12 -0
  207. package/dist/src/web/components/form/textarea/index.js +66 -0
  208. package/dist/src/web/components/form/tips/index.d.ts +8 -0
  209. package/dist/src/web/components/form/tips/index.js +17 -0
  210. package/dist/src/web/components/form/uploader/index.d.ts +3 -0
  211. package/dist/src/web/components/form/uploader/index.js +42 -0
  212. package/dist/src/web/components/form/uploader/uploader.h5.d.ts +20 -0
  213. package/dist/src/web/components/form/uploader/uploader.h5.js +199 -0
  214. package/dist/src/web/components/form/uploader/uploader.pc.d.ts +29 -0
  215. package/dist/src/web/components/form/uploader/uploader.pc.js +208 -0
  216. package/dist/src/web/components/form/uploaderFile/index.d.ts +4 -0
  217. package/dist/src/web/components/form/uploaderFile/index.js +19 -0
  218. package/dist/src/web/components/form/uploaderFile/uploadFile.h5.d.ts +23 -0
  219. package/dist/src/web/components/form/uploaderFile/uploadFile.h5.js +330 -0
  220. package/dist/src/web/components/form/uploaderFile/uploadFile.pc.d.ts +24 -0
  221. package/dist/src/web/components/form/uploaderFile/uploadFile.pc.js +302 -0
  222. package/dist/src/web/components/form/userOrgSelect/comTool.d.ts +8 -0
  223. package/dist/src/web/components/form/userOrgSelect/comTool.js +101 -0
  224. package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.d.ts +19 -0
  225. package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +252 -0
  226. package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.d.ts +4 -0
  227. package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.js +157 -0
  228. package/dist/src/web/components/form/userOrgSelect/departTreeSelect/index.d.ts +2 -0
  229. package/dist/src/web/components/form/userOrgSelect/departTreeSelect/index.js +17 -0
  230. package/dist/src/web/components/form/userOrgSelect/getUserService.d.ts +11 -0
  231. package/dist/src/web/components/form/userOrgSelect/getUserService.js +159 -0
  232. package/dist/src/web/components/form/userOrgSelect/index.d.ts +2 -0
  233. package/dist/src/web/components/form/userOrgSelect/index.js +17 -0
  234. package/dist/src/web/components/form/userOrgSelect/userTreeSelect.h5.d.ts +27 -0
  235. package/dist/src/web/components/form/userOrgSelect/userTreeSelect.h5.js +276 -0
  236. package/dist/src/web/components/form/userOrgSelect/userTreeSelect.pc.d.ts +9 -0
  237. package/dist/src/web/components/form/userOrgSelect/userTreeSelect.pc.js +253 -0
  238. package/dist/src/web/components/form/userOrgSelect/utils.d.ts +36 -0
  239. package/dist/src/web/components/form/userOrgSelect/utils.js +80 -0
  240. package/dist/src/web/components/formdetail/index.d.ts +28 -0
  241. package/dist/src/web/components/formdetail/index.js +173 -0
  242. package/dist/src/web/components/graphicCard/index.d.ts +46 -0
  243. package/dist/src/web/components/graphicCard/index.js +178 -0
  244. package/dist/src/web/components/image/image.d.ts +9 -0
  245. package/dist/src/web/components/image/image.js +119 -0
  246. package/dist/src/web/components/image/index.d.ts +13 -0
  247. package/dist/src/web/components/image/index.js +77 -0
  248. package/dist/src/web/components/index.d.ts +50 -0
  249. package/dist/src/web/components/index.js +99 -0
  250. package/dist/src/web/components/link/index.d.ts +24 -0
  251. package/dist/src/web/components/link/index.js +71 -0
  252. package/dist/src/web/components/listView/index.d.ts +7 -0
  253. package/dist/src/web/components/listView/index.js +297 -0
  254. package/dist/src/web/components/listView/interface.d.ts +127 -0
  255. package/dist/src/web/components/listView/interface.js +1 -0
  256. package/dist/src/web/components/lottery/index.d.ts +22 -0
  257. package/dist/src/web/components/lottery/index.js +385 -0
  258. package/dist/src/web/components/lottery/lotteryUtil.d.ts +23 -0
  259. package/dist/src/web/components/lottery/lotteryUtil.js +181 -0
  260. package/dist/src/web/components/modal/index.d.ts +17 -0
  261. package/dist/src/web/components/modal/index.js +11 -0
  262. package/dist/src/web/components/modal/modal.h5.d.ts +4 -0
  263. package/dist/src/web/components/modal/modal.h5.js +46 -0
  264. package/dist/src/web/components/modal/modal.pc.d.ts +3 -0
  265. package/dist/src/web/components/modal/modal.pc.js +31 -0
  266. package/dist/src/web/components/navLayout/index.d.ts +61 -0
  267. package/dist/src/web/components/navLayout/index.js +127 -0
  268. package/dist/src/web/components/navigationBar/common.d.ts +15 -0
  269. package/dist/src/web/components/navigationBar/common.js +127 -0
  270. package/dist/src/web/components/navigationBar/h5Menu.d.ts +14 -0
  271. package/dist/src/web/components/navigationBar/h5Menu.js +72 -0
  272. package/dist/src/web/components/navigationBar/horizontalMenu.d.ts +12 -0
  273. package/dist/src/web/components/navigationBar/horizontalMenu.js +99 -0
  274. package/dist/src/web/components/navigationBar/index.d.ts +13 -0
  275. package/dist/src/web/components/navigationBar/index.js +157 -0
  276. package/dist/src/web/components/navigationBar/verticalMenu.d.ts +13 -0
  277. package/dist/src/web/components/navigationBar/verticalMenu.js +38 -0
  278. package/dist/src/web/components/phone/index.d.ts +18 -0
  279. package/dist/src/web/components/phone/index.js +4 -0
  280. package/dist/src/web/components/phoneCode/index.d.ts +18 -0
  281. package/dist/src/web/components/phoneCode/index.js +4 -0
  282. package/dist/src/web/components/picker/datePicker.d.ts +10 -0
  283. package/dist/src/web/components/picker/datePicker.js +31 -0
  284. package/dist/src/web/components/picker/picker.d.ts +6 -0
  285. package/dist/src/web/components/picker/picker.js +45 -0
  286. package/dist/src/web/components/picker/timePicker.d.ts +7 -0
  287. package/dist/src/web/components/picker/timePicker.js +42 -0
  288. package/dist/src/web/components/richText/const.d.ts +1 -0
  289. package/dist/src/web/components/richText/const.js +2 -0
  290. package/dist/src/web/components/richText/index.d.ts +50 -0
  291. package/dist/src/web/components/richText/index.js +351 -0
  292. package/dist/src/web/components/richTextView/index.d.ts +7 -0
  293. package/dist/src/web/components/richTextView/index.js +46 -0
  294. package/dist/src/web/components/scrollView/index.d.ts +26 -0
  295. package/dist/src/web/components/scrollView/index.js +97 -0
  296. package/dist/src/web/components/share/index.d.ts +34 -0
  297. package/dist/src/web/components/share/index.js +4 -0
  298. package/dist/src/web/components/slot/index.d.ts +6 -0
  299. package/dist/src/web/components/slot/index.js +9 -0
  300. package/dist/src/web/components/swiper/index.d.ts +24 -0
  301. package/dist/src/web/components/swiper/index.js +153 -0
  302. package/dist/src/web/components/tabs/index.d.ts +13 -0
  303. package/dist/src/web/components/tabs/index.js +20 -0
  304. package/dist/src/web/components/tabs/tabs.h5.d.ts +4 -0
  305. package/dist/src/web/components/tabs/tabs.h5.js +44 -0
  306. package/dist/src/web/components/tabs/tabs.pc.d.ts +3 -0
  307. package/dist/src/web/components/tabs/tabs.pc.js +40 -0
  308. package/dist/src/web/components/text/index.d.ts +14 -0
  309. package/dist/src/web/components/text/index.js +19 -0
  310. package/dist/src/web/components/uploaderFileView/index.d.ts +10 -0
  311. package/dist/src/web/components/uploaderFileView/index.js +46 -0
  312. package/dist/src/web/components/uploaderView/index.d.ts +17 -0
  313. package/dist/src/web/components/uploaderView/index.js +48 -0
  314. package/dist/src/web/components/userInfo/index.d.ts +26 -0
  315. package/dist/src/web/components/userInfo/index.js +4 -0
  316. package/dist/src/web/components/wedaVideo/index.d.ts +17 -0
  317. package/dist/src/web/components/wedaVideo/index.js +156 -0
  318. package/dist/src/web/index.d.ts +8 -0
  319. package/dist/src/web/index.js +4 -0
  320. package/dist/src/web/utils/classnames.d.ts +2 -0
  321. package/dist/src/web/utils/classnames.js +37 -0
  322. package/dist/src/web/utils/console.d.ts +3 -0
  323. package/dist/src/web/utils/console.js +26 -0
  324. package/dist/src/web/utils/constant.d.ts +23 -0
  325. package/dist/src/web/utils/constant.js +24 -0
  326. package/dist/src/web/utils/debounce.d.ts +2 -0
  327. package/dist/src/web/utils/debounce.js +92 -0
  328. package/dist/src/web/utils/getLocalCounter.d.ts +1 -0
  329. package/dist/src/web/utils/getLocalCounter.js +4 -0
  330. package/dist/src/web/utils/getUserService.d.ts +11 -0
  331. package/dist/src/web/utils/getUserService.js +156 -0
  332. package/dist/src/web/utils/isObjectEqual.d.ts +2 -0
  333. package/dist/src/web/utils/isObjectEqual.js +12 -0
  334. package/dist/src/web/utils/loading-fallback.d.ts +2 -0
  335. package/dist/src/web/utils/loading-fallback.js +2 -0
  336. package/dist/src/web/utils/lodash.d.ts +1 -0
  337. package/dist/src/web/utils/lodash.js +2 -0
  338. package/dist/src/web/utils/platform.d.ts +18 -0
  339. package/dist/src/web/utils/platform.js +193 -0
  340. package/dist/src/web/utils/tcb.d.ts +33 -0
  341. package/dist/src/web/utils/tcb.js +118 -0
  342. package/dist/src/web/utils/tmap.d.ts +3 -0
  343. package/dist/src/web/utils/tmap.js +21 -0
  344. package/dist/src/web/utils/use-cloud-id-temp-url.d.ts +1 -0
  345. package/dist/src/web/utils/use-cloud-id-temp-url.js +15 -0
  346. package/dist/src/web/utils/useSetState.d.ts +1 -0
  347. package/dist/src/web/utils/useSetState.js +8 -0
  348. package/dist/src/web/utils/useSyncValue.d.ts +4 -0
  349. package/dist/src/web/utils/useSyncValue.js +16 -0
  350. package/dist/src/web/utils/weui.d.ts +1 -0
  351. package/dist/src/web/utils/weui.js +2 -0
  352. package/dist/web/components/form/input/index.css +16 -0
  353. package/dist/web/components/form/select/allTimePicker/calendar.css +114 -0
  354. package/dist/web/components/form/select/allTimePicker/index.css +136 -0
  355. package/dist/web/components/form/userOrgSelect/userOrgSelect.css +809 -0
  356. package/package.json +34 -21
@@ -0,0 +1,496 @@
1
+ /* eslint-disable react-hooks/exhaustive-deps */
2
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
+ // @ts-nocheck
4
+ import * as React from 'react';
5
+ import classNames from '../../../../utils/classnames';
6
+ import debounce from '../../../../utils/debounce';
7
+ import { tmapApiUrl } from '../constants';
8
+ import { getTMap, calculateDistance, base64LocationIcon } from './tmap';
9
+ import './mapChoose.css';
10
+ import { Icon } from 'tea-component';
11
+ const { useEffect, useState, useRef, useMemo } = React;
12
+ let relativePosition;
13
+ const defaultLatLng = {
14
+ lat: null,
15
+ lng: null,
16
+ };
17
+ export default function MapChoose({ changeLocation, onConfirm, onClose, currentLocations, latlng = defaultLatLng, isPC, APIKEY = '', locationRange, customRange, setConfirmStatus, }) {
18
+ const { lat, lng } = latlng;
19
+ const mapRef = useRef();
20
+ const markerRef = useRef();
21
+ const centerRef = useRef();
22
+ const [isSearch, setIsSearch] = useState(false);
23
+ const [searchValue, setSearchValue] = useState('');
24
+ const [chooseLoc, setChooseLoc] = useState({
25
+ location: {
26
+ lat: null,
27
+ lng: null,
28
+ },
29
+ title: '',
30
+ address: '',
31
+ id: '',
32
+ });
33
+ const [exploreList, setExploreList] = useState([]);
34
+ const [searchList, setSearchList] = useState([]);
35
+ const mapDomName = Date.now();
36
+ const clientHeight = useMemo(() => document.documentElement.clientHeight, []);
37
+ const [mapBoxHeight, setMapBoxHeight] = useState(clientHeight - 328);
38
+ const [searchLoadingStatus, setSearchLoadingStatus] = useState(false);
39
+ const [isOutofrange, setIsOutofrange] = useState(false);
40
+ const [searchBoxHeight, setSearchBoxHeight] = useState(328);
41
+ const touchCoordinate = useRef({
42
+ startY: 0,
43
+ lastY: 0,
44
+ });
45
+ const searchListRef = useRef();
46
+ const searchListPageSize = useRef(1);
47
+ useEffect(() => {
48
+ if (!APIKEY || new RegExp('[\\u4E00-\\u9FFF]+', 'g').test(APIKEY))
49
+ return;
50
+ function loadScript() {
51
+ const script = document.createElement('script');
52
+ script.type = 'text/javascript';
53
+ script.src = `${tmapApiUrl}?v=2.exp&key=${APIKEY}&callback=init&libraries=service`;
54
+ script.onload = () => {
55
+ initMap();
56
+ };
57
+ script.onerror = (error) => {
58
+ console.error(' load mapchoose error success', APIKEY, error);
59
+ };
60
+ document.body.appendChild(script);
61
+ }
62
+ if (getTMap()) {
63
+ initMap();
64
+ }
65
+ else {
66
+ loadScript();
67
+ }
68
+ exploreNear('updateCenter');
69
+ return () => {
70
+ mapRef.current && mapRef.current.destroy();
71
+ };
72
+ }, [APIKEY]);
73
+ useEffect(() => {
74
+ setConfirmStatus(getConfirm());
75
+ }, [isOutofrange, chooseLoc.id]);
76
+ const initMap = () => {
77
+ if (!getTMap())
78
+ return;
79
+ const TMap = getTMap();
80
+ //定义地图中心点坐标
81
+ const center = new TMap.LatLng(lat, lng);
82
+ //定义map变量,调用 TMap.Map() 构造函数创建地图
83
+ mapRef.current = new TMap.Map(document.getElementById(`form-map-choose-${mapDomName}`), {
84
+ center,
85
+ zoom: 16, //设置地图缩放级别
86
+ });
87
+ initMarker(TMap, mapRef.current);
88
+ getRadius() && initCircle(TMap, mapRef.current);
89
+ };
90
+ const initMarker = (TMap, map) => {
91
+ const canLoad = lat && lng && TMap && map;
92
+ if (canLoad) {
93
+ const position = new TMap.LatLng(lat, lng);
94
+ const currentLocationsLatlng = currentLocations.latlng;
95
+ const currentLocationsPosition = new TMap.LatLng(currentLocationsLatlng.lat, currentLocationsLatlng.lng);
96
+ markerRef.current = new TMap.MultiMarker({
97
+ map: mapRef.current,
98
+ styles: {
99
+ pointer: new TMap.MarkerStyle({
100
+ width: 26,
101
+ height: 35,
102
+ }),
103
+ originPointer: new window.TMap.MarkerStyle({
104
+ width: 70,
105
+ height: 70,
106
+ src: base64LocationIcon,
107
+ anchor: {
108
+ x: 35,
109
+ y: 30,
110
+ },
111
+ }),
112
+ },
113
+ geometries: [
114
+ {
115
+ id: `pointer-origin-${mapDomName}`,
116
+ styleId: 'originPointer',
117
+ position: currentLocationsPosition,
118
+ },
119
+ {
120
+ id: `pointer-${mapDomName}`,
121
+ styleId: 'pointer',
122
+ position,
123
+ },
124
+ ],
125
+ });
126
+ // 监听中心点变化事件,更新marker的位置
127
+ map.on('drag', mapDrag);
128
+ }
129
+ };
130
+ const initCircle = (TMap, map) => {
131
+ const currentLocationsLatlng = currentLocations.latlng;
132
+ const canLoad = lat && lng && currentLocationsLatlng && TMap && map;
133
+ if (canLoad) {
134
+ const nowPosition = new TMap.LatLng(currentLocationsLatlng.lat, currentLocationsLatlng.lng);
135
+ let circle = {
136
+ map,
137
+ styles: {
138
+ circleColor: new TMap.CircleStyle({
139
+ showBorder: true,
140
+ borderColor: '#fff',
141
+ borderWidth: 1,
142
+ }),
143
+ },
144
+ geometries: [
145
+ {
146
+ styleId: 'circleColor',
147
+ center: nowPosition,
148
+ radius: getRadius(),
149
+ },
150
+ ],
151
+ };
152
+ new TMap.MultiCircle(circle);
153
+ }
154
+ };
155
+ const mapDrag = () => {
156
+ const TMap = getTMap();
157
+ const canLoad = TMap && lat && lng && mapRef.current;
158
+ if (canLoad) {
159
+ const currentLocationsLatlng = currentLocations.latlng;
160
+ let centerPosition = mapRef.current.getCenter();
161
+ centerRef.current = centerPosition;
162
+ markerRef.current.updateGeometries([
163
+ {
164
+ id: `pointer-${mapDomName}`,
165
+ styleId: 'pointer',
166
+ position: mapRef.current.getCenter(),
167
+ },
168
+ ]);
169
+ exploreNear('updateCenter');
170
+ // 计算距离
171
+ compareDistance(currentLocationsLatlng, {
172
+ lat: centerPosition.getLat(),
173
+ lng: centerPosition.getLng(),
174
+ });
175
+ }
176
+ };
177
+ const compareDistance = (currentLocation, centerPosition) => {
178
+ if (getRadius()) {
179
+ let latlng1 = {
180
+ latitude: currentLocation.lat,
181
+ longitude: currentLocation.lng,
182
+ };
183
+ let latlng2 = {
184
+ latitude: centerPosition.lat,
185
+ longitude: centerPosition.lng,
186
+ };
187
+ const distance = calculateDistance(latlng1, latlng2);
188
+ let isOutof = getRadius() && getRadius() < distance;
189
+ setIsOutofrange(isOutof);
190
+ if (!isPC) {
191
+ changeSearchBoxHeight(false, isOutof, true);
192
+ }
193
+ }
194
+ };
195
+ const handleFocus = (value) => {
196
+ changeSearchBoxHeight(true);
197
+ setIsSearch(value);
198
+ };
199
+ const exploreNear = debounce((type) => {
200
+ const { lat, lng } = centerRef.current || latlng;
201
+ let TMap = getTMap();
202
+ let search = new TMap.service.Search({ pageSize: 10 }); // 新建一个地点搜索类
203
+ if (type === 'updateCenter') {
204
+ searchListPageSize.current = 1;
205
+ }
206
+ setSearchLoadingStatus(true);
207
+ search
208
+ .explore({
209
+ center: new TMap.LatLng(lat, lng),
210
+ policy: 2,
211
+ radius: 1000,
212
+ pageIndex: searchListPageSize.current,
213
+ })
214
+ .then((res) => {
215
+ setSearchLoadingStatus(false);
216
+ if (res.status === 0) {
217
+ let list = [...exploreList, ...res.data];
218
+ if (searchListPageSize.current === 1) {
219
+ list = res.data;
220
+ setRealLocation({ lat, lng }, list);
221
+ }
222
+ else {
223
+ setExploreList(list);
224
+ }
225
+ }
226
+ else {
227
+ setRealLocation({ lat, lng }, []);
228
+ }
229
+ })
230
+ .catch((error) => {
231
+ setSearchLoadingStatus(false);
232
+ setRealLocation({ lat, lng }, []);
233
+ console.error('explore error', error);
234
+ });
235
+ }, 500);
236
+ // 逆解析查询当前经纬度地址
237
+ const setRealLocation = (location, list) => {
238
+ const { lat, lng } = location;
239
+ let TMap = getTMap();
240
+ const Geocoder = new TMap.service.Geocoder();
241
+ Geocoder.getAddress({
242
+ location: new TMap.LatLng(lat, lng),
243
+ })
244
+ .then(({ status, result }) => {
245
+ var _a;
246
+ if (status == 0) {
247
+ let address = result.address;
248
+ let title = (_a = result === null || result === void 0 ? void 0 : result.formatted_addresses) === null || _a === void 0 ? void 0 : _a.recommend;
249
+ let item = {
250
+ id: 'current-location',
251
+ location: {
252
+ lat,
253
+ lng,
254
+ },
255
+ title: title ? title : address,
256
+ address,
257
+ };
258
+ setChooseLoc(item);
259
+ changeLocation(item);
260
+ setExploreList([item, ...list]);
261
+ }
262
+ })
263
+ .catch((error) => {
264
+ console.error('getAddress error', error);
265
+ let item = {
266
+ id: 'current-location',
267
+ location: {
268
+ lat,
269
+ lng,
270
+ },
271
+ title: '[位置]',
272
+ address: '暂无地址信息',
273
+ };
274
+ setChooseLoc(item);
275
+ changeLocation(item);
276
+ setExploreList([item]);
277
+ });
278
+ };
279
+ const chooseLoction = (value, type) => {
280
+ const TMap = getTMap();
281
+ //定义地图中心点坐标
282
+ const center = new TMap.LatLng(value.location.lat, value.location.lng);
283
+ mapRef.current.setCenter(center);
284
+ markerRef.current.updateGeometries([
285
+ {
286
+ id: `pointer-${mapDomName}`,
287
+ styleId: 'pointer',
288
+ position: center,
289
+ },
290
+ ]);
291
+ setChooseLoc(value);
292
+ changeLocation(value);
293
+ if (type) {
294
+ setExploreList([]);
295
+ cancleSearch();
296
+ mapDrag();
297
+ }
298
+ else {
299
+ const currentLocationsLatlng = currentLocations.latlng;
300
+ compareDistance(currentLocationsLatlng, value.location);
301
+ }
302
+ };
303
+ const changeSearchValue = (event) => {
304
+ if (event.target.value) {
305
+ setSearchValue(event.target.value);
306
+ let TMap = getTMap();
307
+ let search = new TMap.service.Suggestion({ pageSize: 20 }); // 新建一个地点搜索类
308
+ search
309
+ .getSuggestions({
310
+ keyword: event.target.value,
311
+ location: new TMap.LatLng(lat, lng),
312
+ radius: 2000,
313
+ pageIndex: 1,
314
+ })
315
+ .then((res) => {
316
+ if (res.status === 0) {
317
+ setSearchList(res.data);
318
+ }
319
+ })
320
+ .catch((error) => {
321
+ console.error('error', error);
322
+ });
323
+ }
324
+ else {
325
+ setSearchValue('');
326
+ // 不知道
327
+ // eslint-disable-next-line rulesdir/no-timer
328
+ setTimeout(() => {
329
+ setSearchList([]);
330
+ }, 300);
331
+ }
332
+ };
333
+ const cancleSearch = () => {
334
+ handleFocus(false);
335
+ setSearchValue('');
336
+ setSearchList([]);
337
+ changeSearchBoxHeight(false);
338
+ };
339
+ const renderMapView = () => {
340
+ return (React.createElement("div", { id: `form-map-choose-${mapDomName}`, style: { height: '100%', width: '100%', position: 'relative' } },
341
+ React.createElement("div", { className: "weda-ui_mapChoose_map_control", onClick: backToOrigin, onTouchEnd: backToOrigin },
342
+ React.createElement("img", { src: "https://qcloudimg.tencent-cloud.cn/raw/16f372916b73decb45faa912e37f6e6f.svg", className: "weda-ui_mapChoose_map_control_img", alt: "" }))));
343
+ };
344
+ const handletouchmove = (event) => {
345
+ document.getElementsByClassName('map-choose-header_search_input')[0].blur();
346
+ let currentY = event.changedTouches[0].clientY;
347
+ let status = currentY <= touchCoordinate.current.startY;
348
+ changeSearchBoxHeight(status);
349
+ };
350
+ const handletouchstart = (event) => {
351
+ document.getElementsByClassName('map-choose-header_search_input')[0].blur();
352
+ touchCoordinate.current.startY = event.changedTouches[0].clientY;
353
+ };
354
+ const changeSearchBoxHeight = (status, currentOutofrange, isInDrag) => {
355
+ // 搜索区域默认 328px ,上拉 75% ,当超出范围多一个超出提示 46px
356
+ let isOut = isInDrag ? currentOutofrange : isOutofrange;
357
+ const boxHeight = Math.ceil(clientHeight * 0.75);
358
+ let searchBoxHeights = isOut ? 328 - 46 : 328;
359
+ if (status) {
360
+ searchBoxHeights = isOut ? boxHeight - 46 : boxHeight;
361
+ }
362
+ setSearchBoxHeight(searchBoxHeights);
363
+ setMapBoxHeight(status ? clientHeight - boxHeight : clientHeight - 328);
364
+ };
365
+ const searchListOnScroll = () => {
366
+ getOnScrollDirection();
367
+ if (searchListPageSize.current === 5 || isSearch) {
368
+ return;
369
+ }
370
+ let scrollTop = searchListRef.current.scrollTop;
371
+ let clientHeight = searchListRef.current.clientHeight;
372
+ let scrollHeight = searchListRef.current.scrollHeight;
373
+ if (scrollTop + clientHeight + 1 >= scrollHeight) {
374
+ searchListPageSize.current++;
375
+ exploreNear();
376
+ }
377
+ };
378
+ const getOnScrollDirection = () => {
379
+ if ((searchBoxHeight !== 328 && searchBoxHeight !== 282) || isPC) {
380
+ return;
381
+ }
382
+ if (searchListRef.current.scrollTop > relativePosition) {
383
+ changeSearchBoxHeight(true);
384
+ }
385
+ relativePosition = searchListRef.current.scrollTop;
386
+ };
387
+ const renderSearchList = () => {
388
+ return (React.createElement("div", { className: classNames({
389
+ 'weda-ui_mapChoose_search': true,
390
+ 'weda-ui_mapChoose_search_pc': isPC,
391
+ }), style: { height: `${searchBoxHeight}px` }, onTouchStart: handletouchstart, onTouchMove: handletouchmove },
392
+ searchBoxHeight !== 328 && searchBoxHeight !== 282 && !isPC && (React.createElement("div", { className: "weda-ui_mapChoose_search_input_arrow", onClick: () => {
393
+ changeSearchBoxHeight(false);
394
+ } },
395
+ React.createElement("span", { className: "weda-ui_mapChoose_search_input_arrow-con" }))),
396
+ React.createElement("div", { className: classNames({
397
+ 'map-choose-header': true,
398
+ 'map-choose-header_focus': isSearch,
399
+ }) },
400
+ React.createElement("div", { className: "map-choose-header_search" },
401
+ React.createElement("input", { type: "text", onFocus: () => {
402
+ handleFocus(true);
403
+ }, onClick: (e) => {
404
+ e.stopPropagation();
405
+ }, onChange: changeSearchValue, value: searchValue, className: "map-choose-header_search_input" }),
406
+ React.createElement("div", { className: classNames({
407
+ 'map-choose-header_search_place': true,
408
+ 'map-choose-header_search_place_value': searchValue,
409
+ }) },
410
+ React.createElement("img", { src: "https://qcloudimg.tencent-cloud.cn/raw/388c48cdcbe9ca07f5682fb10d05ebdd.png", alt: "" }),
411
+ React.createElement("span", null, "\u641C\u7D22\u5730\u70B9")),
412
+ searchValue && (React.createElement("div", { className: "weda-ui_mapChoose_search_input_clear", onClick: changeSearchValue },
413
+ React.createElement("p", { className: "weda-ui_mapChoose_search_input_clear_close" })))),
414
+ React.createElement("span", { className: "map-choose-header_search_cancel", onClick: cancleSearch }, "\u53D6\u6D88")),
415
+ searchLoadingStatus && !isSearch && (React.createElement("div", { className: "weda-ui_mapChoose_search_list_lodading" },
416
+ React.createElement("span", { className: "weda-ui_mapChoose_search_list_lodading_con" }))),
417
+ React.createElement("div", { className: classNames({
418
+ 'weda-ui_mapChoose_search_list': true,
419
+ 'weda-ui_mapChoose_search_list_top': searchBoxHeight !== 328 && searchBoxHeight !== 282 && !isPC,
420
+ }), onTouchStart: (e) => {
421
+ e.stopPropagation();
422
+ }, onTouchMove: (e) => {
423
+ e.stopPropagation();
424
+ }, ref: searchListRef, onScroll: searchListOnScroll }, (isSearch ? searchList : exploreList).map((item, index) => (React.createElement("div", { key: index, className: "weda-ui_mapChoose_search_list_li", onClick: () => {
425
+ chooseLoction(item, isSearch);
426
+ } },
427
+ React.createElement("div", { className: "weda-ui_mapChoose_search_list_li_wrap" },
428
+ React.createElement("div", { className: "weda-ui_mapChoose_search_list_li_title" }, item.title),
429
+ React.createElement("div", { className: "weda-ui_mapChoose_search_list_li_con" }, item.address),
430
+ item.id === chooseLoc.id && (React.createElement("span", { className: "weda-ui_mapChoose_search_list_li_con_choosed" })))))))));
431
+ };
432
+ const renderOutTip = () => {
433
+ return (React.createElement("div", { className: classNames({
434
+ 'weda-ui_mapChoose_outTip': true,
435
+ 'weda-ui_mapChoose_outTip_block': isOutofrange,
436
+ 'weda-ui_mapChoose_outTip_pc': isPC,
437
+ }) },
438
+ isOutofrange && (React.createElement(Icon, { type: "warning", size: "default", color: "#ED7B2F", style: { marginRight: '9px' } })),
439
+ isOutofrange && React.createElement("span", null, "\u5B9A\u4F4D\u8D85\u51FA\u5141\u8BB8\u8303\u56F4,\u8BF7\u8C03\u6574")));
440
+ };
441
+ const getRadius = () => {
442
+ let radius = 0;
443
+ if (locationRange > 0) {
444
+ radius = locationRange;
445
+ }
446
+ else if (locationRange < 0 && customRange > 0) {
447
+ radius = customRange;
448
+ }
449
+ return radius;
450
+ };
451
+ const backToOrigin = () => {
452
+ const TMap = getTMap();
453
+ const canLoad = TMap && lat && lng && mapRef.current;
454
+ if (canLoad) {
455
+ const currentLocationsLatlng = currentLocations.latlng;
456
+ const nowPosition = new TMap.LatLng(currentLocationsLatlng.lat, currentLocationsLatlng.lng);
457
+ markerRef.current.updateGeometries([
458
+ {
459
+ id: `pointer-${mapDomName}`,
460
+ styleId: 'pointer',
461
+ position: nowPosition,
462
+ },
463
+ ]);
464
+ mapRef.current.setCenter(nowPosition);
465
+ searchListPageSize.current = 1;
466
+ setChooseLoc({});
467
+ mapDrag();
468
+ }
469
+ };
470
+ const getConfirm = () => {
471
+ return isOutofrange || !chooseLoc.id;
472
+ };
473
+ if (isPC) {
474
+ return (React.createElement("div", { className: classNames('map-choose', 'map-choose-pc', 'weda-ui_map-choose') },
475
+ renderOutTip(),
476
+ React.createElement("div", { className: classNames({
477
+ 'map-choose-pc_warp': true,
478
+ 'map-choose-pc_warp_out': isOutofrange,
479
+ }) },
480
+ React.createElement("div", { className: "map-choose-pc-left" }, renderSearchList()),
481
+ React.createElement("div", { className: "map-choose-pc-right" }, renderMapView()))));
482
+ }
483
+ return (React.createElement("div", { className: "map-choose weda-ui_map-choose" },
484
+ renderOutTip(),
485
+ React.createElement("div", { className: "weda-ui_mapChoose_map", style: { height: `${mapBoxHeight}px` } },
486
+ React.createElement("div", { className: "weda-ui_mapChoose_msg" },
487
+ React.createElement("div", { className: classNames({
488
+ 'weda-ui_mapChoose_confirm': true,
489
+ 'weda-ui_mapChoose_confirm_disable': getConfirm(),
490
+ }), onClick: () => {
491
+ !getConfirm() && onConfirm();
492
+ } }, "\u786E\u5B9A"),
493
+ React.createElement("div", { className: "weda-ui_mapChoose_colse", onClick: onClose }, "\u53D6\u6D88")),
494
+ renderMapView()),
495
+ renderSearchList()));
496
+ }
@@ -0,0 +1,19 @@
1
+ declare function MapView({ APIKEY, drag, zoom, latlng, }: {
2
+ APIKEY?: string;
3
+ drag?: boolean;
4
+ zoom?: boolean;
5
+ latlng?: {
6
+ lat: any;
7
+ lng: any;
8
+ };
9
+ }): JSX.Element;
10
+ declare namespace MapView {
11
+ namespace propTypes {
12
+ const APIKEY: PropTypes.Requireable<string>;
13
+ const drag: PropTypes.Requireable<boolean>;
14
+ const zoom: PropTypes.Requireable<boolean>;
15
+ const latlng: PropTypes.Requireable<object>;
16
+ }
17
+ }
18
+ export default MapView;
19
+ import * as PropTypes from "prop-types";
@@ -0,0 +1,175 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-nocheck
3
+ import * as React from 'react';
4
+ import * as PropTypes from 'prop-types';
5
+ import { tmapApiUrl } from '../constants';
6
+ import { getTMap } from '../common/tmap';
7
+ const { useEffect, useRef, useState } = React;
8
+ const defaultLatLng = {
9
+ lat: null,
10
+ lng: null,
11
+ };
12
+ export default function MapView({ APIKEY = '', drag = true, zoom = true, latlng = defaultLatLng, }) {
13
+ const mapRef = useRef();
14
+ const markerRef = useRef();
15
+ const mapDom = useRef();
16
+ const mapDomName = useRef(new Date().getTime());
17
+ const [mapStatus, setMapStatus] = useState(false);
18
+ const { lat, lng } = latlng;
19
+ const initMap = () => {
20
+ if (mapRef.current || !mapDom.current)
21
+ return;
22
+ try {
23
+ const TMap = getTMap();
24
+ //定义地图中心点坐标
25
+ const center = new TMap.LatLng(lat, lng);
26
+ //定义map变量,调用 TMap.Map() 构造函数创建地图
27
+ mapRef.current = new TMap.Map(mapDom.current, {
28
+ center,
29
+ zoom: 16,
30
+ minZoom: 3,
31
+ maxZoom: 20,
32
+ });
33
+ mapRef.current.setDraggable(drag);
34
+ removeOrAddZoom(mapRef.current, TMap);
35
+ initMarker();
36
+ setMapStatus(true);
37
+ }
38
+ catch (error) {
39
+ console.error('initMap error', error);
40
+ }
41
+ };
42
+ const initMarker = () => {
43
+ try {
44
+ const TMap = getTMap();
45
+ const canLoad = TMap && lat && lng && mapRef.current;
46
+ if (canLoad) {
47
+ const position = new TMap.LatLng(lat, lng);
48
+ markerRef.current = new TMap.MultiMarker({
49
+ map: mapRef.current,
50
+ styles: {
51
+ pointer: new TMap.MarkerStyle({
52
+ width: 26,
53
+ height: 35,
54
+ }),
55
+ },
56
+ geometries: [
57
+ {
58
+ id: `pointer-${mapDomName.current}`,
59
+ styleId: 'pointer',
60
+ position,
61
+ },
62
+ ],
63
+ });
64
+ }
65
+ }
66
+ catch (err) {
67
+ console.error('initMarker err', err);
68
+ }
69
+ };
70
+ useEffect(() => {
71
+ if (!APIKEY || new RegExp('[\\u4E00-\\u9FFF]+', 'g').test(APIKEY))
72
+ return;
73
+ function loadScript() {
74
+ // 移除之前的
75
+ if (document.getElementById('tmap-script')) {
76
+ document.body.removeChild(document.getElementById('tmap-script'));
77
+ }
78
+ const script = document.createElement('script');
79
+ script.type = 'text/javascript';
80
+ script.src = `${tmapApiUrl}?v=2.exp&key=${APIKEY}&callback=init&libraries=service`;
81
+ script.setAttribute('id', 'tmap-script');
82
+ script.onload = () => {
83
+ initMap();
84
+ };
85
+ script.onerror = (err) => {
86
+ console.error('loadScript err', err);
87
+ };
88
+ document.body.appendChild(script);
89
+ }
90
+ // 不知道
91
+ // eslint-disable-next-line rulesdir/no-timer
92
+ setTimeout(() => {
93
+ loadScript();
94
+ }, 1000);
95
+ return () => {
96
+ mapRef.current && mapRef.current.destroy();
97
+ mapRef.current = null;
98
+ setMapStatus(false);
99
+ };
100
+ // eslint-disable-next-line react-hooks/exhaustive-deps
101
+ }, [APIKEY]);
102
+ useEffect(() => {
103
+ mapRef.current && mapRef.current.setDraggable(drag);
104
+ // eslint-disable-next-line react-hooks/exhaustive-deps
105
+ }, [drag, mapRef.current]);
106
+ useEffect(() => {
107
+ mapRef.current && getTMap() && removeOrAddZoom(mapRef.current, getTMap());
108
+ // eslint-disable-next-line react-hooks/exhaustive-deps
109
+ }, [zoom, mapRef.current]);
110
+ useEffect(() => {
111
+ const TMap = getTMap();
112
+ const canLoad = TMap && lat && lng && mapRef.current && mapStatus;
113
+ if (canLoad) {
114
+ try {
115
+ const newLatLng = new TMap.LatLng(lat, lng);
116
+ mapRef.current.setCenter(newLatLng);
117
+ mapRef.current.panTo(newLatLng);
118
+ markerRef.current.updateGeometries([
119
+ {
120
+ styleId: 'pointer',
121
+ id: `pointer-${mapDomName.current}`,
122
+ position: newLatLng,
123
+ },
124
+ ]);
125
+ }
126
+ catch (error) {
127
+ console.error('updateGeometries error view', error);
128
+ }
129
+ }
130
+ }, [lat, lng, mapStatus]);
131
+ // 缩放事件
132
+ const removeOrAddZoom = (map, TMap) => {
133
+ try {
134
+ let level = map.getZoom();
135
+ map.setScrollable(zoom);
136
+ map.setDoubleClickZoom(zoom);
137
+ // 缩放控件
138
+ if (zoom) {
139
+ addControl(map, TMap);
140
+ map.setMaxZoom(20);
141
+ map.setMinZoom(3);
142
+ }
143
+ else {
144
+ removeControl(map, TMap);
145
+ map.setMaxZoom(level);
146
+ map.setMinZoom(level);
147
+ }
148
+ }
149
+ catch (error) {
150
+ console.error('removeOrAddZoom error', error);
151
+ }
152
+ };
153
+ // 移除缩放控件
154
+ const removeControl = (map, TMap) => {
155
+ if (!map.getControl(TMap.constants.DEFAULT_CONTROL_ID.ZOOM)) {
156
+ return;
157
+ }
158
+ map.removeControl(TMap.constants.DEFAULT_CONTROL_ID.ZOOM);
159
+ };
160
+ // 缩放控件添加到地图上
161
+ const addControl = (map, TMap) => {
162
+ let control = map.getControl(TMap.constants.DEFAULT_CONTROL_ID.ZOOM);
163
+ if (!control) {
164
+ map.addControl(control);
165
+ control.setPosition(TMap.constants.CONTROL_POSITION.BOTTOM_RIGHT);
166
+ }
167
+ };
168
+ return (React.createElement("div", { ref: mapDom, id: `form-location-map-${mapDomName.current}`, style: { height: '100%', width: '100%' } }));
169
+ }
170
+ MapView.propTypes = {
171
+ APIKEY: PropTypes.string,
172
+ drag: PropTypes.bool,
173
+ zoom: PropTypes.bool,
174
+ latlng: PropTypes.object,
175
+ };