namirasoft-account-react 1.3.10 → 1.3.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/dist/IRouterState.d.ts +2 -2
- package/dist/Messenger.d.ts +3 -1
- package/dist/Messenger.js +17 -7
- package/dist/Messenger.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/IRouterState.ts +2 -2
- package/src/Messenger.ts +18 -10
- package/src/index.ts +0 -2
- package/dist/Notification.d.ts +0 -6
- package/dist/Notification.js +0 -3
- package/dist/Notification.js.map +0 -1
- package/dist/NotificationType.d.ts +0 -6
- package/dist/NotificationType.js +0 -11
- package/dist/NotificationType.js.map +0 -1
- package/src/Notification.ts +0 -8
- package/src/NotificationType.ts +0 -7
package/dist/IRouterState.d.ts
CHANGED
package/dist/Messenger.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IRouterState } from "./IRouterState";
|
|
3
|
+
import { NSNotificationProps } from "namirasoft-site-react";
|
|
3
4
|
export declare class Messenger {
|
|
4
|
-
static Counter
|
|
5
|
+
private static Counter;
|
|
5
6
|
private state;
|
|
6
7
|
private setState;
|
|
7
8
|
constructor(state: IRouterState | undefined, setState: React.Dispatch<React.SetStateAction<IRouterState | undefined>>);
|
|
@@ -11,4 +12,5 @@ export declare class Messenger {
|
|
|
11
12
|
onWarning(text: string): void;
|
|
12
13
|
onError(error: Error | string): void;
|
|
13
14
|
delNotification(id: number): void;
|
|
15
|
+
getNotifications(): NSNotificationProps[];
|
|
14
16
|
}
|
package/dist/Messenger.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Messenger = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const
|
|
8
|
+
const namirasoft_site_react_1 = require("namirasoft-site-react");
|
|
9
9
|
class Messenger {
|
|
10
10
|
constructor(state, setState) {
|
|
11
11
|
this.state = state;
|
|
@@ -16,32 +16,38 @@ class Messenger {
|
|
|
16
16
|
this.onWarning = this.onWarning.bind(this);
|
|
17
17
|
this.onError = this.onError.bind(this);
|
|
18
18
|
this.delNotification = this.delNotification.bind(this);
|
|
19
|
+
this.getNotifications = this.getNotifications.bind(this);
|
|
19
20
|
}
|
|
20
21
|
notify(message) {
|
|
22
|
+
var _a;
|
|
21
23
|
let state = this.state;
|
|
22
24
|
if (!state)
|
|
23
25
|
state = {};
|
|
24
|
-
let id = Messenger.Counter++;
|
|
25
26
|
if (!state.notifications)
|
|
26
27
|
state.notifications = [];
|
|
28
|
+
let id = parseInt((_a = message.id) !== null && _a !== void 0 ? _a : `${Messenger.Counter++}`);
|
|
27
29
|
state.notifications[id] = message;
|
|
28
30
|
this.setState(state);
|
|
29
31
|
setTimeout(() => {
|
|
30
|
-
|
|
32
|
+
message.onClose();
|
|
31
33
|
}, 5000);
|
|
32
34
|
window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
|
|
33
35
|
}
|
|
34
36
|
onInformation(text) {
|
|
35
|
-
|
|
37
|
+
let id = Messenger.Counter++;
|
|
38
|
+
this.notify({ id: id.toString(), text, type: namirasoft_site_react_1.NotificationType.Information, color: namirasoft_site_react_1.NSNotificationColor.GRAY, onClose: () => this.delNotification(id) });
|
|
36
39
|
}
|
|
37
40
|
onSuccess(text) {
|
|
38
|
-
|
|
41
|
+
let id = Messenger.Counter++;
|
|
42
|
+
this.notify({ id: id.toString(), text, type: namirasoft_site_react_1.NotificationType.Success, color: namirasoft_site_react_1.NSNotificationColor.GREEN, onClose: () => this.delNotification(id) });
|
|
39
43
|
}
|
|
40
44
|
onWarning(text) {
|
|
41
|
-
|
|
45
|
+
let id = Messenger.Counter++;
|
|
46
|
+
this.notify({ id: id.toString(), text, type: namirasoft_site_react_1.NotificationType.Warning, color: namirasoft_site_react_1.NSNotificationColor.YELLOW, onClose: () => this.delNotification(id) });
|
|
42
47
|
}
|
|
43
48
|
onError(error) {
|
|
44
49
|
var _a;
|
|
50
|
+
let id = Messenger.Counter++;
|
|
45
51
|
let text = "";
|
|
46
52
|
if (error instanceof Error) {
|
|
47
53
|
text = error.message;
|
|
@@ -51,7 +57,7 @@ class Messenger {
|
|
|
51
57
|
}
|
|
52
58
|
else
|
|
53
59
|
text = error;
|
|
54
|
-
this.notify({ text, type:
|
|
60
|
+
this.notify({ id: id.toString(), text, type: namirasoft_site_react_1.NotificationType.Error, color: namirasoft_site_react_1.NSNotificationColor.RED, onClose: () => this.delNotification(id) });
|
|
55
61
|
}
|
|
56
62
|
delNotification(id) {
|
|
57
63
|
let state = this.state;
|
|
@@ -61,6 +67,10 @@ class Messenger {
|
|
|
61
67
|
delete state.notifications[id];
|
|
62
68
|
this.setState(state);
|
|
63
69
|
}
|
|
70
|
+
getNotifications() {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.notifications) !== null && _b !== void 0 ? _b : [];
|
|
73
|
+
}
|
|
64
74
|
}
|
|
65
75
|
exports.Messenger = Messenger;
|
|
66
76
|
Messenger.Counter = 1;
|
package/dist/Messenger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Messenger.js","sourceRoot":"","sources":["../src/Messenger.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,
|
|
1
|
+
{"version":3,"file":"Messenger.js","sourceRoot":"","sources":["../src/Messenger.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iEAAmG;AAEnG,MAAa,SAAS;IAKlB,YAAY,KAA+B,EAAE,QAAwE;QAEjH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,G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AAK,CAAC,OAAO,CAAC;YACrB,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC;gBACzB,IAAI,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI;oBACpB,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;SACtC;;YAEG,IAAI,GAAG,KAAK,CAAC;QACjB,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,wCAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,2CAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACpJ,CAAC;IACD,eAAe,CAAC,EAAU;QAEtB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACvB,IAAI,CAAC,KAAK;YACN,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,KAAK,CAAC,aAAa;YACnB,OAAO,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,gBAAgB;;QAEZ,OAAO,MAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,aAAa,mCAAI,EAAE,CAAC;IAC3C,CAAC;;AA3EL,8BA4EC;AA1EkB,iBAAO,GAAW,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -19,7 +19,5 @@ __exportStar(require("./Info"), exports);
|
|
|
19
19
|
__exportStar(require("./IRouterMaker"), exports);
|
|
20
20
|
__exportStar(require("./IRouterState"), exports);
|
|
21
21
|
__exportStar(require("./Messenger"), exports);
|
|
22
|
-
__exportStar(require("./Notification"), exports);
|
|
23
|
-
__exportStar(require("./NotificationType"), exports);
|
|
24
22
|
__exportStar(require("./RouterMaker"), exports);
|
|
25
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,yCAAuB;AACvB,iDAA+B;AAC/B,iDAA+B;AAC/B,8CAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,yCAAuB;AACvB,iDAA+B;AAC/B,iDAA+B;AAC/B,8CAA4B;AAC5B,gDAA8B"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"framework": "npm",
|
|
9
9
|
"application": "package",
|
|
10
10
|
"private": false,
|
|
11
|
-
"version": "1.3.
|
|
11
|
+
"version": "1.3.12",
|
|
12
12
|
"author": "Amir Abolhasani",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"main": "./dist/index.js",
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@types/device-uuid": "^1.0.3",
|
|
21
|
-
"@types/react": "^18.2.
|
|
21
|
+
"@types/react": "^18.2.79",
|
|
22
22
|
"device-uuid": "^1.0.4",
|
|
23
23
|
"namirasoft-account": "^1.3.8",
|
|
24
|
-
"namirasoft-core": "^1.3.
|
|
24
|
+
"namirasoft-core": "^1.3.19",
|
|
25
|
+
"namirasoft-site-react": "^1.3.65",
|
|
25
26
|
"query-string": "^9.0.0",
|
|
26
27
|
"react": "^18.2.0",
|
|
27
28
|
"react-router-dom": "^6.22.3",
|
package/src/IRouterState.ts
CHANGED
package/src/Messenger.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
-
import { Notification } from "./Notification";
|
|
3
|
-
import { NotificationType } from "./NotificationType";
|
|
4
2
|
import { IRouterState } from "./IRouterState";
|
|
3
|
+
import { NSNotificationColor, NSNotificationProps, NotificationType } from "namirasoft-site-react";
|
|
5
4
|
|
|
6
5
|
export class Messenger
|
|
7
6
|
{
|
|
8
|
-
static Counter: number = 1;
|
|
7
|
+
private static Counter: number = 1;
|
|
9
8
|
private state: IRouterState | undefined;
|
|
10
9
|
private setState: React.Dispatch<React.SetStateAction<IRouterState | undefined>>;
|
|
11
10
|
constructor(state: IRouterState | undefined, setState: React.Dispatch<React.SetStateAction<IRouterState | undefined>>)
|
|
@@ -18,37 +17,42 @@ export class Messenger
|
|
|
18
17
|
this.onWarning = this.onWarning.bind(this);
|
|
19
18
|
this.onError = this.onError.bind(this);
|
|
20
19
|
this.delNotification = this.delNotification.bind(this);
|
|
20
|
+
this.getNotifications = this.getNotifications.bind(this);
|
|
21
21
|
}
|
|
22
|
-
private notify(message:
|
|
22
|
+
private notify(message: NSNotificationProps)
|
|
23
23
|
{
|
|
24
24
|
let state = this.state;
|
|
25
25
|
if (!state)
|
|
26
26
|
state = {};
|
|
27
|
-
let id = Messenger.Counter++;
|
|
28
27
|
if (!state.notifications)
|
|
29
28
|
state.notifications = [];
|
|
29
|
+
let id = parseInt(message.id ?? `${Messenger.Counter++}`);
|
|
30
30
|
state.notifications[id] = message;
|
|
31
31
|
this.setState(state);
|
|
32
32
|
setTimeout(() =>
|
|
33
33
|
{
|
|
34
|
-
|
|
34
|
+
message.onClose();
|
|
35
35
|
}, 5000);
|
|
36
36
|
window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
|
|
37
37
|
}
|
|
38
38
|
onInformation(text: string)
|
|
39
39
|
{
|
|
40
|
-
|
|
40
|
+
let id = Messenger.Counter++;
|
|
41
|
+
this.notify({ id: id.toString(), text, type: NotificationType.Information, color: NSNotificationColor.GRAY, onClose: () => this.delNotification(id) });
|
|
41
42
|
}
|
|
42
43
|
onSuccess(text: string)
|
|
43
44
|
{
|
|
44
|
-
|
|
45
|
+
let id = Messenger.Counter++;
|
|
46
|
+
this.notify({ id: id.toString(), text, type: NotificationType.Success, color: NSNotificationColor.GREEN, onClose: () => this.delNotification(id) });
|
|
45
47
|
}
|
|
46
48
|
onWarning(text: string)
|
|
47
49
|
{
|
|
48
|
-
|
|
50
|
+
let id = Messenger.Counter++;
|
|
51
|
+
this.notify({ id: id.toString(), text, type: NotificationType.Warning, color: NSNotificationColor.YELLOW, onClose: () => this.delNotification(id) });
|
|
49
52
|
}
|
|
50
53
|
onError(error: Error | string)
|
|
51
54
|
{
|
|
55
|
+
let id = Messenger.Counter++;
|
|
52
56
|
let text: string = "";
|
|
53
57
|
if (error instanceof Error)
|
|
54
58
|
{
|
|
@@ -59,7 +63,7 @@ export class Messenger
|
|
|
59
63
|
}
|
|
60
64
|
else
|
|
61
65
|
text = error;
|
|
62
|
-
this.notify({ text, type: NotificationType.Error, color:
|
|
66
|
+
this.notify({ id: id.toString(), text, type: NotificationType.Error, color: NSNotificationColor.RED, onClose: () => this.delNotification(id) });
|
|
63
67
|
}
|
|
64
68
|
delNotification(id: number): void
|
|
65
69
|
{
|
|
@@ -70,4 +74,8 @@ export class Messenger
|
|
|
70
74
|
delete state.notifications[id];
|
|
71
75
|
this.setState(state);
|
|
72
76
|
}
|
|
77
|
+
getNotifications(): NSNotificationProps[]
|
|
78
|
+
{
|
|
79
|
+
return this.state?.notifications ?? [];
|
|
80
|
+
}
|
|
73
81
|
}
|
package/src/index.ts
CHANGED
package/dist/Notification.d.ts
DELETED
package/dist/Notification.js
DELETED
package/dist/Notification.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Notification.js","sourceRoot":"","sources":["../src/Notification.ts"],"names":[],"mappings":""}
|
package/dist/NotificationType.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotificationType = void 0;
|
|
4
|
-
var NotificationType;
|
|
5
|
-
(function (NotificationType) {
|
|
6
|
-
NotificationType["Information"] = "Information";
|
|
7
|
-
NotificationType["Warning"] = "Warning";
|
|
8
|
-
NotificationType["Success"] = "Success";
|
|
9
|
-
NotificationType["Error"] = "Error";
|
|
10
|
-
})(NotificationType || (exports.NotificationType = NotificationType = {}));
|
|
11
|
-
//# sourceMappingURL=NotificationType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationType.js","sourceRoot":"","sources":["../src/NotificationType.ts"],"names":[],"mappings":";;;AAAA,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAExB,+CAA2B,CAAA;IAC3B,uCAAmB,CAAA;IACnB,uCAAmB,CAAA;IACnB,mCAAe,CAAA;AACnB,CAAC,EANW,gBAAgB,gCAAhB,gBAAgB,QAM3B"}
|
package/src/Notification.ts
DELETED