@onepercentio/one-ui 0.28.7 → 0.28.9
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/package.json +8 -5
- package/src/assets/img/svg/checkbox.svg +3 -0
- package/src/assets/styles/index.scss +2 -0
- package/src/assets/styles/mixins.scss +12 -0
- package/src/assets/styles/variables.scss +49 -0
- package/src/components/AdaptiveButton/AdaptiveButton.module.scss +7 -0
- package/src/components/AdaptiveButton/AdaptiveButton.tsx +26 -0
- package/src/components/AdaptiveButton/index.tsx +1 -0
- package/src/components/AdaptiveContainer/AdaptiveContainer.module.scss +53 -0
- package/src/components/AdaptiveContainer/AdaptiveContainer.tsx +200 -0
- package/src/components/AdaptiveContainer/index.tsx +1 -0
- package/src/components/AdaptiveDialog/AdaptiveDialog.module.scss +147 -0
- package/src/components/AdaptiveDialog/AdaptiveDialog.tsx +97 -0
- package/src/components/AdaptiveDialog/index.tsx +1 -0
- package/src/components/AdaptiveSidebar/AdaptiveSidebar.module.scss +49 -0
- package/src/components/AdaptiveSidebar/AdaptiveSidebar.sample.tsx +10 -0
- package/src/components/AdaptiveSidebar/AdaptiveSidebar.tsx +123 -0
- package/src/components/AdaptiveSidebar/index.tsx +1 -0
- package/src/components/AnchoredTooltip/AnchoredTooltip.module.scss +64 -0
- package/src/components/AnchoredTooltip/AnchoredTooltip.tsx +250 -0
- package/src/components/AnchoredTooltip/index.tsx +1 -0
- package/src/components/AnimatedEntrance/AnimatedEntrance.module.scss +108 -0
- package/src/components/AnimatedEntrance/AnimatedEntrance.tsx +227 -0
- package/src/components/AnimatedEntrance/index.tsx +5 -0
- package/src/components/AsyncWrapper/AsyncWrapper.tsx +38 -0
- package/src/components/AsyncWrapper/index.tsx +1 -0
- package/src/components/Avatar/Avatar.module.scss +22 -0
- package/src/components/Avatar/Avatar.tsx +31 -0
- package/src/components/Avatar/index.tsx +1 -0
- package/src/components/BucketFill/BucketFill.module.scss +36 -0
- package/src/components/BucketFill/BucketFill.tsx +65 -0
- package/src/components/BucketFill/index.tsx +1 -0
- package/src/components/Button/Button.module.scss +45 -0
- package/src/components/Button/Button.tsx +40 -0
- package/src/components/Button/index.tsx +1 -0
- package/src/components/Card/Card.module.scss +12 -0
- package/src/components/Card/Card.tsx +9 -0
- package/src/components/Card/index.tsx +1 -0
- package/src/components/Chart/Chart.e2e.ts +4 -0
- package/src/components/Chart/Chart.logic.tsx +8 -0
- package/src/components/Chart/Chart.module.scss +58 -0
- package/src/components/Chart/Chart.types.ts +35 -0
- package/src/components/Chart/Chart.view.tsx +240 -0
- package/src/components/Chart/index.tsx +1 -0
- package/src/components/CheckBox/CheckBox.module.scss +36 -0
- package/src/components/CheckBox/CheckBox.tsx +63 -0
- package/src/components/CheckBox/index.tsx +1 -0
- package/src/components/CodeInput/CodeInput.module.scss +5 -0
- package/src/components/CodeInput/CodeInput.tsx +84 -0
- package/src/components/CodeInput/index.tsx +1 -0
- package/src/components/Collapsable/Collapsable.module.scss +42 -0
- package/src/components/Collapsable/Collapsable.tsx +253 -0
- package/src/components/Collapsable/index.tsx +1 -0
- package/src/components/Countdown/Countdown.tsx +130 -0
- package/src/components/Countdown/index.tsx +1 -0
- package/src/components/CurrencyInput/CurrencyInput.hook.ts +37 -0
- package/src/components/CurrencyInput/CurrencyInput.tsx +25 -0
- package/src/components/CurrencyInput/index.tsx +1 -0
- package/src/components/Divider/Divider.module.scss +7 -0
- package/src/components/Divider/Divider.tsx +13 -0
- package/src/components/Divider/index.tsx +1 -0
- package/src/components/EmailInput/EmailInput.module.scss +0 -0
- package/src/components/EmailInput/EmailInput.tsx +51 -0
- package/src/components/EmailInput/index.tsx +1 -0
- package/src/components/FadeIn/FadeIn.module.scss +9 -0
- package/src/components/FadeIn/FadeIn.tsx +77 -0
- package/src/components/FadeIn/index.tsx +1 -0
- package/src/components/FileInput/FileInput.module.scss +6 -0
- package/src/components/FileInput/FileInput.tsx +75 -0
- package/src/components/FileInput/View/BigFactory/BigFactory.module.scss +20 -0
- package/src/components/FileInput/View/BigFactory/BigFactory.tsx +48 -0
- package/src/components/FileInput/View/BigFactory/index.tsx +1 -0
- package/src/components/FileInput/View/Compact/Compact.module.scss +68 -0
- package/src/components/FileInput/View/Compact/Compact.tsx +151 -0
- package/src/components/FileInput/View/Compact/index.tsx +1 -0
- package/src/components/FileInput/View/View.types.ts +12 -0
- package/src/components/FileInput/index.tsx +1 -0
- package/src/components/FlowController/FlowController.module.scss +47 -0
- package/src/components/FlowController/FlowController.tsx +93 -0
- package/src/components/FlowController/index.tsx +1 -0
- package/src/components/Form/Form.tsx +243 -0
- package/src/components/Form/index.ts +1 -0
- package/src/components/Form/v2/Form.hook.ts +341 -0
- package/src/components/Form/v2/Form.module.scss +0 -0
- package/src/components/Form/v2/Form.tsx +78 -0
- package/src/components/Form/v2/Form.types.ts +118 -0
- package/src/components/Form/v2/FormField/Extensions/DateField/DateField.module.scss +0 -0
- package/src/components/Form/v2/FormField/Extensions/DateField/DateField.tsx +73 -0
- package/src/components/Form/v2/FormField/Extensions/DateField/index.tsx +1 -0
- package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.module.scss +0 -0
- package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.tsx +91 -0
- package/src/components/Form/v2/FormField/Extensions/PhoneField/index.tsx +1 -0
- package/src/components/Form/v2/FormField/FormField.module.scss +0 -0
- package/src/components/Form/v2/FormField/FormField.tsx +378 -0
- package/src/components/Form/v2/FormField/FormField.types.ts +129 -0
- package/src/components/Form/v2/FormField/index.tsx +1 -0
- package/src/components/Form/v2/index.tsx +1 -0
- package/src/components/Freeze/Freeze.tsx +9 -0
- package/src/components/Freeze/index.tsx +1 -0
- package/src/components/HSForms/HSForms.tsx +57 -0
- package/src/components/HSForms/index.tsx +1 -0
- package/src/components/Header/Header.module.scss +119 -0
- package/src/components/Header/Header.tsx +138 -0
- package/src/components/Header/index.tsx +1 -0
- package/src/components/HeaderCloseBtn/HeaderCloseBtn.module.scss +44 -0
- package/src/components/HeaderCloseBtn/HeaderCloseBtn.tsx +28 -0
- package/src/components/HeaderCloseBtn/index.tsx +1 -0
- package/src/components/InfinityScroll/InfinityScroll.module.scss +30 -0
- package/src/components/InfinityScroll/InfinityScroll.tsx +187 -0
- package/src/components/InfinityScroll/index.tsx +1 -0
- package/src/components/Input/Input.module.scss +71 -0
- package/src/components/Input/Input.tsx +134 -0
- package/src/components/Input/index.tsx +1 -0
- package/src/components/InstantCounter/InstantCounter.tsx +77 -0
- package/src/components/InstantCounter/index.tsx +1 -0
- package/src/components/LavaLamp/LavaLamp.data.tsx +114 -0
- package/src/components/LavaLamp/LavaLamp.module.scss +26 -0
- package/src/components/LavaLamp/LavaLamp.tsx +131 -0
- package/src/components/LavaLamp/index.tsx +1 -0
- package/src/components/LavaLamp/v2/LavaLamp.module.scss +23 -0
- package/src/components/LavaLamp/v2/LavaLamp.tsx +197 -0
- package/src/components/LinkToId/LinkToId.module.scss +4 -0
- package/src/components/LinkToId/LinkToId.tsx +51 -0
- package/src/components/LinkToId/index.tsx +1 -0
- package/src/components/Loader/Loader.module.scss +40 -0
- package/src/components/Loader/Loader.tsx +18 -0
- package/src/components/Loader/index.tsx +1 -0
- package/src/components/LoaderDotsIndicator/LoaderDotsIndicator.tsx +34 -0
- package/src/components/LoaderDotsIndicator/index.tsx +1 -0
- package/src/components/LoopableVideo/LoopableVideo.tsx +37 -0
- package/src/components/LoopableVideo/index.tsx +1 -0
- package/src/components/MainGrid/MainGrid.module.scss +28 -0
- package/src/components/MainGrid/MainGrid.tsx +68 -0
- package/src/components/MainGrid/index.tsx +1 -0
- package/src/components/MutableHamburgerButton/MutableHamburgerButton.module.scss +220 -0
- package/src/components/MutableHamburgerButton/MutableHamburgerButton.tsx +38 -0
- package/src/components/MutableHamburgerButton/index.tsx +1 -0
- package/src/components/Notification/Notification.module.scss +25 -0
- package/src/components/Notification/Notification.tsx +13 -0
- package/src/components/Notification/index.tsx +1 -0
- package/src/components/OrderableList/OrderableList.module.scss +98 -0
- package/src/components/OrderableList/OrderableList.tsx +564 -0
- package/src/components/OrderableList/index.tsx +1 -0
- package/src/components/PaginationIndicator/PaginationIndicator.tsx +365 -0
- package/src/components/PaginationIndicator/index.tsx +1 -0
- package/src/components/Parallax/Parallax.module.scss +28 -0
- package/src/components/Parallax/Parallax.tsx +248 -0
- package/src/components/Parallax/index.tsx +1 -0
- package/src/components/Parallax/math/helpers.ts +289 -0
- package/src/components/PasswordInput/PasswordInput.module.scss +17 -0
- package/src/components/PasswordInput/PasswordInput.tsx +154 -0
- package/src/components/PasswordInput/index.tsx +1 -0
- package/src/components/PingPongText/PingPongText.module.scss +4 -0
- package/src/components/PingPongText/PingPongText.tsx +83 -0
- package/src/components/PingPongText/index.tsx +1 -0
- package/src/components/PixelatedScan/PixelatedScan.module.scss +86 -0
- package/src/components/PixelatedScan/PixelatedScan.tsx +175 -0
- package/src/components/PixelatedScan/index.tsx +1 -0
- package/src/components/Portal/Portal.module.scss +3 -0
- package/src/components/Portal/Portal.tsx +68 -0
- package/src/components/Portal/index.tsx +1 -0
- package/src/components/ProgressBar/ProgressBar.module.scss +44 -0
- package/src/components/ProgressBar/ProgressBar.tsx +124 -0
- package/src/components/ProgressBar/index.tsx +1 -0
- package/src/components/ProgressTexts/ProgressTexts.module.scss +37 -0
- package/src/components/ProgressTexts/ProgressTexts.tsx +85 -0
- package/src/components/ProgressTexts/index.tsx +1 -0
- package/src/components/Radio/Radio.module.scss +36 -0
- package/src/components/Radio/Radio.tsx +53 -0
- package/src/components/Radio/index.tsx +1 -0
- package/src/components/SectionContainer/SectionContainer.module.scss +30 -0
- package/src/components/SectionContainer/SectionContainer.tsx +49 -0
- package/src/components/SectionContainer/index.tsx +1 -0
- package/src/components/Select/Select.module.scss +58 -0
- package/src/components/Select/Select.tsx +192 -0
- package/src/components/Select/index.tsx +1 -0
- package/src/components/Skeleton/Skeleton.module.scss +21 -0
- package/src/components/Skeleton/Skeleton.tsx +29 -0
- package/src/components/Skeleton/index.tsx +1 -0
- package/src/components/Spacing/Spacing.module.scss +13 -0
- package/src/components/Spacing/Spacing.tsx +24 -0
- package/src/components/Spacing/index.tsx +1 -0
- package/src/components/StaticScroller/StaticScroller.module.scss +14 -0
- package/src/components/StaticScroller/StaticScroller.tsx +83 -0
- package/src/components/StaticScroller/index.tsx +1 -0
- package/src/components/Switch/Switch.module.scss +43 -0
- package/src/components/Switch/Switch.tsx +41 -0
- package/src/components/Switch/index.tsx +1 -0
- package/src/components/Table/Table.module.scss +76 -0
- package/src/components/Table/Table.tsx +152 -0
- package/src/components/Table/index.tsx +1 -0
- package/src/components/Tabs/Tabs.module.scss +40 -0
- package/src/components/Tabs/Tabs.tsx +104 -0
- package/src/components/Tabs/index.tsx +1 -0
- package/src/components/Text/Text.module.scss +81 -0
- package/src/components/Text/Text.tsx +42 -0
- package/src/components/Text/index.tsx +1 -0
- package/src/components/Transition/MasksFactory/DiagonalReveal.tsx +47 -0
- package/src/components/Transition/MasksFactory/DiagonalSquareToBalls.tsx +78 -0
- package/src/components/Transition/MasksFactory/PhysicsSquares.tsx +106 -0
- package/src/components/Transition/MasksFactory/SquareToBalls.tsx +66 -0
- package/src/components/Transition/MasksFactory/utils.ts +35 -0
- package/src/components/Transition/Transition.module.scss +211 -0
- package/src/components/Transition/Transition.tsx +495 -0
- package/src/components/Transition/index.tsx +1 -0
- package/src/components/UncontrolledTransition/UncontrolledTransition.ai.md +9 -0
- package/src/components/UncontrolledTransition/UncontrolledTransition.sample.tsx +34 -0
- package/src/components/UncontrolledTransition/UncontrolledTransition.tsx +143 -0
- package/src/components/UncontrolledTransition/index.tsx +2 -0
- package/src/components/WalletConnectionWrapper/WalletConnectionWrapper.tsx +212 -0
- package/src/components/WalletConnectionWrapper/index.tsx +1 -0
- package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.module.scss +5 -0
- package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.tsx +52 -0
- package/src/components/utilitary/ScrollAndFocusLock/index.tsx +1 -0
- package/src/context/AsyncProcess.tsx +107 -0
- package/src/context/ContextAsyncControl.tsx +89 -0
- package/src/context/CustomBrowserRouter.tsx +55 -0
- package/src/context/OneUIProvider.tsx +308 -0
- package/src/hooks/logs/useDependencyChangeDetection.ts +25 -0
- package/src/hooks/logs/useIsMounting.ts +7 -0
- package/src/hooks/persistence/useLocalStorage.ts +45 -0
- package/src/hooks/shims/ObjectWatchShim.ts +56 -0
- package/src/hooks/ui/useAdaptiveImage.tsx +36 -0
- package/src/hooks/ui/useAlternating.tsx +22 -0
- package/src/hooks/ui/useBreakpoint.tsx +21 -0
- package/src/hooks/ui/useCustomScrollbar.module.scss +20 -0
- package/src/hooks/ui/useCustomScrollbar.tsx +22 -0
- package/src/hooks/ui/useEffectIf.ts +11 -0
- package/src/hooks/ui/useMouseHover.tsx +26 -0
- package/src/hooks/ui/usePaginationControls.module.scss +16 -0
- package/src/hooks/ui/usePaginationControls.tsx +176 -0
- package/src/hooks/ui/useSnapToViewport.module.scss +6 -0
- package/src/hooks/ui/useSnapToViewport.ts +28 -0
- package/src/hooks/ui/useTilt.tsx +219 -0
- package/src/hooks/ui/useZoomable.module.scss +34 -0
- package/src/hooks/ui/useZoomable.tsx +144 -0
- package/src/hooks/useAsyncControl.ai.md +25 -0
- package/src/hooks/useAsyncControl.ts +101 -0
- package/src/hooks/useContainedRepositioning.ts +110 -0
- package/src/hooks/useCustomHistory.ts +14 -0
- package/src/hooks/useElementFit.ts +82 -0
- package/src/hooks/useFirestoreWatch.ts +54 -0
- package/src/hooks/useForm.ts +49 -0
- package/src/hooks/useFreeze.ts +12 -0
- package/src/hooks/useHero.module.scss +41 -0
- package/src/hooks/useHero.ts +512 -0
- package/src/hooks/useIntersection.ts +32 -0
- package/src/hooks/useMergeRefs.ts +29 -0
- package/src/hooks/useObserve.ts +24 -0
- package/src/hooks/usePagination.ts +228 -0
- package/src/hooks/usePooledOperation.ts +54 -0
- package/src/hooks/usePooling.ts +46 -0
- package/src/hooks/useRebound.ts +23 -0
- package/src/hooks/useShortIntl.ai.md +5 -0
- package/src/hooks/useShortIntl.ts +97 -0
- package/src/hooks/utility/useAsyncMemo.ts +43 -0
- package/src/hooks/utility/useDepChange.ts +11 -0
- package/src/hooks/utility/useEvents.ts +33 -0
- package/src/hooks/utility/useImmediate.ts +8 -0
- package/src/hooks/utility/useManualInit.ts +24 -0
- package/src/hooks/utility/useModule.ts +15 -0
- package/src/hooks/utility/useQuery.ts +15 -0
- package/src/hooks/utility/useUniqueEffect.ts +22 -0
- package/src/index.ts +3 -0
- package/src/models/DebugLogger.ts +7 -0
- package/src/models/GenericContract.ts +169 -0
- package/src/models/Orbs.ts +97 -0
- package/src/reac-app-env.d.ts +6 -0
- package/src/storybook/assets/video/txt-reversed.mp4 +0 -0
- package/src/storybookUtils/index.tsx +53 -0
- package/src/type-utils.ts +49 -0
- package/src/utility.d.ts +70 -0
- package/src/utils/blockchain.ts +43 -0
- package/src/utils/flatten.ts +17 -0
- package/src/utils/formatters.ts +36 -0
- package/src/utils/html.utils.ts +3 -0
- package/src/utils/ownEvent.ts +8 -0
- package/src/utils/test.ts +19 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
createRef,
|
|
3
|
+
ForwardedRef,
|
|
4
|
+
forwardRef,
|
|
5
|
+
MutableRefObject,
|
|
6
|
+
useEffect,
|
|
7
|
+
useLayoutEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from "react";
|
|
12
|
+
import Styles from "./InfinityScroll.module.scss";
|
|
13
|
+
|
|
14
|
+
export function shouldIncrementPage(
|
|
15
|
+
howMuchTheParentScrolled: number,
|
|
16
|
+
prevSectionPosition: number,
|
|
17
|
+
nextSectionPosition: number
|
|
18
|
+
): -1 | 0 | 1 {
|
|
19
|
+
if (howMuchTheParentScrolled === nextSectionPosition) return 1;
|
|
20
|
+
else if (howMuchTheParentScrolled === prevSectionPosition) return -1;
|
|
21
|
+
else return 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function keys(currPage: number) {
|
|
25
|
+
return [currPage % 3, (currPage + 1) % 3, (currPage + 2) % 3]
|
|
26
|
+
.map((a) => `step_${a}`)
|
|
27
|
+
.reverse();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getItemsFactory<T extends any>(
|
|
31
|
+
pageSize: number,
|
|
32
|
+
items: T[],
|
|
33
|
+
isCountTheSameOrLowerThanPage: boolean
|
|
34
|
+
) {
|
|
35
|
+
return function getItems(
|
|
36
|
+
page: number,
|
|
37
|
+
offset: number,
|
|
38
|
+
_pageSize: number = pageSize
|
|
39
|
+
) {
|
|
40
|
+
let from = page * _pageSize + offset;
|
|
41
|
+
if (from < 0) from = items.length + from;
|
|
42
|
+
if (from > items.length) from = from - items.length;
|
|
43
|
+
const to = from + _pageSize;
|
|
44
|
+
const slicedItems = items.slice(from, to);
|
|
45
|
+
|
|
46
|
+
if (slicedItems.length < _pageSize && !isCountTheSameOrLowerThanPage) {
|
|
47
|
+
slicedItems.push(...getItems(0, 0, _pageSize - slicedItems.length));
|
|
48
|
+
}
|
|
49
|
+
return slicedItems.map((i, index) =>
|
|
50
|
+
typeof i === "object"
|
|
51
|
+
? {
|
|
52
|
+
...i,
|
|
53
|
+
key: index,
|
|
54
|
+
}
|
|
55
|
+
: i
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function _InfinityScroll(
|
|
60
|
+
{
|
|
61
|
+
items,
|
|
62
|
+
pageSize,
|
|
63
|
+
initialPage = 0,
|
|
64
|
+
pageClass,
|
|
65
|
+
className = "",
|
|
66
|
+
}: {
|
|
67
|
+
items: (React.ReactElement | string)[];
|
|
68
|
+
pageSize: number;
|
|
69
|
+
initialPage?: number;
|
|
70
|
+
pageClass?: string;
|
|
71
|
+
className?: string;
|
|
72
|
+
},
|
|
73
|
+
ref: ForwardedRef<HTMLDivElement>
|
|
74
|
+
) {
|
|
75
|
+
const [currPage, setCurrPage] = useState({
|
|
76
|
+
page: initialPage,
|
|
77
|
+
offset: 0,
|
|
78
|
+
});
|
|
79
|
+
const parentDiv = useMemo(() => {
|
|
80
|
+
return (ref as MutableRefObject<HTMLDivElement | null>) || createRef();
|
|
81
|
+
}, [ref]);
|
|
82
|
+
const prevDiv = useRef<HTMLDivElement>(null);
|
|
83
|
+
const currDiv = useRef<HTMLDivElement>(null);
|
|
84
|
+
const nextDiv = useRef<HTMLDivElement>(null);
|
|
85
|
+
|
|
86
|
+
const isCountTheSameOrLowerThanPage = items.length <= pageSize;
|
|
87
|
+
|
|
88
|
+
const getItems = useMemo(
|
|
89
|
+
() => getItemsFactory(pageSize, items, isCountTheSameOrLowerThanPage),
|
|
90
|
+
[pageSize, items, isCountTheSameOrLowerThanPage]
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
useLayoutEffect(() => {
|
|
94
|
+
if (isCountTheSameOrLowerThanPage || (window as any).PRERENDER) return;
|
|
95
|
+
const viewportWidth = parentDiv.current!.clientWidth;
|
|
96
|
+
const centerScroll = parentDiv.current!.scrollWidth / 2;
|
|
97
|
+
parentDiv.current!.scrollTo({
|
|
98
|
+
left: centerScroll - viewportWidth / 2,
|
|
99
|
+
});
|
|
100
|
+
}, [isCountTheSameOrLowerThanPage, currPage.page, currPage.offset, items]);
|
|
101
|
+
const [beforeKey, currKey, afterKey] = keys(currPage.page);
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div
|
|
105
|
+
ref={parentDiv}
|
|
106
|
+
className={`${Styles.container} ${className}`}
|
|
107
|
+
data-testid={InfinityDataTestId.ROOT}
|
|
108
|
+
onScroll={
|
|
109
|
+
!isCountTheSameOrLowerThanPage
|
|
110
|
+
? () => {
|
|
111
|
+
const pageToIncrement = shouldIncrementPage(
|
|
112
|
+
Math.round(parentDiv.current!.scrollLeft),
|
|
113
|
+
prevDiv.current!.offsetLeft,
|
|
114
|
+
nextDiv.current!.offsetLeft
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
if (pageToIncrement) {
|
|
118
|
+
setCurrPage((prev) => {
|
|
119
|
+
let nextPage = prev.page + pageToIncrement;
|
|
120
|
+
let offset = prev.offset;
|
|
121
|
+
if (nextPage < 0) {
|
|
122
|
+
nextPage = Math.round(items.length / pageSize) - 1;
|
|
123
|
+
const finalIndex = (nextPage + 1) * pageSize + offset;
|
|
124
|
+
const maxIndex = items.length;
|
|
125
|
+
const remainingItems = maxIndex + offset - finalIndex;
|
|
126
|
+
offset += remainingItems;
|
|
127
|
+
if (offset === -(items.length - 1)) offset = 1;
|
|
128
|
+
}
|
|
129
|
+
let nextIndex = nextPage * pageSize + offset;
|
|
130
|
+
if (nextIndex > items.length) {
|
|
131
|
+
offset = nextIndex - items.length;
|
|
132
|
+
nextPage = 0;
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
page: nextPage,
|
|
136
|
+
offset,
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
: undefined
|
|
142
|
+
}
|
|
143
|
+
>
|
|
144
|
+
{!isCountTheSameOrLowerThanPage && (
|
|
145
|
+
<div
|
|
146
|
+
key={beforeKey}
|
|
147
|
+
className={pageClass}
|
|
148
|
+
data-testid={InfinityDataTestId.PREV_PAGE}
|
|
149
|
+
ref={prevDiv}
|
|
150
|
+
>
|
|
151
|
+
{getItems(currPage.page - 1, currPage.offset)}
|
|
152
|
+
</div>
|
|
153
|
+
)}
|
|
154
|
+
<div
|
|
155
|
+
key={currKey}
|
|
156
|
+
className={pageClass}
|
|
157
|
+
data-testid={InfinityDataTestId.CURR_PAGE}
|
|
158
|
+
ref={currDiv}
|
|
159
|
+
>
|
|
160
|
+
{getItems(currPage.page, currPage.offset)}
|
|
161
|
+
</div>
|
|
162
|
+
{!isCountTheSameOrLowerThanPage && (
|
|
163
|
+
<div
|
|
164
|
+
key={afterKey}
|
|
165
|
+
className={pageClass}
|
|
166
|
+
data-testid={InfinityDataTestId.NEXT_PAGE}
|
|
167
|
+
ref={nextDiv}
|
|
168
|
+
>
|
|
169
|
+
{getItems(currPage.page + 1, currPage.offset)}
|
|
170
|
+
</div>
|
|
171
|
+
)}
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Manages a set of divs that allows the effect of inifinite scrolling between elements
|
|
178
|
+
**/
|
|
179
|
+
const InfinityScroll = forwardRef(_InfinityScroll);
|
|
180
|
+
export default InfinityScroll;
|
|
181
|
+
|
|
182
|
+
export enum InfinityDataTestId {
|
|
183
|
+
PREV_PAGE = "infinity-prev",
|
|
184
|
+
CURR_PAGE = "infinity-curr",
|
|
185
|
+
NEXT_PAGE = "infinity-next",
|
|
186
|
+
ROOT = "infinity-parent",
|
|
187
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './InfinityScroll';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
@import "../../assets/styles/index.scss";
|
|
2
|
+
|
|
3
|
+
.inputContainer {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: flex;
|
|
6
|
+
font-size: 22px;
|
|
7
|
+
line-height: 33px;
|
|
8
|
+
.icon {
|
|
9
|
+
position: absolute;
|
|
10
|
+
top: 1.5px;
|
|
11
|
+
right: 1.5px;
|
|
12
|
+
min-height: 30px;
|
|
13
|
+
min-width: 30px;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
user-select: none;
|
|
16
|
+
&img {
|
|
17
|
+
height: 30px;
|
|
18
|
+
width: 30px;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
&.withIcon {
|
|
22
|
+
padding-right: 33px;
|
|
23
|
+
}
|
|
24
|
+
input,
|
|
25
|
+
textarea {
|
|
26
|
+
border: none;
|
|
27
|
+
background-color: transparent;
|
|
28
|
+
width: 100%;
|
|
29
|
+
font-size: inherit;
|
|
30
|
+
line-height: inherit;
|
|
31
|
+
font-family: $mainFontFamily;
|
|
32
|
+
color: var(--input-text-color, $spaceBlue);
|
|
33
|
+
margin-bottom: 18px;
|
|
34
|
+
outline: none;
|
|
35
|
+
&:placeholder-shown ~ .border {
|
|
36
|
+
animation-iteration-count: infinite;
|
|
37
|
+
animation-duration: $verySlow;
|
|
38
|
+
animation-name: pulse;
|
|
39
|
+
animation-delay: $slow;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
& .border {
|
|
43
|
+
position: absolute;
|
|
44
|
+
left: 0px;
|
|
45
|
+
right: 0px;
|
|
46
|
+
bottom: 18px;
|
|
47
|
+
height: 1px;
|
|
48
|
+
background-color: $spaceBlue;
|
|
49
|
+
opacity: 0;
|
|
50
|
+
}
|
|
51
|
+
.caption {
|
|
52
|
+
position: absolute;
|
|
53
|
+
bottom: 0px;
|
|
54
|
+
white-space: nowrap;
|
|
55
|
+
text-overflow: ellipsis;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
max-width: 100%;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@keyframes pulse {
|
|
62
|
+
0% {
|
|
63
|
+
opacity: 0;
|
|
64
|
+
}
|
|
65
|
+
50% {
|
|
66
|
+
opacity: 0.1;
|
|
67
|
+
}
|
|
68
|
+
100% {
|
|
69
|
+
opacity: 0;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
ChangeEventHandler,
|
|
3
|
+
DetailedHTMLProps,
|
|
4
|
+
ForwardedRef,
|
|
5
|
+
forwardRef,
|
|
6
|
+
ReactElement,
|
|
7
|
+
useEffect,
|
|
8
|
+
useImperativeHandle,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
} from "react";
|
|
13
|
+
import { useOneUIConfig } from "../../context/OneUIProvider";
|
|
14
|
+
import Text from "../Text";
|
|
15
|
+
import Styles from "./Input.module.scss";
|
|
16
|
+
|
|
17
|
+
export type InputProps = {
|
|
18
|
+
decoration?: React.ReactElement | null;
|
|
19
|
+
error?: string | ReactElement;
|
|
20
|
+
hideError?: "onfocus";
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
disclaimer?: string | ReactElement;
|
|
23
|
+
multiline?: number;
|
|
24
|
+
border?: boolean;
|
|
25
|
+
icon?: {
|
|
26
|
+
onClick?: () => void;
|
|
27
|
+
} & DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, any>;
|
|
28
|
+
Icon?: React.ReactElement;
|
|
29
|
+
onChange?: ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
30
|
+
containerProps?: Omit<React.HTMLProps<HTMLDivElement>, "ref">;
|
|
31
|
+
value?: string;
|
|
32
|
+
'data-testid'?: string;
|
|
33
|
+
} & Omit<
|
|
34
|
+
React.HTMLProps<HTMLInputElement | HTMLTextAreaElement>,
|
|
35
|
+
"ref" | "onChange" | 'value'
|
|
36
|
+
>;
|
|
37
|
+
function _Input(
|
|
38
|
+
{
|
|
39
|
+
error,
|
|
40
|
+
placeholder = " ",
|
|
41
|
+
hideError,
|
|
42
|
+
icon,
|
|
43
|
+
Icon,
|
|
44
|
+
autoFocus,
|
|
45
|
+
disclaimer,
|
|
46
|
+
multiline,
|
|
47
|
+
decoration = null,
|
|
48
|
+
border: propBorder,
|
|
49
|
+
containerProps,
|
|
50
|
+
className: localClassName,
|
|
51
|
+
...otherProps
|
|
52
|
+
}: InputProps,
|
|
53
|
+
ref: ForwardedRef<any>
|
|
54
|
+
) {
|
|
55
|
+
const className = useOneUIConfig("component.input.className");
|
|
56
|
+
const globalBorder = useOneUIConfig("component.input.border");
|
|
57
|
+
const [focused, setFocused] = useState(false);
|
|
58
|
+
const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null);
|
|
59
|
+
useImperativeHandle(ref, () => inputRef.current, []);
|
|
60
|
+
const shouldShowError = useMemo(() => {
|
|
61
|
+
if (hideError === "onfocus") return !focused;
|
|
62
|
+
return !!error;
|
|
63
|
+
}, [focused, error, hideError]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (autoFocus) {
|
|
66
|
+
const t = setTimeout(() => {
|
|
67
|
+
inputRef.current!.focus();
|
|
68
|
+
}, 500);
|
|
69
|
+
return () => clearTimeout(t);
|
|
70
|
+
}
|
|
71
|
+
}, [autoFocus]);
|
|
72
|
+
const Component = multiline ? "textarea" : "input";
|
|
73
|
+
const withBorder = useMemo(() => {
|
|
74
|
+
if (propBorder !== undefined) return propBorder;
|
|
75
|
+
return globalBorder;
|
|
76
|
+
}, [propBorder, globalBorder]);
|
|
77
|
+
return (
|
|
78
|
+
<div
|
|
79
|
+
className={`${Styles.inputContainer} ${
|
|
80
|
+
false ? Styles.withIcon : ""
|
|
81
|
+
} ${className} ${localClassName}`}
|
|
82
|
+
{...containerProps}
|
|
83
|
+
>
|
|
84
|
+
{decoration}
|
|
85
|
+
<Component
|
|
86
|
+
ref={inputRef as any}
|
|
87
|
+
placeholder={placeholder}
|
|
88
|
+
rows={multiline}
|
|
89
|
+
{...otherProps}
|
|
90
|
+
onFocus={(e) => {
|
|
91
|
+
setFocused(true);
|
|
92
|
+
if (otherProps.onFocus) otherProps.onFocus(e);
|
|
93
|
+
}}
|
|
94
|
+
onBlur={(e) => {
|
|
95
|
+
setFocused(false);
|
|
96
|
+
if (otherProps.onBlur) otherProps.onBlur(e);
|
|
97
|
+
}}
|
|
98
|
+
/>
|
|
99
|
+
{withBorder && <div className={Styles.border} />}
|
|
100
|
+
{error && shouldShowError ? (
|
|
101
|
+
<Text
|
|
102
|
+
title={typeof error === "string" ? error : ""}
|
|
103
|
+
data-testid={InputTestIds.ERROR}
|
|
104
|
+
className={Styles.caption}
|
|
105
|
+
type="error"
|
|
106
|
+
>
|
|
107
|
+
{error}
|
|
108
|
+
</Text>
|
|
109
|
+
) : disclaimer ? (
|
|
110
|
+
<Text
|
|
111
|
+
title={typeof disclaimer === "string" ? disclaimer : ""}
|
|
112
|
+
type="caption"
|
|
113
|
+
className={Styles.caption}
|
|
114
|
+
data-testid={InputTestIds.DISCLAIMER}
|
|
115
|
+
>
|
|
116
|
+
{disclaimer}
|
|
117
|
+
</Text>
|
|
118
|
+
) : null}
|
|
119
|
+
{Icon && <div className={Styles.icon}>{Icon}</div>}
|
|
120
|
+
{icon && <img className={Styles.icon} {...icon} />}
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export enum InputTestIds {
|
|
126
|
+
DISCLAIMER = "disclaimer",
|
|
127
|
+
ERROR = "error",
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A transparent input with some prebuilt states common to the application
|
|
132
|
+
**/
|
|
133
|
+
const Input = forwardRef(_Input);
|
|
134
|
+
export default Input;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Input';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
ForwardedRef,
|
|
3
|
+
forwardRef,
|
|
4
|
+
useEffect,
|
|
5
|
+
useImperativeHandle,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from "react";
|
|
9
|
+
import { FormatNumberOptions, useIntl } from "react-intl";
|
|
10
|
+
|
|
11
|
+
function _InstantCounter(
|
|
12
|
+
{
|
|
13
|
+
from = 0,
|
|
14
|
+
to,
|
|
15
|
+
framesPerSecond = 30,
|
|
16
|
+
durationInSeconds,
|
|
17
|
+
formatOptions = {},
|
|
18
|
+
autoStart = true,
|
|
19
|
+
}: {
|
|
20
|
+
from?: number;
|
|
21
|
+
to: number;
|
|
22
|
+
framesPerSecond?: number; //Usefull for testing
|
|
23
|
+
durationInSeconds: number;
|
|
24
|
+
formatOptions?: FormatNumberOptions;
|
|
25
|
+
autoStart?: boolean;
|
|
26
|
+
},
|
|
27
|
+
ref: ForwardedRef<{ start: () => void }>
|
|
28
|
+
) {
|
|
29
|
+
const [started, setStarted] = useState(autoStart);
|
|
30
|
+
const initialValue = useRef<number>(from);
|
|
31
|
+
const spanRef = useRef<HTMLSpanElement>(null);
|
|
32
|
+
const { formatNumber } = useIntl();
|
|
33
|
+
|
|
34
|
+
useImperativeHandle(
|
|
35
|
+
ref,
|
|
36
|
+
() => ({
|
|
37
|
+
start: () => setStarted(true),
|
|
38
|
+
}),
|
|
39
|
+
[]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (started) {
|
|
44
|
+
const incrementBy =
|
|
45
|
+
(to - initialValue.current) / (framesPerSecond * durationInSeconds);
|
|
46
|
+
spanRef.current!.innerHTML = formatNumber(
|
|
47
|
+
initialValue.current!,
|
|
48
|
+
formatOptions
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const intervalId = setInterval(() => {
|
|
52
|
+
initialValue.current! += incrementBy;
|
|
53
|
+
spanRef.current!.innerHTML = formatNumber(
|
|
54
|
+
initialValue.current!,
|
|
55
|
+
formatOptions
|
|
56
|
+
);
|
|
57
|
+
if (Math.round(initialValue.current) === Math.round(to)) {
|
|
58
|
+
clearInterval(intervalId);
|
|
59
|
+
}
|
|
60
|
+
}, 1000 / framesPerSecond);
|
|
61
|
+
return () => {
|
|
62
|
+
clearInterval(intervalId);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}, [started, to]);
|
|
66
|
+
return (
|
|
67
|
+
<>
|
|
68
|
+
<span ref={spanRef} />
|
|
69
|
+
</>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Increments the numbers from 0 to the provided value
|
|
75
|
+
**/
|
|
76
|
+
const InstantCounter = forwardRef(_InstantCounter);
|
|
77
|
+
export default InstantCounter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './InstantCounter';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { throttle as t } from "lodash";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { useTiltUpdates } from "../../hooks/ui/useTilt";
|
|
4
|
+
import Styles from "./LavaLamp.module.scss";
|
|
5
|
+
|
|
6
|
+
const transitionMs = Number(Styles.transitionMs);
|
|
7
|
+
export const transitionPositionMs = Number(Styles.transitionPositionMs);
|
|
8
|
+
|
|
9
|
+
export default function useLavaLampSetup(
|
|
10
|
+
onUpdatePosition: (x: number, y: number) => void,
|
|
11
|
+
onUpdateSize: (size: number) => void
|
|
12
|
+
) {
|
|
13
|
+
const [d, setDim] = useState<{ width: number; height: number }>();
|
|
14
|
+
const relativeTo = useRef<HTMLDivElement>(null);
|
|
15
|
+
|
|
16
|
+
const prevTilt = useRef<{ x: number; y: number }>(undefined);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const baseWidth = Math.min(relativeTo.current!.clientWidth, 1440);
|
|
20
|
+
setDim({
|
|
21
|
+
width: baseWidth,
|
|
22
|
+
height:
|
|
23
|
+
baseWidth *
|
|
24
|
+
(relativeTo.current!.clientHeight / relativeTo.current!.clientWidth),
|
|
25
|
+
});
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
const updateTiltCb = useMemo(() => {
|
|
29
|
+
const throttlePosition = t;
|
|
30
|
+
if (!d) return () => {};
|
|
31
|
+
const baseSize = Math.min(d.width, d.height) * 0.1;
|
|
32
|
+
let acceleration = t(
|
|
33
|
+
(currTilt: { x: number; y: number }) => {
|
|
34
|
+
if (!prevTilt.current) {
|
|
35
|
+
prevTilt.current = currTilt;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const diff = {
|
|
40
|
+
x: Math.abs(prevTilt.current.x - currTilt.x),
|
|
41
|
+
y: Math.abs(prevTilt.current.y - currTilt.y),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const baseDiff = Math.max(diff.x, diff.y);
|
|
45
|
+
const percent = (baseDiff * 100) / 90;
|
|
46
|
+
|
|
47
|
+
onUpdateSize(baseSize + baseSize * (percent / 100));
|
|
48
|
+
|
|
49
|
+
prevTilt.current = currTilt!;
|
|
50
|
+
},
|
|
51
|
+
transitionMs,
|
|
52
|
+
{
|
|
53
|
+
leading: false,
|
|
54
|
+
trailing: true,
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
let movement = throttlePosition(
|
|
58
|
+
(currTilt: { x: number; y: number }) => {
|
|
59
|
+
const [x, y] = [currTilt.x + 100, currTilt.y + 100];
|
|
60
|
+
const [cx, cy] = [(d!.width * x) / 200, (d!.height * y) / 200];
|
|
61
|
+
onUpdatePosition(cx, cy);
|
|
62
|
+
},
|
|
63
|
+
transitionPositionMs,
|
|
64
|
+
{
|
|
65
|
+
leading: false,
|
|
66
|
+
trailing: true,
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
return (tilt: NonNullable<typeof prevTilt.current>) => {
|
|
70
|
+
if (!d) return;
|
|
71
|
+
acceleration(tilt);
|
|
72
|
+
movement(tilt);
|
|
73
|
+
};
|
|
74
|
+
}, [d]);
|
|
75
|
+
useTiltUpdates(
|
|
76
|
+
true,
|
|
77
|
+
relativeTo,
|
|
78
|
+
updateTiltCb,
|
|
79
|
+
undefined,
|
|
80
|
+
undefined,
|
|
81
|
+
undefined,
|
|
82
|
+
{
|
|
83
|
+
round: false,
|
|
84
|
+
gyroEnabled: false,
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
const circlesConfig = useMemo(() => {
|
|
88
|
+
if (!d) return [];
|
|
89
|
+
const baseSize = Math.min(d.width, d.height) * 0.15;
|
|
90
|
+
return new Array(10).fill(undefined).map((_, i) => {
|
|
91
|
+
const mod = i % 2;
|
|
92
|
+
const startX =
|
|
93
|
+
Math.random() * d.width * 0.5 + (mod === 0 ? 0 : d.width * 0.5);
|
|
94
|
+
const translateX = startX - (startX + 50 + Math.random() * 200);
|
|
95
|
+
const startY =
|
|
96
|
+
Math.random() * d.height * 0.75 + (mod === 0 ? 0 : d.height * 0.25);
|
|
97
|
+
const translateY = startY - (startY + 50 + Math.random() * 200);
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
baseSize,
|
|
101
|
+
startX,
|
|
102
|
+
startY,
|
|
103
|
+
translateX,
|
|
104
|
+
translateY,
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
}, [d]);
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
relativeTo,
|
|
111
|
+
d,
|
|
112
|
+
circlesConfig,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
@use 'sass:math';
|
|
2
|
+
|
|
3
|
+
$transitionMs: math.div(1000, 5);
|
|
4
|
+
$transitionPositionMs: math.div($transitionMs, 2);
|
|
5
|
+
@value transitionMs #{$transitionMs};
|
|
6
|
+
@value transitionPositionMs #{$transitionPositionMs};
|
|
7
|
+
|
|
8
|
+
.root {
|
|
9
|
+
position: relative;
|
|
10
|
+
svg.effect {
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 0;
|
|
13
|
+
left: 0;
|
|
14
|
+
bottom: 0;
|
|
15
|
+
right: 0;
|
|
16
|
+
circle {
|
|
17
|
+
will-change: r, cx, cy;
|
|
18
|
+
transition: r #{$transitionMs}ms linear,
|
|
19
|
+
cx #{$transitionPositionMs}ms linear,
|
|
20
|
+
cy #{$transitionPositionMs}ms linear;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
> div {
|
|
24
|
+
z-index: 1;
|
|
25
|
+
}
|
|
26
|
+
}
|