@nutui/nutui-react-taro 1.2.2-beta.0 → 1.3.1-beta.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 (363) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/esm/ActionSheet.js +5 -4
  3. package/dist/esm/Address.js +7 -6
  4. package/dist/esm/AnimatingNumbers.js +3 -2
  5. package/dist/esm/Audio/style/index.js +4 -0
  6. package/dist/esm/Audio.js +18 -0
  7. package/dist/esm/Avatar.js +3 -3
  8. package/dist/esm/AvatarGroup.js +4 -4
  9. package/dist/esm/BackTop.js +3 -3
  10. package/dist/esm/Badge.js +3 -3
  11. package/dist/esm/Barrage.js +3 -2
  12. package/dist/esm/Button.js +3 -3
  13. package/dist/esm/Calendar/style/index.js +1 -2
  14. package/dist/esm/Calendar.js +9 -7
  15. package/dist/esm/CalendarItem.js +5 -5
  16. package/dist/esm/Card.js +3 -3
  17. package/dist/esm/Cascader/style/index.js +2 -0
  18. package/dist/esm/Cascader.js +14 -0
  19. package/dist/esm/Cell.js +3 -3
  20. package/dist/esm/Checkbox.js +3 -3
  21. package/dist/esm/CheckboxGroup.js +2 -2
  22. package/dist/esm/Col.js +2 -2
  23. package/dist/esm/Collapse.js +2 -2
  24. package/dist/esm/CollapseItem.js +3 -3
  25. package/dist/esm/ConfigProvider.js +3 -3
  26. package/dist/esm/CountDown.js +4 -4
  27. package/dist/esm/DatePicker.js +9 -8
  28. package/dist/esm/Dialog.js +6 -6
  29. package/dist/esm/Divider.js +2 -2
  30. package/dist/esm/Drag.js +2 -2
  31. package/dist/esm/Elevator.js +3 -2
  32. package/dist/esm/Empty.js +4 -4
  33. package/dist/esm/FixedNav.js +5 -5
  34. package/dist/esm/Grid/style/index.js +2 -0
  35. package/dist/esm/Grid.js +7 -0
  36. package/dist/esm/GridItem/style/index.js +2 -0
  37. package/dist/esm/GridItem.js +8 -0
  38. package/dist/esm/Icon/style/index.js +1 -0
  39. package/dist/esm/Icon.js +2 -2
  40. package/dist/esm/ImagePreview/style/index.js +2 -0
  41. package/dist/esm/ImagePreview.js +15 -0
  42. package/dist/esm/Infiniteloading.js +5 -5
  43. package/dist/esm/Input.js +5 -5
  44. package/dist/esm/InputNumber.js +3 -3
  45. package/dist/esm/Menu/style/index.js +3 -0
  46. package/dist/esm/Menu.js +7 -0
  47. package/dist/esm/MenuItem/style/index.js +3 -0
  48. package/dist/esm/MenuItem.js +11 -0
  49. package/dist/esm/NavBar.js +4 -3
  50. package/dist/esm/NoticeBar.js +4 -3
  51. package/dist/esm/{Notification-b09c89e8.js → Notification-422905bd.js} +20 -12
  52. package/dist/esm/Notify.js +3 -2
  53. package/dist/esm/NumberKeyboard.js +7 -6
  54. package/dist/esm/Pagination.js +4 -4
  55. package/dist/esm/Picker.js +9 -8
  56. package/dist/esm/Popover.js +6 -4
  57. package/dist/esm/Popup.js +4 -3
  58. package/dist/esm/Progress.js +3 -3
  59. package/dist/esm/Radio.js +4 -4
  60. package/dist/esm/RadioGroup.js +2 -3
  61. package/dist/esm/Range.js +11 -9
  62. package/dist/esm/Rate.js +3 -3
  63. package/dist/esm/Row.js +2 -2
  64. package/dist/esm/SearchBar.js +5 -5
  65. package/dist/esm/ShortPassword.js +7 -6
  66. package/dist/esm/SideNavBar/style/index.js +2 -0
  67. package/dist/esm/SideNavBar.js +14 -0
  68. package/dist/esm/SideNavBarItem/style/index.js +2 -0
  69. package/dist/esm/SideNavBarItem.js +3 -0
  70. package/dist/esm/Signature.js +6 -6
  71. package/dist/esm/Skeleton.js +3 -3
  72. package/dist/esm/Step.js +3 -3
  73. package/dist/esm/SubSideNavBar/style/index.js +2 -0
  74. package/dist/esm/SubSideNavBar.js +4 -0
  75. package/dist/esm/Swipe/style/index.js +2 -0
  76. package/dist/esm/Swipe.js +7 -0
  77. package/dist/esm/Swiper.js +3 -2
  78. package/dist/esm/SwiperItem.js +2 -2
  79. package/dist/esm/TabPane.js +2 -2
  80. package/dist/esm/TabbarItem.js +3 -3
  81. package/dist/esm/Table/style/index.js +2 -0
  82. package/dist/esm/Table.js +9 -0
  83. package/dist/esm/Tabs.js +3 -3
  84. package/dist/esm/Tag.js +3 -3
  85. package/dist/esm/TextArea.js +4 -4
  86. package/dist/esm/TimeDetail.js +4 -4
  87. package/dist/esm/TimePannel.js +4 -4
  88. package/dist/esm/TimeSelect.js +7 -6
  89. package/dist/esm/Toast.js +5 -4
  90. package/dist/esm/Uploader.js +5 -5
  91. package/dist/esm/VirtualList.js +4 -4
  92. package/dist/esm/{actionsheet.taro-4ae40ea0.js → actionsheet.taro-f4d407b0.js} +1 -1
  93. package/dist/esm/{address.taro-82a8fa11.js → address.taro-4765a826.js} +95 -36
  94. package/dist/esm/{animatingnumbers.taro-cda438cc.js → animatingnumbers.taro-877baa98.js} +20 -15
  95. package/dist/esm/audio.taro-cd6cc93b.js +292 -0
  96. package/dist/esm/{avatar.taro-5dafffdc.js → avatar.taro-0a0472fd.js} +1 -2
  97. package/dist/esm/{avatargroup.taro-a39282b3.js → avatargroup-1ca79066.js} +1 -1
  98. package/dist/esm/{backtop.taro-65dccd86.js → backtop.taro-0e2e3946.js} +8 -6
  99. package/dist/esm/{badge.taro-8c001377.js → badge.taro-eeac9de8.js} +5 -5
  100. package/dist/esm/{barrage.taro-f1139b9c.js → barrage.taro-efac8422.js} +42 -19
  101. package/dist/esm/{button.taro-90c8bb93.js → button-521a516b.js} +1 -1
  102. package/dist/esm/{button-9b1f3219.js → button.taro-d5968f9d.js} +1 -1
  103. package/dist/esm/calendar.taro-1abb1925.js +89 -0
  104. package/dist/esm/{calendaritem.taro-bbe4a226.js → calendaritem.taro-3c06a809.js} +151 -74
  105. package/dist/esm/{card.taro-c4f88500.js → card.taro-0861c7b3.js} +2 -2
  106. package/dist/esm/cascader.taro-31dbc60e.js +786 -0
  107. package/dist/esm/{cell.taro-8080af48.js → cell.taro-3bb1b0f2.js} +1 -1
  108. package/dist/esm/{checkbox.taro-7267be92.js → checkbox.taro-6fbc4b3c.js} +55 -10
  109. package/dist/esm/{checkboxgroup.taro-bc16131f.js → checkboxgroup.taro-3d380042.js} +26 -4
  110. package/dist/esm/{col.taro-ff3af36f.js → col.taro-2a437387.js} +6 -2
  111. package/dist/esm/{collapse.taro-5fac953d.js → collapse.taro-72e58ba2.js} +1 -0
  112. package/dist/esm/{collapseitem.taro-179cf530.js → collapseitem-5556ec54.js} +14 -13
  113. package/dist/esm/{configprovider-18657611.js → configprovider-9c393a29.js} +1 -1
  114. package/dist/esm/{configprovider.taro-98343012.js → configprovider.taro-1ff7f150.js} +2 -2
  115. package/dist/esm/{countdown.taro-cd6a1bd4.js → countdown.taro-b00d0d46.js} +1 -1
  116. package/dist/esm/{datepicker.taro-f7c8ef80.js → datepicker.taro-e385849d.js} +8 -6
  117. package/dist/esm/{dialog.taro-57f6fc2e.js → dialog.taro-c80b7b5f.js} +13 -19
  118. package/dist/esm/{divider.taro-beaec14a.js → divider.taro-5236fe6a.js} +6 -3
  119. package/dist/esm/{drag.taro-7c0493f8.js → drag.taro-56e8c87a.js} +1 -1
  120. package/dist/esm/{elevator.taro-e37a3fbb.js → elevator.taro-15b0d8c2.js} +139 -39
  121. package/dist/esm/{empty.taro-c7ccac8a.js → empty.taro-20b8adac.js} +3 -3
  122. package/dist/esm/{fixednav.taro-5b473df6.js → fixednav.taro-75e35339.js} +4 -4
  123. package/dist/esm/grid.taro-7fb43d02.js +90 -0
  124. package/dist/esm/griditem.taro-8020b409.js +98 -0
  125. package/dist/esm/{icon-62bd7379.js → icon-8dc4de10.js} +9 -9
  126. package/dist/esm/{icon.taro-bf130544.js → icon.taro-1d0d4fb7.js} +11 -9
  127. package/dist/esm/imagepreview.taro-a0ddd8a2.js +813 -0
  128. package/dist/esm/{infiniteloading.taro-abf15a17.js → infiniteloading.taro-0a86819e.js} +2 -2
  129. package/dist/esm/input.taro-1d23861d.js +392 -0
  130. package/dist/esm/{inputnumber.taro-4ec2bfb6.js → inputnumber.taro-75662231.js} +17 -18
  131. package/dist/esm/menu.taro-03e3b011.js +153 -0
  132. package/dist/esm/menuitem.taro-56bf3205.js +195 -0
  133. package/dist/esm/navbar.taro-f2eae6a6.js +123 -0
  134. package/dist/esm/{noticebar.taro-70193e5e.js → noticebar.taro-1890c693.js} +77 -43
  135. package/dist/esm/{notify.taro-837a878b.js → notify.taro-22b8f4cd.js} +21 -5
  136. package/dist/esm/{numberkeyboard.taro-a80cec74.js → numberkeyboard.taro-5d685c76.js} +2 -2
  137. package/dist/esm/nutui-react.es.js +87 -74
  138. package/dist/esm/offsetContext-0e3d04b3.js +19 -0
  139. package/dist/esm/{pagination.taro-abc4a71e.js → pagination.taro-10449c4a.js} +1 -1
  140. package/dist/esm/{picker.taro-c05b1930.js → picker.taro-216cc3cb.js} +8 -6
  141. package/dist/esm/{pickerSlot-c8f5343e.js → pickerSlot-f8e4e542.js} +9 -6
  142. package/dist/esm/{popover.taro-3b06163e.js → popover.taro-9b3da0fa.js} +90 -107
  143. package/dist/esm/{popup-15922d84.js → popup-67173ec6.js} +55 -31
  144. package/dist/esm/{popup.taro-897e35fd.js → popup.taro-a89dd3a1.js} +55 -31
  145. package/dist/esm/{progress.taro-51bcdd4f.js → progress.taro-dd93ac38.js} +1 -1
  146. package/dist/esm/radio.taro-32cb0172.js +129 -0
  147. package/dist/esm/{radiogroup.taro-f2401b7a.js → radiogroup-e698d3df.js} +5 -2
  148. package/dist/esm/{range.taro-41ced357.js → range.taro-fe08c5f4.js} +262 -86
  149. package/dist/esm/{rate.taro-3d6edec3.js → rate.taro-a0b21714.js} +6 -2
  150. package/dist/esm/render-4a3856cb.js +32 -0
  151. package/dist/esm/{row.taro-7afb510a.js → row.taro-cec13a7e.js} +9 -3
  152. package/dist/esm/{searchbar.taro-b05ef5a8.js → searchbar.taro-450d2f88.js} +2 -2
  153. package/dist/esm/{shortpassword.taro-aad27ce9.js → shortpassword.taro-08a05360.js} +25 -20
  154. package/dist/esm/sidenavbar.taro-dd471476.js +65 -0
  155. package/dist/esm/sidenavbaritem.taro-77e077f4.js +32 -0
  156. package/dist/esm/{signature.taro-454c5413.js → signature.taro-7cb77bab.js} +2 -2
  157. package/dist/esm/{skeleton.taro-b2831f6f.js → skeleton.taro-5934c7d7.js} +6 -7
  158. package/dist/esm/{step.taro-33775bf4.js → step-9a048771.js} +1 -1
  159. package/dist/esm/subsidenavbar.taro-2c1fcf16.js +94 -0
  160. package/dist/esm/swipe.taro-dfb9a049.js +264 -0
  161. package/dist/esm/{swiper.taro-624d2cf2.js → swiper.taro-7a2ef124.js} +39 -14
  162. package/dist/esm/{swiperitem.taro-984e3ebb.js → swiperitem-d00e7513.js} +1 -15
  163. package/dist/esm/{tabbaritem.taro-898becb1.js → tabbaritem.taro-a88d3ae7.js} +1 -1
  164. package/dist/esm/table.taro-305e0317.js +153 -0
  165. package/dist/esm/{tabpane.taro-24514060.js → tabpane.taro-95aa185b.js} +3 -2
  166. package/dist/esm/{tabs.taro-56a953f6.js → tabs.taro-d1e85ea5.js} +15 -5
  167. package/dist/esm/{tag.taro-77cf134f.js → tag.taro-3bbbb557.js} +2 -2
  168. package/dist/esm/{textarea.taro-5d4efaf0.js → textarea.taro-700b04c2.js} +6 -3
  169. package/dist/esm/{timedetail.taro-0e31b4a5.js → timedetail.taro-7cc00243.js} +1 -1
  170. package/dist/esm/{timepannel.taro-2d54b3db.js → timepannel.taro-e24537e4.js} +1 -1
  171. package/dist/esm/{timeselect.taro-e4c97354.js → timeselect.taro-210fd548.js} +2 -2
  172. package/dist/esm/{toast.taro-b7ff92f1.js → toast.taro-bb181833.js} +1 -1
  173. package/dist/esm/{uploader.taro-5fab7e14.js → uploader.taro-f7528535.js} +4 -4
  174. package/dist/esm/useClientRect-8b7cc406.js +74 -0
  175. package/dist/esm/{index-31152350.js → useTouch-a2ea68c6.js} +26 -12
  176. package/dist/esm/{virtuallist.taro-2ff1a5ad.js → virtuallist.taro-ce9619f9.js} +1 -1
  177. package/dist/esm/{zh-CN-f5124686.js → zh-CN-91090ae2.js} +16 -0
  178. package/dist/locales/base.d.ts +16 -0
  179. package/dist/locales/base.js +1 -1
  180. package/dist/locales/en-US.js +17 -1
  181. package/dist/locales/id-ID.js +17 -1
  182. package/dist/locales/zh-CN.js +17 -1
  183. package/dist/locales/zh-TW.js +17 -1
  184. package/dist/nutui.react.es.js +6306 -3636
  185. package/dist/nutui.react.umd.js +20243 -33
  186. package/dist/packages/address/address.scss +9 -2
  187. package/dist/packages/audio/audio.scss +80 -0
  188. package/dist/packages/calendar/calendar.scss +57 -36
  189. package/dist/packages/calendaritem/calendaritem.scss +0 -191
  190. package/dist/packages/cascader/cascader.scss +69 -0
  191. package/dist/packages/col/col.scss +6 -6
  192. package/dist/packages/grid/grid.scss +10 -0
  193. package/dist/packages/griditem/griditem.scss +103 -0
  194. package/dist/packages/icon/icon.scss +104 -12
  195. package/dist/packages/imagepreview/imagepreview.scss +51 -0
  196. package/dist/packages/menu/menu.scss +72 -0
  197. package/dist/packages/menuitem/menuitem.scss +90 -0
  198. package/dist/packages/noticebar/noticebar.scss +31 -15
  199. package/dist/packages/notify/notify.scss +9 -0
  200. package/dist/packages/popover/popover.scss +205 -83
  201. package/dist/packages/popup/popup.scss +1 -1
  202. package/dist/packages/range/range.scss +141 -13
  203. package/dist/packages/searchbar/searchbar.scss +1 -0
  204. package/dist/packages/shortpassword/shortpassword.scss +6 -1
  205. package/dist/packages/sidenavbar/sidenavbar.scss +69 -0
  206. package/dist/packages/sidenavbaritem/sidenavbaritem.scss +8 -0
  207. package/dist/packages/subsidenavbar/subsidenavbar.scss +23 -0
  208. package/dist/packages/swipe/swipe.scss +33 -0
  209. package/dist/packages/swiper/swiper.scss +3 -0
  210. package/dist/packages/table/table.scss +81 -0
  211. package/dist/packages/textarea/textarea.scss +16 -1
  212. package/dist/packages/toast/toast.scss +16 -13
  213. package/dist/style.css +1 -1
  214. package/dist/style.es.js +1 -1
  215. package/dist/styles/animation/icon.scss +245 -0
  216. package/dist/styles/animation/index.scss +1 -0
  217. package/dist/styles/font/config.json +169 -0
  218. package/dist/styles/font/demo_index.html +210 -3
  219. package/dist/styles/font/iconfont.css +39 -3
  220. package/dist/styles/font/iconfont.js +42 -40
  221. package/dist/styles/font/iconfont.json +63 -0
  222. package/dist/styles/font/iconfont.ttf +0 -0
  223. package/dist/styles/font/iconfont.woff +0 -0
  224. package/dist/styles/font/iconfont.woff2 +0 -0
  225. package/dist/styles/themes/default.scss +12 -0
  226. package/dist/styles/variables.scss +101 -21
  227. package/dist/types/address/address.taro.d.ts +4 -27
  228. package/dist/types/animatingnumbers/animatingnumbers.taro.d.ts +1 -1
  229. package/dist/types/animatingnumbers/countup.taro.d.ts +11 -0
  230. package/dist/types/audio/audio.taro.d.ts +18 -0
  231. package/dist/types/audio/index.taro.d.ts +2 -0
  232. package/dist/types/avatargroup/index.taro.d.ts +1 -1
  233. package/dist/types/backtop/backtop.taro.d.ts +4 -4
  234. package/dist/types/badge/badge.taro.d.ts +2 -1
  235. package/dist/types/card/card.taro.d.ts +4 -4
  236. package/dist/types/cascader/cascader.taro.d.ts +25 -0
  237. package/dist/types/cascader/cascaderItem.taro.d.ts +25 -0
  238. package/dist/types/cascader/index.taro.d.ts +2 -0
  239. package/dist/types/cellgroup/cellgroup.taro.d.ts +1 -0
  240. package/dist/types/checkbox/checkbox.taro.d.ts +6 -2
  241. package/dist/types/checkboxgroup/checkboxgroup.taro.d.ts +3 -2
  242. package/dist/types/col/col.taro.d.ts +4 -1
  243. package/dist/types/collapse/collapse.taro.d.ts +2 -1
  244. package/dist/types/collapseitem/index.taro.d.ts +1 -1
  245. package/dist/types/dialog/dialog.taro.d.ts +2 -1
  246. package/dist/types/elevator/elevator.taro.d.ts +6 -1
  247. package/dist/types/fixednav/fixednav.taro.d.ts +5 -5
  248. package/dist/types/grid/grid.taro.d.ts +16 -0
  249. package/dist/types/grid/index.taro.d.ts +2 -0
  250. package/dist/types/griditem/griditem.taro.d.ts +20 -0
  251. package/dist/types/griditem/index.taro.d.ts +2 -0
  252. package/dist/types/icon/icon.taro.d.ts +11 -5
  253. package/dist/types/imagepreview/imagepreview.taro.d.ts +26 -0
  254. package/dist/types/imagepreview/index.taro.d.ts +2 -0
  255. package/dist/types/input/input.taro.d.ts +42 -5
  256. package/dist/types/menu/index.taro.d.ts +2 -0
  257. package/dist/types/menu/menu.taro.d.ts +12 -0
  258. package/dist/types/menuitem/index.taro.d.ts +2 -0
  259. package/dist/types/menuitem/menuitem.taro.d.ts +23 -0
  260. package/dist/types/navbar/navbar.taro.d.ts +10 -4
  261. package/dist/types/noticebar/noticebar.taro.d.ts +1 -1
  262. package/dist/types/notify/notify.taro.d.ts +13 -0
  263. package/dist/types/nutui.react.d.ts +99 -1
  264. package/dist/types/picker/picker.taro.d.ts +3 -2
  265. package/dist/types/popover/popover.taro.d.ts +15 -7
  266. package/dist/types/popup/popup.taro.d.ts +3 -1
  267. package/dist/types/radiogroup/index.taro.d.ts +1 -1
  268. package/dist/types/range/range.taro.d.ts +3 -1
  269. package/dist/types/row/row.taro.d.ts +4 -1
  270. package/dist/types/shortpassword/shortpassword.taro.d.ts +3 -3
  271. package/dist/types/sidenavbar/index.taro.d.ts +2 -0
  272. package/dist/types/sidenavbar/sidenavbar.taro.d.ts +15 -0
  273. package/dist/types/sidenavbaritem/index.taro.d.ts +2 -0
  274. package/dist/types/sidenavbaritem/sidenavbaritem.taro.d.ts +11 -0
  275. package/dist/types/skeleton/skeleton.taro.d.ts +1 -0
  276. package/dist/types/step/index.taro.d.ts +1 -1
  277. package/dist/types/subsidenavbar/index.taro.d.ts +2 -0
  278. package/dist/types/subsidenavbar/subsidenavbar.taro.d.ts +13 -0
  279. package/dist/types/swipe/index.taro.d.ts +2 -0
  280. package/dist/types/swipe/swipe.taro.d.ts +41 -0
  281. package/dist/types/swiper/swiper.taro.d.ts +1 -0
  282. package/dist/types/swiperitem/index.taro.d.ts +1 -1
  283. package/dist/types/tabbar/tabbar.taro.d.ts +1 -0
  284. package/dist/types/table/index.taro.d.ts +2 -0
  285. package/dist/types/table/table.taro.d.ts +4 -0
  286. package/dist/types/tabpane/tabpane.taro.d.ts +3 -1
  287. package/dist/types/tabs/tabs.taro.d.ts +2 -0
  288. package/dist/types/tag/tag.taro.d.ts +2 -1
  289. package/dist/types/toast/toast.taro.d.ts +18 -0
  290. package/dist/types/virtuallist/virtuallist.taro.d.ts +2 -1
  291. package/package.json +18 -11
  292. package/dist/esm/calendar.taro-d3a90861.js +0 -617
  293. package/dist/esm/context-aa058329.js +0 -6
  294. package/dist/esm/input.taro-b6927020.js +0 -190
  295. package/dist/esm/navbar.taro-f2ba2cf4.js +0 -66
  296. package/dist/esm/radio.taro-923d91bc.js +0 -200
  297. package/dist/esm/raf-3fbb5f92.js +0 -126
  298. package/dist/packages/range/custom.scss +0 -9
  299. package/dist/types/actionsheet/demo.taro.d.ts +0 -6
  300. package/dist/types/address/demo.taro.d.ts +0 -3
  301. package/dist/types/animatingnumbers/demo.taro.d.ts +0 -3
  302. package/dist/types/avatar/demo.taro.d.ts +0 -4
  303. package/dist/types/avatargroup/avatargroup.taro.d.ts +0 -14
  304. package/dist/types/backtop/demo.taro.d.ts +0 -3
  305. package/dist/types/badge/demo.taro.d.ts +0 -3
  306. package/dist/types/barrage/demo.taro.d.ts +0 -4
  307. package/dist/types/button/demo.taro.d.ts +0 -3
  308. package/dist/types/calendar/demo.taro.d.ts +0 -3
  309. package/dist/types/card/demo.taro.d.ts +0 -3
  310. package/dist/types/cell/demo.taro.d.ts +0 -3
  311. package/dist/types/checkbox/demo.taro.d.ts +0 -3
  312. package/dist/types/circleprogress/demo.taro.d.ts +0 -4
  313. package/dist/types/collapse/demo.taro.d.ts +0 -3
  314. package/dist/types/collapseitem/collapseitem.taro.d.ts +0 -18
  315. package/dist/types/configprovider/demo.taro.d.ts +0 -3
  316. package/dist/types/countdown/demo.taro.d.ts +0 -3
  317. package/dist/types/datepicker/demo.taro.d.ts +0 -3
  318. package/dist/types/dialog/demo.taro.d.ts +0 -3
  319. package/dist/types/divider/demo.taro.d.ts +0 -3
  320. package/dist/types/drag/demo.taro.d.ts +0 -3
  321. package/dist/types/elevator/demo.taro.d.ts +0 -3
  322. package/dist/types/empty/demo.taro.d.ts +0 -4
  323. package/dist/types/fixednav/demo.taro.d.ts +0 -3
  324. package/dist/types/icon/demo.taro.d.ts +0 -3
  325. package/dist/types/indicator/demo.taro.d.ts +0 -4
  326. package/dist/types/infiniteloading/demo.taro.d.ts +0 -4
  327. package/dist/types/input/demo.taro.d.ts +0 -3
  328. package/dist/types/inputnumber/demo.taro.d.ts +0 -3
  329. package/dist/types/layout/demo.taro.d.ts +0 -4
  330. package/dist/types/navbar/demo.taro.d.ts +0 -3
  331. package/dist/types/noticebar/demo.taro.d.ts +0 -3
  332. package/dist/types/notify/demo.taro.d.ts +0 -3
  333. package/dist/types/numberkeyboard/demo.taro.d.ts +0 -3
  334. package/dist/types/overlay/demo.taro.d.ts +0 -4
  335. package/dist/types/pagination/demo.taro.d.ts +0 -3
  336. package/dist/types/picker/demo.taro.d.ts +0 -3
  337. package/dist/types/popover/demo.taro.d.ts +0 -3
  338. package/dist/types/popup/demo.taro.d.ts +0 -4
  339. package/dist/types/price/demo.taro.d.ts +0 -3
  340. package/dist/types/progress/demo.taro.d.ts +0 -3
  341. package/dist/types/radio/demo.taro.d.ts +0 -3
  342. package/dist/types/radiogroup/radiogroup.taro.d.ts +0 -11
  343. package/dist/types/range/demo.taro.d.ts +0 -3
  344. package/dist/types/rate/demo.taro.d.ts +0 -3
  345. package/dist/types/searchbar/demo.taro.d.ts +0 -3
  346. package/dist/types/shortpassword/demo.taro.d.ts +0 -3
  347. package/dist/types/signature/demo.taro.d.ts +0 -3
  348. package/dist/types/skeleton/demo.taro.d.ts +0 -4
  349. package/dist/types/step/step.taro.d.ts +0 -13
  350. package/dist/types/steps/demo.taro.d.ts +0 -4
  351. package/dist/types/swiper/demo.taro.d.ts +0 -4
  352. package/dist/types/swiperitem/swiperitem.taro.d.ts +0 -7
  353. package/dist/types/switch/demo.taro.d.ts +0 -3
  354. package/dist/types/tabbar/demo.taro.d.ts +0 -3
  355. package/dist/types/tabs/demo.taro.d.ts +0 -3
  356. package/dist/types/tag/demo.taro.d.ts +0 -3
  357. package/dist/types/textarea/demo.taro.d.ts +0 -3
  358. package/dist/types/timedetail/demo.taro.d.ts +0 -3
  359. package/dist/types/timepannel/demo.taro.d.ts +0 -3
  360. package/dist/types/timeselect/demo.taro.d.ts +0 -3
  361. package/dist/types/toast/demo.taro.d.ts +0 -3
  362. package/dist/types/uploader/demo.taro.d.ts +0 -16
  363. package/dist/types/virtuallist/demo.taro.d.ts +0 -3
