namirasoft-account-react 1.3.76 → 1.3.78

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.
Files changed (67) hide show
  1. package/config-overrides.js +72 -72
  2. package/dist/App.css +57 -0
  3. package/dist/IAccountProps.d.ts +22 -0
  4. package/dist/IAccountProps.js +3 -0
  5. package/dist/IAccountProps.js.map +10 -0
  6. package/dist/IRouterMaker.d.ts +8 -0
  7. package/dist/IRouterMaker.js +3 -0
  8. package/dist/IRouterMaker.js.map +1 -0
  9. package/dist/IRouterState.d.ts +5 -0
  10. package/dist/IRouterState.js +3 -0
  11. package/dist/IRouterState.js.map +1 -0
  12. package/dist/IStorageCookie.d.ts +10 -0
  13. package/dist/IStorageCookie.js +27 -0
  14. package/dist/IStorageCookie.js.map +1 -0
  15. package/dist/Messenger.d.ts +16 -0
  16. package/dist/Messenger.js +78 -0
  17. package/dist/Messenger.js.map +1 -0
  18. package/dist/Notification.d.ts +6 -0
  19. package/dist/Notification.js +3 -0
  20. package/dist/Notification.js.map +1 -0
  21. package/dist/NotificationType.d.ts +6 -0
  22. package/dist/NotificationType.js +11 -0
  23. package/dist/NotificationType.js.map +1 -0
  24. package/dist/RouterMaker.d.ts +25 -0
  25. package/dist/RouterMaker.js +125 -0
  26. package/dist/RouterMaker.js.map +1 -0
  27. package/dist/RouterMaker.jsx +118 -0
  28. package/dist/RouterMaker.jsx.map +1 -0
  29. package/dist/components/NSALayoutAction.d.ts +17 -0
  30. package/dist/components/NSALayoutAction.js +6 -0
  31. package/dist/components/NSALayoutAction.js.map +1 -0
  32. package/dist/components/NSALayoutAction.module.css +0 -0
  33. package/dist/components/NSAMessageDialog.module.css +62 -62
  34. package/dist/index.css +0 -0
  35. package/dist/layouts/NSALayoutList.d.ts +17 -0
  36. package/dist/layouts/NSALayoutList.js +19 -0
  37. package/dist/layouts/NSALayoutList.js.map +1 -0
  38. package/dist/layouts/NSASectionList.js +1 -1
  39. package/dist/layouts/NSASectionList.js.map +1 -1
  40. package/dist/layouts/NSASectionNew.d.ts +9 -0
  41. package/dist/layouts/NSASectionNew.js +5 -0
  42. package/dist/layouts/NSASectionNew.js.map +1 -0
  43. package/dist/pages/NSALoginPage.module.css +19 -19
  44. package/package.json +64 -64
  45. package/public/index.html +21 -21
  46. package/src/App.css +56 -56
  47. package/src/App.tsx +10 -10
  48. package/src/IEntityInfo.ts +23 -23
  49. package/src/INSARouterMaker.ts +8 -8
  50. package/src/INSARouterProps.ts +17 -17
  51. package/src/INSARouterState.ts +5 -5
  52. package/src/Info.ts +20 -20
  53. package/src/NSARouterMaker.tsx +138 -138
  54. package/src/components/NSADeleteModal.tsx +24 -24
  55. package/src/components/NSAMessageDialog.module.css +62 -62
  56. package/src/components/NSAMessageDialog.tsx +65 -65
  57. package/src/index.tsx +7 -7
  58. package/src/layouts/Actions.ts +92 -92
  59. package/src/layouts/NSALayout.tsx +193 -193
  60. package/src/layouts/NSASectionEdit.tsx +97 -97
  61. package/src/layouts/NSASectionList.tsx +105 -105
  62. package/src/layouts/NSASectionTabs.tsx +36 -36
  63. package/src/layouts/NSASectionView.tsx +15 -15
  64. package/src/main.ts +16 -16
  65. package/src/pages/NSALoginPage.module.css +19 -19
  66. package/src/pages/NSALoginPage.tsx +37 -37
  67. package/tsconfig.json +43 -43
