@rabbitio/ui-kit 1.0.0-beta.42 → 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 (67) hide show
  1. package/.gitlab-ci.yml +29 -0
  2. package/.husky/commit-msg +8 -0
  3. package/.husky/pre-push +1 -0
  4. package/README.md +13 -4
  5. package/dist/index.cjs +1545 -148
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.css +23630 -0
  8. package/dist/index.css.map +1 -1
  9. package/dist/index.modern.js +1318 -103
  10. package/dist/index.modern.js.map +1 -1
  11. package/dist/index.module.js +1534 -149
  12. package/dist/index.module.js.map +1 -1
  13. package/dist/index.umd.js +1544 -152
  14. package/dist/index.umd.js.map +1 -1
  15. package/package.json +16 -3
  16. package/src/assets/image/icons/arrow-tosca.svg +3 -0
  17. package/src/assets/image/icons/arrow-white.svg +14 -0
  18. package/src/assets/image/icons/failed-validation-icon.svg +15 -0
  19. package/src/assets/image/icons/successful-validation-icon.svg +10 -0
  20. package/src/common/amountUtils.js +4 -2
  21. package/src/common/tests/integration/external-apis/ipAddressProviders/getClientIpAddress.test.js +14 -0
  22. package/src/common/utils/cache.js +4 -4
  23. package/src/components/atoms/BackgroundTitle/BackgroundTitle.jsx +44 -0
  24. package/src/components/atoms/BackgroundTitle/background-title.module.scss +52 -0
  25. package/src/components/atoms/Validation/Validation.jsx +130 -0
  26. package/src/components/atoms/Validation/validation.module.scss +15 -0
  27. package/src/components/atoms/buttons/Close/Close.jsx +64 -0
  28. package/src/components/atoms/buttons/Close/close.module.scss +75 -0
  29. package/src/components/atoms/buttons/LinkButton/LinkButton.jsx +121 -0
  30. package/src/components/atoms/buttons/LinkButton/link-button.module.scss +45 -0
  31. package/src/components/organisms/Dialog/Dialog.jsx +515 -0
  32. package/src/components/organisms/Dialog/DialogButtons/DialogButtons.jsx +122 -0
  33. package/src/components/organisms/Dialog/DialogButtons/dialog-buttons.module.scss +25 -0
  34. package/src/components/organisms/Dialog/DialogStep/DialogStep.jsx +664 -0
  35. package/src/components/organisms/Dialog/DialogStep/dialog-step.module.scss +362 -0
  36. package/src/components/organisms/Dialog/dialog.module.scss +223 -0
  37. package/src/components/tests/utils/inputValueProviders/provideFormatOfFloatValueByInputString.test.js +139 -0
  38. package/src/components/tests/utils/urlQueryUtils/getQueryParameterValues.test.js +71 -0
  39. package/src/components/tests/utils/urlQueryUtils/saveQueryParameterAndValues.test.js +144 -0
  40. package/src/components/utils/inputValueProviders.js +58 -0
  41. package/src/constants/organisms/dialog/DialogStep/dialogStep.js +1 -0
  42. package/src/constants/organisms/dialog/dialog.js +29 -0
  43. package/src/index.js +11 -0
  44. package/src/robustExteranlApiCallerService/robustExternalAPICallerService.js +3 -1
  45. package/src/robustExteranlApiCallerService/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/_performCallAttempt.test.js +787 -0
  46. package/src/robustExteranlApiCallerService/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/callExternalAPI.test.js +745 -0
  47. package/src/robustExteranlApiCallerService/tests/robustExternalAPICallerService/robustExternalAPICallerService/constructor.test.js +31 -0
  48. package/src/swaps-lib/external-apis/swapProvider.js +17 -4
  49. package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +91 -30
  50. package/src/swaps-lib/models/baseSwapCreationInfo.js +4 -1
  51. package/src/swaps-lib/models/existingSwap.js +3 -0
  52. package/src/swaps-lib/models/existingSwapWithFiatData.js +4 -0
  53. package/src/swaps-lib/services/publicSwapService.js +32 -4
  54. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +506 -0
  55. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/createSwap.test.js +1311 -0
  56. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getAllSupportedCurrencies.test.js +76 -0
  57. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getDepositCurrencies.test.js +82 -0
  58. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getSwapInfo.test.js +1892 -0
  59. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getWithdrawalCurrencies.test.js +111 -0
  60. package/src/swaps-lib/test/utils/swapUtils/safeHandleRequestsLimitExceeding.test.js +88 -0
  61. package/stories/stubs/exampleContent.jsx +20 -0
  62. package/styles/fonts/NunitoSans-Bold.ttf +0 -0
  63. package/styles/fonts/NunitoSans-ExtraBold.ttf +0 -0
  64. package/styles/fonts/NunitoSans-Light.ttf +0 -0
  65. package/styles/fonts/NunitoSans-Regular.ttf +0 -0
  66. package/styles/fonts/NunitoSans-SemiBold.ttf +0 -0
  67. package/styles/index.scss +14 -13
