@enact/ui 3.4.9-experimental-3 → 3.4.9-experimental-7

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 (464) hide show
  1. package/{build/A11yDecorator → A11yDecorator}/A11yDecorator.d.ts +0 -0
  2. package/A11yDecorator/A11yDecorator.js +79 -75
  3. package/A11yDecorator/tests/A11yDecorator-specs.js +90 -128
  4. package/AnnounceDecorator/Announce.js +136 -80
  5. package/{build/AnnounceDecorator → AnnounceDecorator}/AnnounceDecorator.d.ts +0 -0
  6. package/AnnounceDecorator/AnnounceDecorator.js +68 -53
  7. package/AnnounceDecorator/tests/Announce-specs.js +29 -35
  8. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +34 -36
  9. package/AnnounceDecorator/tests/useAnnounce-specs.js +56 -63
  10. package/AnnounceDecorator/useAnnounce.js +29 -18
  11. package/{build/BodyText → BodyText}/BodyText.d.ts +0 -0
  12. package/BodyText/BodyText.js +108 -96
  13. package/{build/BodyText → BodyText}/BodyText.module.css +0 -0
  14. package/BodyText/tests/BodyText-specs.js +67 -76
  15. package/{build/Button → Button}/Button.d.ts +0 -0
  16. package/Button/Button.js +236 -215
  17. package/{build/Button → Button}/Button.module.css +0 -0
  18. package/CHANGELOG.md +18 -0
  19. package/{build/Cancelable → Cancelable}/Cancelable.d.ts +0 -0
  20. package/Cancelable/Cancelable.js +213 -184
  21. package/Cancelable/cancelHandler.js +36 -29
  22. package/Cancelable/modalHandler.js +35 -23
  23. package/Cancelable/tests/Cancelable-specs.js +289 -381
  24. package/{build/Changeable → Changeable}/Changeable.d.ts +0 -0
  25. package/Changeable/Changeable.js +137 -161
  26. package/Changeable/tests/Changeable-specs.js +262 -327
  27. package/{build/ComponentOverride → ComponentOverride}/ComponentOverride.d.ts +0 -0
  28. package/ComponentOverride/ComponentOverride.js +21 -24
  29. package/FloatingLayer/FloatingLayer.js +310 -261
  30. package/FloatingLayer/FloatingLayerDecorator.js +150 -99
  31. package/FloatingLayer/Scrim.js +167 -99
  32. package/{build/FloatingLayer → FloatingLayer}/Scrim.module.css +0 -0
  33. package/FloatingLayer/index.js +39 -12
  34. package/FloatingLayer/tests/FloatingLayer-specs.js +24 -27
  35. package/FloatingLayer/tests/Scrim-specs.js +21 -24
  36. package/FloatingLayer/useFloatingLayer.js +46 -18
  37. package/{build/ForwardRef → ForwardRef}/ForwardRef.d.ts +0 -0
  38. package/ForwardRef/ForwardRef.js +35 -34
  39. package/{build/GridListImageItem → GridListImageItem}/GridListImageItem.d.ts +0 -0
  40. package/GridListImageItem/GridListImageItem.js +244 -212
  41. package/{build/GridListImageItem → GridListImageItem}/GridListImageItem.module.css +0 -0
  42. package/{build/Group → Group}/Group.d.ts +0 -0
  43. package/Group/Group.js +186 -168
  44. package/Group/GroupItem.js +83 -79
  45. package/Group/tests/Group-specs.js +128 -164
  46. package/{build/Heading → Heading}/Heading.d.ts +0 -0
  47. package/Heading/Heading.js +146 -128
  48. package/{build/Heading → Heading}/Heading.module.css +0 -0
  49. package/Heading/tests/Heading-specs.js +46 -54
  50. package/{build/Icon → Icon}/Icon.d.ts +0 -0
  51. package/Icon/Icon.js +200 -189
  52. package/{build/Icon → Icon}/Icon.module.css +0 -0
  53. package/Icon/tests/Icon-specs.js +92 -126
  54. package/{build/IconButton → IconButton}/IconButton.d.ts +0 -0
  55. package/IconButton/IconButton.js +213 -181
  56. package/{build/IconButton → IconButton}/IconButton.module.css +0 -0
  57. package/{build/Image → Image}/Image.d.ts +0 -0
  58. package/Image/Image.js +186 -151
  59. package/{build/Image → Image}/Image.module.css +0 -0
  60. package/Image/tests/Image-specs.js +49 -51
  61. package/{build/ImageItem → ImageItem}/ImageItem.d.ts +0 -0
  62. package/ImageItem/ImageItem.js +165 -149
  63. package/{build/ImageItem → ImageItem}/ImageItem.module.css +0 -0
  64. package/ImageItem/tests/ImageItem-specs.js +128 -161
  65. package/{build/Item → Item}/Item.d.ts +0 -0
  66. package/Item/Item.js +131 -121
  67. package/{build/Item → Item}/Item.module.css +0 -0
  68. package/Item/tests/Item-specs.js +71 -88
  69. package/{build/LabeledIcon → LabeledIcon}/LabeledIcon.d.ts +0 -0
  70. package/LabeledIcon/LabeledIcon.js +235 -216
  71. package/{build/LabeledIcon → LabeledIcon}/LabeledIcon.module.css +0 -0
  72. package/LabeledIcon/tests/LabeledIcon-specs.js +49 -58
  73. package/Layout/Cell.js +181 -146
  74. package/{build/Layout → Layout}/Layout.d.ts +0 -0
  75. package/Layout/Layout.js +193 -282
  76. package/{build/Layout → Layout}/Layout.module.css +0 -0
  77. package/Layout/tests/Layout-specs.js +102 -109
  78. package/{build/Marquee → Marquee}/Marquee.module.css +0 -0
  79. package/Marquee/MarqueeBase.js +275 -240
  80. package/Marquee/MarqueeController.js +327 -292
  81. package/Marquee/MarqueeDecorator.js +990 -898
  82. package/{build/Marquee → Marquee}/index.d.ts +0 -0
  83. package/Marquee/index.js +39 -14
  84. package/Marquee/tests/Marquee-specs.js +274 -382
  85. package/{build/Measurable → Measurable}/Measurable.d.ts +0 -0
  86. package/Measurable/Measurable.js +133 -100
  87. package/{build/Media → Media}/Media.d.ts +0 -0
  88. package/Media/Media.js +317 -254
  89. package/Placeholder/PlaceholderControllerDecorator.js +188 -133
  90. package/Placeholder/PlaceholderDecorator.js +147 -95
  91. package/{build/Placeholder → Placeholder}/index.d.ts +0 -0
  92. package/Placeholder/index.js +27 -9
  93. package/{build/ProgressBar → ProgressBar}/ProgressBar.d.ts +0 -0
  94. package/ProgressBar/ProgressBar.js +183 -173
  95. package/{build/ProgressBar → ProgressBar}/ProgressBar.module.css +0 -0
  96. package/ProgressBar/tests/ProgressBar-specs.js +80 -109
  97. package/RadioDecorator/RadioControllerDecorator.js +104 -54
  98. package/{build/RadioDecorator → RadioDecorator}/RadioDecorator.d.ts +0 -0
  99. package/RadioDecorator/RadioDecorator.js +176 -117
  100. package/RadioDecorator/tests/RadioDecorator-specs.js +155 -166
  101. package/{build/Repeater → Repeater}/Repeater.d.ts +0 -0
  102. package/Repeater/Repeater.js +157 -133
  103. package/Repeater/tests/Repeater-specs.js +136 -155
  104. package/{build/Resizable → Resizable}/Resizable.d.ts +0 -0
  105. package/Resizable/Resizable.js +145 -101
  106. package/Routable/Link.js +65 -61
  107. package/{build/Routable → Routable}/Routable.d.ts +0 -0
  108. package/Routable/Routable.js +148 -109
  109. package/Routable/Route.js +37 -27
  110. package/Routable/Router.js +236 -171
  111. package/Routable/tests/Router-specs.js +194 -196
  112. package/Routable/util.js +78 -68
  113. package/Scrollable/ScrollAnimator.js +138 -112
  114. package/Scrollable/ScrollThumb.js +52 -42
  115. package/{build/Scrollable → Scrollable}/ScrollThumb.module.css +0 -0
  116. package/{build/Scrollable → Scrollable}/Scrollable.d.ts +0 -0
  117. package/Scrollable/Scrollable.js +1591 -1443
  118. package/{build/Scrollable → Scrollable}/Scrollable.module.css +0 -0
  119. package/Scrollable/ScrollableNative.js +1599 -1445
  120. package/Scrollable/Scrollbar.js +312 -221
  121. package/{build/Scrollable → Scrollable}/Scrollbar.module.css +0 -0
  122. package/{build/Scroller → Scroller}/Scroller.d.ts +0 -0
  123. package/Scroller/Scroller.js +249 -242
  124. package/{build/Scroller → Scroller}/Scroller.module.css +0 -0
  125. package/Scroller/ScrollerBasic.js +311 -230
  126. package/{build/Scroller → Scroller}/UiScroller.module.css +0 -0
  127. package/Scroller/UiScrollerBase.js +253 -184
  128. package/{build/Skinnable → Skinnable}/Skinnable.d.ts +0 -0
  129. package/Skinnable/Skinnable.js +182 -172
  130. package/Skinnable/tests/Skinnable-specs.js +388 -416
  131. package/Skinnable/tests/useSkins-specs.js +290 -281
  132. package/Skinnable/tests/util-specs.js +107 -113
  133. package/Skinnable/useSkins.js +51 -28
  134. package/Skinnable/util.js +80 -75
  135. package/Slider/Knob.js +85 -71
  136. package/Slider/PositionDecorator.js +232 -162
  137. package/{build/Slider → Slider}/Slider.d.ts +0 -0
  138. package/Slider/Slider.js +331 -312
  139. package/{build/Slider → Slider}/Slider.module.css +0 -0
  140. package/Slider/utils.js +16 -11
  141. package/{build/SlotItem → SlotItem}/SlotItem.d.ts +0 -0
  142. package/SlotItem/SlotItem.js +199 -179
  143. package/{build/SlotItem → SlotItem}/SlotItem.module.css +0 -0
  144. package/{build/Slottable → Slottable}/Slottable.d.ts +0 -0
  145. package/Slottable/Slottable.js +62 -48
  146. package/Slottable/tests/Slottable-specs.js +232 -284
  147. package/Slottable/tests/useSlots-specs.js +277 -313
  148. package/Slottable/useSlots.js +113 -90
  149. package/{build/Spinner → Spinner}/Spinner.d.ts +0 -0
  150. package/Spinner/Spinner.js +213 -178
  151. package/{build/Spinner → Spinner}/Spinner.module.css +0 -0
  152. package/Spinner/tests/Spinner-specs.js +61 -77
  153. package/{build/ToggleIcon → ToggleIcon}/ToggleIcon.d.ts +0 -0
  154. package/ToggleIcon/ToggleIcon.js +134 -123
  155. package/{build/ToggleIcon → ToggleIcon}/ToggleIcon.module.css +0 -0
  156. package/ToggleIcon/tests/ToggleIcon-specs.js +52 -71
  157. package/{build/ToggleItem → ToggleItem}/ToggleItem.d.ts +0 -0
  158. package/ToggleItem/ToggleItem.js +263 -264
  159. package/{build/ToggleItem → ToggleItem}/ToggleItem.module.css +0 -0
  160. package/ToggleItem/tests/ToggleItem-specs.js +87 -87
  161. package/Toggleable/Toggle.js +70 -43
  162. package/{build/Toggleable → Toggleable}/Toggleable.d.ts +0 -0
  163. package/Toggleable/Toggleable.js +219 -244
  164. package/Toggleable/tests/Toggleable-specs.js +416 -549
  165. package/Toggleable/useToggle.js +50 -24
  166. package/Touchable/ClickAllow.js +67 -49
  167. package/Touchable/Drag.js +199 -170
  168. package/Touchable/Flick.js +152 -122
  169. package/Touchable/Hold.js +259 -214
  170. package/{build/Touchable → Touchable}/Touchable.d.ts +0 -0
  171. package/Touchable/Touchable.js +643 -651
  172. package/Touchable/config.js +63 -44
  173. package/Touchable/state.js +31 -14
  174. package/Touchable/tests/Touchable-specs.js +462 -526
  175. package/{build/Transition → Transition}/Transition.d.ts +0 -0
  176. package/Transition/Transition.js +606 -553
  177. package/{build/Transition → Transition}/Transition.module.css +0 -0
  178. package/Transition/tests/Transition-specs.js +123 -138
  179. package/ViewManager/Arranger.js +82 -40
  180. package/ViewManager/TransitionGroup.js +502 -419
  181. package/ViewManager/View.js +383 -298
  182. package/{build/ViewManager → ViewManager}/ViewManager.d.ts +0 -0
  183. package/ViewManager/ViewManager.js +352 -296
  184. package/ViewManager/tests/View-specs.js +176 -275
  185. package/ViewManager/tests/ViewManager-specs.js +524 -471
  186. package/ViewManager/tests/test-utils.js +44 -23
  187. package/{build/VirtualList → VirtualList}/UiVirtualList.module.css +0 -0
  188. package/VirtualList/UiVirtualListBase.js +1381 -1171
  189. package/{build/VirtualList → VirtualList}/VirtualList.d.ts +0 -0
  190. package/VirtualList/VirtualList.js +541 -537
  191. package/{build/VirtualList → VirtualList}/VirtualList.module.css +0 -0
  192. package/VirtualList/VirtualListBase.js +37 -10
  193. package/VirtualList/VirtualListBasic.js +1468 -1241
  194. package/VirtualList/tests/VirtualList-specs.js +314 -345
  195. package/{build/index.d.ts → index.d.ts} +0 -0
  196. package/index.js +1 -0
  197. package/{build/internal → internal}/IdProvider/IdProvider.d.ts +0 -0
  198. package/internal/IdProvider/IdProvider.js +76 -54
  199. package/internal/IdProvider/Provider.js +67 -41
  200. package/internal/IdProvider/tests/useId-specs.js +64 -78
  201. package/internal/IdProvider/useId.js +27 -15
  202. package/{build/internal → internal}/Pure/Pure.d.ts +0 -0
  203. package/internal/Pure/Pure.js +98 -65
  204. package/{build/internal → internal}/localized-fonts/localized-fonts.d.ts +0 -0
  205. package/internal/localized-fonts/localized-fonts.js +179 -159
  206. package/{build/internal → internal}/selection/selection.d.ts +0 -0
  207. package/internal/selection/selection.js +49 -40
  208. package/internal/selection/tests/selection-specs.js +158 -253
  209. package/{build/internal → internal}/validators/validators.d.ts +0 -0
  210. package/internal/validators/validators.js +103 -55
  211. package/package.json +2 -2
  212. package/resolution/ResolutionDecorator.js +150 -97
  213. package/{build/resolution → resolution}/index.d.ts +0 -0
  214. package/resolution/index.js +39 -7
  215. package/resolution/resolution.js +232 -183
  216. package/resolution/tests/ResolutionDecorator-specs.js +42 -48
  217. package/resolution/tests/resolution-specs.js +90 -91
  218. package/useControlledState/tests/useControlledState-specs.js +100 -76
  219. package/{build/useControlledState → useControlledState}/useControlledState.d.ts +0 -0
  220. package/useControlledState/useControlledState.js +56 -38
  221. package/useScroll/ScrollAnimator.js +138 -112
  222. package/useScroll/Scrollbar.js +199 -175
  223. package/{build/useScroll → useScroll}/Scrollbar.module.css +0 -0
  224. package/useScroll/ScrollbarTrack.js +46 -28
  225. package/{build/useScroll → useScroll}/ScrollbarTrack.module.css +0 -0
  226. package/{build/useScroll → useScroll}/useScroll.d.ts +0 -0
  227. package/useScroll/useScroll.js +1714 -1627
  228. package/{build/useScroll → useScroll}/useScroll.module.css +0 -0
  229. package/useScroll/utilDOM.js +62 -55
  230. package/useScroll/utilEvent.js +33 -28
  231. package/BodyText/BodyText.module.less +0 -11
  232. package/Button/Button.module.less +0 -57
  233. package/FloatingLayer/Scrim.module.less +0 -8
  234. package/GridListImageItem/GridListImageItem.module.less +0 -33
  235. package/Heading/Heading.module.less +0 -20
  236. package/Icon/Icon.module.less +0 -38
  237. package/IconButton/IconButton.module.less +0 -18
  238. package/Image/Image.module.less +0 -21
  239. package/ImageItem/ImageItem.module.less +0 -29
  240. package/Item/Item.module.less +0 -14
  241. package/LabeledIcon/LabeledIcon.module.less +0 -45
  242. package/Layout/Layout.module.less +0 -84
  243. package/Marquee/Marquee.module.less +0 -49
  244. package/ProgressBar/ProgressBar.module.less +0 -114
  245. package/Scrollable/ScrollThumb.module.less +0 -46
  246. package/Scrollable/Scrollable.module.less +0 -42
  247. package/Scrollable/Scrollbar.module.less +0 -35
  248. package/Scroller/Scroller.module.less +0 -10
  249. package/Scroller/UiScroller.module.less +0 -10
  250. package/Slider/Slider.module.less +0 -20
  251. package/SlotItem/SlotItem.module.less +0 -19
  252. package/Spinner/Spinner.module.less +0 -52
  253. package/ToggleIcon/ToggleIcon.module.less +0 -14
  254. package/ToggleItem/ToggleItem.module.less +0 -9
  255. package/Transition/Transition.module.less +0 -179
  256. package/VirtualList/UiVirtualList.module.less +0 -31
  257. package/VirtualList/VirtualList.module.less +0 -39
  258. package/build/A11yDecorator/A11yDecorator.js +0 -129
  259. package/build/A11yDecorator/package.json +0 -3
  260. package/build/A11yDecorator/tests/A11yDecorator-specs.js +0 -90
  261. package/build/AnnounceDecorator/Announce.js +0 -172
  262. package/build/AnnounceDecorator/AnnounceDecorator.js +0 -121
  263. package/build/AnnounceDecorator/package.json +0 -3
  264. package/build/AnnounceDecorator/tests/Announce-specs.js +0 -29
  265. package/build/AnnounceDecorator/tests/AnnounceDecorator-specs.js +0 -34
  266. package/build/AnnounceDecorator/tests/useAnnounce-specs.js +0 -56
  267. package/build/AnnounceDecorator/useAnnounce.js +0 -61
  268. package/build/BodyText/BodyText.js +0 -139
  269. package/build/BodyText/package.json +0 -3
  270. package/build/BodyText/tests/BodyText-specs.js +0 -67
  271. package/build/Button/Button.js +0 -283
  272. package/build/Button/package.json +0 -3
  273. package/build/CHANGELOG.md +0 -1089
  274. package/build/Cancelable/Cancelable.js +0 -271
  275. package/build/Cancelable/cancelHandler.js +0 -79
  276. package/build/Cancelable/modalHandler.js +0 -68
  277. package/build/Cancelable/package.json +0 -3
  278. package/build/Cancelable/tests/Cancelable-specs.js +0 -289
  279. package/build/Changeable/Changeable.js +0 -172
  280. package/build/Changeable/package.json +0 -3
  281. package/build/Changeable/tests/Changeable-specs.js +0 -262
  282. package/build/ComponentOverride/ComponentOverride.js +0 -68
  283. package/build/ComponentOverride/package.json +0 -3
  284. package/build/FloatingLayer/FloatingLayer.js +0 -339
  285. package/build/FloatingLayer/FloatingLayerDecorator.js +0 -174
  286. package/build/FloatingLayer/Scrim.js +0 -199
  287. package/build/FloatingLayer/index.js +0 -49
  288. package/build/FloatingLayer/tests/FloatingLayer-specs.js +0 -29
  289. package/build/FloatingLayer/tests/Scrim-specs.js +0 -26
  290. package/build/FloatingLayer/useFloatingLayer.js +0 -53
  291. package/build/ForwardRef/ForwardRef.js +0 -68
  292. package/build/ForwardRef/package.json +0 -3
  293. package/build/GridListImageItem/GridListImageItem.js +0 -257
  294. package/build/GridListImageItem/package.json +0 -3
  295. package/build/Group/Group.js +0 -217
  296. package/build/Group/GroupItem.js +0 -109
  297. package/build/Group/package.json +0 -3
  298. package/build/Group/tests/Group-specs.js +0 -128
  299. package/build/Heading/Heading.js +0 -158
  300. package/build/Heading/package.json +0 -3
  301. package/build/Heading/tests/Heading-specs.js +0 -46
  302. package/build/Icon/Icon.js +0 -234
  303. package/build/Icon/package.json +0 -3
  304. package/build/Icon/tests/Icon-specs.js +0 -92
  305. package/build/IconButton/IconButton.js +0 -252
  306. package/build/IconButton/package.json +0 -3
  307. package/build/Image/Image.js +0 -219
  308. package/build/Image/package.json +0 -3
  309. package/build/Image/tests/Image-specs.js +0 -55
  310. package/build/ImageItem/ImageItem.js +0 -180
  311. package/build/ImageItem/package.json +0 -3
  312. package/build/ImageItem/tests/ImageItem-specs.js +0 -133
  313. package/build/Item/Item.js +0 -166
  314. package/build/Item/package.json +0 -3
  315. package/build/Item/tests/Item-specs.js +0 -77
  316. package/build/LabeledIcon/LabeledIcon.js +0 -287
  317. package/build/LabeledIcon/package.json +0 -3
  318. package/build/LabeledIcon/tests/LabeledIcon-specs.js +0 -49
  319. package/build/Layout/Cell.js +0 -215
  320. package/build/Layout/Layout.js +0 -316
  321. package/build/Layout/package.json +0 -3
  322. package/build/Layout/tests/Layout-specs.js +0 -102
  323. package/build/Marquee/MarqueeBase.js +0 -307
  324. package/build/Marquee/MarqueeController.js +0 -346
  325. package/build/Marquee/MarqueeDecorator.js +0 -1029
  326. package/build/Marquee/index.js +0 -65
  327. package/build/Marquee/package.json +0 -3
  328. package/build/Marquee/tests/Marquee-specs.js +0 -275
  329. package/build/Measurable/Measurable.js +0 -163
  330. package/build/Measurable/package.json +0 -3
  331. package/build/Media/Media.js +0 -389
  332. package/build/Media/package.json +0 -3
  333. package/build/Placeholder/PlaceholderControllerDecorator.js +0 -210
  334. package/build/Placeholder/PlaceholderDecorator.js +0 -171
  335. package/build/Placeholder/index.js +0 -37
  336. package/build/Placeholder/package.json +0 -3
  337. package/build/ProgressBar/ProgressBar.js +0 -200
  338. package/build/ProgressBar/package.json +0 -3
  339. package/build/ProgressBar/tests/ProgressBar-specs.js +0 -80
  340. package/build/README.md +0 -45
  341. package/build/RadioDecorator/RadioControllerDecorator.js +0 -117
  342. package/build/RadioDecorator/RadioDecorator.js +0 -199
  343. package/build/RadioDecorator/package.json +0 -3
  344. package/build/RadioDecorator/tests/RadioDecorator-specs.js +0 -155
  345. package/build/Repeater/Repeater.js +0 -190
  346. package/build/Repeater/package.json +0 -3
  347. package/build/Repeater/tests/Repeater-specs.js +0 -141
  348. package/build/Resizable/Resizable.js +0 -179
  349. package/build/Resizable/package.json +0 -3
  350. package/build/Routable/Link.js +0 -78
  351. package/build/Routable/Routable.js +0 -170
  352. package/build/Routable/Route.js +0 -68
  353. package/build/Routable/Router.js +0 -248
  354. package/build/Routable/package.json +0 -3
  355. package/build/Routable/tests/Router-specs.js +0 -200
  356. package/build/Routable/util.js +0 -90
  357. package/build/Scrollable/ScrollAnimator.js +0 -146
  358. package/build/Scrollable/ScrollThumb.js +0 -63
  359. package/build/Scrollable/Scrollable.js +0 -1612
  360. package/build/Scrollable/ScrollableNative.js +0 -1619
  361. package/build/Scrollable/Scrollbar.js +0 -344
  362. package/build/Scrollable/package.json +0 -3
  363. package/build/Scroller/Scroller.js +0 -291
  364. package/build/Scroller/ScrollerBasic.js +0 -322
  365. package/build/Scroller/UiScrollerBase.js +0 -414
  366. package/build/Scroller/package.json +0 -3
  367. package/build/Skinnable/Skinnable.js +0 -224
  368. package/build/Skinnable/package.json +0 -3
  369. package/build/Skinnable/tests/Skinnable-specs.js +0 -388
  370. package/build/Skinnable/tests/useSkins-specs.js +0 -290
  371. package/build/Skinnable/tests/util-specs.js +0 -120
  372. package/build/Skinnable/useSkins.js +0 -134
  373. package/build/Skinnable/util.js +0 -106
  374. package/build/Slider/Knob.js +0 -100
  375. package/build/Slider/PositionDecorator.js +0 -234
  376. package/build/Slider/Slider.js +0 -380
  377. package/build/Slider/package.json +0 -3
  378. package/build/Slider/utils.js +0 -18
  379. package/build/SlotItem/SlotItem.js +0 -245
  380. package/build/SlotItem/package.json +0 -3
  381. package/build/Slottable/Slottable.js +0 -95
  382. package/build/Slottable/package.json +0 -3
  383. package/build/Slottable/tests/Slottable-specs.js +0 -238
  384. package/build/Slottable/tests/useSlots-specs.js +0 -282
  385. package/build/Slottable/useSlots.js +0 -183
  386. package/build/Spinner/Spinner.js +0 -247
  387. package/build/Spinner/package.json +0 -3
  388. package/build/Spinner/tests/Spinner-specs.js +0 -61
  389. package/build/ToggleIcon/ToggleIcon.js +0 -181
  390. package/build/ToggleIcon/package.json +0 -3
  391. package/build/ToggleIcon/tests/ToggleIcon-specs.js +0 -58
  392. package/build/ToggleItem/ToggleItem.js +0 -306
  393. package/build/ToggleItem/package.json +0 -3
  394. package/build/ToggleItem/tests/ToggleItem-specs.js +0 -100
  395. package/build/Toggleable/Toggle.js +0 -74
  396. package/build/Toggleable/Toggleable.js +0 -250
  397. package/build/Toggleable/package.json +0 -3
  398. package/build/Toggleable/tests/Toggleable-specs.js +0 -421
  399. package/build/Toggleable/useToggle.js +0 -91
  400. package/build/Touchable/ClickAllow.js +0 -78
  401. package/build/Touchable/Drag.js +0 -206
  402. package/build/Touchable/Flick.js +0 -156
  403. package/build/Touchable/Hold.js +0 -262
  404. package/build/Touchable/Touchable.js +0 -661
  405. package/build/Touchable/config.js +0 -147
  406. package/build/Touchable/package.json +0 -3
  407. package/build/Touchable/state.js +0 -36
  408. package/build/Touchable/tests/Touchable-specs.js +0 -470
  409. package/build/Transition/Transition.js +0 -634
  410. package/build/Transition/package.json +0 -3
  411. package/build/Transition/tests/Transition-specs.js +0 -123
  412. package/build/ViewManager/Arranger.js +0 -181
  413. package/build/ViewManager/TransitionGroup.js +0 -547
  414. package/build/ViewManager/View.js +0 -403
  415. package/build/ViewManager/ViewManager.js +0 -386
  416. package/build/ViewManager/package.json +0 -3
  417. package/build/ViewManager/tests/View-specs.js +0 -182
  418. package/build/ViewManager/tests/ViewManager-specs.js +0 -524
  419. package/build/ViewManager/tests/test-utils.js +0 -47
  420. package/build/VirtualList/UiVirtualListBase.js +0 -1566
  421. package/build/VirtualList/VirtualList.js +0 -582
  422. package/build/VirtualList/VirtualListBase.js +0 -37
  423. package/build/VirtualList/VirtualListBasic.js +0 -1503
  424. package/build/VirtualList/package.json +0 -3
  425. package/build/VirtualList/tests/VirtualList-specs.js +0 -314
  426. package/build/index.js +0 -2
  427. package/build/internal/IdProvider/IdProvider.js +0 -99
  428. package/build/internal/IdProvider/Provider.js +0 -67
  429. package/build/internal/IdProvider/package.json +0 -3
  430. package/build/internal/IdProvider/tests/useId-specs.js +0 -64
  431. package/build/internal/IdProvider/useId.js +0 -58
  432. package/build/internal/Pure/Pure.js +0 -133
  433. package/build/internal/Pure/package.json +0 -3
  434. package/build/internal/localized-fonts/localized-fonts.js +0 -272
  435. package/build/internal/localized-fonts/package.json +0 -3
  436. package/build/internal/selection/package.json +0 -3
  437. package/build/internal/selection/selection.js +0 -78
  438. package/build/internal/selection/tests/selection-specs.js +0 -158
  439. package/build/internal/validators/package.json +0 -4
  440. package/build/internal/validators/validators.js +0 -163
  441. package/build/package-lock.json +0 -234
  442. package/build/package.json +0 -39
  443. package/build/resolution/ResolutionDecorator.js +0 -183
  444. package/build/resolution/index.js +0 -47
  445. package/build/resolution/package.json +0 -3
  446. package/build/resolution/resolution.js +0 -529
  447. package/build/resolution/tests/ResolutionDecorator-specs.js +0 -42
  448. package/build/resolution/tests/resolution-specs.js +0 -90
  449. package/build/styles/core.less +0 -91
  450. package/build/styles/mixins.less +0 -444
  451. package/build/styles/variables.less +0 -7
  452. package/build/useControlledState/package.json +0 -3
  453. package/build/useControlledState/tests/useControlledState-specs.js +0 -100
  454. package/build/useControlledState/useControlledState.js +0 -68
  455. package/build/useScroll/ScrollAnimator.js +0 -146
  456. package/build/useScroll/Scrollbar.js +0 -238
  457. package/build/useScroll/ScrollbarTrack.js +0 -62
  458. package/build/useScroll/package.json +0 -3
  459. package/build/useScroll/useScroll.js +0 -1730
  460. package/build/useScroll/utilDOM.js +0 -65
  461. package/build/useScroll/utilEvent.js +0 -39
  462. package/useScroll/Scrollbar.module.less +0 -37
  463. package/useScroll/ScrollbarTrack.module.less +0 -48
  464. package/useScroll/useScroll.module.less +0 -44
