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

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 (113) hide show
  1. package/.husky/pre-push +1 -1
  2. package/dist/index.cjs +1389 -102
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.css +23630 -0
  5. package/dist/index.css.map +1 -1
  6. package/dist/index.modern.js +1185 -57
  7. package/dist/index.modern.js.map +1 -1
  8. package/dist/index.module.js +1379 -103
  9. package/dist/index.module.js.map +1 -1
  10. package/dist/index.umd.js +1388 -106
  11. package/dist/index.umd.js.map +1 -1
  12. package/package.json +6 -1
  13. package/src/assets/image/icons/arrow-tosca.svg +3 -0
  14. package/src/assets/image/icons/arrow-white.svg +14 -0
  15. package/src/assets/image/icons/failed-validation-icon.svg +15 -0
  16. package/src/assets/image/icons/successful-validation-icon.svg +10 -0
  17. package/src/components/atoms/BackgroundTitle/BackgroundTitle.jsx +44 -0
  18. package/src/components/atoms/BackgroundTitle/background-title.module.scss +52 -0
  19. package/src/components/atoms/Validation/Validation.jsx +130 -0
  20. package/src/components/atoms/Validation/validation.module.scss +15 -0
  21. package/src/components/atoms/buttons/Close/Close.jsx +64 -0
  22. package/src/components/atoms/buttons/Close/close.module.scss +75 -0
  23. package/src/components/atoms/buttons/LinkButton/LinkButton.jsx +121 -0
  24. package/src/components/atoms/buttons/LinkButton/link-button.module.scss +45 -0
  25. package/src/components/organisms/Dialog/Dialog.jsx +515 -0
  26. package/src/components/organisms/Dialog/DialogButtons/DialogButtons.jsx +122 -0
  27. package/src/components/organisms/Dialog/DialogButtons/dialog-buttons.module.scss +25 -0
  28. package/src/components/organisms/Dialog/DialogStep/DialogStep.jsx +664 -0
  29. package/src/components/organisms/Dialog/DialogStep/dialog-step.module.scss +362 -0
  30. package/src/components/organisms/Dialog/dialog.module.scss +223 -0
  31. package/src/constants/organisms/dialog/DialogStep/dialogStep.js +1 -0
  32. package/src/constants/organisms/dialog/dialog.js +29 -0
  33. package/src/index.js +10 -0
  34. package/stories/stubs/exampleContent.jsx +20 -0
  35. package/styles/fonts/NunitoSans-Bold.ttf +0 -0
  36. package/styles/fonts/NunitoSans-ExtraBold.ttf +0 -0
  37. package/styles/fonts/NunitoSans-Light.ttf +0 -0
  38. package/styles/fonts/NunitoSans-Regular.ttf +0 -0
  39. package/styles/fonts/NunitoSans-SemiBold.ttf +0 -0
  40. package/styles/index.scss +14 -13
  41. package/coverage/base.css +0 -224
  42. package/coverage/block-navigation.js +0 -87
  43. package/coverage/clover.xml +0 -6516
  44. package/coverage/coverage-final.json +0 -43
  45. package/coverage/favicon.png +0 -0
  46. package/coverage/index.html +0 -416
  47. package/coverage/prettify.css +0 -1
  48. package/coverage/prettify.js +0 -2
  49. package/coverage/rabbit-ui-kit/index.html +0 -116
  50. package/coverage/rabbit-ui-kit/index.js.html +0 -88
  51. package/coverage/rabbit-ui-kit/src/common/adapters/axiosAdapter.js.html +0 -190
  52. package/coverage/rabbit-ui-kit/src/common/adapters/index.html +0 -116
  53. package/coverage/rabbit-ui-kit/src/common/amountUtils.js.html +0 -1393
  54. package/coverage/rabbit-ui-kit/src/common/errorUtils.js.html +0 -211
  55. package/coverage/rabbit-ui-kit/src/common/external-apis/apiGroups.js.html +0 -250
  56. package/coverage/rabbit-ui-kit/src/common/external-apis/index.html +0 -131
  57. package/coverage/rabbit-ui-kit/src/common/external-apis/ipAddressProviders.js.html +0 -499
  58. package/coverage/rabbit-ui-kit/src/common/fiatCurrenciesService.js.html +0 -568
  59. package/coverage/rabbit-ui-kit/src/common/index.html +0 -146
  60. package/coverage/rabbit-ui-kit/src/common/models/blockchain.js.html +0 -115
  61. package/coverage/rabbit-ui-kit/src/common/models/coin.js.html +0 -556
  62. package/coverage/rabbit-ui-kit/src/common/models/index.html +0 -146
  63. package/coverage/rabbit-ui-kit/src/common/models/protocol.js.html +0 -100
  64. package/coverage/rabbit-ui-kit/src/common/utils/cache.js.html +0 -889
  65. package/coverage/rabbit-ui-kit/src/common/utils/emailAPI.js.html +0 -139
  66. package/coverage/rabbit-ui-kit/src/common/utils/index.html +0 -161
  67. package/coverage/rabbit-ui-kit/src/common/utils/logging/index.html +0 -131
  68. package/coverage/rabbit-ui-kit/src/common/utils/logging/logger.js.html +0 -229
  69. package/coverage/rabbit-ui-kit/src/common/utils/logging/logsStorage.js.html +0 -268
  70. package/coverage/rabbit-ui-kit/src/common/utils/postponeExecution.js.html +0 -118
  71. package/coverage/rabbit-ui-kit/src/common/utils/safeStringify.js.html +0 -235
  72. package/coverage/rabbit-ui-kit/src/components/atoms/AssetIcon/AssetIcon.jsx.html +0 -250
  73. package/coverage/rabbit-ui-kit/src/components/atoms/AssetIcon/index.html +0 -116
  74. package/coverage/rabbit-ui-kit/src/components/atoms/LoadingDots/LoadingDots.jsx.html +0 -256
  75. package/coverage/rabbit-ui-kit/src/components/atoms/LoadingDots/index.html +0 -116
  76. package/coverage/rabbit-ui-kit/src/components/atoms/SupportChat/SupportChat.jsx.html +0 -229
  77. package/coverage/rabbit-ui-kit/src/components/atoms/SupportChat/index.html +0 -116
  78. package/coverage/rabbit-ui-kit/src/components/atoms/buttons/Button/Button.jsx.html +0 -802
  79. package/coverage/rabbit-ui-kit/src/components/atoms/buttons/Button/index.html +0 -116
  80. package/coverage/rabbit-ui-kit/src/components/hooks/index.html +0 -131
  81. package/coverage/rabbit-ui-kit/src/components/hooks/useCallHandlingErrors.js.html +0 -163
  82. package/coverage/rabbit-ui-kit/src/components/hooks/useReferredState.js.html +0 -157
  83. package/coverage/rabbit-ui-kit/src/components/utils/index.html +0 -146
  84. package/coverage/rabbit-ui-kit/src/components/utils/inputValueProviders.js.html +0 -259
  85. package/coverage/rabbit-ui-kit/src/components/utils/uiUtils.js.html +0 -127
  86. package/coverage/rabbit-ui-kit/src/components/utils/urlQueryUtils.js.html +0 -346
  87. package/coverage/rabbit-ui-kit/src/index.html +0 -116
  88. package/coverage/rabbit-ui-kit/src/index.js.html +0 -250
  89. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/cacheAndConcurrentRequestsResolver.js.html +0 -1762
  90. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/cachedRobustExternalApiCallerService.js.html +0 -649
  91. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/cancelProcessing.js.html +0 -172
  92. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/concurrentCalculationsMetadataHolder.js.html +0 -394
  93. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/externalApiProvider.js.html +0 -553
  94. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/externalServicesStatsCollector.js.html +0 -331
  95. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/index.html +0 -206
  96. package/coverage/rabbit-ui-kit/src/robustExteranlApiCallerService/robustExternalAPICallerService.js.html +0 -1249
  97. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/index.html +0 -131
  98. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +0 -727
  99. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +0 -2899
  100. package/coverage/rabbit-ui-kit/src/swaps-lib/models/baseSwapCreationInfo.js.html +0 -214
  101. package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwap.js.html +0 -304
  102. package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwapWithFiatData.js.html +0 -487
  103. package/coverage/rabbit-ui-kit/src/swaps-lib/models/index.html +0 -146
  104. package/coverage/rabbit-ui-kit/src/swaps-lib/services/index.html +0 -116
  105. package/coverage/rabbit-ui-kit/src/swaps-lib/services/publicSwapService.js.html +0 -2191
  106. package/coverage/rabbit-ui-kit/src/swaps-lib/utils/index.html +0 -116
  107. package/coverage/rabbit-ui-kit/src/swaps-lib/utils/swapUtils.js.html +0 -742
  108. package/coverage/rabbit-ui-kit/stories/atoms/LoadingDots.stories.jsx.html +0 -226
  109. package/coverage/rabbit-ui-kit/stories/atoms/buttons/Button.stories.jsx.html +0 -946
  110. package/coverage/rabbit-ui-kit/stories/atoms/buttons/index.html +0 -116
  111. package/coverage/rabbit-ui-kit/stories/atoms/index.html +0 -116
  112. package/coverage/sort-arrow-sprite.png +0 -0
  113. package/coverage/sorter.js +0 -196
@@ -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
+ };