@rabbitio/ui-kit 1.0.0-beta.45 → 1.0.0-beta.47
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/.husky/pre-push +1 -1
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +10957 -0
- package/coverage/coverage-final.json +67 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +701 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/rabbit-ui-kit/index.html +116 -0
- package/coverage/rabbit-ui-kit/index.js.html +88 -0
- package/coverage/rabbit-ui-kit/src/common/adapters/axiosAdapter.js.html +190 -0
- package/coverage/rabbit-ui-kit/src/common/adapters/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/common/amountUtils.js.html +1393 -0
- package/coverage/rabbit-ui-kit/src/common/errorUtils.js.html +211 -0
- package/coverage/rabbit-ui-kit/src/common/external-apis/apiGroups.js.html +250 -0
- package/coverage/rabbit-ui-kit/src/common/external-apis/index.html +131 -0
- package/coverage/rabbit-ui-kit/src/common/external-apis/ipAddressProviders.js.html +499 -0
- package/coverage/rabbit-ui-kit/src/common/fiatCurrenciesService.js.html +568 -0
- package/coverage/rabbit-ui-kit/src/common/index.html +146 -0
- package/coverage/rabbit-ui-kit/src/common/models/blockchain.js.html +115 -0
- package/coverage/rabbit-ui-kit/src/common/models/coin.js.html +556 -0
- package/coverage/rabbit-ui-kit/src/common/models/index.html +146 -0
- package/coverage/rabbit-ui-kit/src/common/models/protocol.js.html +100 -0
- package/coverage/rabbit-ui-kit/src/common/utils/cache.js.html +889 -0
- package/coverage/rabbit-ui-kit/src/common/utils/emailAPI.js.html +139 -0
- package/coverage/rabbit-ui-kit/src/common/utils/index.html +161 -0
- package/coverage/rabbit-ui-kit/src/common/utils/logging/index.html +131 -0
- package/coverage/rabbit-ui-kit/src/common/utils/logging/logger.js.html +229 -0
- package/coverage/rabbit-ui-kit/src/common/utils/logging/logsStorage.js.html +268 -0
- package/coverage/rabbit-ui-kit/src/common/utils/postponeExecution.js.html +118 -0
- package/coverage/rabbit-ui-kit/src/common/utils/safeStringify.js.html +235 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/AssetIcon/AssetIcon.jsx.html +250 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/AssetIcon/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/AssetSelection/AssetSelection.jsx.html +364 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/AssetSelection/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +217 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/BackgroundTitle/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/LoadingDots/LoadingDots.jsx.html +256 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/LoadingDots/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/NoticeIcon/NoticeIcon.jsx.html +298 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/NoticeIcon/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/SupportChat/SupportChat.jsx.html +229 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/SupportChat/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/TitleBox/TitleBox.jsx.html +574 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/TitleBox/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/Tooltip/Tooltip.jsx.html +370 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/Tooltip/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/Validation/Validation.jsx.html +475 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/Validation/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/buttons/Button/Button.jsx.html +802 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/buttons/Button/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/buttons/Close/Close.jsx.html +277 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/buttons/Close/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/buttons/LinkButton/LinkButton.jsx.html +448 -0
- package/coverage/rabbit-ui-kit/src/components/atoms/buttons/LinkButton/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/hooks/index.html +131 -0
- package/coverage/rabbit-ui-kit/src/components/hooks/useCallHandlingErrors.js.html +163 -0
- package/coverage/rabbit-ui-kit/src/components/hooks/useReferredState.js.html +157 -0
- package/coverage/rabbit-ui-kit/src/components/molecules/AmountInput/AmountInput.jsx.html +1510 -0
- package/coverage/rabbit-ui-kit/src/components/molecules/AmountInput/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/organisms/Dialog/Dialog.jsx.html +1630 -0
- package/coverage/rabbit-ui-kit/src/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +451 -0
- package/coverage/rabbit-ui-kit/src/components/organisms/Dialog/DialogButtons/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +2077 -0
- package/coverage/rabbit-ui-kit/src/components/organisms/Dialog/DialogStep/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/organisms/Dialog/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/organisms/SwapForm/SwapForm.jsx.html +3538 -0
- package/coverage/rabbit-ui-kit/src/components/organisms/SwapForm/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/components/utils/index.html +161 -0
- package/coverage/rabbit-ui-kit/src/components/utils/inputValueProviders.js.html +259 -0
- package/coverage/rabbit-ui-kit/src/components/utils/textUtils.js.html +139 -0
- package/coverage/rabbit-ui-kit/src/components/utils/uiUtils.js.html +127 -0
- package/coverage/rabbit-ui-kit/src/components/utils/urlQueryUtils.js.html +346 -0
- package/coverage/rabbit-ui-kit/src/constants/organisms/dialog/DialogStep/dialogStep.js.html +88 -0
- package/coverage/rabbit-ui-kit/src/constants/organisms/dialog/DialogStep/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/constants/organisms/dialog/dialog.js.html +172 -0
- package/coverage/rabbit-ui-kit/src/constants/organisms/dialog/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/index.js.html +310 -0
- package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/cacheAndConcurrentRequestsResolver.js.html +1762 -0
- package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/cachedRobustExternalApiCallerService.js.html +649 -0
- package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/cancelProcessing.js.html +172 -0
- package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/concurrentCalculationsMetadataHolder.js.html +394 -0
- package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/externalApiProvider.js.html +553 -0
- package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/externalServicesStatsCollector.js.html +331 -0
- package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/index.html +206 -0
- package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/robustExternalAPICallerService.js.html +1249 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/index.html +131 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +727 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +2899 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/baseSwapCreationInfo.js.html +214 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwap.js.html +304 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwapWithFiatData.js.html +487 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/index.html +146 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/services/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/services/publicSwapService.js.html +2191 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/utils/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/utils/swapUtils.js.html +742 -0
- package/coverage/rabbit-ui-kit/stories/atoms/BackgroundTitle.stories.jsx.html +202 -0
- package/coverage/rabbit-ui-kit/stories/atoms/LoadingDots.stories.jsx.html +226 -0
- package/coverage/rabbit-ui-kit/stories/atoms/Validation.stories.jsx.html +178 -0
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/Button.stories.jsx.html +946 -0
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/Close.stories.jsx.html +211 -0
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/LinkButton.stories.jsx.html +298 -0
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/index.html +146 -0
- package/coverage/rabbit-ui-kit/stories/atoms/index.html +146 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/Dialog.stories.jsx.html +574 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +328 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/index.html +116 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +352 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/index.html +116 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/index.html +116 -0
- package/coverage/rabbit-ui-kit/stories/stubs/exampleContent.jsx.html +145 -0
- package/coverage/rabbit-ui-kit/stories/stubs/index.html +116 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/dist/index.cjs +1634 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +17456 -110
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +1368 -111
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1626 -131
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1637 -134
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -1
- package/src/assets/image/icons/arrow-darker.svg +14 -0
- package/src/assets/image/icons/dark-rectangle.svg +3 -0
- package/src/assets/image/icons/wallet-gray-small.svg +6 -0
- package/src/components/atoms/AssetSelection/AssetSelection.jsx +93 -0
- package/src/components/atoms/AssetSelection/asset-selection.module.scss +55 -0
- package/src/components/atoms/NoticeIcon/NoticeIcon.jsx +71 -0
- package/src/components/atoms/NoticeIcon/notice-icon.module.scss +14 -0
- package/src/components/atoms/TitleBox/TitleBox.jsx +163 -0
- package/src/components/atoms/TitleBox/title-box.module.scss +30 -0
- package/src/components/atoms/Tooltip/Tooltip.jsx +95 -0
- package/src/components/atoms/Tooltip/tooltip.module.scss +231 -0
- package/src/components/atoms/Validation/Validation.jsx +1 -1
- package/src/components/molecules/AmountInput/AmountInput.jsx +475 -0
- package/src/components/molecules/AmountInput/amount-input.module.scss +189 -0
- package/src/components/organisms/SwapForm/SwapForm.jsx +1151 -0
- package/src/components/organisms/SwapForm/swap-form.module.scss +120 -0
- package/src/components/utils/textUtils.js +18 -0
- package/src/index.js +11 -1
- package/styles/index.scss +11 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rabbitio/ui-kit",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.47",
|
|
4
4
|
"description": "Rabbit.io react.js components kit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"axios": "1.6.7",
|
|
46
46
|
"bignumber.js": "9.1.2",
|
|
47
47
|
"body-scroll-lock": "3.1.5",
|
|
48
|
+
"clipboard-copy": "4.0.1",
|
|
48
49
|
"eventbusjs": "0.2.0",
|
|
49
50
|
"jshashes": "1.0.8",
|
|
50
51
|
"react": ">=18.2.0",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<svg
|
|
2
|
+
width="16"
|
|
3
|
+
height="16"
|
|
4
|
+
viewBox="0 0 16 16"
|
|
5
|
+
fill="none"
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
>
|
|
8
|
+
<path
|
|
9
|
+
d="M12.2431 6L8.00045 10.2426L3.75781 6"
|
|
10
|
+
stroke="#232d42" stroke-width="2"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
13
|
+
/>
|
|
14
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M12.6265 10.4119V12.2379C12.6265 12.7338 12.193 13.1356 11.6583 13.1356H3.26825C2.73352 13.1356 2.29999 12.7338 2.29999 12.2379V3.79771C2.29999 3.30178 2.73352 2.89999 3.26825 2.89999H11.6583C12.193 2.89999 12.6265 3.30178 12.6265 3.79771V5.84996" stroke="#8F95A2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.0952 10.1922H10.2664C9.0847 10.1922 8.12704 9.23439 8.12704 8.05246C8.12704 6.87052 9.0847 5.91269 10.2664 5.91269H13.0952C13.4072 5.91269 13.66 6.16552 13.66 6.47758V9.62689C13.66 9.93939 13.4072 10.1922 13.0952 10.1922Z" stroke="#8F95A2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4
|
+
<path d="M2.29999 4.73721H4.99884" stroke="#8F95A2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
<path d="M2.29999 11.3122H4.99884" stroke="#8F95A2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
|
|
4
|
+
import s from "./asset-selection.module.scss";
|
|
5
|
+
|
|
6
|
+
// import arrowIcon from "../../../assets/image/icons/arrow-darker.svg";
|
|
7
|
+
import { AssetIcon } from "../AssetIcon/AssetIcon.jsx";
|
|
8
|
+
|
|
9
|
+
import { useCallHandlingErrors } from "../../hooks/useCallHandlingErrors.js";
|
|
10
|
+
|
|
11
|
+
const ArrowIcon = () => (
|
|
12
|
+
<svg
|
|
13
|
+
width="16"
|
|
14
|
+
height="16"
|
|
15
|
+
viewBox="0 0 16 16"
|
|
16
|
+
fill="none"
|
|
17
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
18
|
+
>
|
|
19
|
+
<path
|
|
20
|
+
d="M12.2431 6L8.00045 10.2426L3.75781 6"
|
|
21
|
+
stroke="#232d42"
|
|
22
|
+
stroke-width="2"
|
|
23
|
+
stroke-linecap="round"
|
|
24
|
+
stroke-linejoin="round"
|
|
25
|
+
/>
|
|
26
|
+
</svg>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Component-button for triggering selecting an asset.
|
|
31
|
+
*
|
|
32
|
+
* @component
|
|
33
|
+
* @param {Function} handleClick - The function to call when the component is clicked
|
|
34
|
+
* @param {boolean} disabled - If true, disables click functionality
|
|
35
|
+
* @param {string} assetIconSrc - The source URL for the asset icon
|
|
36
|
+
* @param {string} [protocolName] - The name of the protocol, if any
|
|
37
|
+
* @param {string} [assetIconProtocolSrc] - The source URL for the asset protocol icon
|
|
38
|
+
* @param {string} [fallbackSrc] - The fallback source URL if the main asset icon fails to load
|
|
39
|
+
*/
|
|
40
|
+
export const AssetSelection = ({
|
|
41
|
+
handleClick = () => {},
|
|
42
|
+
disabled = false,
|
|
43
|
+
assetIconSrc,
|
|
44
|
+
protocolName,
|
|
45
|
+
assetIconProtocolSrc = null,
|
|
46
|
+
fallbackSrc,
|
|
47
|
+
}) => {
|
|
48
|
+
const handleError = useCallHandlingErrors();
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div
|
|
52
|
+
className={
|
|
53
|
+
s["asset-selection"] + " " + (disabled ? s["disabled"] : "")
|
|
54
|
+
}
|
|
55
|
+
onClick={disabled ? () => {} : (e) => handleError(handleClick, e)}
|
|
56
|
+
>
|
|
57
|
+
<div className={s["asset-selection-icon-wrapper"]}>
|
|
58
|
+
<AssetIcon
|
|
59
|
+
small
|
|
60
|
+
assetIconSrc={assetIconSrc}
|
|
61
|
+
assetIconProtocolSrc={assetIconProtocolSrc}
|
|
62
|
+
fallbackSrc={fallbackSrc}
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
{protocolName ? (
|
|
66
|
+
<div className={s["asset-selection-protocol-wrapper"]}>
|
|
67
|
+
{protocolName}
|
|
68
|
+
</div>
|
|
69
|
+
) : (
|
|
70
|
+
""
|
|
71
|
+
)}
|
|
72
|
+
<div className={s["arrow"]}>
|
|
73
|
+
<ArrowIcon />
|
|
74
|
+
</div>
|
|
75
|
+
{/*<img src={arrowIcon} className="arrow" alt=""></img>*/}
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
AssetSelection.propTypes = {
|
|
81
|
+
handleClick: PropTypes.func,
|
|
82
|
+
disabled: PropTypes.bool,
|
|
83
|
+
assetIconSrc: PropTypes.string.isRequired,
|
|
84
|
+
protocolName: PropTypes.string,
|
|
85
|
+
assetIconProtocolSrc: PropTypes.string,
|
|
86
|
+
fallbackSrc: PropTypes.string,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
AssetSelection.defaultProps = {
|
|
90
|
+
handleClick: () => {},
|
|
91
|
+
disabled: false,
|
|
92
|
+
assetIconProtocolSrc: null,
|
|
93
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
@import "../../../../styles/index";
|
|
2
|
+
|
|
3
|
+
.asset-selection {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
background-color: $white;
|
|
7
|
+
border-radius: 100px;
|
|
8
|
+
user-select: none;
|
|
9
|
+
box-shadow: $shadowOutlineStatic;
|
|
10
|
+
transition: all 0.2s ease;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
|
|
13
|
+
@media (hover: hover) {
|
|
14
|
+
&:hover:not(.disabled) {
|
|
15
|
+
box-shadow: $shadowOutlineHover;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.disabled {
|
|
20
|
+
opacity: 0.5;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&:active:not(.disabled),
|
|
24
|
+
&.active:not(.disabled) {
|
|
25
|
+
box-shadow: $shadowOutlineActive;
|
|
26
|
+
transition: all 0.03s ease;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&-protocol-wrapper {
|
|
30
|
+
background-color: LightColor("tosca-20");
|
|
31
|
+
color: SolidColor("tosca");
|
|
32
|
+
padding: 2px 5px;
|
|
33
|
+
font-size: 8px;
|
|
34
|
+
border-radius: 50px;
|
|
35
|
+
font-weight: $bold;
|
|
36
|
+
margin-right: 3px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&-icon-wrapper {
|
|
40
|
+
padding: 10px 5px 10px 10px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
h6 {
|
|
44
|
+
color: SolidColor("dark");
|
|
45
|
+
font-weight: $semi-bold;
|
|
46
|
+
|
|
47
|
+
margin: 1px 7px 0 2px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.arrow {
|
|
51
|
+
margin: 10px 10px 10px 0;
|
|
52
|
+
transform: rotate(-90deg);
|
|
53
|
+
height: 14px;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
|
|
4
|
+
import s from "./notice-icon.module.scss";
|
|
5
|
+
// import exclamationIcon from "../../../assets/image/icons/failed-validation-icon.svg";
|
|
6
|
+
|
|
7
|
+
import { handleClickOutside } from "../../utils/uiUtils.js";
|
|
8
|
+
import { Tooltip, TOOLTIP_POSITIONS } from "../Tooltip/Tooltip.jsx";
|
|
9
|
+
import { FailedValidationIcon } from "../Validation/Validation.jsx";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A component that displays a notice icon with optional tooltip.
|
|
13
|
+
*
|
|
14
|
+
* @component
|
|
15
|
+
* @param {string} noticeText - The text to display inside the tooltip.
|
|
16
|
+
* @param {string} [titleNoticeIcon] - The source URL for the icon displayed on the notice.
|
|
17
|
+
* @param {string} tooltipPosition - Position for the tooltip relative to the icon.
|
|
18
|
+
*/
|
|
19
|
+
export const NoticeIcon = ({
|
|
20
|
+
noticeText,
|
|
21
|
+
titleNoticeIcon = "",
|
|
22
|
+
tooltipPosition = TOOLTIP_POSITIONS.TOP,
|
|
23
|
+
}) => {
|
|
24
|
+
const [showTooltip, setShowTooltip] = useState(false);
|
|
25
|
+
|
|
26
|
+
const noticeRef = useRef();
|
|
27
|
+
|
|
28
|
+
useEffect(
|
|
29
|
+
() => handleClickOutside([noticeRef], () => setShowTooltip(false)),
|
|
30
|
+
[]
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div ref={noticeRef} className={s["notice-icon"]}>
|
|
35
|
+
{titleNoticeIcon ? (
|
|
36
|
+
<img
|
|
37
|
+
// src={titleNoticeIcon ? titleNoticeIcon : exclamationIcon}
|
|
38
|
+
src={titleNoticeIcon}
|
|
39
|
+
alt="title icon"
|
|
40
|
+
onClick={() => setShowTooltip((prev) => !prev)}
|
|
41
|
+
className={s["notice-icon-image"]}
|
|
42
|
+
/>
|
|
43
|
+
) : (
|
|
44
|
+
<div className={s["notice-icon-image"]}>
|
|
45
|
+
<FailedValidationIcon />
|
|
46
|
+
</div>
|
|
47
|
+
)}
|
|
48
|
+
<div className={s["notice-icon-tooltip"]}>
|
|
49
|
+
<Tooltip
|
|
50
|
+
showTooltip={showTooltip}
|
|
51
|
+
handleClick={() => setShowTooltip(false)}
|
|
52
|
+
wide={true}
|
|
53
|
+
position={tooltipPosition}
|
|
54
|
+
>
|
|
55
|
+
{noticeText}
|
|
56
|
+
</Tooltip>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
NoticeIcon.propTypes = {
|
|
63
|
+
noticeText: PropTypes.string.isRequired,
|
|
64
|
+
titleNoticeIcon: PropTypes.string,
|
|
65
|
+
tooltipPosition: PropTypes.oneOf(Object.values(TOOLTIP_POSITIONS)),
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
NoticeIcon.defaultProps = {
|
|
69
|
+
titleNoticeIcon: "",
|
|
70
|
+
tooltipPosition: TOOLTIP_POSITIONS.TOP,
|
|
71
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
|
|
4
|
+
import s from "./title-box.module.scss";
|
|
5
|
+
|
|
6
|
+
import { useCallHandlingErrors } from "../../hooks/useCallHandlingErrors.js";
|
|
7
|
+
import { copyBrowserTextToClipboard } from "../../utils/textUtils.js";
|
|
8
|
+
|
|
9
|
+
import { NoticeIcon } from "../NoticeIcon/NoticeIcon.jsx";
|
|
10
|
+
import { LinkButton } from "../buttons/LinkButton/LinkButton.jsx";
|
|
11
|
+
import { Tooltip, TOOLTIP_POSITIONS } from "../Tooltip/Tooltip.jsx";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A box component for displaying a title with optional controls like buttons or icons and any children inside.
|
|
15
|
+
*
|
|
16
|
+
* @component
|
|
17
|
+
* @param {string} title - The main title text.
|
|
18
|
+
* @param {string} linkText - The text for the link button, if any.
|
|
19
|
+
* @param {Function} linkButtonClick - The function to execute when the link button is clicked.
|
|
20
|
+
* @param {boolean} isLinkButtonDisabled - Determines if the link button is disabled.
|
|
21
|
+
* @param {React.ReactNode} children - Child components to be rendered.
|
|
22
|
+
* @param {boolean} linkButtonLoader - Displays a loader animation on the link button if true.
|
|
23
|
+
* @param {boolean} fullWidth - If true, the title box will take full width of its container.
|
|
24
|
+
* @param {string} titleNoticeText - The text for a notice icon tooltip.
|
|
25
|
+
* @param {string} titleNoticeIcon - The icon for the notice tooltip.
|
|
26
|
+
* @param {string} titleNoticePosition - Tooltip position for the notice icon.
|
|
27
|
+
* @param {boolean} bigTitle - If true, uses a larger font size for the title.
|
|
28
|
+
* @param {boolean} transparentTitle - If true, the title has a transparent background.
|
|
29
|
+
* @param {string} copyButtonText - The text for the copy button.
|
|
30
|
+
* @param {string} copyButtonContent - The content to be copied to the clipboard.
|
|
31
|
+
* @param {string} copyButtonTooltipContent - Tooltip content displayed after copying.
|
|
32
|
+
*/
|
|
33
|
+
export const TitleBox = ({
|
|
34
|
+
title = "",
|
|
35
|
+
linkText = "",
|
|
36
|
+
linkButtonClick = (resetButtonLoader) => {},
|
|
37
|
+
isLinkButtonDisabled = false,
|
|
38
|
+
children,
|
|
39
|
+
linkButtonLoader = false,
|
|
40
|
+
fullWidth = true,
|
|
41
|
+
titleNoticeText = "",
|
|
42
|
+
titleNoticeIcon,
|
|
43
|
+
titleNoticePosition,
|
|
44
|
+
bigTitle = false,
|
|
45
|
+
transparentTitle = false,
|
|
46
|
+
copyButtonText,
|
|
47
|
+
copyButtonContent,
|
|
48
|
+
copyButtonTooltipContent,
|
|
49
|
+
}) => {
|
|
50
|
+
const handleError = useCallHandlingErrors();
|
|
51
|
+
|
|
52
|
+
const transparentTitleClass = transparentTitle
|
|
53
|
+
? s["transparent-title"]
|
|
54
|
+
: "";
|
|
55
|
+
|
|
56
|
+
const [showCopyNotice, setShowCopyNotice] = useState(false);
|
|
57
|
+
|
|
58
|
+
const handleCopyButton = (e) => {
|
|
59
|
+
handleError(() => {
|
|
60
|
+
setShowCopyNotice(true);
|
|
61
|
+
copyBrowserTextToClipboard(copyButtonContent);
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
setShowCopyNotice(false);
|
|
64
|
+
}, 1500);
|
|
65
|
+
}, e);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div
|
|
70
|
+
className={`${s["title-box"]} ${fullWidth ? s["full-width"] : ""}`}
|
|
71
|
+
>
|
|
72
|
+
{title || titleNoticeText || linkText ? (
|
|
73
|
+
<div className={s["title-box-wrapper"]}>
|
|
74
|
+
{bigTitle ? (
|
|
75
|
+
<h5
|
|
76
|
+
className={
|
|
77
|
+
s["title-box-wrapper-title"] +
|
|
78
|
+
" " +
|
|
79
|
+
transparentTitleClass
|
|
80
|
+
}
|
|
81
|
+
>
|
|
82
|
+
{title}
|
|
83
|
+
</h5>
|
|
84
|
+
) : (
|
|
85
|
+
<h6
|
|
86
|
+
className={
|
|
87
|
+
s["title-box-wrapper-title"] +
|
|
88
|
+
" " +
|
|
89
|
+
transparentTitleClass
|
|
90
|
+
}
|
|
91
|
+
>
|
|
92
|
+
{title}
|
|
93
|
+
</h6>
|
|
94
|
+
)}
|
|
95
|
+
{titleNoticeText ? (
|
|
96
|
+
<NoticeIcon
|
|
97
|
+
noticeText={titleNoticeText}
|
|
98
|
+
titleNoticeIcon={titleNoticeIcon}
|
|
99
|
+
tooltipPosition={titleNoticePosition}
|
|
100
|
+
/>
|
|
101
|
+
) : null}
|
|
102
|
+
{copyButtonContent && copyButtonText ? (
|
|
103
|
+
<div className={s["title-box-wrapper-link-button"]}>
|
|
104
|
+
<LinkButton
|
|
105
|
+
content={copyButtonText}
|
|
106
|
+
onClick={handleCopyButton}
|
|
107
|
+
isLoadable={false}
|
|
108
|
+
isDisabled={false}
|
|
109
|
+
/>
|
|
110
|
+
<Tooltip
|
|
111
|
+
position={TOOLTIP_POSITIONS.TOP_LEFT}
|
|
112
|
+
showTooltip={showCopyNotice}
|
|
113
|
+
>
|
|
114
|
+
{copyButtonTooltipContent}
|
|
115
|
+
</Tooltip>
|
|
116
|
+
</div>
|
|
117
|
+
) : linkText ? (
|
|
118
|
+
<div className={s["title-box-wrapper-link-button"]}>
|
|
119
|
+
<LinkButton
|
|
120
|
+
content={linkText}
|
|
121
|
+
onClick={linkButtonClick}
|
|
122
|
+
isLoadable={linkButtonLoader}
|
|
123
|
+
isDisabled={isLinkButtonDisabled}
|
|
124
|
+
/>
|
|
125
|
+
</div>
|
|
126
|
+
) : null}
|
|
127
|
+
</div>
|
|
128
|
+
) : null}
|
|
129
|
+
{children}
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
TitleBox.propTypes = {
|
|
135
|
+
title: PropTypes.string,
|
|
136
|
+
linkText: PropTypes.string,
|
|
137
|
+
linkButtonClick: PropTypes.func,
|
|
138
|
+
isLinkButtonDisabled: PropTypes.bool,
|
|
139
|
+
children: PropTypes.node,
|
|
140
|
+
linkButtonLoader: PropTypes.bool,
|
|
141
|
+
fullWidth: PropTypes.bool,
|
|
142
|
+
titleNoticeText: PropTypes.string,
|
|
143
|
+
titleNoticeIcon: PropTypes.string,
|
|
144
|
+
titleNoticePosition: PropTypes.string,
|
|
145
|
+
bigTitle: PropTypes.bool,
|
|
146
|
+
transparentTitle: PropTypes.bool,
|
|
147
|
+
copyButtonText: PropTypes.string,
|
|
148
|
+
copyButtonContent: PropTypes.string,
|
|
149
|
+
copyButtonTooltipContent: PropTypes.string,
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
TitleBox.defaultProps = {
|
|
153
|
+
title: "",
|
|
154
|
+
linkText: "",
|
|
155
|
+
linkButtonClick: () => {},
|
|
156
|
+
isLinkButtonDisabled: false,
|
|
157
|
+
linkButtonLoader: false,
|
|
158
|
+
fullWidth: true,
|
|
159
|
+
titleNoticeText: "",
|
|
160
|
+
titleNoticePosition: TOOLTIP_POSITIONS.TOP,
|
|
161
|
+
bigTitle: false,
|
|
162
|
+
transparentTitle: false,
|
|
163
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@import "../../../../styles/index";
|
|
2
|
+
|
|
3
|
+
.title-box {
|
|
4
|
+
&.full-width {
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
&-wrapper {
|
|
9
|
+
width: 100%;
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
flex-grow: 1;
|
|
14
|
+
margin-bottom: Margin("1");
|
|
15
|
+
gap: Margin("2");
|
|
16
|
+
min-height: 26px;
|
|
17
|
+
|
|
18
|
+
&-title {
|
|
19
|
+
color: SolidColor("grey");
|
|
20
|
+
font-weight: $semi-bold;
|
|
21
|
+
&.transparent-title {
|
|
22
|
+
color: rgba($white, 0.2);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&-link-button {
|
|
27
|
+
position: relative;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CSSTransition } from "react-transition-group";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
|
|
5
|
+
import s from "./tooltip.module.scss";
|
|
6
|
+
// import darkRectangle from "../../../assets/image/icons/dark-rectangle.svg";
|
|
7
|
+
|
|
8
|
+
import { useCallHandlingErrors } from "../../hooks/useCallHandlingErrors.js";
|
|
9
|
+
|
|
10
|
+
const DarkRectangle = () => (
|
|
11
|
+
<svg
|
|
12
|
+
width="25"
|
|
13
|
+
height="13"
|
|
14
|
+
viewBox="0 0 25 13"
|
|
15
|
+
fill="none"
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
>
|
|
18
|
+
<path
|
|
19
|
+
fill-rule="evenodd"
|
|
20
|
+
clip-rule="evenodd"
|
|
21
|
+
d="M12.5 13L25 0H0L12.5 13Z"
|
|
22
|
+
fill="#232D42"
|
|
23
|
+
/>
|
|
24
|
+
</svg>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export const TOOLTIP_POSITIONS = {
|
|
28
|
+
TOP: "top",
|
|
29
|
+
LEFT: "left",
|
|
30
|
+
RIGHT: "right",
|
|
31
|
+
BOTTOM: "bottom",
|
|
32
|
+
TOP_LEFT: "top-left",
|
|
33
|
+
TOP_RIGHT: "top-right",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Tooltip component for displaying contextual information.
|
|
38
|
+
*
|
|
39
|
+
* @component
|
|
40
|
+
* @param {React.ReactNode} children - The content to display inside the tooltip.
|
|
41
|
+
* @param {boolean} showTooltip - Controls whether the tooltip is visible.
|
|
42
|
+
* @param {Function} handleClick - Handler for click events.
|
|
43
|
+
* @param {boolean} wide - If true, applies a wider style to the tooltip.
|
|
44
|
+
* @param {string} position - One of the predefined positions for the tooltip.
|
|
45
|
+
* @param {boolean} ignorePointerEvents - If true, the tooltip will not react to pointer events.
|
|
46
|
+
*/
|
|
47
|
+
export const Tooltip = ({
|
|
48
|
+
children,
|
|
49
|
+
showTooltip,
|
|
50
|
+
handleClick = () => {},
|
|
51
|
+
wide = false,
|
|
52
|
+
position = TOOLTIP_POSITIONS.TOP,
|
|
53
|
+
ignorePointerEvents = false,
|
|
54
|
+
}) => {
|
|
55
|
+
const handleError = useCallHandlingErrors();
|
|
56
|
+
|
|
57
|
+
const onClick = (e) => {
|
|
58
|
+
e.stopPropagation();
|
|
59
|
+
handleClick();
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<CSSTransition in={showTooltip} timeout={400} unmountOnExit>
|
|
64
|
+
<span
|
|
65
|
+
className={`${s["tooltip"]} ${wide ? s["wide"] : ""} ${
|
|
66
|
+
s[position]
|
|
67
|
+
} ${ignorePointerEvents ? s["ignore-pointer"] : ""}`}
|
|
68
|
+
onClick={(e) => handleError(onClick, e)}
|
|
69
|
+
onDoubleClick={(e) =>
|
|
70
|
+
handleError((e) => e.stopPropagation(), e)
|
|
71
|
+
}
|
|
72
|
+
>
|
|
73
|
+
<DarkRectangle />
|
|
74
|
+
{/*<img src={darkRectangle} alt="dark rectangle" />*/}
|
|
75
|
+
{children}
|
|
76
|
+
</span>
|
|
77
|
+
</CSSTransition>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
Tooltip.propTypes = {
|
|
82
|
+
children: PropTypes.node.isRequired,
|
|
83
|
+
showTooltip: PropTypes.bool.isRequired,
|
|
84
|
+
handleClick: PropTypes.func,
|
|
85
|
+
wide: PropTypes.bool,
|
|
86
|
+
position: PropTypes.oneOf(Object.values(TOOLTIP_POSITIONS)),
|
|
87
|
+
ignorePointerEvents: PropTypes.bool,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
Tooltip.defaultProps = {
|
|
91
|
+
handleClick: () => {},
|
|
92
|
+
wide: false,
|
|
93
|
+
position: TOOLTIP_POSITIONS.TOP,
|
|
94
|
+
ignorePointerEvents: false,
|
|
95
|
+
};
|