@@ -1,66 +1,111 @@
1
- /**
2
- * Unstyled scrollable components and behaviors to be customized by a theme or application.
3
- *
4
- * @module ui/Scrollable
5
- * @exports constants
6
- * @exports Scrollable
7
- * @exports ScrollableBase
8
- * @private
9
- */
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ScrollableBase = exports.Scrollable = exports.constants = exports["default"] = void 0;
7
+
8
+ var _classnames = _interopRequireDefault(require("classnames"));
9
+
10
+ var _handle = _interopRequireWildcard(require("@enact/core/handle"));
11
+
12
+ var _keymap = require("@enact/core/keymap");
13
+
14
+ var _Registry = _interopRequireDefault(require("@enact/core/internal/Registry"));
15
+
16
+ var _util = require("@enact/core/util");
17
+
18
+ var _propTypes = _interopRequireDefault(require("prop-types"));
19
+
20
+ var _clamp = _interopRequireDefault(require("ramda/src/clamp"));
21
+
22
+ var _react = _interopRequireWildcard(require("react"));
23
+
24
+ var _ForwardRef = _interopRequireDefault(require("../ForwardRef"));
25
+
26
+ var _Resizable = require("../Resizable");
27
+
28
+ var _resolution = _interopRequireDefault(require("../resolution"));
29
+
30
+ var _Touchable = _interopRequireDefault(require("../Touchable"));
31
+
32
+ var _ScrollAnimator = _interopRequireDefault(require("./ScrollAnimator"));
33
+
34
+ var _Scrollbar = _interopRequireDefault(require("./Scrollbar"));
35
+
36
+ var _ScrollableModule = _interopRequireDefault(require("./Scrollable.module.css"));
37
+
38
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
10
39
 
11
- import classNames from 'classnames';
12
- import handle, {forward, forwardWithPrevent} from '@enact/core/handle';
13
- import {is} from '@enact/core/keymap';
14
- import Registry from '@enact/core/internal/Registry';
15
- import {Job} from '@enact/core/util';
16
- import PropTypes from 'prop-types';
17
- import clamp from 'ramda/src/clamp';
18
- import React, {Component} from 'react';
19
-
20
- import ForwardRef from '../ForwardRef';
21
- import {ResizeContext} from '../Resizable';
22
- import ri from '../resolution';
23
- import Touchable from '../Touchable';
24
-
25
- import ScrollAnimator from './ScrollAnimator';
26
- import Scrollbar from './Scrollbar';
27
-
28
- import css from './Scrollable.module.less';
29
-
30
- const
31
- constants = {
32
- animationDuration: 1000,
33
- epsilon: 1,
34
- flickConfig: {maxDuration: null},
35
- isPageDown: is('pageDown'),
36
- isPageUp: is('pageUp'),
37
- nop: () => {},
38
- overscrollTypeNone: 0,
39
- overscrollTypeHold: 1,
40
- overscrollTypeOnce: 2,
41
- overscrollTypeDone: 9,
42
- paginationPageMultiplier: 0.66,
43
- scrollStopWaiting: 200,
44
- scrollWheelPageMultiplierForMaxPixel: 0.2 // The ratio of the maximum distance scrolled by wheel to the size of the viewport.
45
- },
46
- {
47
- animationDuration,
48
- epsilon,
49
- flickConfig,
50
- isPageDown,
51
- isPageUp,
52
- nop,
53
- overscrollTypeDone,
54
- overscrollTypeHold,
55
- overscrollTypeNone,
56
- overscrollTypeOnce,
57
- paginationPageMultiplier,
58
- scrollStopWaiting,
59
- scrollWheelPageMultiplierForMaxPixel
60
- } = constants;
61
-
62
- const TouchableDiv = ForwardRef({prop: 'ref'}, Touchable('div'));
40
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
63
41
 
42
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
43
+
44
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
45
+
46
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
47
+
48
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
49
+
50
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
51
+
52
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
53
+
54
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
55
+
56
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
57
+
58
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
59
+
60
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
61
+
62
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
63
+
64
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
65
+
66
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
67
+
68
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
69
+
70
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
71
+
72
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
73
+
74
+ var constants = {
75
+ animationDuration: 1000,
76
+ epsilon: 1,
77
+ flickConfig: {
78
+ maxDuration: null
79
+ },
80
+ isPageDown: (0, _keymap.is)('pageDown'),
81
+ isPageUp: (0, _keymap.is)('pageUp'),
82
+ nop: function nop() {},
83
+ overscrollTypeNone: 0,
84
+ overscrollTypeHold: 1,
85
+ overscrollTypeOnce: 2,
86
+ overscrollTypeDone: 9,
87
+ paginationPageMultiplier: 0.66,
88
+ scrollStopWaiting: 200,
89
+ scrollWheelPageMultiplierForMaxPixel: 0.2 // The ratio of the maximum distance scrolled by wheel to the size of the viewport.
90
+
91
+ },
92
+ animationDuration = constants.animationDuration,
93
+ epsilon = constants.epsilon,
94
+ flickConfig = constants.flickConfig,
95
+ isPageDown = constants.isPageDown,
96
+ isPageUp = constants.isPageUp,
97
+ nop = constants.nop,
98
+ overscrollTypeDone = constants.overscrollTypeDone,
99
+ overscrollTypeHold = constants.overscrollTypeHold,
100
+ overscrollTypeNone = constants.overscrollTypeNone,
101
+ overscrollTypeOnce = constants.overscrollTypeOnce,
102
+ paginationPageMultiplier = constants.paginationPageMultiplier,
103
+ scrollStopWaiting = constants.scrollStopWaiting,
104
+ scrollWheelPageMultiplierForMaxPixel = constants.scrollWheelPageMultiplierForMaxPixel;
105
+ exports.constants = constants;
106
+ var TouchableDiv = (0, _ForwardRef["default"])({
107
+ prop: 'ref'
108
+ }, (0, _Touchable["default"])('div'));
64
109
  /**
65
110
  * An unstyled component that passes scrollable behavior information as its render prop's arguments.
66
111
  *
@@ -69,1321 +114,1066 @@ const TouchableDiv = ForwardRef({prop: 'ref'}, Touchable('div'));
69
114
  * @ui
70
115
  * @private
71
116
  */