@@ -1,73 +1,73 @@
1
- const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
2
- const webpack = require('webpack');
3
-
4
- const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
5
-
6
- module.exports = function config_overrides(config, webpackEnv)
7
- {
8
- console.log('overriding webpack config...');
9
- const isEnvDevelopment = webpackEnv === 'development';
10
- const isEnvProduction = webpackEnv === 'production';
11
- const loaders = config.module.rules[1].oneOf;
12
-
13
- loaders.splice(loaders.length - 1, 0, {
14
- test: /\.(js|mjs|cjs)$/,
15
- exclude: /@babel(?:\/|\\{1,2})runtime/,
16
- loader: require.resolve('babel-loader'),
17
- options: {
18
- babelrc: false,
19
- configFile: false,
20
- compact: false,
21
- presets: [
22
- [
23
- require.resolve('babel-preset-react-app/dependencies'),
24
- { helpers: true },
25
- ],
26
- ],
27
- cacheDirectory: true,
28
- // See #6846 for context on why cacheCompression is disabled
29
- cacheCompression: false,
30
- // @remove-on-eject-begin
31
- cacheIdentifier: getCacheIdentifier(
32
- isEnvProduction
33
- ? 'production'
34
- : isEnvDevelopment && 'development',
35
- [
36
- 'babel-plugin-named-asset-import',
37
- 'babel-preset-react-app',
38
- 'react-dev-utils',
39
- 'react-scripts',
40
- ]
41
- ),
42
- // @remove-on-eject-end
43
- // Babel sourcemaps are needed for debugging into node_modules
44
- // code. Without the options below, debuggers like VSCode
45
- // show incorrect code and set breakpoints on the wrong lines.
46
- sourceMaps: shouldUseSourceMap,
47
- inputSourceMap: shouldUseSourceMap,
48
- },
49
- });
50
-
51
- config.resolve.fallback = {
52
- "fs": false,
53
- "tls": false,
54
- "net": false,
55
- "https": false,
56
- // "http": require.resolve("stream-http"),
57
- // "zlib": require.resolve("browserify-zlib"),
58
- "path": require.resolve("path-browserify"),
59
- // "stream": require.resolve("stream-browserify"),
60
- // "util": require.resolve("util/"),
61
- // "crypto": require.resolve("crypto-browserify")
62
- "child_process": false,
63
- "os": false,
64
- "crypto": false
65
- }
66
- config.plugins = (config.plugins || []).concat([
67
- new webpack.NormalModuleReplacementPlugin(/node:/, (resource) =>
68
- {
69
- resource.request = resource.request.replace(/^node:/, "");
70
- })
71
- ]);
72
- return config;
1
+ const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
2
+ const webpack = require('webpack');
3
+
4
+ const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
5
+
6
+ module.exports = function config_overrides(config, webpackEnv)
7
+ {
8
+ console.log('overriding webpack config...');
9
+ const isEnvDevelopment = webpackEnv === 'development';
10
+ const isEnvProduction = webpackEnv === 'production';
11
+ const loaders = config.module.rules[1].oneOf;
12
+
13
+ loaders.splice(loaders.length - 1, 0, {
14
+ test: /\.(js|mjs|cjs)$/,
15
+ exclude: /@babel(?:\/|\\{1,2})runtime/,
16
+ loader: require.resolve('babel-loader'),
17
+ options: {
18
+ babelrc: false,
19
+ configFile: false,
20
+ compact: false,
21
+ presets: [
22
+ [
23
+ require.resolve('babel-preset-react-app/dependencies'),
24
+ { helpers: true },
25
+ ],
26
+ ],
27
+ cacheDirectory: true,
28
+ // See #6846 for context on why cacheCompression is disabled
29
+ cacheCompression: false,
30
+ // @remove-on-eject-begin
31
+ cacheIdentifier: getCacheIdentifier(
32
+ isEnvProduction
33
+ ? 'production'
34
+ : isEnvDevelopment && 'development',
35
+ [
36
+ 'babel-plugin-named-asset-import',
37
+ 'babel-preset-react-app',
38
+ 'react-dev-utils',
39
+ 'react-scripts',
40
+ ]
41
+ ),
42
+ // @remove-on-eject-end
43
+ // Babel sourcemaps are needed for debugging into node_modules
44
+ // code. Without the options below, debuggers like VSCode
45
+ // show incorrect code and set breakpoints on the wrong lines.
46
+ sourceMaps: shouldUseSourceMap,
47
+ inputSourceMap: shouldUseSourceMap,
48
+ },
49
+ });
50
+
51
+ config.resolve.fallback = {
52
+ "fs": false,
53
+ "tls": false,
54
+ "net": false,
55
+ "https": false,
56
+ // "http": require.resolve("stream-http"),
57
+ // "zlib": require.resolve("browserify-zlib"),
58
+ "path": require.resolve("path-browserify"),
59
+ // "stream": require.resolve("stream-browserify"),
60
+ // "util": require.resolve("util/"),
61
+ // "crypto": require.resolve("crypto-browserify")
62
+ "child_process": false,
63
+ "os": false,
64
+ "crypto": false
65
+ }
66
+ config.plugins = (config.plugins || []).concat([
67
+ new webpack.NormalModuleReplacementPlugin(/node:/, (resource) =>
68
+ {
69
+ resource.request = resource.request.replace(/^node:/, "");
70
+ })
71
+ ]);
72
+ return config;
73
73
  };
package/dist/App.css ADDED
@@ -0,0 +1,57 @@
1
+ @font-face {
2
+ font-family: inter;
3
+ src: url("../src/assets/fonts/Inter-Regular.ttf");
4
+ }
5
+
6
+ body {
7
+ margin: 0;
8
+ font-family: inter;
9
+ -webkit-font-smoothing: antialiased;
10
+ -moz-osx-font-smoothing: grayscale;
11
+ }
12
+
13
+ .toast-header {
14
+ padding: 16px !important;
15
+ justify-content: space-between !important;
16
+ }
17
+
18
+ .toast {
19
+ width: max-content !important;
20
+ max-width: 100%;
21
+ border: 8px;
22
+ }
23
+
24
+ .toast-body {
25
+ padding: 0 !important;
26
+ }
27
+
28
+ .btn-close {
29
+ background: url(./assets/images/icon_close.png) center/1em auto no-repeat !important;
30
+ opacity: 1 !important;
31
+ }
32
+
33
+ .nsa_font_16_bold {
34
+ font-size: 16px;
35
+ font-weight: 600;
36
+ }
37
+
38
+ .nsa_font_13_normal {
39
+ font-size: 13px;
40
+ font-weight: 300;
41
+ }
42
+
43
+ .nsa_font_12_normal {
44
+ font-size: 12px;
45
+ font-weight: 300;
46
+ }
47
+
48
+ /*Toast*/
49
+ .tost {
50
+ position: absolute;
51
+ min-width: max-content;
52
+ right: 0;
53
+ background: #f2f2f2 !important;
54
+ }
55
+ .toast-header{
56
+ justify-content: space-between !important;
57
+ }
@@ -0,0 +1,22 @@
1
+ import { NamirasoftAccountServer, TokenManager } from "namirasoft-account";
2
+ import { Messenger } from "./Messenger";
3
+ import { ParsedNameValue } from "namirasoft-core";
4
+ import { ParsedQuery } from "query-string";
5
+ export interface INSARouterProps
6
+ {
7
+ account: {
8
+ token_manager: TokenManager;
9
+ server: NamirasoftAccountServer;
10
+ };
11
+ messenger: Messenger;
12
+ url: {
13
+ getQueryStrings(): ParsedQuery;
14
+ getQuery(name: string): string;
15
+ getLink(sub: string, customQuery: {
16
+ [name: string]: ParsedNameValue;
17
+ }): string;
18
+ redirect(sub: string, customQuery: {
19
+ [name: string]: ParsedNameValue;
20
+ }): void;
21
+ };
22
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=INSARouterProps.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "file": "INSARouterProps.js",
4
+ "sourceRoot": "",
5
+ "sources": [
6
+ "../src/INSARouterProps.ts"
7
+ ],
8
+ "names": [],
9
+ "mappings": ""
10
+ }
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { INSARouterProps } from "./INSARouterProps";
3
+ export interface IRouterMaker
4
+ {
5
+ on401(): void;
6
+ onRenderOnLogin(props: INSARouterProps): React.JSX.Element;
7
+ onRenderOnLogout(props: INSARouterProps, banned: boolean): React.JSX.Element;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IRouterMaker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IRouterMaker.js","sourceRoot":"","sources":["../src/IRouterMaker.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { NSNotificationProps } from "namirasoft-site-react";
2
+ export interface IRouterState {
3
+ inited?: boolean;
4
+ notifications?: NSNotificationProps[];
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IRouterState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IRouterState.js","sourceRoot":"","sources":["../src/IRouterState.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { IStorage } from "namirasoft-core";
2
+ import { CookieSetOptions } from "universal-cookie";
3
+ export declare class IStorageCookie extends IStorage {
4
+ private options;
5
+ private cookie;
6
+ constructor(options: CookieSetOptions);
7
+ get(name: string, defaultValue: string): any;
8
+ set(name: string, value: string): void;
9
+ del(name: string): void;
10
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.IStorageCookie = void 0;
7
+ const namirasoft_core_1 = require("namirasoft-core");
8
+ const universal_cookie_1 = __importDefault(require("universal-cookie"));
9
+ class IStorageCookie extends namirasoft_core_1.IStorage {
10
+ constructor(options) {
11
+ super();
12
+ this.options = options;
13
+ this.cookie = new universal_cookie_1.default();
14
+ }
15
+ get(name, defaultValue) {
16
+ var _a;
17
+ return (_a = this.cookie.get(name)) !== null && _a !== void 0 ? _a : defaultValue;
18
+ }
19
+ set(name, value) {
20
+ this.cookie.set(name, value, this.options);
21
+ }
22
+ del(name) {
23
+ this.cookie.remove(name);
24
+ }
25
+ }
26
+ exports.IStorageCookie = IStorageCookie;
27
+ //# sourceMappingURL=IStorageCookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IStorageCookie.js","sourceRoot":"","sources":["../src/IStorageCookie.ts"],"names":[],"mappings":";;;;;;AAAA,qDAA2C;AAC3C,wEAA6D;AAE7D,MAAa,cAAe,SAAQ,0BAAQ;IAIxC,YAAY,OAAyB;QAEjC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,IAAI,0BAAO,EAAE,CAAC;IAChC,CAAC;IACQ,GAAG,CAAC,IAAY,EAAE,YAAoB;;QAE3C,OAAO,MAAA,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,mCAAI,YAAY,CAAC;IACjD,CAAC;IACQ,GAAG,CAAC,IAAY,EAAE,KAAa;QAEpC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IACQ,GAAG,CAAC,IAAY;QAErB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACJ;AAtBD,wCAsBC"}
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { IRouterState } from "./IRouterState";
3
+ import { NSNotificationProps } from "namirasoft-site-react";
4
+ export declare class Messenger {
5
+ private static Counter;
6
+ private state;
7
+ private setState;
8
+ constructor(state: IRouterState | undefined, setState: React.Dispatch<React.SetStateAction<IRouterState | undefined>>);
9
+ private notify;
10
+ onInformation(text: string): void;
11
+ onSuccess(text: string): void;
12
+ onWarning(text: string): void;
13
+ onError(error: Error | string): void;
14
+ delNotification(id: string): void;
15
+ getNotifications(): NSNotificationProps[];
16
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Messenger = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const namirasoft_site_react_1 = require("namirasoft-site-react");
9
+ class Messenger {
10
+ constructor(state, setState) {
11
+ this.state = state;
12
+ this.setState = setState;
13
+ this.notify = this.notify.bind(this);
14
+ this.onInformation = this.onInformation.bind(this);
15
+ this.onSuccess = this.onSuccess.bind(this);
16
+ this.onWarning = this.onWarning.bind(this);
17
+ this.onError = this.onError.bind(this);
18
+ this.delNotification = this.delNotification.bind(this);
19
+ this.getNotifications = this.getNotifications.bind(this);
20
+ }
21
+ notify(message) {
22
+ var _a, _b, _c;
23
+ let inited = (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.inited) !== null && _b !== void 0 ? _b : false;
24
+ let notifications = [];
25
+ if ((_c = this.state) === null || _c === void 0 ? void 0 : _c.notifications)
26
+ notifications.push(...this.state.notifications);
27
+ notifications.push(message);
28
+ this.setState({ inited, notifications });
29
+ setTimeout(() => {
30
+ message.onClose();
31
+ }, 5000);
32
+ window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
33
+ }
34
+ onInformation(text) {
35
+ let id = Messenger.Counter++ + "";
36
+ this.notify({ id, text, type: namirasoft_site_react_1.NotificationType.Information, color: namirasoft_site_react_1.NSNotificationColor.GRAY, onClose: () => this.delNotification(id) });
37
+ }
38
+ onSuccess(text) {
39
+ let id = Messenger.Counter++ + "";
40
+ this.notify({ id, text, type: namirasoft_site_react_1.NotificationType.Success, color: namirasoft_site_react_1.NSNotificationColor.GREEN, onClose: () => this.delNotification(id) });
41
+ }
42
+ onWarning(text) {
43
+ let id = Messenger.Counter++ + "";
44
+ this.notify({ id, text, type: namirasoft_site_react_1.NotificationType.Warning, color: namirasoft_site_react_1.NSNotificationColor.YELLOW, onClose: () => this.delNotification(id) });
45
+ }
46
+ onError(error) {
47
+ var _a;
48
+ let id = Messenger.Counter++ + "";
49
+ let text = "";
50
+ if (error instanceof Error) {
51
+ text = error.message;
52
+ if (axios_1.default.isAxiosError(error))
53
+ if ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data)
54
+ text = error.response.data;
55
+ }
56
+ else
57
+ text = error;
58
+ this.notify({ id, text, type: namirasoft_site_react_1.NotificationType.Error, color: namirasoft_site_react_1.NSNotificationColor.RED, onClose: () => this.delNotification(id) });
59
+ }
60
+ delNotification(id) {
61
+ var _a;
62
+ if (!this.state)
63
+ return;
64
+ let inited = (_a = this.state.inited) !== null && _a !== void 0 ? _a : false;
65
+ let notifications = [];
66
+ if (this.state.notifications)
67
+ notifications.push(...this.state.notifications);
68
+ notifications = notifications.filter(x => x.id !== id);
69
+ this.setState({ inited, notifications });
70
+ }
71
+ getNotifications() {
72
+ var _a, _b;
73
+ return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.notifications) !== null && _b !== void 0 ? _b : [];
74
+ }
75
+ }
76
+ exports.Messenger = Messenger;
77
+ Messenger.Counter = 1;
78
+ //# sourceMappingURL=Messenger.js.map
@@ -0,0 +1 @@
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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AC,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,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;IACrI,CAAC;IACD,eAAe,CAAC,EAAU;;QAEtB,IAAI,CAAC,IAAI,CAAC,KAAK;YACX,OAAO;QAEX,IAAI,MAAM,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,MAAM,mCAAI,KAAK,CAAC;QACxC,IAAI,aAAa,GAA0B,EAAE,CAAC;QAC9C,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa;YACxB,aAAa,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACpD,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,gBAAgB;;QAEZ,OAAO,MAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,aAAa,mCAAI,EAAE,CAAC;IAC3C,CAAC;;AA5EL,8BA6EC;AA3EkB,iBAAO,GAAW,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { NotificationType } from "./NotificationType";
2
+ export type Notification = {
3
+ text: string;
4
+ type: NotificationType;
5
+ color: string;
6
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Notification.js","sourceRoot":"","sources":["../src/Notification.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export declare enum NotificationType {
2
+ Information = "Information",
3
+ Warning = "Warning",
4
+ Success = "Success",
5
+ Error = "Error"
6
+ }
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,25 @@
1
+ /// <reference types="react" />
2
+ import { ParsedQuery } from 'query-string';
3
+ import { ParsedNameValue } from "namirasoft-core";
4
+ import { IRouterMaker } from "./IRouterMaker";
5
+ import rrd from 'react-router-dom';
6
+ import { IRouterState } from "./IRouterState";
7
+ export declare class RouterMaker {
8
+ private state;
9
+ private setState;
10
+ private location;
11
+ private navigate;
12
+ private component;
13
+ constructor(state: IRouterState | undefined, setState: React.Dispatch<React.SetStateAction<IRouterState | undefined>>, location: rrd.Location, navigate: rrd.NavigateFunction, component: IRouterMaker);
14
+ private init;
15
+ getQueryStrings(): ParsedQuery;
16
+ getQuery(name: string): string;
17
+ getLink(sub: string, customQuery: {
18
+ [name: string]: ParsedNameValue;
19
+ }): string;
20
+ redirect(sub: string, customQuery: {
21
+ [name: string]: ParsedNameValue;
22
+ }): void;
23
+ onComponentDidMount(): void;
24
+ onRender(): React.JSX.Element;
25
+ }
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RouterMaker = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const query_string_1 = __importDefault(require("query-string"));
9
+ const namirasoft_core_1 = require("namirasoft-core");
10
+ const Messenger_1 = require("./Messenger");
11
+ const namirasoft_account_1 = require("namirasoft-account");
12
+ const axios_1 = __importDefault(require("axios"));
13
+ class RouterMaker {
14
+ constructor(state, setState, location, navigate, component) {
15
+ this.state = state;
16
+ this.setState = setState;
17
+ this.location = location;
18
+ this.navigate = navigate;
19
+ this.component = component;
20
+ this.init = this.init.bind(this);
21
+ this.getQueryStrings = this.getQueryStrings.bind(this);
22
+ this.getQuery = this.getQuery.bind(this);
23
+ this.getLink = this.getLink.bind(this);
24
+ this.redirect = this.redirect.bind(this);
25
+ this.onComponentDidMount = this.onComponentDidMount.bind(this);
26
+ this.onRender = this.onRender.bind(this);
27
+ }
28
+ init() {
29
+ var _a, _b;
30
+ let messenger = new Messenger_1.Messenger(this.state, this.setState);
31
+ let qStorage = this.getQuery("location");
32
+ let qAPI = this.getQuery("api");
33
+ let qToken = this.getQuery("token");
34
+ if (!qStorage)
35
+ if (qAPI)
36
+ qStorage = "memory";
37
+ let storage;
38
+ if (qStorage === "memory")
39
+ storage = new namirasoft_core_1.IStorageMemory();
40
+ else
41
+ storage = new namirasoft_core_1.IStorageLocal();
42
+ let token_manager = new namirasoft_account_1.TokenManager(storage, () => this.setState({}));
43
+ if (qToken)
44
+ token_manager.setValue(qToken, true);
45
+ let server = new namirasoft_account_1.NamirasoftAccountServer(token_manager, (error) => {
46
+ var _a;
47
+ if (axios_1.default.isAxiosError(error))
48
+ if (error.response)
49
+ if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
50
+ token_manager.del();
51
+ this.component.on401();
52
+ return;
53
+ }
54
+ messenger.onError(error);
55
+ });
56
+ let props = {
57
+ account: {
58
+ token_manager,
59
+ server,
60
+ },
61
+ url: {
62
+ getLink: this.getLink,
63
+ redirect: this.redirect,
64
+ getQueryStrings: this.getQueryStrings,
65
+ getQuery: this.getQuery,
66
+ },
67
+ messenger,
68
+ };
69
+ let inited = true;
70
+ if (qToken)
71
+ inited = (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.inited) !== null && _b !== void 0 ? _b : false;
72
+ return { props, inited };
73
+ }
74
+ getQueryStrings() {
75
+ return query_string_1.default.parse(this.location.search);
76
+ }
77
+ getQuery(name) {
78
+ let query = this.getQueryStrings();
79
+ let item = query[name];
80
+ return new namirasoft_core_1.ObjectService(item).getString();
81
+ }
82
+ getLink(sub, customQuery) {
83
+ if (!customQuery)
84
+ customQuery = {};
85
+ let query = query_string_1.default.parse(this.location.search);
86
+ let final = Object.assign(Object.assign({}, query), customQuery);
87
+ return namirasoft_core_1.URLOperation.getLink("", sub, final);
88
+ }
89
+ redirect(sub, customQuery) {
90
+ let ans = this.getLink(sub, customQuery);
91
+ this.navigate(ans);
92
+ }
93
+ onComponentDidMount() {
94
+ let { inited, props } = this.init();
95
+ this.setState({ notifications: [], inited });
96
+ let token = this.getQuery("token");
97
+ if (token) {
98
+ if (!props.account.token_manager.getUserData(u => u.id, "")) {
99
+ props.account.server.session.Current()
100
+ .then(response => {
101
+ props.account.token_manager.set(response, false);
102
+ this.setState({ inited: true });
103
+ })
104
+ .catch(() => {
105
+ this.setState({ inited: true });
106
+ });
107
+ }
108
+ }
109
+ }
110
+ onRender() {
111
+ let { inited, props } = this.init();
112
+ if (!inited)
113
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
114
+ let banned = false;
115
+ if (props.account.token_manager.exists()) {
116
+ banned = props.account.token_manager.getUserData(user => user.banned, false);
117
+ if (!banned)
118
+ return this.component.onRenderOnLogin(props);
119
+ }
120
+ return this.component.onRenderOnLogout(props, banned);
121
+ }
122
+ }
123
+ exports.RouterMaker = RouterMaker;
124
+ ;
125
+ //# sourceMappingURL=RouterMaker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouterMaker.js","sourceRoot":"","sources":["../src/RouterMaker.tsx"],"names":[],"mappings":";;;;;;;AAAA,gEAAwD;AACxD,qDAAwH;AACxH,2CAAwC;AACxC,2DAA2E;AAI3E,kDAA0B;AAG1B,MAAa,WAAW;IAOpB,YAAY,KAA+B,EAAE,QAAwE,EACjH,QAAsB,EAAE,QAA8B,EACtD,SAAuB;QAEvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,QAAQ,GAA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