pixuireactcomponents 1.2.0 → 1.2.2

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 (400) hide show
  1. package/README.md +5 -6
  2. package/package.json +9 -66
  3. package/tsconfig.json +27 -13
  4. package/{src/pixUIReactComponents/ui → ui}/components/slapface/Slapface.tsx +17 -17
  5. package/ui/sample/Slapface/SlapfaceDemo.tsx +30 -0
  6. package/.eslintignore +0 -7
  7. package/.eslintrc.js +0 -48
  8. package/.pixiderc/apps.json +0 -12
  9. package/.pixiderc/devel-config.meta.json +0 -23
  10. package/.pixiderc/postinstall.js +0 -17
  11. package/.pixiderc/util.js +0 -136
  12. package/.pixiderc/webpack.js +0 -180
  13. package/faas/helloworld.js +0 -8
  14. package/gen/pbo/pandora_pb.d.ts +0 -1179
  15. package/gen/pbo/pandora_pb.js +0 -10475
  16. package/gen/pbo/pandora_pb_service.d.ts +0 -1317
  17. package/gen/pbo/pandora_pb_service.js +0 -2307
  18. package/gen/pbo/test_pb.d.ts +0 -99
  19. package/gen/pbo/test_pb.js +0 -889
  20. package/gen/pbo/test_pb_service.d.ts +0 -82
  21. package/gen/pbo/test_pb_service.js +0 -117
  22. package/lib/assets/border.png +0 -0
  23. package/lib/assets/check.html +0 -54
  24. package/lib/assets/pixui.png +0 -0
  25. package/lib/assets/preact.png +0 -0
  26. package/lib/check/main.less +0 -63
  27. package/lib/check/main.tsx +0 -42
  28. package/lib/check/tool.js +0 -3
  29. package/lib/check/util.tsx +0 -107
  30. package/lib/dom.ts +0 -16
  31. package/lib/ext.d.ts +0 -95
  32. package/lib/grpc-web/dist/ChunkParser.js +0 -115
  33. package/lib/grpc-web/dist/ChunkParser.js.map +0 -1
  34. package/lib/grpc-web/dist/Code.js +0 -58
  35. package/lib/grpc-web/dist/Code.js.map +0 -1
  36. package/lib/grpc-web/dist/client.js +0 -299
  37. package/lib/grpc-web/dist/client.js.map +0 -1
  38. package/lib/grpc-web/dist/debug.js +0 -16
  39. package/lib/grpc-web/dist/debug.js.map +0 -1
  40. package/lib/grpc-web/dist/detach.js +0 -7
  41. package/lib/grpc-web/dist/detach.js.map +0 -1
  42. package/lib/grpc-web/dist/index.js +0 -29
  43. package/lib/grpc-web/dist/index.js.map +0 -1
  44. package/lib/grpc-web/dist/invoke.js +0 -32
  45. package/lib/grpc-web/dist/invoke.js.map +0 -1
  46. package/lib/grpc-web/dist/message.js +0 -3
  47. package/lib/grpc-web/dist/message.js.map +0 -1
  48. package/lib/grpc-web/dist/metadata.js +0 -5
  49. package/lib/grpc-web/dist/metadata.js.map +0 -1
  50. package/lib/grpc-web/dist/service.js +0 -3
  51. package/lib/grpc-web/dist/service.js.map +0 -1
  52. package/lib/grpc-web/dist/transports/Transport.js +0 -13
  53. package/lib/grpc-web/dist/transports/Transport.js.map +0 -1
  54. package/lib/grpc-web/dist/transports/http/fetch.js +0 -112
  55. package/lib/grpc-web/dist/transports/http/fetch.js.map +0 -1
  56. package/lib/grpc-web/dist/transports/http/http.js +0 -15
  57. package/lib/grpc-web/dist/transports/http/http.js.map +0 -1
  58. package/lib/grpc-web/dist/transports/http/xhr.js +0 -127
  59. package/lib/grpc-web/dist/transports/http/xhr.js.map +0 -1
  60. package/lib/grpc-web/dist/transports/http/xhrUtil.js +0 -37
  61. package/lib/grpc-web/dist/transports/http/xhrUtil.js.map +0 -1
  62. package/lib/grpc-web/dist/transports/websocket/websocket.js +0 -95
  63. package/lib/grpc-web/dist/transports/websocket/websocket.js.map +0 -1
  64. package/lib/grpc-web/dist/typings/ChunkParser.d.ts +0 -17
  65. package/lib/grpc-web/dist/typings/Code.d.ts +0 -20
  66. package/lib/grpc-web/dist/typings/client.d.ts +0 -22
  67. package/lib/grpc-web/dist/typings/debug.d.ts +0 -1
  68. package/lib/grpc-web/dist/typings/detach.d.ts +0 -1
  69. package/lib/grpc-web/dist/typings/index.d.ts +0 -60
  70. package/lib/grpc-web/dist/typings/invoke.d.ts +0 -17
  71. package/lib/grpc-web/dist/typings/message.d.ts +0 -8
  72. package/lib/grpc-web/dist/typings/metadata.d.ts +0 -2
  73. package/lib/grpc-web/dist/typings/service.d.ts +0 -16
  74. package/lib/grpc-web/dist/typings/transports/Transport.d.ts +0 -22
  75. package/lib/grpc-web/dist/typings/transports/http/fetch.d.ts +0 -6
  76. package/lib/grpc-web/dist/typings/transports/http/http.d.ts +0 -5
  77. package/lib/grpc-web/dist/typings/transports/http/xhr.d.ts +0 -27
  78. package/lib/grpc-web/dist/typings/transports/http/xhrUtil.d.ts +0 -3
  79. package/lib/grpc-web/dist/typings/transports/websocket/websocket.d.ts +0 -2
  80. package/lib/grpc-web/dist/typings/unary.d.ts +0 -20
  81. package/lib/grpc-web/dist/typings/util.d.ts +0 -2
  82. package/lib/grpc-web/dist/unary.js +0 -44
  83. package/lib/grpc-web/dist/unary.js.map +0 -1
  84. package/lib/grpc-web/dist/util.js +0 -11
  85. package/lib/grpc-web/dist/util.js.map +0 -1
  86. package/lib/grpcTransport/PixHttp2Transport.ts +0 -104
  87. package/lib/grpcTransport/PixLuaTransport.ts +0 -80
  88. package/lib/pi_component/tinyList/tinyList.js +0 -573
  89. package/lib/pi_component/tinyList/tinyList.tsx +0 -586
  90. package/lib/preact/compat/src/Children.js +0 -26
  91. package/lib/preact/compat/src/PureComponent.js +0 -19
  92. package/lib/preact/compat/src/events.js +0 -36
  93. package/lib/preact/compat/src/forwardRef.js +0 -29
  94. package/lib/preact/compat/src/index.d.ts +0 -121
  95. package/lib/preact/compat/src/index.js +0 -159
  96. package/lib/preact/compat/src/internal.d.ts +0 -45
  97. package/lib/preact/compat/src/memo.js +0 -34
  98. package/lib/preact/compat/src/portals.js +0 -85
  99. package/lib/preact/compat/src/render.js +0 -166
  100. package/lib/preact/compat/src/suspense-list.d.ts +0 -14
  101. package/lib/preact/compat/src/suspense-list.js +0 -127
  102. package/lib/preact/compat/src/suspense.d.ts +0 -15
  103. package/lib/preact/compat/src/suspense.js +0 -165
  104. package/lib/preact/compat/src/util.js +0 -23
  105. package/lib/preact/hooks/src/index.d.ts +0 -133
  106. package/lib/preact/hooks/src/index.js +0 -339
  107. package/lib/preact/hooks/src/internal.d.ts +0 -55
  108. package/lib/preact/src/clone-element.js +0 -27
  109. package/lib/preact/src/compat.ts +0 -0
  110. package/lib/preact/src/component.js +0 -219
  111. package/lib/preact/src/constants.js +0 -3
  112. package/lib/preact/src/create-context.js +0 -55
  113. package/lib/preact/src/create-element.js +0 -102
  114. package/lib/preact/src/css.d.ts +0 -30341
  115. package/lib/preact/src/diff/catch-error.js +0 -41
  116. package/lib/preact/src/diff/children.js +0 -259
  117. package/lib/preact/src/diff/index.js +0 -445
  118. package/lib/preact/src/diff/props.js +0 -163
  119. package/lib/preact/src/index.d.ts +0 -275
  120. package/lib/preact/src/index.js +0 -14
  121. package/lib/preact/src/internal.d.ts +0 -94
  122. package/lib/preact/src/jsx.d.ts +0 -884
  123. package/lib/preact/src/options.js +0 -16
  124. package/lib/preact/src/render.js +0 -98
  125. package/lib/preact/src/util.js +0 -25
  126. package/lib/preact-router/.travis.yml +0 -3
  127. package/lib/preact-router/LICENSE +0 -21
  128. package/lib/preact-router/README.md +0 -254
  129. package/lib/preact-router/index.d.ts +0 -71
  130. package/lib/preact-router/match/index.d.ts +0 -16
  131. package/lib/preact-router/match/package.json +0 -13
  132. package/lib/preact-router/match/src/cjs.js +0 -4
  133. package/lib/preact-router/match/src/index.js +0 -36
  134. package/lib/preact-router/package-lock.json +0 -12330
  135. package/lib/preact-router/package.json +0 -78
  136. package/lib/preact-router/src/cjs.js +0 -11
  137. package/lib/preact-router/src/index.js +0 -270
  138. package/lib/preact-router/src/util.js +0 -87
  139. package/lib/react-window/src/FixedSizeGrid.js +0 -244
  140. package/lib/react-window/src/FixedSizeList.js +0 -130
  141. package/lib/react-window/src/VariableSizeGrid.js +0 -507
  142. package/lib/react-window/src/VariableSizeList.js +0 -316
  143. package/lib/react-window/src/__tests__/FixedSizeGrid.js +0 -1336
  144. package/lib/react-window/src/__tests__/FixedSizeList.js +0 -966
  145. package/lib/react-window/src/__tests__/VariableSizeGrid.js +0 -779
  146. package/lib/react-window/src/__tests__/VariableSizeList.js +0 -442
  147. package/lib/react-window/src/__tests__/__snapshots__/FixedSizeGrid.js.snap +0 -912
  148. package/lib/react-window/src/__tests__/__snapshots__/FixedSizeList.js.snap +0 -568
  149. package/lib/react-window/src/__tests__/__snapshots__/VariableSizeGrid.js.snap +0 -542
  150. package/lib/react-window/src/__tests__/__snapshots__/VariableSizeList.js.snap +0 -331
  151. package/lib/react-window/src/__tests__/areEqual.js +0 -32
  152. package/lib/react-window/src/__tests__/shouldComponentUpdate.js +0 -36
  153. package/lib/react-window/src/areEqual.js +0 -18
  154. package/lib/react-window/src/createGridComponent.js +0 -919
  155. package/lib/react-window/src/createListComponent.js +0 -729
  156. package/lib/react-window/src/domHelpers.js +0 -72
  157. package/lib/react-window/src/index.js +0 -9
  158. package/lib/react-window/src/shallowDiffers.js +0 -17
  159. package/lib/react-window/src/shouldComponentUpdate.js +0 -16
  160. package/lib/react-window/src/test.js.flow +0 -382
  161. package/lib/react-window/src/timer.js +0 -36
  162. package/src/app/demopage.tsx +0 -77
  163. package/src/app/index.html +0 -48
  164. package/src/app/main.tsx +0 -30
  165. package/src/asset/Textures/Alert/bg_tips.png +0 -0
  166. package/src/asset/Textures/Alert/btn_zhedie_a.png +0 -0
  167. package/src/asset/Textures/Alert/com_home_bg_left.png +0 -0
  168. package/src/asset/Textures/Alert/com_home_bg_rightbar.png +0 -0
  169. package/src/asset/Textures/Commons/com_home_bg_a.png +0 -0
  170. package/src/asset/Textures/Commons/com_home_bg_back_top.png +0 -0
  171. package/src/asset/Textures/Commons/com_home_bg_bottombar_sheet.png +0 -0
  172. package/src/asset/Textures/Commons/com_home_bg_list_xiala.png +0 -0
  173. package/src/asset/Textures/Commons/com_home_bg_rightbar_line.png +0 -0
  174. package/src/asset/Textures/Commons/com_home_bg_rightbar_selected.png +0 -0
  175. package/src/asset/Textures/Commons/com_home_bg_touxiang_140.png +0 -0
  176. package/src/asset/Textures/Commons/com_home_bg_touxiang_60.png +0 -0
  177. package/src/asset/Textures/Commons/com_home_bg_touxiang_80.png +0 -0
  178. package/src/asset/Textures/Commons/com_home_btn_back.png +0 -0
  179. package/src/asset/Textures/Commons/com_home_btn_bottombar.png +0 -0
  180. package/src/asset/Textures/Commons/com_home_btn_bottombar_fadongtai.png +0 -0
  181. package/src/asset/Textures/Commons/com_home_btn_close.png +0 -0
  182. package/src/asset/Textures/Commons/com_home_btn_guanzhu_126.png +0 -0
  183. package/src/asset/Textures/Commons/com_home_btn_guanzhu_86.png +0 -0
  184. package/src/asset/Textures/Commons/com_home_btn_left_bianji.png +0 -0
  185. package/src/asset/Textures/Commons/com_home_btn_left_dongtai.png +0 -0
  186. package/src/asset/Textures/Commons/com_home_btn_left_touxiang.png +0 -0
  187. package/src/asset/Textures/Commons/com_home_btn_selet.png +0 -0
  188. package/src/asset/Textures/Commons/com_home_btn_yiguanzhu_126.png +0 -0
  189. package/src/asset/Textures/Commons/com_home_btn_yiguanzhu_86.png +0 -0
  190. package/src/asset/Textures/Commons/com_home_icon_bottombar_fadongtai.png +0 -0
  191. package/src/asset/Textures/Commons/com_home_icon_bottombar_red.png +0 -0
  192. package/src/asset/Textures/Commons/com_home_icon_loading.png +0 -0
  193. package/src/asset/Textures/Commons/com_home_pic_touxiang_moren.png +0 -0
  194. package/src/asset/Textures/Commons/com_home_tab_left_a.png +0 -0
  195. package/src/asset/Textures/Commons/com_home_tab_left_b.png +0 -0
  196. package/src/asset/Textures/Commons/com_home_tab_left_c.png +0 -0
  197. package/src/asset/Textures/Commons/feedItems/gc1_huati_icon_middle_v.png +0 -0
  198. package/src/asset/Textures/Commons/feedItems/gc1_huati_icon_middle_yonghurenzheng.png +0 -0
  199. package/src/asset/Textures/Commons/feedItems/pinglun_bg.png +0 -0
  200. package/src/asset/Textures/Commons/feedItems/pinglun_bg_line.png +0 -0
  201. package/src/asset/Textures/Commons/feedItems/pinglun_bg_middle_chakan.png +0 -0
  202. package/src/asset/Textures/Commons/feedItems/pinglun_bg_middle_input.png +0 -0
  203. package/src/asset/Textures/Commons/feedItems/pinglun_bg_zan.png +0 -0
  204. package/src/asset/Textures/Commons/feedItems/pinglun_btn_middle_input.png +0 -0
  205. package/src/asset/Textures/Commons/feedItems/pinglun_btn_more.png +0 -0
  206. package/src/asset/Textures/Commons/feedItems/pinglun_btn_normal.png +0 -0
  207. package/src/asset/Textures/Commons/feedItems/pinglun_btn_photo_more.png +0 -0
  208. package/src/asset/Textures/Commons/feedItems/pinglun_btn_zhedie_a.png +0 -0
  209. package/src/asset/Textures/Commons/feedItems/pinglun_btn_zhedie_a_shadow.png +0 -0
  210. package/src/asset/Textures/Commons/feedItems/pinglun_btn_zhedie_b_normal.png +0 -0
  211. package/src/asset/Textures/Commons/feedItems/pinglun_btn_zhedie_b_pressed.png +0 -0
  212. package/src/asset/Textures/Commons/feedItems/pinglun_icon_a_normal.png +0 -0
  213. package/src/asset/Textures/Commons/feedItems/pinglun_icon_a_pressed.png +0 -0
  214. package/src/asset/Textures/Commons/feedItems/pinglun_icon_b_normal.png +0 -0
  215. package/src/asset/Textures/Commons/feedItems/pinglun_icon_c_normal.png +0 -0
  216. package/src/asset/Textures/Commons/feedItems/pinglun_icon_d.png +0 -0
  217. package/src/asset/Textures/Commons/feedItems/pinglun_icon_e.png +0 -0
  218. package/src/asset/Textures/Commons/feedItems/pinglun_icon_f_share.png +0 -0
  219. package/src/asset/Textures/Commons/feedItems/pinglun_icon_middle_input_back.png +0 -0
  220. package/src/asset/Textures/Commons/gc1_huati_bg_middle_topbtn.png +0 -0
  221. package/src/asset/Textures/Commons/gc1_huati_bg_middle_topbtn_pressd.png +0 -0
  222. package/src/asset/Textures/Commons/karaoke/rukou_bg_music.png +0 -0
  223. package/src/asset/Textures/Commons/karaoke/rukou_btn_a.png +0 -0
  224. package/src/asset/Textures/Commons/karaoke/rukou_btn_b.png +0 -0
  225. package/src/asset/Textures/Commons/karaoke/rukou_icon_b.png +0 -0
  226. package/src/asset/Textures/Commons/karaoke/rukou_icon_d.png +0 -0
  227. package/src/asset/Textures/Commons/karaoke/rukou_icon_e.png +0 -0
  228. package/src/asset/Textures/Commons/rukou_bg_bottombar_line.png +0 -0
  229. package/src/asset/Textures/Commons/rukou_icon_a.png +0 -0
  230. package/src/asset/Textures/Commons/tc_bianji_tab_a.png +0 -0
  231. package/src/asset/Textures/Commons/tc_zanshang_bg_line.png +0 -0
  232. package/src/asset/Textures/Commons/touxiang_bg_tishikuang.png +0 -0
  233. package/src/asset/Textures/Commons/video/rukou_icon_shipin.png +0 -0
  234. package/src/asset/Textures/Commons/video/xiangce_btn_bofang.png +0 -0
  235. package/src/asset/Textures/Commons/voice/rukou_icon_yuyin.png +0 -0
  236. package/src/asset/Textures/Commons/voice/tc_yuyin_bg.png +0 -0
  237. package/src/asset/Textures/Commons/voice/tc_yuyin_bg_load.png +0 -0
  238. package/src/asset/Textures/Commons/voice/tc_yuyin_bg_xinhao_a.png +0 -0
  239. package/src/asset/Textures/Commons/voice/tc_yuyin_bg_xinhao_b.png +0 -0
  240. package/src/asset/Textures/Commons/xiangce_icon_bottombar_gulita.png +0 -0
  241. package/src/asset/Textures/SocialSecond/com_tc_bg.png +0 -0
  242. package/src/asset/Textures/SocialSecond/com_tc_bg_bottom.png +0 -0
  243. package/src/asset/Textures/SocialSecond/com_tc_bg_input.png +0 -0
  244. package/src/asset/Textures/SocialSecond/com_tc_bg_tips.png +0 -0
  245. package/src/asset/Textures/SocialSecond/com_tc_bg_topbar_a.png +0 -0
  246. package/src/asset/Textures/SocialSecond/com_tc_bg_topbar_line.png +0 -0
  247. package/src/asset/Textures/SocialSecond/com_tc_bg_upload_photo.png +0 -0
  248. package/src/asset/Textures/SocialSecond/com_tc_bg_upload_photo_line.png +0 -0
  249. package/src/asset/Textures/SocialSecond/com_tc_bg_zhaopian_line.png +0 -0
  250. package/src/asset/Textures/SocialSecond/com_tc_btn.png +0 -0
  251. package/src/asset/Textures/SocialSecond/com_tc_btn_close.png +0 -0
  252. package/src/asset/Textures/SocialSecond/com_tc_btn_upload_photo.png +0 -0
  253. package/src/asset/Textures/SocialSecond/com_tc_radio_normal.png +0 -0
  254. package/src/asset/Textures/SocialSecond/com_tc_radio_normal_@slice_0.png +0 -0
  255. package/src/asset/Textures/SocialSecond/com_tc_radio_selected.png +0 -0
  256. package/src/asset/Textures/SocialSecond/com_tc_tab_a.png +0 -0
  257. package/src/asset/Textures/SocialSecond/gc1_huati_bg_middle_topbar.png +0 -0
  258. package/src/asset/Textures/SocialSecond/gc1_huati_bg_middle_topbar_pre.png +0 -0
  259. package/src/asset/Textures/SocialSecond/newmessage_bg_left_line.png +0 -0
  260. package/src/asset/Textures/SocialSecond/newmessage_bg_left_normal.png +0 -0
  261. package/src/asset/Textures/SocialSecond/newmessage_bg_left_selected.png +0 -0
  262. package/src/asset/Textures/SocialSecond/newmessage_bg_middle_new.png +0 -0
  263. package/src/asset/Textures/SocialSecond/paihang_bg_list.png +0 -0
  264. package/src/asset/Textures/SocialSecond/paihang_bg_list_line.png +0 -0
  265. package/src/asset/Textures/SocialSecond/paihang_bg_list_my.png +0 -0
  266. package/src/asset/Textures/SocialSecond/paihang_bg_list_top.png +0 -0
  267. package/src/asset/Textures/SocialSecond/paihang_bg_topbar_a.png +0 -0
  268. package/src/asset/Textures/SocialSecond/paihang_icon_topbar_selected.png +0 -0
  269. package/src/asset/Textures/SocialSecond/paihang_pic_1.png +0 -0
  270. package/src/asset/Textures/SocialSecond/paihang_pic_2.png +0 -0
  271. package/src/asset/Textures/SocialSecond/tc_fadongtai_btn_close.png +0 -0
  272. package/src/asset/Textures/SocialSecond/tc_guanzhu_bg_topbar.png +0 -0
  273. package/src/asset/Textures/SocialSecond/tc_guanzhu_bg_topbar_selected.png +0 -0
  274. package/src/asset/Textures/SocialSecond/tc_liwu_bg.png +0 -0
  275. package/src/asset/Textures/SocialSecond/tc_liwu_bg_daoju.png +0 -0
  276. package/src/asset/Textures/SocialSecond/tc_liwu_btn_a.png +0 -0
  277. package/src/asset/Textures/SocialSecond/tc_liwu_btn_b.png +0 -0
  278. package/src/asset/Textures/SocialSecond/tc_liwu_btn_c.png +0 -0
  279. package/src/asset/Textures/SocialSecond/tc_liwu_pic_daoju1.png +0 -0
  280. package/src/asset/Textures/SocialSecond/tc_liwu_pic_daoju2.png +0 -0
  281. package/src/asset/Textures/SocialSecond/tc_liwu_pic_daoju3.png +0 -0
  282. package/src/asset/Textures/SocialSecond/tc_pinglun_bg.png +0 -0
  283. package/src/asset/Textures/SocialSecond/tc_shipin_tianjiashipin.png +0 -0
  284. package/src/asset/Textures/SocialSecond/tc_yuyin_bg.png +0 -0
  285. package/src/asset/Textures/SocialSecond/tc_yuyin_bg_delete.png +0 -0
  286. package/src/asset/Textures/SocialSecond/tc_yuyin_bg_xinhao_a.png +0 -0
  287. package/src/asset/Textures/SocialSecond/tc_yuyin_bg_xinhao_b.png +0 -0
  288. package/src/asset/Textures/SocialSecond/tc_yuyin_star.png +0 -0
  289. package/src/asset/Textures/SocialSecond/tc_yuyin_stop.png +0 -0
  290. package/src/asset/Textures/SocialSecond/tc_zanshang_bg_line.png +0 -0
  291. package/src/asset/Textures/SocialSecond/touxiang_bg_tishikuang.png +0 -0
  292. package/src/asset/Textures/SocialSecond/xiangce_huadong.png +0 -0
  293. package/src/asset/Textures/SocialSecond/xiangce_huadong_xuanzhong.png +0 -0
  294. package/src/asset/Textures/SocialSecond/xiangce_icon_xiazai.png +0 -0
  295. package/src/asset/Textures/SocialVideo/com_home_btn_close.png +0 -0
  296. package/src/asset/Textures/SocialVideo/tc_shipin_bg_guodu.png +0 -0
  297. package/src/asset/Textures/SocialVideo/tc_shipin_jinduanjian.png +0 -0
  298. package/src/asset/Textures/SocialVideo/tc_shipin_jindutiao.png +0 -0
  299. package/src/asset/Textures/SocialVideo/tc_shipin_jindutiao_hui.png +0 -0
  300. package/src/asset/Textures/SocialVideo/tc_shipin_play.png +0 -0
  301. package/src/asset/Textures/SocialVideo/tc_shipin_play_big.png +0 -0
  302. package/src/asset/Textures/SocialVideo/tc_shipin_stop.png +0 -0
  303. package/src/asset/laugh.gif +0 -0
  304. package/src/asset/npms.png +0 -0
  305. package/src/asset/pixui.png +0 -0
  306. package/src/asset/preact.png +0 -0
  307. package/src/asset/template.html +0 -47
  308. package/src/common/frame/appsettings.js +0 -111
  309. package/src/common/frame/common.js +0 -17
  310. package/src/common/frame/platform-api-callback.js +0 -341
  311. package/src/common/frame/platform-api.d.ts +0 -156
  312. package/src/common/frame/platform-api.js +0 -479
  313. package/src/common/main.less +0 -119
  314. package/src/pixUIReactComponents/README.md +0 -8
  315. package/src/pixUIReactComponents/package.json +0 -11
  316. package/src/pixUIReactComponents/tsconfig.json +0 -45
  317. package/src/pixUIReactComponents/ui/sample/Slapface/SlapfaceDemo.tsx +0 -30
  318. package/src/pixUIReactUtils/GenerateConstructorAndGeterSeter.js +0 -227
  319. package/src/pixUIReactUtils/MakeImage.js +0 -207
  320. package/src/pixUIReactUtils/README.md +0 -124
  321. package/src/pixUIReactUtils/Version.js +0 -3
  322. package/src/pixUIReactUtils/img/makeImage.png +0 -0
  323. package/src/pixUIReactUtils/index.js +0 -1
  324. package/src/pixUIReactUtils/package.json +0 -16
  325. package/src/preprocess/index.html +0 -48
  326. package/src/preprocess/main.tsx +0 -17
  327. package/src/preprocess/preprocesspage.tsx +0 -41
  328. /package/{src/pixUIReactComponents/cmdAfterTsBuild.js → cmdAfterTsBuild.js} +0 -0
  329. /package/{src/pixUIReactComponents/index.js → index.js} +0 -0
  330. /package/{src/pixUIReactComponents/tools → tools}/EventDispatcherJs.tsx +0 -0
  331. /package/{src/pixUIReactComponents/tools → tools}/Logger.tsx +0 -0
  332. /package/{src/pixUIReactComponents/tools → tools}/img/logger.png +0 -0
  333. /package/{src/pixUIReactComponents/tools → tools}/tools.md +0 -0
  334. /package/{src/pixUIReactComponents/ui → ui}/components/bulletscreen/BulletItemAnimation.tsx +0 -0
  335. /package/{src/pixUIReactComponents/ui → ui}/components/bulletscreen/BulletScreenAnimation.tsx +0 -0
  336. /package/{src/pixUIReactComponents/ui → ui}/components/bulletscreen/bullet.less +0 -0
  337. /package/{src/pixUIReactComponents/ui → ui}/components/button/Button.tsx +0 -0
  338. /package/{src/pixUIReactComponents/ui → ui}/components/carousel/Carousel.tsx +0 -0
  339. /package/{src/pixUIReactComponents/ui → ui}/components/checkBox/CheckBox.tsx +0 -0
  340. /package/{src/pixUIReactComponents/ui → ui}/components/dropdown/Dropdown.tsx +0 -0
  341. /package/{src/pixUIReactComponents/ui → ui}/components/dropdown/DropdownOptionUI.tsx +0 -0
  342. /package/{src/pixUIReactComponents/ui → ui}/components/dropdown/DropdownSpreadMainUI.tsx +0 -0
  343. /package/{src/pixUIReactComponents/ui → ui}/components/dropdown/DropdownUnspreadMainUI.tsx +0 -0
  344. /package/{src/pixUIReactComponents/ui → ui}/components/gradient/GradientText.tsx +0 -0
  345. /package/{src/pixUIReactComponents/ui → ui}/components/outlinetext/OutlineText.tsx +0 -0
  346. /package/{src/pixUIReactComponents/ui → ui}/components/progress/Progress.tsx +0 -0
  347. /package/{src/pixUIReactComponents/ui → ui}/components/slapface/less/Slapface.less +0 -0
  348. /package/{src/pixUIReactComponents/ui → ui}/components/slider/Slider.tsx +0 -0
  349. /package/{src/pixUIReactComponents/ui → ui}/components/tab/Tab.tsx +0 -0
  350. /package/{src/pixUIReactComponents/ui → ui}/components/tab/Tabs.tsx +0 -0
  351. /package/{src/pixUIReactComponents/ui → ui}/components/togglegroup/ToggleGroup.tsx +0 -0
  352. /package/{src/pixUIReactComponents/ui → ui}/components/videoplayer/VideoPlayer.tsx +0 -0
  353. /package/{src/pixUIReactComponents/ui → ui}/components/waterfallcomponent/WaterfallComponent.jsx +0 -0
  354. /package/{src/pixUIReactComponents/ui → ui}/components/waterfallcomponent/less/WaterfallComponent.less +0 -0
  355. /package/{src/pixUIReactComponents/ui → ui}/sample/Images.tsx +0 -0
  356. /package/{src/pixUIReactComponents/ui → ui}/sample/OutlineText/OutlineDemo.tsx +0 -0
  357. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/btn_close.png +0 -0
  358. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/changtai_button.jpg +0 -0
  359. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/checkbox0.png +0 -0
  360. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/checkbox1.png +0 -0
  361. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/data_arrow_down.png +0 -0
  362. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/data_arrow_up.png +0 -0
  363. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/dot.png +0 -0
  364. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/inner.png +0 -0
  365. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/item_reddot.png +0 -0
  366. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/loading.png +0 -0
  367. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/money_dropdown.png +0 -0
  368. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/money_dropdownall.png +0 -0
  369. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/outer.png +0 -0
  370. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/slapface_samplepic1.png +0 -0
  371. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/slapface_samplepic2.png +0 -0
  372. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/slapface_samplepic3.png +0 -0
  373. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/slapface_samplepic4.png +0 -0
  374. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/slapface_samplepic5.png +0 -0
  375. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/slapface_samplepic6.png +0 -0
  376. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/tab_choosed.png +0 -0
  377. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/tabs_bg.png +0 -0
  378. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/video_pause.png +0 -0
  379. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/video_play.png +0 -0
  380. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/video_reload.png +0 -0
  381. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/xuanfu_button.jpg +0 -0
  382. /package/{src/pixUIReactComponents/ui → ui}/sample/asset/yaxia_button.jpg +0 -0
  383. /package/{src/pixUIReactComponents/ui → ui}/sample/bulletscreen/BulletDemo.tsx +0 -0
  384. /package/{src/pixUIReactComponents/ui → ui}/sample/button/ButtonDemo.tsx +0 -0
  385. /package/{src/pixUIReactComponents/ui → ui}/sample/carousel/carouselDemo.tsx +0 -0
  386. /package/{src/pixUIReactComponents/ui → ui}/sample/checkBox/checkBoxDemo.tsx +0 -0
  387. /package/{src/pixUIReactComponents/ui → ui}/sample/dropdown/DropdownDemo.tsx +0 -0
  388. /package/{src/pixUIReactComponents/ui → ui}/sample/dropdown/MoneyDropdownOption.tsx +0 -0
  389. /package/{src/pixUIReactComponents/ui → ui}/sample/dropdown/MoneyDropdownSpreadMain.tsx +0 -0
  390. /package/{src/pixUIReactComponents/ui → ui}/sample/dropdown/MoneyDropdownUnspreadMain.tsx +0 -0
  391. /package/{src/pixUIReactComponents/ui → ui}/sample/gradient/GradientDemo.tsx +0 -0
  392. /package/{src/pixUIReactComponents/ui → ui}/sample/less/video.less +0 -0
  393. /package/{src/pixUIReactComponents/ui → ui}/sample/progress/ProgressDemo.tsx +0 -0
  394. /package/{src/pixUIReactComponents/ui → ui}/sample/slider/SliderDemo.tsx +0 -0
  395. /package/{src/pixUIReactComponents/ui → ui}/sample/tab/TabDemo.tsx +0 -0
  396. /package/{src/pixUIReactComponents/ui → ui}/sample/tab/TopTab.tsx +0 -0
  397. /package/{src/pixUIReactComponents/ui → ui}/sample/togglegroup/ToggleGroupDemo.tsx +0 -0
  398. /package/{src/pixUIReactComponents/ui → ui}/sample/videoplayer/VideoPlayerDemo.tsx +0 -0
  399. /package/{src/pixUIReactComponents/ui → ui}/sample/waterfallcomponent/WaterfallComponentDemo.jsx +0 -0
  400. /package/{src/pixUIReactComponents/ui → ui}/ui.md +0 -0
