@cashub/ui 0.6.0 → 0.6.1
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/index.js +13 -0
- package/package.json +1 -1
- package/module/geolocation/api.js +0 -51
- package/module/message/index.js +0 -59
- package/services/api/index.js +0 -73
package/index.js
CHANGED
|
@@ -17,6 +17,19 @@ Object.keys(_animate).forEach(function (key) {
|
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
+
var _backdrop = require("./backdrop");
|
|
21
|
+
|
|
22
|
+
Object.keys(_backdrop).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _backdrop[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _backdrop[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
20
33
|
var _badge = require("./badge");
|
|
21
34
|
|
|
22
35
|
Object.keys(_badge).forEach(function (key) {
|
package/package.json
CHANGED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getReverseGeolocation = exports.getGeolocationByAddress = void 0;
|
|
7
|
-
|
|
8
|
-
var _api = require("../../services/api");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* call osm nominatim reverse geolocation service
|
|
12
|
-
*
|
|
13
|
-
* @param {Object} coordinates The coordinates to convert
|
|
14
|
-
* @param {Object.latitude}
|
|
15
|
-
* @param {Object.longitude}
|
|
16
|
-
*
|
|
17
|
-
* @fires cashub.reverse.geo.done
|
|
18
|
-
*/
|
|
19
|
-
var getReverseGeolocation = function getReverseGeolocation(coordinates) {
|
|
20
|
-
return _api.callApi.get('https://nominatim.openstreetmap.org/reverse', {
|
|
21
|
-
params: {
|
|
22
|
-
lat: coordinates.lat,
|
|
23
|
-
lon: coordinates.lng,
|
|
24
|
-
format: 'json',
|
|
25
|
-
'accept-language': window.navigator.language || window.navigator.languages[0]
|
|
26
|
-
},
|
|
27
|
-
external: true
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* call osm nominatim search geolocation service
|
|
32
|
-
*
|
|
33
|
-
* @param {String} address The address to convert
|
|
34
|
-
*
|
|
35
|
-
* @fires cashub.reverse.geo.done
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
exports.getReverseGeolocation = getReverseGeolocation;
|
|
40
|
-
|
|
41
|
-
var getGeolocationByAddress = function getGeolocationByAddress(address) {
|
|
42
|
-
return _api.callApi.get('https://nominatim.openstreetmap.org/search', {
|
|
43
|
-
params: {
|
|
44
|
-
q: address,
|
|
45
|
-
format: 'json'
|
|
46
|
-
},
|
|
47
|
-
external: true
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
exports.getGeolocationByAddress = getGeolocationByAddress;
|
package/module/message/index.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.warning = exports.success = exports.error = void 0;
|
|
7
|
-
|
|
8
|
-
var _reactToastify = require("react-toastify");
|
|
9
|
-
|
|
10
|
-
var _MessageContainer = _interopRequireDefault(require("../../toast/MessageContainer"));
|
|
11
|
-
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
var success = function success(_ref) {
|
|
17
|
-
var title = _ref.title,
|
|
18
|
-
message = _ref.message,
|
|
19
|
-
_ref$containHTML = _ref.containHTML,
|
|
20
|
-
containHTML = _ref$containHTML === void 0 ? false : _ref$containHTML;
|
|
21
|
-
|
|
22
|
-
_reactToastify.toast.success( /*#__PURE__*/(0, _jsxRuntime.jsx)(_MessageContainer.default, {
|
|
23
|
-
title: title,
|
|
24
|
-
message: message,
|
|
25
|
-
containHTML: containHTML
|
|
26
|
-
}));
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
exports.success = success;
|
|
30
|
-
|
|
31
|
-
var error = function error(_ref2) {
|
|
32
|
-
var title = _ref2.title,
|
|
33
|
-
message = _ref2.message,
|
|
34
|
-
_ref2$containHTML = _ref2.containHTML,
|
|
35
|
-
containHTML = _ref2$containHTML === void 0 ? false : _ref2$containHTML;
|
|
36
|
-
|
|
37
|
-
_reactToastify.toast.error( /*#__PURE__*/(0, _jsxRuntime.jsx)(_MessageContainer.default, {
|
|
38
|
-
title: title,
|
|
39
|
-
message: message,
|
|
40
|
-
containHTML: containHTML
|
|
41
|
-
}));
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
exports.error = error;
|
|
45
|
-
|
|
46
|
-
var warning = function warning(_ref3) {
|
|
47
|
-
var title = _ref3.title,
|
|
48
|
-
message = _ref3.message,
|
|
49
|
-
_ref3$containHTML = _ref3.containHTML,
|
|
50
|
-
containHTML = _ref3$containHTML === void 0 ? false : _ref3$containHTML;
|
|
51
|
-
|
|
52
|
-
_reactToastify.toast.warning( /*#__PURE__*/(0, _jsxRuntime.jsx)(_MessageContainer.default, {
|
|
53
|
-
title: title,
|
|
54
|
-
message: message,
|
|
55
|
-
containHTML: containHTML
|
|
56
|
-
}));
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
exports.warning = warning;
|
package/services/api/index.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.callApi = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
|
|
10
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
// Create axios instance for set default config
|
|
15
|
-
var numberOfAjaxCallPending = 0;
|
|
16
|
-
|
|
17
|
-
var callApi = _axios.default.create({
|
|
18
|
-
baseURL: '/api'
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
exports.callApi = callApi;
|
|
22
|
-
|
|
23
|
-
var AxiosInterceptor = function AxiosInterceptor(_ref) {
|
|
24
|
-
var onBeforeSend = _ref.onBeforeSend,
|
|
25
|
-
onDone = _ref.onDone,
|
|
26
|
-
onAllDone = _ref.onAllDone;
|
|
27
|
-
var countAjaxCall = (0, _react.useCallback)(function () {
|
|
28
|
-
if (numberOfAjaxCallPending > 0) {
|
|
29
|
-
numberOfAjaxCallPending -= 1;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (numberOfAjaxCallPending === 0) {
|
|
33
|
-
onAllDone();
|
|
34
|
-
}
|
|
35
|
-
}, [onAllDone]);
|
|
36
|
-
(0, _react.useEffect)(function () {
|
|
37
|
-
var requestInterceptor = callApi.interceptors.request.use(function (config) {
|
|
38
|
-
if (config.global !== false) {
|
|
39
|
-
numberOfAjaxCallPending += 1;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (typeof onBeforeSend === 'function') {
|
|
43
|
-
return onBeforeSend(config);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return config;
|
|
47
|
-
}, function (error) {
|
|
48
|
-
countAjaxCall();
|
|
49
|
-
return Promise.reject(error);
|
|
50
|
-
});
|
|
51
|
-
var responseInterceptor = callApi.interceptors.response.use(function (response) {
|
|
52
|
-
if (!response) return response;
|
|
53
|
-
countAjaxCall();
|
|
54
|
-
|
|
55
|
-
if (typeof onDone === 'function') {
|
|
56
|
-
return onDone(response);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return response;
|
|
60
|
-
}, function (error) {
|
|
61
|
-
countAjaxCall();
|
|
62
|
-
return Promise.reject(error);
|
|
63
|
-
});
|
|
64
|
-
return function () {
|
|
65
|
-
callApi.interceptors.request.eject(requestInterceptor);
|
|
66
|
-
callApi.interceptors.response.eject(responseInterceptor);
|
|
67
|
-
};
|
|
68
|
-
}, [onBeforeSend, onDone, countAjaxCall]);
|
|
69
|
-
return null;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
var _default = AxiosInterceptor;
|
|
73
|
-
exports.default = _default;
|