@rabbitio/ui-kit 1.0.0-beta.43 → 1.0.0-beta.46

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.
Files changed (164) hide show
  1. package/coverage/clover.xml +5262 -821
  2. package/coverage/coverage-final.json +25 -1
  3. package/coverage/index.html +311 -26
  4. package/coverage/rabbit-ui-kit/index.html +1 -1
  5. package/coverage/rabbit-ui-kit/index.js.html +1 -1
  6. package/coverage/rabbit-ui-kit/src/common/adapters/axiosAdapter.js.html +1 -1
  7. package/coverage/rabbit-ui-kit/src/common/adapters/index.html +1 -1
  8. package/coverage/rabbit-ui-kit/src/common/amountUtils.js.html +1 -1
  9. package/coverage/rabbit-ui-kit/src/common/errorUtils.js.html +1 -1
  10. package/coverage/rabbit-ui-kit/src/common/external-apis/apiGroups.js.html +1 -1
  11. package/coverage/rabbit-ui-kit/src/common/external-apis/index.html +1 -1
  12. package/coverage/rabbit-ui-kit/src/common/external-apis/ipAddressProviders.js.html +1 -1
  13. package/coverage/rabbit-ui-kit/src/common/fiatCurrenciesService.js.html +1 -1
  14. package/coverage/rabbit-ui-kit/src/common/index.html +1 -1
  15. package/coverage/rabbit-ui-kit/src/common/models/blockchain.js.html +1 -1
  16. package/coverage/rabbit-ui-kit/src/common/models/coin.js.html +1 -1
  17. package/coverage/rabbit-ui-kit/src/common/models/index.html +1 -1
  18. package/coverage/rabbit-ui-kit/src/common/models/protocol.js.html +1 -1
  19. package/coverage/rabbit-ui-kit/src/common/utils/cache.js.html +1 -1
  20. package/coverage/rabbit-ui-kit/src/common/utils/emailAPI.js.html +1 -1
  21. package/coverage/rabbit-ui-kit/src/common/utils/index.html +1 -1
  22. package/coverage/rabbit-ui-kit/src/common/utils/logging/index.html +1 -1
  23. package/coverage/rabbit-ui-kit/src/common/utils/logging/logger.js.html +1 -1
  24. package/coverage/rabbit-ui-kit/src/common/utils/logging/logsStorage.js.html +1 -1
  25. package/coverage/rabbit-ui-kit/src/common/utils/postponeExecution.js.html +1 -1
  26. package/coverage/rabbit-ui-kit/src/common/utils/safeStringify.js.html +1 -1
  27. package/coverage/rabbit-ui-kit/src/components/atoms/AssetIcon/AssetIcon.jsx.html +1 -1
  28. package/coverage/rabbit-ui-kit/src/components/atoms/AssetIcon/index.html +1 -1
  29. package/coverage/rabbit-ui-kit/src/components/atoms/AssetSelection/AssetSelection.jsx.html +364 -0
  30. package/coverage/rabbit-ui-kit/src/components/atoms/AssetSelection/index.html +116 -0
  31. package/coverage/rabbit-ui-kit/src/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +217 -0
  32. package/coverage/rabbit-ui-kit/src/components/atoms/BackgroundTitle/index.html +116 -0
  33. package/coverage/rabbit-ui-kit/src/components/atoms/LoadingDots/LoadingDots.jsx.html +1 -1
  34. package/coverage/rabbit-ui-kit/src/components/atoms/LoadingDots/index.html +1 -1
  35. package/coverage/rabbit-ui-kit/src/components/atoms/NoticeIcon/NoticeIcon.jsx.html +298 -0
  36. package/coverage/rabbit-ui-kit/src/components/atoms/NoticeIcon/index.html +116 -0
  37. package/coverage/rabbit-ui-kit/src/components/atoms/SupportChat/SupportChat.jsx.html +1 -1
  38. package/coverage/rabbit-ui-kit/src/components/atoms/SupportChat/index.html +1 -1
  39. package/coverage/rabbit-ui-kit/src/components/atoms/TitleBox/TitleBox.jsx.html +574 -0
  40. package/coverage/rabbit-ui-kit/src/components/atoms/TitleBox/index.html +116 -0
  41. package/coverage/rabbit-ui-kit/src/components/atoms/Tooltip/Tooltip.jsx.html +370 -0
  42. package/coverage/rabbit-ui-kit/src/components/atoms/Tooltip/index.html +116 -0
  43. package/coverage/rabbit-ui-kit/src/components/atoms/Validation/Validation.jsx.html +475 -0
  44. package/coverage/rabbit-ui-kit/src/components/atoms/Validation/index.html +116 -0
  45. package/coverage/rabbit-ui-kit/src/components/atoms/buttons/Button/Button.jsx.html +1 -1
  46. package/coverage/rabbit-ui-kit/src/components/atoms/buttons/Button/index.html +1 -1
  47. package/coverage/rabbit-ui-kit/src/components/atoms/buttons/Close/Close.jsx.html +277 -0
  48. package/coverage/rabbit-ui-kit/src/components/atoms/buttons/Close/index.html +116 -0
  49. package/coverage/rabbit-ui-kit/src/components/atoms/buttons/LinkButton/LinkButton.jsx.html +448 -0
  50. package/coverage/rabbit-ui-kit/src/components/atoms/buttons/LinkButton/index.html +116 -0
  51. package/coverage/rabbit-ui-kit/src/components/hooks/index.html +1 -1
  52. package/coverage/rabbit-ui-kit/src/components/hooks/useCallHandlingErrors.js.html +1 -1
  53. package/coverage/rabbit-ui-kit/src/components/hooks/useReferredState.js.html +1 -1
  54. package/coverage/rabbit-ui-kit/src/components/molecules/AmountInput/AmountInput.jsx.html +1510 -0
  55. package/coverage/rabbit-ui-kit/src/components/molecules/AmountInput/index.html +116 -0
  56. package/coverage/rabbit-ui-kit/src/components/organisms/Dialog/Dialog.jsx.html +1630 -0
  57. package/coverage/rabbit-ui-kit/src/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +451 -0
  58. package/coverage/rabbit-ui-kit/src/components/organisms/Dialog/DialogButtons/index.html +116 -0
  59. package/coverage/rabbit-ui-kit/src/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +2077 -0
  60. package/coverage/rabbit-ui-kit/src/components/organisms/Dialog/DialogStep/index.html +116 -0
  61. package/coverage/rabbit-ui-kit/src/components/organisms/Dialog/index.html +116 -0
  62. package/coverage/rabbit-ui-kit/src/components/organisms/SwapForm/SwapForm.jsx.html +3538 -0
  63. package/coverage/rabbit-ui-kit/src/components/organisms/SwapForm/index.html +116 -0
  64. package/coverage/rabbit-ui-kit/src/components/utils/index.html +24 -9
  65. package/coverage/rabbit-ui-kit/src/components/utils/inputValueProviders.js.html +1 -1
  66. package/coverage/rabbit-ui-kit/src/components/utils/textUtils.js.html +139 -0
  67. package/coverage/rabbit-ui-kit/src/components/utils/uiUtils.js.html +1 -1
  68. package/coverage/rabbit-ui-kit/src/components/utils/urlQueryUtils.js.html +1 -1
  69. package/coverage/rabbit-ui-kit/src/constants/organisms/dialog/DialogStep/dialogStep.js.html +88 -0
  70. package/coverage/rabbit-ui-kit/src/constants/organisms/dialog/DialogStep/index.html +116 -0
  71. package/coverage/rabbit-ui-kit/src/constants/organisms/dialog/dialog.js.html +172 -0
  72. package/coverage/rabbit-ui-kit/src/constants/organisms/dialog/index.html +116 -0
  73. package/coverage/rabbit-ui-kit/src/index.html +5 -5
  74. package/coverage/rabbit-ui-kit/src/index.js.html +65 -5
  75. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/cacheAndConcurrentRequestsResolver.js.html +1 -1
  76. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/cachedRobustExternalApiCallerService.js.html +1 -1
  77. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/cancelProcessing.js.html +1 -1
  78. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/concurrentCalculationsMetadataHolder.js.html +1 -1
  79. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/externalApiProvider.js.html +1 -1
  80. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/externalServicesStatsCollector.js.html +1 -1
  81. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/index.html +1 -1
  82. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/robustExternalAPICallerService.js.html +1 -1
  83. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/index.html +1 -1
  84. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +1 -1
  85. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +1 -1
  86. package/coverage/rabbit-ui-kit/src/swaps-lib/models/baseSwapCreationInfo.js.html +1 -1
  87. package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwap.js.html +1 -1
  88. package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwapWithFiatData.js.html +1 -1
  89. package/coverage/rabbit-ui-kit/src/swaps-lib/models/index.html +1 -1
  90. package/coverage/rabbit-ui-kit/src/swaps-lib/services/index.html +1 -1
  91. package/coverage/rabbit-ui-kit/src/swaps-lib/services/publicSwapService.js.html +1 -1
  92. package/coverage/rabbit-ui-kit/src/swaps-lib/utils/index.html +1 -1
  93. package/coverage/rabbit-ui-kit/src/swaps-lib/utils/swapUtils.js.html +1 -1
  94. package/coverage/rabbit-ui-kit/stories/atoms/BackgroundTitle.stories.jsx.html +202 -0
  95. package/coverage/rabbit-ui-kit/stories/atoms/LoadingDots.stories.jsx.html +1 -1
  96. package/coverage/rabbit-ui-kit/stories/atoms/Validation.stories.jsx.html +178 -0
  97. package/coverage/rabbit-ui-kit/stories/atoms/buttons/Button.stories.jsx.html +1 -1
  98. package/coverage/rabbit-ui-kit/stories/atoms/buttons/Close.stories.jsx.html +211 -0
  99. package/coverage/rabbit-ui-kit/stories/atoms/buttons/LinkButton.stories.jsx.html +298 -0
  100. package/coverage/rabbit-ui-kit/stories/atoms/buttons/index.html +35 -5
  101. package/coverage/rabbit-ui-kit/stories/atoms/index.html +35 -5
  102. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/Dialog.stories.jsx.html +574 -0
  103. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +328 -0
  104. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/index.html +116 -0
  105. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +352 -0
  106. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/index.html +116 -0
  107. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/index.html +116 -0
  108. package/coverage/rabbit-ui-kit/stories/stubs/exampleContent.jsx.html +145 -0
  109. package/coverage/rabbit-ui-kit/stories/stubs/index.html +116 -0
  110. package/dist/index.cjs +3022 -231
  111. package/dist/index.cjs.map +1 -1
  112. package/dist/index.css +40976 -0
  113. package/dist/index.css.map +1 -1
  114. package/dist/index.modern.js +2568 -183
  115. package/dist/index.modern.js.map +1 -1
  116. package/dist/index.module.js +3010 -239
  117. package/dist/index.module.js.map +1 -1
  118. package/dist/index.umd.js +3019 -234
  119. package/dist/index.umd.js.map +1 -1
  120. package/package.json +7 -1
  121. package/src/assets/image/icons/arrow-darker.svg +14 -0
  122. package/src/assets/image/icons/arrow-tosca.svg +3 -0
  123. package/src/assets/image/icons/arrow-white.svg +14 -0
  124. package/src/assets/image/icons/dark-rectangle.svg +3 -0
  125. package/src/assets/image/icons/failed-validation-icon.svg +15 -0
  126. package/src/assets/image/icons/successful-validation-icon.svg +10 -0
  127. package/src/assets/image/icons/wallet-gray-small.svg +6 -0
  128. package/src/components/atoms/AssetSelection/AssetSelection.jsx +93 -0
  129. package/src/components/atoms/AssetSelection/asset-selection.module.scss +55 -0
  130. package/src/components/atoms/BackgroundTitle/BackgroundTitle.jsx +44 -0
  131. package/src/components/atoms/BackgroundTitle/background-title.module.scss +52 -0
  132. package/src/components/atoms/NoticeIcon/NoticeIcon.jsx +71 -0
  133. package/src/components/atoms/NoticeIcon/notice-icon.module.scss +14 -0
  134. package/src/components/atoms/TitleBox/TitleBox.jsx +163 -0
  135. package/src/components/atoms/TitleBox/title-box.module.scss +30 -0
  136. package/src/components/atoms/Tooltip/Tooltip.jsx +95 -0
  137. package/src/components/atoms/Tooltip/tooltip.module.scss +231 -0
  138. package/src/components/atoms/Validation/Validation.jsx +130 -0
  139. package/src/components/atoms/Validation/validation.module.scss +15 -0
  140. package/src/components/atoms/buttons/Close/Close.jsx +64 -0
  141. package/src/components/atoms/buttons/Close/close.module.scss +75 -0
  142. package/src/components/atoms/buttons/LinkButton/LinkButton.jsx +121 -0
  143. package/src/components/atoms/buttons/LinkButton/link-button.module.scss +45 -0
  144. package/src/components/molecules/AmountInput/AmountInput.jsx +475 -0
  145. package/src/components/molecules/AmountInput/amount-input.module.scss +189 -0
  146. package/src/components/organisms/Dialog/Dialog.jsx +515 -0
  147. package/src/components/organisms/Dialog/DialogButtons/DialogButtons.jsx +122 -0
  148. package/src/components/organisms/Dialog/DialogButtons/dialog-buttons.module.scss +25 -0
  149. package/src/components/organisms/Dialog/DialogStep/DialogStep.jsx +664 -0
  150. package/src/components/organisms/Dialog/DialogStep/dialog-step.module.scss +362 -0
  151. package/src/components/organisms/Dialog/dialog.module.scss +223 -0
  152. package/src/components/organisms/SwapForm/SwapForm.jsx +1151 -0
  153. package/src/components/organisms/SwapForm/swap-form.module.scss +120 -0
  154. package/src/components/utils/textUtils.js +18 -0
  155. package/src/constants/organisms/dialog/DialogStep/dialogStep.js +1 -0
  156. package/src/constants/organisms/dialog/dialog.js +29 -0
  157. package/src/index.js +21 -1
  158. package/stories/stubs/exampleContent.jsx +20 -0
  159. package/styles/fonts/NunitoSans-Bold.ttf +0 -0
  160. package/styles/fonts/NunitoSans-ExtraBold.ttf +0 -0
  161. package/styles/fonts/NunitoSans-Light.ttf +0 -0
  162. package/styles/fonts/NunitoSans-Regular.ttf +0 -0
  163. package/styles/fonts/NunitoSans-SemiBold.ttf +0 -0
  164. package/styles/index.scss +5 -3