@@ -1,1336 +0,0 @@
1
- import React, { createRef, forwardRef, PureComponent } from 'react';
2
- import ReactDOM from 'react-dom';
3
- import ReactTestRenderer from 'react-test-renderer';
4
- import ReactTestUtils from 'react-dom/test-utils';
5
- import { FixedSizeGrid } from '..';
6
- import * as domHelpers from '../domHelpers';
7
-
8
- const findScrollContainer = rendered => rendered.root.children[0].children[0];
9
-
10
- const simulateScroll = (instance, { scrollLeft, scrollTop }) => {
11
- instance._outerRef.scrollLeft = scrollLeft;
12
- instance._outerRef.scrollTop = scrollTop;
13
- ReactTestUtils.Simulate.scroll(instance._outerRef);
14
- };
15
-
16
- describe('FixedSizeGrid', () => {
17
- let defaultProps, getScrollbarSize, itemRenderer, onItemsRendered;
18
-
19
- // Use PureComponent to test memoization.
20
- // Pass through to itemRenderer mock for easier test assertions.
21
- class PureItemRenderer extends PureComponent {
22
- render() {
23
- return itemRenderer(this.props);
24
- }
25
- }
26
-
27
- beforeEach(() => {
28
- jest.useFakeTimers();
29
-
30
- // JSdom does not do actual layout and so doesn't return meaningful values here.
31
- // For the purposes of our tests though, we can mock out semi-meaningful values.
32
- // This mock is required for e.g. "onScroll" tests to work properly.
33
- Object.defineProperties(HTMLElement.prototype, {
34
- clientWidth: {
35
- configurable: true,
36
- get: function() {
37
- return parseInt(this.style.width, 10) || 0;
38
- },
39
- },
40
- clientHeight: {
41
- configurable: true,
42
- get: function() {
43
- return parseInt(this.style.height, 10) || 0;
44
- },
45
- },
46
- scrollHeight: {
47
- configurable: true,
48
- get: () => Number.MAX_SAFE_INTEGER,
49
- },
50
- scrollWidth: {
51
- configurable: true,
52
- get: () => Number.MAX_SAFE_INTEGER,
53
- },
54
- });
55
-
56
- // Mock the DOM helper util for testing purposes.
57
- getScrollbarSize = domHelpers.getScrollbarSize = jest.fn(() => 0);
58
-
59
- onItemsRendered = jest.fn();
60
-
61
- itemRenderer = jest.fn(({ style, ...rest }) => (
62
- <div style={style}>{JSON.stringify(rest, null, 2)}</div>
63
- ));
64
- defaultProps = {
65
- children: PureItemRenderer,
66
- columnCount: 100,
67
- columnWidth: 100,
68
- height: 100,
69
- onItemsRendered,
70
- rowCount: 100,
71
- rowHeight: 25,
72
- width: 200,
73
- };
74
- });
75
-
76
- it('should render an empty grid', () => {
77
- ReactTestRenderer.create(
78
- <FixedSizeGrid {...defaultProps} columnCount={0} rowCount={0} />
79
- );
80
- ReactTestRenderer.create(
81
- <FixedSizeGrid {...defaultProps} columnCount={0} />
82
- );
83
- ReactTestRenderer.create(<FixedSizeGrid {...defaultProps} rowCount={0} />);
84
- expect(itemRenderer).not.toHaveBeenCalled();
85
- expect(onItemsRendered).not.toHaveBeenCalled();
86
- });
87
-
88
- it('should render a grid of items', () => {
89
- ReactTestRenderer.create(<FixedSizeGrid {...defaultProps} />);
90
- expect(itemRenderer).toHaveBeenCalledTimes(15);
91
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
92
- });
93
-
94
- describe('style caching', () => {
95
- it('should cache styles while scrolling to avoid breaking pure sCU for items', () => {
96
- const rendered = ReactTestRenderer.create(
97
- <FixedSizeGrid {...defaultProps} />
98
- );
99
- // Scroll a few times.
100
- // Each time, make sure to render row 3, column 1.
101
- rendered
102
- .getInstance()
103
- .scrollToItem({ columnIndex: 1, rowIndex: 1, align: 'start' });
104
- rendered
105
- .getInstance()
106
- .scrollToItem({ columnIndex: 1, rowIndex: 2, align: 'start' });
107
- rendered
108
- .getInstance()
109
- .scrollToItem({ columnIndex: 1, rowIndex: 3, align: 'start' });
110
- // Find all of the times row 3, column 1 was rendered.
111
- // If we are caching props correctly, it should only be once.
112
- expect(
113
- itemRenderer.mock.calls.filter(
114
- ([params]) => params.rowIndex === 3 && params.columnIndex === 1
115
- )
116
- ).toHaveLength(1);
117
- });
118
-
119
- it('should reset cached styles when scrolling stops', () => {
120
- // Use ReactDOM renderer so the container ref and "onScroll" event work correctly.
121
- const instance = ReactDOM.render(
122
- <FixedSizeGrid {...defaultProps} useIsScrolling />,
123
- document.createElement('div')
124
- );
125
- // Scroll, then capture the rendered style for item 1,
126
- // Then let the debounce timer clear the cached styles.
127
- simulateScroll(instance, { scrollLeft: 100, scrollTop: 25 });
128
- expect(itemRenderer).toHaveBeenCalled();
129
- const itemOneArgsA = itemRenderer.mock.calls.find(
130
- ([params]) => params.columnIndex === 1 && params.rowIndex === 1
131
- );
132
- jest.runAllTimers();
133
- itemRenderer.mockClear();
134
- // Scroll again, then capture the rendered style for item 1,
135
- // And confirm that the style was recreated.
136
- simulateScroll(instance, { scrollLeft: 0, scrollTop: 0 });
137
- expect(itemRenderer).toHaveBeenCalled();
138
- const itemOneArgsB = itemRenderer.mock.calls.find(
139
- ([params]) => params.columnIndex === 1 && params.rowIndex === 1
140
- );
141
- expect(itemOneArgsA[0].style).not.toBe(itemOneArgsB[0].style);
142
- });
143
- });
144
-
145
- it('changing item size updates the rendered items', () => {
146
- const rendered = ReactTestRenderer.create(
147
- <FixedSizeGrid {...defaultProps} />
148
- );
149
- rendered.update(<FixedSizeGrid {...defaultProps} columnWidth={150} />);
150
- rendered.update(
151
- <FixedSizeGrid {...defaultProps} columnWidth={150} rowHeight={50} />
152
- );
153
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
154
- });
155
-
156
- it('changing itemSize updates the rendered items and busts the style cache', () => {
157
- const rendered = ReactTestRenderer.create(
158
- <FixedSizeGrid {...defaultProps} />
159
- );
160
- const styleOne = itemRenderer.mock.calls[0][0].style;
161
- itemRenderer.mockClear();
162
- rendered.update(<FixedSizeGrid {...defaultProps} columnWidth={150} />);
163
- expect(itemRenderer).toHaveBeenCalled();
164
- const styleTwo = itemRenderer.mock.calls[0][0].style;
165
- expect(styleOne).not.toBe(styleTwo);
166
- itemRenderer.mockClear();
167
- rendered.update(
168
- <FixedSizeGrid {...defaultProps} columnWidth={150} rowHeight={50} />
169
- );
170
- const styleThree = itemRenderer.mock.calls[0][0].style;
171
- expect(styleTwo).not.toBe(styleThree);
172
- });
173
-
174
- it('should support momentum scrolling on iOS devices', () => {
175
- const rendered = ReactTestRenderer.create(
176
- <FixedSizeGrid {...defaultProps} />
177
- );
178
- expect(rendered.toJSON().props.style.WebkitOverflowScrolling).toBe('touch');
179
- });
180
-
181
- it('should disable pointer events while scrolling', () => {
182
- const rendered = ReactTestRenderer.create(
183
- <FixedSizeGrid {...defaultProps} />
184
- );
185
- const scrollContainer = findScrollContainer(rendered);
186
- expect(scrollContainer.props.style.pointerEvents).toBe(undefined);
187
- rendered.getInstance().setState({ isScrolling: true });
188
- expect(scrollContainer.props.style.pointerEvents).toBe('none');
189
- });
190
-
191
- describe('style overrides', () => {
192
- it('should support className prop', () => {
193
- const rendered = ReactTestRenderer.create(
194
- <FixedSizeGrid {...defaultProps} className="custom" />
195
- );
196
- expect(rendered.toJSON().props.className).toBe('custom');
197
- });
198
-
199
- it('should support style prop', () => {
200
- const rendered = ReactTestRenderer.create(
201
- <FixedSizeGrid {...defaultProps} style={{ backgroundColor: 'red' }} />
202
- );
203
- expect(rendered.toJSON().props.style.backgroundColor).toBe('red');
204
- });
205
- });
206
-
207
- describe('direction', () => {
208
- it('should set the appropriate CSS direction style', () => {
209
- const renderer = ReactTestRenderer.create(
210
- <FixedSizeGrid {...defaultProps} direction="ltr" />
211
- );
212
- expect(renderer.toJSON().props.style.direction).toBe('ltr');
213
- renderer.update(<FixedSizeGrid {...defaultProps} direction="rtl" />);
214
- expect(renderer.toJSON().props.style.direction).toBe('rtl');
215
- });
216
-
217
- it('should position items correctly', () => {
218
- const renderer = ReactTestRenderer.create(
219
- <FixedSizeGrid {...defaultProps} direction="ltr" />
220
- );
221
-
222
- let params = itemRenderer.mock.calls[0][0];
223
- expect(params.columnIndex).toBe(0);
224
- expect(params.rowIndex).toBe(0);
225
- let style = params.style;
226
- expect(style.left).toBe(0);
227
- expect(style.right).toBeUndefined();
228
-
229
- itemRenderer.mockClear();
230
-
231
- renderer.update(<FixedSizeGrid {...defaultProps} direction="rtl" />);
232
-
233
- params = itemRenderer.mock.calls[0][0];
234
- expect(params.columnIndex).toBe(0);
235
- expect(params.rowIndex).toBe(0);
236
- style = params.style;
237
- expect(style.left).toBeUndefined();
238
- expect(style.right).toBe(0);
239
- });
240
- });
241
-
242
- describe('overscanColumnCount and overscanRowCount', () => {
243
- it('should require a minimum of 1 overscan to support tabbing', () => {
244
- ReactTestRenderer.create(
245
- <FixedSizeGrid
246
- {...defaultProps}
247
- initialScrollLeft={250}
248
- initialScrollTop={250}
249
- overscanColumnCount={0}
250
- overscanRowCount={0}
251
- />
252
- );
253
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
254
- });
255
-
256
- it('should overscan in the direction being scrolled', () => {
257
- const rendered = ReactTestRenderer.create(
258
- <FixedSizeGrid
259
- {...defaultProps}
260
- initialScrollLeft={250}
261
- initialScrollTop={250}
262
- overscanColumnCount={2}
263
- overscanRowCount={2}
264
- />
265
- );
266
- rendered.getInstance().scrollTo({ scrollLeft: 1000, scrollTop: 1000 });
267
- rendered.getInstance().scrollTo({ scrollLeft: 500, scrollTop: 500 });
268
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
269
- });
270
-
271
- it('should overscan in both directions when not scrolling', () => {
272
- ReactTestRenderer.create(
273
- <FixedSizeGrid
274
- {...defaultProps}
275
- initialScrollLeft={250}
276
- initialScrollTop={250}
277
- overscanColumnCount={2}
278
- overscanRowCount={2}
279
- />
280
- );
281
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
282
- });
283
-
284
- it('should accommodate a custom overscan', () => {
285
- ReactTestRenderer.create(
286
- <FixedSizeGrid
287
- {...defaultProps}
288
- initialScrollLeft={250}
289
- initialScrollTop={250}
290
- overscanColumnCount={2}
291
- overscanRowCount={2}
292
- />
293
- );
294
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
295
- });
296
-
297
- it('should not scan past the beginning of the grid', () => {
298
- ReactTestRenderer.create(<FixedSizeGrid {...defaultProps} />);
299
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
300
- });
301
-
302
- it('should not scan past the end of the grid', () => {
303
- ReactTestRenderer.create(
304
- <FixedSizeGrid
305
- {...defaultProps}
306
- columnCount={10}
307
- initialScrollLeft={900}
308
- initialScrollTop={150}
309
- rowCount={10}
310
- />
311
- );
312
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
313
- });
314
-
315
- describe('overscanCount', () => {
316
- it('should warn about deprecated overscanCount prop', () => {
317
- spyOn(console, 'warn');
318
-
319
- const renderer = ReactTestRenderer.create(
320
- <FixedSizeGrid {...defaultProps} overscanCount={1} />
321
- );
322
- expect(console.warn).toHaveBeenCalledTimes(1);
323
- expect(console.warn).toHaveBeenLastCalledWith(
324
- 'The overscanCount prop has been deprecated. ' +
325
- 'Please use the overscanColumnCount and overscanRowCount props instead.'
326
- );
327
-
328
- renderer.update(<FixedSizeGrid {...defaultProps} overscanCount={1} />);
329
-
330
- // But it should only warn once.
331
- expect(console.warn).toHaveBeenCalledTimes(1);
332
- });
333
-
334
- it('should warn about deprecated overscanRowsCount or overscanColumnsCount prop', () => {
335
- spyOn(console, 'warn');
336
-
337
- const renderer = ReactTestRenderer.create(
338
- <FixedSizeGrid
339
- {...defaultProps}
340
- overscanRowsCount={1}
341
- overscanColumnsCount={1}
342
- />
343
- );
344
- expect(console.warn).toHaveBeenCalledTimes(1);
345
- expect(console.warn).toHaveBeenLastCalledWith(
346
- 'The overscanColumnsCount and overscanRowsCount props have been deprecated. ' +
347
- 'Please use the overscanColumnCount and overscanRowCount props instead.'
348
- );
349
-
350
- renderer.update(
351
- <FixedSizeGrid
352
- {...defaultProps}
353
- overscanRowsCount={1}
354
- overscanColumnsCount={1}
355
- />
356
- );
357
-
358
- // But it should only warn once.
359
- expect(console.warn).toHaveBeenCalledTimes(1);
360
- });
361
-
362
- it('should use overscanColumnsCount if both it and overscanCount are provided', () => {
363
- spyOn(console, 'warn');
364
-
365
- ReactTestRenderer.create(
366
- <FixedSizeGrid
367
- {...defaultProps}
368
- initialScrollLeft={100}
369
- initialScrollTop={100}
370
- overscanColumnsCount={3}
371
- overscanCount={2}
372
- />
373
- );
374
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
375
- });
376
-
377
- it('should use overscanRowCount if both it and overscanCount are provided', () => {
378
- spyOn(console, 'warn');
379
-
380
- ReactTestRenderer.create(
381
- <FixedSizeGrid
382
- {...defaultProps}
383
- initialScrollLeft={100}
384
- initialScrollTop={100}
385
- overscanCount={2}
386
- overscanRowCount={3}
387
- />
388
- );
389
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
390
- });
391
-
392
- it('should use overscanColumnCount and overscanRowCount if both them and deprecated props are provided', () => {
393
- spyOn(console, 'warn');
394
-
395
- ReactTestRenderer.create(
396
- <FixedSizeGrid
397
- {...defaultProps}
398
- initialScrollLeft={100}
399
- initialScrollTop={100}
400
- overscanCount={1}
401
- overscanColumnsCount={2}
402
- overscanColumnCount={3}
403
- overscanRowsCount={2}
404
- overscanRowCount={3}
405
- />
406
- );
407
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
408
- });
409
-
410
- it('should support deprecated overscanCount', () => {
411
- spyOn(console, 'warn');
412
-
413
- ReactTestRenderer.create(
414
- <FixedSizeGrid
415
- {...defaultProps}
416
- initialScrollLeft={100}
417
- initialScrollTop={100}
418
- overscanCount={2}
419
- />
420
- );
421
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
422
- });
423
-
424
- it('should support deprecated overscanColumnsCount and overscanRowsCount', () => {
425
- spyOn(console, 'warn');
426
-
427
- ReactTestRenderer.create(
428
- <FixedSizeGrid
429
- {...defaultProps}
430
- initialScrollLeft={100}
431
- initialScrollTop={100}
432
- overscanColumnsCount={2}
433
- overscanRowsCount={2}
434
- />
435
- );
436
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
437
- });
438
- });
439
- });
440
-
441
- describe('useIsScrolling', () => {
442
- it('should not pass an isScrolling param to children unless requested', () => {
443
- ReactTestRenderer.create(<FixedSizeGrid {...defaultProps} />);
444
- expect(itemRenderer.mock.calls[0][0].isScrolling).toBe(undefined);
445
- });
446
-
447
- it('should pass an isScrolling param to children if requested', () => {
448
- // Use ReactDOM renderer so the container ref and "onScroll" event work correctly.
449
- const instance = ReactDOM.render(
450
- <FixedSizeGrid {...defaultProps} useIsScrolling />,
451
- document.createElement('div')
452
- );
453
- expect(itemRenderer.mock.calls[0][0].isScrolling).toBe(false);
454
- itemRenderer.mockClear();
455
- simulateScroll(instance, { scrollLeft: 300, scrollTop: 400 });
456
- expect(itemRenderer.mock.calls[0][0].isScrolling).toBe(true);
457
- itemRenderer.mockClear();
458
- jest.runAllTimers();
459
- expect(itemRenderer.mock.calls[0][0].isScrolling).toBe(false);
460
- });
461
-
462
- it('should not re-render children unnecessarily if isScrolling param is not used', () => {
463
- // Use ReactDOM renderer so the container ref and "onScroll" event work correctly.
464
- const instance = ReactDOM.render(
465
- <FixedSizeGrid {...defaultProps} />,
466
- document.createElement('div')
467
- );
468
- simulateScroll(instance, { scrollLeft: 300, scrollTop: 400 });
469
- itemRenderer.mockClear();
470
- jest.runAllTimers();
471
- expect(itemRenderer).not.toHaveBeenCalled();
472
- });
473
- });
474
-
475
- describe('scrollTo method', () => {
476
- it('should not report isScrolling', () => {
477
- // Use ReactDOM renderer so the container ref and "onScroll" event work correctly.
478
- const instance = ReactDOM.render(
479
- <FixedSizeGrid {...defaultProps} useIsScrolling />,
480
- document.createElement('div')
481
- );
482
- itemRenderer.mockClear();
483
- instance.scrollTo({ scrollLeft: 100, scrollTop: 100 });
484
- expect(itemRenderer.mock.calls[0][0].isScrolling).toBe(false);
485
- });
486
-
487
- it('should allow only scrollLeft or scrollTop values to be specified', () => {
488
- const instance = ReactDOM.render(
489
- <FixedSizeGrid {...defaultProps} useIsScrolling />,
490
- document.createElement('div')
491
- );
492
-
493
- instance.scrollTo({ scrollLeft: 100, scrollTop: 100 });
494
- expect(onItemsRendered).toHaveBeenLastCalledWith(
495
- expect.objectContaining({
496
- visibleColumnStartIndex: 1,
497
- visibleColumnStopIndex: 2,
498
- visibleRowStartIndex: 4,
499
- visibleRowStopIndex: 7,
500
- })
501
- );
502
-
503
- itemRenderer.mockClear();
504
- instance.scrollTo({ scrollTop: 200 });
505
- expect(onItemsRendered).toHaveBeenCalled();
506
- expect(onItemsRendered).toHaveBeenLastCalledWith(
507
- expect.objectContaining({
508
- visibleColumnStartIndex: 1,
509
- visibleColumnStopIndex: 2,
510
- })
511
- );
512
-
513
- itemRenderer.mockClear();
514
- instance.scrollTo({ scrollLeft: 150 });
515
- expect(onItemsRendered).toHaveBeenCalled();
516
- expect(onItemsRendered).toHaveBeenLastCalledWith(
517
- expect.objectContaining({
518
- visibleRowStartIndex: 8,
519
- visibleRowStopIndex: 11,
520
- })
521
- );
522
- });
523
-
524
- it('should ignore offsets less than zero', () => {
525
- const onScroll = jest.fn();
526
- const instance = ReactDOM.render(
527
- <FixedSizeGrid {...defaultProps} onScroll={onScroll} />,
528
- document.createElement('div')
529
- );
530
- instance.scrollTo({ scrollLeft: 100, scrollTop: 100 });
531
- onScroll.mockClear();
532
- instance.scrollTo({ scrollLeft: -1, scrollTop: -1 });
533
- expect(onScroll.mock.calls[0][0].scrollLeft).toBe(0);
534
- expect(onScroll.mock.calls[0][0].scrollTop).toBe(0);
535
- });
536
- });
537
-
538
- describe('scrollToItem method', () => {
539
- it('should not set invalid offsets when the list contains few items', () => {
540
- const rendered = ReactTestRenderer.create(
541
- <FixedSizeGrid {...defaultProps} columnCount={1} rowCount={2} />
542
- );
543
- expect(onItemsRendered).toMatchSnapshot();
544
- onItemsRendered.mockClear();
545
- rendered.getInstance().scrollToItem(0);
546
- expect(onItemsRendered).not.toHaveBeenCalled();
547
- });
548
-
549
- it('should scroll to the correct item for align = "auto"', () => {
550
- const rendered = ReactTestRenderer.create(
551
- <FixedSizeGrid {...defaultProps} />
552
- );
553
- // Scroll down enough to show item 10 at the bottom.
554
- rendered
555
- .getInstance()
556
- .scrollToItem({ columnIndex: 10, rowIndex: 10, align: 'auto' });
557
- // No need to scroll again; item 9 is already visible.
558
- // Overscan indices will change though, since direction changes.
559
- rendered
560
- .getInstance()
561
- .scrollToItem({ columnIndex: 9, rowIndex: 9, align: 'auto' });
562
- // Scroll up enough to show item 2 at the top.
563
- rendered
564
- .getInstance()
565
- .scrollToItem({ columnIndex: 2, rowIndex: 2, align: 'auto' });
566
- // Scroll down to row 10, without changing scrollLeft
567
- rendered.getInstance().scrollToItem({ rowIndex: 10, align: 'auto' });
568
- // Scroll left to column 0, without changing scrollTop
569
- rendered.getInstance().scrollToItem({ columnIndex: 0, align: 'auto' });
570
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
571
- });
572
-
573
- it('scroll with align = "auto" should work with partially-visible items', () => {
574
- const rendered = ReactTestRenderer.create(
575
- // Create list where items don't fit exactly into container.
576
- // The container has space for 3 1/3 items.
577
- <FixedSizeGrid {...defaultProps} columnWidth={70} rowHeight={30} />
578
- );
579
- // Scroll down enough to show row 10 at the bottom a nd column 10 at the right.
580
- // Should show 4 rows: 3 full and one partial at the beginning
581
- // Should show 3 columns: 2 full and one partial at the beginning
582
- rendered
583
- .getInstance()
584
- .scrollToItem({ columnIndex: 10, rowIndex: 10, align: 'auto' });
585
- // No need to scroll again; row and column 9 are already visible.
586
- // Because there's no scrolling, it won't call onItemsRendered.
587
- rendered
588
- .getInstance()
589
- .scrollToItem({ columnIndex: 9, rowIndex: 9, align: 'auto' });
590
- // Scroll to near the end. row 96 and column 97 will be partly visible.
591
- rendered
592
- .getInstance()
593
- .scrollToItem({ columnIndex: 99, rowIndex: 99, align: 'auto' });
594
- // Scroll back to row 91 and column 97.
595
- // This will cause row 99 and column 99 to be partly viisble
596
- // Even though a scroll happened, none of the items rendered have changed.
597
- rendered
598
- .getInstance()
599
- .scrollToItem({ columnIndex: 97, rowIndex: 96, align: 'auto' });
600
- // Scroll forward again. Because row and column #99 were already partly visible,
601
- // all props of the onItemsRendered will be the same.
602
- rendered
603
- .getInstance()
604
- .scrollToItem({ columnIndex: 99, rowIndex: 99, align: 'auto' });
605
- // Scroll to the second row and column.
606
- // This should leave row 4 and column 3 partly visible.
607
- rendered
608
- .getInstance()
609
- .scrollToItem({ columnIndex: 1, rowIndex: 1, align: 'auto' });
610
- // Scroll to the first row and column.
611
- // This should leave row 3 and column 2 partly visible.
612
- rendered
613
- .getInstance()
614
- .scrollToItem({ columnIndex: 0, rowIndex: 0, align: 'auto' });
615
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
616
- });
617
-
618
- it('should scroll to the correct item for align = "auto" at the bottom of the grid', () => {
619
- getScrollbarSize.mockImplementation(() => 20);
620
-
621
- const rendered = ReactTestRenderer.create(
622
- <FixedSizeGrid {...defaultProps} rowCount={20} rowHeight={30} />
623
- );
624
- onItemsRendered.mockClear();
625
-
626
- // Scroll down to the last row in the list.
627
- rendered
628
- .getInstance()
629
- .scrollToItem({ columnIndex: 5, rowIndex: 19, align: 'auto' });
630
-
631
- expect(onItemsRendered).toHaveBeenCalledTimes(1);
632
- expect(onItemsRendered).toHaveBeenLastCalledWith(
633
- expect.objectContaining({
634
- visibleRowStartIndex: 17,
635
- visibleRowStopIndex: 19,
636
- })
637
- );
638
- // Repeat the previous scrollToItem call.
639
- rendered
640
- .getInstance()
641
- .scrollToItem({ columnIndex: 5, rowIndex: 19, align: 'auto' });
642
-
643
- // Shouldn't have been called again
644
- expect(onItemsRendered).toHaveBeenCalledTimes(1);
645
- expect(onItemsRendered).toHaveBeenLastCalledWith(
646
- expect.objectContaining({
647
- visibleRowStartIndex: 17,
648
- visibleRowStopIndex: 19,
649
- })
650
- );
651
- });
652
-
653
- it('should scroll to the correct item for align = "auto" at the right hand side of the grid', () => {
654
- getScrollbarSize.mockImplementation(() => 20);
655
-
656
- const rendered = ReactTestRenderer.create(
657
- <FixedSizeGrid
658
- {...defaultProps}
659
- columnCount={20}
660
- columnWidth={50}
661
- width={120}
662
- />
663
- );
664
- onItemsRendered.mockClear();
665
-
666
- // Scroll across to the last row in the list.
667
- rendered
668
- .getInstance()
669
- .scrollToItem({ columnIndex: 19, rowIndex: 19, align: 'auto' });
670
-
671
- expect(onItemsRendered).toHaveBeenCalledTimes(1);
672
- expect(onItemsRendered).toHaveBeenLastCalledWith(
673
- expect.objectContaining({
674
- visibleColumnStartIndex: 18,
675
- visibleColumnStopIndex: 19,
676
- })
677
- );
678
- // Repeat the previous scrollToItem call.
679
- rendered
680
- .getInstance()
681
- .scrollToItem({ columnIndex: 19, rowIndex: 19, align: 'auto' });
682
-
683
- // Shouldn't have been called again
684
- expect(onItemsRendered).toHaveBeenCalledTimes(1);
685
- expect(onItemsRendered).toHaveBeenLastCalledWith(
686
- expect.objectContaining({
687
- visibleColumnStartIndex: 18,
688
- visibleColumnStopIndex: 19,
689
- })
690
- );
691
- });
692
-
693
- it('should scroll to the correct item for align = "start"', () => {
694
- const rendered = ReactTestRenderer.create(
695
- <FixedSizeGrid {...defaultProps} />
696
- );
697
- // Scroll down enough to show item 10 at the top.
698
- rendered
699
- .getInstance()
700
- .scrollToItem({ columnIndex: 10, rowIndex: 10, align: 'start' });
701
- // Scroll back up so that item 9 is at the top.
702
- // Overscroll direction wil change too.
703
- rendered
704
- .getInstance()
705
- .scrollToItem({ columnIndex: 9, rowIndex: 9, align: 'start' });
706
- // Item 99 can't align at the top because there aren't enough items.
707
- // Scroll down as far as possible though.
708
- // Overscroll direction wil change again.
709
- rendered
710
- .getInstance()
711
- .scrollToItem({ columnIndex: 99, rowIndex: 99, align: 'start' });
712
- // Scroll up to row 10, without changing scrollLeft
713
- rendered.getInstance().scrollToItem({ rowIndex: 10, align: 'start' });
714
- // Scroll left to column 0, without changing scrollTop
715
- rendered.getInstance().scrollToItem({ columnIndex: 0, align: 'start' });
716
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
717
- });
718
-
719
- it('should scroll to the correct item for align = "end"', () => {
720
- const rendered = ReactTestRenderer.create(
721
- <FixedSizeGrid {...defaultProps} />
722
- );
723
- // Scroll down enough to show item 10 at the bottom.
724
- rendered
725
- .getInstance()
726
- .scrollToItem({ columnIndex: 10, rowIndex: 10, align: 'end' });
727
- // Scroll back up so that item 9 is at the bottom.
728
- // Overscroll direction wil change too.
729
- rendered
730
- .getInstance()
731
- .scrollToItem({ columnIndex: 9, rowIndex: 9, align: 'end' });
732
- // Item 1 can't align at the bottom because it's too close to the beginning.
733
- // Scroll up as far as possible though.
734
- // Overscroll direction wil change again.
735
- rendered
736
- .getInstance()
737
- .scrollToItem({ columnIndex: 1, rowIndex: 1, align: 'end' });
738
- // Scroll down to row 10, without changing scrollLeft
739
- rendered.getInstance().scrollToItem({ rowIndex: 10, align: 'end' });
740
- // Scroll right to column 9, without changing scrollTop
741
- rendered.getInstance().scrollToItem({ columnIndex: 9, align: 'end' });
742
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
743
- });
744
-
745
- it('should scroll to the correct item for align = "center"', () => {
746
- const rendered = ReactTestRenderer.create(
747
- <FixedSizeGrid {...defaultProps} />
748
- );
749
- // Scroll down enough to show item 10 in the middle.
750
- rendered
751
- .getInstance()
752
- .scrollToItem({ columnIndex: 10, rowIndex: 10, align: 'center' });
753
- // Scroll back up so that item 9 is in the middle.
754
- // Overscroll direction wil change too.
755
- rendered
756
- .getInstance()
757
- .scrollToItem({ columnIndex: 9, rowIndex: 9, align: 'center' });
758
- // Item 1 can't align in the middle because it's too close to the beginning.
759
- // Scroll up as far as possible though.
760
- // Overscroll direction wil change again.
761
- rendered
762
- .getInstance()
763
- .scrollToItem({ columnIndex: 1, rowIndex: 1, align: 'center' });
764
- // Item 99 can't align in the middle because it's too close to the end.
765
- // Scroll down as far as possible though.
766
- // Overscroll direction wil change again.
767
- rendered
768
- .getInstance()
769
- .scrollToItem({ columnIndex: 99, rowIndex: 99, align: 'center' });
770
- // Scroll up to row 10, without changing scrollLeft
771
- rendered.getInstance().scrollToItem({ rowIndex: 10, align: 'center' });
772
- // Scroll left to column 3, without changing scrollTop
773
- rendered.getInstance().scrollToItem({ columnIndex: 3, align: 'center' });
774
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
775
- });
776
-
777
- it('should scroll to the correct item for align = "smart"', () => {
778
- const rendered = ReactTestRenderer.create(
779
- <FixedSizeGrid {...defaultProps} />
780
- );
781
-
782
- // Scroll down enough to show item 10 at the center.
783
- // It was further than one screen away, so it gets centered.
784
- rendered
785
- .getInstance()
786
- .scrollToItem({ columnIndex: 10, rowIndex: 10, align: 'smart' });
787
- // No need to scroll again; item 9 is already visible.
788
- // Overscan indices will change though, since direction changes.
789
- rendered
790
- .getInstance()
791
- .scrollToItem({ columnIndex: 9, rowIndex: 9, align: 'smart' });
792
- // Scroll up enough to show item 2 as close to the center as we can.
793
- rendered
794
- .getInstance()
795
- .scrollToItem({ columnIndex: 2, rowIndex: 2, align: 'smart' });
796
- // Scroll down to row 10, without changing scrollLeft
797
- rendered.getInstance().scrollToItem({ rowIndex: 10, align: 'smart' });
798
- // Scroll left to column 0, without changing scrollTop
799
- rendered.getInstance().scrollToItem({ columnIndex: 0, align: 'smart' });
800
-
801
- // Scrolling within a distance of a single screen from viewport
802
- // should have the 'auto' behavior of scrolling as little as possible.
803
- rendered
804
- .getInstance()
805
- .scrollToItem({ columnIndex: 5, rowIndex: 5, align: 'smart' });
806
- rendered
807
- .getInstance()
808
- .scrollToItem({ columnIndex: 10, rowIndex: 10, align: 'smart' });
809
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
810
- });
811
-
812
- it('should not report isScrolling', () => {
813
- // Use ReactDOM renderer so the container ref and "onScroll" event work correctly.
814
- const instance = ReactDOM.render(
815
- <FixedSizeGrid {...defaultProps} useIsScrolling />,
816
- document.createElement('div')
817
- );
818
- itemRenderer.mockClear();
819
- instance.scrollToItem({ columnIndex: 15, rowIndex: 20 });
820
- expect(itemRenderer.mock.calls[0][0].isScrolling).toBe(false);
821
- });
822
-
823
- it('should account for scrollbar size', () => {
824
- const onScroll = jest.fn();
825
- const rendered = ReactTestRenderer.create(
826
- <FixedSizeGrid
827
- {...defaultProps}
828
- columnWidth={100}
829
- height={150}
830
- rowHeight={25}
831
- width={300}
832
- onScroll={onScroll}
833
- />
834
- );
835
-
836
- onScroll.mockClear();
837
- rendered
838
- .getInstance()
839
- .scrollToItem({ columnIndex: 15, rowIndex: 10, align: 'end' });
840
-
841
- // With hidden scrollbars (size === 0) we would expect...
842
- expect(onScroll).toHaveBeenCalledWith({
843
- horizontalScrollDirection: 'forward',
844
- scrollLeft: 1300,
845
- scrollTop: 125,
846
- scrollUpdateWasRequested: true,
847
- verticalScrollDirection: 'forward',
848
- });
849
-
850
- getScrollbarSize.mockImplementation(() => 20);
851
-
852
- onScroll.mockClear();
853
- rendered
854
- .getInstance()
855
- .scrollToItem({ columnIndex: 15, rowIndex: 10, align: 'end' });
856
-
857
- // With scrollbars of size 20 we would expect those values ot increase by 20px
858
- expect(onScroll).toHaveBeenCalledWith({
859
- horizontalScrollDirection: 'forward',
860
- scrollLeft: 1320,
861
- scrollTop: 145,
862
- scrollUpdateWasRequested: true,
863
- verticalScrollDirection: 'forward',
864
- });
865
- });
866
-
867
- it('should not account for scrollbar size when no scrollbar is visible for a particular direction', () => {
868
- getScrollbarSize.mockImplementation(() => 20);
869
-
870
- const onScroll = jest.fn();
871
- const rendered = ReactTestRenderer.create(
872
- <FixedSizeGrid
873
- {...defaultProps}
874
- columnCount={2}
875
- columnWidth={100}
876
- height={150}
877
- rowHeight={25}
878
- width={300}
879
- onScroll={onScroll}
880
- />
881
- );
882
-
883
- onScroll.mockClear();
884
- rendered
885
- .getInstance()
886
- .scrollToItem({ columnIndex: 0, rowIndex: 10, align: 'end' });
887
-
888
- // Since there aren't enough columns to require horizontal scrolling,
889
- // the additional 20px for the scrollbar should not be taken into consideration.
890
- expect(onScroll).toHaveBeenCalledWith({
891
- horizontalScrollDirection: 'backward',
892
- scrollLeft: 0,
893
- scrollTop: 125,
894
- scrollUpdateWasRequested: true,
895
- verticalScrollDirection: 'forward',
896
- });
897
-
898
- rendered.update(
899
- <FixedSizeGrid
900
- {...defaultProps}
901
- columnWidth={100}
902
- height={150}
903
- rowCount={4}
904
- rowHeight={25}
905
- width={300}
906
- onScroll={onScroll}
907
- />
908
- );
909
-
910
- onScroll.mockClear();
911
- rendered
912
- .getInstance()
913
- .scrollToItem({ columnIndex: 15, rowIndex: 0, align: 'end' });
914
-
915
- // Since there aren't enough rows to require vertical scrolling,
916
- // the additional 20px for the scrollbar should not be taken into consideration.
917
- expect(onScroll).toHaveBeenCalledWith({
918
- horizontalScrollDirection: 'forward',
919
- scrollLeft: 1300,
920
- scrollTop: 0,
921
- scrollUpdateWasRequested: true,
922
- verticalScrollDirection: 'backward',
923
- });
924
- });
925
-
926
- it('should ignore indexes less than zero', () => {
927
- const instance = ReactDOM.render(
928
- <FixedSizeGrid {...defaultProps} />,
929
- document.createElement('div')
930
- );
931
- instance.scrollToItem({ columnIndex: 20, rowIndex: 20 });
932
- onItemsRendered.mockClear();
933
- instance.scrollToItem({ columnIndex: -1, rowIndex: -1 });
934
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
935
- });
936
-
937
- it('should ignore indexes greater than itemCount', () => {
938
- const instance = ReactDOM.render(
939
- <FixedSizeGrid {...defaultProps} />,
940
- document.createElement('div')
941
- );
942
- onItemsRendered.mockClear();
943
- instance.scrollToItem({
944
- columnIndex: defaultProps.columnCount * 2,
945
- rowIndex: defaultProps.rowCount * 2,
946
- });
947
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
948
- });
949
- });
950
-
951
- // onItemsRendered is pretty well covered by other snapshot tests
952
- describe('onScroll', () => {
953
- it('should call onScroll after mount', () => {
954
- const onScroll = jest.fn();
955
- ReactTestRenderer.create(
956
- <FixedSizeGrid {...defaultProps} onScroll={onScroll} />
957
- );
958
- expect(onScroll.mock.calls).toMatchSnapshot();
959
- });
960
-
961
- it('should call onScroll when scroll position changes', () => {
962
- const onScroll = jest.fn();
963
- const rendered = ReactTestRenderer.create(
964
- <FixedSizeGrid {...defaultProps} onScroll={onScroll} />
965
- );
966
- rendered.getInstance().scrollTo({
967
- scrollLeft: 100,
968
- scrollTop: 50,
969
- });
970
- rendered.getInstance().scrollTo({
971
- scrollLeft: 0,
972
- scrollTop: 150,
973
- });
974
- rendered.getInstance().scrollTo({
975
- scrollLeft: 150,
976
- scrollTop: 0,
977
- });
978
- expect(onScroll.mock.calls).toMatchSnapshot();
979
- });
980
-
981
- it('should distinguish between "onScroll" events and scrollTo() calls', () => {
982
- const onScroll = jest.fn();
983
- // Use ReactDOM renderer so the container ref and "onScroll" event work correctly.
984
- const instance = ReactDOM.render(
985
- <FixedSizeGrid {...defaultProps} onScroll={onScroll} />,
986
- document.createElement('div')
987
- );
988
-
989
- onScroll.mockClear();
990
- instance.scrollTo({ scrollLeft: 100, scrollTop: 100 });
991
- expect(onScroll.mock.calls[0][0].scrollUpdateWasRequested).toBe(true);
992
-
993
- onScroll.mockClear();
994
- simulateScroll(instance, { scrollLeft: 200, scrollTop: 200 });
995
- expect(onScroll.mock.calls[0][0].scrollUpdateWasRequested).toBe(false);
996
- });
997
-
998
- it('scrolling should report partial items correctly in onItemsRendered', () => {
999
- // Use ReactDOM renderer so the container ref works correctly.
1000
- const instance = ReactDOM.render(
1001
- <FixedSizeGrid
1002
- {...defaultProps}
1003
- initialScrollLeft={20}
1004
- initialScrollTop={10}
1005
- />,
1006
- document.createElement('div')
1007
- );
1008
- // grid 200w x 100h
1009
- // columnWidth: 100, rowHeight: 25,
1010
- // columnCount: 100, rowCount: 100
1011
- // Scroll 2 items fwd, but thanks to the initialScrollOffset, we should
1012
- // still be showing partials on both ends.
1013
- instance.scrollTo({ scrollLeft: 150, scrollTop: 40 });
1014
- // Scroll a little fwd to cause partials to be hidden
1015
- instance.scrollTo({ scrollLeft: 200, scrollTop: 50 });
1016
- // Scroll backwards to show partials again
1017
- instance.scrollTo({ scrollLeft: 150, scrollTop: 40 });
1018
- // Scroll near the end so that the last item is shown
1019
- // as a partial.
1020
- instance.scrollTo({
1021
- scrollLeft: 98 * 100 - 5,
1022
- scrollTop: 96 * 25 - 5,
1023
- });
1024
- // Scroll to the end. No partials.
1025
- instance.scrollTo({
1026
- scrollLeft: 98 * 100,
1027
- scrollTop: 96 * 25,
1028
- });
1029
- // Verify that backwards scrolling near the end works OK.
1030
- instance.scrollTo({
1031
- scrollLeft: 98 * 100 - 5,
1032
- scrollTop: 96 * 25 - 5,
1033
- });
1034
- expect(onItemsRendered.mock.calls).toMatchSnapshot();
1035
- });
1036
- });
1037
-
1038
- describe('itemKey', () => {
1039
- it('should be used', () => {
1040
- const itemKey = jest.fn(
1041
- ({ columnIndex, rowIndex }) => `${rowIndex}:${columnIndex}`
1042
- );
1043
- ReactTestRenderer.create(
1044
- <FixedSizeGrid
1045
- {...defaultProps}
1046
- columnCount={3}
1047
- rowCount={2}
1048
- itemKey={itemKey}
1049
- />
1050
- );
1051
- expect(itemKey).toHaveBeenCalledTimes(6);
1052
- expect(itemKey.mock.calls[0][0]).toEqual({ columnIndex: 0, rowIndex: 0 });
1053
- expect(itemKey.mock.calls[1][0]).toEqual({ columnIndex: 1, rowIndex: 0 });
1054
- expect(itemKey.mock.calls[2][0]).toEqual({ columnIndex: 2, rowIndex: 0 });
1055
- expect(itemKey.mock.calls[3][0]).toEqual({ columnIndex: 0, rowIndex: 1 });
1056
- expect(itemKey.mock.calls[4][0]).toEqual({ columnIndex: 1, rowIndex: 1 });
1057
- expect(itemKey.mock.calls[5][0]).toEqual({ columnIndex: 2, rowIndex: 1 });
1058
- });
1059
-
1060
- it('should allow items to be moved within the collection without causing caching problems', () => {
1061
- const keyMap = [['0:0', '0:1:', '0:2'], ['1:0', '1:1:', '1:2']];
1062
- const keyMapItemRenderer = jest.fn(({ index, style }) => (
1063
- <div style={style}>{keyMap[index]}</div>
1064
- ));
1065
- class ItemRenderer extends PureComponent {
1066
- render() {
1067
- return keyMapItemRenderer(this.props);
1068
- }
1069
- }
1070
- const itemKey = jest.fn(
1071
- ({ columnIndex, rowIndex }) => keyMap[rowIndex][columnIndex]
1072
- );
1073
- const rendered = ReactTestRenderer.create(
1074
- <FixedSizeGrid
1075
- {...defaultProps}
1076
- columnCount={3}
1077
- rowCount={2}
1078
- itemKey={itemKey}
1079
- >
1080
- {ItemRenderer}
1081
- </FixedSizeGrid>
1082
- );
1083
- expect(itemKey).toHaveBeenCalledTimes(6);
1084
- itemKey.mockClear();
1085
-
1086
- expect(keyMapItemRenderer).toHaveBeenCalledTimes(6);
1087
- keyMapItemRenderer.mockClear();
1088
-
1089
- // Simulate swapping the first and last items.
1090
- keyMap[0][0] = '1:2';
1091
- keyMap[1][2] = '0:0';
1092
-
1093
- rendered.getInstance().forceUpdate();
1094
-
1095
- // Our key getter should be called again for each key.
1096
- // Since we've modified the map, the first and last key will swap.
1097
- expect(itemKey).toHaveBeenCalledTimes(6);
1098
-
1099
- // The first and third item have swapped place,
1100
- // So they should have been re-rendered,
1101
- // But the second item should not.
1102
- expect(keyMapItemRenderer).toHaveBeenCalledTimes(2);
1103
- expect(keyMapItemRenderer.mock.calls[0][0].columnIndex).toBe(0);
1104
- expect(keyMapItemRenderer.mock.calls[0][0].rowIndex).toBe(0);
1105
- expect(keyMapItemRenderer.mock.calls[1][0].columnIndex).toBe(2);
1106
- expect(keyMapItemRenderer.mock.calls[1][0].rowIndex).toBe(1);
1107
- });
1108
-
1109
- it('should receive a data value if itemData is provided', () => {
1110
- const itemKey = jest.fn(
1111
- ({ columnIndex, data, rowIndex }) => `${columnIndex}-${rowIndex}`
1112
- );
1113
- const itemData = {};
1114
- ReactTestRenderer.create(
1115
- <FixedSizeGrid
1116
- {...defaultProps}
1117
- itemData={itemData}
1118
- itemKey={itemKey}
1119
- />
1120
- );
1121
- expect(itemKey).toHaveBeenCalled();
1122
- expect(
1123
- itemKey.mock.calls.filter(([params]) => params.data === itemData)
1124
- ).toHaveLength(itemKey.mock.calls.length);
1125
- });
1126
- });
1127
-
1128
- describe('refs', () => {
1129
- it('should pass through innerRef and outerRef ref functions', () => {
1130
- const innerRef = jest.fn();
1131
- const outerRef = jest.fn();
1132
- ReactDOM.render(
1133
- <FixedSizeGrid
1134
- {...defaultProps}
1135
- innerRef={innerRef}
1136
- outerRef={outerRef}
1137
- />,
1138
- document.createElement('div')
1139
- );
1140
- expect(innerRef).toHaveBeenCalled();
1141
- expect(innerRef.mock.calls[0][0]).toBeInstanceOf(HTMLDivElement);
1142
- expect(outerRef).toHaveBeenCalled();
1143
- expect(outerRef.mock.calls[0][0]).toBeInstanceOf(HTMLDivElement);
1144
- });
1145
-
1146
- it('should pass through innerRef and outerRef createRef objects', () => {
1147
- const innerRef = createRef();
1148
- const outerRef = createRef();
1149
- ReactDOM.render(
1150
- <FixedSizeGrid
1151
- {...defaultProps}
1152
- innerRef={innerRef}
1153
- outerRef={outerRef}
1154
- />,
1155
- document.createElement('div')
1156
- );
1157
- expect(innerRef.current).toBeInstanceOf(HTMLDivElement);
1158
- expect(outerRef.current).toBeInstanceOf(HTMLDivElement);
1159
- });
1160
- });
1161
-
1162
- describe('custom element types', () => {
1163
- it('should use a custom innerElementType if specified', () => {
1164
- const rendered = ReactTestRenderer.create(
1165
- <FixedSizeGrid {...defaultProps} innerElementType="section" />
1166
- );
1167
- expect(rendered.root.findByType('section')).toBeDefined();
1168
- });
1169
-
1170
- it('should use a custom outerElementType if specified', () => {
1171
- const rendered = ReactTestRenderer.create(
1172
- <FixedSizeGrid {...defaultProps} outerElementType="section" />
1173
- );
1174
- expect(rendered.root.findByType('section')).toBeDefined();
1175
- });
1176
-
1177
- it('should support spreading additional, arbitrary props, e.g. id', () => {
1178
- const container = document.createElement('div');
1179
- ReactDOM.render(
1180
- <FixedSizeGrid
1181
- {...defaultProps}
1182
- innerElementType={forwardRef((props, ref) => (
1183
- <div ref={ref} id="inner" {...props} />
1184
- ))}
1185
- outerElementType={forwardRef((props, ref) => (
1186
- <div ref={ref} id="outer" {...props} />
1187
- ))}
1188
- />,
1189
- container
1190
- );
1191
- expect(container.firstChild.id).toBe('outer');
1192
- expect(container.firstChild.firstChild.id).toBe('inner');
1193
- });
1194
-
1195
- it('should warn if legacy innerTagName or outerTagName props are used', () => {
1196
- spyOn(console, 'warn');
1197
- const renderer = ReactTestRenderer.create(
1198
- <FixedSizeGrid
1199
- {...defaultProps}
1200
- innerTagName="div"
1201
- outerTagName="div"
1202
- />
1203
- );
1204
- expect(console.warn).toHaveBeenCalledTimes(1);
1205
- expect(console.warn).toHaveBeenLastCalledWith(
1206
- 'The innerTagName and outerTagName props have been deprecated. ' +
1207
- 'Please use the innerElementType and outerElementType props instead.'
1208
- );
1209
-
1210
- renderer.update(
1211
- <FixedSizeGrid
1212
- {...defaultProps}
1213
- innerTagName="div"
1214
- outerTagName="div"
1215
- />
1216
- );
1217
-
1218
- // But it should only warn once.
1219
- expect(console.warn).toHaveBeenCalledTimes(1);
1220
- });
1221
- });
1222
-
1223
- describe('itemData', () => {
1224
- it('should pass itemData to item renderers as a "data" prop', () => {
1225
- const itemData = {};
1226
- ReactTestRenderer.create(
1227
- <FixedSizeGrid {...defaultProps} itemData={itemData} />
1228
- );
1229
- expect(itemRenderer).toHaveBeenCalled();
1230
- expect(
1231
- itemRenderer.mock.calls.filter(([params]) => params.data === itemData)
1232
- ).toHaveLength(itemRenderer.mock.calls.length);
1233
- });
1234
-
1235
- it('should re-render items if itemData changes', () => {
1236
- const itemData = {};
1237
- const rendered = ReactTestRenderer.create(
1238
- <FixedSizeGrid {...defaultProps} itemData={itemData} />
1239
- );
1240
- expect(itemRenderer).toHaveBeenCalled();
1241
- itemRenderer.mockClear();
1242
-
1243
- // Re-rendering should not affect pure sCU children:
1244
- rendered.update(<FixedSizeGrid {...defaultProps} itemData={itemData} />);
1245
- expect(itemRenderer).not.toHaveBeenCalled();
1246
-
1247
- // Re-rendering with new itemData should re-render children:
1248
- const newItemData = {};
1249
- rendered.update(
1250
- <FixedSizeGrid {...defaultProps} itemData={newItemData} />
1251
- );
1252
- expect(itemRenderer).toHaveBeenCalled();
1253
- expect(
1254
- itemRenderer.mock.calls.filter(
1255
- ([params]) => params.data === newItemData
1256
- )
1257
- ).toHaveLength(itemRenderer.mock.calls.length);
1258
- });
1259
- });
1260
-
1261
- describe('props validation', () => {
1262
- beforeEach(() => spyOn(console, 'error'));
1263
-
1264
- it('should fail if non-numeric columnWidth is provided', () => {
1265
- expect(() =>
1266
- ReactTestRenderer.create(
1267
- <FixedSizeGrid {...defaultProps} columnWidth="abc" />
1268
- )
1269
- ).toThrow(
1270
- 'An invalid "columnWidth" prop has been specified. ' +
1271
- 'Value should be a number. ' +
1272
- '"string" was specified.'
1273
- );
1274
- });
1275
-
1276
- it('should fail if non-numeric rowHeight is provided', () => {
1277
- expect(() =>
1278
- ReactTestRenderer.create(
1279
- <FixedSizeGrid {...defaultProps} rowHeight="abc" />
1280
- )
1281
- ).toThrow(
1282
- 'An invalid "rowHeight" prop has been specified. ' +
1283
- 'Value should be a number. ' +
1284
- '"string" was specified.'
1285
- );
1286
- });
1287
-
1288
- it('should fail if no children value is provided', () => {
1289
- expect(() =>
1290
- ReactTestRenderer.create(
1291
- <FixedSizeGrid {...defaultProps} children={undefined} />
1292
- )
1293
- ).toThrow(
1294
- 'An invalid "children" prop has been specified. ' +
1295
- 'Value should be a React component. ' +
1296
- '"undefined" was specified.'
1297
- );
1298
- });
1299
-
1300
- it('should fail if an invalid direction is provided', () => {
1301
- expect(() =>
1302
- ReactTestRenderer.create(
1303
- <FixedSizeGrid {...defaultProps} direction={null} />
1304
- )
1305
- ).toThrow(
1306
- 'An invalid "direction" prop has been specified. ' +
1307
- 'Value should be either "ltr" or "rtl". ' +
1308
- '"null" was specified.'
1309
- );
1310
- });
1311
-
1312
- it('should fail if a string height is provided', () => {
1313
- expect(() =>
1314
- ReactTestRenderer.create(
1315
- <FixedSizeGrid {...defaultProps} height="100%" />
1316
- )
1317
- ).toThrow(
1318
- 'An invalid "height" prop has been specified. ' +
1319
- 'Grids must specify a number for height. ' +
1320
- '"string" was specified.'
1321
- );
1322
- });
1323
-
1324
- it('should fail if a string width is provided', () => {
1325
- expect(() =>
1326
- ReactTestRenderer.create(
1327
- <FixedSizeGrid {...defaultProps} width="100%" />
1328
- )
1329
- ).toThrow(
1330
- 'An invalid "width" prop has been specified. ' +
1331
- 'Grids must specify a number for width. ' +
1332
- '"string" was specified.'
1333
- );
1334
- });
1335
- });
1336
- });