@onepercentio/one-ui 0.29.4 → 0.29.6
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/dist/components/Portal/Portal.d.ts +5 -0
- package/dist/components/Portal/Portal.js +6 -1
- package/dist/components/Switch/Switch.d.ts +1 -1
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/utils/e2e.d.ts +1 -1
- package/dist/utils/e2e.js +1 -1
- package/dist-ts/components/Portal/Portal.d.ts +5 -0
- package/dist-ts/components/Portal/Portal.js +5 -0
- package/dist-ts/components/Portal/Portal.js.map +1 -1
- package/dist-ts/components/Switch/Switch.d.ts +1 -1
- package/dist-ts/utils/e2e.d.ts +1 -1
- package/package.json +1 -1
- package/src/assets/img/svg/checkbox.svg +0 -3
- package/src/assets/styles/index.scss +0 -2
- package/src/assets/styles/mixins.scss +0 -12
- package/src/assets/styles/variables.scss +0 -49
- package/src/components/AdaptiveButton/AdaptiveButton.module.scss +0 -7
- package/src/components/AdaptiveButton/AdaptiveButton.tsx +0 -26
- package/src/components/AdaptiveButton/index.tsx +0 -2
- package/src/components/AdaptiveContainer/AdaptiveContainer.module.scss +0 -53
- package/src/components/AdaptiveContainer/AdaptiveContainer.tsx +0 -200
- package/src/components/AdaptiveContainer/index.tsx +0 -2
- package/src/components/AdaptiveDialog/AdaptiveDialog.module.scss +0 -147
- package/src/components/AdaptiveDialog/AdaptiveDialog.tsx +0 -97
- package/src/components/AdaptiveDialog/index.tsx +0 -2
- package/src/components/AdaptiveSidebar/AdaptiveSidebar.module.scss +0 -49
- package/src/components/AdaptiveSidebar/AdaptiveSidebar.sample.tsx +0 -10
- package/src/components/AdaptiveSidebar/AdaptiveSidebar.tsx +0 -123
- package/src/components/AdaptiveSidebar/index.tsx +0 -2
- package/src/components/AnchoredTooltip/AnchoredTooltip.module.scss +0 -64
- package/src/components/AnchoredTooltip/AnchoredTooltip.tsx +0 -250
- package/src/components/AnchoredTooltip/index.tsx +0 -2
- package/src/components/AnimatedEntrance/AnimatedEntrance.module.scss +0 -108
- package/src/components/AnimatedEntrance/AnimatedEntrance.tsx +0 -227
- package/src/components/AnimatedEntrance/index.tsx +0 -2
- package/src/components/AsyncWrapper/AsyncWrapper.tsx +0 -38
- package/src/components/AsyncWrapper/index.tsx +0 -2
- package/src/components/Avatar/Avatar.module.scss +0 -22
- package/src/components/Avatar/Avatar.tsx +0 -31
- package/src/components/Avatar/index.tsx +0 -2
- package/src/components/BucketFill/BucketFill.module.scss +0 -36
- package/src/components/BucketFill/BucketFill.tsx +0 -65
- package/src/components/BucketFill/index.tsx +0 -2
- package/src/components/Button/Button.module.scss +0 -45
- package/src/components/Button/Button.tsx +0 -40
- package/src/components/Button/index.tsx +0 -2
- package/src/components/Card/Card.module.scss +0 -12
- package/src/components/Card/Card.tsx +0 -9
- package/src/components/Card/index.tsx +0 -2
- package/src/components/Chart/Chart.e2e.ts +0 -4
- package/src/components/Chart/Chart.logic.tsx +0 -8
- package/src/components/Chart/Chart.module.scss +0 -58
- package/src/components/Chart/Chart.tsx +0 -2
- package/src/components/Chart/Chart.types.ts +0 -35
- package/src/components/Chart/Chart.view.tsx +0 -241
- package/src/components/Chart/index.tsx +0 -2
- package/src/components/CheckBox/CheckBox.module.scss +0 -36
- package/src/components/CheckBox/CheckBox.tsx +0 -63
- package/src/components/CheckBox/index.tsx +0 -2
- package/src/components/CodeInput/CodeInput.module.scss +0 -5
- package/src/components/CodeInput/CodeInput.tsx +0 -84
- package/src/components/CodeInput/index.tsx +0 -2
- package/src/components/Collapsable/Collapsable.module.scss +0 -42
- package/src/components/Collapsable/Collapsable.tsx +0 -253
- package/src/components/Collapsable/index.tsx +0 -2
- package/src/components/Countdown/Countdown.tsx +0 -130
- package/src/components/Countdown/index.tsx +0 -2
- package/src/components/CurrencyInput/CurrencyInput.hook.ts +0 -37
- package/src/components/CurrencyInput/CurrencyInput.tsx +0 -25
- package/src/components/CurrencyInput/index.tsx +0 -2
- package/src/components/Divider/Divider.module.scss +0 -7
- package/src/components/Divider/Divider.tsx +0 -13
- package/src/components/Divider/index.tsx +0 -2
- package/src/components/EmailInput/EmailInput.module.scss +0 -0
- package/src/components/EmailInput/EmailInput.tsx +0 -51
- package/src/components/EmailInput/index.tsx +0 -2
- package/src/components/FadeIn/FadeIn.module.scss +0 -9
- package/src/components/FadeIn/FadeIn.tsx +0 -77
- package/src/components/FadeIn/index.tsx +0 -2
- package/src/components/FileInput/FileInput.module.scss +0 -6
- package/src/components/FileInput/FileInput.tsx +0 -75
- package/src/components/FileInput/View/BigFactory/BigFactory.module.scss +0 -20
- package/src/components/FileInput/View/BigFactory/BigFactory.tsx +0 -48
- package/src/components/FileInput/View/BigFactory/index.tsx +0 -2
- package/src/components/FileInput/View/Compact/Compact.module.scss +0 -68
- package/src/components/FileInput/View/Compact/Compact.tsx +0 -151
- package/src/components/FileInput/View/Compact/index.tsx +0 -2
- package/src/components/FileInput/View/View.types.ts +0 -12
- package/src/components/FileInput/index.tsx +0 -2
- package/src/components/FlowController/FlowController.module.scss +0 -47
- package/src/components/FlowController/FlowController.tsx +0 -93
- package/src/components/FlowController/index.tsx +0 -2
- package/src/components/Form/Form.tsx +0 -243
- package/src/components/Form/index.ts +0 -2
- package/src/components/Form/v2/Form.hook.ts +0 -341
- package/src/components/Form/v2/Form.module.scss +0 -0
- package/src/components/Form/v2/Form.tsx +0 -78
- package/src/components/Form/v2/Form.types.ts +0 -118
- package/src/components/Form/v2/FormField/Extensions/DateField/DateField.module.scss +0 -0
- package/src/components/Form/v2/FormField/Extensions/DateField/DateField.tsx +0 -73
- package/src/components/Form/v2/FormField/Extensions/DateField/index.tsx +0 -2
- package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.module.scss +0 -0
- package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.tsx +0 -91
- package/src/components/Form/v2/FormField/Extensions/PhoneField/index.tsx +0 -2
- package/src/components/Form/v2/FormField/FormField.module.scss +0 -0
- package/src/components/Form/v2/FormField/FormField.tsx +0 -378
- package/src/components/Form/v2/FormField/FormField.types.ts +0 -129
- package/src/components/Form/v2/FormField/index.tsx +0 -2
- package/src/components/Form/v2/index.tsx +0 -2
- package/src/components/Freeze/Freeze.tsx +0 -9
- package/src/components/Freeze/index.tsx +0 -2
- package/src/components/HSForms/HSForms.tsx +0 -57
- package/src/components/HSForms/index.tsx +0 -2
- package/src/components/Header/Header.module.scss +0 -119
- package/src/components/Header/Header.tsx +0 -138
- package/src/components/Header/index.tsx +0 -2
- package/src/components/HeaderCloseBtn/HeaderCloseBtn.module.scss +0 -44
- package/src/components/HeaderCloseBtn/HeaderCloseBtn.tsx +0 -28
- package/src/components/HeaderCloseBtn/index.tsx +0 -2
- package/src/components/InfinityScroll/InfinityScroll.module.scss +0 -30
- package/src/components/InfinityScroll/InfinityScroll.tsx +0 -187
- package/src/components/InfinityScroll/index.tsx +0 -2
- package/src/components/Input/Input.module.scss +0 -71
- package/src/components/Input/Input.tsx +0 -134
- package/src/components/Input/index.tsx +0 -2
- package/src/components/InstantCounter/InstantCounter.tsx +0 -77
- package/src/components/InstantCounter/index.tsx +0 -2
- package/src/components/LavaLamp/LavaLamp.data.tsx +0 -114
- package/src/components/LavaLamp/LavaLamp.module.scss +0 -26
- package/src/components/LavaLamp/LavaLamp.tsx +0 -131
- package/src/components/LavaLamp/index.tsx +0 -2
- package/src/components/LavaLamp/v2/LavaLamp.module.scss +0 -23
- package/src/components/LavaLamp/v2/LavaLamp.tsx +0 -197
- package/src/components/LinkToId/LinkToId.module.scss +0 -4
- package/src/components/LinkToId/LinkToId.tsx +0 -51
- package/src/components/LinkToId/index.tsx +0 -2
- package/src/components/Loader/Loader.module.scss +0 -40
- package/src/components/Loader/Loader.tsx +0 -18
- package/src/components/Loader/index.tsx +0 -2
- package/src/components/LoaderDotsIndicator/LoaderDotsIndicator.tsx +0 -34
- package/src/components/LoaderDotsIndicator/index.tsx +0 -2
- package/src/components/LoopableVideo/LoopableVideo.tsx +0 -37
- package/src/components/LoopableVideo/index.tsx +0 -2
- package/src/components/MainGrid/MainGrid.module.scss +0 -28
- package/src/components/MainGrid/MainGrid.tsx +0 -68
- package/src/components/MainGrid/index.tsx +0 -2
- package/src/components/MutableHamburgerButton/MutableHamburgerButton.module.scss +0 -220
- package/src/components/MutableHamburgerButton/MutableHamburgerButton.tsx +0 -38
- package/src/components/MutableHamburgerButton/index.tsx +0 -2
- package/src/components/Notification/Notification.module.scss +0 -25
- package/src/components/Notification/Notification.tsx +0 -13
- package/src/components/Notification/index.tsx +0 -2
- package/src/components/OrderableList/OrderableList.module.scss +0 -98
- package/src/components/OrderableList/OrderableList.tsx +0 -564
- package/src/components/OrderableList/index.tsx +0 -2
- package/src/components/PaginationIndicator/PaginationIndicator.tsx +0 -365
- package/src/components/PaginationIndicator/index.tsx +0 -2
- package/src/components/Parallax/Parallax.module.scss +0 -28
- package/src/components/Parallax/Parallax.tsx +0 -225
- package/src/components/Parallax/index.tsx +0 -2
- package/src/components/Parallax/math/helpers.ts +0 -289
- package/src/components/PasswordInput/PasswordInput.module.scss +0 -17
- package/src/components/PasswordInput/PasswordInput.tsx +0 -154
- package/src/components/PasswordInput/index.tsx +0 -2
- package/src/components/PingPongText/PingPongText.module.scss +0 -4
- package/src/components/PingPongText/PingPongText.tsx +0 -83
- package/src/components/PingPongText/index.tsx +0 -2
- package/src/components/PixelatedScan/PixelatedScan.module.scss +0 -86
- package/src/components/PixelatedScan/PixelatedScan.tsx +0 -175
- package/src/components/PixelatedScan/index.tsx +0 -2
- package/src/components/Portal/Portal.module.scss +0 -3
- package/src/components/Portal/Portal.tsx +0 -68
- package/src/components/Portal/index.tsx +0 -2
- package/src/components/ProgressBar/ProgressBar.module.scss +0 -44
- package/src/components/ProgressBar/ProgressBar.tsx +0 -124
- package/src/components/ProgressBar/index.tsx +0 -2
- package/src/components/ProgressTexts/ProgressTexts.module.scss +0 -37
- package/src/components/ProgressTexts/ProgressTexts.tsx +0 -85
- package/src/components/ProgressTexts/index.tsx +0 -2
- package/src/components/Radio/Radio.module.scss +0 -36
- package/src/components/Radio/Radio.tsx +0 -53
- package/src/components/Radio/index.tsx +0 -2
- package/src/components/SectionContainer/SectionContainer.module.scss +0 -30
- package/src/components/SectionContainer/SectionContainer.tsx +0 -49
- package/src/components/SectionContainer/index.tsx +0 -2
- package/src/components/Select/Select.module.scss +0 -58
- package/src/components/Select/Select.tsx +0 -192
- package/src/components/Select/index.tsx +0 -2
- package/src/components/Skeleton/Skeleton.module.scss +0 -21
- package/src/components/Skeleton/Skeleton.tsx +0 -29
- package/src/components/Skeleton/index.tsx +0 -2
- package/src/components/Spacing/Spacing.module.scss +0 -13
- package/src/components/Spacing/Spacing.tsx +0 -24
- package/src/components/Spacing/index.tsx +0 -2
- package/src/components/StaticScroller/StaticScroller.module.scss +0 -14
- package/src/components/StaticScroller/StaticScroller.tsx +0 -83
- package/src/components/StaticScroller/index.tsx +0 -2
- package/src/components/Switch/Switch.module.scss +0 -43
- package/src/components/Switch/Switch.tsx +0 -41
- package/src/components/Switch/index.tsx +0 -2
- package/src/components/Table/Table.module.scss +0 -76
- package/src/components/Table/Table.tsx +0 -152
- package/src/components/Table/index.tsx +0 -2
- package/src/components/Tabs/Tabs.module.scss +0 -40
- package/src/components/Tabs/Tabs.tsx +0 -104
- package/src/components/Tabs/index.tsx +0 -2
- package/src/components/Text/Text.module.scss +0 -81
- package/src/components/Text/Text.tsx +0 -42
- package/src/components/Text/index.tsx +0 -2
- package/src/components/Transition/MasksFactory/DiagonalReveal.tsx +0 -47
- package/src/components/Transition/MasksFactory/DiagonalSquareToBalls.tsx +0 -78
- package/src/components/Transition/MasksFactory/PhysicsSquares.tsx +0 -106
- package/src/components/Transition/MasksFactory/SquareToBalls.tsx +0 -66
- package/src/components/Transition/MasksFactory/utils.ts +0 -35
- package/src/components/Transition/Transition.module.scss +0 -211
- package/src/components/Transition/Transition.tsx +0 -495
- package/src/components/Transition/index.tsx +0 -2
- package/src/components/UncontrolledTransition/UncontrolledTransition.ai.md +0 -9
- package/src/components/UncontrolledTransition/UncontrolledTransition.sample.tsx +0 -34
- package/src/components/UncontrolledTransition/UncontrolledTransition.tsx +0 -143
- package/src/components/UncontrolledTransition/index.tsx +0 -2
- package/src/components/WalletConnectionWrapper/WalletConnectionWrapper.tsx +0 -212
- package/src/components/WalletConnectionWrapper/index.tsx +0 -2
- package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.module.scss +0 -5
- package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.tsx +0 -52
- package/src/components/utilitary/ScrollAndFocusLock/index.tsx +0 -2
- package/src/context/AsyncProcess.tsx +0 -107
- package/src/context/ContextAsyncControl.tsx +0 -89
- package/src/context/CustomBrowserRouter.tsx +0 -55
- package/src/context/OneUIProvider.tsx +0 -308
- package/src/hooks/logs/useDependencyChangeDetection.ts +0 -25
- package/src/hooks/logs/useIsMounting.ts +0 -7
- package/src/hooks/persistence/useLocalStorage.ts +0 -45
- package/src/hooks/shims/ObjectWatchShim.ts +0 -56
- package/src/hooks/ui/useAdaptiveImage.tsx +0 -36
- package/src/hooks/ui/useAlternating.tsx +0 -22
- package/src/hooks/ui/useBreakpoint.tsx +0 -21
- package/src/hooks/ui/useCustomScrollbar.module.scss +0 -20
- package/src/hooks/ui/useCustomScrollbar.tsx +0 -22
- package/src/hooks/ui/useEffectIf.ts +0 -11
- package/src/hooks/ui/useMouseHover.tsx +0 -26
- package/src/hooks/ui/usePaginationControls.module.scss +0 -16
- package/src/hooks/ui/usePaginationControls.tsx +0 -176
- package/src/hooks/ui/useSnapToViewport.module.scss +0 -6
- package/src/hooks/ui/useSnapToViewport.ts +0 -28
- package/src/hooks/ui/useTilt.tsx +0 -219
- package/src/hooks/ui/useZoomable.module.scss +0 -34
- package/src/hooks/ui/useZoomable.tsx +0 -144
- package/src/hooks/useAsyncControl.ai.md +0 -25
- package/src/hooks/useAsyncControl.ts +0 -101
- package/src/hooks/useContainedRepositioning.ts +0 -110
- package/src/hooks/useCustomHistory.ts +0 -14
- package/src/hooks/useElementFit.ts +0 -82
- package/src/hooks/useFirestoreWatch.ts +0 -54
- package/src/hooks/useForm.ts +0 -49
- package/src/hooks/useFreeze.ts +0 -12
- package/src/hooks/useHero.module.scss +0 -41
- package/src/hooks/useHero.ts +0 -514
- package/src/hooks/useIntersection.ts +0 -32
- package/src/hooks/useMergeRefs.ts +0 -29
- package/src/hooks/useObserve.ts +0 -24
- package/src/hooks/usePagination.ts +0 -228
- package/src/hooks/usePooledOperation.ts +0 -54
- package/src/hooks/usePooling.ts +0 -46
- package/src/hooks/useRebound.ts +0 -23
- package/src/hooks/useShortIntl.ai.md +0 -5
- package/src/hooks/useShortIntl.ts +0 -97
- package/src/hooks/utility/useAsyncMemo.ts +0 -43
- package/src/hooks/utility/useDepChange.ts +0 -11
- package/src/hooks/utility/useEvents.ts +0 -33
- package/src/hooks/utility/useImmediate.ts +0 -8
- package/src/hooks/utility/useManualInit.ts +0 -24
- package/src/hooks/utility/useModule.ts +0 -15
- package/src/hooks/utility/useQuery.ts +0 -15
- package/src/hooks/utility/useUniqueEffect.ts +0 -22
- package/src/index.preprocess.ts +0 -82
- package/src/index.ts +0 -229
- package/src/models/DebugLogger.ts +0 -7
- package/src/models/GenericContract.ts +0 -169
- package/src/models/Orbs.ts +0 -97
- package/src/reac-app-env.d.ts +0 -6
- package/src/storybook/assets/video/txt-reversed.mp4 +0 -0
- package/src/storybookUtils/index.tsx +0 -53
- package/src/test.tsx +0 -0
- package/src/type-utils.ts +0 -49
- package/src/types.ts +0 -199
- package/src/utility.d.ts +0 -70
- package/src/utils/blockchain.ts +0 -43
- package/src/utils/e2e.ts +0 -55
- package/src/utils/flatten.ts +0 -17
- package/src/utils/formatters.ts +0 -36
- package/src/utils/html.utils.ts +0 -3
- package/src/utils/ownEvent.ts +0 -8
- package/src/utils/test.ts +0 -20
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { SetStateAction, useCallback, useMemo, useState } from "react";
|
|
2
|
-
import { Primitive } from "type-fest";
|
|
3
|
-
|
|
4
|
-
type Arr<X> = [X, React.Dispatch<SetStateAction<X>>];
|
|
5
|
-
export type FunctionMap = {
|
|
6
|
-
[f: string]: ((...args: any[]) => Promise<any>) | Object | Primitive;
|
|
7
|
-
};
|
|
8
|
-
export type Control<E extends any = any> = {
|
|
9
|
-
error?: E;
|
|
10
|
-
loading: boolean;
|
|
11
|
-
};
|
|
12
|
-
export function useRawAsynControl<E = any, F extends FunctionMap = {}>(
|
|
13
|
-
functionsToWrap: F | undefined,
|
|
14
|
-
[error, setError]: Arr<E | undefined>,
|
|
15
|
-
[loading, setLoading]: Arr<boolean>
|
|
16
|
-
) {
|
|
17
|
-
const _process = useCallback(async (asyncFn: (() => Promise<any>) | Promise<any>) => {
|
|
18
|
-
try {
|
|
19
|
-
setLoading(true);
|
|
20
|
-
setError(undefined);
|
|
21
|
-
if (asyncFn instanceof Promise) await asyncFn;
|
|
22
|
-
else return await asyncFn();
|
|
23
|
-
} catch (e) {
|
|
24
|
-
if (process.env.NODE_ENV === "development") console.error(e);
|
|
25
|
-
setError(e as E);
|
|
26
|
-
throw e;
|
|
27
|
-
} finally {
|
|
28
|
-
setLoading(false);
|
|
29
|
-
}
|
|
30
|
-
}, []);
|
|
31
|
-
|
|
32
|
-
const { functionsToMemoize, other } = Object.entries(
|
|
33
|
-
functionsToWrap || {}
|
|
34
|
-
).reduce(
|
|
35
|
-
(r, [k, func]) => {
|
|
36
|
-
return {
|
|
37
|
-
...r,
|
|
38
|
-
...(typeof func === "function"
|
|
39
|
-
? {
|
|
40
|
-
functionsToMemoize: {
|
|
41
|
-
...r.functionsToMemoize,
|
|
42
|
-
[k]: func,
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
: {
|
|
46
|
-
other: {
|
|
47
|
-
...r.other,
|
|
48
|
-
[k]: func,
|
|
49
|
-
},
|
|
50
|
-
}),
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
functionsToMemoize: {},
|
|
55
|
-
other: {},
|
|
56
|
-
} as {
|
|
57
|
-
functionsToMemoize: F;
|
|
58
|
-
other: F;
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
process: _process,
|
|
64
|
-
loading,
|
|
65
|
-
error,
|
|
66
|
-
setError,
|
|
67
|
-
setLoading,
|
|
68
|
-
...other,
|
|
69
|
-
...Object.entries(functionsToMemoize).reduce(
|
|
70
|
-
(r, [k, v]) => ({
|
|
71
|
-
...r,
|
|
72
|
-
[k]: useMemo(
|
|
73
|
-
() =>
|
|
74
|
-
(...args: any[]) =>
|
|
75
|
-
_process(() => (v as any)(...args)),
|
|
76
|
-
[v]
|
|
77
|
-
),
|
|
78
|
-
}),
|
|
79
|
-
{} as F
|
|
80
|
-
),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function useAsyncControl<
|
|
85
|
-
E = any,
|
|
86
|
-
F extends {
|
|
87
|
-
[f: string]: ((...args: any[]) => Promise<any>) | Object | Primitive;
|
|
88
|
-
} = {}
|
|
89
|
-
>(functionsToWrap?: F) {
|
|
90
|
-
const error = useState<E | Error>();
|
|
91
|
-
const loading = useState<boolean>(false);
|
|
92
|
-
|
|
93
|
-
return useRawAsynControl(functionsToWrap, error, loading);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* This hook provides a way to handle async operations storing the loading state, or the error when it fails, it does not store information returned from the functions.
|
|
98
|
-
* @param functionsToWrap The functions to wrap in control.
|
|
99
|
-
* @returns
|
|
100
|
-
*/
|
|
101
|
-
export default useAsyncControl;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import debounce from "lodash/debounce";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This hook takes an html and checks if its outside its parent
|
|
6
|
-
* If it is, it should move it so it can be totally visible inside the container
|
|
7
|
-
*/
|
|
8
|
-
export default function useContainedRepositioning(
|
|
9
|
-
focused: boolean,
|
|
10
|
-
getParent: (el: HTMLElement) => HTMLElement,
|
|
11
|
-
{
|
|
12
|
-
offset = 16,
|
|
13
|
-
scale = 1,
|
|
14
|
-
offsetLimit = Number.POSITIVE_INFINITY,
|
|
15
|
-
}: {
|
|
16
|
-
/** The offset the element will be moved by from the closest bound */
|
|
17
|
-
offset?: number;
|
|
18
|
-
|
|
19
|
-
/** The scaled element width to be considered. usefull for when the focused element will change size */
|
|
20
|
-
scale?: number;
|
|
21
|
-
|
|
22
|
-
/** Limit offset */
|
|
23
|
-
offsetLimit?: number;
|
|
24
|
-
} = {}
|
|
25
|
-
) {
|
|
26
|
-
const elementToCheck = useRef<HTMLDivElement>(null);
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
const el = elementToCheck.current;
|
|
29
|
-
if (!el) return;
|
|
30
|
-
|
|
31
|
-
const curr = el;
|
|
32
|
-
const relativeParent = getParent(curr);
|
|
33
|
-
|
|
34
|
-
if (process.env.NODE_ENV === "development") {
|
|
35
|
-
if (window.getComputedStyle(el).position !== "relative")
|
|
36
|
-
throw new Error(
|
|
37
|
-
"The target element MUST have position relative so it can be moved"
|
|
38
|
-
);
|
|
39
|
-
if (window.getComputedStyle(relativeParent).position !== "relative")
|
|
40
|
-
throw new Error(
|
|
41
|
-
"The relative to element MUST have position relative so it can calculate correctly the target position"
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (focused) {
|
|
46
|
-
curr.style.right = `0px`;
|
|
47
|
-
const reposition = debounce(() => {
|
|
48
|
-
const alreadyRight = Number(curr.style.right.replace("px", ""));
|
|
49
|
-
const limitOffset =
|
|
50
|
-
relativeParent.scrollLeft + relativeParent.clientWidth;
|
|
51
|
-
const elWidth = curr.clientWidth * scale;
|
|
52
|
-
const offsetOfScale = (elWidth - curr.clientWidth) / 2;
|
|
53
|
-
const cardLimit =
|
|
54
|
-
curr.offsetLeft - offsetOfScale + alreadyRight + elWidth;
|
|
55
|
-
const exceedingSpace = cardLimit - limitOffset;
|
|
56
|
-
const offsetLeft =
|
|
57
|
-
curr.offsetLeft -
|
|
58
|
-
offsetOfScale +
|
|
59
|
-
alreadyRight -
|
|
60
|
-
relativeParent.scrollLeft;
|
|
61
|
-
const isOverflowedRight = exceedingSpace > 0;
|
|
62
|
-
const isOverflowedLeft = offsetLeft < 0;
|
|
63
|
-
const limit = exceedingSpace + -offsetLeft;
|
|
64
|
-
|
|
65
|
-
if (isOverflowedRight) {
|
|
66
|
-
const val = Math.min(
|
|
67
|
-
exceedingSpace - -Math.min(Math.abs(limit / 2), offset),
|
|
68
|
-
offsetLimit
|
|
69
|
-
);
|
|
70
|
-
curr.style.right = `${val}px`;
|
|
71
|
-
}
|
|
72
|
-
if (isOverflowedLeft) {
|
|
73
|
-
const val = Math.max(
|
|
74
|
-
offsetLeft - Math.min(Math.abs(limit) / 2, offset),
|
|
75
|
-
-offsetLimit
|
|
76
|
-
);
|
|
77
|
-
curr.style.right = `${val}px`;
|
|
78
|
-
}
|
|
79
|
-
if (isOverflowedLeft || isOverflowedRight) {
|
|
80
|
-
curr.style.zIndex = "1000";
|
|
81
|
-
}
|
|
82
|
-
}, 50);
|
|
83
|
-
reposition();
|
|
84
|
-
reposition.flush();
|
|
85
|
-
|
|
86
|
-
relativeParent.addEventListener("scroll", reposition, {
|
|
87
|
-
passive: true
|
|
88
|
-
});
|
|
89
|
-
return () => {
|
|
90
|
-
reposition.cancel();
|
|
91
|
-
relativeParent.removeEventListener("scroll", reposition);
|
|
92
|
-
el.style.right = `0px`;
|
|
93
|
-
const restore = ({ propertyName, currentTarget }: TransitionEvent) => {
|
|
94
|
-
const targetTransformation = window.getComputedStyle(
|
|
95
|
-
currentTarget as HTMLDivElement
|
|
96
|
-
).right;
|
|
97
|
-
if (propertyName === "right" && targetTransformation === "0px") {
|
|
98
|
-
curr.style.zIndex = "";
|
|
99
|
-
el.removeEventListener("transitionend", restore);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
el.addEventListener("transitionend", restore);
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}, [focused]);
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
elementToCheck,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useHistory, useLocation } from "react-router-dom"
|
|
2
|
-
import { CustomState } from "../context/CustomBrowserRouter";
|
|
3
|
-
|
|
4
|
-
export default function useCustomHistory() {
|
|
5
|
-
const customHistory = useHistory();
|
|
6
|
-
const { state } = useLocation<CustomState | undefined>();
|
|
7
|
-
return {
|
|
8
|
-
...customHistory,
|
|
9
|
-
goBackWithFallback(fallbackRoute: string) {
|
|
10
|
-
if (state?.internalNavigation) customHistory.goBack();
|
|
11
|
-
else customHistory.push(fallbackRoute);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { RefObject, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This hook receives a base width of an element and returns how much items fit **vertically** inside the referenced html element
|
|
5
|
-
*
|
|
6
|
-
* @param baseWidth The base width of each element
|
|
7
|
-
*/
|
|
8
|
-
export default function useElementFit(
|
|
9
|
-
baseWidth: number,
|
|
10
|
-
baseHeight?: number
|
|
11
|
-
): {
|
|
12
|
-
/** The amount of items that are able to fit in the available width */
|
|
13
|
-
howManyItemsFit?: number;
|
|
14
|
-
/** The amount of items that are able to fit in the available visible space + a row more so it can be scrollable */
|
|
15
|
-
howManyItemsFitWithExtraRow?: number;
|
|
16
|
-
/** How many items would fit a single row */
|
|
17
|
-
howManyItemsByRow?: number;
|
|
18
|
-
/** How many items until it overflows width */
|
|
19
|
-
anItemMore?: number;
|
|
20
|
-
|
|
21
|
-
/** The ref to be sent to the element that will receive the items */
|
|
22
|
-
ref: RefObject<HTMLDivElement | undefined>;
|
|
23
|
-
} {
|
|
24
|
-
const ref = useRef<HTMLDivElement>(undefined);
|
|
25
|
-
function calculateDimension() {
|
|
26
|
-
function howManyItemsStackVertically() {
|
|
27
|
-
if (!ref.current || baseHeight === undefined) return 1;
|
|
28
|
-
return Math.floor(ref.current!.clientHeight / baseHeight);
|
|
29
|
-
}
|
|
30
|
-
if ((window as any).PRERENDER)
|
|
31
|
-
return {
|
|
32
|
-
howManyItemsWillBeVisible: 4,
|
|
33
|
-
byRow: 4,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const width = ref.current?.clientWidth || window.visualViewport!.width;
|
|
37
|
-
const maxItemsHorizontally = Math.floor(width / baseWidth) || 1;
|
|
38
|
-
|
|
39
|
-
if (process.env.NODE_ENV === "development")
|
|
40
|
-
require("../models/DebugLogger").default(
|
|
41
|
-
`${useElementFit.name}:clientWidth`,
|
|
42
|
-
ref.current?.clientWidth
|
|
43
|
-
);
|
|
44
|
-
return {
|
|
45
|
-
howManyItemsWillBeVisible:
|
|
46
|
-
maxItemsHorizontally * howManyItemsStackVertically(),
|
|
47
|
-
byRow: maxItemsHorizontally,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const [itemsToShow, setItemsToShow] = useState<
|
|
51
|
-
ReturnType<typeof calculateDimension> | undefined
|
|
52
|
-
>(
|
|
53
|
-
(window as any).PRERENDER
|
|
54
|
-
? {
|
|
55
|
-
byRow: 4,
|
|
56
|
-
howManyItemsWillBeVisible: 4,
|
|
57
|
-
}
|
|
58
|
-
: undefined
|
|
59
|
-
);
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
setItemsToShow(calculateDimension());
|
|
62
|
-
function onResize() {
|
|
63
|
-
setItemsToShow(calculateDimension());
|
|
64
|
-
}
|
|
65
|
-
window.addEventListener("resize", onResize);
|
|
66
|
-
return () => {
|
|
67
|
-
window.removeEventListener("resize", onResize);
|
|
68
|
-
};
|
|
69
|
-
}, []);
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
howManyItemsFit: itemsToShow?.howManyItemsWillBeVisible,
|
|
73
|
-
howManyItemsFitWithExtraRow: itemsToShow
|
|
74
|
-
? itemsToShow.howManyItemsWillBeVisible + itemsToShow.byRow
|
|
75
|
-
: undefined,
|
|
76
|
-
anItemMore: itemsToShow
|
|
77
|
-
? itemsToShow.howManyItemsWillBeVisible + 1
|
|
78
|
-
: undefined,
|
|
79
|
-
howManyItemsByRow: itemsToShow?.byRow,
|
|
80
|
-
ref,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { DocumentChangeType, Unsubscribe } from "firebase/firestore";
|
|
3
|
-
|
|
4
|
-
type SnapshotFactoryCb<D extends any> = (changes: {
|
|
5
|
-
doc: D,
|
|
6
|
-
type: DocumentChangeType
|
|
7
|
-
}[]) => void
|
|
8
|
-
|
|
9
|
-
export type SnapshotFactoryReturn<D extends { id: string }> = (cb: SnapshotFactoryCb<D>) => Unsubscribe
|
|
10
|
-
|
|
11
|
-
export default function useFirestoreWatch<D extends { id: string }, P extends any[]>(queryFactory: (...params: P) => SnapshotFactoryReturn<D>, params: P) {
|
|
12
|
-
const [docsList, updateList] = useState<D[]>();
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
const unsub = queryFactory(...params)((changes) => {
|
|
16
|
-
updateList((prevList = []) => {
|
|
17
|
-
for (let docChange of changes) {
|
|
18
|
-
if (docChange.type === undefined) {
|
|
19
|
-
const existing = prevList.find((f) => f.id === docChange.doc.id);
|
|
20
|
-
if (existing) docChange.type = "modified"
|
|
21
|
-
else docChange.type = "added"
|
|
22
|
-
}
|
|
23
|
-
switch (docChange.type) {
|
|
24
|
-
case 'added':
|
|
25
|
-
if (!prevList.find((f) => f.id === docChange.doc.id)) {
|
|
26
|
-
prevList.unshift(docChange.doc)
|
|
27
|
-
}
|
|
28
|
-
break
|
|
29
|
-
case 'modified':
|
|
30
|
-
prevList = prevList!.map((item) => {
|
|
31
|
-
if (item.id === docChange.doc.id)
|
|
32
|
-
for (let key in docChange.doc) {
|
|
33
|
-
item[key] = docChange.doc[key];
|
|
34
|
-
}
|
|
35
|
-
return item
|
|
36
|
-
})
|
|
37
|
-
break
|
|
38
|
-
case 'removed':
|
|
39
|
-
prevList = prevList!.filter(
|
|
40
|
-
(item) => item.id !== docChange.doc.id
|
|
41
|
-
)
|
|
42
|
-
break
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return [...prevList]
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
})
|
|
50
|
-
return unsub;
|
|
51
|
-
}, params);
|
|
52
|
-
|
|
53
|
-
return docsList;
|
|
54
|
-
}
|
package/src/hooks/useForm.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Context, useMemo, useState } from "react"
|
|
2
|
-
import { BaseForm, FieldDefinition, FieldTypes } from "../components/Form/Form";
|
|
3
|
-
|
|
4
|
-
type Intermediary<F extends BaseForm> = {
|
|
5
|
-
form: F,
|
|
6
|
-
formValidation: {
|
|
7
|
-
[k in keyof F]: string
|
|
8
|
-
} & { isValid: string | true },
|
|
9
|
-
set: <K extends keyof F>(k: K, value: F[K]) => void
|
|
10
|
-
}
|
|
11
|
-
export type FormControls<C extends FormConfig<any>> = Intermediary<C extends FormConfig<infer F> ? F : never>
|
|
12
|
-
export type FormConfig<T extends BaseForm> = { [k in keyof T]: FieldDefinition<T, k, FieldTypes> };
|
|
13
|
-
export default function useContextForm<T extends BaseForm>(
|
|
14
|
-
config: FormConfig<T>,
|
|
15
|
-
initialState: T
|
|
16
|
-
): FormControls<FormConfig<T>> {
|
|
17
|
-
const [form, setForm] = useState<Partial<T>>(initialState);
|
|
18
|
-
const isValid = useMemo(
|
|
19
|
-
() =>
|
|
20
|
-
!Object.keys(config).some(
|
|
21
|
-
(a) => typeof config[a].validator(form[a], form) === "string"
|
|
22
|
-
),
|
|
23
|
-
[form]
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
const _setFormField: <K extends keyof T>(k: K, value: T[K]) => void = (key, value) => {
|
|
27
|
-
setForm(prev => ({
|
|
28
|
-
...prev,
|
|
29
|
-
[key]: value
|
|
30
|
-
}))
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const validFormFields = useMemo(() => {
|
|
34
|
-
return Object.keys(config).reduce((result, field: keyof T) => {
|
|
35
|
-
const fieldConfig = config[field];
|
|
36
|
-
const invalidMessage = fieldConfig.validator(form[field], form);
|
|
37
|
-
return {
|
|
38
|
-
...result,
|
|
39
|
-
[field]: invalidMessage
|
|
40
|
-
}
|
|
41
|
-
}, { isValid } as { [k in keyof T]: string | true } & { isValid: boolean })
|
|
42
|
-
}, [form, isValid]);
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
form: form,
|
|
46
|
-
formValidation: validFormFields,
|
|
47
|
-
set: _setFormField
|
|
48
|
-
} as any
|
|
49
|
-
}
|
package/src/hooks/useFreeze.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useRef } from "react";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This hook pipes a data and when it is set to a falsy value ("", undefined, null, 0),
|
|
5
|
-
* it returns the previous valid value
|
|
6
|
-
*/
|
|
7
|
-
export default function useFreeze<T>(something: T) {
|
|
8
|
-
const currChildOrPrev = useRef<T>(undefined);
|
|
9
|
-
currChildOrPrev.current =
|
|
10
|
-
something === undefined ? currChildOrPrev.current : something;
|
|
11
|
-
return currChildOrPrev.current;
|
|
12
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
@import "../assets/styles/index.scss";
|
|
2
|
-
|
|
3
|
-
$timing: cubic-bezier(0.5, -0.45, 0.44, 1.37);
|
|
4
|
-
// $timing: cubic-bezier(0.73, -0.49, 0.16, 1.4);
|
|
5
|
-
|
|
6
|
-
.acceleration {
|
|
7
|
-
--animation--speed-fast: 1s;
|
|
8
|
-
animation-name: acceleration;
|
|
9
|
-
animation-duration: var(--animation--speed-fast);
|
|
10
|
-
animation-timing-function: $timing;
|
|
11
|
-
transition-timing-function: $timing !important;
|
|
12
|
-
transform-origin: var(--origin-1);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@keyframes acceleration {
|
|
16
|
-
0% {
|
|
17
|
-
transform: rotateY(0deg);
|
|
18
|
-
}
|
|
19
|
-
10% {
|
|
20
|
-
transform-origin: var(--origin-1);
|
|
21
|
-
transform: var(--stage-1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
70% {
|
|
25
|
-
transform: var(--stage-1);
|
|
26
|
-
transform-origin: var(--origin-1);
|
|
27
|
-
}
|
|
28
|
-
85% {
|
|
29
|
-
transform-origin: var(--origin-2);
|
|
30
|
-
transform: var(--stage-2);
|
|
31
|
-
}
|
|
32
|
-
100% {
|
|
33
|
-
transform: rotateY(0deg);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.component:not([data-hero-clone]) {
|
|
38
|
-
transition: height $fast linear, opacity $fast linear, min-height $fast linear,
|
|
39
|
-
max-height $fast linear !important;
|
|
40
|
-
overflow: hidden;
|
|
41
|
-
}
|