kui-utils 0.0.11 → 0.0.12
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/cjs/index.js +44 -0
- package/cjs/index.js.map +1 -1
- package/index.d.ts +22 -2
- package/index.js +44 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -2064,6 +2064,31 @@ function getCookie(name) {
|
|
|
2064
2064
|
return matches ? decodeURIComponent(matches[1]) : undefined;
|
|
2065
2065
|
}
|
|
2066
2066
|
|
|
2067
|
+
var KUIUtilsSettings = /** @class */ (function () {
|
|
2068
|
+
function KUIUtilsSettings() {
|
|
2069
|
+
var _this = this;
|
|
2070
|
+
this.getSettings = function () { return (__assign({}, _this.settings)); };
|
|
2071
|
+
this.setSettings = function (newSettings) {
|
|
2072
|
+
_this.settings = __assign(__assign({}, _this.settings), newSettings);
|
|
2073
|
+
_this.observers.forEach(function (observer) { return observer(_this.settings); });
|
|
2074
|
+
};
|
|
2075
|
+
this.subscribeToSettings = function (observer) {
|
|
2076
|
+
_this.observers.push(observer);
|
|
2077
|
+
};
|
|
2078
|
+
this.unsubscribeFromSettings = function (observer) {
|
|
2079
|
+
var index = _this.observers.indexOf(observer);
|
|
2080
|
+
if (index !== -1)
|
|
2081
|
+
_this.observers.splice(index, 1);
|
|
2082
|
+
};
|
|
2083
|
+
this.settings = {};
|
|
2084
|
+
this.observers = [];
|
|
2085
|
+
this.id = Math.random() * 100;
|
|
2086
|
+
}
|
|
2087
|
+
return KUIUtilsSettings;
|
|
2088
|
+
}());
|
|
2089
|
+
var kuiUtilsSettings = new KUIUtilsSettings();
|
|
2090
|
+
|
|
2091
|
+
var delayTime = 600;
|
|
2067
2092
|
var Loader = /** @class */ (function () {
|
|
2068
2093
|
function Loader(isLoading) {
|
|
2069
2094
|
var _this = this;
|
|
@@ -2074,8 +2099,24 @@ var Loader = /** @class */ (function () {
|
|
|
2074
2099
|
_this.cleanError();
|
|
2075
2100
|
};
|
|
2076
2101
|
this.endLoading = function () {
|
|
2102
|
+
var runMode = kuiUtilsSettings.getSettings().runMode;
|
|
2103
|
+
if (runMode === "test") {
|
|
2104
|
+
_this.isLoading = false;
|
|
2105
|
+
return null;
|
|
2106
|
+
}
|
|
2107
|
+
_this.timeAfterLoading = new Date().getTime();
|
|
2108
|
+
if (_this.timeAfterLoading - _this.timeBeforeLoading < delayTime) {
|
|
2109
|
+
return new Promise(function (resolve) {
|
|
2110
|
+
// eslint-disable-next-line no-promise-executor-return
|
|
2111
|
+
return setTimeout(function () {
|
|
2112
|
+
_this.isLoading = false;
|
|
2113
|
+
resolve(true);
|
|
2114
|
+
}, delayTime - (_this.timeAfterLoading - _this.timeBeforeLoading));
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2077
2117
|
_this.isLoading = false;
|
|
2078
2118
|
_this.loadingMessage = "";
|
|
2119
|
+
return null;
|
|
2079
2120
|
};
|
|
2080
2121
|
this.setError = function (errorMessage, err) {
|
|
2081
2122
|
_this.hasError = true;
|
|
@@ -2087,6 +2128,8 @@ var Loader = /** @class */ (function () {
|
|
|
2087
2128
|
};
|
|
2088
2129
|
this.isLoading = !!isLoading;
|
|
2089
2130
|
this.hasError = false;
|
|
2131
|
+
this.timeBeforeLoading = 0;
|
|
2132
|
+
this.timeAfterLoading = 0;
|
|
2090
2133
|
mobx.makeAutoObservable(this);
|
|
2091
2134
|
}
|
|
2092
2135
|
return Loader;
|
|
@@ -2309,6 +2352,7 @@ var mediumPasswordRegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{12,
|
|
|
2309
2352
|
var strongPasswordRegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{14,}$/;
|
|
2310
2353
|
|
|
2311
2354
|
exports.Editor = Editor;
|
|
2355
|
+
exports.KUIUtilsSettings = kuiUtilsSettings;
|
|
2312
2356
|
exports.Loader = Loader;
|
|
2313
2357
|
exports.MultistepForm = MultistepForm;
|
|
2314
2358
|
exports.Paginator = Paginator;
|