72
- class ScrollableBase extends Component {
73
- static displayName = 'ui:ScrollableBase';
74
-
75
- static propTypes = /** @lends ui/Scrollable.Scrollable.prototype */ {
76
- /**
77
- * Render function.
78
- *
79
- * @type {Function}
80
- * @required
81
- * @private
82
- */
83
- containerRenderer: PropTypes.func.isRequired,
84
-
85
- /**
86
- * Called when adding additional event listeners in a themed component.
87
- *
88
- * @type {Function}
89
- * @private
90
- */
91
- addEventListeners: PropTypes.func,
92
-
93
- /**
94
- * Called to execute additional logic in a themed component to show overscroll effect.
95
- *
96
- * @type {Function}
97
- * @private
98
- */
99
- applyOverscrollEffect: PropTypes.func,
100
-
101
- /**
102
- * A callback function that receives a reference to the `scrollTo` feature.
103
- *
104
- * Once received, the `scrollTo` method can be called as an imperative interface.
105
- *
106
- * The `scrollTo` function accepts the following parameters:
107
- * - {position: {x, y}} - Pixel value for x and/or y position
108
- * - {align} - Where the scroll area should be aligned. Values are:
109
- * `'left'`, `'right'`, `'top'`, `'bottom'`,
110
- * `'topleft'`, `'topright'`, `'bottomleft'`, and `'bottomright'`.
111
- * - {index} - Index of specific item. (`0` or positive integer)
112
- * This option is available for only `VirtualList` kind.
113
- * - {node} - Node to scroll into view
114
- * - {animate} - When `true`, scroll occurs with animation. When `false`, no
115
- * animation occurs.
116
- * - {focus} - When `true`, attempts to focus item after scroll. Only valid when scrolling
117
- * by `index` or `node`.
118
- * > Note: Only specify one of: `position`, `align`, `index` or `node`
119
- *
120
- * Example:
121
- * ```
122
- * // If you set cbScrollTo prop like below;
123
- * cbScrollTo: (fn) => {this.scrollTo = fn;}
124
- * // You can simply call like below;
125
- * this.scrollTo({align: 'top'}); // scroll to the top
126
- * ```
127
- *
128
- * @type {Function}
129
- * @public
130
- */
131
- cbScrollTo: PropTypes.func,
132
-
133
- /**
134
- * Called to execute additional logic in a themed component to clear overscroll effect.
135
- *
136
- * @type {Function}
137
- * @private
138
- */
139
- clearOverscrollEffect: PropTypes.func,
140
-
141
- /**
142
- * Client size of the container; valid values are an object that has `clientWidth` and `clientHeight`.
143
- *
144
- * @type {Object}
145
- * @property {Number} clientHeight The client height of the list.
146
- * @property {Number} clientWidth The client width of the list.
147
- * @public
148
- */
149
- clientSize: PropTypes.shape({
150
- clientHeight: PropTypes.number.isRequired,
151
- clientWidth: PropTypes.number.isRequired
152
- }),
153
-
154
- /**
155
- * Direction of the list or the scroller.
156
- *
157
- * `'both'` could be only used for[Scroller]{@link ui/Scroller.Scroller}.
158
- *
159
- * Valid values are:
160
- * * `'both'`,
161
- * * `'horizontal'`, and
162
- * * `'vertical'`.
163
- *
164
- * @type {String}
165
- * @private
166
- */
167
- direction: PropTypes.oneOf(['both', 'horizontal', 'vertical']),
168
-
169
- /**
170
- * Called when resizing window
171
- *
172
- * @type {Function}
173
- * @private
174
- */
175
- handleResizeWindow: PropTypes.func,
176
-
177
- /**
178
- * Specifies how to show horizontal scrollbar.
179
- *
180
- * Valid values are:
181
- * * `'auto'`,
182
- * * `'visible'`, and
183
- * * `'hidden'`.
184
- *
185
- * @type {String}
186
- * @default 'auto'
187
- * @public
188
- */
189
- horizontalScrollbar: PropTypes.oneOf(['auto', 'visible', 'hidden']),
190
-
191
- /**
192
- * Prevents scroll by dragging or flicking on the list or the scroller.
193
- *
194
- * @type {Boolean}
195
- * @default false
196
- * @private
197
- */
198
- noScrollByDrag: PropTypes.bool,
199
-
200
- /**
201
- * Prevents scroll by wheeling on the list or the scroller.
202
- *
203
- * @type {Boolean}
204
- * @default false
205
- * @public
206
- */
207
- noScrollByWheel: PropTypes.bool,
208
-
209
- /**
210
- * Called when triggering a drag event.
211
- *
212
- * @type {Function}
213
- * @private
214
- */
215
- onDrag: PropTypes.func,
216
-
217
- /**
218
- * Called when triggering a dragend event.
219
- *
220
- * @type {Function}
221
- * @private
222
- */
223
- onDragEnd: PropTypes.func,
224
-
225
- /**
226
- * Called when triggering a dragstart event.
227
- *
228
- * @type {Function}
229
- * @private
230
- */
231
- onDragStart: PropTypes.func,
232
-
233
- /**
234
- * Called when flicking with a mouse or a touch screen.
235
- *
236
- * @type {Function}
237
- * @private
238
- */
239
- onFlick: PropTypes.func,
240
-
241
- /**
242
- * Called when pressing a key.
243
- *
244
- * @type {Function}
245
- * @private
246
- */
247
- onKeyDown: PropTypes.func,
248
-
249
- /**
250
- * Called when triggering a mousedown event.
251
- *
252
- * @type {Function}
253
- * @private
254
- */
255
- onMouseDown: PropTypes.func,
256
-
257
- /**
258
- * Called when scrolling.
259
- *
260
- * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
261
- * It is not recommended to set this prop since it can cause performance degradation.
262
- * Use `onScrollStart` or `onScrollStop` instead.
263
- *
264
- * @type {Function}
265
- * @param {Object} event
266
- * @param {Number} event.scrollLeft Scroll left value.
267
- * @param {Number} event.scrollTop Scroll top value.
268
- * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
269
- * @public
270
- */
271
- onScroll: PropTypes.func,
272
-
273
- /**
274
- * Called when scroll starts.
275
- *
276
- * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
277
- * You can get firstVisibleIndex and lastVisibleIndex from VirtualList with `moreInfo`.
278
- *
279
- * Example:
280
- * ```
281
- * onScrollStart = ({scrollLeft, scrollTop, moreInfo}) => {
282
- * const {firstVisibleIndex, lastVisibleIndex} = moreInfo;
283
- * // do something with firstVisibleIndex and lastVisibleIndex
284
- * }
285
- *
286
- * render = () => (
287
- * <VirtualList
288
- * ...
289
- * onScrollStart={this.onScrollStart}
290
- * ...
291
- * />
292
- * )
293
- * ```
294
- *
295
- * @type {Function}
296
- * @param {Object} event
297
- * @param {Number} event.scrollLeft Scroll left value.
298
- * @param {Number} event.scrollTop Scroll top value.
299
- * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
300
- * @public
301
- */
302
- onScrollStart: PropTypes.func,
303
-
304
- /**
305
- * Called when scroll stops.
306
- *
307
- * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
308
- * You can get firstVisibleIndex and lastVisibleIndex from VirtualList with `moreInfo`.
309
- *
310
- * Example:
311
- * ```
312
- * onScrollStop = ({scrollLeft, scrollTop, moreInfo}) => {
313
- * const {firstVisibleIndex, lastVisibleIndex} = moreInfo;
314
- * // do something with firstVisibleIndex and lastVisibleIndex
315
- * }
316
- *
317
- * render = () => (
318
- * <VirtualList
319
- * ...
320
- * onScrollStop={this.onScrollStop}
321
- * ...
322
- * />
323
- * )
324
- * ```
325
- *
326
- * @type {Function}
327
- * @param {Object} event
328
- * @param {Number} event.scrollLeft Scroll left value.
329
- * @param {Number} event.scrollTop Scroll top value.
330
- * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
331
- * @public
332
- */
333
- onScrollStop: PropTypes.func,
334
-
335
- /**
336
- * Called when wheeling.
337
- *
338
- * @type {Function}
339
- * @private
340
- */
341
- onWheel: PropTypes.func,
342
-
343
- /**
344
- * Specifies overscroll effects shows on which type of inputs.
345
- *
346
- * @type {Object}
347
- * @default {drag: false, pageKey: false, wheel: false}
348
- * @private
349
- */
350
- overscrollEffectOn: PropTypes.shape({
351
- drag: PropTypes.bool,
352
- pageKey: PropTypes.bool,
353
- wheel: PropTypes.bool
354
- }),
355
-
356
- /**
357
- * Called when removing additional event listeners in a themed component.
358
- *
359
- * @type {Function}
360
- * @private
361
- */
362
- removeEventListeners: PropTypes.func,
363
-
364
- /**
365
- * Indicates the content's text direction is right-to-left.
366
- *
367
- * @type {Boolean}
368
- * @private
369
- */
370
- rtl: PropTypes.bool,
371
-
372
- /**
373
- * Called to execute additional logic in a themed component when scrollTo is called.
374
- *
375
- * @type {Function}
376
- * @private
377
- */
378
- scrollTo: PropTypes.func,
379
-
380
- /**
381
- * Called to execute additional logic in a themed component when scroll stops.
382
- *
383
- * @type {Function}
384
- * @private
385
- */
386
- stop: PropTypes.func,
387
-
388
- /**
389
- * Specifies how to show vertical scrollbar.
390
- *
391
- * Valid values are:
392
- * * `'auto'`,
393
- * * `'visible'`, and
394
- * * `'hidden'`.
395
- *
396
- * @type {String}
397
- * @default 'auto'
398
- * @public
399
- */
400
- verticalScrollbar: PropTypes.oneOf(['auto', 'visible', 'hidden'])
401
- };
402
-
403
- static defaultProps = {
404
- cbScrollTo: nop,
405
- horizontalScrollbar: 'auto',
406
- noScrollByDrag: false,
407
- noScrollByWheel: false,
408
- onScroll: nop,
409
- onScrollStart: nop,
410
- onScrollStop: nop,
411
- overscrollEffectOn: {drag: false, pageKey: false, wheel: false},
412
- verticalScrollbar: 'auto'
413
- };
414
-
415
- static contextType = ResizeContext;
416
-
417
- constructor (props) {
418
- super(props);
419
-
420
- this.state = {
421
- remeasure: false,
422
- isHorizontalScrollbarVisible: props.horizontalScrollbar === 'visible',
423
- isVerticalScrollbarVisible: props.verticalScrollbar === 'visible'
424
- };
425
-
426
- this.containerRef = React.createRef();
427
- this.horizontalScrollbarRef = React.createRef();
428
- this.verticalScrollbarRef = React.createRef();
429
-
430
- this.horizontalScrollbarProps = {
431
- ref: this.horizontalScrollbarRef,
432
- vertical: false,
433
- clientSize: props.clientSize
434
- };
435
-
436
- this.verticalScrollbarProps = {
437
- ref: this.verticalScrollbarRef,
438
- vertical: true,
439
- clientSize: props.clientSize
440
- };
441
-
442
- this.overscrollEnabled = !!(props.applyOverscrollEffect);
443
-
444
- // Enable the early bail out of repeated scrolling to the same position
445
- this.animationInfo = null;
446
-
447
- this.resizeRegistry = Registry.create(this.handleResize.bind(this));
448
-
449
- props.cbScrollTo(this.scrollTo);
450
- }
451
-
452
- componentDidMount () {
453
- this.resizeRegistry.parent = this.context;
454
- this.addEventListeners();
455
- this.updateScrollbars();
456
- }
457
-
458
- componentDidUpdate (prevProps, prevState) {
459
- const
460
- {isHorizontalScrollbarVisible, isVerticalScrollbarVisible} = this.state,
461
- {hasDataSizeChanged} = this.childRefCurrent;
462
-
463
- // Need to sync calculated client size if it is different from the real size
464
- if (this.childRefCurrent.syncClientSize) {
465
- // If we actually synced, we need to reset scroll position.
466
- if (this.childRefCurrent.syncClientSize()) {
467
- this.setScrollLeft(0);
468
- this.setScrollTop(0);
469
- }
470
- }
471
-
472
- this.clampScrollPosition();
473
-
474
- this.addEventListeners();
475
- if (
476
- hasDataSizeChanged === false &&
477
- (isHorizontalScrollbarVisible && !prevState.isHorizontalScrollbarVisible || isVerticalScrollbarVisible && !prevState.isVerticalScrollbarVisible)
478
- ) {
479
- this.deferScrollTo = false;
480
- this.isUpdatedScrollThumb = this.updateScrollThumbSize();
481
- } else {
482
- this.updateScrollbars();
483
- }
484
-
485
- if (this.scrollToInfo !== null) {
486
- if (!this.deferScrollTo) {
487
- this.scrollTo(this.scrollToInfo);
488
- }
489
- }
490
-
491
- // publish container resize changes
492
- const horizontal = isHorizontalScrollbarVisible !== prevState.isHorizontalScrollbarVisible;
493
- const vertical = isVerticalScrollbarVisible !== prevState.isVerticalScrollbarVisible;
494
- if (horizontal || vertical) {
495
- this.resizeRegistry.notify({});
496
- }
497
- }
498
-
499
- componentWillUnmount () {
500
- this.resizeRegistry.parent = null;
501
- // Before call cancelAnimationFrame, you must send scrollStop Event.
502
- if (this.scrolling) {
503
- this.forwardScrollEvent('onScrollStop', this.getReachedEdgeInfo());
504
- }
505
- this.scrollStopJob.stop();
506
-
507
- if (this.animator.isAnimating()) {
508
- this.animator.stop();
509
- }
510
-
511
- this.removeEventListeners();
512
- }
513
-
514
- handleResize (ev) {
515
- if (ev.action === 'invalidateBounds') {
516
- this.enqueueForceUpdate();
517
- }
518
- }
519
-
520
- handleResizeWindow = () => {
521
- // `handleSize` in `ui/resolution.ResolutionDecorator` should be executed first.
522
- setTimeout(() => {
523
- const {handleResizeWindow} = this.props;
524
-
525
- if (handleResizeWindow) {
526
- handleResizeWindow();
527
- }
528
- this.scrollTo({position: {x: 0, y: 0}, animate: false});
529
-
530
- this.enqueueForceUpdate();
531
- });
532
- };
533
-
534
- // TODO: consider replacing forceUpdate() by storing bounds in state rather than a non-
535
- // state member.
536
- enqueueForceUpdate () {
537
- this.childRefCurrent.calculateMetrics(this.childRefCurrent.props);
538
- this.forceUpdate();
539
- }
540
-
541
- clampScrollPosition () {
542
- const bounds = this.getScrollBounds();
543
-
544
- if (this.scrollTop > bounds.maxTop) {
545
- this.scrollTop = bounds.maxTop;
546
- }
547
-
548
- if (this.scrollLeft > bounds.maxLeft) {
549
- this.scrollLeft = bounds.maxLeft;
550
- }
551
- }
552
-
553
- // constants
554
- pixelPerLine = 39;
555
- scrollWheelMultiplierForDeltaPixel = 1.5; // The ratio of wheel 'delta' units to pixels scrolled.
556
-
557
- // status
558
- deferScrollTo = true;
559
- isScrollAnimationTargetAccumulated = false;
560
- isUpdatedScrollThumb = false;
561
-
562
- // overscroll
563
- lastInputType = null;
564
- overscrollEnabled = false;
565
- overscrollStatus = {
566
- horizontal: {
567
- before: {type: overscrollTypeNone, ratio: 0},
568
- after: {type: overscrollTypeNone, ratio: 0}
569
- },
570
- vertical: {
571
- before: {type: overscrollTypeNone, ratio: 0},
572
- after: {type: overscrollTypeNone, ratio: 0}
573
- }
574
- };
575
-
576
- // bounds info
577
- bounds = {
578
- clientWidth: 0,
579
- clientHeight: 0,
580
- scrollWidth: 0,
581
- scrollHeight: 0,
582
- maxTop: 0,
583
- maxLeft: 0
584
- };
585
-
586
- // wheel/drag/flick info
587
- wheelDirection = 0;
588
- isDragging = false;
589
-
590
- // scroll info
591
- scrolling = false;
592
- scrollLeft = 0;
593
- scrollTop = 0;
594
- scrollToInfo = null;
595
-
596
- // component info
597
- childRefCurrent = null;
598
-
599
- // scroll animator
600
- animator = new ScrollAnimator();
601
-
602
- // drag/flick event handlers
603
-
604
- getRtlX = (x) => (this.props.rtl ? -x : x);
605
-
606
- onMouseDown = handle(
607
- forwardWithPrevent('onMouseDown'),
608
- this.stop
609
- ).bindAs(this, 'onMouseDown');
610
-
611
- onDragStart = (ev) => {
612
- if (ev.type === 'dragstart') return;
613
-
614
- forward('onDragStart', ev, this.props);
615
- this.stop();
616
- this.isDragging = true;
617
- this.dragStartX = this.scrollLeft + this.getRtlX(ev.x);
618
- this.dragStartY = this.scrollTop + ev.y;
619
- };
620
-
621
- onDrag = (ev) => {
622
- if (ev.type === 'drag') return;
623
-
624
- const {direction} = this.props;
625
-
626
- this.lastInputType = 'drag';
627
-
628
- forward('onDrag', ev, this.props);
629
- this.start({
630
- targetX: (direction === 'vertical') ? 0 : this.dragStartX - this.getRtlX(ev.x), // 'horizontal' or 'both'
631
- targetY: (direction === 'horizontal') ? 0 : this.dragStartY - ev.y, // 'vertical' or 'both'
632
- animate: false,
633
- overscrollEffect: this.props.overscrollEffectOn.drag
634
- });
635
- };
636
-
637
- onDragEnd = (ev) => {
638
- if (ev.type === 'dragend') return;
639
-
640
- this.isDragging = false;
641
-
642
- forward('onDragEnd', ev, this.props);
643
- if (this.flickTarget) {
644
- const {targetX, targetY, duration} = this.flickTarget;
645
-
646
- this.lastInputType = 'drag';
647
-
648
- this.isScrollAnimationTargetAccumulated = false;
649
- this.start({targetX, targetY, duration, overscrollEffect: this.props.overscrollEffectOn.drag});
650
- } else {
651
- this.stop();
652
- }
653
-
654
- if (this.overscrollEnabled) { // not check this.props.overscrollEffectOn.drag for safety
655
- this.clearAllOverscrollEffects();
656
- }
657
-
658
- this.flickTarget = null;
659
- };
660
-
661
- onFlick = (ev) => {
662
- const {direction} = this.props;
663
-
664
- this.flickTarget = this.animator.simulate(
665
- this.scrollLeft,
666
- this.scrollTop,
667
- (direction !== 'vertical') ? this.getRtlX(-ev.velocityX) : 0,
668
- (direction !== 'horizontal') ? -ev.velocityY : 0
669
- );
670
-
671
- if (this.props.onFlick) {
672
- forward('onFlick', ev, this.props);
673
- }
674
- };
675
-
676
- calculateDistanceByWheel (deltaMode, delta, maxPixel) {
677
- if (deltaMode === 0) {
678
- delta = clamp(-maxPixel, maxPixel, ri.scale(delta * this.scrollWheelMultiplierForDeltaPixel));
679
- } else if (deltaMode === 1) { // line; firefox
680
- delta = clamp(-maxPixel, maxPixel, ri.scale(delta * this.pixelPerLine * this.scrollWheelMultiplierForDeltaPixel));
681
- } else if (deltaMode === 2) { // page
682
- delta = delta < 0 ? -maxPixel : maxPixel;
683
- }
684
-
685
- return delta;
686
- }
687
-
688
- onWheel = (ev) => {
689
- if (this.isDragging) {
690
- ev.preventDefault();
691
- ev.stopPropagation();
692
- } else {
693
- const
694
- {verticalScrollbarRef, horizontalScrollbarRef} = this,
695
- bounds = this.getScrollBounds(),
696
- canScrollHorizontally = this.canScrollHorizontally(bounds),
697
- canScrollVertically = this.canScrollVertically(bounds),
698
- eventDeltaMode = ev.deltaMode,
699
- eventDelta = (-ev.wheelDeltaY || ev.deltaY);
700
- let
701
- delta = 0,
702
- direction;
703
-
704
- this.lastInputType = 'wheel';
705
-
706
- if (this.props.noScrollByWheel) {
707
- return;
708
- }
709
-
710
- if (canScrollVertically) {
711
- delta = this.calculateDistanceByWheel(eventDeltaMode, eventDelta, bounds.clientHeight * scrollWheelPageMultiplierForMaxPixel);
712
- } else if (canScrollHorizontally) {
713
- delta = this.calculateDistanceByWheel(eventDeltaMode, eventDelta, bounds.clientWidth * scrollWheelPageMultiplierForMaxPixel);
714
- }
715
-
716
- direction = Math.sign(delta);
717
-
718
- if (direction !== this.wheelDirection) {
719
- this.isScrollAnimationTargetAccumulated = false;
720
- this.wheelDirection = direction;
721
- }
722
-
723
- forward('onWheel', {delta, horizontalScrollbarRef, verticalScrollbarRef}, this.props);
724
-
725
- if (delta !== 0) {
726
- this.scrollToAccumulatedTarget(delta, canScrollVertically, this.props.overscrollEffectOn.wheel);
727
- ev.preventDefault();
728
- ev.stopPropagation();
729
- }
730
- }
731
- };
732
-
733
- scrollByPage = (keyCode) => {
734
- const
735
- bounds = this.getScrollBounds(),
736
- canScrollVertically = this.canScrollVertically(bounds),
737
- pageDistance = (isPageUp(keyCode) ? -1 : 1) * (canScrollVertically ? bounds.clientHeight : bounds.clientWidth) * paginationPageMultiplier;
738
-
739
- this.lastInputType = 'pageKey';
740
-
741
- this.scrollToAccumulatedTarget(pageDistance, canScrollVertically, this.props.overscrollEffectOn.pageKey);
742
- };
743
-
744
- onKeyDown = (ev) => {
745
- if (this.props.onKeyDown) {
746
- forward('onKeyDown', ev, this.props);
747
- } else if ((isPageUp(ev.keyCode) || isPageDown(ev.keyCode))) {
748
- this.scrollByPage(ev.keyCode);
749
- }
750
- };
751
-
752
- scrollToAccumulatedTarget = (delta, vertical, overscrollEffect) => {
753
- if (!this.isScrollAnimationTargetAccumulated) {
754
- this.accumulatedTargetX = this.scrollLeft;
755
- this.accumulatedTargetY = this.scrollTop;
756
- this.isScrollAnimationTargetAccumulated = true;
757
- }
758
-
759
- if (vertical) {
760
- this.accumulatedTargetY += delta;
761
- } else {
762
- this.accumulatedTargetX += delta;
763
- }
764
-
765
- this.start({targetX: this.accumulatedTargetX, targetY: this.accumulatedTargetY, overscrollEffect});
766
- };
767
-
768
- // overscroll effect
769
-
770
- getEdgeFromPosition = (position, maxPosition) => {
771
- if (position <= 0) {
772
- return 'before';
773
- } else if (position >= maxPosition) {
774
- return 'after';
775
- } else {
776
- return null;
777
- }
778
- };
779
-
780
- setOverscrollStatus = (orientation, edge, type, ratio) => {
781
- const status = this.overscrollStatus[orientation][edge];
782
- status.type = type;
783
- status.ratio = ratio;
784
- };
785
-
786
- getOverscrollStatus = (orientation, edge) => (this.overscrollStatus[orientation][edge]);
787
-
788
- calculateOverscrollRatio = (orientation, position) => {
789
- const
790
- bounds = this.getScrollBounds(),
791
- isVertical = (orientation === 'vertical'),
792
- baseSize = isVertical ? bounds.clientHeight : bounds.clientWidth,
793
- maxPos = bounds[isVertical ? 'maxTop' : 'maxLeft'];
794
- let overDistance = 0;
795
-
796
- if (position < 0) {
797
- overDistance = -position;
798
- } else if (position > maxPos) {
799
- overDistance = position - maxPos;
800
- } else {
801
- return 0;
802
- }
803
-
804
- return Math.min(1, 2 * overDistance / baseSize);
805
- };
806
-
807
- applyOverscrollEffect = (orientation, edge, type, ratio) => {
808
- this.props.applyOverscrollEffect(orientation, edge, type, ratio);
809
- this.setOverscrollStatus(orientation, edge, type === overscrollTypeOnce ? overscrollTypeDone : type, ratio);
810
- };
811
-
812
- checkAndApplyOverscrollEffect = (orientation, edge, type, ratio = 1) => {
813
- const
814
- isVertical = (orientation === 'vertical'),
815
- curPos = isVertical ? this.scrollTop : this.scrollLeft,
816
- maxPos = this.getScrollBounds()[isVertical ? 'maxTop' : 'maxLeft'];
817
-
818
- if ((edge === 'before' && curPos <= 0) || (edge === 'after' && curPos >= maxPos)) { // Already on the edge
819
- this.applyOverscrollEffect(orientation, edge, type, ratio);
820
- } else {
821
- this.setOverscrollStatus(orientation, edge, type, ratio);
822
- }
823
- };
824
-
825
- clearOverscrollEffect = (orientation, edge) => {
826
- if (this.getOverscrollStatus(orientation, edge).type !== overscrollTypeNone) {
827
- if (this.props.clearOverscrollEffect) {
828
- this.props.clearOverscrollEffect(orientation, edge);
829
- } else {
830
- this.applyOverscrollEffect(orientation, edge, overscrollTypeNone, 0);
831
- }
832
- }
833
- };
834
-
835
- clearAllOverscrollEffects = () => {
836
- ['horizontal', 'vertical'].forEach((orientation) => {
837
- ['before', 'after'].forEach((edge) => {
838
- this.clearOverscrollEffect(orientation, edge);
839
- });
840
- });
841
- };
842
-
843
- applyOverscrollEffectOnDrag = (orientation, edge, targetPosition, type) => {
844
- if (edge) {
845
- const
846
- oppositeEdge = edge === 'before' ? 'after' : 'before',
847
- ratio = this.calculateOverscrollRatio(orientation, targetPosition);
848
-
849
- this.applyOverscrollEffect(orientation, edge, type, ratio);
850
- this.clearOverscrollEffect(orientation, oppositeEdge);
851
- } else {
852
- this.clearOverscrollEffect(orientation, 'before');
853
- this.clearOverscrollEffect(orientation, 'after');
854
- }
855
- };
856
-
857
- checkAndApplyOverscrollEffectOnScroll = (orientation) => {
858
- ['before', 'after'].forEach((edge) => {
859
- const {ratio, type} = this.getOverscrollStatus(orientation, edge);
860
-
861
- if (type === overscrollTypeOnce) {
862
- this.checkAndApplyOverscrollEffect(orientation, edge, type, ratio);
863
- }
864
- });
865
- };
866
-
867
- checkAndApplyOverscrollEffectOnStart = (orientation, edge, targetPosition) => {
868
- if (this.isDragging) {
869
- this.applyOverscrollEffectOnDrag(orientation, edge, targetPosition, overscrollTypeHold);
870
- } else if (edge) {
871
- this.checkAndApplyOverscrollEffect(orientation, edge, overscrollTypeOnce);
872
- }
873
- };
874
-
875
- // call scroll callbacks
876
-
877
- forwardScrollEvent (type, reachedEdgeInfo) {
878
- forward(type, {scrollLeft: this.scrollLeft, scrollTop: this.scrollTop, moreInfo: this.getMoreInfo(), reachedEdgeInfo}, this.props);
879
- }
880
-
881
- // update scroll position
882
-
883
- setScrollLeft (value) {
884
- const bounds = this.getScrollBounds();
885
-
886
- this.scrollLeft = clamp(0, bounds.maxLeft, value);
887
-
888
- if (this.overscrollEnabled && this.props.overscrollEffectOn[this.lastInputType]) {
889
- this.checkAndApplyOverscrollEffectOnScroll('horizontal');
890
- }
891
-
892
- if (this.state.isHorizontalScrollbarVisible) {
893
- this.updateThumb(this.horizontalScrollbarRef, bounds);
894
- }
895
- }
896
-
897
- setScrollTop (value) {
898
- const bounds = this.getScrollBounds();
899
-
900
- this.scrollTop = clamp(0, bounds.maxTop, value);
901
-
902
- if (this.overscrollEnabled && this.props.overscrollEffectOn[this.lastInputType]) {
903
- this.checkAndApplyOverscrollEffectOnScroll('vertical');
904
- }
905
-
906
- if (this.state.isVerticalScrollbarVisible) {
907
- this.updateThumb(this.verticalScrollbarRef, bounds);
908
- }
909
- }
910
-
911
- getReachedEdgeInfo = () => {
912
- const
913
- bounds = this.getScrollBounds(),
914
- reachedEdgeInfo = {bottom: false, left: false, right: false, top: false};
915
-
916
- if (this.canScrollHorizontally(bounds)) {
917
- const
918
- rtl = this.props.rtl,
919
- edge = this.getEdgeFromPosition(this.scrollLeft, bounds.maxLeft);
920
-
921
- if (edge) { // if edge is null, no need to check which edge is reached.
922
- if ((edge === 'before' && !rtl) || (edge === 'after' && rtl)) {
923
- reachedEdgeInfo.left = true;
924
- } else {
925
- reachedEdgeInfo.right = true;
926
- }
927
- }
928
- }
929
-
930
- if (this.canScrollVertically(bounds)) {
931
- const edge = this.getEdgeFromPosition(this.scrollTop, bounds.maxTop);
932
-
933
- if (edge === 'before') {
934
- reachedEdgeInfo.top = true;
935
- } else if (edge === 'after') {
936
- reachedEdgeInfo.bottom = true;
937
- }
938
- }
939
-
940
- return reachedEdgeInfo;
941
- };
942
-
943
- // scroll start/stop
944
-
945
- doScrollStop = () => {
946
- this.scrolling = false;
947
- this.forwardScrollEvent('onScrollStop', this.getReachedEdgeInfo());
948
- };
949
-
950
- scrollStopJob = new Job(this.doScrollStop, scrollStopWaiting);
951
-
952
- start ({targetX, targetY, animate = true, duration = animationDuration, overscrollEffect = false}) {
953
- const
954
- {scrollLeft, scrollTop} = this,
955
- bounds = this.getScrollBounds(),
956
- {maxLeft, maxTop} = bounds;
957
-
958
- const updatedAnimationInfo = {
959
- sourceX: scrollLeft,
960
- sourceY: scrollTop,
961
- targetX,
962
- targetY,
963
- duration
964
- };
965
-
966
- // bail early when scrolling to the same position
967
- if (this.animator.isAnimating() && this.animationInfo && this.animationInfo.targetX === targetX && this.animationInfo.targetY === targetY) {
968
- return;
969
- }
970
-
971
- this.animationInfo = updatedAnimationInfo;
972
-
973
- this.animator.stop();
974
- if (!this.scrolling) {
975
- this.scrolling = true;
976
- this.forwardScrollEvent('onScrollStart');
977
- }
978
- this.scrollStopJob.stop();
979
-
980
- if (Math.abs(maxLeft - targetX) < epsilon) {
981
- targetX = maxLeft;
982
- }
983
- if (Math.abs(maxTop - targetY) < epsilon) {
984
- targetY = maxTop;
985
- }
986
-
987
- if (this.overscrollEnabled && overscrollEffect) {
988
- if (scrollLeft !== targetX && this.canScrollHorizontally(bounds)) {
989
- this.checkAndApplyOverscrollEffectOnStart('horizontal', this.getEdgeFromPosition(targetX, maxLeft), targetX);
990
- }
991
- if (scrollTop !== targetY && this.canScrollVertically(bounds)) {
992
- this.checkAndApplyOverscrollEffectOnStart('vertical', this.getEdgeFromPosition(targetY, maxTop), targetY);
993
- }
994
- }
995
-
996
- this.showThumb(bounds);
997
-
998
- if (animate) {
999
- this.animator.animate(this.scrollAnimation(this.animationInfo));
1000
- } else {
1001
- this.scroll(targetX, targetY, targetX, targetY);
1002
- this.stop();
1003
- }
1004
- }
1005
-
1006
- scrollAnimation = (animationInfo) => (curTime) => {
1007
- const
1008
- {sourceX, sourceY, targetX, targetY, duration} = animationInfo,
1009
- bounds = this.getScrollBounds();
1010
-
1011
- if (curTime < duration) {
1012
- let
1013
- toBeContinued = false,
1014
- curTargetX = sourceX,
1015
- curTargetY = sourceY;
1016
-
1017
- if (this.canScrollHorizontally(bounds)) {
1018
- curTargetX = this.animator.timingFunction(sourceX, targetX, duration, curTime);
1019
- if (Math.abs(curTargetX - targetX) < epsilon) {
1020
- curTargetX = targetX;
1021
- } else {
1022
- toBeContinued = true;
1023
- }
1024
- }
1025
-
1026
- if (this.canScrollVertically(bounds)) {
1027
- curTargetY = this.animator.timingFunction(sourceY, targetY, duration, curTime);
1028
- if (Math.abs(curTargetY - targetY) < epsilon) {
1029
- curTargetY = targetY;
1030
- } else {
1031
- toBeContinued = true;
1032
- }
1033
- }
1034
-
1035
- this.scroll(curTargetX, curTargetY, targetX, targetY);
1036
- if (!toBeContinued) {
1037
- this.stop();
1038
- }
1039
- } else {
1040
- this.scroll(targetX, targetY, targetX, targetY);
1041
- this.stop();
1042
- }
1043
- };
1044
-
1045
- scroll = (left, top, ...rest) => {
1046
- if (left !== this.scrollLeft) {
1047
- this.setScrollLeft(left);
1048
- }
1049
- if (top !== this.scrollTop) {
1050
- this.setScrollTop(top);
1051
- }
1052
-
1053
- this.childRefCurrent.setScrollPosition(this.scrollLeft, this.scrollTop, this.props.rtl, ...rest);
1054
- this.forwardScrollEvent('onScroll');
1055
- };
1056
-
1057
- stop () {
1058
- this.animator.stop();
1059
- this.lastInputType = null;
1060
- this.isScrollAnimationTargetAccumulated = false;
1061
- this.startHidingThumb();
1062
- if (this.overscrollEnabled && !this.isDragging) { // not check this.props.overscrollEffectOn for safety
1063
- this.clearAllOverscrollEffects();
1064
- }
1065
- if (this.props.stop) {
1066
- this.props.stop();
1067
- }
1068
- if (this.scrolling) {
1069
- this.scrollStopJob.start();
1070
- }
1071
- }
1072
-
1073
- // scrollTo API
1074
-
1075
- getPositionForScrollTo = (opt) => {
1076
- const
1077
- bounds = this.getScrollBounds(),
1078
- canScrollHorizontally = this.canScrollHorizontally(bounds),
1079
- canScrollVertically = this.canScrollVertically(bounds);
1080
- let
1081
- itemPos,
1082
- left = null,
1083
- top = null;
1084
-
1085
- if (opt instanceof Object) {
1086
- if (opt.position instanceof Object) {
1087
- if (canScrollHorizontally) {
1088
- // We need '!=' to check if opt.position.x is null or undefined
1089
- left = opt.position.x != null ? opt.position.x : this.scrollLeft;
1090
- } else {
1091
- left = 0;
1092
- }
1093
- if (canScrollVertically) {
1094
- // We need '!=' to check if opt.position.y is null or undefined
1095
- top = opt.position.y != null ? opt.position.y : this.scrollTop;
1096
- } else {
1097
- top = 0;
1098
- }
1099
- } else if (typeof opt.align === 'string') {
1100
- if (canScrollHorizontally) {
1101
- if (opt.align.includes('left')) {
1102
- left = 0;
1103
- } else if (opt.align.includes('right')) {
1104
- left = bounds.maxLeft;
1105
- }
1106
- }
1107
- if (canScrollVertically) {
1108
- if (opt.align.includes('top')) {
1109
- top = 0;
1110
- } else if (opt.align.includes('bottom')) {
1111
- top = bounds.maxTop;
1112
- }
1113
- }
1114
- } else {
1115
- if (typeof opt.index === 'number' && typeof this.childRefCurrent.getItemPosition === 'function') {
1116
- itemPos = this.childRefCurrent.getItemPosition(opt.index, opt.stickTo);
1117
- } else if (opt.node instanceof Object) {
1118
- if (opt.node.nodeType === 1 && typeof this.childRefCurrent.getNodePosition === 'function') {
1119
- itemPos = this.childRefCurrent.getNodePosition(opt.node);
1120
- }
1121
- }
1122
- if (itemPos) {
1123
- if (canScrollHorizontally) {
1124
- left = itemPos.left;
1125
- }
1126
- if (canScrollVertically) {
1127
- top = itemPos.top;
1128
- }
1129
- }
1130
- }
1131
- }
1132
-
1133
- return {left, top};
1134
- };
1135
-
1136
- scrollTo = (opt) => {
1137
- if (!this.deferScrollTo) {
1138
- const {left, top} = this.getPositionForScrollTo(opt);
1139
-
1140
- if (this.props.scrollTo) {
1141
- this.props.scrollTo(opt);
1142
- }
1143
- this.scrollToInfo = null;
1144
- this.start({
1145
- targetX: (left !== null) ? left : this.scrollLeft,
1146
- targetY: (top !== null) ? top : this.scrollTop,
1147
- animate: opt.animate
1148
- });
1149
- } else {
1150
- this.scrollToInfo = opt;
1151
- }
1152
- };
1153
-
1154
- canScrollHorizontally = (bounds) => {
1155
- const {direction} = this.props;
1156
- return (direction === 'horizontal' || direction === 'both') && (bounds.scrollWidth > bounds.clientWidth) && !isNaN(bounds.scrollWidth);
1157
- };
1158
-
1159
- canScrollVertically = (bounds) => {
1160
- const {direction} = this.props;
1161
- return (direction === 'vertical' || direction === 'both') && (bounds.scrollHeight > bounds.clientHeight) && !isNaN(bounds.scrollHeight);
1162
- };
1163
-
1164
- // scroll bar
1165
-
1166
- showThumb (bounds) {
1167
- if (this.state.isHorizontalScrollbarVisible && this.canScrollHorizontally(bounds) && this.horizontalScrollbarRef.current) {
1168
- this.horizontalScrollbarRef.current.showThumb();
1169
- }
1170
- if (this.state.isVerticalScrollbarVisible && this.canScrollVertically(bounds) && this.verticalScrollbarRef.current) {
1171
- this.verticalScrollbarRef.current.showThumb();
1172
- }
1173
- }
1174
-
1175
- updateThumb (scrollbarRef, bounds) {
1176
- scrollbarRef.current.update({
1177
- ...bounds,
1178
- scrollLeft: this.scrollLeft,
1179
- scrollTop: this.scrollTop
1180
- });
1181
- }
1182
-
1183
- startHidingThumb = () => {
1184
- if (this.state.isHorizontalScrollbarVisible && this.horizontalScrollbarRef.current) {
1185
- this.horizontalScrollbarRef.current.startHidingThumb();
1186
- }
1187
- if (this.state.isVerticalScrollbarVisible && this.verticalScrollbarRef.current) {
1188
- this.verticalScrollbarRef.current.startHidingThumb();
1189
- }
1190
- };
1191
-
1192
- updateScrollbars = () => {
1193
- const
1194
- {horizontalScrollbar, verticalScrollbar} = this.props,
1195
- {isHorizontalScrollbarVisible, isVerticalScrollbarVisible} = this.state,
1196
- bounds = this.getScrollBounds(),
1197
- canScrollHorizontally = this.canScrollHorizontally(bounds),
1198
- canScrollVertically = this.canScrollVertically(bounds),
1199
- curHorizontalScrollbarVisible = (horizontalScrollbar === 'auto') ? canScrollHorizontally : horizontalScrollbar === 'visible',
1200
- curVerticalScrollbarVisible = (verticalScrollbar === 'auto') ? canScrollVertically : verticalScrollbar === 'visible';
1201
-
1202
- // determine if we should hide or show any scrollbars
1203
- const
1204
- isVisibilityChanged = (
1205
- isHorizontalScrollbarVisible !== curHorizontalScrollbarVisible ||
1206
- isVerticalScrollbarVisible !== curVerticalScrollbarVisible
1207
- );
1208
-
1209
- if (isVisibilityChanged) {
1210
- // one or both scrollbars have changed visibility
1211
- this.setState({
1212
- isHorizontalScrollbarVisible: curHorizontalScrollbarVisible,
1213
- isVerticalScrollbarVisible: curVerticalScrollbarVisible
1214
- });
1215
- } else {
1216
- this.deferScrollTo = false;
1217
- this.isUpdatedScrollThumb = this.updateScrollThumbSize();
1218
- }
1219
- };
1220
-
1221
- updateScrollThumbSize = () => {
1222
- const
1223
- {horizontalScrollbar, verticalScrollbar} = this.props,
1224
- bounds = this.getScrollBounds(),
1225
- canScrollHorizontally = this.canScrollHorizontally(bounds),
1226
- canScrollVertically = this.canScrollVertically(bounds),
1227
- curHorizontalScrollbarVisible = (horizontalScrollbar === 'auto') ? canScrollHorizontally : horizontalScrollbar === 'visible',
1228
- curVerticalScrollbarVisible = (verticalScrollbar === 'auto') ? canScrollVertically : verticalScrollbar === 'visible';
1229
-
1230
- if (curHorizontalScrollbarVisible || curVerticalScrollbarVisible) {
1231
- // no visibility change but need to notify whichever scrollbars are visible of the
1232
- // updated bounds and scroll position
1233
- const
1234
- updatedBounds = {
1235
- ...bounds,
1236
- scrollLeft: this.scrollLeft,
1237
- scrollTop: this.scrollTop
1238
- };
1239
-
1240
- if (curHorizontalScrollbarVisible && this.horizontalScrollbarRef.current) {
1241
- this.horizontalScrollbarRef.current.update(updatedBounds);
1242
- }
1243
- if (curVerticalScrollbarVisible && this.verticalScrollbarRef.current) {
1244
- this.verticalScrollbarRef.current.update(updatedBounds);
1245
- }
1246
- return true;
1247
- }
1248
- return false;
1249
- };
1250
-
1251
- // ref
1252
-
1253
- getScrollBounds () {
1254
- if (this.childRefCurrent && typeof this.childRefCurrent.getScrollBounds === 'function') {
1255
- return this.childRefCurrent.getScrollBounds();
1256
- }
1257
- }
1258
-
1259
- getMoreInfo () {
1260
- if (this.childRefCurrent && typeof this.childRefCurrent.getMoreInfo === 'function') {
1261
- return this.childRefCurrent.getMoreInfo();
1262
- }
1263
- }
1264
-
1265
- // FIXME setting event handlers directly to work on the V8 snapshot.
1266
- addEventListeners () {
1267
- const {childRefCurrent, containerRef} = this;
1268
-
1269
- if (containerRef.current && containerRef.current.addEventListener) {
1270
- containerRef.current.addEventListener('wheel', this.onWheel);
1271
- containerRef.current.addEventListener('keydown', this.onKeyDown);
1272
- containerRef.current.addEventListener('mousedown', this.onMouseDown);
1273
- }
1274
-
1275
- if (this.props.addEventListeners) {
1276
- this.props.addEventListeners(childRefCurrent.containerRef);
1277
- }
1278
-
1279
- if (window) {
1280
- window.addEventListener('resize', this.handleResizeWindow);
1281
- }
1282
- }
1283
-
1284
- // FIXME setting event handlers directly to work on the V8 snapshot.
1285
- removeEventListeners () {
1286
- const {childRefCurrent, containerRef} = this;
1287
-
1288
- if (containerRef.current && containerRef.current.removeEventListener) {
1289
- containerRef.current.removeEventListener('wheel', this.onWheel);
1290
- containerRef.current.removeEventListener('keydown', this.onKeyDown);
1291
- containerRef.current.removeEventListener('mousedown', this.onMouseDown);
1292
- }
1293
-
1294
- if (this.props.removeEventListeners) {
1295
- this.props.removeEventListeners(childRefCurrent.containerRef);
1296
- }
1297
-
1298
- if (window) {
1299
- window.removeEventListener('resize', this.handleResizeWindow);
1300
- }
1301
- }
1302
-
1303
- // render
1304
-
1305
- initChildRef = (ref) => {
1306
- if (ref) {
1307
- this.childRefCurrent = ref;
1308
- }
1309
- };
1310
-
1311
- handleScroll = () => {
1312
- const childRefCurrent = this.childRefCurrent;
1313
-
1314
- // Prevent scroll by focus.
1315
- // VirtualList and VirtualGridList DO NOT receive `onscroll` event.
1316
- // Only Scroller could get `onscroll` event.
1317
- if (!this.animator.isAnimating() && childRefCurrent && childRefCurrent.containerRef.current && childRefCurrent.getRtlPositionX) {
1318
- // For Scroller
1319
- childRefCurrent.containerRef.current.scrollTop = this.scrollTop;
1320
- childRefCurrent.containerRef.current.scrollLeft = childRefCurrent.getRtlPositionX(this.scrollLeft);
1321
- }
1322
- };
1323
-
1324
- render () {
1325
- const
1326
- {className, containerRenderer, noScrollByDrag, rtl, style, ...rest} = this.props,
1327
- {isHorizontalScrollbarVisible, isVerticalScrollbarVisible} = this.state,
1328
- scrollableClasses = classNames(css.scrollable, className),
1329
- childWrapper = noScrollByDrag ? 'div' : TouchableDiv,
1330
- childWrapperProps = {
1331
- className: css.content,
1332
- ...(!noScrollByDrag && {
1333
- flickConfig,
1334
- onDrag: this.onDrag,
1335
- onDragEnd: this.onDragEnd,
1336
- onDragStart: this.onDragStart,
1337
- onFlick: this.onFlick
1338
- })
1339
- };
1340
-
1341
- delete rest.addEventListeners;
1342
- delete rest.applyOverscrollEffect;
1343
- delete rest.cbScrollTo;
1344
- delete rest.clearOverscrollEffect;
1345
- delete rest.handleResizeWindow;
1346
- delete rest.horizontalScrollbar;
1347
- delete rest.noScrollByWheel;
1348
- delete rest.onFlick;
1349
- delete rest.onKeyDown;
1350
- delete rest.onMouseDown;
1351
- delete rest.onScroll;
1352
- delete rest.onScrollStart;
1353
- delete rest.onScrollStop;
1354
- delete rest.onWheel;
1355
- delete rest.overscrollEffectOn;
1356
- delete rest.removeEventListeners;
1357
- delete rest.scrollTo;
1358
- delete rest.stop;
1359
- delete rest.verticalScrollbar;
1360
-
1361
- this.deferScrollTo = true;
1362
-
1363
- return (
1364
- <ResizeContext.Provider value={this.resizeRegistry.register}>
1365
- {containerRenderer({
1366
- childComponentProps: rest,
1367
- childWrapper,
1368
- childWrapperProps,
1369
- className: scrollableClasses,
1370
- componentCss: css,
1371
- containerRef: this.containerRef,
1372
- handleScroll: this.handleScroll,
1373
- horizontalScrollbarProps: this.horizontalScrollbarProps,
1374
- initChildRef: this.initChildRef,
1375
- isHorizontalScrollbarVisible,
1376
- isVerticalScrollbarVisible,
1377
- rtl,
1378
- scrollTo: this.scrollTo,
1379
- style,
1380
- verticalScrollbarProps: this.verticalScrollbarProps
1381
- })}
1382
- </ResizeContext.Provider>
1383
- );
1384
- }
1385
- }
1386
117
 
