namirasoft-account-react 1.3.9 → 1.3.11

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.
@@ -1,5 +1,5 @@
1
- import { Notification } from "./Notification";
1
+ import { NSNotificationProps } from "namirasoft-site-react";
2
2
  export interface IRouterState {
3
3
  inited?: boolean;
4
- notifications?: Notification[];
4
+ notifications?: NSNotificationProps[];
5
5
  }
package/dist/Info.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ParsedQuery } from 'query-string';
2
2
  export default class Info {
3
3
  static getDeviceName(query: ParsedQuery): string | (string | null)[];
4
+ static getVersion(): string;
4
5
  static getOS(query: ParsedQuery): string | (string | null)[];
5
6
  }
package/dist/Info.js CHANGED
@@ -8,7 +8,11 @@ class Info {
8
8
  static getDeviceName(query) {
9
9
  var _a;
10
10
  var du = new device_uuid_1.default.DeviceUUID().parse();
11
- return (_a = query.device) !== null && _a !== void 0 ? _a : du.version;
11
+ return (_a = query.device) !== null && _a !== void 0 ? _a : (du.platform + " " + du.version);
12
+ }
13
+ static getVersion() {
14
+ var du = new device_uuid_1.default.DeviceUUID().parse();
15
+ return du.version;
12
16
  }
13
17
  static getOS(query) {
14
18
  var _a;
package/dist/Info.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Info.js","sourceRoot":"","sources":["../src/Info.ts"],"names":[],"mappings":";;;;;AACA,8DAAqC;AAErC,MAAqB,IAAI;IAErB,MAAM,CAAC,aAAa,CAAC,KAAkB;;QAEnC,IAAI,EAAE,GAAG,IAAI,qBAAU,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC;QAC7C,OAAO,MAAA,KAAK,CAAC,MAAM,mCAAI,EAAE,CAAC,OAAO,CAAC;IACtC,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,KAAkB;;QAE3B,IAAI,EAAE,GAAG,IAAI,qBAAU,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC;QAC7C,OAAO,MAAA,KAAK,CAAC,EAAE,mCAAI,EAAE,CAAC,EAAE,CAAC;IAC7B,CAAC;CACJ;AAZD,uBAYC;AAAA,CAAC"}
1
+ {"version":3,"file":"Info.js","sourceRoot":"","sources":["../src/Info.ts"],"names":[],"mappings":";;;;;AACA,8DAAqC;AAErC,MAAqB,IAAI;IAErB,MAAM,CAAC,aAAa,CAAC,KAAkB;;QAEnC,IAAI,EAAE,GAAG,IAAI,qBAAU,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC;QAC7C,OAAO,MAAA,KAAK,CAAC,MAAM,mCAAI,CAAC,EAAE,CAAC,QAAQ,GAAG,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,CAAC,UAAU;QAEb,IAAI,EAAE,GAAG,IAAI,qBAAU,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC;QAC7C,OAAO,EAAE,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,KAAkB;;QAE3B,IAAI,EAAE,GAAG,IAAI,qBAAU,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC;QAC7C,OAAO,MAAA,KAAK,CAAC,EAAE,mCAAI,EAAE,CAAC,EAAE,CAAC;IAC7B,CAAC;CACJ;AAjBD,uBAiBC;AAAA,CAAC"}
@@ -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: number;
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 NotificationType_1 = require("./NotificationType");
8
+ const namirasoft_site_react_1 = require("namirasoft-site-react");
9
9
  class Messenger {
10
10
  constructor(state, setState) {
11
11
  this.state = state;
@@ -18,30 +18,35 @@ class Messenger {
18
18
  this.delNotification = this.delNotification.bind(this);
19
19
  }
20
20
  notify(message) {
21
+ var _a;
21
22
  let state = this.state;
22
23
  if (!state)
23
24
  state = {};
24
- let id = Messenger.Counter++;
25
25
  if (!state.notifications)
26
26
  state.notifications = [];
27
+ let id = parseInt((_a = message.id) !== null && _a !== void 0 ? _a : `${Messenger.Counter++}`);
27
28
  state.notifications[id] = message;
28
29
  this.setState(state);
29
30
  setTimeout(() => {
30
- this.delNotification(id);
31
+ message.onClose();
31
32
  }, 5000);
32
33
  window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
33
34
  }
34
35
  onInformation(text) {
35
- this.notify({ text, type: NotificationType_1.NotificationType.Information, color: "black" });
36
+ let id = Messenger.Counter++;
37
+ 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
38
  }
37
39
  onSuccess(text) {
38
- this.notify({ text, type: NotificationType_1.NotificationType.Success, color: "green" });
40
+ let id = Messenger.Counter++;
41
+ 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
42
  }
40
43
  onWarning(text) {
41
- this.notify({ text, type: NotificationType_1.NotificationType.Warning, color: "yellow" });
44
+ let id = Messenger.Counter++;
45
+ 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
46
  }
43
47
  onError(error) {
44
48
  var _a;
49
+ let id = Messenger.Counter++;
45
50
  let text = "";
46
51
  if (error instanceof Error) {
47
52
  text = error.message;
@@ -51,7 +56,7 @@ class Messenger {
51
56
  }
52
57
  else
53
58
  text = error;
54
- this.notify({ text, type: NotificationType_1.NotificationType.Error, color: "red" });
59
+ 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
60
  }
56
61
  delNotification(id) {
57
62
  let state = this.state;
@@ -61,6 +66,10 @@ class Messenger {
61
66
  delete state.notifications[id];
62
67
  this.setState(state);
63
68
  }
69
+ getNotifications() {
70
+ var _a, _b;
71
+ return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.notifications) !== null && _b !== void 0 ? _b : [];
72
+ }
64
73
  }
65
74
  exports.Messenger = Messenger;
66
75
  Messenger.Counter = 1;
@@ -1 +1 @@
1
- {"version":3,"file":"Messenger.js","sourceRoot":"","sources":["../src/Messenger.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,yDAAsD;AAGtD,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,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAA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AE,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;;AA1EL,8BA2EC;AAzEkB,iBAAO,GAAW,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -3,6 +3,4 @@ export * from "./Info";
3
3
  export * from "./IRouterMaker";
4
4
  export * from "./IRouterState";
5
5
  export * from "./Messenger";
6
- export * from "./Notification";
7
- export * from "./NotificationType";
8
6
  export * from "./RouterMaker";
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,iDAA+B;AAC/B,qDAAmC;AACnC,gDAA8B"}
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.9",
11
+ "version": "1.3.11",
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.77",
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.18",
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",
@@ -32,4 +33,4 @@
32
33
  "/tsconfig.json"
33
34
  ]
34
35
  }
35
- }
36
+ }
@@ -1,7 +1,7 @@
1
- import { Notification } from "./Notification";
1
+ import { NSNotificationProps } from "namirasoft-site-react";
2
2
 
3
3
  export interface IRouterState
4
4
  {
5
5
  inited?: boolean;
6
- notifications?: Notification[];
6
+ notifications?: NSNotificationProps[];
7
7
  }
package/src/Info.ts CHANGED
@@ -6,7 +6,12 @@ export default class Info
6
6
  static getDeviceName(query: ParsedQuery)
7
7
  {
8
8
  var du = new DeviceUUID.DeviceUUID().parse();
9
- return query.device ?? du.version;
9
+ return query.device ?? (du.platform + " " + du.version);
10
+ }
11
+ static getVersion()
12
+ {
13
+ var du = new DeviceUUID.DeviceUUID().parse();
14
+ return du.version;
10
15
  }
11
16
  static getOS(query: ParsedQuery)
12
17
  {
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>>)
@@ -19,36 +18,40 @@ export class Messenger
19
18
  this.onError = this.onError.bind(this);
20
19
  this.delNotification = this.delNotification.bind(this);
21
20
  }
22
- private notify(message: Notification)
21
+ private notify(message: NSNotificationProps)
23
22
  {
24
23
  let state = this.state;
25
24
  if (!state)
26
25
  state = {};
27
- let id = Messenger.Counter++;
28
26
  if (!state.notifications)
29
27
  state.notifications = [];
28
+ let id = parseInt(message.id ?? `${Messenger.Counter++}`);
30
29
  state.notifications[id] = message;
31
30
  this.setState(state);
32
31
  setTimeout(() =>
33
32
  {
34
- this.delNotification(id);
33
+ message.onClose();
35
34
  }, 5000);
36
35
  window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
37
36
  }
38
37
  onInformation(text: string)
39
38
  {
40
- this.notify({ text, type: NotificationType.Information, color: "black" });
39
+ let id = Messenger.Counter++;
40
+ this.notify({ id: id.toString(), text, type: NotificationType.Information, color: NSNotificationColor.GRAY, onClose: () => this.delNotification(id) });
41
41
  }
42
42
  onSuccess(text: string)
43
43
  {
44
- this.notify({ text, type: NotificationType.Success, color: "green" });
44
+ let id = Messenger.Counter++;
45
+ this.notify({ id: id.toString(), text, type: NotificationType.Success, color: NSNotificationColor.GREEN, onClose: () => this.delNotification(id) });
45
46
  }
46
47
  onWarning(text: string)
47
48
  {
48
- this.notify({ text, type: NotificationType.Warning, color: "yellow" });
49
+ let id = Messenger.Counter++;
50
+ this.notify({ id: id.toString(), text, type: NotificationType.Warning, color: NSNotificationColor.YELLOW, onClose: () => this.delNotification(id) });
49
51
  }
50
52
  onError(error: Error | string)
51
53
  {
54
+ let id = Messenger.Counter++;
52
55
  let text: string = "";
53
56
  if (error instanceof Error)
54
57
  {
@@ -59,7 +62,7 @@ export class Messenger
59
62
  }
60
63
  else
61
64
  text = error;
62
- this.notify({ text, type: NotificationType.Error, color: "red" });
65
+ this.notify({ id: id.toString(), text, type: NotificationType.Error, color: NSNotificationColor.RED, onClose: () => this.delNotification(id) });
63
66
  }
64
67
  delNotification(id: number): void
65
68
  {
@@ -70,4 +73,8 @@ export class Messenger
70
73
  delete state.notifications[id];
71
74
  this.setState(state);
72
75
  }
76
+ getNotifications(): NSNotificationProps[]
77
+ {
78
+ return this.state?.notifications ?? [];
79
+ }
73
80
  }
package/src/index.ts CHANGED
@@ -3,6 +3,4 @@ export * from "./Info";
3
3
  export * from "./IRouterMaker";
4
4
  export * from "./IRouterState";
5
5
  export * from "./Messenger";
6
- export * from "./Notification";
7
- export * from "./NotificationType";
8
6
  export * from "./RouterMaker";
@@ -1,6 +0,0 @@
1
- import { NotificationType } from "./NotificationType";
2
- export type Notification = {
3
- text: string;
4
- type: NotificationType;
5
- color: string;
6
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=Notification.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Notification.js","sourceRoot":"","sources":["../src/Notification.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- export declare enum NotificationType {
2
- Information = "Information",
3
- Warning = "Warning",
4
- Success = "Success",
5
- Error = "Error"
6
- }
@@ -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"}
@@ -1,8 +0,0 @@
1
- import { NotificationType } from "./NotificationType";
2
-
3
- export type Notification =
4
- {
5
- text: string;
6
- type: NotificationType;
7
- color: string;
8
- }
@@ -1,7 +0,0 @@
1
- export enum NotificationType
2
- {
3
- Information = "Information",
4
- Warning = "Warning",
5
- Success = "Success",
6
- Error = "Error",
7
- }