@onepercentio/one-ui 0.29.2 → 0.29.5
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/Switch/Switch.d.ts +1 -1
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/hooks/useHero.js +3 -2
- package/dist-ts/components/Switch/Switch.d.ts +1 -1
- package/dist-ts/hooks/useHero.js +5 -4
- package/dist-ts/hooks/useHero.js.map +1 -1
- package/package.json +5 -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 -512
- 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,84 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useRef } from "react";
|
|
2
|
-
import { Uri } from "monaco-editor";
|
|
3
|
-
import Styles from "./CodeInput.module.scss";
|
|
4
|
-
import Loader from "../Loader";
|
|
5
|
-
import useModule from "../../hooks/utility/useModule";
|
|
6
|
-
|
|
7
|
-
window.MonacoEnvironment = {
|
|
8
|
-
getWorkerUrl: function (moduleId, label) {
|
|
9
|
-
if (label === "typescript" || label === "javascript")
|
|
10
|
-
return "./ts.worker.js";
|
|
11
|
-
return "./editor.worker.js";
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Allows the user to input code using monaco editor
|
|
17
|
-
**/
|
|
18
|
-
export default function CodeInput({
|
|
19
|
-
codeSample,
|
|
20
|
-
onChange,
|
|
21
|
-
mode,
|
|
22
|
-
}: {
|
|
23
|
-
codeSample?: string;
|
|
24
|
-
onChange?: (code: string) => void;
|
|
25
|
-
mode?: "dark" | "light";
|
|
26
|
-
}) {
|
|
27
|
-
const divRef = useRef<HTMLDivElement>(null);
|
|
28
|
-
const Monaco = useModule(() => import("monaco-editor"));
|
|
29
|
-
const content = useMemo(() => {
|
|
30
|
-
if (!Monaco) return <Loader />;
|
|
31
|
-
else {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
}, [Monaco]);
|
|
35
|
-
const editorRef =
|
|
36
|
-
useRef<import("monaco-editor").editor.IStandaloneCodeEditor>(undefined);
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (Monaco) {
|
|
39
|
-
Monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
40
|
-
noSemanticValidation: true,
|
|
41
|
-
});
|
|
42
|
-
const editor = Monaco.editor.create(divRef.current!, {
|
|
43
|
-
language: "typescript",
|
|
44
|
-
scrollBeyondLastLine: false,
|
|
45
|
-
minimap: { enabled: false },
|
|
46
|
-
folding: false,
|
|
47
|
-
readOnly: !onChange,
|
|
48
|
-
theme: mode === "dark" ? "vs-dark" : undefined,
|
|
49
|
-
automaticLayout: true
|
|
50
|
-
});
|
|
51
|
-
editor.onDidContentSizeChange(() => {
|
|
52
|
-
if (!editorRef.current) {
|
|
53
|
-
editorRef.current = editor;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
editor.onDidChangeModelContent(() => {
|
|
57
|
-
if (onChange) onChange(editor.getModel()!.getValue());
|
|
58
|
-
});
|
|
59
|
-
const model = Monaco.editor.createModel(
|
|
60
|
-
codeSample || "",
|
|
61
|
-
"typescript",
|
|
62
|
-
Uri.file(`example.tsx`)
|
|
63
|
-
);
|
|
64
|
-
editor.setModel(model);
|
|
65
|
-
return () => {
|
|
66
|
-
model.dispose();
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}, [Monaco]);
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
if (!codeSample) return;
|
|
72
|
-
const editor = editorRef.current;
|
|
73
|
-
if (!editor) return;
|
|
74
|
-
const model = editor.getModel();
|
|
75
|
-
if (!model) return;
|
|
76
|
-
const currentValue = model.getValue();
|
|
77
|
-
if (codeSample !== currentValue) model.setValue(codeSample);
|
|
78
|
-
}, [codeSample]);
|
|
79
|
-
return (
|
|
80
|
-
<div ref={divRef} className={Styles.root}>
|
|
81
|
-
{content}
|
|
82
|
-
</div>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
@import "../../assets/styles/index.scss";
|
|
2
|
-
|
|
3
|
-
.container {
|
|
4
|
-
> .title {
|
|
5
|
-
cursor: pointer;
|
|
6
|
-
margin: 0px;
|
|
7
|
-
display: block;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.open .title::after {
|
|
12
|
-
transform: translateX(-0.5em) rotateX(180deg) rotateZ(45deg);
|
|
13
|
-
}
|
|
14
|
-
.closed .title::after {
|
|
15
|
-
transform: translateX(-0.5em) rotateX(0deg) rotateZ(45deg);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.content {
|
|
19
|
-
width: 100%;
|
|
20
|
-
max-width: 500px;
|
|
21
|
-
overflow: hidden;
|
|
22
|
-
transition: height $fast ease-in;
|
|
23
|
-
height: 0px;
|
|
24
|
-
&.float {
|
|
25
|
-
width: initial;
|
|
26
|
-
max-width: initial;
|
|
27
|
-
position: fixed;
|
|
28
|
-
z-index: 100;
|
|
29
|
-
background: $mainBackgroundColor;
|
|
30
|
-
overflow: auto;
|
|
31
|
-
}
|
|
32
|
-
&.block {
|
|
33
|
-
box-sizing: initial;
|
|
34
|
-
}
|
|
35
|
-
&.transitionMarginTop {
|
|
36
|
-
transition: height $fast ease-in, margin-top $fast ease-in;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.open {
|
|
41
|
-
transition: height $fast ease-out;
|
|
42
|
-
}
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
ForwardedRef,
|
|
3
|
-
HTMLAttributes,
|
|
4
|
-
HTMLProps,
|
|
5
|
-
PropsWithChildren,
|
|
6
|
-
forwardRef,
|
|
7
|
-
useEffect,
|
|
8
|
-
useImperativeHandle,
|
|
9
|
-
useLayoutEffect,
|
|
10
|
-
useRef,
|
|
11
|
-
useState,
|
|
12
|
-
} from "react";
|
|
13
|
-
import FadeIn from "../FadeIn";
|
|
14
|
-
import Styles from "./Collapsable.module.scss";
|
|
15
|
-
import {
|
|
16
|
-
AnchoredTooltipAlignment,
|
|
17
|
-
AnchoredTooltipAnchor,
|
|
18
|
-
updateTooltipPosition,
|
|
19
|
-
} from "../AnchoredTooltip/AnchoredTooltip";
|
|
20
|
-
import { useOneUIConfig } from "../../context/OneUIProvider";
|
|
21
|
-
function _Collapsable(
|
|
22
|
-
{
|
|
23
|
-
children,
|
|
24
|
-
title,
|
|
25
|
-
className,
|
|
26
|
-
onToggleOpen: _onToggleOpen,
|
|
27
|
-
open: _open,
|
|
28
|
-
id,
|
|
29
|
-
mode = "block",
|
|
30
|
-
contentClassName,
|
|
31
|
-
onContentClick,
|
|
32
|
-
keepUnderlayingElement,
|
|
33
|
-
onClickOut,
|
|
34
|
-
...props
|
|
35
|
-
}: PropsWithChildren<
|
|
36
|
-
{
|
|
37
|
-
title: React.ReactNode | ((isOpen: boolean) => React.ReactNode);
|
|
38
|
-
className?: string;
|
|
39
|
-
contentClassName?: string;
|
|
40
|
-
onToggleOpen?: (isOpen: boolean) => void;
|
|
41
|
-
open?: boolean;
|
|
42
|
-
id?: string | undefined;
|
|
43
|
-
"data-testid"?: string;
|
|
44
|
-
onContentClick?: HTMLAttributes<HTMLInputElement>["onClick"];
|
|
45
|
-
/**
|
|
46
|
-
* This flag indicates if the collapsable content should be kept in HTML while it's collapsed
|
|
47
|
-
*
|
|
48
|
-
* Usefull for responsive layouts where the collapsable should not "behave" as a collapsable content
|
|
49
|
-
*/
|
|
50
|
-
keepUnderlayingElement?: boolean;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* To detect when the user clicks out of the container
|
|
54
|
-
*/
|
|
55
|
-
onClickOut?: () => void;
|
|
56
|
-
} & (
|
|
57
|
-
| {
|
|
58
|
-
/** This will define if the content will be floating under the title or will expand all the container as one */
|
|
59
|
-
mode?: "block";
|
|
60
|
-
}
|
|
61
|
-
| {
|
|
62
|
-
mode: "float";
|
|
63
|
-
alignTo: AnchoredTooltipAlignment;
|
|
64
|
-
anchorTo?: AnchoredTooltipAnchor;
|
|
65
|
-
}
|
|
66
|
-
)
|
|
67
|
-
> &
|
|
68
|
-
Omit<HTMLAttributes<HTMLDivElement>, "title">,
|
|
69
|
-
ref: ForwardedRef<{ redimension: () => void }>
|
|
70
|
-
) {
|
|
71
|
-
const globalClassName = useOneUIConfig("component.collapsable.className", "");
|
|
72
|
-
const [localOpen, setLocalOpen] = useState(!!_open);
|
|
73
|
-
const open = _open === undefined ? localOpen : _open;
|
|
74
|
-
const onToggleOpen =
|
|
75
|
-
_onToggleOpen === undefined ? setLocalOpen : _onToggleOpen;
|
|
76
|
-
|
|
77
|
-
const contentRef = useRef<HTMLDivElement>(null);
|
|
78
|
-
const toggleRef = useRef<HTMLDivElement>(null);
|
|
79
|
-
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
if (open && onClickOut) {
|
|
82
|
-
window.addEventListener("click", onClickOut);
|
|
83
|
-
return () => window.removeEventListener("click", onClickOut);
|
|
84
|
-
}
|
|
85
|
-
}, [!!onClickOut, open]);
|
|
86
|
-
|
|
87
|
-
function redimension(canShrink: boolean = false) {
|
|
88
|
-
const el = contentRef.current!;
|
|
89
|
-
const contentEl = el.firstElementChild! as HTMLDivElement;
|
|
90
|
-
if (open) {
|
|
91
|
-
el.style.marginTop = ``;
|
|
92
|
-
el.style.height =
|
|
93
|
-
Math.min(
|
|
94
|
-
canShrink ? contentEl.clientHeight : Number.POSITIVE_INFINITY,
|
|
95
|
-
el.scrollHeight,
|
|
96
|
-
visualViewport!.height - 16
|
|
97
|
-
) + "px";
|
|
98
|
-
el.parentElement!.style.position = "relative";
|
|
99
|
-
if (mode === "float") {
|
|
100
|
-
el.style.minHeight = el.style.height;
|
|
101
|
-
const { shouldAnchorToBottom } = updateTooltipPosition(
|
|
102
|
-
el,
|
|
103
|
-
toggleRef.current!,
|
|
104
|
-
true,
|
|
105
|
-
"alignTo" in props ? props.alignTo : AnchoredTooltipAlignment.CENTER,
|
|
106
|
-
"anchorTo" in props ? props.anchorTo : undefined
|
|
107
|
-
);
|
|
108
|
-
el.style.minHeight = "";
|
|
109
|
-
if (!shouldAnchorToBottom) {
|
|
110
|
-
el.style.marginTop = el.style.height;
|
|
111
|
-
}
|
|
112
|
-
const transitionStart = ({
|
|
113
|
-
currentTarget,
|
|
114
|
-
target,
|
|
115
|
-
propertyName,
|
|
116
|
-
}: TransitionEvent) => {
|
|
117
|
-
if (
|
|
118
|
-
currentTarget === target &&
|
|
119
|
-
propertyName == "height" &&
|
|
120
|
-
!shouldAnchorToBottom
|
|
121
|
-
) {
|
|
122
|
-
el.classList.add(Styles.transitionMarginTop);
|
|
123
|
-
el.style.marginTop = "0px";
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
el.addEventListener("transitionstart", transitionStart);
|
|
127
|
-
return () => el.removeEventListener("transitionstart", transitionStart);
|
|
128
|
-
}
|
|
129
|
-
const onTransitionEnd = () => {
|
|
130
|
-
el.style.height = "auto";
|
|
131
|
-
};
|
|
132
|
-
el.addEventListener("transitionend", onTransitionEnd);
|
|
133
|
-
el.addEventListener("transitionend", () =>
|
|
134
|
-
el.removeEventListener("transitionend", onTransitionEnd)
|
|
135
|
-
);
|
|
136
|
-
return () => {
|
|
137
|
-
el.removeEventListener("transitionend", onTransitionEnd);
|
|
138
|
-
};
|
|
139
|
-
} else {
|
|
140
|
-
el.style.height = el.clientHeight + "px";
|
|
141
|
-
setTimeout(() => {
|
|
142
|
-
if (el.style.marginTop === "0px")
|
|
143
|
-
el.style.marginTop = `${el.clientHeight}px`;
|
|
144
|
-
el.style.height = 0 + "px";
|
|
145
|
-
}, 100);
|
|
146
|
-
const onTransitionEnd = () => {
|
|
147
|
-
el.parentElement!.style.position = "initial";
|
|
148
|
-
el.classList.remove(Styles.transitionMarginTop);
|
|
149
|
-
el.removeEventListener("transitionend", onTransitionEnd);
|
|
150
|
-
};
|
|
151
|
-
el.addEventListener("transitionend", onTransitionEnd);
|
|
152
|
-
return () => {
|
|
153
|
-
el.removeEventListener("transitionend", onTransitionEnd);
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
useImperativeHandle(ref, () => ({
|
|
159
|
-
redimension: () => redimension(true),
|
|
160
|
-
}));
|
|
161
|
-
|
|
162
|
-
useLayoutEffect(() => {
|
|
163
|
-
redimension();
|
|
164
|
-
}, [open]);
|
|
165
|
-
|
|
166
|
-
const propsToSpread = { ...props } as any;
|
|
167
|
-
delete propsToSpread.alignTo;
|
|
168
|
-
delete propsToSpread.anchorTo;
|
|
169
|
-
|
|
170
|
-
return (
|
|
171
|
-
<div
|
|
172
|
-
className={`${Styles.container} ${
|
|
173
|
-
open ? Styles.open : Styles.closed
|
|
174
|
-
} ${className} ${globalClassName}`}
|
|
175
|
-
{...propsToSpread}
|
|
176
|
-
>
|
|
177
|
-
<div
|
|
178
|
-
ref={toggleRef}
|
|
179
|
-
onClick={(e) => {
|
|
180
|
-
e.stopPropagation();
|
|
181
|
-
onToggleOpen(!open);
|
|
182
|
-
}}
|
|
183
|
-
id={_collapsableId("header", id)}
|
|
184
|
-
>
|
|
185
|
-
{typeof title === "function" ? title(open) : title}
|
|
186
|
-
</div>
|
|
187
|
-
<div
|
|
188
|
-
onClick={(e) => {
|
|
189
|
-
e.stopPropagation();
|
|
190
|
-
if (onContentClick) onContentClick(e as any);
|
|
191
|
-
}}
|
|
192
|
-
ref={contentRef}
|
|
193
|
-
className={`${Styles.content} ${
|
|
194
|
-
Styles[mode] || ""
|
|
195
|
-
} ${contentClassName}`}
|
|
196
|
-
id={_collapsableId("content", id)}
|
|
197
|
-
>
|
|
198
|
-
<FadeIn>{open || keepUnderlayingElement ? children : null}</FadeIn>
|
|
199
|
-
</div>
|
|
200
|
-
</div>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function _collapsableId(type: "header" | "content", id?: string) {
|
|
205
|
-
return id ? `collapsable_${type}_${id}` : undefined;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
class _CollapsableInterface {
|
|
209
|
-
_id: string;
|
|
210
|
-
|
|
211
|
-
constructor(id: string) {
|
|
212
|
-
this._id = id;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
_getElements() {
|
|
216
|
-
return {
|
|
217
|
-
header: document.getElementById(_collapsableId("header", this._id)!),
|
|
218
|
-
content: document.getElementById(_collapsableId("content", this._id)!),
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
open(onOpened: () => void) {
|
|
223
|
-
const { header, content } = this._getElements();
|
|
224
|
-
if ((content?.clientHeight || 0) === 0) {
|
|
225
|
-
header!.click();
|
|
226
|
-
content!.addEventListener("transitionend", function _handler() {
|
|
227
|
-
content!.removeEventListener("transitionend", _handler);
|
|
228
|
-
onOpened();
|
|
229
|
-
});
|
|
230
|
-
} else {
|
|
231
|
-
onOpened();
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
getElement(type: "header" | "content"): HTMLDivElement | null {
|
|
236
|
-
return document.getElementById(
|
|
237
|
-
_collapsableId(type, this._id)!
|
|
238
|
-
) as HTMLDivElement | null;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* A helper function for interacting with collapsables without a reference
|
|
244
|
-
*/
|
|
245
|
-
export function CollapsableInterface(id: string) {
|
|
246
|
-
return new _CollapsableInterface(id);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Allows collapsing and expanding the wrapped content
|
|
251
|
-
**/
|
|
252
|
-
const Collapsable = forwardRef(_Collapsable);
|
|
253
|
-
export default Collapsable;
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
Fragment,
|
|
3
|
-
useEffect,
|
|
4
|
-
useLayoutEffect,
|
|
5
|
-
useMemo,
|
|
6
|
-
useState,
|
|
7
|
-
} from "react";
|
|
8
|
-
|
|
9
|
-
export type TimeObject = {
|
|
10
|
-
hours: number;
|
|
11
|
-
minutes: number;
|
|
12
|
-
seconds: number;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export function calculateTimeFromTimespan(timespan: number): TimeObject {
|
|
16
|
-
const seconds = Math.floor(timespan / 1000);
|
|
17
|
-
const minutes = Math.floor(seconds / 60);
|
|
18
|
-
const hours = Math.floor(minutes / 60);
|
|
19
|
-
return {
|
|
20
|
-
hours,
|
|
21
|
-
minutes: minutes % 60,
|
|
22
|
-
seconds: seconds % 60,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const IntegerFormatter = new Intl.NumberFormat(undefined, {
|
|
27
|
-
minimumIntegerDigits: 2,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export enum CountdownTextModel {
|
|
31
|
-
/** This shows the countdown on the format 00:00:00 */
|
|
32
|
-
CLOCK,
|
|
33
|
-
/** This shows the countdown on the format 00h 00m 00s */
|
|
34
|
-
SHORT,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* You five it some time, and a countdown is shown
|
|
39
|
-
**/
|
|
40
|
-
export default function Countdown({
|
|
41
|
-
timeRemaining,
|
|
42
|
-
onFinish,
|
|
43
|
-
model = CountdownTextModel.CLOCK,
|
|
44
|
-
options,
|
|
45
|
-
}: {
|
|
46
|
-
timeRemaining: number;
|
|
47
|
-
onFinish?: () => void;
|
|
48
|
-
model?: CountdownTextModel;
|
|
49
|
-
options?: {
|
|
50
|
-
/** Controls if the hours fragment should be shown */
|
|
51
|
-
hours: boolean;
|
|
52
|
-
};
|
|
53
|
-
}) {
|
|
54
|
-
const [t, setT] = useState<TimeObject>(() =>
|
|
55
|
-
calculateTimeFromTimespan(timeRemaining)
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
useLayoutEffect(() => {
|
|
59
|
-
setT(calculateTimeFromTimespan(timeRemaining));
|
|
60
|
-
}, [timeRemaining]);
|
|
61
|
-
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
const cl = setInterval(() => {
|
|
64
|
-
setT((prev) => {
|
|
65
|
-
let nextSecond = prev!.seconds - 1;
|
|
66
|
-
let nextMinute = prev!.minutes;
|
|
67
|
-
let nextHour = prev!.hours;
|
|
68
|
-
if (nextSecond < 0) {
|
|
69
|
-
nextSecond = 59;
|
|
70
|
-
nextMinute -= 1;
|
|
71
|
-
if (nextMinute < 0) {
|
|
72
|
-
nextMinute = 59;
|
|
73
|
-
nextHour -= 1;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (nextHour === 0 && nextMinute === 0 && nextSecond === 0) {
|
|
78
|
-
if (onFinish) onFinish();
|
|
79
|
-
clearInterval(cl);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
seconds: nextSecond,
|
|
84
|
-
minutes: nextMinute,
|
|
85
|
-
hours: nextHour,
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
}, 1000);
|
|
89
|
-
|
|
90
|
-
return () => {
|
|
91
|
-
clearInterval(cl);
|
|
92
|
-
};
|
|
93
|
-
}, [timeRemaining]);
|
|
94
|
-
|
|
95
|
-
const txt = useMemo(() => {
|
|
96
|
-
switch (model) {
|
|
97
|
-
case CountdownTextModel.CLOCK:
|
|
98
|
-
const hourFragment =
|
|
99
|
-
options?.hours ?? true ? `${IntegerFormatter.format(t!.hours)}:` : "";
|
|
100
|
-
return (
|
|
101
|
-
<Fragment>
|
|
102
|
-
{`${hourFragment}${IntegerFormatter.format(
|
|
103
|
-
t!.minutes
|
|
104
|
-
)}:${IntegerFormatter.format(t!.seconds)}`}
|
|
105
|
-
</Fragment>
|
|
106
|
-
);
|
|
107
|
-
case CountdownTextModel.SHORT:
|
|
108
|
-
const hourFragmentS =
|
|
109
|
-
options?.hours ?? true ? (
|
|
110
|
-
<>
|
|
111
|
-
{IntegerFormatter.format(t!.hours)}
|
|
112
|
-
<span>h</span>
|
|
113
|
-
</>
|
|
114
|
-
) : (
|
|
115
|
-
""
|
|
116
|
-
);
|
|
117
|
-
return (
|
|
118
|
-
<Fragment>
|
|
119
|
-
{hourFragmentS}
|
|
120
|
-
{IntegerFormatter.format(t!.minutes)}
|
|
121
|
-
<span>m</span>
|
|
122
|
-
{IntegerFormatter.format(t!.seconds)}
|
|
123
|
-
<span>s</span>
|
|
124
|
-
</Fragment>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
}, [t, model]);
|
|
128
|
-
|
|
129
|
-
return <span>{txt}</span>;
|
|
130
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect, useMemo, useRef } from "react";
|
|
2
|
-
import { currencyFormatterFactory } from "../../utils/formatters";
|
|
3
|
-
|
|
4
|
-
export function useCurrencyInput(
|
|
5
|
-
amount: string | undefined,
|
|
6
|
-
locale: string,
|
|
7
|
-
currency: string,
|
|
8
|
-
onChange?: (formattedCurrency: string) => void
|
|
9
|
-
) {
|
|
10
|
-
const formatter = useMemo(
|
|
11
|
-
() => currencyFormatterFactory(locale, currency),
|
|
12
|
-
[]
|
|
13
|
-
);
|
|
14
|
-
const number = useMemo(
|
|
15
|
-
() => Number(amount?.replace(/[^0-9]/g, "") || 0) / 100,
|
|
16
|
-
[amount]
|
|
17
|
-
);
|
|
18
|
-
const moneyFormat = useMemo(() => {
|
|
19
|
-
return formatter.format(number);
|
|
20
|
-
}, [number, formatter]);
|
|
21
|
-
|
|
22
|
-
const lastPosition = useRef(0);
|
|
23
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
24
|
-
useLayoutEffect(() => {
|
|
25
|
-
const el = inputRef.current!;
|
|
26
|
-
const putCaretOn = el.value.length - lastPosition.current;
|
|
27
|
-
el.setSelectionRange(putCaretOn, putCaretOn);
|
|
28
|
-
|
|
29
|
-
onChange?.(moneyFormat);
|
|
30
|
-
}, [moneyFormat]);
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
inputRef,
|
|
34
|
-
moneyFormat,
|
|
35
|
-
lastPosition,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { ComponentProps } from "react"
|
|
2
|
-
import Input from "../Input"
|
|
3
|
-
import { useCurrencyInput } from "./CurrencyInput.hook"
|
|
4
|
-
|
|
5
|
-
export default function CurrencyInput({ locale, value: amount, currency, onChange, placeholder, error, ...props }: Omit<ComponentProps<typeof Input>, 'onChange'> & { currency: string, onChange?: (formatted: string) => void, locale: string }) {
|
|
6
|
-
const { inputRef, moneyFormat, lastPosition } = useCurrencyInput(amount, locale, currency, onChange)
|
|
7
|
-
return (
|
|
8
|
-
<>
|
|
9
|
-
<Input
|
|
10
|
-
ref={inputRef}
|
|
11
|
-
placeholder={placeholder}
|
|
12
|
-
value={moneyFormat}
|
|
13
|
-
error={error as string}
|
|
14
|
-
data-testid={props['data-testid']}
|
|
15
|
-
onChange={({
|
|
16
|
-
target: { value, selectionStart = value.length },
|
|
17
|
-
}) => {
|
|
18
|
-
const diffFromEndToStart = value.length - selectionStart!
|
|
19
|
-
lastPosition.current = diffFromEndToStart
|
|
20
|
-
onChange?.(value)
|
|
21
|
-
}}
|
|
22
|
-
/>
|
|
23
|
-
</>
|
|
24
|
-
)
|
|
25
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Styles from "./Divider.module.scss";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Guess what this does
|
|
6
|
-
**/
|
|
7
|
-
export default function Divider({className = ""}: {className?: string}) {
|
|
8
|
-
return (
|
|
9
|
-
<>
|
|
10
|
-
<div className={`${Styles.container} ${className}`} />
|
|
11
|
-
</>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
File without changes
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
ChangeEvent,
|
|
3
|
-
ForwardedRef,
|
|
4
|
-
forwardRef,
|
|
5
|
-
useImperativeHandle,
|
|
6
|
-
useState,
|
|
7
|
-
} from "react";
|
|
8
|
-
import Input from "../Input";
|
|
9
|
-
|
|
10
|
-
export function validateEmail(email: string) {
|
|
11
|
-
return /@.*\./.test(email);
|
|
12
|
-
}
|
|
13
|
-
function _EmailInput(
|
|
14
|
-
props: Omit<React.ComponentProps<typeof Input>, "onChange" | "value"> & {
|
|
15
|
-
onChange: (email: string, isValid: boolean) => void;
|
|
16
|
-
value: string;
|
|
17
|
-
messages: {
|
|
18
|
-
invalidEmail: string;
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
ref: ForwardedRef<{
|
|
22
|
-
validateEmail: (email: string) => boolean;
|
|
23
|
-
}>
|
|
24
|
-
) {
|
|
25
|
-
const [localWarning, setLocalWarning] = useState(
|
|
26
|
-
props.value ? !validateEmail(props.value) : false
|
|
27
|
-
);
|
|
28
|
-
useImperativeHandle(ref, () => ({
|
|
29
|
-
validateEmail: validateEmail,
|
|
30
|
-
}));
|
|
31
|
-
function _handleInputChange(e: ChangeEvent<HTMLInputElement>) {
|
|
32
|
-
props.onChange(e.target.value, validateEmail(e.target.value));
|
|
33
|
-
}
|
|
34
|
-
return (
|
|
35
|
-
<Input
|
|
36
|
-
{...props}
|
|
37
|
-
error={localWarning ? props.messages.invalidEmail : props.error}
|
|
38
|
-
onBlur={({ target: { value } }) => {
|
|
39
|
-
setLocalWarning(!!value && !validateEmail(value));
|
|
40
|
-
}}
|
|
41
|
-
onFocus={() => setLocalWarning(false)}
|
|
42
|
-
onChange={_handleInputChange}
|
|
43
|
-
/>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* A Input based wrapper to handle inputs of email
|
|
49
|
-
**/
|
|
50
|
-
const EmailInput = forwardRef(_EmailInput);
|
|
51
|
-
export default EmailInput;
|