@@ -0,0 +1,813 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import _typeof from "@babel/runtime/helpers/typeof";
5
+ var _excluded = ["children", "direction", "className", "pageContent", "onChange", "initPage", "paginationColor", "paginationVisible", "touchable", "isPreventDefault", "isStopPropagation", "autoPlay", "isCenter"];
6
+
7
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
+
9
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
+
11
+ import React__default, { useRef, useState, useMemo, useEffect } from 'react';
12
+ import { P as Popup } from './popup-67173ec6.js';
13
+ import { V as Video } from './video-c1090c92.js';
14
+ import classNames from 'classnames';
15
+ import { D as DataContext } from './UserContext-b4181162.js';
16
+ import { c as cn } from './bem-893ad28d.js';
17
+ import { a as getRect } from './useClientRect-8b7cc406.js';
18
+ import { S as SwiperItem } from './swiperitem-d00e7513.js';
19
+ var defaultProps$1 = {
20
+ width: (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' ? window.innerWidth : 375,
21
+ height: 0,
22
+ duration: 500,
23
+ initPage: 0,
24
+ autoPlay: 0,
25
+ direction: 'horizontal',
26
+ paginationColor: '#fff',
27
+ paginationVisible: false,
28
+ loop: true,
29
+ touchable: true,
30
+ isPreventDefault: true,
31
+ isStopPropagation: true,
32
+ isCenter: false,
33
+ className: ''
34
+ };
35
+ var DISTANCE = 5;
36
+ var Swiper = React__default.forwardRef(function (props, ref) {
37
+ var _classNames, _classNames2;
38
+
39
+ var propSwiper = _objectSpread(_objectSpread({}, defaultProps$1), props);
40
+
41
+ var children = propSwiper.children,
42
+ direction = propSwiper.direction,
43
+ className = propSwiper.className,
44
+ pageContent = propSwiper.pageContent,
45
+ onChange = propSwiper.onChange,
46
+ initPage = propSwiper.initPage,
47
+ paginationColor = propSwiper.paginationColor,
48
+ paginationVisible = propSwiper.paginationVisible,
49
+ touchable = propSwiper.touchable,
50
+ isPreventDefault = propSwiper.isPreventDefault,
51
+ isStopPropagation = propSwiper.isStopPropagation,
52
+ autoPlay = propSwiper.autoPlay,
53
+ isCenter = propSwiper.isCenter,
54
+ rest = _objectWithoutProperties(propSwiper, _excluded);
55
+
56
+ var container = useRef(null);
57
+ var innerRef = useRef(null);
58
+
59
+ var _swiper = useRef({
60
+ moving: false,
61
+ autoplayTimer: null,
62
+ width: 0,
63
+ height: 0,
64
+ offset: 0,
65
+ size: 0
66
+ });
67
+
68
+ var isVertical = direction === 'vertical';
69
+
70
+ var _useState = useState(null),
71
+ _useState2 = _slicedToArray(_useState, 2),
72
+ rect = _useState2[0],
73
+ setRect = _useState2[1]; // eslint-disable-next-line prefer-const
74
+
75
+
76
+ var _useState3 = useState(0),
77
+ _useState4 = _slicedToArray(_useState3, 2),
78
+ active = _useState4[0],
79
+ setActive = _useState4[1];
80
+
81
+ var _useState5 = useState(0),
82
+ _useState6 = _slicedToArray(_useState5, 2),
83
+ width = _useState6[0],
84
+ setWidth = _useState6[1];
85
+
86
+ var _useState7 = useState(0),
87
+ _useState8 = _slicedToArray(_useState7, 2),
88
+ height = _useState8[0],
89
+ setHeight = _useState8[1];
90
+
91
+ var _useState9 = useState(0),
92
+ _useState10 = _slicedToArray(_useState9, 2),
93
+ offset = _useState10[0],
94
+ setOffset = _useState10[1];
95
+
96
+ var _useState11 = useState([]),
97
+ _useState12 = _slicedToArray(_useState11, 2),
98
+ childOffset = _useState12[0],
99
+ setChildOffset = _useState12[1];
100
+
101
+ var _useState13 = useState(false),
102
+ _useState14 = _slicedToArray(_useState13, 2),
103
+ ready = _useState14[0],
104
+ setReady = _useState14[1];
105
+
106
+ var size = isVertical ? height : width;
107
+
108
+ var _useState15 = useState({
109
+ startX: 0,
110
+ startY: 0,
111
+ deltaX: 0,
112
+ deltaY: 0,
113
+ offsetX: 0,
114
+ offsetY: 0,
115
+ stateDirection: '',
116
+ delta: 0,
117
+ touchTime: 0
118
+ }),
119
+ _useState16 = _slicedToArray(_useState15, 2),
120
+ touch = _useState16[0],
121
+ setTouch = _useState16[1];
122
+
123
+ var _useMemo = useMemo(function () {
124
+ var childCount = 0;
125
+ var childs = React__default.Children.map(props.children, function (child) {
126
+ if (!React__default.isValidElement(child)) return null;
127
+ childCount++;
128
+ return child;
129
+ });
130
+ return {
131
+ childs: childs,
132
+ childCount: childCount
133
+ };
134
+ }, [props.children]),
135
+ childs = _useMemo.childs,
136
+ childCount = _useMemo.childCount;
137
+
138
+ var trackSize = childCount * Number(size); // 父组件参数传入子组件item
139
+
140
+ var parent = {
141
+ propSwiper: propSwiper,
142
+ size: size
143
+ };
144
+
145
+ var minOffset = function () {
146
+ if (rect) {
147
+ var base = isVertical ? rect.height : rect.width;
148
+ return base - Number(size) * childCount;
149
+ }
150
+
151
+ return 0;
152
+ }(); // 清除定时器
153
+
154
+
155
+ var stopAutoPlay = function stopAutoPlay() {
156
+ clearTimeout(_swiper.current.autoplayTimer);
157
+ _swiper.current.autoplayTimer = null;
158
+ }; // 定时轮播
159
+
160
+
161
+ var autoplay = function autoplay() {
162
+ if (propSwiper.autoPlay <= 0 || childCount <= 1) return;
163
+ stopAutoPlay();
164
+ _swiper.current.autoplayTimer = setTimeout(function () {
165
+ next();
166
+ autoplay();
167
+ }, Number(propSwiper.autoPlay));
168
+ }; // 重置首尾位置信息
169
+
170
+
171
+ var resettPosition = function resettPosition() {
172
+ _swiper.current.moving = true;
173
+
174
+ if (active <= -1) {
175
+ move({
176
+ pace: childCount
177
+ });
178
+ }
179
+
180
+ if (active >= childCount) {
181
+ move({
182
+ pace: -childCount
183
+ });
184
+ }
185
+ }; // 上一页
186
+
187
+
188
+ var prev = function prev() {
189
+ resettPosition();
190
+ touchReset();
191
+ requestFrame(function () {
192
+ requestFrame(function () {
193
+ _swiper.current.moving = false;
194
+ move({
195
+ pace: -1,
196
+ isEmit: true
197
+ });
198
+ });
199
+ });
200
+ }; // 下一页
201
+
202
+
203
+ var next = function next() {
204
+ resettPosition();
205
+ touchReset();
206
+ requestFrame(function () {
207
+ requestFrame(function () {
208
+ _swiper.current.moving = false;
209
+ move({
210
+ pace: 1,
211
+ isEmit: true
212
+ });
213
+ });
214
+ });
215
+ }; // 前往指定页
216
+
217
+
218
+ var to = function to(index) {
219
+ resettPosition();
220
+ touchReset();
221
+ requestFrame(function () {
222
+ requestFrame(function () {
223
+ _swiper.current.moving = false;
224
+ var targetIndex;
225
+
226
+ if (props.loop && childCount === index) {
227
+ targetIndex = active === 0 ? 0 : index;
228
+ } else {
229
+ targetIndex = index % childCount;
230
+ }
231
+
232
+ move({
233
+ pace: targetIndex - active,
234
+ isEmit: true
235
+ });
236
+ });
237
+ });
238
+ }; // 切换方法
239
+
240
+
241
+ var move = function move(_ref) {
242
+ var _ref$pace = _ref.pace,
243
+ pace = _ref$pace === void 0 ? 0 : _ref$pace,
244
+ _ref$offset = _ref.offset,
245
+ offset = _ref$offset === void 0 ? 0 : _ref$offset,
246
+ _ref$isEmit = _ref.isEmit,
247
+ isEmit = _ref$isEmit === void 0 ? false : _ref$isEmit,
248
+ _ref$movingStatus = _ref.movingStatus,
249
+ movingStatus = _ref$movingStatus === void 0 ? false : _ref$movingStatus;
250
+ if (childCount <= 1) return;
251
+ var targetActive = getActive(pace); // 父级容器偏移量
252
+
253
+ var targetOffset = getOffset(targetActive, offset); // 如果循环,调整开头结尾图片位置
254
+
255
+ if (props.loop) {
256
+ if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
257
+ var rightBound = targetOffset < minOffset;
258
+ childOffset[0] = rightBound ? trackSize : 0;
259
+ }
260
+
261
+ if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
262
+ var leftBound = targetOffset > 0;
263
+ childOffset[childCount - 1] = leftBound ? -trackSize : 0;
264
+ }
265
+
266
+ setChildOffset(childOffset);
267
+ }
268
+
269
+ if (isEmit && active !== targetActive) {
270
+ props.onChange && props.onChange((targetActive + childCount) % childCount);
271
+ }
272
+
273
+ active = targetActive;
274
+ setActive(targetActive);
275
+ setOffset(targetOffset);
276
+ getStyle(targetOffset);
277
+ }; // 确定当前active 元素
278
+
279
+
280
+ var getActive = function getActive(pace) {
281
+ if (pace) {
282
+ var _active = active + pace;
283
+
284
+ if (props.loop) {
285
+ return range(_active, -1, childCount);
286
+ }
287
+
288
+ return range(_active, 0, childCount - 1);
289
+ }
290
+
291
+ return active;
292
+ }; // 计算位移
293
+
294
+
295
+ var getOffset = function getOffset(active) {
296
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
297
+ var currentPosition = active * Number(size);
298
+
299
+ if (!props.loop) {
300
+ currentPosition = Math.min(currentPosition, -minOffset);
301
+ }
302
+
303
+ var targetOffset = offset - currentPosition;
304
+
305
+ if (!props.loop) {
306
+ targetOffset = range(targetOffset, minOffset, 0);
307
+ }
308
+
309
+ return targetOffset;
310
+ }; // 浏览器 帧 事件
311
+
312
+
313
+ var requestFrame = function requestFrame(fn) {
314
+ window.requestAnimationFrame.call(window, fn);
315
+ }; // 取值 方法
316
+
317
+
318
+ var range = function range(num, min, max) {
319
+ return Math.min(Math.max(num, min), max);
320
+ };
321
+
322
+ var getDirection = function getDirection(x, y) {
323
+ if (x > y && x > DISTANCE) return 'horizontal';
324
+ if (y > x && y > DISTANCE) return 'vertical';
325
+ return '';
326
+ }; // 重置 全部位移信息
327
+
328
+
329
+ var touchReset = function touchReset() {
330
+ touch.startX = 0;
331
+ touch.startY = 0;
332
+ touch.deltaX = 0;
333
+ touch.deltaY = 0;
334
+ touch.offsetX = 0;
335
+ touch.offsetY = 0;
336
+ touch.delta = 0;
337
+ touch.stateDirection = '';
338
+ touch.touchTime = 0;
339
+ }; // 触摸事件开始
340
+
341
+
342
+ var touchStart = function touchStart(e) {
343
+ touchReset();
344
+ touch.startX = e.touches[0].clientX;
345
+ touch.startY = e.touches[0].clientY;
346
+ }; // 触摸事件移动
347
+
348
+
349
+ var touchMove = function touchMove(e) {
350
+ touch.deltaX = e.touches[0].clientX - touch.startX;
351
+ touch.deltaY = e.touches[0].clientY - touch.startY;
352
+ touch.offsetX = Math.abs(touch.deltaX);
353
+ touch.offsetY = Math.abs(touch.deltaY);
354
+ touch.delta = isVertical ? touch.deltaY : touch.deltaX;
355
+
356
+ if (!touch.stateDirection) {
357
+ touch.stateDirection = getDirection(touch.offsetX, touch.offsetY);
358
+ }
359
+ };
360
+
361
+ var b = cn('swiper');
362
+ var classes = classNames(b(''));
363
+ var contentClass = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(b('inner')), true), _defineProperty(_classNames, "".concat(b('vertical')), isVertical), _classNames));
364
+
365
+ var getStyle = function getStyle() {
366
+ var moveOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : offset;
367
+ var target = innerRef.current;
368
+ var _offset = 0;
369
+
370
+ if (!isCenter) {
371
+ _offset = moveOffset;
372
+ } else {
373
+ var _size = isVertical ? height : width;
374
+
375
+ var val = isVertical ? rect.height - _size : rect.width - _size;
376
+ _offset = moveOffset + (active === childCount - 1 && !props.loop ? -val / 2 : val / 2);
377
+ }
378
+
379
+ target.style.transform = "translate3D".concat(!isVertical ? "(".concat(_offset, "px,0,0)") : "(0,".concat(_offset, "px,0)"));
380
+ target.style.transitionDuration = "".concat(_swiper.current.moving ? 0 : props.duration, "ms");
381
+ target.style[isVertical ? 'height' : 'width'] = "".concat(Number(size) * childCount, "px");
382
+ target.style[isVertical ? 'width' : 'height'] = "".concat(isVertical ? width : height, "px");
383
+ };
384
+
385
+ var onTouchStart = function onTouchStart(e) {
386
+ if (props.isPreventDefault) e.preventDefault();
387
+ if (props.isStopPropagation) e.stopPropagation();
388
+ if (!props.touchable) return;
389
+ touchStart(e);
390
+ touch.touchTime = Date.now();
391
+ stopAutoPlay();
392
+ resettPosition();
393
+ };
394
+
395
+ var onTouchMove = function onTouchMove(e) {
396
+ if (props.touchable && _swiper.current.moving) {
397
+ touchMove(e);
398
+
399
+ if (touch.stateDirection === props.direction) {
400
+ move({
401
+ offset: touch.delta
402
+ });
403
+ }
404
+ }
405
+ };
406
+
407
+ var onTouchEnd = function onTouchEnd(e) {
408
+ if (!props.touchable || !_swiper.current.moving) return;
409
+ var speed = touch.delta / (Date.now() - touch.touchTime);
410
+ var isShouldMove = Math.abs(speed) > 0.3 || Math.abs(touch.delta) > +(size / 2).toFixed(2);
411
+ var pace = 0;
412
+ _swiper.current.moving = false;
413
+
414
+ if (isShouldMove && touch.stateDirection === props.direction) {
415
+ var _offset2 = isVertical ? touch.offsetY : touch.offsetX;
416
+
417
+ if (props.loop) {
418
+ if (_offset2 > 0) {
419
+ pace = touch.delta > 0 ? -1 : 1;
420
+ } else {
421
+ pace = 0;
422
+ }
423
+ } else {
424
+ pace = -Math[touch.delta > 0 ? 'ceil' : 'floor'](touch.delta / size);
425
+ }
426
+
427
+ move({
428
+ pace: pace,
429
+ isEmit: true
430
+ });
431
+ } else if (touch.delta) {
432
+ move({
433
+ pace: 0
434
+ });
435
+ } else {
436
+ getStyle();
437
+ }
438
+
439
+ autoplay();
440
+ };
441
+
442
+ useEffect(function () {
443
+ _swiper.current.activePagination = (active + childCount) % childCount;
444
+ }, [active]);
445
+
446
+ var init = function init() {
447
+ var active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : +propSwiper.initPage;
448
+ var rect = getRect(container === null || container === void 0 ? void 0 : container.current);
449
+
450
+ var _active = Math.max(Math.min(childCount - 1, active), 0);
451
+
452
+ var _width = propSwiper.width ? +propSwiper.width : rect.width;
453
+
454
+ var _height = propSwiper.height ? +propSwiper.height : rect.height;
455
+
456
+ size = isVertical ? _height : _width;
457
+ trackSize = childCount * Number(size);
458
+ var targetOffset = getOffset(_active);
459
+ _swiper.current.moving = true;
460
+
461
+ if (ready) {
462
+ _swiper.current.moving = false;
463
+ }
464
+
465
+ setRect(rect);
466
+ setActive(_active);
467
+ setWidth(_width);
468
+ setHeight(_height);
469
+ setOffset(targetOffset);
470
+ setReady(true);
471
+ };
472
+
473
+ useEffect(function () {
474
+ if (ready) {
475
+ getStyle();
476
+ }
477
+ }, [isVertical, width, height, offset, ready]);
478
+ useEffect(function () {
479
+ if (ready) {
480
+ stopAutoPlay();
481
+ autoplay();
482
+ }
483
+
484
+ return function () {
485
+ setReady(false);
486
+ };
487
+ }, [ready]);
488
+ useEffect(function () {
489
+ stopAutoPlay();
490
+ autoplay();
491
+ }, [children]);
492
+ useEffect(function () {
493
+ init();
494
+ }, [propSwiper.initPage]);
495
+ useEffect(function () {
496
+ var target = container.current;
497
+ target.addEventListener('touchstart', onTouchStart, false);
498
+ target.addEventListener('touchmove', onTouchMove, false);
499
+ target.addEventListener('touchend', onTouchEnd, false);
500
+ return function () {
501
+ target.removeEventListener('touchstart', onTouchStart, false);
502
+ target.removeEventListener('touchmove', onTouchMove, false);
503
+ target.removeEventListener('touchend', onTouchEnd, false);
504
+ };
505
+ });
506
+ useEffect(function () {
507
+ return function () {
508
+ stopAutoPlay();
509
+ };
510
+ }, []);
511
+
512
+ var itemStyle = function itemStyle(index) {
513
+ var style = {};
514
+
515
+ var _direction = propSwiper.direction || direction;
516
+
517
+ var _size = size;
518
+
519
+ if (_size) {
520
+ style[_direction === 'horizontal' ? 'width' : 'height'] = "".concat(_size, "px");
521
+ }
522
+
523
+ var offset = childOffset[index];
524
+
525
+ if (offset) {
526
+ style.transform = "translate3D".concat(_direction === 'horizontal' ? "(".concat(offset, "px,0,0)") : "(0,".concat(offset, "px,0)"));
527
+ }
528
+
529
+ return style;
530
+ };
531
+
532
+ React__default.useImperativeHandle(ref, function () {
533
+ return {
534
+ to: to,
535
+ next: next,
536
+ prev: prev
537
+ };
538
+ });
539
+ return React__default.createElement(DataContext.Provider, {
540
+ value: parent
541
+ }, React__default.createElement("div", _objectSpread({
542
+ className: "".concat(classes, " ").concat(className),
543
+ ref: container
544
+ }, rest), React__default.createElement("div", {
545
+ className: contentClass,
546
+ ref: innerRef
547
+ }, React__default.Children.map(childs, function (child, index) {
548
+ return React__default.createElement("div", {
549
+ className: b('item-wrapper'),
550
+ style: itemStyle(index),
551
+ key: index
552
+ }, child);
553
+ })), propSwiper.paginationVisible && !('pageContent' in propSwiper) ? React__default.createElement("div", {
554
+ className: classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(b('pagination')), true), _defineProperty(_classNames2, "".concat(b('pagination-vertical')), isVertical), _classNames2))
555
+ }, React__default.Children.map(childs, function (item, index) {
556
+ var _classNames3;
557
+
558
+ return React__default.createElement("i", {
559
+ style: (active + childCount) % childCount === index ? {
560
+ backgroundColor: propSwiper.paginationColor
561
+ } : undefined,
562
+ className: classNames((_classNames3 = {}, _defineProperty(_classNames3, "".concat(b('pagination-item')), true), _defineProperty(_classNames3, "active", (active + childCount) % childCount === index), _classNames3)),
563
+ key: index
564
+ });
565
+ })) : React__default.createElement("div", null, pageContent)));
566
+ });
567
+ Swiper.defaultProps = defaultProps$1;
568
+ Swiper.displayName = 'NutSwiper';
569
+ var defaultProps = {
570
+ images: [],
571
+ videos: [],
572
+ show: false,
573
+ autoplay: 3000,
574
+ initNo: 1,
575
+ contentClose: false,
576
+ paginationVisible: false,
577
+ paginationColor: '#fff',
578
+ onClose: function onClose() {}
579
+ };
580
+
581
+ var ImagePreview = function ImagePreview(props) {
582
+ var images = props.images,
583
+ videos = props.videos,
584
+ show = props.show,
585
+ initNo = props.initNo,
586
+ paginationColor = props.paginationColor,
587
+ paginationVisible = props.paginationVisible,
588
+ autoplay = props.autoplay,
589
+ contentClose = props.contentClose,
590
+ onClose = props.onClose;
591
+ var nutImagePreview = useRef(null);
592
+
593
+ var _useState17 = useState(false),
594
+ _useState18 = _slicedToArray(_useState17, 2),
595
+ showPop = _useState18[0],
596
+ setShowPop = _useState18[1];
597
+
598
+ var _useState19 = useState(1),
599
+ _useState20 = _slicedToArray(_useState19, 2),
600
+ active = _useState20[0],
601
+ setActive = _useState20[1];
602
+
603
+ var _useState21 = useState(1),
604
+ _useState22 = _slicedToArray(_useState21, 2),
605
+ maxNo = _useState22[0],
606
+ setMaxNo = _useState22[1];
607
+
608
+ var _useState23 = useState({
609
+ scale: 1,
610
+ moveable: false
611
+ }),
612
+ _useState24 = _slicedToArray(_useState23, 2),
613
+ store = _useState24[0],
614
+ setStore = _useState24[1];
615
+
616
+ var _useState25 = useState(0),
617
+ _useState26 = _slicedToArray(_useState25, 2),
618
+ lastTouchEndTime = _useState26[0],
619
+ setLastTouchEndTime = _useState26[1]; // 用来辅助监听双击
620
+
621
+
622
+ var onTouchStart = function onTouchStart(event) {
623
+ var touches = event.touches;
624
+ var events = touches[0];
625
+ var events2 = touches[1]; // 如果已经放大,双击应变回原尺寸;如果是原尺寸,双击应放大
626
+
627
+ var curTouchTime = new Date().getTime();
628
+
629
+ if (curTouchTime - lastTouchEndTime < 300) {
630
+ var _store = store;
631
+
632
+ if (_store.scale > 1) {
633
+ _store.scale = 1;
634
+ } else if (_store.scale === 1) {
635
+ _store.scale = 2;
636
+ }
637
+
638
+ scaleNow();
639
+ }
640
+
641
+ var store1 = store;
642
+ store1.moveable = true;
643
+
644
+ if (events2) {
645
+ // 如果开始两指操作,记录初始时刻两指间的距离
646
+ store1.oriDistance = getDistance({
647
+ x: events.pageX,
648
+ y: events.pageY
649
+ }, {
650
+ x: events2.pageX,
651
+ y: events2.pageY
652
+ });
653
+ } // 取到开始两指操作时的放大(缩小比例),store.scale 存储的是当前的放缩比(相对于标准大小 scale 为 1 的情况的放大缩小比)
654
+
655
+
656
+ store1.originScale = store1.scale || 1;
657
+ };
658
+
659
+ var onTouchMove = function onTouchMove(event) {
660
+ var touches = event.touches;
661
+ var events = touches[0];
662
+ var events2 = touches[1];
663
+
664
+ if (!store.moveable) {
665
+ return;
666
+ }
667
+
668
+ var store1 = store; // 双指移动
669
+
670
+ if (events2) {
671
+ // 获得当前两点间的距离
672
+ var curDistance = getDistance({
673
+ x: events.pageX,
674
+ y: events.pageY
675
+ }, {
676
+ x: events2.pageX,
677
+ y: events2.pageY
678
+ });
679
+ /** 此处计算倍数,距离放大(缩小) k 倍则 scale 也 扩大(缩小) k 倍。距离放大(缩小)倍数 = 结束时两点距离 除以 开始时两点距离
680
+ * 注意此处的 scale 变化是基于 store.scale 的。
681
+ * store.scale 是一个暂存值,比如第一次放大 2 倍,则 store.scale 为 2。
682
+ * 再次两指触碰的时候,store.originScale 就为 store.scale 的值,基于此时的 store.scale 继续放大缩小。 * */
683
+
684
+ var curScale = curDistance / store1.oriDistance;
685
+ store1.scale = store1.originScale * curScale; // 最大放大 3 倍,缩小后松手要弹回原比例
686
+
687
+ if (store1.scale > 3) {
688
+ store1.scale = 3;
689
+ }
690
+
691
+ scaleNow();
692
+ }
693
+ };
694
+
695
+ var onTouchEnd = function onTouchEnd() {
696
+ setLastTouchEndTime(new Date().getTime());
697
+ var store1 = store;
698
+ store1.moveable = false;
699
+
700
+ if (store1.scale < 1.1 && store1.scale > 1 || store1.scale < 1) {
701
+ store1.scale = 1;
702
+ scaleNow();
703
+ }
704
+ };
705
+
706
+ var init = function init() {
707
+ document.addEventListener('touchmove', onTouchMove);
708
+ document.addEventListener('touchend', onTouchEnd);
709
+ document.addEventListener('touchcancel', onTouchEnd);
710
+ };
711
+
712
+ useEffect(function () {
713
+ if (show !== undefined) {
714
+ setShowPop(show);
715
+ init();
716
+ }
717
+ }, [show]);
718
+ useEffect(function () {
719
+ if (initNo !== undefined) {
720
+ setActive(initNo);
721
+ }
722
+
723
+ if (show !== undefined) {
724
+ setShowPop(show);
725
+ }
726
+
727
+ if (images && videos) {
728
+ setMaxNo(images.length + videos.length);
729
+ }
730
+ }, []);
731
+
732
+ var scaleNow = function scaleNow() {
733
+ if (nutImagePreview.current) {
734
+ nutImagePreview.current.style.transform = "scale(".concat(store.scale, ")");
735
+ }
736
+ };
737
+
738
+ var onCloseInner = function onCloseInner() {
739
+ setShowPop(false);
740
+ setActive(1);
741
+ scaleNow();
742
+ onClose && onClose();
743
+ setStore(_objectSpread(_objectSpread({}, store), {}, {
744
+ scale: 1
745
+ }));
746
+ }; // 计算两个点的距离
747
+
748
+
749
+ var getDistance = function getDistance(first, second) {
750
+ // 计算两个点起始时刻的距离和终止时刻的距离,终止时刻距离变大了则放大,变小了则缩小
751
+ // 放大 k 倍则 scale 也 扩大 k 倍
752
+ return Math.hypot(Math.abs(second.x - first.x), Math.abs(second.y - first.y));
753
+ };
754
+
755
+ var slideChangeEnd = function slideChangeEnd(page) {
756
+ setActive(page + 1);
757
+ };
758
+
759
+ var closeOnImg = function closeOnImg() {
760
+ // 点击内容区域的图片是否可以关闭弹层(视频区域由于nut-video做了限制,无法关闭弹层)
761
+ if (contentClose) {
762
+ onCloseInner();
763
+ }
764
+ };
765
+
766
+ return React__default.createElement(Popup, {
767
+ visible: showPop,
768
+ popClass: "custom-pop",
769
+ style: {
770
+ width: '100%'
771
+ },
772
+ onClick: onCloseInner
773
+ }, React__default.createElement("div", {
774
+ className: "nut-imagepreview",
775
+ ref: nutImagePreview,
776
+ onClick: closeOnImg,
777
+ onTouchStart: onTouchStart
778
+ }, React__default.createElement(Swiper, {
779
+ autoPlay: autoplay,
780
+ className: "nut-imagepreview-swiper",
781
+ loop: true,
782
+ isPreventDefault: false,
783
+ style: {
784
+ display: showPop ? 'block' : 'none'
785
+ },
786
+ direction: "horizontal",
787
+ onChange: slideChangeEnd,
788
+ initPage: initNo && (initNo > maxNo ? maxNo - 1 : initNo - 1),
789
+ paginationColor: paginationColor,
790
+ paginationVisible: paginationVisible
791
+ }, videos && videos.length > 0 && videos.map(function (item, index) {
792
+ return React__default.createElement(SwiperItem, {
793
+ key: index
794
+ }, React__default.createElement(Video, {
795
+ source: item.source,
796
+ options: item.options
797
+ }));
798
+ }), images && images.length > 0 && images.map(function (item, index) {
799
+ return React__default.createElement(SwiperItem, {
800
+ key: index
801
+ }, React__default.createElement("img", {
802
+ src: item.src,
803
+ alt: "",
804
+ className: "nut-imagepreview-img"
805
+ }));
806
+ }))), React__default.createElement("div", {
807
+ className: "nut-imagepreview-index"
808
+ }, active, "/", (images ? images.length : 0) + (videos ? videos.length : 0)));
809
+ };
810
+
811
+ ImagePreview.defaultProps = defaultProps;
812
+ ImagePreview.displayName = 'NutImagePreview';
813
+ export { ImagePreview as I };