@onepercentio/one-ui 0.19.2 → 0.19.3
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/.babelrc +17 -0
- package/.prod.babelrc +22 -0
- package/dist/assets/styles/variables.scss +1 -0
- package/dist/components/AdaptiveButton/AdaptiveButton.js +24 -25
- package/dist/components/AdaptiveButton/index.js +12 -8
- package/dist/components/AdaptiveContainer/AdaptiveContainer.js +95 -114
- package/dist/components/AdaptiveContainer/index.js +12 -8
- package/dist/components/AdaptiveDialog/AdaptiveDialog.js +85 -65
- package/dist/components/AdaptiveDialog/index.js +12 -8
- package/dist/components/AdaptiveSidebar/AdaptiveSidebar.js +84 -76
- package/dist/components/AdaptiveSidebar/index.js +12 -8
- package/dist/components/AnchoredTooltip/AnchoredTooltip.js +155 -160
- package/dist/components/AnchoredTooltip/index.js +12 -8
- package/dist/components/AnimatedEntrance/AnimatedEntrance.js +172 -139
- package/dist/components/AnimatedEntrance/index.js +26 -10
- package/dist/components/AsyncWrapper/AsyncWrapper.js +33 -21
- package/dist/components/AsyncWrapper/index.js +12 -8
- package/dist/components/Avatar/Avatar.js +34 -40
- package/dist/components/Avatar/index.js +12 -8
- package/dist/components/BucketFill/BucketFill.js +47 -58
- package/dist/components/BucketFill/index.js +12 -8
- package/dist/components/Button/Button.js +32 -49
- package/dist/components/Button/README.md +8 -0
- package/dist/components/Button/index.js +12 -8
- package/dist/components/Card/Card.js +16 -11
- package/dist/components/Card/index.js +12 -8
- package/dist/components/Chart/Chart.logic.js +10 -10
- package/dist/components/Chart/Chart.types.js +4 -2
- package/dist/components/Chart/Chart.view.js +212 -131
- package/dist/components/Chart/index.js +12 -8
- package/dist/components/CheckBox/CheckBox.d.ts +3 -1
- package/dist/components/CheckBox/CheckBox.js +43 -30
- package/dist/components/CheckBox/CheckBox.module.scss +4 -0
- package/dist/components/CheckBox/index.js +12 -8
- package/dist/components/Collapsable/Collapsable.d.ts +26 -27
- package/dist/components/Collapsable/Collapsable.js +173 -143
- package/dist/components/Collapsable/index.js +12 -8
- package/dist/components/Countdown/Countdown.js +87 -100
- package/dist/components/Countdown/index.js +12 -8
- package/dist/components/Divider/Divider.js +15 -12
- package/dist/components/Divider/index.js +12 -8
- package/dist/components/EmailInput/EmailInput.d.ts +4 -3
- package/dist/components/EmailInput/EmailInput.js +45 -43
- package/dist/components/EmailInput/README.md +10 -0
- package/dist/components/EmailInput/index.js +20 -9
- package/dist/components/FadeIn/FadeIn.js +62 -69
- package/dist/components/FadeIn/index.js +12 -8
- package/dist/components/FileInput/FileInput.d.ts +25 -9
- package/dist/components/FileInput/FileInput.js +41 -70
- package/dist/components/FileInput/FileInput.module.scss +0 -21
- package/dist/components/FileInput/View/BigFactory/BigFactory.d.ts +6 -0
- package/dist/components/FileInput/View/BigFactory/BigFactory.js +46 -0
- package/dist/components/FileInput/View/BigFactory/BigFactory.module.scss +20 -0
- package/dist/components/FileInput/View/BigFactory/index.d.ts +1 -0
- package/dist/components/FileInput/View/BigFactory/index.js +13 -0
- package/dist/components/FileInput/View/Compact/Compact.d.ts +5 -0
- package/dist/components/FileInput/View/Compact/Compact.js +88 -0
- package/dist/components/FileInput/View/Compact/Compact.module.scss +59 -0
- package/dist/components/FileInput/View/Compact/index.d.ts +1 -0
- package/dist/components/FileInput/View/Compact/index.js +13 -0
- package/dist/components/FileInput/View/View.types.d.ts +8 -0
- package/dist/components/FileInput/View/View.types.js +5 -0
- package/dist/components/FileInput/index.js +12 -8
- package/dist/components/FlowController/FlowController.js +60 -29
- package/dist/components/FlowController/README.md +13 -0
- package/dist/components/FlowController/index.js +12 -8
- package/dist/components/Form/Form.js +157 -96
- package/dist/components/Form/index.js +12 -8
- package/dist/components/Freeze/Freeze.js +11 -10
- package/dist/components/Freeze/index.js +12 -8
- package/dist/components/HSForms/HSForms.js +48 -68
- package/dist/components/HSForms/index.js +12 -8
- package/dist/components/Header/Header.js +100 -69
- package/dist/components/Header/index.js +12 -8
- package/dist/components/HeaderCloseBtn/HeaderCloseBtn.js +17 -13
- package/dist/components/HeaderCloseBtn/index.js +12 -8
- package/dist/components/InfinityScroll/InfinityScroll.js +137 -117
- package/dist/components/InfinityScroll/index.js +12 -8
- package/dist/components/Input/Input.d.ts +8 -6
- package/dist/components/Input/Input.js +105 -90
- package/dist/components/Input/Input.module.scss +4 -2
- package/dist/components/Input/README.md +10 -0
- package/dist/components/Input/index.js +12 -8
- package/dist/components/InstantCounter/InstantCounter.js +61 -52
- package/dist/components/InstantCounter/index.js +12 -8
- package/dist/components/LavaLamp/LavaLamp.data.js +95 -87
- package/dist/components/LavaLamp/LavaLamp.js +107 -70
- package/dist/components/LavaLamp/index.js +12 -8
- package/dist/components/LavaLamp/v2/LavaLamp.js +200 -182
- package/dist/components/LinkToId/LinkToId.js +42 -28
- package/dist/components/LinkToId/index.js +20 -9
- package/dist/components/Loader/Loader.js +20 -26
- package/dist/components/Loader/index.js +12 -8
- package/dist/components/LoaderDotsIndicator/LoaderDotsIndicator.js +34 -37
- package/dist/components/LoaderDotsIndicator/index.js +12 -8
- package/dist/components/LoopableVideo/LoopableVideo.js +29 -30
- package/dist/components/LoopableVideo/index.js +12 -8
- package/dist/components/MainGrid/MainGrid.js +44 -50
- package/dist/components/MainGrid/index.js +12 -8
- package/dist/components/MutableHamburgerButton/MutableHamburgerButton.js +26 -26
- package/dist/components/MutableHamburgerButton/index.js +12 -8
- package/dist/components/Notification/Notification.js +16 -12
- package/dist/components/Notification/index.js +12 -8
- package/dist/components/OrderableList/OrderableList.js +406 -374
- package/dist/components/OrderableList/index.js +12 -8
- package/dist/components/PaginationIndicator/PaginationIndicator.js +230 -196
- package/dist/components/PaginationIndicator/index.js +12 -8
- package/dist/components/Parallax/Parallax.js +164 -161
- package/dist/components/Parallax/index.js +12 -8
- package/dist/components/Parallax/math/helpers.js +128 -217
- package/dist/components/PasswordInput/PasswordInput.d.ts +4 -3
- package/dist/components/PasswordInput/PasswordInput.js +120 -97
- package/dist/components/PasswordInput/index.js +12 -8
- package/dist/components/PixelatedScan/PixelatedScan.js +140 -97
- package/dist/components/PixelatedScan/index.js +12 -8
- package/dist/components/Portal/Portal.js +54 -64
- package/dist/components/Portal/index.js +20 -9
- package/dist/components/ProgressBar/ProgressBar.js +48 -45
- package/dist/components/ProgressBar/index.js +20 -9
- package/dist/components/ProgressTexts/ProgressTexts.js +42 -34
- package/dist/components/ProgressTexts/README.md +12 -0
- package/dist/components/ProgressTexts/index.js +12 -8
- package/dist/components/Radio/Radio.d.ts +13 -0
- package/dist/components/Radio/Radio.js +47 -0
- package/dist/components/Radio/Radio.module.scss +33 -0
- package/dist/components/Radio/index.d.ts +1 -0
- package/dist/components/Radio/index.js +13 -0
- package/dist/components/SectionContainer/SectionContainer.js +35 -39
- package/dist/components/SectionContainer/index.js +12 -8
- package/dist/components/Select/Select.d.ts +2 -1
- package/dist/components/Select/Select.js +133 -82
- package/dist/components/Select/Select.module.scss +14 -2
- package/dist/components/Select/index.js +12 -8
- package/dist/components/Skeleton/Skeleton.js +21 -15
- package/dist/components/Skeleton/index.js +12 -8
- package/dist/components/Spacing/Spacing.js +14 -11
- package/dist/components/Spacing/index.js +12 -8
- package/dist/components/StaticScroller/StaticScroller.js +61 -81
- package/dist/components/StaticScroller/index.js +12 -8
- package/dist/components/Switch/Switch.js +29 -25
- package/dist/components/Switch/index.js +12 -8
- package/dist/components/Table/Table.js +111 -80
- package/dist/components/Table/index.js +12 -8
- package/dist/components/Tabs/Tabs.js +42 -52
- package/dist/components/Tabs/index.js +12 -8
- package/dist/components/Text/Text.js +31 -50
- package/dist/components/Text/index.js +12 -8
- package/dist/components/Transition/MasksFactory/DiagonalReveal.js +46 -22
- package/dist/components/Transition/MasksFactory/DiagonalSquareToBalls.js +71 -57
- package/dist/components/Transition/MasksFactory/PhysicsSquares.js +97 -80
- package/dist/components/Transition/MasksFactory/SquareToBalls.js +59 -50
- package/dist/components/Transition/MasksFactory/utils.js +25 -28
- package/dist/components/Transition/Transition.js +316 -309
- package/dist/components/Transition/index.js +20 -9
- package/dist/components/UncontrolledTransition/UncontrolledTransition.js +110 -86
- package/dist/components/UncontrolledTransition/index.js +12 -8
- package/dist/components/WalletConnectionWrapper/WalletConnectionWrapper.js +116 -105
- package/dist/components/WalletConnectionWrapper/index.js +20 -9
- package/dist/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.js +51 -69
- package/dist/components/utilitary/ScrollAndFocusLock/index.js +12 -8
- package/dist/context/AsyncProcess.js +77 -63
- package/dist/context/CustomBrowserRouter.js +40 -52
- package/dist/context/OneUIProvider.d.ts +8 -2
- package/dist/context/OneUIProvider.js +90 -104
- package/dist/hooks/logs/README.md +3 -0
- package/dist/hooks/logs/useDependencyChangeDetection.js +17 -17
- package/dist/hooks/logs/useIsMounting.js +10 -8
- package/dist/hooks/persistence/useLocalStorage.js +40 -30
- package/dist/hooks/shims/ObjectWatchShim.d.ts +1 -0
- package/dist/hooks/shims/ObjectWatchShim.js +49 -46
- package/dist/hooks/ui/useAdaptiveImage.js +43 -35
- package/dist/hooks/ui/useBreakpoint.js +34 -19
- package/dist/hooks/ui/useCustomScrollbar.js +26 -21
- package/dist/hooks/ui/useMouseHover.js +29 -16
- package/dist/hooks/ui/usePaginationControls.d.ts +0 -4
- package/dist/hooks/ui/usePaginationControls.e2e.d.ts +4 -0
- package/dist/hooks/ui/usePaginationControls.js +125 -153
- package/dist/hooks/ui/useTilt.js +156 -128
- package/dist/hooks/ui/useZoomable.js +114 -138
- package/dist/hooks/useAsyncControl.js +82 -47
- package/dist/hooks/useContainedRepositioning.js +75 -72
- package/dist/hooks/useCustomHistory.js +21 -13
- package/dist/hooks/useElementFit.js +42 -34
- package/dist/hooks/useFirestoreWatch.js +54 -35
- package/dist/hooks/useForm.js +47 -22
- package/dist/hooks/useFreeze.js +11 -9
- package/dist/hooks/useHero.d.ts +4 -0
- package/dist/hooks/useHero.js +171 -159
- package/dist/hooks/useIntersection.js +33 -27
- package/dist/hooks/useMergeRefs.js +26 -23
- package/dist/hooks/useObserve.js +28 -15
- package/dist/hooks/usePagination.js +151 -129
- package/dist/hooks/usePooledOperation.js +43 -58
- package/dist/hooks/usePooling.js +62 -48
- package/dist/hooks/useRebound.js +36 -22
- package/dist/hooks/useShortIntl.js +79 -51
- package/dist/hooks/utility/useEvents.js +28 -22
- package/dist/hooks/utility/useModule.js +21 -10
- package/dist/hooks/utility/useQuery.js +14 -8
- package/dist/models/DebugLogger.js +7 -6
- package/dist/models/GenericContract.js +39 -12
- package/dist/reac-app-env.d.js +1 -0
- package/dist/storybook/assets/video/txt-reversed.mp4 +0 -0
- package/dist/storybookUtils/index.js +42 -24
- package/dist/type-utils.js +4 -2
- package/dist/types.js +4 -2
- package/dist/utility.d.js +17 -0
- package/dist/utils/blockchain.js +60 -54
- package/dist/utils/flatten.js +23 -13
- package/dist/utils/html.utils.js +9 -6
- package/dist/utils/ownEvent.js +9 -8
- package/package.json +13 -8
- package/tsconfig.json +3 -2
- package/cypress/support/commands.ts +0 -49
- package/cypress/support/component-index.html +0 -30
- package/cypress/support/component.ts +0 -39
- package/cypress/support/e2e.js +0 -49
- package/dist/components/AdaptiveButton/AdaptiveButton.js.map +0 -1
- package/dist/components/AdaptiveButton/index.js.map +0 -1
- package/dist/components/AdaptiveContainer/AdaptiveContainer.js.map +0 -1
- package/dist/components/AdaptiveContainer/index.js.map +0 -1
- package/dist/components/AdaptiveDialog/AdaptiveDialog.js.map +0 -1
- package/dist/components/AdaptiveDialog/index.js.map +0 -1
- package/dist/components/AdaptiveSidebar/AdaptiveSidebar.js.map +0 -1
- package/dist/components/AdaptiveSidebar/index.js.map +0 -1
- package/dist/components/AnchoredTooltip/AnchoredTooltip.js.map +0 -1
- package/dist/components/AnchoredTooltip/index.js.map +0 -1
- package/dist/components/AnimatedEntrance/AnimatedEntrance.js.map +0 -1
- package/dist/components/AnimatedEntrance/index.js.map +0 -1
- package/dist/components/AsyncWrapper/AsyncWrapper.js.map +0 -1
- package/dist/components/AsyncWrapper/index.js.map +0 -1
- package/dist/components/Avatar/Avatar.js.map +0 -1
- package/dist/components/Avatar/index.js.map +0 -1
- package/dist/components/BucketFill/BucketFill.js.map +0 -1
- package/dist/components/BucketFill/index.js.map +0 -1
- package/dist/components/Button/Button.js.map +0 -1
- package/dist/components/Button/index.js.map +0 -1
- package/dist/components/Card/Card.js.map +0 -1
- package/dist/components/Card/index.js.map +0 -1
- package/dist/components/Chart/Chart.e2e.js +0 -9
- package/dist/components/Chart/Chart.e2e.js.map +0 -1
- package/dist/components/Chart/Chart.logic.js.map +0 -1
- package/dist/components/Chart/Chart.types.js.map +0 -1
- package/dist/components/Chart/Chart.view.js.map +0 -1
- package/dist/components/Chart/index.js.map +0 -1
- package/dist/components/CheckBox/CheckBox.js.map +0 -1
- package/dist/components/CheckBox/index.js.map +0 -1
- package/dist/components/Collapsable/Collapsable.js.map +0 -1
- package/dist/components/Collapsable/index.js.map +0 -1
- package/dist/components/Countdown/Countdown.js.map +0 -1
- package/dist/components/Countdown/index.js.map +0 -1
- package/dist/components/Divider/Divider.js.map +0 -1
- package/dist/components/Divider/index.js.map +0 -1
- package/dist/components/EmailInput/EmailInput.js.map +0 -1
- package/dist/components/EmailInput/index.js.map +0 -1
- package/dist/components/FadeIn/FadeIn.js.map +0 -1
- package/dist/components/FadeIn/index.js.map +0 -1
- package/dist/components/FileInput/FileInput.js.map +0 -1
- package/dist/components/FileInput/index.js.map +0 -1
- package/dist/components/FlowController/FlowController.js.map +0 -1
- package/dist/components/FlowController/index.js.map +0 -1
- package/dist/components/Form/Form.js.map +0 -1
- package/dist/components/Form/index.js.map +0 -1
- package/dist/components/Freeze/Freeze.js.map +0 -1
- package/dist/components/Freeze/index.js.map +0 -1
- package/dist/components/HSForms/HSForms.js.map +0 -1
- package/dist/components/HSForms/index.js.map +0 -1
- package/dist/components/Header/Header.js.map +0 -1
- package/dist/components/Header/index.js.map +0 -1
- package/dist/components/HeaderCloseBtn/HeaderCloseBtn.js.map +0 -1
- package/dist/components/HeaderCloseBtn/index.js.map +0 -1
- package/dist/components/InfinityScroll/InfinityScroll.js.map +0 -1
- package/dist/components/InfinityScroll/index.js.map +0 -1
- package/dist/components/Input/Input.js.map +0 -1
- package/dist/components/Input/index.js.map +0 -1
- package/dist/components/InstantCounter/InstantCounter.js.map +0 -1
- package/dist/components/InstantCounter/index.js.map +0 -1
- package/dist/components/LavaLamp/LavaLamp.data.js.map +0 -1
- package/dist/components/LavaLamp/LavaLamp.js.map +0 -1
- package/dist/components/LavaLamp/index.js.map +0 -1
- package/dist/components/LavaLamp/v2/LavaLamp.js.map +0 -1
- package/dist/components/LinkToId/LinkToId.js.map +0 -1
- package/dist/components/LinkToId/index.js.map +0 -1
- package/dist/components/Loader/Loader.js.map +0 -1
- package/dist/components/Loader/index.js.map +0 -1
- package/dist/components/LoaderDotsIndicator/LoaderDotsIndicator.js.map +0 -1
- package/dist/components/LoaderDotsIndicator/index.js.map +0 -1
- package/dist/components/LoopableVideo/LoopableVideo.js.map +0 -1
- package/dist/components/LoopableVideo/index.js.map +0 -1
- package/dist/components/MainGrid/MainGrid.js.map +0 -1
- package/dist/components/MainGrid/index.js.map +0 -1
- package/dist/components/MutableHamburgerButton/MutableHamburgerButton.js.map +0 -1
- package/dist/components/MutableHamburgerButton/index.js.map +0 -1
- package/dist/components/Notification/Notification.js.map +0 -1
- package/dist/components/Notification/index.js.map +0 -1
- package/dist/components/OrderableList/OrderableList.js.map +0 -1
- package/dist/components/OrderableList/index.js.map +0 -1
- package/dist/components/PaginationIndicator/PaginationIndicator.js.map +0 -1
- package/dist/components/PaginationIndicator/index.js.map +0 -1
- package/dist/components/Parallax/Parallax.js.map +0 -1
- package/dist/components/Parallax/index.js.map +0 -1
- package/dist/components/Parallax/math/helpers.js.map +0 -1
- package/dist/components/PasswordInput/PasswordInput.js.map +0 -1
- package/dist/components/PasswordInput/index.js.map +0 -1
- package/dist/components/PixelatedScan/PixelatedScan.js.map +0 -1
- package/dist/components/PixelatedScan/index.js.map +0 -1
- package/dist/components/Portal/Portal.js.map +0 -1
- package/dist/components/Portal/index.js.map +0 -1
- package/dist/components/ProgressBar/ProgressBar.js.map +0 -1
- package/dist/components/ProgressBar/index.js.map +0 -1
- package/dist/components/ProgressTexts/ProgressTexts.js.map +0 -1
- package/dist/components/ProgressTexts/index.js.map +0 -1
- package/dist/components/SectionContainer/SectionContainer.js.map +0 -1
- package/dist/components/SectionContainer/index.js.map +0 -1
- package/dist/components/Select/Select.js.map +0 -1
- package/dist/components/Select/index.js.map +0 -1
- package/dist/components/Skeleton/Skeleton.js.map +0 -1
- package/dist/components/Skeleton/index.js.map +0 -1
- package/dist/components/Spacing/Spacing.js.map +0 -1
- package/dist/components/Spacing/index.js.map +0 -1
- package/dist/components/StaticScroller/StaticScroller.js.map +0 -1
- package/dist/components/StaticScroller/index.js.map +0 -1
- package/dist/components/Switch/Switch.js.map +0 -1
- package/dist/components/Switch/index.js.map +0 -1
- package/dist/components/Table/Table.js.map +0 -1
- package/dist/components/Table/index.js.map +0 -1
- package/dist/components/Tabs/Tabs.js.map +0 -1
- package/dist/components/Tabs/index.js.map +0 -1
- package/dist/components/Text/Text.js.map +0 -1
- package/dist/components/Text/index.js.map +0 -1
- package/dist/components/Transition/MasksFactory/DiagonalReveal.js.map +0 -1
- package/dist/components/Transition/MasksFactory/DiagonalSquareToBalls.js.map +0 -1
- package/dist/components/Transition/MasksFactory/PhysicsSquares.js.map +0 -1
- package/dist/components/Transition/MasksFactory/SquareToBalls.js.map +0 -1
- package/dist/components/Transition/MasksFactory/utils.js.map +0 -1
- package/dist/components/Transition/Transition.js.map +0 -1
- package/dist/components/Transition/index.js.map +0 -1
- package/dist/components/UncontrolledTransition/UncontrolledTransition.js.map +0 -1
- package/dist/components/UncontrolledTransition/index.js.map +0 -1
- package/dist/components/WalletConnectionWrapper/WalletConnectionWrapper.js.map +0 -1
- package/dist/components/WalletConnectionWrapper/index.js.map +0 -1
- package/dist/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.js.map +0 -1
- package/dist/components/utilitary/ScrollAndFocusLock/index.js.map +0 -1
- package/dist/context/AsyncProcess.js.map +0 -1
- package/dist/context/CustomBrowserRouter.js.map +0 -1
- package/dist/context/OneUIProvider.js.map +0 -1
- package/dist/hooks/logs/useDependencyChangeDetection.js.map +0 -1
- package/dist/hooks/logs/useIsMounting.js.map +0 -1
- package/dist/hooks/persistence/useLocalStorage.js.map +0 -1
- package/dist/hooks/shims/ObjectWatchShim.js.map +0 -1
- package/dist/hooks/ui/useAdaptiveImage.js.map +0 -1
- package/dist/hooks/ui/useBreakpoint.js.map +0 -1
- package/dist/hooks/ui/useCustomScrollbar.js.map +0 -1
- package/dist/hooks/ui/useMouseHover.js.map +0 -1
- package/dist/hooks/ui/usePaginationControls.js.map +0 -1
- package/dist/hooks/ui/useTilt.js.map +0 -1
- package/dist/hooks/ui/useZoomable.js.map +0 -1
- package/dist/hooks/useAsyncControl.js.map +0 -1
- package/dist/hooks/useContainedRepositioning.js.map +0 -1
- package/dist/hooks/useCustomHistory.js.map +0 -1
- package/dist/hooks/useElementFit.js.map +0 -1
- package/dist/hooks/useFirestoreWatch.js.map +0 -1
- package/dist/hooks/useForm.js.map +0 -1
- package/dist/hooks/useFreeze.js.map +0 -1
- package/dist/hooks/useHero.js.map +0 -1
- package/dist/hooks/useHero.module.scss +0 -5
- package/dist/hooks/useIntersection.js.map +0 -1
- package/dist/hooks/useMergeRefs.js.map +0 -1
- package/dist/hooks/useObserve.js.map +0 -1
- package/dist/hooks/usePagination.js.map +0 -1
- package/dist/hooks/usePooledOperation.js.map +0 -1
- package/dist/hooks/usePooling.js.map +0 -1
- package/dist/hooks/useRebound.js.map +0 -1
- package/dist/hooks/useShortIntl.js.map +0 -1
- package/dist/hooks/utility/useEvents.js.map +0 -1
- package/dist/hooks/utility/useModule.js.map +0 -1
- package/dist/hooks/utility/useQuery.js.map +0 -1
- package/dist/models/DebugLogger.js.map +0 -1
- package/dist/models/GenericContract.js.map +0 -1
- package/dist/storybookUtils/index.js.map +0 -1
- package/dist/type-utils.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/blockchain.js.map +0 -1
- package/dist/utils/flatten.js.map +0 -1
- package/dist/utils/html.utils.js.map +0 -1
- package/dist/utils/ownEvent.js.map +0 -1
|
@@ -1,142 +1,164 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = usePagination;
|
|
8
|
+
exports.useContainerPagination = useContainerPagination;
|
|
9
|
+
exports.useLocalPagination = useLocalPagination;
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _useAsyncControl2 = _interopRequireDefault(require("./useAsyncControl"));
|
|
12
|
+
var _throttle = _interopRequireDefault(require("lodash/throttle"));
|
|
13
|
+
const _excluded = ["process"];
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
19
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
21
|
+
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."); }
|
|
22
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
23
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
24
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
25
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
26
|
+
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; }
|
|
27
|
+
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; }
|
|
28
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
29
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
30
|
+
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); }
|
|
31
|
+
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; }
|
|
32
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
33
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
34
|
+
function usePagination(request) {
|
|
35
|
+
let paginationId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
|
|
36
|
+
return "default";
|
|
37
|
+
};
|
|
38
|
+
let startingItems = arguments.length > 2 ? arguments[2] : undefined;
|
|
39
|
+
const paginationDataRef = (0, _react.useRef)({});
|
|
40
|
+
const paginationData = paginationDataRef.current;
|
|
41
|
+
const _useState = (0, _react.useState)(function () {
|
|
42
|
+
if (startingItems) return [paginationId(), startingItems, 0];else return undefined;
|
|
43
|
+
}),
|
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
+
items = _useState2[0],
|
|
46
|
+
setItems = _useState2[1];
|
|
47
|
+
const _useAsyncControl = (0, _useAsyncControl2.default)(),
|
|
48
|
+
process = _useAsyncControl.process,
|
|
49
|
+
control = _objectWithoutProperties(_useAsyncControl, _excluded);
|
|
50
|
+
function updateItems(cb) {
|
|
51
|
+
setItems(function (prev) {
|
|
52
|
+
return [prev[0], cb(), prev[2]];
|
|
38
53
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
54
|
+
}
|
|
55
|
+
const _requestPage = (0, _react.useCallback)(function (page) {
|
|
56
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
57
|
+
args[_key - 1] = arguments[_key];
|
|
42
58
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
59
|
+
const id = paginationId.apply(void 0, args);
|
|
60
|
+
process( /*#__PURE__*/_asyncToGenerator(function* () {
|
|
61
|
+
var _paginationData$id;
|
|
62
|
+
if ((_paginationData$id = paginationData[id]) !== null && _paginationData$id !== void 0 && _paginationData$id.finished) return;
|
|
63
|
+
const result = yield request.apply(void 0, [page, (items === null || items === void 0 ? void 0 : items[0]) === id && page !== 0 ? items === null || items === void 0 ? void 0 : items[1] : undefined].concat(args));
|
|
64
|
+
paginationData[id] = {
|
|
65
|
+
finished: result.finished,
|
|
66
|
+
totalItems: result.totalItems
|
|
67
|
+
};
|
|
68
|
+
setItems(function (prev) {
|
|
69
|
+
if (page === 0) return [id, result.items, page];else if (!prev || id === prev[0]) return [id, result.items, page];
|
|
70
|
+
return prev;
|
|
71
|
+
});
|
|
72
|
+
}));
|
|
73
|
+
}, [items, request]);
|
|
74
|
+
return {
|
|
75
|
+
updateItems: updateItems,
|
|
76
|
+
getNextPage: function getNextPage() {
|
|
77
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
78
|
+
args[_key2] = arguments[_key2];
|
|
79
|
+
}
|
|
80
|
+
_requestPage.apply(void 0, [((items === null || items === void 0 ? void 0 : items[2]) || 0) + 1].concat(args));
|
|
81
|
+
},
|
|
82
|
+
getPage: _requestPage,
|
|
83
|
+
totalItems: function totalItems() {
|
|
84
|
+
var _paginationData$pagin;
|
|
85
|
+
return (_paginationData$pagin = paginationData[paginationId.apply(void 0, arguments)]) === null || _paginationData$pagin === void 0 ? void 0 : _paginationData$pagin.totalItems;
|
|
86
|
+
},
|
|
87
|
+
loading: control.loading,
|
|
88
|
+
error: control.error,
|
|
89
|
+
items: items === null || items === void 0 ? void 0 : items[1],
|
|
90
|
+
setError: control.setError
|
|
91
|
+
};
|
|
75
92
|
}
|
|
76
|
-
exports.default = usePagination;
|
|
77
93
|
/**
|
|
78
94
|
* This returns a ref to be bound to an elements so it can be able to detect when a pagination whould occur
|
|
79
95
|
*/
|
|
80
|
-
function useContainerPagination(cb
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
109
|
-
return () => el.removeEventListener("scroll", calculateIfReachedLimit);
|
|
110
|
-
}, [cb]);
|
|
111
|
-
return {
|
|
112
|
-
scrollableRef,
|
|
113
|
-
customOptionsRef,
|
|
96
|
+
function useContainerPagination(cb) {
|
|
97
|
+
let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "v";
|
|
98
|
+
const scrollableRef = (0, _react.useRef)(null);
|
|
99
|
+
const customOptionsRef = (0, _react.useRef)();
|
|
100
|
+
(0, _react.useEffect)(function () {
|
|
101
|
+
const el = scrollableRef.current;
|
|
102
|
+
const scrollElement = el.scrollingElement || el;
|
|
103
|
+
const calculateIfReachedLimit = (0, _throttle.default)(function () {
|
|
104
|
+
var _customOptionsRef$cur;
|
|
105
|
+
const _ref2 = ((_customOptionsRef$cur = customOptionsRef.current) === null || _customOptionsRef$cur === void 0 ? void 0 : _customOptionsRef$cur.call(customOptionsRef)) || {},
|
|
106
|
+
_ref2$offsetBottom = _ref2.offsetBottom,
|
|
107
|
+
offsetBottom = _ref2$offsetBottom === void 0 ? 0 : _ref2$offsetBottom,
|
|
108
|
+
_ref2$offsetLeft = _ref2.offsetLeft,
|
|
109
|
+
offsetLeft = _ref2$offsetLeft === void 0 ? 0 : _ref2$offsetLeft;
|
|
110
|
+
const offsetLimit = direction === "v" ? scrollElement.scrollHeight - offsetBottom - scrollElement.clientHeight * 0.6 : scrollElement.scrollWidth - offsetLeft - scrollElement.clientWidth * 0.6;
|
|
111
|
+
const offset = direction === "v" ? scrollElement.clientHeight + scrollElement.scrollTop : scrollElement.clientWidth + scrollElement.scrollLeft;
|
|
112
|
+
if (offset >= offsetLimit) {
|
|
113
|
+
cb();
|
|
114
|
+
}
|
|
115
|
+
}, 250, {
|
|
116
|
+
leading: false,
|
|
117
|
+
trailing: true
|
|
118
|
+
});
|
|
119
|
+
el.addEventListener("scroll", calculateIfReachedLimit, {
|
|
120
|
+
passive: true
|
|
121
|
+
});
|
|
122
|
+
return function () {
|
|
123
|
+
return el.removeEventListener("scroll", calculateIfReachedLimit);
|
|
114
124
|
};
|
|
125
|
+
}, [cb]);
|
|
126
|
+
return {
|
|
127
|
+
scrollableRef: scrollableRef,
|
|
128
|
+
customOptionsRef: customOptionsRef
|
|
129
|
+
};
|
|
115
130
|
}
|
|
116
|
-
|
|
131
|
+
|
|
117
132
|
/**
|
|
118
133
|
* This function receives an amount of local instances and paginates it
|
|
119
134
|
*/
|
|
120
135
|
function useLocalPagination(items, pageSize) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
const instanceID = (0, _react.useMemo)(function () {
|
|
137
|
+
return Date.now();
|
|
138
|
+
}, [items]);
|
|
139
|
+
const cb = (0, _react.useCallback)(function (page) {
|
|
140
|
+
let currItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
141
|
+
if (!items) return Promise.resolve({
|
|
142
|
+
finished: false,
|
|
143
|
+
totalItems: 0,
|
|
144
|
+
items: []
|
|
145
|
+
});
|
|
146
|
+
const from = pageSize * page;
|
|
147
|
+
const newArray = [].concat(_toConsumableArray(currItems), _toConsumableArray(items.slice(from, from + pageSize)));
|
|
148
|
+
return Promise.resolve({
|
|
149
|
+
finished: newArray.length === items.length,
|
|
150
|
+
totalItems: items.length,
|
|
151
|
+
items: newArray
|
|
152
|
+
});
|
|
153
|
+
}, [pageSize, items]);
|
|
154
|
+
const pagination = usePagination(cb, function () {
|
|
155
|
+
return "".concat(instanceID);
|
|
156
|
+
}, items === null || items === void 0 ? void 0 : items.slice(0, pageSize));
|
|
157
|
+
const pagSrc = (0, _react.useMemo)(function () {
|
|
158
|
+
return items;
|
|
159
|
+
}, [pagination.items]);
|
|
160
|
+
return _objectSpread(_objectSpread({}, pagination), {}, {
|
|
161
|
+
loading: items === undefined,
|
|
162
|
+
src: pagSrc
|
|
163
|
+
});
|
|
164
|
+
}
|
|
@@ -1,64 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const react_1 = require("react");
|
|
16
|
-
const useAsyncControl_1 = __importDefault(require("./useAsyncControl"));
|
|
17
|
-
const usePooling_1 = __importDefault(require("./usePooling"));
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = usePooledOperation;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _useAsyncControl = _interopRequireDefault(require("./useAsyncControl"));
|
|
9
|
+
var _usePooling = _interopRequireDefault(require("./usePooling"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
18
13
|
/**
|
|
19
14
|
* A toolkit hook to trigger an request to start a process and execute a pooling operation to validate when the operation is finished
|
|
20
15
|
*/
|
|
21
16
|
function usePooledOperation() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
const requestOperation = (0, _react.useRef)();
|
|
18
|
+
const poolingOperation = (0, _react.useRef)();
|
|
19
|
+
const requestControl = (0, _useAsyncControl.default)();
|
|
20
|
+
const pollingControl = (0, _usePooling.default)();
|
|
21
|
+
function triggerRequest() {
|
|
22
|
+
requestControl.process( /*#__PURE__*/_asyncToGenerator(function* () {
|
|
23
|
+
yield requestOperation.current();
|
|
24
|
+
triggerPooling();
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
function triggerPooling() {
|
|
28
|
+
pollingControl.startPolling(poolingOperation.current);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
/** Indicates when it's loading */
|
|
32
|
+
loading: requestControl.loading || pollingControl.isPooling,
|
|
33
|
+
/** Indicates error of pooling or request */
|
|
34
|
+
error: !!requestControl.error || !!pollingControl.failed,
|
|
35
|
+
/** Retries the operation based on the current failed step */
|
|
36
|
+
retry: requestControl.error ? triggerRequest : pollingControl.failed ? triggerPooling : undefined,
|
|
37
|
+
/** Initiates the request followed by the pooling operation */
|
|
38
|
+
start: function start(_requestOperation, _poolingOperation) {
|
|
39
|
+
requestOperation.current = _requestOperation;
|
|
40
|
+
poolingOperation.current = _poolingOperation;
|
|
41
|
+
triggerRequest();
|
|
42
|
+
},
|
|
43
|
+
/** Clear any error that is registered */
|
|
44
|
+
clearError: function clearError() {
|
|
45
|
+
requestControl.setError(undefined);
|
|
46
|
+
pollingControl.setFailed(false);
|
|
34
47
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
loading: requestControl.loading || pollingControl.isPooling,
|
|
38
|
-
/** Indicates error of pooling or request */
|
|
39
|
-
error: !!requestControl.error || !!pollingControl.failed,
|
|
40
|
-
/** Retries the operation based on the current failed step */
|
|
41
|
-
retry: requestControl.error
|
|
42
|
-
? triggerRequest
|
|
43
|
-
: pollingControl.failed
|
|
44
|
-
? triggerPooling
|
|
45
|
-
: undefined,
|
|
46
|
-
/** Initiates the request followed by the pooling operation */
|
|
47
|
-
start: (
|
|
48
|
-
/** An arbitrary request */
|
|
49
|
-
_requestOperation,
|
|
50
|
-
/** Resolves to a boolean that indicated if is finished (true) or not (false) */
|
|
51
|
-
_poolingOperation) => {
|
|
52
|
-
requestOperation.current = _requestOperation;
|
|
53
|
-
poolingOperation.current = _poolingOperation;
|
|
54
|
-
triggerRequest();
|
|
55
|
-
},
|
|
56
|
-
/** Clear any error that is registered */
|
|
57
|
-
clearError: () => {
|
|
58
|
-
requestControl.setError(undefined);
|
|
59
|
-
pollingControl.setFailed(false);
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
exports.default = usePooledOperation;
|
|
64
|
-
//# sourceMappingURL=usePooledOperation.js.map
|
|
48
|
+
};
|
|
49
|
+
}
|
package/dist/hooks/usePooling.js
CHANGED
|
@@ -1,50 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const react_1 = require("react");
|
|
13
|
-
function usePooling(intervalMs = 1000, maxPoolingTime = 60000) {
|
|
14
|
-
const [intervalId, setIntervalId] = (0, react_1.useState)();
|
|
15
|
-
const [failed, setFailed] = (0, react_1.useState)(false);
|
|
16
|
-
const cancelPooling = () => {
|
|
17
|
-
if (intervalId)
|
|
18
|
-
clearInterval(intervalId);
|
|
19
|
-
};
|
|
20
|
-
(0, react_1.useEffect)(() => cancelPooling, [intervalId]);
|
|
21
|
-
return {
|
|
22
|
-
failed,
|
|
23
|
-
setFailed,
|
|
24
|
-
isPooling: !!intervalId,
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @param cb {@link PoolingAction} - Executes and returns if has finished (true) or not (false)
|
|
28
|
-
*/
|
|
29
|
-
startPolling: (cb) => {
|
|
30
|
-
let poolingCount = 0;
|
|
31
|
-
const maxPoolings = (maxPoolingTime !== null) ? Math.ceil(maxPoolingTime / intervalMs) : undefined;
|
|
32
|
-
const intervalId = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
poolingCount++;
|
|
34
|
-
const finished = yield cb();
|
|
35
|
-
if (finished)
|
|
36
|
-
setIntervalId(undefined);
|
|
37
|
-
else if (poolingCount === maxPoolings) {
|
|
38
|
-
setIntervalId(undefined);
|
|
39
|
-
setFailed(true);
|
|
40
|
-
}
|
|
41
|
-
}), intervalMs);
|
|
42
|
-
setIntervalId(intervalId);
|
|
43
|
-
setFailed(false);
|
|
44
|
-
return () => clearInterval(intervalId);
|
|
45
|
-
},
|
|
46
|
-
stop: cancelPooling,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
49
6
|
exports.default = usePooling;
|
|
50
|
-
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
15
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
+
/**
|
|
17
|
+
* This callback should return a boolean that indicates if the pooling has finished (true) or it should continue (false)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function usePooling() {
|
|
21
|
+
let intervalMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
|
|
22
|
+
let maxPoolingTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 60000;
|
|
23
|
+
const _useState = (0, _react.useState)(),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
intervalId = _useState2[0],
|
|
26
|
+
setIntervalId = _useState2[1];
|
|
27
|
+
const _useState3 = (0, _react.useState)(false),
|
|
28
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
29
|
+
failed = _useState4[0],
|
|
30
|
+
setFailed = _useState4[1];
|
|
31
|
+
const cancelPooling = function cancelPooling() {
|
|
32
|
+
if (intervalId) clearInterval(intervalId);
|
|
33
|
+
};
|
|
34
|
+
(0, _react.useEffect)(function () {
|
|
35
|
+
return cancelPooling;
|
|
36
|
+
}, [intervalId]);
|
|
37
|
+
return {
|
|
38
|
+
failed: failed,
|
|
39
|
+
setFailed: setFailed,
|
|
40
|
+
isPooling: !!intervalId,
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param cb {@link PoolingAction} - Executes and returns if has finished (true) or not (false)
|
|
44
|
+
*/
|
|
45
|
+
startPolling: function startPolling(cb) {
|
|
46
|
+
let poolingCount = 0;
|
|
47
|
+
const maxPoolings = maxPoolingTime !== null ? Math.ceil(maxPoolingTime / intervalMs) : undefined;
|
|
48
|
+
const intervalId = setInterval( /*#__PURE__*/_asyncToGenerator(function* () {
|
|
49
|
+
poolingCount++;
|
|
50
|
+
const finished = yield cb();
|
|
51
|
+
if (finished) setIntervalId(undefined);else if (poolingCount === maxPoolings) {
|
|
52
|
+
setIntervalId(undefined);
|
|
53
|
+
setFailed(true);
|
|
54
|
+
}
|
|
55
|
+
}), intervalMs);
|
|
56
|
+
setIntervalId(intervalId);
|
|
57
|
+
setFailed(false);
|
|
58
|
+
return function () {
|
|
59
|
+
return clearInterval(intervalId);
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
stop: cancelPooling
|
|
63
|
+
};
|
|
64
|
+
}
|
package/dist/hooks/useRebound.js
CHANGED
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* state after a defined time (usefull for notification)
|
|
7
|
-
*/
|
|
8
|
-
function useRebound(initialValue, timeoutSec = 1) {
|
|
9
|
-
const [state, setState] = (0, react_1.useState)(initialValue);
|
|
10
|
-
(0, react_1.useEffect)(() => {
|
|
11
|
-
if (state !== initialValue) {
|
|
12
|
-
const timeout = setTimeout(() => {
|
|
13
|
-
setState(initialValue);
|
|
14
|
-
}, timeoutSec * 1000);
|
|
15
|
-
return () => clearTimeout(timeout);
|
|
16
|
-
}
|
|
17
|
-
}, [state]);
|
|
18
|
-
return {
|
|
19
|
-
current: state,
|
|
20
|
-
setState
|
|
21
|
-
};
|
|
22
|
-
}
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
23
6
|
exports.default = useRebound;
|
|
24
|
-
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
/**
|
|
15
|
+
* This hook adds a prop that you can toggle and returns to initial
|
|
16
|
+
* state after a defined time (usefull for notification)
|
|
17
|
+
*/
|
|
18
|
+
function useRebound(initialValue) {
|
|
19
|
+
let timeoutSec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
20
|
+
const _useState = (0, _react.useState)(initialValue),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
state = _useState2[0],
|
|
23
|
+
setState = _useState2[1];
|
|
24
|
+
(0, _react.useEffect)(function () {
|
|
25
|
+
if (state !== initialValue) {
|
|
26
|
+
const timeout = setTimeout(function () {
|
|
27
|
+
setState(initialValue);
|
|
28
|
+
}, timeoutSec * 1000);
|
|
29
|
+
return function () {
|
|
30
|
+
return clearTimeout(timeout);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}, [state]);
|
|
34
|
+
return {
|
|
35
|
+
current: state,
|
|
36
|
+
setState: setState
|
|
37
|
+
};
|
|
38
|
+
}
|