@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.
- package/{build/A11yDecorator → A11yDecorator}/A11yDecorator.d.ts +0 -0
- package/A11yDecorator/A11yDecorator.js +79 -75
- package/A11yDecorator/tests/A11yDecorator-specs.js +90 -128
- package/AnnounceDecorator/Announce.js +136 -80
- package/{build/AnnounceDecorator → AnnounceDecorator}/AnnounceDecorator.d.ts +0 -0
- package/AnnounceDecorator/AnnounceDecorator.js +68 -53
- package/AnnounceDecorator/tests/Announce-specs.js +29 -35
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +34 -36
- package/AnnounceDecorator/tests/useAnnounce-specs.js +56 -63
- package/AnnounceDecorator/useAnnounce.js +29 -18
- package/{build/BodyText → BodyText}/BodyText.d.ts +0 -0
- package/BodyText/BodyText.js +108 -96
- package/{build/BodyText → BodyText}/BodyText.module.css +0 -0
- package/BodyText/tests/BodyText-specs.js +67 -76
- package/{build/Button → Button}/Button.d.ts +0 -0
- package/Button/Button.js +236 -215
- package/{build/Button → Button}/Button.module.css +0 -0
- package/CHANGELOG.md +18 -0
- package/{build/Cancelable → Cancelable}/Cancelable.d.ts +0 -0
- package/Cancelable/Cancelable.js +213 -184
- package/Cancelable/cancelHandler.js +36 -29
- package/Cancelable/modalHandler.js +35 -23
- package/Cancelable/tests/Cancelable-specs.js +289 -381
- package/{build/Changeable → Changeable}/Changeable.d.ts +0 -0
- package/Changeable/Changeable.js +137 -161
- package/Changeable/tests/Changeable-specs.js +262 -327
- package/{build/ComponentOverride → ComponentOverride}/ComponentOverride.d.ts +0 -0
- package/ComponentOverride/ComponentOverride.js +21 -24
- package/FloatingLayer/FloatingLayer.js +310 -261
- package/FloatingLayer/FloatingLayerDecorator.js +150 -99
- package/FloatingLayer/Scrim.js +167 -99
- package/{build/FloatingLayer → FloatingLayer}/Scrim.module.css +0 -0
- package/FloatingLayer/index.js +39 -12
- package/FloatingLayer/tests/FloatingLayer-specs.js +24 -27
- package/FloatingLayer/tests/Scrim-specs.js +21 -24
- package/FloatingLayer/useFloatingLayer.js +46 -18
- package/{build/ForwardRef → ForwardRef}/ForwardRef.d.ts +0 -0
- package/ForwardRef/ForwardRef.js +35 -34
- package/{build/GridListImageItem → GridListImageItem}/GridListImageItem.d.ts +0 -0
- package/GridListImageItem/GridListImageItem.js +244 -212
- package/{build/GridListImageItem → GridListImageItem}/GridListImageItem.module.css +0 -0
- package/{build/Group → Group}/Group.d.ts +0 -0
- package/Group/Group.js +186 -168
- package/Group/GroupItem.js +83 -79
- package/Group/tests/Group-specs.js +128 -164
- package/{build/Heading → Heading}/Heading.d.ts +0 -0
- package/Heading/Heading.js +146 -128
- package/{build/Heading → Heading}/Heading.module.css +0 -0
- package/Heading/tests/Heading-specs.js +46 -54
- package/{build/Icon → Icon}/Icon.d.ts +0 -0
- package/Icon/Icon.js +200 -189
- package/{build/Icon → Icon}/Icon.module.css +0 -0
- package/Icon/tests/Icon-specs.js +92 -126
- package/{build/IconButton → IconButton}/IconButton.d.ts +0 -0
- package/IconButton/IconButton.js +213 -181
- package/{build/IconButton → IconButton}/IconButton.module.css +0 -0
- package/{build/Image → Image}/Image.d.ts +0 -0
- package/Image/Image.js +186 -151
- package/{build/Image → Image}/Image.module.css +0 -0
- package/Image/tests/Image-specs.js +49 -51
- package/{build/ImageItem → ImageItem}/ImageItem.d.ts +0 -0
- package/ImageItem/ImageItem.js +165 -149
- package/{build/ImageItem → ImageItem}/ImageItem.module.css +0 -0
- package/ImageItem/tests/ImageItem-specs.js +128 -161
- package/{build/Item → Item}/Item.d.ts +0 -0
- package/Item/Item.js +131 -121
- package/{build/Item → Item}/Item.module.css +0 -0
- package/Item/tests/Item-specs.js +71 -88
- package/{build/LabeledIcon → LabeledIcon}/LabeledIcon.d.ts +0 -0
- package/LabeledIcon/LabeledIcon.js +235 -216
- package/{build/LabeledIcon → LabeledIcon}/LabeledIcon.module.css +0 -0
- package/LabeledIcon/tests/LabeledIcon-specs.js +49 -58
- package/Layout/Cell.js +181 -146
- package/{build/Layout → Layout}/Layout.d.ts +0 -0
- package/Layout/Layout.js +193 -282
- package/{build/Layout → Layout}/Layout.module.css +0 -0
- package/Layout/tests/Layout-specs.js +102 -109
- package/{build/Marquee → Marquee}/Marquee.module.css +0 -0
- package/Marquee/MarqueeBase.js +275 -240
- package/Marquee/MarqueeController.js +327 -292
- package/Marquee/MarqueeDecorator.js +990 -898
- package/{build/Marquee → Marquee}/index.d.ts +0 -0
- package/Marquee/index.js +39 -14
- package/Marquee/tests/Marquee-specs.js +274 -382
- package/{build/Measurable → Measurable}/Measurable.d.ts +0 -0
- package/Measurable/Measurable.js +133 -100
- package/{build/Media → Media}/Media.d.ts +0 -0
- package/Media/Media.js +317 -254
- package/Placeholder/PlaceholderControllerDecorator.js +188 -133
- package/Placeholder/PlaceholderDecorator.js +147 -95
- package/{build/Placeholder → Placeholder}/index.d.ts +0 -0
- package/Placeholder/index.js +27 -9
- package/{build/ProgressBar → ProgressBar}/ProgressBar.d.ts +0 -0
- package/ProgressBar/ProgressBar.js +183 -173
- package/{build/ProgressBar → ProgressBar}/ProgressBar.module.css +0 -0
- package/ProgressBar/tests/ProgressBar-specs.js +80 -109
- package/RadioDecorator/RadioControllerDecorator.js +104 -54
- package/{build/RadioDecorator → RadioDecorator}/RadioDecorator.d.ts +0 -0
- package/RadioDecorator/RadioDecorator.js +176 -117
- package/RadioDecorator/tests/RadioDecorator-specs.js +155 -166
- package/{build/Repeater → Repeater}/Repeater.d.ts +0 -0
- package/Repeater/Repeater.js +157 -133
- package/Repeater/tests/Repeater-specs.js +136 -155
- package/{build/Resizable → Resizable}/Resizable.d.ts +0 -0
- package/Resizable/Resizable.js +145 -101
- package/Routable/Link.js +65 -61
- package/{build/Routable → Routable}/Routable.d.ts +0 -0
- package/Routable/Routable.js +148 -109
- package/Routable/Route.js +37 -27
- package/Routable/Router.js +236 -171
- package/Routable/tests/Router-specs.js +194 -196
- package/Routable/util.js +78 -68
- package/Scrollable/ScrollAnimator.js +138 -112
- package/Scrollable/ScrollThumb.js +52 -42
- package/{build/Scrollable → Scrollable}/ScrollThumb.module.css +0 -0
- package/{build/Scrollable → Scrollable}/Scrollable.d.ts +0 -0
- package/Scrollable/Scrollable.js +1591 -1443
- package/{build/Scrollable → Scrollable}/Scrollable.module.css +0 -0
- package/Scrollable/ScrollableNative.js +1599 -1445
- package/Scrollable/Scrollbar.js +312 -221
- package/{build/Scrollable → Scrollable}/Scrollbar.module.css +0 -0
- package/{build/Scroller → Scroller}/Scroller.d.ts +0 -0
- package/Scroller/Scroller.js +249 -242
- package/{build/Scroller → Scroller}/Scroller.module.css +0 -0
- package/Scroller/ScrollerBasic.js +311 -230
- package/{build/Scroller → Scroller}/UiScroller.module.css +0 -0
- package/Scroller/UiScrollerBase.js +253 -184
- package/{build/Skinnable → Skinnable}/Skinnable.d.ts +0 -0
- package/Skinnable/Skinnable.js +182 -172
- package/Skinnable/tests/Skinnable-specs.js +388 -416
- package/Skinnable/tests/useSkins-specs.js +290 -281
- package/Skinnable/tests/util-specs.js +107 -113
- package/Skinnable/useSkins.js +51 -28
- package/Skinnable/util.js +80 -75
- package/Slider/Knob.js +85 -71
- package/Slider/PositionDecorator.js +232 -162
- package/{build/Slider → Slider}/Slider.d.ts +0 -0
- package/Slider/Slider.js +331 -312
- package/{build/Slider → Slider}/Slider.module.css +0 -0
- package/Slider/utils.js +16 -11
- package/{build/SlotItem → SlotItem}/SlotItem.d.ts +0 -0
- package/SlotItem/SlotItem.js +199 -179
- package/{build/SlotItem → SlotItem}/SlotItem.module.css +0 -0
- package/{build/Slottable → Slottable}/Slottable.d.ts +0 -0
- package/Slottable/Slottable.js +62 -48
- package/Slottable/tests/Slottable-specs.js +232 -284
- package/Slottable/tests/useSlots-specs.js +277 -313
- package/Slottable/useSlots.js +113 -90
- package/{build/Spinner → Spinner}/Spinner.d.ts +0 -0
- package/Spinner/Spinner.js +213 -178
- package/{build/Spinner → Spinner}/Spinner.module.css +0 -0
- package/Spinner/tests/Spinner-specs.js +61 -77
- package/{build/ToggleIcon → ToggleIcon}/ToggleIcon.d.ts +0 -0
- package/ToggleIcon/ToggleIcon.js +134 -123
- package/{build/ToggleIcon → ToggleIcon}/ToggleIcon.module.css +0 -0
- package/ToggleIcon/tests/ToggleIcon-specs.js +52 -71
- package/{build/ToggleItem → ToggleItem}/ToggleItem.d.ts +0 -0
- package/ToggleItem/ToggleItem.js +263 -264
- package/{build/ToggleItem → ToggleItem}/ToggleItem.module.css +0 -0
- package/ToggleItem/tests/ToggleItem-specs.js +87 -87
- package/Toggleable/Toggle.js +70 -43
- package/{build/Toggleable → Toggleable}/Toggleable.d.ts +0 -0
- package/Toggleable/Toggleable.js +219 -244
- package/Toggleable/tests/Toggleable-specs.js +416 -549
- package/Toggleable/useToggle.js +50 -24
- package/Touchable/ClickAllow.js +67 -49
- package/Touchable/Drag.js +199 -170
- package/Touchable/Flick.js +152 -122
- package/Touchable/Hold.js +259 -214
- package/{build/Touchable → Touchable}/Touchable.d.ts +0 -0
- package/Touchable/Touchable.js +643 -651
- package/Touchable/config.js +63 -44
- package/Touchable/state.js +31 -14
- package/Touchable/tests/Touchable-specs.js +462 -526
- package/{build/Transition → Transition}/Transition.d.ts +0 -0
- package/Transition/Transition.js +606 -553
- package/{build/Transition → Transition}/Transition.module.css +0 -0
- package/Transition/tests/Transition-specs.js +123 -138
- package/ViewManager/Arranger.js +82 -40
- package/ViewManager/TransitionGroup.js +502 -419
- package/ViewManager/View.js +383 -298
- package/{build/ViewManager → ViewManager}/ViewManager.d.ts +0 -0
- package/ViewManager/ViewManager.js +352 -296
- package/ViewManager/tests/View-specs.js +176 -275
- package/ViewManager/tests/ViewManager-specs.js +524 -471
- package/ViewManager/tests/test-utils.js +44 -23
- package/{build/VirtualList → VirtualList}/UiVirtualList.module.css +0 -0
- package/VirtualList/UiVirtualListBase.js +1381 -1171
- package/{build/VirtualList → VirtualList}/VirtualList.d.ts +0 -0
- package/VirtualList/VirtualList.js +541 -537
- package/{build/VirtualList → VirtualList}/VirtualList.module.css +0 -0
- package/VirtualList/VirtualListBase.js +37 -10
- package/VirtualList/VirtualListBasic.js +1468 -1241
- package/VirtualList/tests/VirtualList-specs.js +314 -345
- package/{build/index.d.ts → index.d.ts} +0 -0
- package/index.js +1 -0
- package/{build/internal → internal}/IdProvider/IdProvider.d.ts +0 -0
- package/internal/IdProvider/IdProvider.js +76 -54
- package/internal/IdProvider/Provider.js +67 -41
- package/internal/IdProvider/tests/useId-specs.js +64 -78
- package/internal/IdProvider/useId.js +27 -15
- package/{build/internal → internal}/Pure/Pure.d.ts +0 -0
- package/internal/Pure/Pure.js +98 -65
- package/{build/internal → internal}/localized-fonts/localized-fonts.d.ts +0 -0
- package/internal/localized-fonts/localized-fonts.js +179 -159
- package/{build/internal → internal}/selection/selection.d.ts +0 -0
- package/internal/selection/selection.js +49 -40
- package/internal/selection/tests/selection-specs.js +158 -253
- package/{build/internal → internal}/validators/validators.d.ts +0 -0
- package/internal/validators/validators.js +103 -55
- package/package.json +2 -2
- package/resolution/ResolutionDecorator.js +150 -97
- package/{build/resolution → resolution}/index.d.ts +0 -0
- package/resolution/index.js +39 -7
- package/resolution/resolution.js +232 -183
- package/resolution/tests/ResolutionDecorator-specs.js +42 -48
- package/resolution/tests/resolution-specs.js +90 -91
- package/useControlledState/tests/useControlledState-specs.js +100 -76
- package/{build/useControlledState → useControlledState}/useControlledState.d.ts +0 -0
- package/useControlledState/useControlledState.js +56 -38
- package/useScroll/ScrollAnimator.js +138 -112
- package/useScroll/Scrollbar.js +199 -175
- package/{build/useScroll → useScroll}/Scrollbar.module.css +0 -0
- package/useScroll/ScrollbarTrack.js +46 -28
- package/{build/useScroll → useScroll}/ScrollbarTrack.module.css +0 -0
- package/{build/useScroll → useScroll}/useScroll.d.ts +0 -0
- package/useScroll/useScroll.js +1714 -1627
- package/{build/useScroll → useScroll}/useScroll.module.css +0 -0
- package/useScroll/utilDOM.js +62 -55
- package/useScroll/utilEvent.js +33 -28
- package/BodyText/BodyText.module.less +0 -11
- package/Button/Button.module.less +0 -57
- package/FloatingLayer/Scrim.module.less +0 -8
- package/GridListImageItem/GridListImageItem.module.less +0 -33
- package/Heading/Heading.module.less +0 -20
- package/Icon/Icon.module.less +0 -38
- package/IconButton/IconButton.module.less +0 -18
- package/Image/Image.module.less +0 -21
- package/ImageItem/ImageItem.module.less +0 -29
- package/Item/Item.module.less +0 -14
- package/LabeledIcon/LabeledIcon.module.less +0 -45
- package/Layout/Layout.module.less +0 -84
- package/Marquee/Marquee.module.less +0 -49
- package/ProgressBar/ProgressBar.module.less +0 -114
- package/Scrollable/ScrollThumb.module.less +0 -46
- package/Scrollable/Scrollable.module.less +0 -42
- package/Scrollable/Scrollbar.module.less +0 -35
- package/Scroller/Scroller.module.less +0 -10
- package/Scroller/UiScroller.module.less +0 -10
- package/Slider/Slider.module.less +0 -20
- package/SlotItem/SlotItem.module.less +0 -19
- package/Spinner/Spinner.module.less +0 -52
- package/ToggleIcon/ToggleIcon.module.less +0 -14
- package/ToggleItem/ToggleItem.module.less +0 -9
- package/Transition/Transition.module.less +0 -179
- package/VirtualList/UiVirtualList.module.less +0 -31
- package/VirtualList/VirtualList.module.less +0 -39
- package/build/A11yDecorator/A11yDecorator.js +0 -129
- package/build/A11yDecorator/package.json +0 -3
- package/build/A11yDecorator/tests/A11yDecorator-specs.js +0 -90
- package/build/AnnounceDecorator/Announce.js +0 -172
- package/build/AnnounceDecorator/AnnounceDecorator.js +0 -121
- package/build/AnnounceDecorator/package.json +0 -3
- package/build/AnnounceDecorator/tests/Announce-specs.js +0 -29
- package/build/AnnounceDecorator/tests/AnnounceDecorator-specs.js +0 -34
- package/build/AnnounceDecorator/tests/useAnnounce-specs.js +0 -56
- package/build/AnnounceDecorator/useAnnounce.js +0 -61
- package/build/BodyText/BodyText.js +0 -139
- package/build/BodyText/package.json +0 -3
- package/build/BodyText/tests/BodyText-specs.js +0 -67
- package/build/Button/Button.js +0 -283
- package/build/Button/package.json +0 -3
- package/build/CHANGELOG.md +0 -1089
- package/build/Cancelable/Cancelable.js +0 -271
- package/build/Cancelable/cancelHandler.js +0 -79
- package/build/Cancelable/modalHandler.js +0 -68
- package/build/Cancelable/package.json +0 -3
- package/build/Cancelable/tests/Cancelable-specs.js +0 -289
- package/build/Changeable/Changeable.js +0 -172
- package/build/Changeable/package.json +0 -3
- package/build/Changeable/tests/Changeable-specs.js +0 -262
- package/build/ComponentOverride/ComponentOverride.js +0 -68
- package/build/ComponentOverride/package.json +0 -3
- package/build/FloatingLayer/FloatingLayer.js +0 -339
- package/build/FloatingLayer/FloatingLayerDecorator.js +0 -174
- package/build/FloatingLayer/Scrim.js +0 -199
- package/build/FloatingLayer/index.js +0 -49
- package/build/FloatingLayer/tests/FloatingLayer-specs.js +0 -29
- package/build/FloatingLayer/tests/Scrim-specs.js +0 -26
- package/build/FloatingLayer/useFloatingLayer.js +0 -53
- package/build/ForwardRef/ForwardRef.js +0 -68
- package/build/ForwardRef/package.json +0 -3
- package/build/GridListImageItem/GridListImageItem.js +0 -257
- package/build/GridListImageItem/package.json +0 -3
- package/build/Group/Group.js +0 -217
- package/build/Group/GroupItem.js +0 -109
- package/build/Group/package.json +0 -3
- package/build/Group/tests/Group-specs.js +0 -128
- package/build/Heading/Heading.js +0 -158
- package/build/Heading/package.json +0 -3
- package/build/Heading/tests/Heading-specs.js +0 -46
- package/build/Icon/Icon.js +0 -234
- package/build/Icon/package.json +0 -3
- package/build/Icon/tests/Icon-specs.js +0 -92
- package/build/IconButton/IconButton.js +0 -252
- package/build/IconButton/package.json +0 -3
- package/build/Image/Image.js +0 -219
- package/build/Image/package.json +0 -3
- package/build/Image/tests/Image-specs.js +0 -55
- package/build/ImageItem/ImageItem.js +0 -180
- package/build/ImageItem/package.json +0 -3
- package/build/ImageItem/tests/ImageItem-specs.js +0 -133
- package/build/Item/Item.js +0 -166
- package/build/Item/package.json +0 -3
- package/build/Item/tests/Item-specs.js +0 -77
- package/build/LabeledIcon/LabeledIcon.js +0 -287
- package/build/LabeledIcon/package.json +0 -3
- package/build/LabeledIcon/tests/LabeledIcon-specs.js +0 -49
- package/build/Layout/Cell.js +0 -215
- package/build/Layout/Layout.js +0 -316
- package/build/Layout/package.json +0 -3
- package/build/Layout/tests/Layout-specs.js +0 -102
- package/build/Marquee/MarqueeBase.js +0 -307
- package/build/Marquee/MarqueeController.js +0 -346
- package/build/Marquee/MarqueeDecorator.js +0 -1029
- package/build/Marquee/index.js +0 -65
- package/build/Marquee/package.json +0 -3
- package/build/Marquee/tests/Marquee-specs.js +0 -275
- package/build/Measurable/Measurable.js +0 -163
- package/build/Measurable/package.json +0 -3
- package/build/Media/Media.js +0 -389
- package/build/Media/package.json +0 -3
- package/build/Placeholder/PlaceholderControllerDecorator.js +0 -210
- package/build/Placeholder/PlaceholderDecorator.js +0 -171
- package/build/Placeholder/index.js +0 -37
- package/build/Placeholder/package.json +0 -3
- package/build/ProgressBar/ProgressBar.js +0 -200
- package/build/ProgressBar/package.json +0 -3
- package/build/ProgressBar/tests/ProgressBar-specs.js +0 -80
- package/build/README.md +0 -45
- package/build/RadioDecorator/RadioControllerDecorator.js +0 -117
- package/build/RadioDecorator/RadioDecorator.js +0 -199
- package/build/RadioDecorator/package.json +0 -3
- package/build/RadioDecorator/tests/RadioDecorator-specs.js +0 -155
- package/build/Repeater/Repeater.js +0 -190
- package/build/Repeater/package.json +0 -3
- package/build/Repeater/tests/Repeater-specs.js +0 -141
- package/build/Resizable/Resizable.js +0 -179
- package/build/Resizable/package.json +0 -3
- package/build/Routable/Link.js +0 -78
- package/build/Routable/Routable.js +0 -170
- package/build/Routable/Route.js +0 -68
- package/build/Routable/Router.js +0 -248
- package/build/Routable/package.json +0 -3
- package/build/Routable/tests/Router-specs.js +0 -200
- package/build/Routable/util.js +0 -90
- package/build/Scrollable/ScrollAnimator.js +0 -146
- package/build/Scrollable/ScrollThumb.js +0 -63
- package/build/Scrollable/Scrollable.js +0 -1612
- package/build/Scrollable/ScrollableNative.js +0 -1619
- package/build/Scrollable/Scrollbar.js +0 -344
- package/build/Scrollable/package.json +0 -3
- package/build/Scroller/Scroller.js +0 -291
- package/build/Scroller/ScrollerBasic.js +0 -322
- package/build/Scroller/UiScrollerBase.js +0 -414
- package/build/Scroller/package.json +0 -3
- package/build/Skinnable/Skinnable.js +0 -224
- package/build/Skinnable/package.json +0 -3
- package/build/Skinnable/tests/Skinnable-specs.js +0 -388
- package/build/Skinnable/tests/useSkins-specs.js +0 -290
- package/build/Skinnable/tests/util-specs.js +0 -120
- package/build/Skinnable/useSkins.js +0 -134
- package/build/Skinnable/util.js +0 -106
- package/build/Slider/Knob.js +0 -100
- package/build/Slider/PositionDecorator.js +0 -234
- package/build/Slider/Slider.js +0 -380
- package/build/Slider/package.json +0 -3
- package/build/Slider/utils.js +0 -18
- package/build/SlotItem/SlotItem.js +0 -245
- package/build/SlotItem/package.json +0 -3
- package/build/Slottable/Slottable.js +0 -95
- package/build/Slottable/package.json +0 -3
- package/build/Slottable/tests/Slottable-specs.js +0 -238
- package/build/Slottable/tests/useSlots-specs.js +0 -282
- package/build/Slottable/useSlots.js +0 -183
- package/build/Spinner/Spinner.js +0 -247
- package/build/Spinner/package.json +0 -3
- package/build/Spinner/tests/Spinner-specs.js +0 -61
- package/build/ToggleIcon/ToggleIcon.js +0 -181
- package/build/ToggleIcon/package.json +0 -3
- package/build/ToggleIcon/tests/ToggleIcon-specs.js +0 -58
- package/build/ToggleItem/ToggleItem.js +0 -306
- package/build/ToggleItem/package.json +0 -3
- package/build/ToggleItem/tests/ToggleItem-specs.js +0 -100
- package/build/Toggleable/Toggle.js +0 -74
- package/build/Toggleable/Toggleable.js +0 -250
- package/build/Toggleable/package.json +0 -3
- package/build/Toggleable/tests/Toggleable-specs.js +0 -421
- package/build/Toggleable/useToggle.js +0 -91
- package/build/Touchable/ClickAllow.js +0 -78
- package/build/Touchable/Drag.js +0 -206
- package/build/Touchable/Flick.js +0 -156
- package/build/Touchable/Hold.js +0 -262
- package/build/Touchable/Touchable.js +0 -661
- package/build/Touchable/config.js +0 -147
- package/build/Touchable/package.json +0 -3
- package/build/Touchable/state.js +0 -36
- package/build/Touchable/tests/Touchable-specs.js +0 -470
- package/build/Transition/Transition.js +0 -634
- package/build/Transition/package.json +0 -3
- package/build/Transition/tests/Transition-specs.js +0 -123
- package/build/ViewManager/Arranger.js +0 -181
- package/build/ViewManager/TransitionGroup.js +0 -547
- package/build/ViewManager/View.js +0 -403
- package/build/ViewManager/ViewManager.js +0 -386
- package/build/ViewManager/package.json +0 -3
- package/build/ViewManager/tests/View-specs.js +0 -182
- package/build/ViewManager/tests/ViewManager-specs.js +0 -524
- package/build/ViewManager/tests/test-utils.js +0 -47
- package/build/VirtualList/UiVirtualListBase.js +0 -1566
- package/build/VirtualList/VirtualList.js +0 -582
- package/build/VirtualList/VirtualListBase.js +0 -37
- package/build/VirtualList/VirtualListBasic.js +0 -1503
- package/build/VirtualList/package.json +0 -3
- package/build/VirtualList/tests/VirtualList-specs.js +0 -314
- package/build/index.js +0 -2
- package/build/internal/IdProvider/IdProvider.js +0 -99
- package/build/internal/IdProvider/Provider.js +0 -67
- package/build/internal/IdProvider/package.json +0 -3
- package/build/internal/IdProvider/tests/useId-specs.js +0 -64
- package/build/internal/IdProvider/useId.js +0 -58
- package/build/internal/Pure/Pure.js +0 -133
- package/build/internal/Pure/package.json +0 -3
- package/build/internal/localized-fonts/localized-fonts.js +0 -272
- package/build/internal/localized-fonts/package.json +0 -3
- package/build/internal/selection/package.json +0 -3
- package/build/internal/selection/selection.js +0 -78
- package/build/internal/selection/tests/selection-specs.js +0 -158
- package/build/internal/validators/package.json +0 -4
- package/build/internal/validators/validators.js +0 -163
- package/build/package-lock.json +0 -234
- package/build/package.json +0 -39
- package/build/resolution/ResolutionDecorator.js +0 -183
- package/build/resolution/index.js +0 -47
- package/build/resolution/package.json +0 -3
- package/build/resolution/resolution.js +0 -529
- package/build/resolution/tests/ResolutionDecorator-specs.js +0 -42
- package/build/resolution/tests/resolution-specs.js +0 -90
- package/build/styles/core.less +0 -91
- package/build/styles/mixins.less +0 -444
- package/build/styles/variables.less +0 -7
- package/build/useControlledState/package.json +0 -3
- package/build/useControlledState/tests/useControlledState-specs.js +0 -100
- package/build/useControlledState/useControlledState.js +0 -68
- package/build/useScroll/ScrollAnimator.js +0 -146
- package/build/useScroll/Scrollbar.js +0 -238
- package/build/useScroll/ScrollbarTrack.js +0 -62
- package/build/useScroll/package.json +0 -3
- package/build/useScroll/useScroll.js +0 -1730
- package/build/useScroll/utilDOM.js +0 -65
- package/build/useScroll/utilEvent.js +0 -39
- package/useScroll/Scrollbar.module.less +0 -37
- package/useScroll/ScrollbarTrack.module.less +0 -48
- package/useScroll/useScroll.module.less +0 -44
|
@@ -1,1503 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.VirtualListBasic = exports.itemSizesShape = exports.gridListItemSizeShape = exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
|
|
11
|
-
|
|
12
|
-
var _handle = require("@enact/core/handle");
|
|
13
|
-
|
|
14
|
-
var _platform = require("@enact/core/platform");
|
|
15
|
-
|
|
16
|
-
var _util = require("@enact/core/util");
|
|
17
|
-
|
|
18
|
-
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
19
|
-
|
|
20
|
-
var _equals = _interopRequireDefault(require("ramda/src/equals"));
|
|
21
|
-
|
|
22
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
23
|
-
|
|
24
|
-
var _VirtualListModule = _interopRequireDefault(require("./VirtualList.module.css"));
|
|
25
|
-
|
|
26
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
27
|
-
|
|
28
|
-
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; }
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
31
|
-
|
|
32
|
-
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; }
|
|
33
|
-
|
|
34
|
-
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; }
|
|
35
|
-
|
|
36
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
37
|
-
|
|
38
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
39
|
-
|
|
40
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
41
|
-
|
|
42
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
43
|
-
|
|
44
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
45
|
-
|
|
46
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
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 nop = function nop() {};
|
|
75
|
-
/**
|
|
76
|
-
* The shape for the grid list item size
|
|
77
|
-
* in a list for [VirtualGridList]{@link ui/VirtualList.VirtualGridList}.
|
|
78
|
-
*
|
|
79
|
-
* @typedef {Object} gridListItemSizeShape
|
|
80
|
-
* @memberof ui/VirtualList
|
|
81
|
-
* @property {Number} minWidth The minimum width of the grid list item.
|
|
82
|
-
* @property {Number} minHeight The minimum height of the grid list item.
|
|
83
|
-
* @public
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
var gridListItemSizeShape = _propTypes2["default"].shape({
|
|
88
|
-
minHeight: _propTypes2["default"].number.isRequired,
|
|
89
|
-
minWidth: _propTypes2["default"].number.isRequired
|
|
90
|
-
});
|
|
91
|
-
/**
|
|
92
|
-
* The shape for the list different item size
|
|
93
|
-
* in a list for [VirtualList]{@link ui/VirtualList.VirtualList}.
|
|
94
|
-
*
|
|
95
|
-
* @typedef {Object} itemSizesShape
|
|
96
|
-
* @memberof ui/VirtualList
|
|
97
|
-
* @property {Number} minSize The minimum size of the list item.
|
|
98
|
-
* @property {Number[]} size An array of the list item size. If it is not defined, the list items will render with the `minSize` size.
|
|
99
|
-
* @public
|
|
100
|
-
*/
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
exports.gridListItemSizeShape = gridListItemSizeShape;
|
|
104
|
-
|
|
105
|
-
var itemSizesShape = _propTypes2["default"].shape({
|
|
106
|
-
minSize: _propTypes2["default"].number.isRequired,
|
|
107
|
-
size: _propTypes2["default"].arrayOf(_propTypes2["default"].number)
|
|
108
|
-
});
|
|
109
|
-
/**
|
|
110
|
-
* A basic base component for
|
|
111
|
-
* [VirtualList]{@link ui/VirtualList.VirtualList} and [VirtualGridList]{@link ui/VirtualList.VirtualGridList}.
|
|
112
|
-
*
|
|
113
|
-
* @class VirtualListBasic
|
|
114
|
-
* @memberof ui/VirtualList
|
|
115
|
-
* @ui
|
|
116
|
-
* @public
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
exports.itemSizesShape = itemSizesShape;
|
|
121
|
-
|
|
122
|
-
var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
123
|
-
_inherits(VirtualListBasic, _Component);
|
|
124
|
-
|
|
125
|
-
var _super = _createSuper(VirtualListBasic);
|
|
126
|
-
|
|
127
|
-
function VirtualListBasic(_props) {
|
|
128
|
-
var _this;
|
|
129
|
-
|
|
130
|
-
_classCallCheck(this, VirtualListBasic);
|
|
131
|
-
|
|
132
|
-
var nextState = null;
|
|
133
|
-
_this = _super.call(this, _props);
|
|
134
|
-
_this.displayName = 'ui:VirtualListBasic';
|
|
135
|
-
_this.scrollBounds = {
|
|
136
|
-
clientWidth: 0,
|
|
137
|
-
clientHeight: 0,
|
|
138
|
-
scrollWidth: 0,
|
|
139
|
-
scrollHeight: 0,
|
|
140
|
-
maxLeft: 0,
|
|
141
|
-
maxTop: 0
|
|
142
|
-
};
|
|
143
|
-
_this.moreInfo = {
|
|
144
|
-
firstVisibleIndex: null,
|
|
145
|
-
lastVisibleIndex: null
|
|
146
|
-
};
|
|
147
|
-
_this.primary = null;
|
|
148
|
-
_this.secondary = null;
|
|
149
|
-
_this.isPrimaryDirectionVertical = true;
|
|
150
|
-
_this.isItemSized = false;
|
|
151
|
-
_this.shouldUpdateBounds = false;
|
|
152
|
-
_this.dimensionToExtent = 0;
|
|
153
|
-
_this.threshold = 0;
|
|
154
|
-
_this.maxFirstIndex = 0;
|
|
155
|
-
_this.curDataSize = 0;
|
|
156
|
-
_this.hasDataSizeChanged = false;
|
|
157
|
-
_this.cc = [];
|
|
158
|
-
_this.scrollPosition = 0;
|
|
159
|
-
_this.scrollPositionTarget = 0;
|
|
160
|
-
_this.scrollToPositionTarget = -1;
|
|
161
|
-
_this.itemPositions = [];
|
|
162
|
-
_this.indexToScrollIntoView = -1;
|
|
163
|
-
|
|
164
|
-
_this.updateScrollPosition = function (_ref) {
|
|
165
|
-
var x = _ref.x,
|
|
166
|
-
y = _ref.y;
|
|
167
|
-
var rtl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.props.rtl;
|
|
168
|
-
|
|
169
|
-
if (_this.props.scrollMode === 'native') {
|
|
170
|
-
_this.scrollToPosition(x, y, rtl);
|
|
171
|
-
} else {
|
|
172
|
-
_this.setScrollPositionTarget(x, y);
|
|
173
|
-
|
|
174
|
-
_this.setScrollPosition(x, y, rtl);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
_this.isVertical = function () {
|
|
179
|
-
return _this.isPrimaryDirectionVertical;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
_this.isHorizontal = function () {
|
|
183
|
-
return !_this.isPrimaryDirectionVertical;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
_this.getScrollBounds = function () {
|
|
187
|
-
return _this.scrollBounds;
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
_this.getMoreInfo = function () {
|
|
191
|
-
return _this.moreInfo;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
_this.getItemBottomPosition = function (index) {
|
|
195
|
-
var itemPosition = _this.itemPositions[index],
|
|
196
|
-
itemSize = _this.props.itemSizes[index];
|
|
197
|
-
|
|
198
|
-
if (itemPosition && (itemSize || itemSize === 0)) {
|
|
199
|
-
return itemPosition.position + itemSize;
|
|
200
|
-
} else {
|
|
201
|
-
return index * _this.primary.gridSize - _this.props.spacing;
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
_this.getItemTopPositionFromPreviousItemBottomPosition = function (index, spacing) {
|
|
206
|
-
return index === 0 ? 0 : _this.getItemBottomPosition(index - 1) + spacing;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
_this.getItemPosition = function (index) {
|
|
210
|
-
var stickTo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'start';
|
|
211
|
-
var optionalOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
212
|
-
|
|
213
|
-
var _assertThisInitialize = _assertThisInitialized(_this),
|
|
214
|
-
isPrimaryDirectionVertical = _assertThisInitialize.isPrimaryDirectionVertical,
|
|
215
|
-
primary = _assertThisInitialize.primary,
|
|
216
|
-
scrollBounds = _assertThisInitialize.scrollBounds;
|
|
217
|
-
|
|
218
|
-
var maxPos = isPrimaryDirectionVertical ? scrollBounds.maxTop : scrollBounds.maxLeft;
|
|
219
|
-
|
|
220
|
-
var position = _this.getGridPosition(index);
|
|
221
|
-
|
|
222
|
-
var offset = 0;
|
|
223
|
-
|
|
224
|
-
if (stickTo === 'start') {
|
|
225
|
-
offset = optionalOffset;
|
|
226
|
-
} else if (_this.props.itemSizes) {
|
|
227
|
-
offset = primary.clientSize - _this.props.itemSizes[index] - optionalOffset;
|
|
228
|
-
} else {
|
|
229
|
-
offset = primary.clientSize - primary.itemSize - optionalOffset;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
position.primaryPosition = (0, _util.clamp)(0, maxPos, position.primaryPosition - offset);
|
|
233
|
-
return _this.gridPositionToItemPosition(position);
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
_this.gridPositionToItemPosition = function (_ref2) {
|
|
237
|
-
var primaryPosition = _ref2.primaryPosition,
|
|
238
|
-
secondaryPosition = _ref2.secondaryPosition;
|
|
239
|
-
return _this.isPrimaryDirectionVertical ? {
|
|
240
|
-
left: secondaryPosition,
|
|
241
|
-
top: primaryPosition
|
|
242
|
-
} : {
|
|
243
|
-
left: primaryPosition,
|
|
244
|
-
top: secondaryPosition
|
|
245
|
-
};
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
_this.getXY = function (primaryPosition, secondaryPosition) {
|
|
249
|
-
return _this.isPrimaryDirectionVertical ? {
|
|
250
|
-
x: secondaryPosition,
|
|
251
|
-
y: primaryPosition
|
|
252
|
-
} : {
|
|
253
|
-
x: primaryPosition,
|
|
254
|
-
y: secondaryPosition
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
_this.getClientSize = function (node) {
|
|
259
|
-
return {
|
|
260
|
-
clientWidth: node.clientWidth,
|
|
261
|
-
clientHeight: node.clientHeight
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
_this.getStatesAndUpdateBounds = function (props) {
|
|
266
|
-
var firstIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
267
|
-
|
|
268
|
-
var dataSize = props.dataSize,
|
|
269
|
-
overhang = props.overhang,
|
|
270
|
-
updateStatesAndBounds = props.updateStatesAndBounds,
|
|
271
|
-
_assertThisInitialize2 = _assertThisInitialized(_this),
|
|
272
|
-
dimensionToExtent = _assertThisInitialize2.dimensionToExtent,
|
|
273
|
-
primary = _assertThisInitialize2.primary,
|
|
274
|
-
moreInfo = _assertThisInitialize2.moreInfo,
|
|
275
|
-
scrollPosition = _assertThisInitialize2.scrollPosition,
|
|
276
|
-
numOfItems = Math.min(dataSize, dimensionToExtent * (Math.ceil(primary.clientSize / primary.gridSize) + overhang)),
|
|
277
|
-
wasFirstIndexMax = _this.maxFirstIndex < moreInfo.firstVisibleIndex - dimensionToExtent && firstIndex === _this.maxFirstIndex,
|
|
278
|
-
dataSizeDiff = dataSize - _this.curDataSize;
|
|
279
|
-
|
|
280
|
-
var newFirstIndex = firstIndex; // When calling setState() except in didScroll(), `shouldUpdateBounds` should be `true`
|
|
281
|
-
// so that setState() in didScroll() could be called to override state.
|
|
282
|
-
// Before calling setState() except in didScroll(), getStatesAndUpdateBounds() is always called.
|
|
283
|
-
// So `shouldUpdateBounds` is true here.
|
|
284
|
-
|
|
285
|
-
_this.shouldUpdateBounds = true;
|
|
286
|
-
_this.maxFirstIndex = Math.ceil((dataSize - numOfItems) / dimensionToExtent) * dimensionToExtent;
|
|
287
|
-
_this.curDataSize = dataSize; // reset children
|
|
288
|
-
|
|
289
|
-
_this.cc = [];
|
|
290
|
-
_this.itemPositions = []; // For individually sized item
|
|
291
|
-
|
|
292
|
-
_this.calculateScrollBounds(props);
|
|
293
|
-
|
|
294
|
-
_this.updateMoreInfo(dataSize, scrollPosition);
|
|
295
|
-
|
|
296
|
-
if (!(updateStatesAndBounds && updateStatesAndBounds({
|
|
297
|
-
cbScrollTo: props.cbScrollTo,
|
|
298
|
-
numOfItems: numOfItems,
|
|
299
|
-
dataSize: dataSize,
|
|
300
|
-
moreInfo: moreInfo
|
|
301
|
-
}))) {
|
|
302
|
-
newFirstIndex = _this.calculateFirstIndex(props, wasFirstIndexMax, dataSizeDiff, firstIndex);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return {
|
|
306
|
-
firstIndex: Math.min(newFirstIndex, _this.maxFirstIndex),
|
|
307
|
-
numOfItems: numOfItems
|
|
308
|
-
};
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
_this.setContainerSize = function () {
|
|
312
|
-
if (_this.contentRef.current) {
|
|
313
|
-
_this.contentRef.current.style.width = _this.scrollBounds.scrollWidth + (_this.isPrimaryDirectionVertical ? -1 : 0) + 'px';
|
|
314
|
-
_this.contentRef.current.style.height = _this.scrollBounds.scrollHeight + (_this.isPrimaryDirectionVertical ? 0 : -1) + 'px';
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
_this.applyStyleToNewNode = function (index) {
|
|
319
|
-
var _this2;
|
|
320
|
-
|
|
321
|
-
var _this$props = _this.props,
|
|
322
|
-
childProps = _this$props.childProps,
|
|
323
|
-
itemRefs = _this$props.itemRefs,
|
|
324
|
-
itemRenderer = _this$props.itemRenderer,
|
|
325
|
-
getComponentProps = _this$props.getComponentProps,
|
|
326
|
-
key = index % _this.state.numOfItems,
|
|
327
|
-
componentProps = getComponentProps && getComponentProps(index) || {},
|
|
328
|
-
itemContainerRef = function itemContainerRef(ref) {
|
|
329
|
-
if (ref === null) {
|
|
330
|
-
itemRefs.current[key] = ref;
|
|
331
|
-
} else {
|
|
332
|
-
var itemNode = ref.children[0];
|
|
333
|
-
itemRefs.current[key] = parseInt(itemNode.dataset.index) === index ? itemNode : ref.querySelector("[data-index=\"".concat(index, "\"]"));
|
|
334
|
-
_this.itemContainerRefs[key] = ref;
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
339
|
-
rest[_key - 1] = arguments[_key];
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
_this.cc[key] = /*#__PURE__*/_react["default"].createElement("div", {
|
|
343
|
-
className: _VirtualListModule["default"].listItem,
|
|
344
|
-
key: key,
|
|
345
|
-
ref: itemContainerRef,
|
|
346
|
-
style: (_this2 = _this).composeStyle.apply(_this2, rest)
|
|
347
|
-
}, itemRenderer(_objectSpread(_objectSpread(_objectSpread({}, childProps), componentProps), {}, {
|
|
348
|
-
index: index
|
|
349
|
-
})));
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
_this.applyStyleToHideNode = function (index) {
|
|
353
|
-
var itemRefs = _this.props.itemRefs,
|
|
354
|
-
key = index % _this.state.numOfItems,
|
|
355
|
-
itemContainerRef = function itemContainerRef() {
|
|
356
|
-
return itemRefs.current[key] = null;
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
_this.cc[key] = /*#__PURE__*/_react["default"].createElement("div", {
|
|
360
|
-
key: key,
|
|
361
|
-
ref: itemContainerRef,
|
|
362
|
-
style: {
|
|
363
|
-
display: 'none'
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
_this.getScrollHeight = function () {
|
|
369
|
-
return _this.isPrimaryDirectionVertical ? _this.getVirtualScrollDimension() + _this.props.getAffordance() : _this.scrollBounds.clientHeight;
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
_this.getScrollWidth = function () {
|
|
373
|
-
return _this.isPrimaryDirectionVertical ? _this.scrollBounds.clientWidth : _this.getVirtualScrollDimension();
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
_this.getVirtualScrollDimension = function () {
|
|
377
|
-
if (_this.props.itemSizes) {
|
|
378
|
-
return _this.props.itemSizes.reduce(function (total, size, index) {
|
|
379
|
-
return total + size + (index > 0 ? _this.props.spacing : 0);
|
|
380
|
-
}, 0);
|
|
381
|
-
} else {
|
|
382
|
-
var _assertThisInitialize3 = _assertThisInitialized(_this),
|
|
383
|
-
dimensionToExtent = _assertThisInitialize3.dimensionToExtent,
|
|
384
|
-
primary = _assertThisInitialize3.primary,
|
|
385
|
-
curDataSize = _assertThisInitialize3.curDataSize,
|
|
386
|
-
spacing = _this.props.spacing;
|
|
387
|
-
|
|
388
|
-
return Math.ceil(curDataSize / dimensionToExtent) * primary.gridSize - spacing;
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
_this.syncClientSize = function () {
|
|
393
|
-
var _assertThisInitialize4 = _assertThisInitialized(_this),
|
|
394
|
-
props = _assertThisInitialize4.props,
|
|
395
|
-
node = _this.props.scrollContentRef.current;
|
|
396
|
-
|
|
397
|
-
if (!props.clientSize && !node) {
|
|
398
|
-
return false;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
var _ref3 = props.clientSize || _this.getClientSize(node),
|
|
402
|
-
clientWidth = _ref3.clientWidth,
|
|
403
|
-
clientHeight = _ref3.clientHeight,
|
|
404
|
-
_assertThisInitialize5 = _assertThisInitialized(_this),
|
|
405
|
-
scrollBounds = _assertThisInitialize5.scrollBounds;
|
|
406
|
-
|
|
407
|
-
if (clientWidth !== scrollBounds.clientWidth || clientHeight !== scrollBounds.clientHeight) {
|
|
408
|
-
_this.calculateMetrics(props);
|
|
409
|
-
|
|
410
|
-
_this.setState(_this.getStatesAndUpdateBounds(props));
|
|
411
|
-
|
|
412
|
-
_this.setContainerSize();
|
|
413
|
-
|
|
414
|
-
return true;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
return false;
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
_this.contentRef = /*#__PURE__*/_react["default"].createRef();
|
|
421
|
-
_this.itemContainerRefs = [];
|
|
422
|
-
|
|
423
|
-
if (_props.clientSize) {
|
|
424
|
-
_this.calculateMetrics(_props);
|
|
425
|
-
|
|
426
|
-
nextState = _this.getStatesAndUpdateBounds(_props);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
_this.state = _objectSpread({
|
|
430
|
-
firstIndex: 0,
|
|
431
|
-
numOfItems: 0,
|
|
432
|
-
prevChildProps: null,
|
|
433
|
-
prevFirstIndex: 0,
|
|
434
|
-
updateFrom: 0,
|
|
435
|
-
updateTo: 0
|
|
436
|
-
}, nextState);
|
|
437
|
-
return _this;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
_createClass(VirtualListBasic, [{
|
|
441
|
-
key: "componentDidMount",
|
|
442
|
-
// Calculate metrics for VirtualList after the 1st render to know client W/H.
|
|
443
|
-
value: function componentDidMount() {
|
|
444
|
-
if (!this.props.clientSize) {
|
|
445
|
-
this.calculateMetrics(this.props); // eslint-disable-next-line react/no-did-mount-set-state
|
|
446
|
-
|
|
447
|
-
this.setState(this.getStatesAndUpdateBounds(this.props));
|
|
448
|
-
} else {
|
|
449
|
-
this.emitUpdateItems();
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
if (this.props.itemSizes) {
|
|
453
|
-
this.adjustItemPositionWithItemSize();
|
|
454
|
-
} else {
|
|
455
|
-
this.setContainerSize();
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}, {
|
|
459
|
-
key: "componentDidUpdate",
|
|
460
|
-
value: function componentDidUpdate(prevProps, prevState) {
|
|
461
|
-
var deferScrollTo = false;
|
|
462
|
-
var _this$state = this.state,
|
|
463
|
-
firstIndex = _this$state.firstIndex,
|
|
464
|
-
numOfItems = _this$state.numOfItems;
|
|
465
|
-
this.shouldUpdateBounds = false; // TODO: remove `this.hasDataSizeChanged` and fix useScroll
|
|
466
|
-
|
|
467
|
-
this.hasDataSizeChanged = prevProps.dataSize !== this.props.dataSize;
|
|
468
|
-
|
|
469
|
-
if (prevState.firstIndex !== firstIndex || prevState.numOfItems !== numOfItems) {
|
|
470
|
-
this.emitUpdateItems();
|
|
471
|
-
} // When an item expands or shrinks,
|
|
472
|
-
// we need to calculate the item position again and
|
|
473
|
-
// the item needs to scroll into view if the item does not show fully.
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
if (this.props.itemSizes) {
|
|
477
|
-
if (this.itemPositions.length > this.props.itemSizes.length) {
|
|
478
|
-
// The item with `this.props.itemSizes.length` index is not rendered yet.
|
|
479
|
-
// So the item could scroll into view after it rendered.
|
|
480
|
-
// To do it, `this.props.itemSizes.length` value is cached in `this.indexToScrollIntoView`.
|
|
481
|
-
this.indexToScrollIntoView = this.props.itemSizes.length;
|
|
482
|
-
this.itemPositions = _toConsumableArray(this.itemPositions.slice(0, this.props.itemSizes.length));
|
|
483
|
-
this.adjustItemPositionWithItemSize();
|
|
484
|
-
} else {
|
|
485
|
-
var indexToScrollIntoView = this.indexToScrollIntoView;
|
|
486
|
-
this.adjustItemPositionWithItemSize();
|
|
487
|
-
|
|
488
|
-
if (indexToScrollIntoView !== -1) {
|
|
489
|
-
// Currently we support expandable items in only vertical VirtualList.
|
|
490
|
-
// So the top and bottom of the boundaries are checked.
|
|
491
|
-
var scrollBounds = {
|
|
492
|
-
top: this.scrollPosition,
|
|
493
|
-
bottom: this.scrollPosition + this.scrollBounds.clientHeight
|
|
494
|
-
},
|
|
495
|
-
itemBounds = {
|
|
496
|
-
top: this.getGridPosition(indexToScrollIntoView).primaryPosition,
|
|
497
|
-
bottom: this.getItemBottomPosition(indexToScrollIntoView)
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
if (itemBounds.top < scrollBounds.top) {
|
|
501
|
-
this.props.cbScrollTo({
|
|
502
|
-
index: indexToScrollIntoView,
|
|
503
|
-
stickTo: 'start',
|
|
504
|
-
animate: true
|
|
505
|
-
});
|
|
506
|
-
} else if (itemBounds.bottom > scrollBounds.bottom) {
|
|
507
|
-
this.props.cbScrollTo({
|
|
508
|
-
index: indexToScrollIntoView,
|
|
509
|
-
stickTo: 'end',
|
|
510
|
-
animate: true
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
this.indexToScrollIntoView = -1;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
if (prevProps.direction !== this.props.direction || prevProps.overhang !== this.props.overhang || prevProps.spacing !== this.props.spacing || !(0, _equals["default"])(prevProps.itemSize, this.props.itemSize)) {
|
|
520
|
-
var _this$getXY = this.getXY(this.scrollPosition, 0),
|
|
521
|
-
x = _this$getXY.x,
|
|
522
|
-
y = _this$getXY.y;
|
|
523
|
-
|
|
524
|
-
this.calculateMetrics(this.props); // eslint-disable-next-line react/no-did-update-set-state
|
|
525
|
-
|
|
526
|
-
this.setState(this.getStatesAndUpdateBounds(this.props));
|
|
527
|
-
this.setContainerSize();
|
|
528
|
-
var _this$scrollBounds = this.scrollBounds,
|
|
529
|
-
clientHeight = _this$scrollBounds.clientHeight,
|
|
530
|
-
clientWidth = _this$scrollBounds.clientWidth,
|
|
531
|
-
scrollHeight = _this$scrollBounds.scrollHeight,
|
|
532
|
-
scrollWidth = _this$scrollBounds.scrollWidth;
|
|
533
|
-
var xMax = scrollWidth - clientWidth;
|
|
534
|
-
var yMax = scrollHeight - clientHeight;
|
|
535
|
-
this.updateScrollPosition({
|
|
536
|
-
x: xMax > x ? x : xMax,
|
|
537
|
-
y: yMax > y ? y : yMax
|
|
538
|
-
});
|
|
539
|
-
deferScrollTo = true;
|
|
540
|
-
} else if (this.hasDataSizeChanged) {
|
|
541
|
-
var newState = this.getStatesAndUpdateBounds(this.props, this.state.firstIndex); // eslint-disable-next-line react/no-did-update-set-state
|
|
542
|
-
|
|
543
|
-
this.setState(newState);
|
|
544
|
-
this.setContainerSize();
|
|
545
|
-
deferScrollTo = true;
|
|
546
|
-
} else if (prevProps.rtl !== this.props.rtl) {
|
|
547
|
-
this.updateScrollPosition(this.getXY(this.scrollPosition, 0));
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
var maxPos = this.isPrimaryDirectionVertical ? this.scrollBounds.maxTop : this.scrollBounds.maxLeft;
|
|
551
|
-
var currentPos = this.scrollPosition;
|
|
552
|
-
|
|
553
|
-
if (this.props.scrollMode === 'native' && this.scrollToPositionTarget >= 0) {
|
|
554
|
-
currentPos = this.scrollToPositionTarget;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
if (!deferScrollTo && currentPos > maxPos) {
|
|
558
|
-
this.props.cbScrollTo({
|
|
559
|
-
position: this.isPrimaryDirectionVertical ? {
|
|
560
|
-
y: maxPos
|
|
561
|
-
} : {
|
|
562
|
-
x: maxPos
|
|
563
|
-
},
|
|
564
|
-
animate: false
|
|
565
|
-
});
|
|
566
|
-
this.scrollToPositionTarget = -1;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
}, {
|
|
570
|
-
key: "getGridPosition",
|
|
571
|
-
value: function getGridPosition(index) {
|
|
572
|
-
var _this$props2 = this.props,
|
|
573
|
-
dataSize = _this$props2.dataSize,
|
|
574
|
-
itemSizes = _this$props2.itemSizes,
|
|
575
|
-
dimensionToExtent = this.dimensionToExtent,
|
|
576
|
-
itemPositions = this.itemPositions,
|
|
577
|
-
primary = this.primary,
|
|
578
|
-
secondary = this.secondary,
|
|
579
|
-
secondaryPosition = index % dimensionToExtent * secondary.gridSize,
|
|
580
|
-
extent = Math.floor(index / dimensionToExtent);
|
|
581
|
-
var primaryPosition;
|
|
582
|
-
|
|
583
|
-
if (itemSizes && typeof itemSizes[index] !== 'undefined' && dataSize > index) {
|
|
584
|
-
var firstIndexInExtent = extent * dimensionToExtent;
|
|
585
|
-
|
|
586
|
-
if (!itemPositions[firstIndexInExtent]) {
|
|
587
|
-
// Cache individually sized item positions
|
|
588
|
-
for (var i = itemPositions.length; i <= index; i++) {
|
|
589
|
-
this.calculateAndCacheItemPosition(i);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
if (itemPositions[firstIndexInExtent]) {
|
|
594
|
-
primaryPosition = itemPositions[firstIndexInExtent].position;
|
|
595
|
-
} else {
|
|
596
|
-
primaryPosition = extent * primary.gridSize;
|
|
597
|
-
}
|
|
598
|
-
} else {
|
|
599
|
-
primaryPosition = extent * primary.gridSize;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
return {
|
|
603
|
-
primaryPosition: primaryPosition,
|
|
604
|
-
secondaryPosition: secondaryPosition
|
|
605
|
-
};
|
|
606
|
-
} // For individually sized item
|
|
607
|
-
|
|
608
|
-
}, {
|
|
609
|
-
key: "emitUpdateItems",
|
|
610
|
-
value: function emitUpdateItems() {
|
|
611
|
-
var dataSize = this.props.dataSize;
|
|
612
|
-
var _this$state2 = this.state,
|
|
613
|
-
firstIndex = _this$state2.firstIndex,
|
|
614
|
-
numOfItems = _this$state2.numOfItems;
|
|
615
|
-
(0, _handle.forward)('onUpdateItems', {
|
|
616
|
-
firstIndex: firstIndex,
|
|
617
|
-
lastIndex: Math.min(firstIndex + numOfItems, dataSize)
|
|
618
|
-
}, this.props);
|
|
619
|
-
}
|
|
620
|
-
}, {
|
|
621
|
-
key: "calculateMetrics",
|
|
622
|
-
value: function calculateMetrics(props) {
|
|
623
|
-
var clientSize = props.clientSize,
|
|
624
|
-
direction = props.direction,
|
|
625
|
-
itemSize = props.itemSize,
|
|
626
|
-
overhang = props.overhang,
|
|
627
|
-
scrollMode = props.scrollMode,
|
|
628
|
-
spacing = props.spacing,
|
|
629
|
-
node = this.props.scrollContentRef.current;
|
|
630
|
-
|
|
631
|
-
if (!clientSize && !node) {
|
|
632
|
-
return;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
var _ref4 = clientSize || this.getClientSize(node),
|
|
636
|
-
clientWidth = _ref4.clientWidth,
|
|
637
|
-
clientHeight = _ref4.clientHeight,
|
|
638
|
-
heightInfo = {
|
|
639
|
-
clientSize: clientHeight,
|
|
640
|
-
minItemSize: itemSize.minHeight || null,
|
|
641
|
-
itemSize: itemSize
|
|
642
|
-
},
|
|
643
|
-
widthInfo = {
|
|
644
|
-
clientSize: clientWidth,
|
|
645
|
-
minItemSize: itemSize.minWidth || null,
|
|
646
|
-
itemSize: itemSize
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
var primary, secondary, dimensionToExtent, thresholdBase;
|
|
650
|
-
this.isPrimaryDirectionVertical = direction === 'vertical';
|
|
651
|
-
|
|
652
|
-
if (this.isPrimaryDirectionVertical) {
|
|
653
|
-
primary = heightInfo;
|
|
654
|
-
secondary = widthInfo;
|
|
655
|
-
} else {
|
|
656
|
-
primary = widthInfo;
|
|
657
|
-
secondary = heightInfo;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
dimensionToExtent = 1;
|
|
661
|
-
this.isItemSized = primary.minItemSize && secondary.minItemSize;
|
|
662
|
-
|
|
663
|
-
if (this.isItemSized) {
|
|
664
|
-
// the number of columns is the ratio of the available width plus the spacing
|
|
665
|
-
// by the minimum item width plus the spacing
|
|
666
|
-
dimensionToExtent = Math.max(Math.floor((secondary.clientSize + spacing) / (secondary.minItemSize + spacing)), 1); // the actual item width is a ratio of the remaining width after all columns
|
|
667
|
-
// and spacing are accounted for and the number of columns that we know we should have
|
|
668
|
-
|
|
669
|
-
secondary.itemSize = Math.floor((secondary.clientSize - spacing * (dimensionToExtent - 1)) / dimensionToExtent); // the actual item height is related to the item width
|
|
670
|
-
|
|
671
|
-
primary.itemSize = Math.floor(primary.minItemSize * (secondary.itemSize / secondary.minItemSize));
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
primary.gridSize = primary.itemSize + spacing;
|
|
675
|
-
secondary.gridSize = secondary.itemSize + spacing;
|
|
676
|
-
thresholdBase = primary.gridSize * Math.ceil(overhang / 2);
|
|
677
|
-
this.threshold = {
|
|
678
|
-
min: -Infinity,
|
|
679
|
-
max: thresholdBase,
|
|
680
|
-
base: thresholdBase
|
|
681
|
-
};
|
|
682
|
-
this.dimensionToExtent = dimensionToExtent;
|
|
683
|
-
this.primary = primary;
|
|
684
|
-
this.secondary = secondary; // reset
|
|
685
|
-
|
|
686
|
-
this.scrollPosition = 0;
|
|
687
|
-
this.scrollToPositionTarget = -1;
|
|
688
|
-
|
|
689
|
-
if (scrollMode === 'translate' && this.contentRef.current) {
|
|
690
|
-
this.contentRef.current.style.transform = null;
|
|
691
|
-
} else if (scrollMode === 'native' && node) {
|
|
692
|
-
node.style.scrollBehavior = null;
|
|
693
|
-
this.updateScrollPosition(this.getXY(this.scrollPosition, 0));
|
|
694
|
-
node.style.scrollBehavior = 'smooth';
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
}, {
|
|
698
|
-
key: "calculateFirstIndex",
|
|
699
|
-
value: function calculateFirstIndex(props, wasFirstIndexMax, dataSizeDiff, firstIndex) {
|
|
700
|
-
var overhang = props.overhang,
|
|
701
|
-
dimensionToExtent = this.dimensionToExtent,
|
|
702
|
-
isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
|
|
703
|
-
maxFirstIndex = this.maxFirstIndex,
|
|
704
|
-
primary = this.primary,
|
|
705
|
-
scrollBounds = this.scrollBounds,
|
|
706
|
-
scrollPosition = this.scrollPosition,
|
|
707
|
-
threshold = this.threshold,
|
|
708
|
-
gridSize = primary.gridSize;
|
|
709
|
-
var newFirstIndex = firstIndex;
|
|
710
|
-
|
|
711
|
-
if (wasFirstIndexMax && dataSizeDiff > 0) {
|
|
712
|
-
// If dataSize increased from bottom, we need adjust firstIndex
|
|
713
|
-
// If this is a gridlist and dataSizeDiff is smaller than 1 line, we are adjusting firstIndex without threshold change.
|
|
714
|
-
if (dimensionToExtent > 1 && dataSizeDiff < dimensionToExtent) {
|
|
715
|
-
newFirstIndex = maxFirstIndex;
|
|
716
|
-
} else {
|
|
717
|
-
// For other bottom adding case, we need to update firstIndex and threshold.
|
|
718
|
-
var maxPos = isPrimaryDirectionVertical ? scrollBounds.maxTop : scrollBounds.maxLeft,
|
|
719
|
-
maxOfMin = maxPos - threshold.base,
|
|
720
|
-
numOfUpperLine = Math.floor(overhang / 2),
|
|
721
|
-
firstIndexFromPosition = Math.floor(scrollPosition / gridSize),
|
|
722
|
-
expectedFirstIndex = Math.max(0, firstIndexFromPosition - numOfUpperLine); // To navigate with 5way, we need to adjust firstIndex to the next line
|
|
723
|
-
// since at the bottom we have num of overhang lines for upper side but none for bottom side
|
|
724
|
-
// So we add numOfUpperLine at the top and rest lines at the bottom
|
|
725
|
-
|
|
726
|
-
newFirstIndex = Math.min(maxFirstIndex, expectedFirstIndex * dimensionToExtent); // We need to update threshold also since we moved the firstIndex
|
|
727
|
-
|
|
728
|
-
threshold.max = Math.min(maxPos, threshold.max + gridSize);
|
|
729
|
-
threshold.min = Math.min(maxOfMin, threshold.max - gridSize);
|
|
730
|
-
}
|
|
731
|
-
} else {
|
|
732
|
-
// Other cases, we can keep the min value between firstIndex and maxFirstIndex. No need to change threshold
|
|
733
|
-
newFirstIndex = Math.min(firstIndex, maxFirstIndex);
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
return newFirstIndex;
|
|
737
|
-
}
|
|
738
|
-
}, {
|
|
739
|
-
key: "calculateScrollBounds",
|
|
740
|
-
value: function calculateScrollBounds(props) {
|
|
741
|
-
var clientSize = props.clientSize,
|
|
742
|
-
node = this.props.scrollContentRef.current;
|
|
743
|
-
|
|
744
|
-
if (!clientSize && !node) {
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
var scrollBounds = this.scrollBounds,
|
|
749
|
-
isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
|
|
750
|
-
_ref5 = clientSize || this.getClientSize(node),
|
|
751
|
-
clientWidth = _ref5.clientWidth,
|
|
752
|
-
clientHeight = _ref5.clientHeight;
|
|
753
|
-
|
|
754
|
-
var maxPos;
|
|
755
|
-
scrollBounds.clientWidth = clientWidth;
|
|
756
|
-
scrollBounds.clientHeight = clientHeight;
|
|
757
|
-
scrollBounds.scrollWidth = this.getScrollWidth();
|
|
758
|
-
scrollBounds.scrollHeight = this.getScrollHeight();
|
|
759
|
-
scrollBounds.maxLeft = Math.max(0, scrollBounds.scrollWidth - clientWidth);
|
|
760
|
-
scrollBounds.maxTop = Math.max(0, scrollBounds.scrollHeight - clientHeight); // correct position
|
|
761
|
-
|
|
762
|
-
maxPos = isPrimaryDirectionVertical ? scrollBounds.maxTop : scrollBounds.maxLeft;
|
|
763
|
-
this.syncThreshold(maxPos);
|
|
764
|
-
}
|
|
765
|
-
}, {
|
|
766
|
-
key: "updateMoreInfo",
|
|
767
|
-
value: function updateMoreInfo(dataSize, primaryPosition) {
|
|
768
|
-
var dimensionToExtent = this.dimensionToExtent,
|
|
769
|
-
moreInfo = this.moreInfo,
|
|
770
|
-
_this$primary = this.primary,
|
|
771
|
-
itemSize = _this$primary.itemSize,
|
|
772
|
-
gridSize = _this$primary.gridSize,
|
|
773
|
-
clientSize = _this$primary.clientSize;
|
|
774
|
-
|
|
775
|
-
if (dataSize <= 0) {
|
|
776
|
-
moreInfo.firstVisibleIndex = null;
|
|
777
|
-
moreInfo.lastVisibleIndex = null;
|
|
778
|
-
} else if (this.props.itemSizes) {
|
|
779
|
-
var _this$state3 = this.state,
|
|
780
|
-
firstIndex = _this$state3.firstIndex,
|
|
781
|
-
numOfItems = _this$state3.numOfItems;
|
|
782
|
-
var isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
|
|
783
|
-
_this$scrollBounds2 = this.scrollBounds,
|
|
784
|
-
clientWidth = _this$scrollBounds2.clientWidth,
|
|
785
|
-
clientHeight = _this$scrollBounds2.clientHeight,
|
|
786
|
-
scrollPosition = this.scrollPosition;
|
|
787
|
-
var size = isPrimaryDirectionVertical ? clientHeight : clientWidth;
|
|
788
|
-
var firstVisibleIndex = null,
|
|
789
|
-
lastVisibleIndex = null;
|
|
790
|
-
|
|
791
|
-
for (var i = firstIndex; i < firstIndex + numOfItems; i++) {
|
|
792
|
-
if (scrollPosition <= this.getItemBottomPosition(i)) {
|
|
793
|
-
firstVisibleIndex = i;
|
|
794
|
-
break;
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
for (var _i = firstIndex + numOfItems - 1; _i >= firstIndex; _i--) {
|
|
799
|
-
if (scrollPosition + size >= this.getItemBottomPosition(_i) - this.props.itemSizes[_i]) {
|
|
800
|
-
lastVisibleIndex = _i;
|
|
801
|
-
break;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
if (firstVisibleIndex > lastVisibleIndex) {
|
|
806
|
-
firstVisibleIndex = null;
|
|
807
|
-
lastVisibleIndex = null;
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
moreInfo.firstVisibleIndex = firstVisibleIndex;
|
|
811
|
-
moreInfo.lastVisibleIndex = lastVisibleIndex;
|
|
812
|
-
} else {
|
|
813
|
-
moreInfo.firstVisibleIndex = (Math.floor((primaryPosition - itemSize) / gridSize) + 1) * dimensionToExtent;
|
|
814
|
-
moreInfo.lastVisibleIndex = Math.min(dataSize - 1, Math.ceil((primaryPosition + clientSize) / gridSize) * dimensionToExtent - 1);
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
}, {
|
|
818
|
-
key: "syncThreshold",
|
|
819
|
-
value: function syncThreshold(maxPos) {
|
|
820
|
-
var threshold = this.threshold;
|
|
821
|
-
|
|
822
|
-
if (threshold.max > maxPos) {
|
|
823
|
-
if (maxPos < threshold.base) {
|
|
824
|
-
threshold.max = threshold.base;
|
|
825
|
-
threshold.min = -Infinity;
|
|
826
|
-
} else {
|
|
827
|
-
threshold.max = maxPos;
|
|
828
|
-
threshold.min = maxPos - threshold.base;
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
} // scrollMode 'native' only
|
|
832
|
-
|
|
833
|
-
}, {
|
|
834
|
-
key: "scrollToPosition",
|
|
835
|
-
value: function scrollToPosition(x, y) {
|
|
836
|
-
var rtl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.props.rtl;
|
|
837
|
-
|
|
838
|
-
if (this.props.scrollContentRef.current && this.props.scrollContentRef.current.scrollTo) {
|
|
839
|
-
if (rtl) {
|
|
840
|
-
x = _platform.platform.ios || _platform.platform.safari ? -x : this.scrollBounds.maxLeft - x;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
this.props.scrollContentRef.current.scrollTo(x, y);
|
|
844
|
-
}
|
|
845
|
-
} // scrollMode 'native' only
|
|
846
|
-
|
|
847
|
-
}, {
|
|
848
|
-
key: "setScrollToPositionTarget",
|
|
849
|
-
value: function setScrollToPositionTarget(x, y) {
|
|
850
|
-
if (this.isPrimaryDirectionVertical) {
|
|
851
|
-
this.scrollToPositionTarget = y;
|
|
852
|
-
} else {
|
|
853
|
-
this.scrollToPositionTarget = x;
|
|
854
|
-
}
|
|
855
|
-
} // scrollMode 'translate' only
|
|
856
|
-
|
|
857
|
-
}, {
|
|
858
|
-
key: "setScrollPositionTarget",
|
|
859
|
-
value: function setScrollPositionTarget(x, y) {
|
|
860
|
-
// The `x`, `y` as parameters in scrollToPosition() are the position when stopping scrolling.
|
|
861
|
-
// But the `x`, `y` as parameters in setScrollPosition() are the position between current position and the position stopping scrolling.
|
|
862
|
-
// To know the position when stopping scrolling properly, `x` and `y` are passed and cached in `this.scrollPositionTarget`.
|
|
863
|
-
if (this.isPrimaryDirectionVertical) {
|
|
864
|
-
this.scrollPositionTarget = y;
|
|
865
|
-
} else {
|
|
866
|
-
this.scrollPositionTarget = x;
|
|
867
|
-
}
|
|
868
|
-
} // scrollMode 'translate' only
|
|
869
|
-
|
|
870
|
-
}, {
|
|
871
|
-
key: "setScrollPosition",
|
|
872
|
-
value: function setScrollPosition(x, y) {
|
|
873
|
-
var rtl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.props.rtl;
|
|
874
|
-
|
|
875
|
-
if (this.contentRef.current) {
|
|
876
|
-
this.contentRef.current.style.transform = "translate3d(".concat(rtl ? x : -x, "px, -").concat(y, "px, 0)");
|
|
877
|
-
this.didScroll(x, y);
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
}, {
|
|
881
|
-
key: "didScroll",
|
|
882
|
-
value: function didScroll(x, y) {
|
|
883
|
-
var _this$props3 = this.props,
|
|
884
|
-
dataSize = _this$props3.dataSize,
|
|
885
|
-
spacing = _this$props3.spacing,
|
|
886
|
-
itemSizes = _this$props3.itemSizes,
|
|
887
|
-
firstIndex = this.state.firstIndex,
|
|
888
|
-
isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
|
|
889
|
-
threshold = this.threshold,
|
|
890
|
-
dimensionToExtent = this.dimensionToExtent,
|
|
891
|
-
maxFirstIndex = this.maxFirstIndex,
|
|
892
|
-
scrollBounds = this.scrollBounds,
|
|
893
|
-
itemPositions = this.itemPositions,
|
|
894
|
-
_this$primary2 = this.primary,
|
|
895
|
-
clientSize = _this$primary2.clientSize,
|
|
896
|
-
gridSize = _this$primary2.gridSize,
|
|
897
|
-
maxPos = isPrimaryDirectionVertical ? scrollBounds.maxTop : scrollBounds.maxLeft;
|
|
898
|
-
var newFirstIndex = firstIndex,
|
|
899
|
-
index,
|
|
900
|
-
pos,
|
|
901
|
-
size,
|
|
902
|
-
itemPosition;
|
|
903
|
-
|
|
904
|
-
if (isPrimaryDirectionVertical) {
|
|
905
|
-
pos = y;
|
|
906
|
-
} else {
|
|
907
|
-
pos = x;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
if (pos > threshold.max || pos < threshold.min) {
|
|
911
|
-
var newThresholdMin = -Infinity,
|
|
912
|
-
newThresholdMax = Infinity;
|
|
913
|
-
|
|
914
|
-
if (this.props.itemSizes) {
|
|
915
|
-
var overhangBefore = Math.floor(this.props.overhang / 2);
|
|
916
|
-
var firstRenderedIndex = -1; // find an item which is known as placed the first rendered item's position
|
|
917
|
-
|
|
918
|
-
for (index = 0; index < dataSize; index += dimensionToExtent) {
|
|
919
|
-
itemPosition = itemPositions[index];
|
|
920
|
-
size = itemSizes[index];
|
|
921
|
-
|
|
922
|
-
if (itemPosition && size && itemPosition.position + size >= pos && itemPosition.position <= pos + clientSize) {
|
|
923
|
-
firstRenderedIndex = index;
|
|
924
|
-
break;
|
|
925
|
-
}
|
|
926
|
-
} // found an item which is visible within a current viewport
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
if (index < dataSize) {
|
|
930
|
-
if (itemPosition.position <= pos) {
|
|
931
|
-
newFirstIndex = firstRenderedIndex - overhangBefore * dimensionToExtent;
|
|
932
|
-
newThresholdMin = itemPosition.position;
|
|
933
|
-
newThresholdMax = newThresholdMin + size + spacing;
|
|
934
|
-
} else {
|
|
935
|
-
var diffToFirstIndex = Math.ceil((itemPosition.position - pos) / gridSize);
|
|
936
|
-
newFirstIndex = firstRenderedIndex - (diffToFirstIndex + overhangBefore) * dimensionToExtent;
|
|
937
|
-
newThresholdMin = itemPosition.position - diffToFirstIndex * gridSize;
|
|
938
|
-
newThresholdMax = newThresholdMin + gridSize;
|
|
939
|
-
}
|
|
940
|
-
} else {
|
|
941
|
-
// calculate the first index based on assuming that all items have minimal size
|
|
942
|
-
var firstExtent = Math.max(0, Math.min(Math.floor(maxFirstIndex / dimensionToExtent), Math.floor((pos - gridSize * overhangBefore) / gridSize)));
|
|
943
|
-
newFirstIndex = firstExtent * dimensionToExtent;
|
|
944
|
-
newThresholdMin = (firstExtent + overhangBefore) * gridSize;
|
|
945
|
-
newThresholdMax = newThresholdMin + gridSize;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
newFirstIndex = Math.max(0, Math.min(maxFirstIndex, newFirstIndex));
|
|
949
|
-
} else {
|
|
950
|
-
var _overhangBefore = Math.floor(this.props.overhang / 2),
|
|
951
|
-
_firstExtent = Math.max(0, Math.min(Math.floor(maxFirstIndex / dimensionToExtent), Math.floor((pos - gridSize * _overhangBefore) / gridSize)));
|
|
952
|
-
|
|
953
|
-
newFirstIndex = _firstExtent * dimensionToExtent;
|
|
954
|
-
newThresholdMin = (_firstExtent + _overhangBefore) * gridSize;
|
|
955
|
-
newThresholdMax = newThresholdMin + gridSize;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
threshold.min = newFirstIndex === 0 ? -Infinity : newThresholdMin;
|
|
959
|
-
threshold.max = newFirstIndex === maxFirstIndex ? Infinity : newThresholdMax;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
this.syncThreshold(maxPos);
|
|
963
|
-
this.scrollPosition = pos;
|
|
964
|
-
this.updateMoreInfo(dataSize, pos);
|
|
965
|
-
|
|
966
|
-
if (this.shouldUpdateBounds || firstIndex !== newFirstIndex) {
|
|
967
|
-
this.setState({
|
|
968
|
-
firstIndex: newFirstIndex
|
|
969
|
-
});
|
|
970
|
-
}
|
|
971
|
-
} // For individually sized item
|
|
972
|
-
|
|
973
|
-
}, {
|
|
974
|
-
key: "calculateAndCacheItemPosition",
|
|
975
|
-
value: function calculateAndCacheItemPosition(index) {
|
|
976
|
-
var itemSizes = this.props.itemSizes;
|
|
977
|
-
|
|
978
|
-
if (!this.itemPositions[index] && itemSizes[index]) {
|
|
979
|
-
var spacing = this.props.spacing,
|
|
980
|
-
position = this.getItemTopPositionFromPreviousItemBottomPosition(index, spacing);
|
|
981
|
-
this.itemPositions[index] = {
|
|
982
|
-
position: position
|
|
983
|
-
};
|
|
984
|
-
}
|
|
985
|
-
} // For individually sized item
|
|
986
|
-
|
|
987
|
-
}, {
|
|
988
|
-
key: "applyItemPositionToDOMElement",
|
|
989
|
-
value: function applyItemPositionToDOMElement(index) {
|
|
990
|
-
var _this$props4 = this.props,
|
|
991
|
-
direction = _this$props4.direction,
|
|
992
|
-
rtl = _this$props4.rtl,
|
|
993
|
-
numOfItems = this.state.numOfItems,
|
|
994
|
-
itemPositions = this.itemPositions,
|
|
995
|
-
childNode = this.itemContainerRefs[index % numOfItems];
|
|
996
|
-
|
|
997
|
-
if (childNode && itemPositions[index]) {
|
|
998
|
-
var position = itemPositions[index].position;
|
|
999
|
-
|
|
1000
|
-
if (direction === 'vertical') {
|
|
1001
|
-
childNode.style.transform = "translate3d(0, ".concat(position, "px, 0)");
|
|
1002
|
-
} else {
|
|
1003
|
-
childNode.style.transform = "translate3d(".concat(position * (rtl ? -1 : 1), "px, 0, 0)");
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
} // For individually sized item
|
|
1007
|
-
|
|
1008
|
-
}, {
|
|
1009
|
-
key: "updateThresholdWithItemPosition",
|
|
1010
|
-
value: function updateThresholdWithItemPosition() {
|
|
1011
|
-
var overhang = this.props.overhang,
|
|
1012
|
-
firstIndex = this.state.firstIndex,
|
|
1013
|
-
maxFirstIndex = this.maxFirstIndex,
|
|
1014
|
-
numOfUpperLine = Math.floor(overhang / 2);
|
|
1015
|
-
this.threshold.min = firstIndex === 0 ? -Infinity : this.getItemBottomPosition(firstIndex + numOfUpperLine);
|
|
1016
|
-
this.threshold.max = firstIndex === maxFirstIndex ? Infinity : this.getItemBottomPosition(firstIndex + (numOfUpperLine + 1));
|
|
1017
|
-
} // For individually sized item
|
|
1018
|
-
|
|
1019
|
-
}, {
|
|
1020
|
-
key: "updateScrollBoundsWithItemPositions",
|
|
1021
|
-
value: function updateScrollBoundsWithItemPositions() {
|
|
1022
|
-
var _this$props5 = this.props,
|
|
1023
|
-
dataSize = _this$props5.dataSize,
|
|
1024
|
-
itemSizes = _this$props5.itemSizes,
|
|
1025
|
-
spacing = _this$props5.spacing,
|
|
1026
|
-
_this$state4 = this.state,
|
|
1027
|
-
firstIndex = _this$state4.firstIndex,
|
|
1028
|
-
numOfItems = _this$state4.numOfItems,
|
|
1029
|
-
isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
|
|
1030
|
-
itemPositions = this.itemPositions,
|
|
1031
|
-
scrollBoundsDimension = isPrimaryDirectionVertical ? 'scrollHeight' : 'scrollWidth';
|
|
1032
|
-
|
|
1033
|
-
if (itemPositions.length === dataSize) {
|
|
1034
|
-
// all item sizes are known
|
|
1035
|
-
this.scrollBounds[scrollBoundsDimension] = itemSizes.reduce(function (acc, cur) {
|
|
1036
|
-
return acc + cur;
|
|
1037
|
-
}, 0) + (dataSize - 1) * spacing;
|
|
1038
|
-
} else {
|
|
1039
|
-
for (var index = firstIndex + numOfItems - 1; index < dataSize; index++) {
|
|
1040
|
-
var nextInfo = itemPositions[index + 1];
|
|
1041
|
-
|
|
1042
|
-
if (!nextInfo) {
|
|
1043
|
-
var endPosition = this.getItemBottomPosition(index);
|
|
1044
|
-
|
|
1045
|
-
if (endPosition > this.scrollBounds[scrollBoundsDimension]) {
|
|
1046
|
-
this.scrollBounds[scrollBoundsDimension] = endPosition;
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
break;
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
this.scrollBounds.maxTop = Math.max(0, this.scrollBounds.scrollHeight - this.scrollBounds.clientHeight);
|
|
1055
|
-
} // For individually sized item
|
|
1056
|
-
|
|
1057
|
-
}, {
|
|
1058
|
-
key: "adjustItemPositionWithItemSize",
|
|
1059
|
-
value: function adjustItemPositionWithItemSize() {
|
|
1060
|
-
if (this.cc.length) {
|
|
1061
|
-
var dataSize = this.props.dataSize,
|
|
1062
|
-
_this$state5 = this.state,
|
|
1063
|
-
firstIndex = _this$state5.firstIndex,
|
|
1064
|
-
numOfItems = _this$state5.numOfItems,
|
|
1065
|
-
lastIndex = firstIndex + numOfItems - 1; // Cache individually sized item positions
|
|
1066
|
-
// and adjust item DOM element positions
|
|
1067
|
-
|
|
1068
|
-
for (var index = firstIndex; index <= lastIndex; index++) {
|
|
1069
|
-
this.calculateAndCacheItemPosition(index);
|
|
1070
|
-
this.applyItemPositionToDOMElement(index);
|
|
1071
|
-
} // Update threshold based on this.itemPositions
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
this.updateThresholdWithItemPosition(); // Update scroll bounds based on this.itemPositions
|
|
1075
|
-
|
|
1076
|
-
this.updateScrollBoundsWithItemPositions(); // Set container size based on this.scrollbounds
|
|
1077
|
-
|
|
1078
|
-
this.setContainerSize(); // Update moreInfo based on this.itemPositions
|
|
1079
|
-
|
|
1080
|
-
this.updateMoreInfo(dataSize, this.scrollPosition);
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
}, {
|
|
1084
|
-
key: "composeStyle",
|
|
1085
|
-
value: function composeStyle(width, height, primaryPosition, secondaryPosition) {
|
|
1086
|
-
var _this$getXY2 = this.getXY(primaryPosition, secondaryPosition),
|
|
1087
|
-
x = _this$getXY2.x,
|
|
1088
|
-
y = _this$getXY2.y,
|
|
1089
|
-
style = {
|
|
1090
|
-
/* FIXME: RTL / this calculation only works for Chrome */
|
|
1091
|
-
transform: "translate3d(".concat(this.props.rtl ? -x : x, "px, ").concat(y, "px, 0)")
|
|
1092
|
-
};
|
|
1093
|
-
|
|
1094
|
-
if (this.isItemSized) {
|
|
1095
|
-
style.width = width;
|
|
1096
|
-
style.height = height;
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
return style;
|
|
1100
|
-
}
|
|
1101
|
-
}, {
|
|
1102
|
-
key: "positionItems",
|
|
1103
|
-
value: function positionItems() {
|
|
1104
|
-
var _this$props6 = this.props,
|
|
1105
|
-
dataSize = _this$props6.dataSize,
|
|
1106
|
-
itemSizes = _this$props6.itemSizes,
|
|
1107
|
-
_this$state6 = this.state,
|
|
1108
|
-
firstIndex = _this$state6.firstIndex,
|
|
1109
|
-
numOfItems = _this$state6.numOfItems,
|
|
1110
|
-
cc = this.cc,
|
|
1111
|
-
isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
|
|
1112
|
-
dimensionToExtent = this.dimensionToExtent,
|
|
1113
|
-
primary = this.primary,
|
|
1114
|
-
secondary = this.secondary,
|
|
1115
|
-
itemPositions = this.itemPositions;
|
|
1116
|
-
var hideTo = 0,
|
|
1117
|
-
updateFrom = cc.length ? this.state.updateFrom : firstIndex,
|
|
1118
|
-
updateTo = cc.length ? this.state.updateTo : firstIndex + numOfItems;
|
|
1119
|
-
|
|
1120
|
-
if (updateFrom >= updateTo) {
|
|
1121
|
-
return;
|
|
1122
|
-
} else if (updateTo > dataSize) {
|
|
1123
|
-
hideTo = updateTo;
|
|
1124
|
-
updateTo = dataSize;
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
var width,
|
|
1128
|
-
height,
|
|
1129
|
-
_this$getGridPosition = this.getGridPosition(updateFrom),
|
|
1130
|
-
primaryPosition = _this$getGridPosition.primaryPosition,
|
|
1131
|
-
secondaryPosition = _this$getGridPosition.secondaryPosition;
|
|
1132
|
-
|
|
1133
|
-
width = (isPrimaryDirectionVertical ? secondary.itemSize : primary.itemSize) + 'px';
|
|
1134
|
-
height = (isPrimaryDirectionVertical ? primary.itemSize : secondary.itemSize) + 'px'; // positioning items
|
|
1135
|
-
|
|
1136
|
-
for (var i = updateFrom, j = updateFrom % dimensionToExtent; i < updateTo; i++) {
|
|
1137
|
-
this.applyStyleToNewNode(i, width, height, primaryPosition, secondaryPosition);
|
|
1138
|
-
|
|
1139
|
-
if (++j === dimensionToExtent) {
|
|
1140
|
-
secondaryPosition = 0;
|
|
1141
|
-
|
|
1142
|
-
if (this.props.itemSizes) {
|
|
1143
|
-
if (itemPositions[i + 1] || itemPositions[i + 1] === 0) {
|
|
1144
|
-
primaryPosition = itemPositions[i + 1].position;
|
|
1145
|
-
} else if (itemSizes[i]) {
|
|
1146
|
-
primaryPosition += itemSizes[i] + this.props.spacing;
|
|
1147
|
-
} else {
|
|
1148
|
-
primaryPosition += primary.gridSize;
|
|
1149
|
-
}
|
|
1150
|
-
} else {
|
|
1151
|
-
primaryPosition += primary.gridSize;
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
j = 0;
|
|
1155
|
-
} else {
|
|
1156
|
-
secondaryPosition += secondary.gridSize;
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
for (var _i2 = updateTo; _i2 < hideTo; _i2++) {
|
|
1161
|
-
this.applyStyleToHideNode(_i2);
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
}, {
|
|
1165
|
-
key: "render",
|
|
1166
|
-
// render
|
|
1167
|
-
value: function render() {
|
|
1168
|
-
var _this$props7 = this.props,
|
|
1169
|
-
className = _this$props7.className,
|
|
1170
|
-
voiceFocused = _this$props7['data-webos-voice-focused'],
|
|
1171
|
-
voiceGroupLabel = _this$props7['data-webos-voice-group-label'],
|
|
1172
|
-
voiceDisabled = _this$props7['data-webos-voice-disabled'],
|
|
1173
|
-
placeholderRenderer = _this$props7.placeholderRenderer,
|
|
1174
|
-
role = _this$props7.role,
|
|
1175
|
-
style = _this$props7.style,
|
|
1176
|
-
scrollMode = _this$props7.scrollMode,
|
|
1177
|
-
rest = _objectWithoutProperties(_this$props7, ["className", "data-webos-voice-focused", "data-webos-voice-group-label", "data-webos-voice-disabled", "placeholderRenderer", "role", "style", "scrollMode"]),
|
|
1178
|
-
cc = this.cc,
|
|
1179
|
-
isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
|
|
1180
|
-
primary = this.primary,
|
|
1181
|
-
scrollModeNative = scrollMode === 'native',
|
|
1182
|
-
containerClasses = (0, _classnames["default"])(_VirtualListModule["default"].virtualList, isPrimaryDirectionVertical ? _VirtualListModule["default"].vertical : _VirtualListModule["default"].horizontal, _defineProperty({}, _VirtualListModule["default"]["native"], scrollModeNative), className),
|
|
1183
|
-
contentClasses = scrollModeNative ? null : _VirtualListModule["default"].content;
|
|
1184
|
-
|
|
1185
|
-
delete rest.cbScrollTo;
|
|
1186
|
-
delete rest.childProps;
|
|
1187
|
-
delete rest.clientSize;
|
|
1188
|
-
delete rest.dataSize;
|
|
1189
|
-
delete rest.direction;
|
|
1190
|
-
delete rest.getAffordance;
|
|
1191
|
-
delete rest.getComponentProps;
|
|
1192
|
-
delete rest.isHorizontalScrollbarVisible;
|
|
1193
|
-
delete rest.isVerticalScrollbarVisible;
|
|
1194
|
-
delete rest.itemRefs;
|
|
1195
|
-
delete rest.itemRenderer;
|
|
1196
|
-
delete rest.itemSize;
|
|
1197
|
-
delete rest.itemSizes;
|
|
1198
|
-
delete rest.onUpdate;
|
|
1199
|
-
delete rest.onUpdateItems;
|
|
1200
|
-
delete rest.overhang;
|
|
1201
|
-
delete rest.pageScroll;
|
|
1202
|
-
delete rest.rtl;
|
|
1203
|
-
delete rest.scrollContainerContainsDangerously;
|
|
1204
|
-
delete rest.scrollContentRef;
|
|
1205
|
-
delete rest.scrollMode;
|
|
1206
|
-
delete rest.setThemeScrollContentHandle;
|
|
1207
|
-
delete rest.spacing;
|
|
1208
|
-
delete rest.updateStatesAndBounds;
|
|
1209
|
-
|
|
1210
|
-
if (primary) {
|
|
1211
|
-
this.positionItems();
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
1215
|
-
className: containerClasses,
|
|
1216
|
-
"data-webos-voice-focused": voiceFocused,
|
|
1217
|
-
"data-webos-voice-group-label": voiceGroupLabel,
|
|
1218
|
-
"data-webos-voice-disabled": voiceDisabled,
|
|
1219
|
-
ref: this.props.scrollContentRef,
|
|
1220
|
-
style: style
|
|
1221
|
-
}, /*#__PURE__*/_react["default"].createElement("div", Object.assign({}, rest, {
|
|
1222
|
-
className: contentClasses,
|
|
1223
|
-
ref: this.contentRef,
|
|
1224
|
-
role: role
|
|
1225
|
-
}), [].concat(_toConsumableArray(cc), [placeholderRenderer && placeholderRenderer(primary)])));
|
|
1226
|
-
}
|
|
1227
|
-
}], [{
|
|
1228
|
-
key: "getDerivedStateFromProps",
|
|
1229
|
-
value: function getDerivedStateFromProps(props, state) {
|
|
1230
|
-
var shouldInvalidate = state.prevFirstIndex === state.firstIndex || state.prevChildProps !== props.childProps,
|
|
1231
|
-
diff = state.firstIndex - state.prevFirstIndex,
|
|
1232
|
-
updateTo = -state.numOfItems >= diff || diff > 0 || shouldInvalidate ? state.firstIndex + state.numOfItems : state.prevFirstIndex,
|
|
1233
|
-
updateFrom = 0 >= diff || diff >= state.numOfItems || shouldInvalidate ? state.firstIndex : state.prevFirstIndex + state.numOfItems,
|
|
1234
|
-
nextUpdateFromAndTo = state.updateFrom !== updateFrom || state.updateTo !== updateTo ? {
|
|
1235
|
-
updateFrom: updateFrom,
|
|
1236
|
-
updateTo: updateTo
|
|
1237
|
-
} : null;
|
|
1238
|
-
return _objectSpread(_objectSpread({}, nextUpdateFromAndTo), {}, {
|
|
1239
|
-
prevChildProps: props.childProps,
|
|
1240
|
-
prevFirstIndex: state.firstIndex
|
|
1241
|
-
});
|
|
1242
|
-
}
|
|
1243
|
-
}]);
|
|
1244
|
-
|
|
1245
|
-
return VirtualListBasic;
|
|
1246
|
-
}(_react.Component);
|
|
1247
|
-
|
|
1248
|
-
exports.VirtualListBasic = VirtualListBasic;
|
|
1249
|
-
VirtualListBasic.propTypes =
|
|
1250
|
-
/** @lends ui/VirtualList.VirtualListBasic.prototype */
|
|
1251
|
-
{
|
|
1252
|
-
/**
|
|
1253
|
-
* The rendering function called for each item in the list.
|
|
1254
|
-
*
|
|
1255
|
-
* > **Note**: The list does **not** always render a component whenever its render function is called
|
|
1256
|
-
* due to performance optimization.
|
|
1257
|
-
*
|
|
1258
|
-
* Example:
|
|
1259
|
-
* ```
|
|
1260
|
-
* renderItem = ({index, ...rest}) => {
|
|
1261
|
-
*
|
|
1262
|
-
* return (
|
|
1263
|
-
* <MyComponent index={index} {...rest} />
|
|
1264
|
-
* );
|
|
1265
|
-
* }
|
|
1266
|
-
* ```
|
|
1267
|
-
*
|
|
1268
|
-
* @type {Function}
|
|
1269
|
-
* @param {Object} event
|
|
1270
|
-
* @param {Number} event.data-index It is required for `Spotlight` 5-way navigation. Pass to the root element in the component.
|
|
1271
|
-
* @param {Number} event.index The index number of the component to render
|
|
1272
|
-
*
|
|
1273
|
-
* @required
|
|
1274
|
-
* @public
|
|
1275
|
-
*/
|
|
1276
|
-
itemRenderer: _propTypes2["default"].func.isRequired,
|
|
1277
|
-
|
|
1278
|
-
/**
|
|
1279
|
-
* The size of an item for the list; valid values are either a number for `VirtualList`
|
|
1280
|
-
* or an object that has `minWidth` and `minHeight` for `VirtualGridList`.
|
|
1281
|
-
*
|
|
1282
|
-
* @type {Number|ui/VirtualList.gridListItemSizeShape}
|
|
1283
|
-
* @required
|
|
1284
|
-
* @private
|
|
1285
|
-
*/
|
|
1286
|
-
itemSize: _propTypes2["default"].oneOfType([_propTypes2["default"].number, gridListItemSizeShape]).isRequired,
|
|
1287
|
-
|
|
1288
|
-
/**
|
|
1289
|
-
* Callback method of scrollTo.
|
|
1290
|
-
* Normally, useScroll should set this value.
|
|
1291
|
-
*
|
|
1292
|
-
* @type {Function}
|
|
1293
|
-
* @private
|
|
1294
|
-
*/
|
|
1295
|
-
cbScrollTo: _propTypes2["default"].func,
|
|
1296
|
-
|
|
1297
|
-
/**
|
|
1298
|
-
* Additional props included in the object passed to the `itemRenderer` callback.
|
|
1299
|
-
*
|
|
1300
|
-
* @type {Object}
|
|
1301
|
-
* @public
|
|
1302
|
-
*/
|
|
1303
|
-
childProps: _propTypes2["default"].object,
|
|
1304
|
-
|
|
1305
|
-
/**
|
|
1306
|
-
* Client size of the list; valid values are an object that has `clientWidth` and `clientHeight`.
|
|
1307
|
-
*
|
|
1308
|
-
* @type {Object}
|
|
1309
|
-
* @property {Number} clientHeight The client height of the list.
|
|
1310
|
-
* @property {Number} clientWidth The client width of the list.
|
|
1311
|
-
* @public
|
|
1312
|
-
*/
|
|
1313
|
-
clientSize: _propTypes2["default"].shape({
|
|
1314
|
-
clientHeight: _propTypes2["default"].number.isRequired,
|
|
1315
|
-
clientWidth: _propTypes2["default"].number.isRequired
|
|
1316
|
-
}),
|
|
1317
|
-
|
|
1318
|
-
/**
|
|
1319
|
-
* Disable voice control feature of component.
|
|
1320
|
-
*
|
|
1321
|
-
* @type {Boolean}
|
|
1322
|
-
* @public
|
|
1323
|
-
*/
|
|
1324
|
-
'data-webos-voice-disabled': _propTypes2["default"].bool,
|
|
1325
|
-
|
|
1326
|
-
/**
|
|
1327
|
-
* Activates the component for voice control.
|
|
1328
|
-
*
|
|
1329
|
-
* @type {Boolean}
|
|
1330
|
-
* @public
|
|
1331
|
-
*/
|
|
1332
|
-
'data-webos-voice-focused': _propTypes2["default"].bool,
|
|
1333
|
-
|
|
1334
|
-
/**
|
|
1335
|
-
* The voice control group label.
|
|
1336
|
-
*
|
|
1337
|
-
* @type {String}
|
|
1338
|
-
* @public
|
|
1339
|
-
*/
|
|
1340
|
-
'data-webos-voice-group-label': _propTypes2["default"].string,
|
|
1341
|
-
|
|
1342
|
-
/**
|
|
1343
|
-
* The number of items of data the list contains.
|
|
1344
|
-
*
|
|
1345
|
-
* @type {Number}
|
|
1346
|
-
* @default 0
|
|
1347
|
-
* @public
|
|
1348
|
-
*/
|
|
1349
|
-
dataSize: _propTypes2["default"].number,
|
|
1350
|
-
|
|
1351
|
-
/**
|
|
1352
|
-
* The layout direction of the list.
|
|
1353
|
-
*
|
|
1354
|
-
* Valid values are:
|
|
1355
|
-
* * `'horizontal'`, and
|
|
1356
|
-
* * `'vertical'`.
|
|
1357
|
-
*
|
|
1358
|
-
* @type {String}
|
|
1359
|
-
* @default 'vertical'
|
|
1360
|
-
* @public
|
|
1361
|
-
*/
|
|
1362
|
-
direction: _propTypes2["default"].oneOf(['horizontal', 'vertical']),
|
|
1363
|
-
|
|
1364
|
-
/**
|
|
1365
|
-
* Called to get the scroll affordance from themed component.
|
|
1366
|
-
*
|
|
1367
|
-
* @type {Function}
|
|
1368
|
-
* @private
|
|
1369
|
-
*/
|
|
1370
|
-
getAffordance: _propTypes2["default"].func,
|
|
1371
|
-
|
|
1372
|
-
/**
|
|
1373
|
-
* Called to get the props for list items.
|
|
1374
|
-
*
|
|
1375
|
-
* @type {Function}
|
|
1376
|
-
* @private
|
|
1377
|
-
*/
|
|
1378
|
-
getComponentProps: _propTypes2["default"].func,
|
|
1379
|
-
|
|
1380
|
-
/**
|
|
1381
|
-
* Ref for items
|
|
1382
|
-
*
|
|
1383
|
-
* @type {Object}
|
|
1384
|
-
* @private
|
|
1385
|
-
*/
|
|
1386
|
-
itemRefs: _propTypes2["default"].object,
|
|
1387
|
-
|
|
1388
|
-
/**
|
|
1389
|
-
* The array for individually sized items.
|
|
1390
|
-
*
|
|
1391
|
-
* @type {Number[]}
|
|
1392
|
-
* @private
|
|
1393
|
-
*/
|
|
1394
|
-
itemSizes: _propTypes2["default"].arrayOf(_propTypes2["default"].number),
|
|
1395
|
-
|
|
1396
|
-
/**
|
|
1397
|
-
* Called when the range of items has updated.
|
|
1398
|
-
*
|
|
1399
|
-
* Event payload includes the `firstIndex` and `lastIndex` of the list.
|
|
1400
|
-
*
|
|
1401
|
-
* @type {Function}
|
|
1402
|
-
* @private
|
|
1403
|
-
*/
|
|
1404
|
-
onUpdateItems: _propTypes2["default"].func,
|
|
1405
|
-
|
|
1406
|
-
/**
|
|
1407
|
-
* Number of spare DOM node.
|
|
1408
|
-
* `3` is good for the default value experimentally and
|
|
1409
|
-
* this value is highly recommended not to be changed by developers.
|
|
1410
|
-
*
|
|
1411
|
-
* @type {Number}
|
|
1412
|
-
* @default 3
|
|
1413
|
-
* @private
|
|
1414
|
-
*/
|
|
1415
|
-
overhang: _propTypes2["default"].number,
|
|
1416
|
-
|
|
1417
|
-
/**
|
|
1418
|
-
* When `true`, the list will scroll by page. Otherwise the list will scroll by item.
|
|
1419
|
-
*
|
|
1420
|
-
* @type {Boolean}
|
|
1421
|
-
* @default false
|
|
1422
|
-
* @private
|
|
1423
|
-
*/
|
|
1424
|
-
pageScroll: _propTypes2["default"].bool,
|
|
1425
|
-
|
|
1426
|
-
/**
|
|
1427
|
-
* The render function for the placeholder elements.
|
|
1428
|
-
*
|
|
1429
|
-
* @type {Function}
|
|
1430
|
-
* @required
|
|
1431
|
-
* @private
|
|
1432
|
-
*/
|
|
1433
|
-
placeholderRenderer: _propTypes2["default"].func,
|
|
1434
|
-
|
|
1435
|
-
/**
|
|
1436
|
-
* The ARIA role for the list.
|
|
1437
|
-
*
|
|
1438
|
-
* @type {String}
|
|
1439
|
-
* @default 'list'
|
|
1440
|
-
* @public
|
|
1441
|
-
*/
|
|
1442
|
-
role: _propTypes2["default"].string,
|
|
1443
|
-
|
|
1444
|
-
/**
|
|
1445
|
-
* `true` if RTL, `false` if LTR.
|
|
1446
|
-
*
|
|
1447
|
-
* @type {Boolean}
|
|
1448
|
-
* @private
|
|
1449
|
-
*/
|
|
1450
|
-
rtl: _propTypes2["default"].bool,
|
|
1451
|
-
|
|
1452
|
-
/**
|
|
1453
|
-
* Ref for scroll content
|
|
1454
|
-
*
|
|
1455
|
-
* @type {Object|Function}}
|
|
1456
|
-
* @private
|
|
1457
|
-
*/
|
|
1458
|
-
scrollContentRef: _propTypes["default"].ref,
|
|
1459
|
-
|
|
1460
|
-
/**
|
|
1461
|
-
* Specifies how to scroll.
|
|
1462
|
-
*
|
|
1463
|
-
* Valid values are:
|
|
1464
|
-
* * `'translate'`,
|
|
1465
|
-
* * `'native'`.
|
|
1466
|
-
*
|
|
1467
|
-
* @type {String}
|
|
1468
|
-
* @default 'translate'
|
|
1469
|
-
* @public
|
|
1470
|
-
*/
|
|
1471
|
-
scrollMode: _propTypes2["default"].string,
|
|
1472
|
-
|
|
1473
|
-
/**
|
|
1474
|
-
* The spacing between items.
|
|
1475
|
-
*
|
|
1476
|
-
* @type {Number}
|
|
1477
|
-
* @default 0
|
|
1478
|
-
* @public
|
|
1479
|
-
*/
|
|
1480
|
-
spacing: _propTypes2["default"].number,
|
|
1481
|
-
|
|
1482
|
-
/**
|
|
1483
|
-
* Called to execute additional logic in a themed component when updating states and bounds.
|
|
1484
|
-
*
|
|
1485
|
-
* @type {Function}
|
|
1486
|
-
* @private
|
|
1487
|
-
*/
|
|
1488
|
-
updateStatesAndBounds: _propTypes2["default"].func
|
|
1489
|
-
};
|
|
1490
|
-
VirtualListBasic.defaultProps = {
|
|
1491
|
-
cbScrollTo: nop,
|
|
1492
|
-
dataSize: 0,
|
|
1493
|
-
direction: 'vertical',
|
|
1494
|
-
getAffordance: function getAffordance() {
|
|
1495
|
-
return 0;
|
|
1496
|
-
},
|
|
1497
|
-
overhang: 3,
|
|
1498
|
-
pageScroll: false,
|
|
1499
|
-
scrollMode: 'translate',
|
|
1500
|
-
spacing: 0
|
|
1501
|
-
};
|
|
1502
|
-
var _default = VirtualListBasic;
|
|
1503
|
-
exports["default"] = _default;
|