@onepercentio/one-ui 0.28.8 → 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 +4 -1
- 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,240 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
ElementRef,
|
|
3
|
+
PropsWithChildren,
|
|
4
|
+
ReactNode,
|
|
5
|
+
useEffect,
|
|
6
|
+
useLayoutEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from "react";
|
|
11
|
+
import throttle from "lodash/throttle";
|
|
12
|
+
import { ChartViewProps } from "./Chart.types";
|
|
13
|
+
import Styles from "./Chart.module.scss";
|
|
14
|
+
import { ChartDataTestIds } from "./Chart.e2e";
|
|
15
|
+
import AnchoredTooltip from "../AnchoredTooltip";
|
|
16
|
+
|
|
17
|
+
const DEFAULT_STYLE = {
|
|
18
|
+
lineColor: "#000",
|
|
19
|
+
pointColor: "#000",
|
|
20
|
+
textColor: "#fff",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function FloatingTooltip({
|
|
24
|
+
children,
|
|
25
|
+
x,
|
|
26
|
+
y,
|
|
27
|
+
hoverOnly,
|
|
28
|
+
height,
|
|
29
|
+
style,
|
|
30
|
+
}: {
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
hoverOnly: boolean;
|
|
35
|
+
height: number;
|
|
36
|
+
style: Pick<
|
|
37
|
+
NonNullable<NonNullable<ChartViewProps["style"]>[number]>,
|
|
38
|
+
"pointColor" | "lineColor" | "textColor"
|
|
39
|
+
>;
|
|
40
|
+
}) {
|
|
41
|
+
const [ope, setOpen] = useState(() => (hoverOnly ? false : true));
|
|
42
|
+
const ref = useRef<ElementRef<typeof AnchoredTooltip>>(null);
|
|
43
|
+
const circleRef = useRef<SVGCircleElement>(null);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const animateEl = circleRef.current!.children.item(0) as SVGAnimateElement;
|
|
46
|
+
let interval: NodeJS.Timeout;
|
|
47
|
+
animateEl.addEventListener("beginEvent", () => {
|
|
48
|
+
interval = setInterval(() => ref.current!.updatePosition(), 1000 / 24);
|
|
49
|
+
});
|
|
50
|
+
animateEl.addEventListener("endEvent", () => {
|
|
51
|
+
clearInterval(interval);
|
|
52
|
+
ref.current!.updatePosition();
|
|
53
|
+
});
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
const actions = useMemo(
|
|
57
|
+
() =>
|
|
58
|
+
hoverOnly
|
|
59
|
+
? {
|
|
60
|
+
onMouseEnter: () => setOpen(true),
|
|
61
|
+
onMouseOut: () => setOpen(false),
|
|
62
|
+
}
|
|
63
|
+
: {},
|
|
64
|
+
[hoverOnly]
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<>
|
|
69
|
+
<circle
|
|
70
|
+
ref={circleRef}
|
|
71
|
+
r={height * 0.01}
|
|
72
|
+
cx={x}
|
|
73
|
+
cy={y}
|
|
74
|
+
style={
|
|
75
|
+
{
|
|
76
|
+
"--point-color": style.pointColor,
|
|
77
|
+
} as any
|
|
78
|
+
}
|
|
79
|
+
{...actions}
|
|
80
|
+
>
|
|
81
|
+
<animate attributeName="cy" values={`${height};${y}`} dur="1s" />
|
|
82
|
+
</circle>
|
|
83
|
+
<AnchoredTooltip
|
|
84
|
+
ref={ref}
|
|
85
|
+
containInViewport={false}
|
|
86
|
+
anchorRef={circleRef as any}
|
|
87
|
+
open={ope}
|
|
88
|
+
className={Styles.tooltipContainer}
|
|
89
|
+
style={{
|
|
90
|
+
"--line-color": style.lineColor,
|
|
91
|
+
"--text-color": style.textColor,
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
{children as any}
|
|
95
|
+
</AnchoredTooltip>
|
|
96
|
+
</>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Draws a simple line chart with some animation
|
|
102
|
+
**/
|
|
103
|
+
export default function ChartView({
|
|
104
|
+
bounds: [[startX, endX, stepsX], [startY, endY, stepsY]],
|
|
105
|
+
data = [],
|
|
106
|
+
points = [],
|
|
107
|
+
label,
|
|
108
|
+
style: groupStyle = [],
|
|
109
|
+
}: ChartViewProps) {
|
|
110
|
+
const [dim, setDIm] = useState<{ width: number; height: number }>();
|
|
111
|
+
const chartRef = useRef<HTMLDivElement>(null);
|
|
112
|
+
useLayoutEffect(() => {
|
|
113
|
+
setDIm({
|
|
114
|
+
width: chartRef.current!.clientWidth,
|
|
115
|
+
height: chartRef.current!.clientHeight,
|
|
116
|
+
});
|
|
117
|
+
}, []);
|
|
118
|
+
const { width, height } = dim || {};
|
|
119
|
+
|
|
120
|
+
const howMuchStepsY = useMemo(
|
|
121
|
+
() => (endY - startY) / stepsY + 1,
|
|
122
|
+
[endY, startY, stepsY]
|
|
123
|
+
);
|
|
124
|
+
const yAxis = useMemo(() => {
|
|
125
|
+
return new Array(howMuchStepsY).fill(undefined).map((_, i) => {
|
|
126
|
+
return <span>{label.y(endY - i * stepsY)}</span>;
|
|
127
|
+
});
|
|
128
|
+
}, [startY, endY, stepsY, howMuchStepsY]);
|
|
129
|
+
|
|
130
|
+
const howMuchStepsX = useMemo(
|
|
131
|
+
() => (endX - startX) / stepsX + 1,
|
|
132
|
+
[endX, startX, stepsX]
|
|
133
|
+
);
|
|
134
|
+
const xAxis = useMemo(() => {
|
|
135
|
+
return new Array(howMuchStepsX).fill(undefined).map((_, i) => {
|
|
136
|
+
return <span>{label.x(startX + i * stepsX)}</span>;
|
|
137
|
+
});
|
|
138
|
+
}, [startX, endX, stepsX]);
|
|
139
|
+
|
|
140
|
+
const { polylines, tooltips } = useMemo(() => {
|
|
141
|
+
const calculate =
|
|
142
|
+
(end: number, start: number, overrideScale: number = 100) =>
|
|
143
|
+
(point: number) => {
|
|
144
|
+
const max = end - start;
|
|
145
|
+
const current = point - start;
|
|
146
|
+
|
|
147
|
+
return (current * overrideScale) / max;
|
|
148
|
+
};
|
|
149
|
+
const calculateX = calculate(endX, startX, width);
|
|
150
|
+
const calculateY = calculate(endY, startY, height);
|
|
151
|
+
return {
|
|
152
|
+
tooltips: points.map((pointsCategory, i) => {
|
|
153
|
+
const style = groupStyle[i] || DEFAULT_STYLE;
|
|
154
|
+
return pointsCategory.map(([x, y, label, onlyOnHover = false]) => {
|
|
155
|
+
return (
|
|
156
|
+
<FloatingTooltip
|
|
157
|
+
x={calculateX(x)}
|
|
158
|
+
y={height! - calculateY(y)}
|
|
159
|
+
height={height!}
|
|
160
|
+
style={style}
|
|
161
|
+
hoverOnly={onlyOnHover}
|
|
162
|
+
>
|
|
163
|
+
{label}
|
|
164
|
+
</FloatingTooltip>
|
|
165
|
+
);
|
|
166
|
+
});
|
|
167
|
+
}),
|
|
168
|
+
polylines: data.map((lineData, i) => {
|
|
169
|
+
const style = groupStyle[i] || DEFAULT_STYLE;
|
|
170
|
+
const calculateLines = (yOverride?: number) => {
|
|
171
|
+
return lineData
|
|
172
|
+
.map(
|
|
173
|
+
([x, y]) =>
|
|
174
|
+
`${calculateX(x)},${
|
|
175
|
+
yOverride === undefined ? height! - calculateY(y) : yOverride
|
|
176
|
+
}`
|
|
177
|
+
)
|
|
178
|
+
.join(" ");
|
|
179
|
+
};
|
|
180
|
+
return (
|
|
181
|
+
<polyline
|
|
182
|
+
strokeLinejoin="round"
|
|
183
|
+
strokeLinecap="round"
|
|
184
|
+
points={calculateLines()}
|
|
185
|
+
fill="none"
|
|
186
|
+
strokeWidth={5}
|
|
187
|
+
style={
|
|
188
|
+
{
|
|
189
|
+
"--line-color": style.lineColor,
|
|
190
|
+
} as any
|
|
191
|
+
}
|
|
192
|
+
>
|
|
193
|
+
<animate
|
|
194
|
+
attributeName="points"
|
|
195
|
+
attributeType="XML"
|
|
196
|
+
values={[calculateLines(height), calculateLines()].join("; ")}
|
|
197
|
+
dur="1s"
|
|
198
|
+
/>
|
|
199
|
+
</polyline>
|
|
200
|
+
);
|
|
201
|
+
}),
|
|
202
|
+
};
|
|
203
|
+
}, [data, width, height]);
|
|
204
|
+
|
|
205
|
+
const paddingY = useMemo(() => {
|
|
206
|
+
const stepSizeY = height! / (howMuchStepsY - 1);
|
|
207
|
+
return stepSizeY / 2;
|
|
208
|
+
}, [howMuchStepsY, height]);
|
|
209
|
+
|
|
210
|
+
const paddingX = useMemo(() => {
|
|
211
|
+
const stepSizeX = width! / (howMuchStepsX - 1);
|
|
212
|
+
return stepSizeX / 2;
|
|
213
|
+
}, [howMuchStepsX, width]);
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<div className={Styles.chartRoot}>
|
|
217
|
+
<div className={Styles.yAxis} data-testid={ChartDataTestIds.Y_AXIS}>
|
|
218
|
+
{yAxis}
|
|
219
|
+
</div>
|
|
220
|
+
<div ref={chartRef} className={Styles.chartContainer}>
|
|
221
|
+
{width && (
|
|
222
|
+
<svg
|
|
223
|
+
className={Styles.chart}
|
|
224
|
+
viewBox={`${-paddingX} ${-paddingY} ${width + paddingX * 2} ${
|
|
225
|
+
height! + paddingY * 2
|
|
226
|
+
}`}
|
|
227
|
+
preserveAspectRatio="none"
|
|
228
|
+
>
|
|
229
|
+
{polylines}
|
|
230
|
+
{tooltips}
|
|
231
|
+
</svg>
|
|
232
|
+
)}
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
<div className={Styles.xAxis} data-testid={ChartDataTestIds.X_AXIS}>
|
|
236
|
+
{xAxis}
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Chart.logic';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@import "../../assets/styles/index.scss";
|
|
2
|
+
|
|
3
|
+
.container {
|
|
4
|
+
display: flex;
|
|
5
|
+
line-height: 1.5em;
|
|
6
|
+
vertical-align: middle;
|
|
7
|
+
input {
|
|
8
|
+
max-width: 0px;
|
|
9
|
+
max-height: 0px;
|
|
10
|
+
width: 0;
|
|
11
|
+
height: 0;
|
|
12
|
+
opacity: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
> span:first-child {
|
|
16
|
+
visibility: visible;
|
|
17
|
+
width: 1.5em;
|
|
18
|
+
height: 1.5em;
|
|
19
|
+
border-radius: 0.45em;
|
|
20
|
+
background-image: url("../../assets/img/svg/checkbox.svg");
|
|
21
|
+
background-color: transparent;
|
|
22
|
+
transition: background-color 250ms, border 250ms, box-shadow 250ms;
|
|
23
|
+
border: 1px solid rgb(40, 43, 53);
|
|
24
|
+
box-shadow: 0px 0px 0px -4px $digitalBlue;
|
|
25
|
+
flex-shrink: 0;
|
|
26
|
+
|
|
27
|
+
&.wContent {
|
|
28
|
+
margin-right: 0.45em;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
> span:first-child.checked {
|
|
32
|
+
background-color: $digitalBlue;
|
|
33
|
+
border: 1px solid $digitalBlue;
|
|
34
|
+
box-shadow: 0px 0px 12px -4px $digitalBlue;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import { useOneUIConfig } from "../../context/OneUIProvider";
|
|
3
|
+
import Styles from "./CheckBox.module.scss";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A simple checkbox with nissan guidelines
|
|
7
|
+
**/
|
|
8
|
+
export default function CheckBox({
|
|
9
|
+
checked,
|
|
10
|
+
onToggle,
|
|
11
|
+
label,
|
|
12
|
+
className = "",
|
|
13
|
+
size = undefined,
|
|
14
|
+
groupId,
|
|
15
|
+
value,
|
|
16
|
+
...props
|
|
17
|
+
}: PropsWithChildren<{
|
|
18
|
+
checked: boolean;
|
|
19
|
+
onToggle: (checked: boolean) => void;
|
|
20
|
+
label: React.ReactNode;
|
|
21
|
+
className?: string;
|
|
22
|
+
size?: number;
|
|
23
|
+
groupId: string;
|
|
24
|
+
value: string;
|
|
25
|
+
}> &
|
|
26
|
+
Omit<
|
|
27
|
+
React.DetailedHTMLProps<
|
|
28
|
+
React.HTMLAttributes<HTMLSpanElement>,
|
|
29
|
+
HTMLSpanElement
|
|
30
|
+
>,
|
|
31
|
+
"onToggle"
|
|
32
|
+
>) {
|
|
33
|
+
const Checkbox = useOneUIConfig(
|
|
34
|
+
"component.checkbox.Component",
|
|
35
|
+
"span" as any
|
|
36
|
+
) as any;
|
|
37
|
+
return (
|
|
38
|
+
<label
|
|
39
|
+
className={`${Styles.container} ${className}`}
|
|
40
|
+
style={{ fontSize: size }}
|
|
41
|
+
onClick={(e) => {
|
|
42
|
+
onToggle(!checked);
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<Checkbox
|
|
47
|
+
{...props}
|
|
48
|
+
className={`${checked ? Styles.checked : ""} ${
|
|
49
|
+
label ? Styles.wContent : ""
|
|
50
|
+
}`}
|
|
51
|
+
/>
|
|
52
|
+
<input
|
|
53
|
+
type="checkbox"
|
|
54
|
+
name={groupId}
|
|
55
|
+
id={value}
|
|
56
|
+
checked={checked}
|
|
57
|
+
readOnly
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
{label}
|
|
61
|
+
</label>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CheckBox';
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CodeInput';
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|