118
+ var ScrollableBase = /*#__PURE__*/function (_Component) {
119
+ _inherits(ScrollableBase, _Component);
120
+
121
+ var _super = _createSuper(ScrollableBase);
122
+
123
+ function ScrollableBase(props) {
124
+ var _this;
125
+
126
+ _classCallCheck(this, ScrollableBase);
127
+
128
+ _this = _super.call(this, props);
129
+
130
+ _this.handleResizeWindow = function () {
131
+ // `handleSize` in `ui/resolution.ResolutionDecorator` should be executed first.
132
+ setTimeout(function () {
133
+ var handleResizeWindow = _this.props.handleResizeWindow;
134
+
135
+ if (handleResizeWindow) {
136
+ handleResizeWindow();
137
+ }
138
+
139
+ _this.scrollTo({
140
+ position: {
141
+ x: 0,
142
+ y: 0
143
+ },
144
+ animate: false
145
+ });
146
+
147
+ _this.enqueueForceUpdate();
148
+ });
149
+ };
150
+
151
+ _this.pixelPerLine = 39;
152
+ _this.scrollWheelMultiplierForDeltaPixel = 1.5;
153
+ _this.deferScrollTo = true;
154
+ _this.isScrollAnimationTargetAccumulated = false;
155
+ _this.isUpdatedScrollThumb = false;
156
+ _this.lastInputType = null;
157
+ _this.overscrollEnabled = false;
158
+ _this.overscrollStatus = {
159
+ horizontal: {
160
+ before: {
161
+ type: overscrollTypeNone,
162
+ ratio: 0
163
+ },
164
+ after: {
165
+ type: overscrollTypeNone,
166
+ ratio: 0
167
+ }
168
+ },
169
+ vertical: {
170
+ before: {
171
+ type: overscrollTypeNone,
172
+ ratio: 0
173
+ },
174
+ after: {
175
+ type: overscrollTypeNone,
176
+ ratio: 0
177
+ }
178
+ }
179
+ };
180
+ _this.bounds = {
181
+ clientWidth: 0,
182
+ clientHeight: 0,
183
+ scrollWidth: 0,
184
+ scrollHeight: 0,
185
+ maxTop: 0,
186
+ maxLeft: 0
187
+ };
188
+ _this.wheelDirection = 0;
189
+ _this.isDragging = false;
190
+ _this.scrolling = false;
191
+ _this.scrollLeft = 0;
192
+ _this.scrollTop = 0;
193
+ _this.scrollToInfo = null;
194
+ _this.childRefCurrent = null;
195
+ _this.animator = new _ScrollAnimator["default"]();
196
+
197
+ _this.getRtlX = function (x) {
198
+ return _this.props.rtl ? -x : x;
199
+ };
200
+
201
+ _this.onMouseDown = (0, _handle["default"])((0, _handle.forwardWithPrevent)('onMouseDown'), _this.stop).bindAs(_assertThisInitialized(_this), 'onMouseDown');
202
+
203
+ _this.onDragStart = function (ev) {
204
+ if (ev.type === 'dragstart') return;
205
+ (0, _handle.forward)('onDragStart', ev, _this.props);
206
+
207
+ _this.stop();
208
+
209
+ _this.isDragging = true;
210
+ _this.dragStartX = _this.scrollLeft + _this.getRtlX(ev.x);
211
+ _this.dragStartY = _this.scrollTop + ev.y;
212
+ };
213
+
214
+ _this.onDrag = function (ev) {
215
+ if (ev.type === 'drag') return;
216
+ var direction = _this.props.direction;
217
+ _this.lastInputType = 'drag';
218
+ (0, _handle.forward)('onDrag', ev, _this.props);
219
+
220
+ _this.start({
221
+ targetX: direction === 'vertical' ? 0 : _this.dragStartX - _this.getRtlX(ev.x),
222
+ // 'horizontal' or 'both'
223
+ targetY: direction === 'horizontal' ? 0 : _this.dragStartY - ev.y,
224
+ // 'vertical' or 'both'
225
+ animate: false,
226
+ overscrollEffect: _this.props.overscrollEffectOn.drag
227
+ });
228
+ };
229
+
230
+ _this.onDragEnd = function (ev) {
231
+ if (ev.type === 'dragend') return;
232
+ _this.isDragging = false;
233
+ (0, _handle.forward)('onDragEnd', ev, _this.props);
234
+
235
+ if (_this.flickTarget) {
236
+ var _this$flickTarget = _this.flickTarget,
237
+ targetX = _this$flickTarget.targetX,
238
+ targetY = _this$flickTarget.targetY,
239
+ duration = _this$flickTarget.duration;
240
+ _this.lastInputType = 'drag';
241
+ _this.isScrollAnimationTargetAccumulated = false;
242
+
243
+ _this.start({
244
+ targetX: targetX,
245
+ targetY: targetY,
246
+ duration: duration,
247
+ overscrollEffect: _this.props.overscrollEffectOn.drag
248
+ });
249
+ } else {
250
+ _this.stop();
251
+ }
252
+
253
+ if (_this.overscrollEnabled) {
254
+ // not check this.props.overscrollEffectOn.drag for safety
255
+ _this.clearAllOverscrollEffects();
256
+ }
257
+
258
+ _this.flickTarget = null;
259
+ };
260
+
261
+ _this.onFlick = function (ev) {
262
+ var direction = _this.props.direction;
263
+ _this.flickTarget = _this.animator.simulate(_this.scrollLeft, _this.scrollTop, direction !== 'vertical' ? _this.getRtlX(-ev.velocityX) : 0, direction !== 'horizontal' ? -ev.velocityY : 0);
264
+
265
+ if (_this.props.onFlick) {
266
+ (0, _handle.forward)('onFlick', ev, _this.props);
267
+ }
268
+ };
269
+
270
+ _this.onWheel = function (ev) {
271
+ if (_this.isDragging) {
272
+ ev.preventDefault();
273
+ ev.stopPropagation();
274
+ } else {
275
+ var _assertThisInitialize = _assertThisInitialized(_this),
276
+ verticalScrollbarRef = _assertThisInitialize.verticalScrollbarRef,
277
+ horizontalScrollbarRef = _assertThisInitialize.horizontalScrollbarRef,
278
+ bounds = _this.getScrollBounds(),
279
+ canScrollHorizontally = _this.canScrollHorizontally(bounds),
280
+ canScrollVertically = _this.canScrollVertically(bounds),
281
+ eventDeltaMode = ev.deltaMode,
282
+ eventDelta = -ev.wheelDeltaY || ev.deltaY;
283
+
284
+ var delta = 0,
285
+ direction;
286
+ _this.lastInputType = 'wheel';
287
+
288
+ if (_this.props.noScrollByWheel) {
289
+ return;
290
+ }
291
+
292
+ if (canScrollVertically) {
293
+ delta = _this.calculateDistanceByWheel(eventDeltaMode, eventDelta, bounds.clientHeight * scrollWheelPageMultiplierForMaxPixel);
294
+ } else if (canScrollHorizontally) {
295
+ delta = _this.calculateDistanceByWheel(eventDeltaMode, eventDelta, bounds.clientWidth * scrollWheelPageMultiplierForMaxPixel);
296
+ }
297
+
298
+ direction = Math.sign(delta);
299
+
300
+ if (direction !== _this.wheelDirection) {
301
+ _this.isScrollAnimationTargetAccumulated = false;
302
+ _this.wheelDirection = direction;
303
+ }
304
+
305
+ (0, _handle.forward)('onWheel', {
306
+ delta: delta,
307
+ horizontalScrollbarRef: horizontalScrollbarRef,
308
+ verticalScrollbarRef: verticalScrollbarRef
309
+ }, _this.props);
310
+
311
+ if (delta !== 0) {
312
+ _this.scrollToAccumulatedTarget(delta, canScrollVertically, _this.props.overscrollEffectOn.wheel);
313
+
314
+ ev.preventDefault();
315
+ ev.stopPropagation();
316
+ }
317
+ }
318
+ };
319
+
320
+ _this.scrollByPage = function (keyCode) {
321
+ var bounds = _this.getScrollBounds(),
322
+ canScrollVertically = _this.canScrollVertically(bounds),
323
+ pageDistance = (isPageUp(keyCode) ? -1 : 1) * (canScrollVertically ? bounds.clientHeight : bounds.clientWidth) * paginationPageMultiplier;
324
+
325
+ _this.lastInputType = 'pageKey';
326
+
327
+ _this.scrollToAccumulatedTarget(pageDistance, canScrollVertically, _this.props.overscrollEffectOn.pageKey);
328
+ };
329
+
330
+ _this.onKeyDown = function (ev) {
331
+ if (_this.props.onKeyDown) {
332
+ (0, _handle.forward)('onKeyDown', ev, _this.props);
333
+ } else if (isPageUp(ev.keyCode) || isPageDown(ev.keyCode)) {
334
+ _this.scrollByPage(ev.keyCode);
335
+ }
336
+ };
337
+
338
+ _this.scrollToAccumulatedTarget = function (delta, vertical, overscrollEffect) {
339
+ if (!_this.isScrollAnimationTargetAccumulated) {
340
+ _this.accumulatedTargetX = _this.scrollLeft;
341
+ _this.accumulatedTargetY = _this.scrollTop;
342
+ _this.isScrollAnimationTargetAccumulated = true;
343
+ }
344
+
345
+ if (vertical) {
346
+ _this.accumulatedTargetY += delta;
347
+ } else {
348
+ _this.accumulatedTargetX += delta;
349
+ }
350
+
351
+ _this.start({
352
+ targetX: _this.accumulatedTargetX,
353
+ targetY: _this.accumulatedTargetY,
354
+ overscrollEffect: overscrollEffect
355
+ });
356
+ };
357
+
358
+ _this.getEdgeFromPosition = function (position, maxPosition) {
359
+ if (position <= 0) {
360
+ return 'before';
361
+ } else if (position >= maxPosition) {
362
+ return 'after';
363
+ } else {
364
+ return null;
365
+ }
366
+ };
367
+
368
+ _this.setOverscrollStatus = function (orientation, edge, type, ratio) {
369
+ var status = _this.overscrollStatus[orientation][edge];
370
+ status.type = type;
371
+ status.ratio = ratio;
372
+ };
373
+
374
+ _this.getOverscrollStatus = function (orientation, edge) {
375
+ return _this.overscrollStatus[orientation][edge];
376
+ };
377
+
378
+ _this.calculateOverscrollRatio = function (orientation, position) {
379
+ var bounds = _this.getScrollBounds(),
380
+ isVertical = orientation === 'vertical',
381
+ baseSize = isVertical ? bounds.clientHeight : bounds.clientWidth,
382
+ maxPos = bounds[isVertical ? 'maxTop' : 'maxLeft'];
383
+
384
+ var overDistance = 0;
385
+
386
+ if (position < 0) {
387
+ overDistance = -position;
388
+ } else if (position > maxPos) {
389
+ overDistance = position - maxPos;
390
+ } else {
391
+ return 0;
392
+ }
393
+
394
+ return Math.min(1, 2 * overDistance / baseSize);
395
+ };
396
+
397
+ _this.applyOverscrollEffect = function (orientation, edge, type, ratio) {
398
+ _this.props.applyOverscrollEffect(orientation, edge, type, ratio);
399
+
400
+ _this.setOverscrollStatus(orientation, edge, type === overscrollTypeOnce ? overscrollTypeDone : type, ratio);
401
+ };
402
+
403
+ _this.checkAndApplyOverscrollEffect = function (orientation, edge, type) {
404
+ var ratio = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
405
+
406
+ var isVertical = orientation === 'vertical',
407
+ curPos = isVertical ? _this.scrollTop : _this.scrollLeft,
408
+ maxPos = _this.getScrollBounds()[isVertical ? 'maxTop' : 'maxLeft'];
409
+
410
+ if (edge === 'before' && curPos <= 0 || edge === 'after' && curPos >= maxPos) {
411
+ // Already on the edge
412
+ _this.applyOverscrollEffect(orientation, edge, type, ratio);
413
+ } else {
414
+ _this.setOverscrollStatus(orientation, edge, type, ratio);
415
+ }
416
+ };
417
+
418
+ _this.clearOverscrollEffect = function (orientation, edge) {
419
+ if (_this.getOverscrollStatus(orientation, edge).type !== overscrollTypeNone) {
420
+ if (_this.props.clearOverscrollEffect) {
421
+ _this.props.clearOverscrollEffect(orientation, edge);
422
+ } else {
423
+ _this.applyOverscrollEffect(orientation, edge, overscrollTypeNone, 0);
424
+ }
425
+ }
426
+ };
427
+
428
+ _this.clearAllOverscrollEffects = function () {
429
+ ['horizontal', 'vertical'].forEach(function (orientation) {
430
+ ['before', 'after'].forEach(function (edge) {
431
+ _this.clearOverscrollEffect(orientation, edge);
432
+ });
433
+ });
434
+ };
435
+
436
+ _this.applyOverscrollEffectOnDrag = function (orientation, edge, targetPosition, type) {
437
+ if (edge) {
438
+ var oppositeEdge = edge === 'before' ? 'after' : 'before',
439
+ ratio = _this.calculateOverscrollRatio(orientation, targetPosition);
440
+
441
+ _this.applyOverscrollEffect(orientation, edge, type, ratio);
442
+
443
+ _this.clearOverscrollEffect(orientation, oppositeEdge);
444
+ } else {
445
+ _this.clearOverscrollEffect(orientation, 'before');
446
+
447
+ _this.clearOverscrollEffect(orientation, 'after');
448
+ }
449
+ };
450
+
451
+ _this.checkAndApplyOverscrollEffectOnScroll = function (orientation) {
452
+ ['before', 'after'].forEach(function (edge) {
453
+ var _this$getOverscrollSt = _this.getOverscrollStatus(orientation, edge),
454
+ ratio = _this$getOverscrollSt.ratio,
455
+ type = _this$getOverscrollSt.type;
456
+
457
+ if (type === overscrollTypeOnce) {
458
+ _this.checkAndApplyOverscrollEffect(orientation, edge, type, ratio);
459
+ }
460
+ });
461
+ };
462
+
463
+ _this.checkAndApplyOverscrollEffectOnStart = function (orientation, edge, targetPosition) {
464
+ if (_this.isDragging) {
465
+ _this.applyOverscrollEffectOnDrag(orientation, edge, targetPosition, overscrollTypeHold);
466
+ } else if (edge) {
467
+ _this.checkAndApplyOverscrollEffect(orientation, edge, overscrollTypeOnce);
468
+ }
469
+ };
470
+
471
+ _this.getReachedEdgeInfo = function () {
472
+ var bounds = _this.getScrollBounds(),
473
+ reachedEdgeInfo = {
474
+ bottom: false,
475
+ left: false,
476
+ right: false,
477
+ top: false
478
+ };
479
+
480
+ if (_this.canScrollHorizontally(bounds)) {
481
+ var rtl = _this.props.rtl,
482
+ edge = _this.getEdgeFromPosition(_this.scrollLeft, bounds.maxLeft);
483
+
484
+ if (edge) {
485
+ // if edge is null, no need to check which edge is reached.
486
+ if (edge === 'before' && !rtl || edge === 'after' && rtl) {
487
+ reachedEdgeInfo.left = true;
488
+ } else {
489
+ reachedEdgeInfo.right = true;
490
+ }
491
+ }
492
+ }
493
+
494
+ if (_this.canScrollVertically(bounds)) {
495
+ var _edge = _this.getEdgeFromPosition(_this.scrollTop, bounds.maxTop);
496
+
497
+ if (_edge === 'before') {
498
+ reachedEdgeInfo.top = true;
499
+ } else if (_edge === 'after') {
500
+ reachedEdgeInfo.bottom = true;
501
+ }
502
+ }
503
+
504
+ return reachedEdgeInfo;
505
+ };
506
+
507
+ _this.doScrollStop = function () {
508
+ _this.scrolling = false;
509
+
510
+ _this.forwardScrollEvent('onScrollStop', _this.getReachedEdgeInfo());
511
+ };
512
+
513
+ _this.scrollStopJob = new _util.Job(_this.doScrollStop, scrollStopWaiting);
514
+
515
+ _this.scrollAnimation = function (animationInfo) {
516
+ return function (curTime) {
517
+ var sourceX = animationInfo.sourceX,
518
+ sourceY = animationInfo.sourceY,
519
+ targetX = animationInfo.targetX,
520
+ targetY = animationInfo.targetY,
521
+ duration = animationInfo.duration,
522
+ bounds = _this.getScrollBounds();
523
+
524
+ if (curTime < duration) {
525
+ var toBeContinued = false,
526
+ curTargetX = sourceX,
527
+ curTargetY = sourceY;
528
+
529
+ if (_this.canScrollHorizontally(bounds)) {
530
+ curTargetX = _this.animator.timingFunction(sourceX, targetX, duration, curTime);
531
+
532
+ if (Math.abs(curTargetX - targetX) < epsilon) {
533
+ curTargetX = targetX;
534
+ } else {
535
+ toBeContinued = true;
536
+ }
537
+ }
538
+
539
+ if (_this.canScrollVertically(bounds)) {
540
+ curTargetY = _this.animator.timingFunction(sourceY, targetY, duration, curTime);
541
+
542
+ if (Math.abs(curTargetY - targetY) < epsilon) {
543
+ curTargetY = targetY;
544
+ } else {
545
+ toBeContinued = true;
546
+ }
547
+ }
548
+
549
+ _this.scroll(curTargetX, curTargetY, targetX, targetY);
550
+
551
+ if (!toBeContinued) {
552
+ _this.stop();
553
+ }
554
+ } else {
555
+ _this.scroll(targetX, targetY, targetX, targetY);
556
+
557
+ _this.stop();
558
+ }
559
+ };
560
+ };
561
+
562
+ _this.scroll = function (left, top) {
563
+ var _this$childRefCurrent;
564
+
565
+ if (left !== _this.scrollLeft) {
566
+ _this.setScrollLeft(left);
567
+ }
568
+
569
+ if (top !== _this.scrollTop) {
570
+ _this.setScrollTop(top);
571
+ }
572
+
573
+ for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
574
+ rest[_key - 2] = arguments[_key];
575
+ }
576
+
577
+ (_this$childRefCurrent = _this.childRefCurrent).setScrollPosition.apply(_this$childRefCurrent, [_this.scrollLeft, _this.scrollTop, _this.props.rtl].concat(rest));
578
+
579
+ _this.forwardScrollEvent('onScroll');
580
+ };
581
+
582
+ _this.getPositionForScrollTo = function (opt) {
583
+ var bounds = _this.getScrollBounds(),
584
+ canScrollHorizontally = _this.canScrollHorizontally(bounds),
585
+ canScrollVertically = _this.canScrollVertically(bounds);
586
+
587
+ var itemPos,
588
+ left = null,
589
+ top = null;
590
+
591
+ if (opt instanceof Object) {
592
+ if (opt.position instanceof Object) {
593
+ if (canScrollHorizontally) {
594
+ // We need '!=' to check if opt.position.x is null or undefined
595
+ left = opt.position.x != null ? opt.position.x : _this.scrollLeft;
596
+ } else {
597
+ left = 0;
598
+ }
599
+
600
+ if (canScrollVertically) {
601
+ // We need '!=' to check if opt.position.y is null or undefined
602
+ top = opt.position.y != null ? opt.position.y : _this.scrollTop;
603
+ } else {
604
+ top = 0;
605
+ }
606
+ } else if (typeof opt.align === 'string') {
607
+ if (canScrollHorizontally) {
608
+ if (opt.align.includes('left')) {
609
+ left = 0;
610
+ } else if (opt.align.includes('right')) {
611
+ left = bounds.maxLeft;
612
+ }
613
+ }
614
+
615
+ if (canScrollVertically) {
616
+ if (opt.align.includes('top')) {
617
+ top = 0;
618
+ } else if (opt.align.includes('bottom')) {
619
+ top = bounds.maxTop;
620
+ }
621
+ }
622
+ } else {
623
+ if (typeof opt.index === 'number' && typeof _this.childRefCurrent.getItemPosition === 'function') {
624
+ itemPos = _this.childRefCurrent.getItemPosition(opt.index, opt.stickTo);
625
+ } else if (opt.node instanceof Object) {
626
+ if (opt.node.nodeType === 1 && typeof _this.childRefCurrent.getNodePosition === 'function') {
627
+ itemPos = _this.childRefCurrent.getNodePosition(opt.node);
628
+ }
629
+ }
630
+
631
+ if (itemPos) {
632
+ if (canScrollHorizontally) {
633
+ left = itemPos.left;
634
+ }
635
+
636
+ if (canScrollVertically) {
637
+ top = itemPos.top;
638
+ }
639
+ }
640
+ }
641
+ }
642
+
643
+ return {
644
+ left: left,
645
+ top: top
646
+ };
647
+ };
648
+
649
+ _this.scrollTo = function (opt) {
650
+ if (!_this.deferScrollTo) {
651
+ var _this$getPositionForS = _this.getPositionForScrollTo(opt),
652
+ left = _this$getPositionForS.left,
653
+ top = _this$getPositionForS.top;
654
+
655
+ if (_this.props.scrollTo) {
656
+ _this.props.scrollTo(opt);
657
+ }
658
+
659
+ _this.scrollToInfo = null;
660
+
661
+ _this.start({
662
+ targetX: left !== null ? left : _this.scrollLeft,
663
+ targetY: top !== null ? top : _this.scrollTop,
664
+ animate: opt.animate
665
+ });
666
+ } else {
667
+ _this.scrollToInfo = opt;
668
+ }
669
+ };
670
+
671
+ _this.canScrollHorizontally = function (bounds) {
672
+ var direction = _this.props.direction;
673
+ return (direction === 'horizontal' || direction === 'both') && bounds.scrollWidth > bounds.clientWidth && !isNaN(bounds.scrollWidth);
674
+ };
675
+
676
+ _this.canScrollVertically = function (bounds) {
677
+ var direction = _this.props.direction;
678
+ return (direction === 'vertical' || direction === 'both') && bounds.scrollHeight > bounds.clientHeight && !isNaN(bounds.scrollHeight);
679
+ };
680
+
681
+ _this.startHidingThumb = function () {
682
+ if (_this.state.isHorizontalScrollbarVisible && _this.horizontalScrollbarRef.current) {
683
+ _this.horizontalScrollbarRef.current.startHidingThumb();
684
+ }
685
+
686
+ if (_this.state.isVerticalScrollbarVisible && _this.verticalScrollbarRef.current) {
687
+ _this.verticalScrollbarRef.current.startHidingThumb();
688
+ }
689
+ };
690
+
691
+ _this.updateScrollbars = function () {
692
+ var _this$props = _this.props,
693
+ horizontalScrollbar = _this$props.horizontalScrollbar,
694
+ verticalScrollbar = _this$props.verticalScrollbar,
695
+ _this$state = _this.state,
696
+ isHorizontalScrollbarVisible = _this$state.isHorizontalScrollbarVisible,
697
+ isVerticalScrollbarVisible = _this$state.isVerticalScrollbarVisible,
698
+ bounds = _this.getScrollBounds(),
699
+ canScrollHorizontally = _this.canScrollHorizontally(bounds),
700
+ canScrollVertically = _this.canScrollVertically(bounds),
701
+ curHorizontalScrollbarVisible = horizontalScrollbar === 'auto' ? canScrollHorizontally : horizontalScrollbar === 'visible',
702
+ curVerticalScrollbarVisible = verticalScrollbar === 'auto' ? canScrollVertically : verticalScrollbar === 'visible'; // determine if we should hide or show any scrollbars
703
+
704
+
705
+ var isVisibilityChanged = isHorizontalScrollbarVisible !== curHorizontalScrollbarVisible || isVerticalScrollbarVisible !== curVerticalScrollbarVisible;
706
+
707
+ if (isVisibilityChanged) {
708
+ // one or both scrollbars have changed visibility
709
+ _this.setState({
710
+ isHorizontalScrollbarVisible: curHorizontalScrollbarVisible,
711
+ isVerticalScrollbarVisible: curVerticalScrollbarVisible
712
+ });
713
+ } else {
714
+ _this.deferScrollTo = false;
715
+ _this.isUpdatedScrollThumb = _this.updateScrollThumbSize();
716
+ }
717
+ };
718
+
719
+ _this.updateScrollThumbSize = function () {
720
+ var _this$props2 = _this.props,
721
+ horizontalScrollbar = _this$props2.horizontalScrollbar,
722
+ verticalScrollbar = _this$props2.verticalScrollbar,
723
+ bounds = _this.getScrollBounds(),
724
+ canScrollHorizontally = _this.canScrollHorizontally(bounds),
725
+ canScrollVertically = _this.canScrollVertically(bounds),
726
+ curHorizontalScrollbarVisible = horizontalScrollbar === 'auto' ? canScrollHorizontally : horizontalScrollbar === 'visible',
727
+ curVerticalScrollbarVisible = verticalScrollbar === 'auto' ? canScrollVertically : verticalScrollbar === 'visible';
728
+
729
+ if (curHorizontalScrollbarVisible || curVerticalScrollbarVisible) {
730
+ // no visibility change but need to notify whichever scrollbars are visible of the
731
+ // updated bounds and scroll position
732
+ var updatedBounds = _objectSpread(_objectSpread({}, bounds), {}, {
733
+ scrollLeft: _this.scrollLeft,
734
+ scrollTop: _this.scrollTop
735
+ });
736
+
737
+ if (curHorizontalScrollbarVisible && _this.horizontalScrollbarRef.current) {
738
+ _this.horizontalScrollbarRef.current.update(updatedBounds);
739
+ }
740
+
741
+ if (curVerticalScrollbarVisible && _this.verticalScrollbarRef.current) {
742
+ _this.verticalScrollbarRef.current.update(updatedBounds);
743
+ }
744
+
745
+ return true;
746
+ }
747
+
748
+ return false;
749
+ };
750
+
751
+ _this.initChildRef = function (ref) {
752
+ if (ref) {
753
+ _this.childRefCurrent = ref;
754
+ }
755
+ };
756
+
757
+ _this.handleScroll = function () {
758
+ var childRefCurrent = _this.childRefCurrent; // Prevent scroll by focus.
759
+ // VirtualList and VirtualGridList DO NOT receive `onscroll` event.
760
+ // Only Scroller could get `onscroll` event.
761
+
762
+ if (!_this.animator.isAnimating() && childRefCurrent && childRefCurrent.containerRef.current && childRefCurrent.getRtlPositionX) {
763
+ // For Scroller
764
+ childRefCurrent.containerRef.current.scrollTop = _this.scrollTop;
765
+ childRefCurrent.containerRef.current.scrollLeft = childRefCurrent.getRtlPositionX(_this.scrollLeft);
766
+ }
767
+ };
768
+
769
+ _this.state = {
770
+ remeasure: false,
771
+ isHorizontalScrollbarVisible: props.horizontalScrollbar === 'visible',
772
+ isVerticalScrollbarVisible: props.verticalScrollbar === 'visible'
773
+ };
774
+ _this.containerRef = /*#__PURE__*/_react["default"].createRef();
775
+ _this.horizontalScrollbarRef = /*#__PURE__*/_react["default"].createRef();
776
+ _this.verticalScrollbarRef = /*#__PURE__*/_react["default"].createRef();
777
+ _this.horizontalScrollbarProps = {
778
+ ref: _this.horizontalScrollbarRef,
779
+ vertical: false,
780
+ clientSize: props.clientSize
781
+ };
782
+ _this.verticalScrollbarProps = {
783
+ ref: _this.verticalScrollbarRef,
784
+ vertical: true,
785
+ clientSize: props.clientSize
786
+ };
787
+ _this.overscrollEnabled = !!props.applyOverscrollEffect; // Enable the early bail out of repeated scrolling to the same position
788
+
789
+ _this.animationInfo = null;
790
+ _this.resizeRegistry = _Registry["default"].create(_this.handleResize.bind(_assertThisInitialized(_this)));
791
+ props.cbScrollTo(_this.scrollTo);
792
+ return _this;
793
+ }
794
+
795
+ _createClass(ScrollableBase, [{
796
+ key: "componentDidMount",
797
+ value: function componentDidMount() {
798
+ this.resizeRegistry.parent = this.context;
799
+ this.addEventListeners();
800
+ this.updateScrollbars();
801
+ }
802
+ }, {
803
+ key: "componentDidUpdate",
804
+ value: function componentDidUpdate(prevProps, prevState) {
805
+ var _this$state2 = this.state,
806
+ isHorizontalScrollbarVisible = _this$state2.isHorizontalScrollbarVisible,
807
+ isVerticalScrollbarVisible = _this$state2.isVerticalScrollbarVisible,
808
+ hasDataSizeChanged = this.childRefCurrent.hasDataSizeChanged; // Need to sync calculated client size if it is different from the real size
809
+
810
+ if (this.childRefCurrent.syncClientSize) {
811
+ // If we actually synced, we need to reset scroll position.
812
+ if (this.childRefCurrent.syncClientSize()) {
813
+ this.setScrollLeft(0);
814
+ this.setScrollTop(0);
815
+ }
816
+ }
817
+
818
+ this.clampScrollPosition();
819
+ this.addEventListeners();
820
+
821
+ if (hasDataSizeChanged === false && (isHorizontalScrollbarVisible && !prevState.isHorizontalScrollbarVisible || isVerticalScrollbarVisible && !prevState.isVerticalScrollbarVisible)) {
822
+ this.deferScrollTo = false;
823
+ this.isUpdatedScrollThumb = this.updateScrollThumbSize();
824
+ } else {
825
+ this.updateScrollbars();
826
+ }
827
+
828
+ if (this.scrollToInfo !== null) {
829
+ if (!this.deferScrollTo) {
830
+ this.scrollTo(this.scrollToInfo);
831
+ }
832
+ } // publish container resize changes
833
+
834
+
835
+ var horizontal = isHorizontalScrollbarVisible !== prevState.isHorizontalScrollbarVisible;
836
+ var vertical = isVerticalScrollbarVisible !== prevState.isVerticalScrollbarVisible;
837
+
838
+ if (horizontal || vertical) {
839
+ this.resizeRegistry.notify({});
840
+ }
841
+ }
842
+ }, {
843
+ key: "componentWillUnmount",
844
+ value: function componentWillUnmount() {
845
+ this.resizeRegistry.parent = null; // Before call cancelAnimationFrame, you must send scrollStop Event.
846
+
847
+ if (this.scrolling) {
848
+ this.forwardScrollEvent('onScrollStop', this.getReachedEdgeInfo());
849
+ }
850
+
851
+ this.scrollStopJob.stop();
852
+
853
+ if (this.animator.isAnimating()) {
854
+ this.animator.stop();
855
+ }
856
+
857
+ this.removeEventListeners();
858
+ }
859
+ }, {
860
+ key: "handleResize",
861
+ value: function handleResize(ev) {
862
+ if (ev.action === 'invalidateBounds') {
863
+ this.enqueueForceUpdate();
864
+ }
865
+ }
866
+ }, {
867
+ key: "enqueueForceUpdate",
868
+ // TODO: consider replacing forceUpdate() by storing bounds in state rather than a non-
869
+ // state member.
870
+ value: function enqueueForceUpdate() {
871
+ this.childRefCurrent.calculateMetrics(this.childRefCurrent.props);
872
+ this.forceUpdate();
873
+ }
874
+ }, {
875
+ key: "clampScrollPosition",
876
+ value: function clampScrollPosition() {
877
+ var bounds = this.getScrollBounds();
878
+
879
+ if (this.scrollTop > bounds.maxTop) {
880
+ this.scrollTop = bounds.maxTop;
881
+ }
882
+
883
+ if (this.scrollLeft > bounds.maxLeft) {
884
+ this.scrollLeft = bounds.maxLeft;
885
+ }
886
+ } // constants
887
+
888
+ }, {
889
+ key: "calculateDistanceByWheel",
890
+ value: function calculateDistanceByWheel(deltaMode, delta, maxPixel) {
891
+ if (deltaMode === 0) {
892
+ delta = (0, _clamp["default"])(-maxPixel, maxPixel, _resolution["default"].scale(delta * this.scrollWheelMultiplierForDeltaPixel));
893
+ } else if (deltaMode === 1) {
894
+ // line; firefox
895
+ delta = (0, _clamp["default"])(-maxPixel, maxPixel, _resolution["default"].scale(delta * this.pixelPerLine * this.scrollWheelMultiplierForDeltaPixel));
896
+ } else if (deltaMode === 2) {
897
+ // page
898
+ delta = delta < 0 ? -maxPixel : maxPixel;
899
+ }
900
+
901
+ return delta;
902
+ }
903
+ }, {
904
+ key: "forwardScrollEvent",
905
+ // call scroll callbacks
906
+ value: function forwardScrollEvent(type, reachedEdgeInfo) {
907
+ (0, _handle.forward)(type, {
908
+ scrollLeft: this.scrollLeft,
909
+ scrollTop: this.scrollTop,
910
+ moreInfo: this.getMoreInfo(),
911
+ reachedEdgeInfo: reachedEdgeInfo
912
+ }, this.props);
913
+ } // update scroll position
914
+
915
+ }, {
916
+ key: "setScrollLeft",
917
+ value: function setScrollLeft(value) {
918
+ var bounds = this.getScrollBounds();
919
+ this.scrollLeft = (0, _clamp["default"])(0, bounds.maxLeft, value);
920
+
921
+ if (this.overscrollEnabled && this.props.overscrollEffectOn[this.lastInputType]) {
922
+ this.checkAndApplyOverscrollEffectOnScroll('horizontal');
923
+ }
924
+
925
+ if (this.state.isHorizontalScrollbarVisible) {
926
+ this.updateThumb(this.horizontalScrollbarRef, bounds);
927
+ }
928
+ }
929
+ }, {
930
+ key: "setScrollTop",
931
+ value: function setScrollTop(value) {
932
+ var bounds = this.getScrollBounds();
933
+ this.scrollTop = (0, _clamp["default"])(0, bounds.maxTop, value);
934
+
935
+ if (this.overscrollEnabled && this.props.overscrollEffectOn[this.lastInputType]) {
936
+ this.checkAndApplyOverscrollEffectOnScroll('vertical');
937
+ }
938
+
939
+ if (this.state.isVerticalScrollbarVisible) {
940
+ this.updateThumb(this.verticalScrollbarRef, bounds);
941
+ }
942
+ }
943
+ }, {
944
+ key: "start",
945
+ value: function start(_ref) {
946
+ var targetX = _ref.targetX,
947
+ targetY = _ref.targetY,
948
+ _ref$animate = _ref.animate,
949
+ animate = _ref$animate === void 0 ? true : _ref$animate,
950
+ _ref$duration = _ref.duration,
951
+ duration = _ref$duration === void 0 ? animationDuration : _ref$duration,
952
+ _ref$overscrollEffect = _ref.overscrollEffect,
953
+ overscrollEffect = _ref$overscrollEffect === void 0 ? false : _ref$overscrollEffect;
954
+ var scrollLeft = this.scrollLeft,
955
+ scrollTop = this.scrollTop,
956
+ bounds = this.getScrollBounds(),
957
+ maxLeft = bounds.maxLeft,
958
+ maxTop = bounds.maxTop;
959
+ var updatedAnimationInfo = {
960
+ sourceX: scrollLeft,
961
+ sourceY: scrollTop,
962
+ targetX: targetX,
963
+ targetY: targetY,
964
+ duration: duration
965
+ }; // bail early when scrolling to the same position
966
+
967
+ if (this.animator.isAnimating() && this.animationInfo && this.animationInfo.targetX === targetX && this.animationInfo.targetY === targetY) {
968
+ return;
969
+ }
970
+
971
+ this.animationInfo = updatedAnimationInfo;
972
+ this.animator.stop();
973
+
974
+ if (!this.scrolling) {
975
+ this.scrolling = true;
976
+ this.forwardScrollEvent('onScrollStart');
977
+ }
978
+
979
+ this.scrollStopJob.stop();
980
+
981
+ if (Math.abs(maxLeft - targetX) < epsilon) {
982
+ targetX = maxLeft;
983
+ }
984
+
985
+ if (Math.abs(maxTop - targetY) < epsilon) {
986
+ targetY = maxTop;
987
+ }
988
+
989
+ if (this.overscrollEnabled && overscrollEffect) {
990
+ if (scrollLeft !== targetX && this.canScrollHorizontally(bounds)) {
991
+ this.checkAndApplyOverscrollEffectOnStart('horizontal', this.getEdgeFromPosition(targetX, maxLeft), targetX);
992
+ }
993
+
994
+ if (scrollTop !== targetY && this.canScrollVertically(bounds)) {
995
+ this.checkAndApplyOverscrollEffectOnStart('vertical', this.getEdgeFromPosition(targetY, maxTop), targetY);
996
+ }
997
+ }
998
+
999
+ this.showThumb(bounds);
1000
+
1001
+ if (animate) {
1002
+ this.animator.animate(this.scrollAnimation(this.animationInfo));
1003
+ } else {
1004
+ this.scroll(targetX, targetY, targetX, targetY);
1005
+ this.stop();
1006
+ }
1007
+ }
1008
+ }, {
1009
+ key: "stop",
1010
+ value: function stop() {
1011
+ this.animator.stop();
1012
+ this.lastInputType = null;
1013
+ this.isScrollAnimationTargetAccumulated = false;
1014
+ this.startHidingThumb();
1015
+
1016
+ if (this.overscrollEnabled && !this.isDragging) {
1017
+ // not check this.props.overscrollEffectOn for safety
1018
+ this.clearAllOverscrollEffects();
1019
+ }
1020
+
1021
+ if (this.props.stop) {
1022
+ this.props.stop();
1023
+ }
1024
+
1025
+ if (this.scrolling) {
1026
+ this.scrollStopJob.start();
1027
+ }
1028
+ } // scrollTo API
1029
+
1030
+ }, {
1031
+ key: "showThumb",
1032
+ // scroll bar
1033
+ value: function showThumb(bounds) {
1034
+ if (this.state.isHorizontalScrollbarVisible && this.canScrollHorizontally(bounds) && this.horizontalScrollbarRef.current) {
1035
+ this.horizontalScrollbarRef.current.showThumb();
1036
+ }
1037
+
1038
+ if (this.state.isVerticalScrollbarVisible && this.canScrollVertically(bounds) && this.verticalScrollbarRef.current) {
1039
+ this.verticalScrollbarRef.current.showThumb();
1040
+ }
1041
+ }
1042
+ }, {
1043
+ key: "updateThumb",
1044
+ value: function updateThumb(scrollbarRef, bounds) {
1045
+ scrollbarRef.current.update(_objectSpread(_objectSpread({}, bounds), {}, {
1046
+ scrollLeft: this.scrollLeft,
1047
+ scrollTop: this.scrollTop
1048
+ }));
1049
+ }
1050
+ }, {
1051
+ key: "getScrollBounds",
1052
+ // ref
1053
+ value: function getScrollBounds() {
1054
+ if (this.childRefCurrent && typeof this.childRefCurrent.getScrollBounds === 'function') {
1055
+ return this.childRefCurrent.getScrollBounds();
1056
+ }
1057
+ }
1058
+ }, {
1059
+ key: "getMoreInfo",
1060
+ value: function getMoreInfo() {
1061
+ if (this.childRefCurrent && typeof this.childRefCurrent.getMoreInfo === 'function') {
1062
+ return this.childRefCurrent.getMoreInfo();
1063
+ }
1064
+ } // FIXME setting event handlers directly to work on the V8 snapshot.
1065
+
1066
+ }, {
1067
+ key: "addEventListeners",
1068
+ value: function addEventListeners() {
1069
+ var childRefCurrent = this.childRefCurrent,
1070
+ containerRef = this.containerRef;
1071
+
1072
+ if (containerRef.current && containerRef.current.addEventListener) {
1073
+ containerRef.current.addEventListener('wheel', this.onWheel);
1074
+ containerRef.current.addEventListener('keydown', this.onKeyDown);
1075
+ containerRef.current.addEventListener('mousedown', this.onMouseDown);
1076
+ }
1077
+
1078
+ if (this.props.addEventListeners) {
1079
+ this.props.addEventListeners(childRefCurrent.containerRef);
1080
+ }
1081
+
1082
+ if (window) {
1083
+ window.addEventListener('resize', this.handleResizeWindow);
1084
+ }
1085
+ } // FIXME setting event handlers directly to work on the V8 snapshot.
1086
+
1087
+ }, {
1088
+ key: "removeEventListeners",
1089
+ value: function removeEventListeners() {
1090
+ var childRefCurrent = this.childRefCurrent,
1091
+ containerRef = this.containerRef;
1092
+
1093
+ if (containerRef.current && containerRef.current.removeEventListener) {
1094
+ containerRef.current.removeEventListener('wheel', this.onWheel);
1095
+ containerRef.current.removeEventListener('keydown', this.onKeyDown);
1096
+ containerRef.current.removeEventListener('mousedown', this.onMouseDown);
1097
+ }
1098
+
1099
+ if (this.props.removeEventListeners) {
1100
+ this.props.removeEventListeners(childRefCurrent.containerRef);
1101
+ }
1102
+
1103
+ if (window) {
1104
+ window.removeEventListener('resize', this.handleResizeWindow);
1105
+ }
1106
+ } // render
1107
+
1108
+ }, {
1109
+ key: "render",
1110
+ value: function render() {
1111
+ var _this$props3 = this.props,
1112
+ className = _this$props3.className,
1113
+ containerRenderer = _this$props3.containerRenderer,
1114
+ noScrollByDrag = _this$props3.noScrollByDrag,
1115
+ rtl = _this$props3.rtl,
1116
+ style = _this$props3.style,
1117
+ rest = _objectWithoutProperties(_this$props3, ["className", "containerRenderer", "noScrollByDrag", "rtl", "style"]),
1118
+ _this$state3 = this.state,
1119
+ isHorizontalScrollbarVisible = _this$state3.isHorizontalScrollbarVisible,
1120
+ isVerticalScrollbarVisible = _this$state3.isVerticalScrollbarVisible,
1121
+ scrollableClasses = (0, _classnames["default"])(_ScrollableModule["default"].scrollable, className),
1122
+ childWrapper = noScrollByDrag ? 'div' : TouchableDiv,
1123
+ childWrapperProps = _objectSpread({
1124
+ className: _ScrollableModule["default"].content
1125
+ }, !noScrollByDrag && {
1126
+ flickConfig: flickConfig,
1127
+ onDrag: this.onDrag,
1128
+ onDragEnd: this.onDragEnd,
1129
+ onDragStart: this.onDragStart,
1130
+ onFlick: this.onFlick
1131
+ });
1132
+
1133
+ delete rest.addEventListeners;
1134
+ delete rest.applyOverscrollEffect;
1135
+ delete rest.cbScrollTo;
1136
+ delete rest.clearOverscrollEffect;
1137
+ delete rest.handleResizeWindow;
1138
+ delete rest.horizontalScrollbar;
1139
+ delete rest.noScrollByWheel;
1140
+ delete rest.onFlick;
1141
+ delete rest.onKeyDown;
1142
+ delete rest.onMouseDown;
1143
+ delete rest.onScroll;
1144
+ delete rest.onScrollStart;
1145
+ delete rest.onScrollStop;
1146
+ delete rest.onWheel;
1147
+ delete rest.overscrollEffectOn;
1148
+ delete rest.removeEventListeners;
1149
+ delete rest.scrollTo;
1150
+ delete rest.stop;
1151
+ delete rest.verticalScrollbar;
1152
+ this.deferScrollTo = true;
1153
+ return /*#__PURE__*/_react["default"].createElement(_Resizable.ResizeContext.Provider, {
1154
+ value: this.resizeRegistry.register
1155
+ }, containerRenderer({
1156
+ childComponentProps: rest,
1157
+ childWrapper: childWrapper,
1158
+ childWrapperProps: childWrapperProps,
1159
+ className: scrollableClasses,
1160
+ componentCss: _ScrollableModule["default"],
1161
+ containerRef: this.containerRef,
1162
+ handleScroll: this.handleScroll,
1163
+ horizontalScrollbarProps: this.horizontalScrollbarProps,
1164
+ initChildRef: this.initChildRef,
1165
+ isHorizontalScrollbarVisible: isHorizontalScrollbarVisible,
1166
+ isVerticalScrollbarVisible: isVerticalScrollbarVisible,
1167
+ rtl: rtl,
1168
+ scrollTo: this.scrollTo,
1169
+ style: style,
1170
+ verticalScrollbarProps: this.verticalScrollbarProps
1171
+ }));
1172
+ }
1173
+ }]);
1174
+
1175
+ return ScrollableBase;
1176
+ }(_react.Component);
1387
1177
  /**
1388
1178
  * An unstyled component that provides horizontal and vertical scrollbars and makes a render prop element scrollable.
1389
1179
  *
@@ -1393,72 +1183,430 @@ class ScrollableBase extends Component {
1393
1183
  * @ui
1394
1184
  * @private
1395
1185
  */
