dry-ux 1.29.0 → 1.31.0
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/helpers/DajaxiceProxy.d.ts +8 -2
- package/dist/helpers/DajaxiceProxy.js +30 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/ui-utils/Loader.d.ts +8 -0
- package/dist/ui-utils/Loader.js +157 -0
- package/dist/ui-utils/UIUtilProvider.d.ts +2 -2
- package/dist/ui-utils/UIUtilProvider.js +3 -3
- package/dist/ui-utils/uiUtil.interface.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
declare type Args<T = void> = {
|
|
2
2
|
args: T;
|
|
3
|
-
|
|
3
|
+
skip?: {
|
|
4
|
+
authCheck?: boolean;
|
|
5
|
+
errorHandler?: boolean;
|
|
6
|
+
loader?: boolean;
|
|
7
|
+
};
|
|
4
8
|
};
|
|
5
9
|
declare type ArgType<T> = T extends void ? Omit<Args, "args"> | void : Args<T>;
|
|
6
10
|
export declare type DajaxiceFn<TArgs = void> = <TResult = any>(args: ArgType<TArgs>) => Promise<TResult>;
|
|
@@ -10,11 +14,13 @@ export declare type DajaxiceFn<TArgs = void> = <TResult = any>(args: ArgType<TAr
|
|
|
10
14
|
* @param authCheck The auth check object. If undefined, it will not check for authentication.
|
|
11
15
|
* @returns A type safe proxy for calling Dajaxice functions.
|
|
12
16
|
*/
|
|
13
|
-
export declare const DajaxiceProxy: <TModule>({ modules, authCheck, }: {
|
|
17
|
+
export declare const DajaxiceProxy: <TModule>({ modules, authCheck, onError, loader, }: {
|
|
14
18
|
modules: TModule;
|
|
15
19
|
authCheck?: {
|
|
16
20
|
url: string;
|
|
17
21
|
redirectUrl: string;
|
|
18
22
|
};
|
|
23
|
+
onError?: (error: any) => void;
|
|
24
|
+
loader?: boolean;
|
|
19
25
|
}) => TModule;
|
|
20
26
|
export {};
|
|
@@ -2,28 +2,52 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DajaxiceProxy = void 0;
|
|
4
4
|
const utilities_1 = require("./utilities");
|
|
5
|
+
const Loader_1 = require("../ui-utils/Loader");
|
|
5
6
|
/**
|
|
6
7
|
* This function is used to create a type safe proxy for the Dajaxice functions.
|
|
7
8
|
* @param modules: The modules object from the Dajaxice generated file.
|
|
8
9
|
* @param authCheck The auth check object. If undefined, it will not check for authentication.
|
|
9
10
|
* @returns A type safe proxy for calling Dajaxice functions.
|
|
10
11
|
*/
|
|
11
|
-
const DajaxiceProxy = ({ modules, authCheck, }) => new Proxy(modules, {
|
|
12
|
+
const DajaxiceProxy = ({ modules, authCheck, onError, loader: showLoader, }) => new Proxy(modules, {
|
|
12
13
|
get(target, module) {
|
|
13
14
|
return new Proxy({}, {
|
|
14
15
|
get(target, method) {
|
|
15
|
-
return function ({ args,
|
|
16
|
+
return function ({ args, skip } = {}) {
|
|
16
17
|
return new Promise((resolve, reject) => {
|
|
17
18
|
const methodName = window["Dajaxice"][module][method];
|
|
19
|
+
const loader = showLoader && !(skip === null || skip === void 0 ? void 0 : skip.loader) ? new Loader_1.Loader() : undefined;
|
|
20
|
+
const hideLoader = () => {
|
|
21
|
+
try {
|
|
22
|
+
loader === null || loader === void 0 ? void 0 : loader.hide();
|
|
23
|
+
}
|
|
24
|
+
catch (e) { }
|
|
25
|
+
};
|
|
18
26
|
if (methodName) {
|
|
19
|
-
const
|
|
20
|
-
|
|
27
|
+
const handleError = (e) => {
|
|
28
|
+
try {
|
|
29
|
+
!(skip === null || skip === void 0 ? void 0 : skip.errorHandler) && (onError === null || onError === void 0 ? void 0 : onError(e));
|
|
30
|
+
}
|
|
31
|
+
catch (e) { }
|
|
32
|
+
hideLoader();
|
|
33
|
+
reject(e);
|
|
34
|
+
};
|
|
35
|
+
const handleSuccess = (result) => {
|
|
36
|
+
hideLoader();
|
|
37
|
+
resolve(result);
|
|
38
|
+
};
|
|
39
|
+
const fn = () => methodName(handleSuccess, args, {
|
|
40
|
+
error_callback: handleError,
|
|
21
41
|
});
|
|
22
|
-
|
|
42
|
+
try {
|
|
43
|
+
loader === null || loader === void 0 ? void 0 : loader.show();
|
|
44
|
+
}
|
|
45
|
+
catch (e) { }
|
|
46
|
+
if ((skip === null || skip === void 0 ? void 0 : skip.authCheck) || !authCheck) {
|
|
23
47
|
fn();
|
|
24
48
|
}
|
|
25
49
|
else {
|
|
26
|
-
(0, utilities_1.fnWithAuthCheck)(fn, authCheck.url, authCheck.redirectUrl).catch(
|
|
50
|
+
(0, utilities_1.fnWithAuthCheck)(fn, authCheck.url, authCheck.redirectUrl).catch(handleError);
|
|
27
51
|
}
|
|
28
52
|
}
|
|
29
53
|
else {
|
package/dist/index.d.ts
CHANGED
|
@@ -9,3 +9,4 @@ export { flatten, unflatten } from "./helpers/flat";
|
|
|
9
9
|
export { DajaxiceFn, DajaxiceProxy } from "./helpers/DajaxiceProxy";
|
|
10
10
|
export { ErrorBoundary } from "./error/ErrorBoundary";
|
|
11
11
|
export { ErrorScreen } from "./error/ErrorScreen";
|
|
12
|
+
export { Loader } from "./ui-utils/Loader";
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ErrorScreen = exports.ErrorBoundary = exports.DajaxiceProxy = exports.unflatten = exports.flatten = exports.classSet = exports.DryUXProvider = exports.Money = exports.DryUXRenderer = exports.DryUXContext = exports.useDryUxContext = void 0;
|
|
17
|
+
exports.Loader = exports.ErrorScreen = exports.ErrorBoundary = exports.DajaxiceProxy = exports.unflatten = exports.flatten = exports.classSet = exports.DryUXProvider = exports.Money = exports.DryUXRenderer = exports.DryUXContext = exports.useDryUxContext = void 0;
|
|
18
18
|
var UIUtilProvider_1 = require("./ui-utils/UIUtilProvider");
|
|
19
19
|
Object.defineProperty(exports, "useDryUxContext", { enumerable: true, get: function () { return UIUtilProvider_1.useUIUtilContext; } });
|
|
20
20
|
Object.defineProperty(exports, "DryUXContext", { enumerable: true, get: function () { return UIUtilProvider_1.UIUtilContext; } });
|
|
@@ -37,3 +37,5 @@ var ErrorBoundary_1 = require("./error/ErrorBoundary");
|
|
|
37
37
|
Object.defineProperty(exports, "ErrorBoundary", { enumerable: true, get: function () { return ErrorBoundary_1.ErrorBoundary; } });
|
|
38
38
|
var ErrorScreen_1 = require("./error/ErrorScreen");
|
|
39
39
|
Object.defineProperty(exports, "ErrorScreen", { enumerable: true, get: function () { return ErrorScreen_1.ErrorScreen; } });
|
|
40
|
+
var Loader_1 = require("./ui-utils/Loader");
|
|
41
|
+
Object.defineProperty(exports, "Loader", { enumerable: true, get: function () { return Loader_1.Loader; } });
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Loader = void 0;
|
|
4
|
+
class Loader {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.css = `/* Absolute Center Spinner */
|
|
7
|
+
#dry-ux-loader {
|
|
8
|
+
position: fixed;
|
|
9
|
+
z-index: 999;
|
|
10
|
+
height: 2em;
|
|
11
|
+
width: 2em;
|
|
12
|
+
overflow: show;
|
|
13
|
+
margin: auto;
|
|
14
|
+
top: 0;
|
|
15
|
+
left: 0;
|
|
16
|
+
bottom: 0;
|
|
17
|
+
right: 0;
|
|
18
|
+
visibility: hidden;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* Transparent Overlay */
|
|
22
|
+
#dry-ux-loader:before {
|
|
23
|
+
content: '';
|
|
24
|
+
display: block;
|
|
25
|
+
position: fixed;
|
|
26
|
+
top: 0;
|
|
27
|
+
left: 0;
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
background-color: rgba(0,0,0,0.3);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* :not(:required) hides these rules from IE9 and below */
|
|
34
|
+
#dry-ux-loader:not(:required) {
|
|
35
|
+
/* hide "loading..." text */
|
|
36
|
+
font: 0/0 a;
|
|
37
|
+
color: transparent;
|
|
38
|
+
text-shadow: none;
|
|
39
|
+
background-color: transparent;
|
|
40
|
+
border: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#dry-ux-loader:not(:required):after {
|
|
44
|
+
content: '';
|
|
45
|
+
display: block;
|
|
46
|
+
font-size: 10px;
|
|
47
|
+
width: 1em;
|
|
48
|
+
height: 1em;
|
|
49
|
+
margin-top: -0.5em;
|
|
50
|
+
-webkit-animation: spinner 1500ms infinite linear;
|
|
51
|
+
-moz-animation: spinner 1500ms infinite linear;
|
|
52
|
+
-ms-animation: spinner 1500ms infinite linear;
|
|
53
|
+
-o-animation: spinner 1500ms infinite linear;
|
|
54
|
+
animation: spinner 1500ms infinite linear;
|
|
55
|
+
border-radius: 0.5em;
|
|
56
|
+
-webkit-box-shadow: rgba(0, 0, 0, 0.75) 1.5em 0 0 0, rgba(0, 0, 0, 0.75) 1.1em 1.1em 0 0, rgba(0, 0, 0, 0.75) 0 1.5em 0 0, rgba(0, 0, 0, 0.75) -1.1em 1.1em 0 0, rgba(0, 0, 0, 0.5) -1.5em 0 0 0, rgba(0, 0, 0, 0.5) -1.1em -1.1em 0 0, rgba(0, 0, 0, 0.75) 0 -1.5em 0 0, rgba(0, 0, 0, 0.75) 1.1em -1.1em 0 0;
|
|
57
|
+
box-shadow: rgba(0, 0, 0, 0.75) 1.5em 0 0 0, rgba(0, 0, 0, 0.75) 1.1em 1.1em 0 0, rgba(0, 0, 0, 0.75) 0 1.5em 0 0, rgba(0, 0, 0, 0.75) -1.1em 1.1em 0 0, rgba(0, 0, 0, 0.75) -1.5em 0 0 0, rgba(0, 0, 0, 0.75) -1.1em -1.1em 0 0, rgba(0, 0, 0, 0.75) 0 -1.5em 0 0, rgba(0, 0, 0, 0.75) 1.1em -1.1em 0 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Animation */
|
|
61
|
+
|
|
62
|
+
@-webkit-keyframes spinner {
|
|
63
|
+
0% {
|
|
64
|
+
-webkit-transform: rotate(0deg);
|
|
65
|
+
-moz-transform: rotate(0deg);
|
|
66
|
+
-ms-transform: rotate(0deg);
|
|
67
|
+
-o-transform: rotate(0deg);
|
|
68
|
+
transform: rotate(0deg);
|
|
69
|
+
}
|
|
70
|
+
100% {
|
|
71
|
+
-webkit-transform: rotate(360deg);
|
|
72
|
+
-moz-transform: rotate(360deg);
|
|
73
|
+
-ms-transform: rotate(360deg);
|
|
74
|
+
-o-transform: rotate(360deg);
|
|
75
|
+
transform: rotate(360deg);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
@-moz-keyframes spinner {
|
|
79
|
+
0% {
|
|
80
|
+
-webkit-transform: rotate(0deg);
|
|
81
|
+
-moz-transform: rotate(0deg);
|
|
82
|
+
-ms-transform: rotate(0deg);
|
|
83
|
+
-o-transform: rotate(0deg);
|
|
84
|
+
transform: rotate(0deg);
|
|
85
|
+
}
|
|
86
|
+
100% {
|
|
87
|
+
-webkit-transform: rotate(360deg);
|
|
88
|
+
-moz-transform: rotate(360deg);
|
|
89
|
+
-ms-transform: rotate(360deg);
|
|
90
|
+
-o-transform: rotate(360deg);
|
|
91
|
+
transform: rotate(360deg);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
@-o-keyframes spinner {
|
|
95
|
+
0% {
|
|
96
|
+
-webkit-transform: rotate(0deg);
|
|
97
|
+
-moz-transform: rotate(0deg);
|
|
98
|
+
-ms-transform: rotate(0deg);
|
|
99
|
+
-o-transform: rotate(0deg);
|
|
100
|
+
transform: rotate(0deg);
|
|
101
|
+
}
|
|
102
|
+
100% {
|
|
103
|
+
-webkit-transform: rotate(360deg);
|
|
104
|
+
-moz-transform: rotate(360deg);
|
|
105
|
+
-ms-transform: rotate(360deg);
|
|
106
|
+
-o-transform: rotate(360deg);
|
|
107
|
+
transform: rotate(360deg);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
@keyframes spinner {
|
|
111
|
+
0% {
|
|
112
|
+
-webkit-transform: rotate(0deg);
|
|
113
|
+
-moz-transform: rotate(0deg);
|
|
114
|
+
-ms-transform: rotate(0deg);
|
|
115
|
+
-o-transform: rotate(0deg);
|
|
116
|
+
transform: rotate(0deg);
|
|
117
|
+
}
|
|
118
|
+
100% {
|
|
119
|
+
-webkit-transform: rotate(360deg);
|
|
120
|
+
-moz-transform: rotate(360deg);
|
|
121
|
+
-ms-transform: rotate(360deg);
|
|
122
|
+
-o-transform: rotate(360deg);
|
|
123
|
+
transform: rotate(360deg);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
128
|
+
get element() {
|
|
129
|
+
return document.getElementById("dry-ux-loader");
|
|
130
|
+
}
|
|
131
|
+
show() {
|
|
132
|
+
this.addElementsIfNotExists();
|
|
133
|
+
this.element.style.visibility = "visible";
|
|
134
|
+
}
|
|
135
|
+
hide() {
|
|
136
|
+
if (this.element) {
|
|
137
|
+
this.element.style.visibility = "hidden";
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
addStyles() {
|
|
141
|
+
let el = document.createElement("style");
|
|
142
|
+
el.innerText = this.css;
|
|
143
|
+
document.head.appendChild(el);
|
|
144
|
+
return el;
|
|
145
|
+
}
|
|
146
|
+
addElementsIfNotExists() {
|
|
147
|
+
if (!document.getElementById("dry-ux-loader-styles")) {
|
|
148
|
+
this.addStyles();
|
|
149
|
+
}
|
|
150
|
+
if (!this.element) {
|
|
151
|
+
let el = document.createElement("div");
|
|
152
|
+
el.id = "dry-ux-loader";
|
|
153
|
+
document.body.appendChild(el);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.Loader = Loader;
|
|
@@ -12,9 +12,9 @@ export declare class UIUtilProvider extends React.PureComponent<{}, IUIUtilProvi
|
|
|
12
12
|
constructor(props: any);
|
|
13
13
|
get modalDefaults(): {
|
|
14
14
|
create: any;
|
|
15
|
-
show: (options:
|
|
15
|
+
show: (options: ModalOptions) => IModalCreate;
|
|
16
16
|
getCurrent: () => IModalCreate;
|
|
17
|
-
showAlert: (content:
|
|
17
|
+
showAlert: (content: ModalOptions["content"]) => IModalCreate;
|
|
18
18
|
showConfirm: (options: ModalOptions, onYes: () => void, onNo?: () => void) => IModalCreate;
|
|
19
19
|
showActions: (options: ModalOptions, actions: IUtilModalAction[]) => IModalCreate;
|
|
20
20
|
instances: {
|
|
@@ -33,12 +33,12 @@ class UIUtilProvider extends React.PureComponent {
|
|
|
33
33
|
this.state = Object.assign(Object.assign({}, defaultState), { modal: this.modalDefaults, alert: this.alertDefaults, loader: this.loaderDefaults });
|
|
34
34
|
}
|
|
35
35
|
get modalDefaults() {
|
|
36
|
-
return Object.assign(Object.assign({}, defaultState.modal), { create: this.createModal.bind(this), show: options => this.createModal(null, options), getCurrent: () => {
|
|
36
|
+
return Object.assign(Object.assign({}, defaultState.modal), { create: this.createModal.bind(this), show: (options) => this.createModal(null, options), getCurrent: () => {
|
|
37
37
|
const { modal: { instances }, } = this.state;
|
|
38
38
|
const id = Object.keys(instances).find(id => instances[id].shown);
|
|
39
39
|
return this.getCurrentModal(id);
|
|
40
|
-
}, showAlert: content => this.createModal(null, {
|
|
41
|
-
content: React.createElement("h4", { className: "text-center mtop" }, content),
|
|
40
|
+
}, showAlert: (content) => this.createModal(null, {
|
|
41
|
+
content: typeof content == "string" ? React.createElement("h4", { className: "text-center mtop" }, content) : content,
|
|
42
42
|
destroyOnClose: true,
|
|
43
43
|
closeBtn: true,
|
|
44
44
|
width: 400,
|
|
@@ -101,7 +101,7 @@ export interface IUIUtilModal {
|
|
|
101
101
|
* Shows an alert style modal.
|
|
102
102
|
* @param content The content to display in the modal.
|
|
103
103
|
*/
|
|
104
|
-
showAlert: (content:
|
|
104
|
+
showAlert: (content: ModalOptions["content"]) => IModalCreate;
|
|
105
105
|
/**
|
|
106
106
|
* Shows a confirm style modal.
|
|
107
107
|
* @param options The options for the modal.
|