@@ -0,0 +1,664 @@
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import PropTypes from "prop-types";
3
+
4
+ import { logErrorOrOutputToConsole } from "../../../../common/errorUtils";
5
+ import { DIALOG_STEP_CLASS } from "../../../../constants/organisms/dialog/DialogStep/dialogStep";
6
+ import { DIALOG_TRANSITION_STEP_DURATION } from "../../../../constants/organisms/dialog/dialog";
7
+
8
+ // import arrowIconTosca from "../../../../assets/image/icons/arrow-tosca.svg";
9
+ // import arrowIconWhite from "../../../../assets/image/icons/arrow-white.svg";
10
+
11
+ import s from "./dialog-step.module.scss";
12
+ import { AssetIcon } from "../../../atoms/AssetIcon/AssetIcon";
13
+ import {
14
+ LinkButton,
15
+ // iconRotateOptions,
16
+ } from "../../../atoms/buttons/LinkButton/LinkButton";
17
+ import { BackgroundTitle } from "../../../atoms/BackgroundTitle/BackgroundTitle";
18
+ import { DialogButtons } from "../DialogButtons/DialogButtons";
19
+ import { LoadingDots } from "../../../atoms/LoadingDots/LoadingDots";
20
+
21
+ /**
22
+ * Step component, part of the DialogWithSteps modal component. This component should be used inside the primary dialog component.
23
+ * @component
24
+ * @param {string} stepName - Step name, specified on the root dialog level, used as an ID for dialog navigation.
25
+ * @param {Object} children - Content of the dialog step. Supports both raw content and components.
26
+ * @param {string} image - Illustration/icon at the top, path to an image.
27
+ * @param {string} title - Step title.
28
+ * @param {string} titleIcon - Icon next to the step title, path to an image.
29
+ * @param {Coin} titleIconCoin - Coin to be shown as an AssetIcon next to the step title.
30
+ * @param {function} coinToIconPaths - Function returning icons paths by Coin
31
+ * @param {boolean} titleLoadingDots - Show loading dots next to the title or not.
32
+ * @param {string} subtitle - Step subtitle.
33
+ * @param {string} backButtonText - Secondary button title.
34
+ * @param {function} backButtonClick - Secondary button click handler.
35
+ * @param {string} backButtonTo - Secondary button link.
36
+ * @param {string} confirmButtonText - Primary button title.
37
+ * @param {function} confirmButtonClick - Primary button click handler.
38
+ * @param {string} confirmButtonLink - Primary button link.
39
+ * @param {boolean} primaryButtonLoader - Enable loader for the primary button.
40
+ * @param {boolean} fixedButtons - Enable fixed buttons in the bottom for mobile devices.
41
+ * @param {boolean} showCornerBackButton - Forcefully enable or disable blue corner back button.
42
+ * @param {string} cornerBackButtonTitle - Blue corner back button title.
43
+ * @param {function} cornerBackButtonClick - Blue corner back button click handler.
44
+ * @param {boolean} bigButtonMargins - Increase button margins.
45
+ * @param {boolean} noButtonMargins - Decrease button margins.
46
+ * @param {boolean} headerTitleLeft - Align header title to the left. Default: false.
47
+ * @param {boolean} subtitleSmallMargin - Reduce the margin under the subtitle.
48
+ * @param {boolean} subtitleNoMargin - Disable the margin under the subtitle.
49
+ * @param {boolean} showBackgroundTitle - Enable the semi-transparent secondary background title.
50
+ * @param {function} setClickTrigger - Function to setup an external trigger for the primary button.
51
+ * @param {boolean} breakSubtitleWords - Enable word-break for subtitles. Default: false.
52
+ * @param {string} contentAlign - Receives "left", "center", "right". Controls the step content container alignment.
53
+ * @param {Object} controls - Dialog-to-step connection object, required for multi-step dialog windows.
54
+ * @param {string} width - Width in pixels, formatted as "1000px" and passed a string. Values should be used from constants.
55
+ * @param {string} height - Height in pixels, formatted as "1000px" and passed a string. Values should be used from constants.
56
+ * @param {string} backgroundImage - Background image, path to an image.
57
+ * @param {string} backgroundImageMobile - Background image for mobiles, path to an image.
58
+ * @param {boolean} isSecondaryButtonBig - Changes the secondary button style from link to a secondary-button. Default: false.
59
+ * @returns {JSX.Element} React component
60
+ */
61
+ export const DialogStep = ({
62
+ stepName = "",
63
+ children = "",
64
+ image = "",
65
+ title = "",
66
+ titleIcon = "",
67
+ titleIconCoin,
68
+ coinToIconPaths = () => {},
69
+ titleLoadingDots = false,
70
+ subtitle = "",
71
+ backButtonText = "",
72
+ backButtonClick = () => {},
73
+ backButtonTo = "",
74
+ confirmButtonText = "",
75
+ confirmButtonClick = () => {},
76
+ confirmButtonLink = "",
77
+ primaryButtonLoader = false,
78
+ fixedButtons = false,
79
+ showCornerBackButton = null,
80
+ cornerBackButtonTitle = null,
81
+ cornerBackButtonClick = null,
82
+ bigButtonMargins = false,
83
+ noButtonMargins = false,
84
+ headerTitleLeft = false,
85
+ subtitleSmallMargin = false,
86
+ subtitleNoMargin = false,
87
+ showBackgroundTitle = true,
88
+ setClickTrigger = () => {},
89
+ breakSubtitleWords = false,
90
+ contentAlign = "left",
91
+ controls = {},
92
+ width = "",
93
+ height,
94
+ backgroundImage,
95
+ backgroundImageMobile,
96
+ isSecondaryButtonBig = false,
97
+ }) => {
98
+ const {
99
+ currentStep = null,
100
+ isCurrentStep = () => {},
101
+ previousStep,
102
+ getStepClass = () => {},
103
+ updateDialogConfiguration,
104
+ provideCurrentStepRef,
105
+ animationConfiguration,
106
+ disableAnimation,
107
+ showCornerButtonForStep,
108
+ scrollDialogToTop = () => {},
109
+ updateButtonsConfiguration = () => {},
110
+ clearButtonsConfiguration = () => {},
111
+ buttonControllingStep,
112
+ updateButtonControllingStep = () => {},
113
+ updateAnimationConfiguration = () => {},
114
+ inline,
115
+ } = controls;
116
+
117
+ const [isMultiStep, setIsMultiStep] = useState(false);
118
+ const [stepClass, setStepClass] = useState("");
119
+ const [wrapperDirectionSubclass, setWrapperDirectionSubclass] =
120
+ useState("");
121
+ const [unmountOnAnimationEndTrigger, setUnmountOnAnimationEndTrigger] =
122
+ useState(0);
123
+ const [stepMounted, setStepMounted] = useState(false);
124
+
125
+ const currentStepRef = useRef();
126
+ // const { t } = useTranslation();
127
+
128
+ useEffect(() => {
129
+ if (controls !== {} && stepName !== "") setIsMultiStep(true);
130
+ // eslint-disable-next-line react-hooks/exhaustive-deps
131
+ }, []);
132
+
133
+ const handleTransitionEnd = (event) => {
134
+ if (
135
+ isMultiStep &&
136
+ isCurrentStep(stepName) &&
137
+ event.propertyName === "opacity" &&
138
+ event.target.classList[0] === DIALOG_STEP_CLASS
139
+ ) {
140
+ disableAnimation(
141
+ animationConfiguration.animateHeightTransitionEnabled
142
+ );
143
+ }
144
+
145
+ if (
146
+ isMultiStep &&
147
+ unmountOnAnimationEndTrigger &&
148
+ event.propertyName === "opacity" &&
149
+ event.target.classList[0] === DIALOG_STEP_CLASS
150
+ ) {
151
+ clearButtonsConfiguration();
152
+ scrollDialogToTop();
153
+ setStepMounted(false);
154
+ setUnmountOnAnimationEndTrigger(0);
155
+ }
156
+ };
157
+
158
+ useEffect(() => {
159
+ var multiStep = false;
160
+ if (controls !== {} && stepName !== "") {
161
+ setIsMultiStep(true);
162
+ multiStep = true;
163
+ }
164
+
165
+ if (!multiStep && fixedButtons) {
166
+ logErrorOrOutputToConsole(
167
+ new Error(
168
+ "DialogStep parameter 'fixedButtons' works only with controls connected between the DialogWithSteps and DialogStep components. Unless the controls are configured the 'fixedButtons' parameter will be ignored."
169
+ )
170
+ );
171
+ }
172
+
173
+ if (multiStep) {
174
+ if (getStepClass(stepName) === "current") setStepMounted(true);
175
+
176
+ if (stepClass === "current" && getStepClass(stepName) !== "current")
177
+ setUnmountOnAnimationEndTrigger((prev) => prev + 1);
178
+
179
+ setWrapperDirectionSubclass(
180
+ getStepClass(stepName) === "current" &&
181
+ animationConfiguration.currentStepAnimationEnabled
182
+ ? stepClass === "prev"
183
+ ? "appear-from-left"
184
+ : "appear-from-right"
185
+ : ""
186
+ );
187
+ } else {
188
+ if (width !== "")
189
+ logErrorOrOutputToConsole(
190
+ new Error(
191
+ "Single DialogStep does not support 'width' parameter, since it requires controls to be connected. Pass 'width' to the Dialog component to set the width of the modal window."
192
+ )
193
+ );
194
+ setStepMounted(true);
195
+ }
196
+
197
+ setStepClass(multiStep ? getStepClass(stepName) : "current");
198
+ if (multiStep && isCurrentStep(stepName)) {
199
+ setTimeout(
200
+ () => updateButtonControllingStep(stepName),
201
+ buttonControllingStep === ""
202
+ ? 0
203
+ : DIALOG_TRANSITION_STEP_DURATION
204
+ );
205
+
206
+ setTimeout(() => {
207
+ updateButtonsConfiguration(
208
+ {
209
+ primaryButtonTitle: confirmButtonText,
210
+ primaryButtonOnClick: (resetButtonLoader) =>
211
+ confirmButtonClick(resetButtonLoader),
212
+ primaryButtonLoader: primaryButtonLoader,
213
+ primaryButtonTo: confirmButtonLink,
214
+ primaryButtonSetClickTrigger: setClickTrigger,
215
+ secondaryButtonTitle: backButtonText,
216
+ secondaryButtonOnClick: backButtonClick,
217
+ secondaryButtonTo: backButtonTo,
218
+ fixedButtonsEnabled: fixedButtons,
219
+ },
220
+ stepName
221
+ );
222
+
223
+ updateAnimationConfiguration((prev) => {
224
+ return {
225
+ ...prev,
226
+ hideMobileBottomButtonSection: false,
227
+ };
228
+ });
229
+ }, DIALOG_TRANSITION_STEP_DURATION * 3);
230
+
231
+ updateDialogConfiguration((prev) => {
232
+ return {
233
+ ...prev,
234
+ cornerBackButtonTitle: cornerBackButtonTitle,
235
+ customWidth: width,
236
+ };
237
+ });
238
+ provideCurrentStepRef(currentStepRef);
239
+ }
240
+ // eslint-disable-next-line react-hooks/exhaustive-deps
241
+ }, [currentStep]);
242
+
243
+ useEffect(() => {
244
+ if (
245
+ isMultiStep &&
246
+ isCurrentStep(stepName) &&
247
+ fixedButtons &&
248
+ (confirmButtonText || backButtonText)
249
+ ) {
250
+ updateButtonsConfiguration(
251
+ {
252
+ primaryButtonTitle: confirmButtonText,
253
+ primaryButtonOnClick: (resetButtonLoader) =>
254
+ confirmButtonClick(resetButtonLoader),
255
+ primaryButtonLoader: primaryButtonLoader,
256
+ primaryButtonTo: confirmButtonLink,
257
+ primaryButtonSetClickTrigger: setClickTrigger,
258
+ secondaryButtonTitle: backButtonText,
259
+ secondaryButtonOnClick: backButtonClick,
260
+ secondaryButtonTo: backButtonTo,
261
+ fixedButtonsEnabled: fixedButtons,
262
+ },
263
+ stepName
264
+ );
265
+ }
266
+ // eslint-disable-next-line react-hooks/exhaustive-deps
267
+ }, [
268
+ confirmButtonText,
269
+ confirmButtonClick,
270
+ primaryButtonLoader,
271
+ confirmButtonLink,
272
+ setClickTrigger,
273
+ backButtonText,
274
+ backButtonClick,
275
+ backButtonTo,
276
+ currentStep,
277
+ ]);
278
+
279
+ const { assetIconSrc, assetIconProtocolSrc, fallbackSrc } =
280
+ titleIconCoin && coinToIconPaths ? coinToIconPaths(titleIconCoin) : {};
281
+
282
+ return (
283
+ <div
284
+ className={
285
+ s[DIALOG_STEP_CLASS] +
286
+ " " +
287
+ s[stepClass] +
288
+ (!isMultiStep ||
289
+ !animationConfiguration?.currentStepAnimationEnabled
290
+ ? " " + s["animation-disabled"]
291
+ : "") +
292
+ (!isMultiStep ? " " + s["single-step"] : "") +
293
+ (backgroundImage || backgroundImageMobile
294
+ ? " " + s["with-background"]
295
+ : "")
296
+ }
297
+ ref={currentStepRef}
298
+ onTransitionEnd={handleTransitionEnd}
299
+ style={height ? { height: height } : null}
300
+ >
301
+ {stepMounted ? (
302
+ <>
303
+ {backgroundImage || backgroundImageMobile ? (
304
+ <div
305
+ className={
306
+ s["dialog-step-background-image"] +
307
+ " " +
308
+ s[stepClass]
309
+ }
310
+ >
311
+ {backgroundImage ? (
312
+ <img
313
+ src={backgroundImage}
314
+ className={
315
+ s[
316
+ "dialog-step-background-image-desktop"
317
+ ] +
318
+ " " +
319
+ stepClass +
320
+ (!backgroundImageMobile
321
+ ? " " + s["primary"]
322
+ : "")
323
+ }
324
+ alt={"dialog step background"}
325
+ />
326
+ ) : null}
327
+ {backgroundImageMobile ? (
328
+ <img
329
+ src={backgroundImageMobile}
330
+ className={
331
+ s[
332
+ "dialog-step-background-image-mobile"
333
+ ] +
334
+ " " +
335
+ stepClass +
336
+ (!backgroundImage
337
+ ? " " + s["primary"]
338
+ : "")
339
+ }
340
+ alt={"dialog step background"}
341
+ />
342
+ ) : null}
343
+ </div>
344
+ ) : null}
345
+ <div
346
+ className={
347
+ s["dialog-step-wrapper"] +
348
+ " " +
349
+ s[stepClass] +
350
+ " " +
351
+ s[wrapperDirectionSubclass]
352
+ }
353
+ >
354
+ {isMultiStep &&
355
+ showCornerButtonForStep(
356
+ stepName,
357
+ showCornerBackButton
358
+ ) ? (
359
+ <div
360
+ className={s["dialog-step-wrapper-back-button"]}
361
+ >
362
+ <LinkButton
363
+ onClick={
364
+ cornerBackButtonClick
365
+ ? cornerBackButtonClick
366
+ : previousStep
367
+ }
368
+ content={
369
+ cornerBackButtonTitle
370
+ ? cornerBackButtonTitle
371
+ : // : t("organisms.DialogWithSteps.DialogStep.default-back-button-title")
372
+ "Back"
373
+ }
374
+ // TODO: Fix the SVG usage and add it back
375
+ // icon={
376
+ // backgroundImage || backgroundImageMobile
377
+ // ? arrowIconWhite
378
+ // : arrowIconTosca
379
+ // }
380
+ // iconRotate={iconRotateOptions.rotate90}
381
+ isColored={
382
+ backgroundImage || backgroundImageMobile
383
+ ? false
384
+ : undefined
385
+ }
386
+ />
387
+ </div>
388
+ ) : null}
389
+
390
+ <div
391
+ className={
392
+ s["dialog-step-wrapper-header"] +
393
+ (headerTitleLeft ? " " + s["text-left"] : "") +
394
+ (backgroundImage || backgroundImageMobile
395
+ ? " " + s["with-background-image"]
396
+ : "")
397
+ }
398
+ >
399
+ {image ? (
400
+ <img
401
+ src={image}
402
+ alt="dialog popup logo"
403
+ className={
404
+ s["dialog-step-wrapper-header-logo"]
405
+ }
406
+ />
407
+ ) : null}
408
+
409
+ <div
410
+ className={
411
+ s["dialog-step-wrapper-header-title"] +
412
+ (!image ? " " + s["without-logo"] : "") +
413
+ (!image && headerTitleLeft
414
+ ? " " + s["close-button-padding"]
415
+ : "") +
416
+ (inline
417
+ ? " " + s["no-close-button-padding"]
418
+ : "")
419
+ }
420
+ >
421
+ {titleIconCoin ? (
422
+ <div
423
+ className={
424
+ s[
425
+ "dialog-step-wrapper-header-title-coin-icon"
426
+ ]
427
+ }
428
+ >
429
+ <AssetIcon
430
+ assetIconSrc={assetIconSrc}
431
+ assetIconProtocolSrc={
432
+ assetIconProtocolSrc
433
+ }
434
+ fallbackSrc={fallbackSrc}
435
+ />
436
+ </div>
437
+ ) : titleIcon ? (
438
+ <div
439
+ className={
440
+ s[
441
+ "dialog-step-wrapper-header-title-icon"
442
+ ]
443
+ }
444
+ >
445
+ <img
446
+ src={titleIcon}
447
+ alt="coin icon to send"
448
+ />
449
+ </div>
450
+ ) : null}
451
+ {titleLoadingDots ? (
452
+ <div
453
+ className={
454
+ s[
455
+ "dialog-step-wrapper-header-title-loading"
456
+ ]
457
+ }
458
+ >
459
+ <LoadingDots isColored />
460
+ </div>
461
+ ) : (
462
+ ""
463
+ )}
464
+ <div
465
+ className={
466
+ s[
467
+ "dialog-step-wrapper-header-title-text"
468
+ ]
469
+ }
470
+ >
471
+ {!image && showBackgroundTitle ? (
472
+ <BackgroundTitle text={title} />
473
+ ) : null}
474
+ <h5
475
+ className={
476
+ s[
477
+ "dialog-step-wrapper-header-title-text-content"
478
+ ] +
479
+ (!image
480
+ ? " " + s["without-logo"]
481
+ : "") +
482
+ (backgroundImage ||
483
+ backgroundImageMobile
484
+ ? " " + s["white"]
485
+ : "")
486
+ }
487
+ >
488
+ {title}
489
+ </h5>
490
+ </div>
491
+ </div>
492
+
493
+ {subtitle ? (
494
+ <p
495
+ className={
496
+ s["dialog-step-wrapper-header-text"] +
497
+ ` ${!image ? s["without-logo"] : ""} ${
498
+ subtitleSmallMargin
499
+ ? s["small-margin"]
500
+ : ""
501
+ }${
502
+ subtitleNoMargin
503
+ ? s["no-margin"]
504
+ : ""
505
+ } ${
506
+ headerTitleLeft
507
+ ? s["text-left"]
508
+ : ""
509
+ } ${
510
+ breakSubtitleWords
511
+ ? s["break-words"]
512
+ : ""
513
+ } ${
514
+ backgroundImage ||
515
+ backgroundImageMobile
516
+ ? s["white"]
517
+ : ""
518
+ }`
519
+ }
520
+ >
521
+ {subtitle}
522
+ </p>
523
+ ) : null}
524
+ </div>
525
+ <div
526
+ className={
527
+ s["dialog-step-wrapper-content"] +
528
+ " " +
529
+ s["align-" + contentAlign]
530
+ }
531
+ >
532
+ {children}
533
+ </div>
534
+
535
+ {backButtonText || confirmButtonText ? (
536
+ <div
537
+ className={
538
+ s["dialog-step-wrapper-buttons"] +
539
+ ` ${
540
+ bigButtonMargins ? s["big-margin"] : ""
541
+ } ${
542
+ noButtonMargins ? s["no-margin"] : ""
543
+ } ${
544
+ isSecondaryButtonBig
545
+ ? s["space-between-layout"]
546
+ : ""
547
+ }`
548
+ }
549
+ >
550
+ <DialogButtons
551
+ primaryButtonTitle={confirmButtonText}
552
+ primaryButtonOnClick={(resetButtonLoader) =>
553
+ confirmButtonClick(resetButtonLoader)
554
+ }
555
+ primaryButtonLoader={primaryButtonLoader}
556
+ primaryButtonTo={confirmButtonLink}
557
+ primaryButtonSetClickTrigger={
558
+ setClickTrigger
559
+ }
560
+ secondaryButtonTitle={backButtonText}
561
+ secondaryButtonOnClick={backButtonClick}
562
+ secondaryButtonTo={backButtonTo}
563
+ secondaryButtonBig={isSecondaryButtonBig}
564
+ withBackgroundImage={
565
+ backgroundImage || backgroundImageMobile
566
+ }
567
+ hideOnMobiles={
568
+ isMultiStep &&
569
+ fixedButtons &&
570
+ (backButtonText || confirmButtonText)
571
+ }
572
+ />
573
+ </div>
574
+ ) : (
575
+ ""
576
+ )}
577
+ </div>
578
+ </>
579
+ ) : null}
580
+ </div>
581
+ );
582
+ };
583
+
584
+ DialogStep.propTypes = {
585
+ stepName: PropTypes.string,
586
+ children: PropTypes.node,
587
+ image: PropTypes.string,
588
+ title: PropTypes.string,
589
+ titleIcon: PropTypes.string,
590
+ titleIconCoin: PropTypes.object,
591
+ coinToIconPaths: PropTypes.func,
592
+ titleLoadingDots: PropTypes.bool,
593
+ subtitle: PropTypes.string,
594
+ backButtonText: PropTypes.string,
595
+ backButtonClick: PropTypes.func,
596
+ backButtonTo: PropTypes.string,
597
+ confirmButtonText: PropTypes.string,
598
+ confirmButtonClick: PropTypes.func,
599
+ confirmButtonLink: PropTypes.string,
600
+ primaryButtonLoader: PropTypes.bool,
601
+ fixedButtons: PropTypes.bool,
602
+ showCornerBackButton: PropTypes.bool,
603
+ cornerBackButtonTitle: PropTypes.string,
604
+ cornerBackButtonClick: PropTypes.func,
605
+ bigButtonMargins: PropTypes.bool,
606
+ noButtonMargins: PropTypes.bool,
607
+ headerTitleLeft: PropTypes.bool,
608
+ subtitleSmallMargin: PropTypes.bool,
609
+ subtitleNoMargin: PropTypes.bool,
610
+ showBackgroundTitle: PropTypes.bool,
611
+ setClickTrigger: PropTypes.func,
612
+ breakSubtitleWords: PropTypes.bool,
613
+ contentAlign: PropTypes.string,
614
+ controls: PropTypes.object,
615
+ width: PropTypes.oneOf([
616
+ "550px",
617
+ "600px",
618
+ "700px",
619
+ "750px",
620
+ "800px",
621
+ "1000px",
622
+ ]),
623
+ height: PropTypes.string,
624
+ backgroundImage: PropTypes.string,
625
+ backgroundImageMobile: PropTypes.string,
626
+ isSecondaryButtonBig: PropTypes.bool,
627
+ };
628
+
629
+ DialogStep.defaultProps = {
630
+ stepName: "",
631
+ children: null,
632
+ image: "",
633
+ title: "",
634
+ titleIcon: "",
635
+ coinToIconPaths: () => ({}),
636
+ titleLoadingDots: false,
637
+ subtitle: "",
638
+ backButtonText: "",
639
+ backButtonClick: () => {},
640
+ backButtonTo: "",
641
+ confirmButtonText: "",
642
+ confirmButtonClick: () => {},
643
+ confirmButtonLink: "",
644
+ primaryButtonLoader: false,
645
+ fixedButtons: false,
646
+ showCornerBackButton: null,
647
+ cornerBackButtonTitle: null,
648
+ cornerBackButtonClick: null,
649
+ bigButtonMargins: false,
650
+ noButtonMargins: false,
651
+ headerTitleLeft: false,
652
+ subtitleSmallMargin: false,
653
+ subtitleNoMargin: false,
654
+ showBackgroundTitle: true,
655
+ setClickTrigger: () => {},
656
+ breakSubtitleWords: false,
657
+ contentAlign: "left",
658
+ controls: {},
659
+ width: "",
660
+ height: null,
661
+ backgroundImage: "",
662
+ backgroundImageMobile: "",
663
+ isSecondaryButtonBig: false,
664
+ };