1396
- class Scrollable extends Component {
1397
- static displayName = 'ui:Scrollable';
1398
-
1399
- static propTypes = /** @lends ui/Scrollable.Scrollable.prototype */ {
1400
- /**
1401
- * Render function.
1402
- *
1403
- * @type {Function}
1404
- * @required
1405
- * @private
1406
- */
1407
- childRenderer: PropTypes.func.isRequired
1408
- };
1409
-
1410
- render () {
1411
- const {childRenderer, ...rest} = this.props;
1412
-
1413
- return (
1414
- <ScrollableBase
1415
- {...rest}
1416
- containerRenderer={({ // eslint-disable-line react/jsx-no-bind
1417
- childComponentProps,
1418
- childWrapper: ChildWrapper,
1419
- childWrapperProps,
1420
- containerRef,
1421
- className,
1422
- componentCss,
1423
- handleScroll,
1424
- horizontalScrollbarProps,
1425
- initChildRef,
1426
- isHorizontalScrollbarVisible,
1427
- isVerticalScrollbarVisible,
1428
- rtl,
1429
- scrollTo,
1430
- style,
1431
- verticalScrollbarProps
1432
- }) => (
1433
- <div
1434
- className={className}
1435
- ref={containerRef}
1436
- style={style}
1437
- >
1438
- <div className={componentCss.container}>
1439
- <ChildWrapper {...childWrapperProps}>
1440
- {childRenderer({
1441
- ...childComponentProps,
1442
- cbScrollTo: scrollTo,
1443
- className: componentCss.scrollableFill,
1444
- initChildRef,
1445
- onScroll: handleScroll,
1446
- rtl
1447
- })}
1448
- </ChildWrapper>
1449
- {isVerticalScrollbarVisible ? <Scrollbar {...verticalScrollbarProps} disabled={!isVerticalScrollbarVisible} /> : null}
1450
- </div>
1451
- {isHorizontalScrollbarVisible ? <Scrollbar {...horizontalScrollbarProps} corner={isVerticalScrollbarVisible} disabled={!isHorizontalScrollbarVisible} /> : null}
1452
- </div>
1453
- )}
1454
- />
1455
- );
1456
- }
1457
- }
1458
-
1459
- export default Scrollable;
1460
- export {
1461
- constants,
1462
- Scrollable,
1463
- ScrollableBase
1186
+
1187
+
1188
+ exports.ScrollableBase = ScrollableBase;
1189
+ ScrollableBase.displayName = 'ui:ScrollableBase';
1190
+ ScrollableBase.propTypes =
1191
+ /** @lends ui/Scrollable.Scrollable.prototype */
1192
+ {
1193
+ /**
1194
+ * Render function.
1195
+ *
1196
+ * @type {Function}
1197
+ * @required
1198
+ * @private
1199
+ */
1200
+ containerRenderer: _propTypes["default"].func.isRequired,
1201
+
1202
+ /**
1203
+ * Called when adding additional event listeners in a themed component.
1204
+ *
1205
+ * @type {Function}
1206
+ * @private
1207
+ */
1208
+ addEventListeners: _propTypes["default"].func,
1209
+
1210
+ /**
1211
+ * Called to execute additional logic in a themed component to show overscroll effect.
1212
+ *
1213
+ * @type {Function}
1214
+ * @private
1215
+ */
1216
+ applyOverscrollEffect: _propTypes["default"].func,
1217
+
1218
+ /**
1219
+ * A callback function that receives a reference to the `scrollTo` feature.
1220
+ *
1221
+ * Once received, the `scrollTo` method can be called as an imperative interface.
1222
+ *
1223
+ * The `scrollTo` function accepts the following parameters:
1224
+ * - {position: {x, y}} - Pixel value for x and/or y position
1225
+ * - {align} - Where the scroll area should be aligned. Values are:
1226
+ * `'left'`, `'right'`, `'top'`, `'bottom'`,
1227
+ * `'topleft'`, `'topright'`, `'bottomleft'`, and `'bottomright'`.
1228
+ * - {index} - Index of specific item. (`0` or positive integer)
1229
+ * This option is available for only `VirtualList` kind.
1230
+ * - {node} - Node to scroll into view
1231
+ * - {animate} - When `true`, scroll occurs with animation. When `false`, no
1232
+ * animation occurs.
1233
+ * - {focus} - When `true`, attempts to focus item after scroll. Only valid when scrolling
1234
+ * by `index` or `node`.
1235
+ * > Note: Only specify one of: `position`, `align`, `index` or `node`
1236
+ *
1237
+ * Example:
1238
+ * ```
1239
+ * // If you set cbScrollTo prop like below;
1240
+ * cbScrollTo: (fn) => {this.scrollTo = fn;}
1241
+ * // You can simply call like below;
1242
+ * this.scrollTo({align: 'top'}); // scroll to the top
1243
+ * ```
1244
+ *
1245
+ * @type {Function}
1246
+ * @public
1247
+ */
1248
+ cbScrollTo: _propTypes["default"].func,
1249
+
1250
+ /**
1251
+ * Called to execute additional logic in a themed component to clear overscroll effect.
1252
+ *
1253
+ * @type {Function}
1254
+ * @private
1255
+ */
1256
+ clearOverscrollEffect: _propTypes["default"].func,
1257
+
1258
+ /**
1259
+ * Client size of the container; valid values are an object that has `clientWidth` and `clientHeight`.
1260
+ *
1261
+ * @type {Object}
1262
+ * @property {Number} clientHeight The client height of the list.
1263
+ * @property {Number} clientWidth The client width of the list.
1264
+ * @public
1265
+ */
1266
+ clientSize: _propTypes["default"].shape({
1267
+ clientHeight: _propTypes["default"].number.isRequired,
1268
+ clientWidth: _propTypes["default"].number.isRequired
1269
+ }),
1270
+
1271
+ /**
1272
+ * Direction of the list or the scroller.
1273
+ *
1274
+ * `'both'` could be only used for[Scroller]{@link ui/Scroller.Scroller}.
1275
+ *
1276
+ * Valid values are:
1277
+ * * `'both'`,
1278
+ * * `'horizontal'`, and
1279
+ * * `'vertical'`.
1280
+ *
1281
+ * @type {String}
1282
+ * @private
1283
+ */
1284
+ direction: _propTypes["default"].oneOf(['both', 'horizontal', 'vertical']),
1285
+
1286
+ /**
1287
+ * Called when resizing window
1288
+ *
1289
+ * @type {Function}
1290
+ * @private
1291
+ */
1292
+ handleResizeWindow: _propTypes["default"].func,
1293
+
1294
+ /**
1295
+ * Specifies how to show horizontal scrollbar.
1296
+ *
1297
+ * Valid values are:
1298
+ * * `'auto'`,
1299
+ * * `'visible'`, and
1300
+ * * `'hidden'`.
1301
+ *
1302
+ * @type {String}
1303
+ * @default 'auto'
1304
+ * @public
1305
+ */
1306
+ horizontalScrollbar: _propTypes["default"].oneOf(['auto', 'visible', 'hidden']),
1307
+
1308
+ /**
1309
+ * Prevents scroll by dragging or flicking on the list or the scroller.
1310
+ *
1311
+ * @type {Boolean}
1312
+ * @default false
1313
+ * @private
1314
+ */
1315
+ noScrollByDrag: _propTypes["default"].bool,
1316
+
1317
+ /**
1318
+ * Prevents scroll by wheeling on the list or the scroller.
1319
+ *
1320
+ * @type {Boolean}
1321
+ * @default false
1322
+ * @public
1323
+ */
1324
+ noScrollByWheel: _propTypes["default"].bool,
1325
+
1326
+ /**
1327
+ * Called when triggering a drag event.
1328
+ *
1329
+ * @type {Function}
1330
+ * @private
1331
+ */
1332
+ onDrag: _propTypes["default"].func,
1333
+
1334
+ /**
1335
+ * Called when triggering a dragend event.
1336
+ *
1337
+ * @type {Function}
1338
+ * @private
1339
+ */
1340
+ onDragEnd: _propTypes["default"].func,
1341
+
1342
+ /**
1343
+ * Called when triggering a dragstart event.
1344
+ *
1345
+ * @type {Function}
1346
+ * @private
1347
+ */
1348
+ onDragStart: _propTypes["default"].func,
1349
+
1350
+ /**
1351
+ * Called when flicking with a mouse or a touch screen.
1352
+ *
1353
+ * @type {Function}
1354
+ * @private
1355
+ */
1356
+ onFlick: _propTypes["default"].func,
1357
+
1358
+ /**
1359
+ * Called when pressing a key.
1360
+ *
1361
+ * @type {Function}
1362
+ * @private
1363
+ */
1364
+ onKeyDown: _propTypes["default"].func,
1365
+
1366
+ /**
1367
+ * Called when triggering a mousedown event.
1368
+ *
1369
+ * @type {Function}
1370
+ * @private
1371
+ */
1372
+ onMouseDown: _propTypes["default"].func,
1373
+
1374
+ /**
1375
+ * Called when scrolling.
1376
+ *
1377
+ * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
1378
+ * It is not recommended to set this prop since it can cause performance degradation.
1379
+ * Use `onScrollStart` or `onScrollStop` instead.
1380
+ *
1381
+ * @type {Function}
1382
+ * @param {Object} event
1383
+ * @param {Number} event.scrollLeft Scroll left value.
1384
+ * @param {Number} event.scrollTop Scroll top value.
1385
+ * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
1386
+ * @public
1387
+ */
1388
+ onScroll: _propTypes["default"].func,
1389
+
1390
+ /**
1391
+ * Called when scroll starts.
1392
+ *
1393
+ * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
1394
+ * You can get firstVisibleIndex and lastVisibleIndex from VirtualList with `moreInfo`.
1395
+ *
1396
+ * Example:
1397
+ * ```
1398
+ * onScrollStart = ({scrollLeft, scrollTop, moreInfo}) => {
1399
+ * const {firstVisibleIndex, lastVisibleIndex} = moreInfo;
1400
+ * // do something with firstVisibleIndex and lastVisibleIndex
1401
+ * }
1402
+ *
1403
+ * render = () => (
1404
+ * <VirtualList
1405
+ * ...
1406
+ * onScrollStart={this.onScrollStart}
1407
+ * ...
1408
+ * />
1409
+ * )
1410
+ * ```
1411
+ *
1412
+ * @type {Function}
1413
+ * @param {Object} event
1414
+ * @param {Number} event.scrollLeft Scroll left value.
1415
+ * @param {Number} event.scrollTop Scroll top value.
1416
+ * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
1417
+ * @public
1418
+ */
1419
+ onScrollStart: _propTypes["default"].func,
1420
+
1421
+ /**
1422
+ * Called when scroll stops.
1423
+ *
1424
+ * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
1425
+ * You can get firstVisibleIndex and lastVisibleIndex from VirtualList with `moreInfo`.
1426
+ *
1427
+ * Example:
1428
+ * ```
1429
+ * onScrollStop = ({scrollLeft, scrollTop, moreInfo}) => {
1430
+ * const {firstVisibleIndex, lastVisibleIndex} = moreInfo;
1431
+ * // do something with firstVisibleIndex and lastVisibleIndex
1432
+ * }
1433
+ *
1434
+ * render = () => (
1435
+ * <VirtualList
1436
+ * ...
1437
+ * onScrollStop={this.onScrollStop}
1438
+ * ...
1439
+ * />
1440
+ * )
1441
+ * ```
1442
+ *
1443
+ * @type {Function}
1444
+ * @param {Object} event
1445
+ * @param {Number} event.scrollLeft Scroll left value.
1446
+ * @param {Number} event.scrollTop Scroll top value.
1447
+ * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
1448
+ * @public
1449
+ */
1450
+ onScrollStop: _propTypes["default"].func,
1451
+
1452
+ /**
1453
+ * Called when wheeling.
1454
+ *
1455
+ * @type {Function}
1456
+ * @private
1457
+ */
1458
+ onWheel: _propTypes["default"].func,
1459
+
1460
+ /**
1461
+ * Specifies overscroll effects shows on which type of inputs.
1462
+ *
1463
+ * @type {Object}
1464
+ * @default {drag: false, pageKey: false, wheel: false}
1465
+ * @private
1466
+ */
1467
+ overscrollEffectOn: _propTypes["default"].shape({
1468
+ drag: _propTypes["default"].bool,
1469
+ pageKey: _propTypes["default"].bool,
1470
+ wheel: _propTypes["default"].bool
1471
+ }),
1472
+
1473
+ /**
1474
+ * Called when removing additional event listeners in a themed component.
1475
+ *
1476
+ * @type {Function}
1477
+ * @private
1478
+ */
1479
+ removeEventListeners: _propTypes["default"].func,
1480
+
1481
+ /**
1482
+ * Indicates the content's text direction is right-to-left.
1483
+ *
1484
+ * @type {Boolean}
1485
+ * @private
1486
+ */
1487
+ rtl: _propTypes["default"].bool,
1488
+
1489
+ /**
1490
+ * Called to execute additional logic in a themed component when scrollTo is called.
1491
+ *
1492
+ * @type {Function}
1493
+ * @private
1494
+ */
1495
+ scrollTo: _propTypes["default"].func,
1496
+
1497
+ /**
1498
+ * Called to execute additional logic in a themed component when scroll stops.
1499
+ *
1500
+ * @type {Function}
1501
+ * @private
1502
+ */
1503
+ stop: _propTypes["default"].func,
1504
+
1505
+ /**
1506
+ * Specifies how to show vertical scrollbar.
1507
+ *
1508
+ * Valid values are:
1509
+ * * `'auto'`,
1510
+ * * `'visible'`, and
1511
+ * * `'hidden'`.
1512
+ *
1513
+ * @type {String}
1514
+ * @default 'auto'
1515
+ * @public
1516
+ */
1517
+ verticalScrollbar: _propTypes["default"].oneOf(['auto', 'visible', 'hidden'])
1518
+ };
1519
+ ScrollableBase.defaultProps = {
1520
+ cbScrollTo: nop,
1521
+ horizontalScrollbar: 'auto',
1522
+ noScrollByDrag: false,
1523
+ noScrollByWheel: false,
1524
+ onScroll: nop,
1525
+ onScrollStart: nop,
1526
+ onScrollStop: nop,
1527
+ overscrollEffectOn: {
1528
+ drag: false,
1529
+ pageKey: false,
1530
+ wheel: false
1531
+ },
1532
+ verticalScrollbar: 'auto'
1533
+ };
1534
+ ScrollableBase.contextType = _Resizable.ResizeContext;
1535
+
1536
+ var Scrollable = /*#__PURE__*/function (_Component2) {
1537
+ _inherits(Scrollable, _Component2);
1538
+
1539
+ var _super2 = _createSuper(Scrollable);
1540
+
1541
+ function Scrollable() {
1542
+ _classCallCheck(this, Scrollable);
1543
+
1544
+ return _super2.apply(this, arguments);
1545
+ }
1546
+
1547
+ _createClass(Scrollable, [{
1548
+ key: "render",
1549
+ value: function render() {
1550
+ var _this$props4 = this.props,
1551
+ childRenderer = _this$props4.childRenderer,
1552
+ rest = _objectWithoutProperties(_this$props4, ["childRenderer"]);
1553
+
1554
+ return /*#__PURE__*/_react["default"].createElement(ScrollableBase, Object.assign({}, rest, {
1555
+ containerRenderer: function containerRenderer(_ref2) {
1556
+ var childComponentProps = _ref2.childComponentProps,
1557
+ ChildWrapper = _ref2.childWrapper,
1558
+ childWrapperProps = _ref2.childWrapperProps,
1559
+ containerRef = _ref2.containerRef,
1560
+ className = _ref2.className,
1561
+ componentCss = _ref2.componentCss,
1562
+ handleScroll = _ref2.handleScroll,
1563
+ horizontalScrollbarProps = _ref2.horizontalScrollbarProps,
1564
+ initChildRef = _ref2.initChildRef,
1565
+ isHorizontalScrollbarVisible = _ref2.isHorizontalScrollbarVisible,
1566
+ isVerticalScrollbarVisible = _ref2.isVerticalScrollbarVisible,
1567
+ rtl = _ref2.rtl,
1568
+ scrollTo = _ref2.scrollTo,
1569
+ style = _ref2.style,
1570
+ verticalScrollbarProps = _ref2.verticalScrollbarProps;
1571
+ return /*#__PURE__*/_react["default"].createElement("div", {
1572
+ className: className,
1573
+ ref: containerRef,
1574
+ style: style
1575
+ }, /*#__PURE__*/_react["default"].createElement("div", {
1576
+ className: componentCss.container
1577
+ }, /*#__PURE__*/_react["default"].createElement(ChildWrapper, childWrapperProps, childRenderer(_objectSpread(_objectSpread({}, childComponentProps), {}, {
1578
+ cbScrollTo: scrollTo,
1579
+ className: componentCss.scrollableFill,
1580
+ initChildRef: initChildRef,
1581
+ onScroll: handleScroll,
1582
+ rtl: rtl
1583
+ }))), isVerticalScrollbarVisible ? /*#__PURE__*/_react["default"].createElement(_Scrollbar["default"], Object.assign({}, verticalScrollbarProps, {
1584
+ disabled: !isVerticalScrollbarVisible
1585
+ })) : null), isHorizontalScrollbarVisible ? /*#__PURE__*/_react["default"].createElement(_Scrollbar["default"], Object.assign({}, horizontalScrollbarProps, {
1586
+ corner: isVerticalScrollbarVisible,
1587
+ disabled: !isHorizontalScrollbarVisible
1588
+ })) : null);
1589
+ }
1590
+ }));
1591
+ }
1592
+ }]);
1593
+
1594
+ return Scrollable;
1595
+ }(_react.Component);
1596
+
1597
+ exports.Scrollable = Scrollable;
1598
+ Scrollable.displayName = 'ui:Scrollable';
1599
+ Scrollable.propTypes =
1600
+ /** @lends ui/Scrollable.Scrollable.prototype */
1601
+ {
1602
+ /**
1603
+ * Render function.
1604
+ *
1605
+ * @type {Function}
1606
+ * @required
1607
+ * @private
1608
+ */
1609
+ childRenderer: _propTypes["default"].func.isRequired
1464
1610
  };
1611
+ var _default = Scrollable;
1612
+ exports["default"] = _default;