kui-utils 0.0.10 → 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 +48 -0
- package/cjs/index.js.map +1 -1
- package/index.d.ts +23 -2
- package/index.js +48 -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;
|
|
@@ -2149,6 +2192,10 @@ var SortingFilter = /** @class */ (function () {
|
|
|
2149
2192
|
this.setOrderBy = function (orderBy) {
|
|
2150
2193
|
_this.orderBy = orderBy;
|
|
2151
2194
|
};
|
|
2195
|
+
this.clearFilter = function () {
|
|
2196
|
+
_this.searchQuery = "";
|
|
2197
|
+
_this.filterQuery = "";
|
|
2198
|
+
};
|
|
2152
2199
|
this.searchQuery = "";
|
|
2153
2200
|
this.filterQuery = filterQuery || "";
|
|
2154
2201
|
this.order = order || "asc";
|
|
@@ -2305,6 +2352,7 @@ var mediumPasswordRegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{12,
|
|
|
2305
2352
|
var strongPasswordRegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{14,}$/;
|
|
2306
2353
|
|
|
2307
2354
|
exports.Editor = Editor;
|
|
2355
|
+
exports.KUIUtilsSettings = kuiUtilsSettings;
|
|
2308
2356
|
exports.Loader = Loader;
|
|
2309
2357
|
exports.MultistepForm = MultistepForm;
|
|
2310
2358
|
exports.Paginator = Paginator;
|