@@ -0,0 +1,71 @@
1
+ import should from "should";
2
+
3
+ import { beforeEach, afterEach, describe, it } from "vitest";
4
+ import { getQueryParameterValues } from "../../../utils/urlQueryUtils.js";
5
+
6
+ describe("urlQueryUtils", function () {
7
+ describe("#getQueryParameterValues", function () {
8
+ beforeEach(function () {});
9
+
10
+ afterEach(function () {
11
+ global.window = {};
12
+ });
13
+
14
+ function setCustomQueryString(query) {
15
+ global.window = {
16
+ location: {
17
+ search: query,
18
+ },
19
+ };
20
+ }
21
+
22
+ it("Should unescape parameter values", function () {
23
+ const parameterValuesWithSpecialSymbols = "#a@se /wer|*|##eee$";
24
+ setCustomQueryString(
25
+ `?a=${encodeURIComponent(parameterValuesWithSpecialSymbols)}`
26
+ );
27
+ const result = getQueryParameterValues("a");
28
+
29
+ result.should.be.deepEqual([
30
+ ...parameterValuesWithSpecialSymbols.split("|*|"),
31
+ ]);
32
+ });
33
+
34
+ it("Should return empty array if there is no such parameter in the query", function () {
35
+ setCustomQueryString(`?a=val&b=val2`);
36
+ const result = getQueryParameterValues("c");
37
+
38
+ result.should.be.deepEqual([]);
39
+ });
40
+
41
+ it("Should return array with the only empty string element if the value of the parameter is empty", function () {
42
+ setCustomQueryString(`?a=`);
43
+ const result = getQueryParameterValues("a");
44
+
45
+ result.should.be.deepEqual([""]);
46
+ });
47
+
48
+ it("Should return array with one value", function () {
49
+ setCustomQueryString(`?a=val1`);
50
+ const result = getQueryParameterValues("a");
51
+
52
+ result.should.be.deepEqual(["val1"]);
53
+ });
54
+
55
+ it("Should return array with several values", function () {
56
+ setCustomQueryString(`?a=${encodeURIComponent("val1|*|val2")}`);
57
+ const result = getQueryParameterValues("a");
58
+
59
+ result.should.be.deepEqual(["val1", "val2"]);
60
+ });
61
+
62
+ it("Should return array of all values if parameter is defined several times in the query", function () {
63
+ setCustomQueryString(
64
+ `?a=${encodeURIComponent("val1|*|val2")}&a=val3`
65
+ );
66
+ const result = getQueryParameterValues("a");
67
+
68
+ result.should.be.deepEqual(["val1", "val2", "val3"]);
69
+ });
70
+ });
71
+ });
@@ -0,0 +1,144 @@
1
+ import sinon from "sinon";
2
+ import should from "should";
3
+
4
+ import { beforeEach, afterEach, describe, it } from "vitest";
5
+ import { saveQueryParameterAndValues } from "../../../utils/urlQueryUtils.js";
6
+
7
+ describe("urlQueryUtils", function () {
8
+ describe("#saveQueryParameterAndValues", function () {
9
+ let callbackStub;
10
+ beforeEach(function () {
11
+ callbackStub = sinon.stub();
12
+ });
13
+
14
+ afterEach(function () {
15
+ global.window = {};
16
+ });
17
+
18
+ function setCustomQueryString(query) {
19
+ global.window = {
20
+ location: {
21
+ search: query,
22
+ },
23
+ };
24
+ }
25
+
26
+ it("Should escape parameter values", function () {
27
+ setCustomQueryString("");
28
+ const result = saveQueryParameterAndValues(
29
+ "a",
30
+ ["e #e"],
31
+ callbackStub
32
+ );
33
+ result.should.be.equal(`?a=${encodeURIComponent("e #e")}`);
34
+ });
35
+
36
+ it("Should call callback ones", function () {
37
+ setCustomQueryString("");
38
+ saveQueryParameterAndValues("a", ["1"], callbackStub);
39
+ callbackStub.callCount.should.be.equal(1);
40
+ });
41
+
42
+ it("Should add parameter with no values - Case query is empty", function () {
43
+ setCustomQueryString("");
44
+ const result = saveQueryParameterAndValues("a", [], callbackStub);
45
+ result.should.be.equal("?a=");
46
+ });
47
+
48
+ it("Should add parameter with no values - Case query contains one parameter", function () {
49
+ setCustomQueryString("?one=val");
50
+ const result = saveQueryParameterAndValues("a", [], callbackStub);
51
+ result.should.be.equal("?one=val&a=");
52
+ });
53
+
54
+ it("Should add parameter with no values - Case query contains several parameters", function () {
55
+ setCustomQueryString("?one=val&err=week");
56
+ const result = saveQueryParameterAndValues("a", [], callbackStub);
57
+ result.should.be.equal("?one=val&err=week&a=");
58
+ });
59
+
60
+ it("Should add parameter with one value - Case query is empty", function () {
61
+ setCustomQueryString("");
62
+ const result = saveQueryParameterAndValues(
63
+ "a",
64
+ ["1"],
65
+ callbackStub
66
+ );
67
+ result.should.be.equal("?a=1");
68
+ });
69
+
70
+ it("Should add parameter with one value - Case query contains one parameter", function () {
71
+ setCustomQueryString("?one=val");
72
+ const result = saveQueryParameterAndValues(
73
+ "a",
74
+ ["1"],
75
+ callbackStub
76
+ );
77
+ result.should.be.equal("?one=val&a=1");
78
+ });
79
+
80
+ it("Should add parameter with one value - Case query contains several parameters", function () {
81
+ setCustomQueryString("?one=val&err=week");
82
+ const result = saveQueryParameterAndValues(
83
+ "a",
84
+ ["1"],
85
+ callbackStub
86
+ );
87
+ result.should.be.equal("?one=val&err=week&a=1");
88
+ });
89
+
90
+ it("Should add parameter with several values using separator - Case query is empty", function () {
91
+ setCustomQueryString("");
92
+ const result = saveQueryParameterAndValues(
93
+ "a",
94
+ ["1", "aa", "err"],
95
+ callbackStub
96
+ );
97
+ result.should.be.equal(`?a=${encodeURIComponent("1|*|aa|*|err")}`);
98
+ });
99
+
100
+ it("Should add parameter with several values using separator - Case query contains one parameter", function () {
101
+ setCustomQueryString("?one=val");
102
+ const result = saveQueryParameterAndValues(
103
+ "a",
104
+ ["1", "aa", "err"],
105
+ callbackStub
106
+ );
107
+ result.should.be.equal(
108
+ `?one=val&a=${encodeURIComponent("1|*|aa|*|err")}`
109
+ );
110
+ });
111
+
112
+ it("Should add parameter with several values using separator - Case query contains several parameters", function () {
113
+ setCustomQueryString("?one=val&err=week");
114
+ const result = saveQueryParameterAndValues(
115
+ "a",
116
+ ["1", "aa", "err"],
117
+ callbackStub
118
+ );
119
+ result.should.be.equal(
120
+ `?one=val&err=week&a=${encodeURIComponent("1|*|aa|*|err")}`
121
+ );
122
+ });
123
+
124
+ it("Should replace existing parameter value - Case query contains one parameter", function () {
125
+ setCustomQueryString("?a=val");
126
+ const result = saveQueryParameterAndValues(
127
+ "a",
128
+ ["1"],
129
+ callbackStub
130
+ );
131
+ result.should.be.equal("?a=1");
132
+ });
133
+
134
+ it("Should replace existing parameter value - Case query contains several parameters", function () {
135
+ setCustomQueryString("?one=val&a=week");
136
+ const result = saveQueryParameterAndValues(
137
+ "a",
138
+ ["1"],
139
+ callbackStub
140
+ );
141
+ result.should.be.equal("?one=val&a=1");
142
+ });
143
+ });
144
+ });
@@ -0,0 +1,58 @@
1
+ import { BigNumber } from "bignumber.js";
2
+
3
+ export class InputValuesProviders {
4
+ /**
5
+ * Designed to be called onKeyUp event of html input field for float value
6
+ * Removes all prohibited stuff from the given float string and remains only allowed.
7
+ * Removes digits before and after the dot.
8
+ *
9
+ * @param inputString {string} string to be corrected
10
+ * @param maxValue {string} max value for the correcting float value
11
+ * @param digitsAfterDot {number} count of digits after the dot that this method should provide, min 0
12
+ * @return {string} corrected float value string
13
+ */
14
+ static provideFormatOfFloatValueByInputString(
15
+ inputString,
16
+ digitsAfterDot = 2,
17
+ maxValue = null
18
+ ) {
19
+ let value = inputString;
20
+ if (!value) {
21
+ return "";
22
+ }
23
+
24
+ if (digitsAfterDot < 0) {
25
+ throw new Error("Min suffix length is 0, got " + digitsAfterDot);
26
+ }
27
+
28
+ value = value.replace(/[,]/g, "."); // replaces commas with dots
29
+ value = value.replace(/[^0-9.]/g, ""); // remove non digits/dots
30
+ value = value.replace(/^\./g, "0."); // adds leading zero
31
+ value = value.replace(/\.+/g, "."); // replaces series of dots with single dot
32
+
33
+ let parts = value.split(".");
34
+ if (parts.length > 2) {
35
+ // removes all after second dot and itself
36
+ parts = [parts[0], parts[1]];
37
+ }
38
+
39
+ if (maxValue != null) {
40
+ const maxDigitsCountBeforeTheDot =
41
+ BigNumber(maxValue).toFixed(0).length;
42
+ if (parts[0]?.length > maxDigitsCountBeforeTheDot) {
43
+ // removes redundant prefix digits
44
+ parts[0] = parts[0].substring(
45
+ parts[0].length - maxDigitsCountBeforeTheDot,
46
+ parts[0].length
47
+ );
48
+ }
49
+ }
50
+
51
+ if (parts[1]?.length > digitsAfterDot) {
52
+ // removes redundant suffix digits
53
+ parts[1] = parts[1].substring(0, digitsAfterDot);
54
+ }
55
+
56
+ return parts.join(".");
57
+ }
58
+ }
@@ -0,0 +1 @@
1
+ export const DIALOG_STEP_CLASS = "dialog-step";
@@ -0,0 +1,29 @@
1
+ // If changed - update the prop configuration in the stories and related components.
2
+ export const DIALOG_SIZES = {
3
+ small: {
4
+ width: "550px",
5
+ height: "650px",
6
+ },
7
+ regular: {
8
+ width: "600px",
9
+ height: "650px",
10
+ },
11
+ large: {
12
+ width: "700px",
13
+ height: "650px",
14
+ },
15
+ largePlus: {
16
+ width: "750px",
17
+ height: "650px",
18
+ },
19
+ largePlusPlus: {
20
+ width: "800px",
21
+ height: "650px",
22
+ },
23
+ extraLarge: {
24
+ width: "1000px",
25
+ height: "650px",
26
+ },
27
+ };
28
+
29
+ export const DIALOG_TRANSITION_STEP_DURATION = 200;
package/src/index.js CHANGED
@@ -3,10 +3,21 @@ export { Button } from "./components/atoms/buttons/Button/Button.jsx";
3
3
  export { LoadingDots } from "./components/atoms/LoadingDots/LoadingDots.jsx";
