kui-utils 0.0.11 → 0.0.13
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/index.d.ts
CHANGED
|
@@ -69,9 +69,11 @@ declare class Loader {
|
|
|
69
69
|
hasError: boolean;
|
|
70
70
|
loadingMessage?: string;
|
|
71
71
|
errorMessage?: string;
|
|
72
|
+
private timeBeforeLoading;
|
|
73
|
+
private timeAfterLoading;
|
|
72
74
|
constructor(isLoading?: boolean);
|
|
73
75
|
startLoading: (message?: string | undefined, withoutCleanError?: boolean | undefined) => void;
|
|
74
|
-
endLoading: () =>
|
|
76
|
+
endLoading: () => Promise<unknown> | null;
|
|
75
77
|
setError: (errorMessage?: string | undefined, err?: any) => void;
|
|
76
78
|
cleanError: () => void;
|
|
77
79
|
}
|
|
@@ -186,4 +188,22 @@ declare const _default: ({
|
|
|
186
188
|
mask: boolean;
|
|
187
189
|
})[];
|
|
188
190
|
|
|
189
|
-
|
|
191
|
+
declare type KUIUtilsSettingsParams = {
|
|
192
|
+
runMode?: "production" | "development" | "test";
|
|
193
|
+
};
|
|
194
|
+
declare type KUICrmObserver = (settings: KUIUtilsSettingsParams) => void;
|
|
195
|
+
declare class KUIUtilsSettings {
|
|
196
|
+
settings: KUIUtilsSettingsParams;
|
|
197
|
+
observers: KUICrmObserver[];
|
|
198
|
+
id: number;
|
|
199
|
+
constructor();
|
|
200
|
+
getSettings: () => {
|
|
201
|
+
runMode?: "production" | "development" | "test" | undefined;
|
|
202
|
+
};
|
|
203
|
+
setSettings: (newSettings: KUIUtilsSettingsParams) => void;
|
|
204
|
+
subscribeToSettings: (observer: KUICrmObserver) => void;
|
|
205
|
+
unsubscribeFromSettings: (observer: KUICrmObserver) => void;
|
|
206
|
+
}
|
|
207
|
+
declare const kuiUtilsSettings: KUIUtilsSettings;
|
|
208
|
+
|
|
209
|
+
export { Editor, kuiUtilsSettings as KUIUtilsSettings, Loader, MultistepForm, ObjectType, PaginationRes, Paginator, PhoneParams, ResHandlerParams, SortOrder, SortingFilter, Values, accountRegExp, addLeadZero, addToArrayByCondition, applyMask, bicRegExp, callPromises, carNumberRegExp, checkIsIOS, cleanEmptyFields, clearNotValidFields, copyInfo, corrAccountRegExp, _default as countries, cropText, dateRegExp, declineByNumber, deleteCookie, emailRegExp, formatError, generateFormDataBody, getChangedValue, getCookie, getFileNameFromFile, getFileNameFromUrl, getNestedData, getPhoneNumberFromPhoneParams, getPhoneParamsFromString, innRegExp, isValidWithMaskExp, mediumPasswordRegExp, monthYearRegExp, phoneRegExp, promisesWithCallback, resHandler, setCookie, simplePasswordRegExp, strongPasswordRegExp, swiftRegExp, toNumber, updateQueryParams, useDebounce, useForkRef, useTabIndex, useToggle, useWindowWidth };
|
package/index.js
CHANGED
|
@@ -2038,6 +2038,31 @@ function getCookie(name) {
|
|
|
2038
2038
|
return matches ? decodeURIComponent(matches[1]) : undefined;
|
|
2039
2039
|
}
|
|
2040
2040
|
|
|
2041
|
+
var KUIUtilsSettings = /** @class */ (function () {
|
|
2042
|
+
function KUIUtilsSettings() {
|
|
2043
|
+
var _this = this;
|
|
2044
|
+
this.getSettings = function () { return (__assign({}, _this.settings)); };
|
|
2045
|
+
this.setSettings = function (newSettings) {
|
|
2046
|
+
_this.settings = __assign(__assign({}, _this.settings), newSettings);
|
|
2047
|
+
_this.observers.forEach(function (observer) { return observer(_this.settings); });
|
|
2048
|
+
};
|
|
2049
|
+
this.subscribeToSettings = function (observer) {
|
|
2050
|
+
_this.observers.push(observer);
|
|
2051
|
+
};
|
|
2052
|
+
this.unsubscribeFromSettings = function (observer) {
|
|
2053
|
+
var index = _this.observers.indexOf(observer);
|
|
2054
|
+
if (index !== -1)
|
|
2055
|
+
_this.observers.splice(index, 1);
|
|
2056
|
+
};
|
|
2057
|
+
this.settings = {};
|
|
2058
|
+
this.observers = [];
|
|
2059
|
+
this.id = Math.random() * 100;
|
|
2060
|
+
}
|
|
2061
|
+
return KUIUtilsSettings;
|
|
2062
|
+
}());
|
|
2063
|
+
var kuiUtilsSettings = new KUIUtilsSettings();
|
|
2064
|
+
|
|
2065
|
+
var delayTime = 600;
|
|
2041
2066
|
var Loader = /** @class */ (function () {
|
|
2042
2067
|
function Loader(isLoading) {
|
|
2043
2068
|
var _this = this;
|
|
@@ -2048,8 +2073,24 @@ var Loader = /** @class */ (function () {
|
|
|
2048
2073
|
_this.cleanError();
|
|
2049
2074
|
};
|
|
2050
2075
|
this.endLoading = function () {
|
|
2076
|
+
var runMode = kuiUtilsSettings.getSettings().runMode;
|
|
2077
|
+
if (runMode === "test") {
|
|
2078
|
+
_this.isLoading = false;
|
|
2079
|
+
return null;
|
|
2080
|
+
}
|
|
2081
|
+
_this.timeAfterLoading = new Date().getTime();
|
|
2082
|
+
if (_this.timeAfterLoading - _this.timeBeforeLoading < delayTime) {
|
|
2083
|
+
return new Promise(function (resolve) {
|
|
2084
|
+
// eslint-disable-next-line no-promise-executor-return
|
|
2085
|
+
return setTimeout(function () {
|
|
2086
|
+
_this.isLoading = false;
|
|
2087
|
+
resolve(true);
|
|
2088
|
+
}, delayTime - (_this.timeAfterLoading - _this.timeBeforeLoading));
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2051
2091
|
_this.isLoading = false;
|
|
2052
2092
|
_this.loadingMessage = "";
|
|
2093
|
+
return null;
|
|
2053
2094
|
};
|
|
2054
2095
|
this.setError = function (errorMessage, err) {
|
|
2055
2096
|
_this.hasError = true;
|
|
@@ -2061,6 +2102,8 @@ var Loader = /** @class */ (function () {
|
|
|
2061
2102
|
};
|
|
2062
2103
|
this.isLoading = !!isLoading;
|
|
2063
2104
|
this.hasError = false;
|
|
2105
|
+
this.timeBeforeLoading = 0;
|
|
2106
|
+
this.timeAfterLoading = 0;
|
|
2064
2107
|
makeAutoObservable(this);
|
|
2065
2108
|
}
|
|
2066
2109
|
return Loader;
|
|
@@ -2282,5 +2325,5 @@ var simplePasswordRegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{10,
|
|
|
2282
2325
|
var mediumPasswordRegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{12,}$/;
|
|
2283
2326
|
var strongPasswordRegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{14,}$/;
|
|
2284
2327
|
|
|
2285
|
-
export { Editor, Loader, MultistepForm, Paginator, SortingFilter, accountRegExp, addLeadZero, addToArrayByCondition, applyMask, bicRegExp, callPromises, carNumberRegExp, checkIsIOS, cleanEmptyFields, clearNotValidFields, copyInfo, corrAccountRegExp, countries, cropText, dateRegExp, declineByNumber, deleteCookie, emailRegExp, formatError, generateFormDataBody, getChangedValue, getCookie, getFileNameFromFile, getFileNameFromUrl, getNestedData, getPhoneNumberFromPhoneParams, getPhoneParamsFromString, innRegExp, isValidWithMaskExp, mediumPasswordRegExp, monthYearRegExp, phoneRegExp, promisesWithCallback, resHandler, setCookie, simplePasswordRegExp, strongPasswordRegExp, swiftRegExp, toNumber, updateQueryParams, useDebounce, useForkRef, useTabIndex, useToggle, useWindowWidth };
|
|
2328
|
+
export { Editor, kuiUtilsSettings as KUIUtilsSettings, Loader, MultistepForm, Paginator, SortingFilter, accountRegExp, addLeadZero, addToArrayByCondition, applyMask, bicRegExp, callPromises, carNumberRegExp, checkIsIOS, cleanEmptyFields, clearNotValidFields, copyInfo, corrAccountRegExp, countries, cropText, dateRegExp, declineByNumber, deleteCookie, emailRegExp, formatError, generateFormDataBody, getChangedValue, getCookie, getFileNameFromFile, getFileNameFromUrl, getNestedData, getPhoneNumberFromPhoneParams, getPhoneParamsFromString, innRegExp, isValidWithMaskExp, mediumPasswordRegExp, monthYearRegExp, phoneRegExp, promisesWithCallback, resHandler, setCookie, simplePasswordRegExp, strongPasswordRegExp, swiftRegExp, toNumber, updateQueryParams, useDebounce, useForkRef, useTabIndex, useToggle, useWindowWidth };
|
|
2286
2329
|
//# sourceMappingURL=index.js.map
|