@rabbitio/ui-kit 1.0.0-beta.36 → 1.0.0-beta.38
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/dist/index.cjs +108 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +81 -2
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +103 -2
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +108 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/common/errorUtils.js +15 -0
- package/src/components/utils/uiUtils.js +14 -0
- package/src/components/utils/urlQueryUtils.js +87 -0
- package/src/index.js +7 -0
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1681,6 +1681,96 @@ function useReferredState(initialValue) {
|
|
|
1681
1681
|
return [reference, setReferredState];
|
|
1682
1682
|
}
|
|
1683
1683
|
|
|
1684
|
+
var handleClickOutside = function handleClickOutside(exceptionsRefs, callback) {
|
|
1685
|
+
function handleClick(event) {
|
|
1686
|
+
var isExceptionClicked = exceptionsRefs.find(function (ref) {
|
|
1687
|
+
return (ref == null ? void 0 : ref.current) && ref.current.contains(event.target);
|
|
1688
|
+
});
|
|
1689
|
+
if (!isExceptionClicked) {
|
|
1690
|
+
callback();
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
document.addEventListener("click", handleClick);
|
|
1694
|
+
return function () {
|
|
1695
|
+
return document.removeEventListener("click", handleClick);
|
|
1696
|
+
};
|
|
1697
|
+
};
|
|
1698
|
+
|
|
1699
|
+
var PARAMETER_VALUES_SEPARATOR = "|*|"; // Sting that with high probability will not be in the user's data
|
|
1700
|
+
|
|
1701
|
+
/**
|
|
1702
|
+
* Adds specified parameter with values to the URL query string
|
|
1703
|
+
*
|
|
1704
|
+
* @param parameterName - String - name of the parameter
|
|
1705
|
+
* @param values - Array of String values
|
|
1706
|
+
* @param updateURLCallback - callback that will be called with the updated query string. Can be used to save it to URL
|
|
1707
|
+
*/
|
|
1708
|
+
function saveQueryParameterAndValues(parameterName, values, updateURLCallback) {
|
|
1709
|
+
if (updateURLCallback === void 0) {
|
|
1710
|
+
updateURLCallback = function updateURLCallback(newQueryString) {};
|
|
1711
|
+
}
|
|
1712
|
+
var parametersAndValues = parseSearchString();
|
|
1713
|
+
parametersAndValues = parametersAndValues.filter(function (parameterAndValues) {
|
|
1714
|
+
return parameterAndValues[0] !== parameterName;
|
|
1715
|
+
});
|
|
1716
|
+
var parameterValuesForURL = encodeURIComponent(values.join(PARAMETER_VALUES_SEPARATOR));
|
|
1717
|
+
parametersAndValues.push([parameterName, parameterValuesForURL]);
|
|
1718
|
+
var newQueryString = "?" + parametersAndValues.map(function (parameterAndValues) {
|
|
1719
|
+
return parameterAndValues.join("=");
|
|
1720
|
+
}).join("&");
|
|
1721
|
+
updateURLCallback(newQueryString);
|
|
1722
|
+
return newQueryString;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
/**
|
|
1726
|
+
* Removes specified parameter with values from the URL query string
|
|
1727
|
+
*
|
|
1728
|
+
* @param parameterName - String - name of the parameter
|
|
1729
|
+
* @param updateURLCallback - callback that will be called with the updated query string. Can be used to save it to URL
|
|
1730
|
+
*/
|
|
1731
|
+
// TODO: [tests, moderate] units required the same as or other functions in this module
|
|
1732
|
+
function removeQueryParameterAndValues(parameterName, updateURLCallback) {
|
|
1733
|
+
if (updateURLCallback === void 0) {
|
|
1734
|
+
updateURLCallback = function updateURLCallback(newQueryString) {};
|
|
1735
|
+
}
|
|
1736
|
+
var parametersAndValues = parseSearchString();
|
|
1737
|
+
parametersAndValues = parametersAndValues.filter(function (parameterAndValues) {
|
|
1738
|
+
return parameterAndValues[0] !== parameterName;
|
|
1739
|
+
});
|
|
1740
|
+
var newQueryString = "?" + parametersAndValues.map(function (parameterAndValues) {
|
|
1741
|
+
return parameterAndValues.join("=");
|
|
1742
|
+
}).join("&");
|
|
1743
|
+
updateURLCallback(newQueryString);
|
|
1744
|
+
return newQueryString;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* Retrieves parameter values from the URL query string.
|
|
1749
|
+
*
|
|
1750
|
+
* If there are several parameters with the same name in the URL then all their values are returned
|
|
1751
|
+
*
|
|
1752
|
+
* @param name {string} - parameter name
|
|
1753
|
+
* @return {string[]} [] - if the parameter is not present in URL. [""] - if parameter present but has empty value
|
|
1754
|
+
*/
|
|
1755
|
+
function getQueryParameterValues(name) {
|
|
1756
|
+
return parseSearchString().filter(function (parameterAndValue) {
|
|
1757
|
+
return parameterAndValue[0] === name;
|
|
1758
|
+
}).reduce(function (allValues, parameterAndValue) {
|
|
1759
|
+
var values = decodeURIComponent(parameterAndValue[1] || "").split(PARAMETER_VALUES_SEPARATOR);
|
|
1760
|
+
return [].concat(allValues, values);
|
|
1761
|
+
}, []);
|
|
1762
|
+
}
|
|
1763
|
+
function parseSearchString() {
|
|
1764
|
+
var _window$location$sear;
|
|
1765
|
+
var trimmed = (((_window$location$sear = window.location.search) == null ? void 0 : _window$location$sear.slice(1)) || "").trim();
|
|
1766
|
+
return trimmed && trimmed.split("&").map(function (parameterAndValue) {
|
|
1767
|
+
return parameterAndValue.split("=");
|
|
1768
|
+
}) || [];
|
|
1769
|
+
}
|
|
1770
|
+
function getQueryParameterSingleValue(name) {
|
|
1771
|
+
return (getQueryParameterValues(name) || [])[0];
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1684
1774
|
/**
|
|
1685
1775
|
* This function improves the passed error object (its message) by adding the passed function name
|
|
1686
1776
|
* and additional message to it.
|
|
@@ -1709,6 +1799,17 @@ function improvedErrorMessage(e, settingFunction, additionalMessage) {
|
|
|
1709
1799
|
additionalMessage && (message += additionalMessage + " ");
|
|
1710
1800
|
return message;
|
|
1711
1801
|
}
|
|
1802
|
+
function logErrorOrOutputToConsole(e) {
|
|
1803
|
+
try {
|
|
1804
|
+
// TODO: [dev] remove this after few weeks of testing output in real life
|
|
1805
|
+
// eslint-disable-next-line no-console
|
|
1806
|
+
console.log("BEFORE SAFE", e);
|
|
1807
|
+
Logger.log("logErrorOrOutputToConsole", safeStringify(e));
|
|
1808
|
+
} catch (e) {
|
|
1809
|
+
// eslint-disable-next-line no-console
|
|
1810
|
+
console.log("logErrorOrOutputToConsole", e);
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1712
1813
|
|
|
1713
1814
|
var FiatCurrenciesService = /*#__PURE__*/function () {
|
|
1714
1815
|
function FiatCurrenciesService() {}
|
|
@@ -3001,7 +3102,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3001
3102
|
}
|
|
3002
3103
|
_this = _SwapProvider.call(this) || this;
|
|
3003
3104
|
_this._supportedCoins = [];
|
|
3004
|
-
_this._URL =
|
|
3105
|
+
_this._URL = "" + apiKeysProxyUrl;
|
|
3005
3106
|
_this._maxRateDigits = 20;
|
|
3006
3107
|
_this.useRestrictedCoinsSet = useRestrictedCoinsSet;
|
|
3007
3108
|
_this._customCoinBuilder = customCoinBuilder;
|
|
@@ -4606,8 +4707,14 @@ exports.SupportChat = SupportChat;
|
|
|
4606
4707
|
exports.SwapProvider = SwapProvider;
|
|
4607
4708
|
exports.SwapUtils = SwapUtils;
|
|
4608
4709
|
exports.SwapspaceSwapProvider = SwapspaceSwapProvider;
|
|
4710
|
+
exports.getQueryParameterSingleValue = getQueryParameterSingleValue;
|
|
4711
|
+
exports.getQueryParameterValues = getQueryParameterValues;
|
|
4712
|
+
exports.handleClickOutside = handleClickOutside;
|
|
4609
4713
|
exports.improveAndRethrow = improveAndRethrow;
|
|
4714
|
+
exports.logErrorOrOutputToConsole = logErrorOrOutputToConsole;
|
|
4715
|
+
exports.removeQueryParameterAndValues = removeQueryParameterAndValues;
|
|
4610
4716
|
exports.safeStringify = safeStringify;
|
|
4717
|
+
exports.saveQueryParameterAndValues = saveQueryParameterAndValues;
|
|
4611
4718
|
exports.useCallHandlingErrors = useCallHandlingErrors;
|
|
4612
4719
|
exports.useReferredState = useReferredState;
|
|
4613
4720
|
//# sourceMappingURL=index.cjs.map
|