4
4
  export { SupportChat } from "./components/atoms/SupportChat/SupportChat.jsx";
5
5
  export { AssetIcon } from "./components/atoms/AssetIcon/AssetIcon.jsx";
6
+ export { LinkButton } from "./components/atoms/buttons/LinkButton/LinkButton.jsx";
7
+ export { DialogButtons } from "./components/organisms/Dialog/DialogButtons/DialogButtons.jsx";
8
+ export { BackgroundTitle } from "./components/atoms/BackgroundTitle/BackgroundTitle.jsx";
9
+ export {
10
+ Close,
11
+ CLOSE_COLORS,
12
+ } from "./components/atoms/buttons/Close/Close.jsx";
13
+ export { Validation } from "./components/atoms/Validation/Validation.jsx";
14
+ export { Dialog } from "./components/organisms/Dialog/Dialog.jsx";
15
+ export { DialogStep } from "./components/organisms/Dialog/DialogStep/DialogStep.jsx";
6
16
 
7
17
  export { useCallHandlingErrors } from "./components/hooks/useCallHandlingErrors.js";
8
18
  export { useReferredState } from "./components/hooks/useReferredState.js";
9
19
  export { handleClickOutside } from "./components/utils/uiUtils.js";
20
+ export { InputValuesProviders } from "./components/utils/inputValueProviders.js";
10
21
 
11
22
  export { saveQueryParameterAndValues } from "./components/utils/urlQueryUtils.js";
12
23
  export { removeQueryParameterAndValues } from "./components/utils/urlQueryUtils.js";
@@ -46,7 +46,9 @@ export class RobustExternalAPICallerService {
46
46
  this.providers = providersData;
47
47
  providersData.forEach((provider) => provider.resetNiceFactor());
48
48
  this.bio = bio;
49
- this._logger = Logger.logError;
49
+ this._logger = (...args) => {
50
+ Logger.logError(...args);
51
+ };
50
52
  }
51
53
 
52
54
  static defaultRPSFactor = 1;