@etsoo/react 1.3.24 → 1.3.28

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,10 +1,11 @@
1
1
  import { IAppSettings } from '@etsoo/appscript';
2
+ import { DataTypes } from '@etsoo/shared';
2
3
  /**
3
4
  * Service app settings interface
4
5
  */
5
- export interface IServiceAppSettings extends IAppSettings {
6
+ export interface IServiceAppSettings<S extends DataTypes.IdType = number> extends IAppSettings {
6
7
  /**
7
8
  * Service id
8
9
  */
9
- readonly serviceId?: string;
10
+ readonly serviceId: S;
10
11
  }
@@ -0,0 +1,6 @@
1
+ import { IPageData } from '../states/PageState';
2
+ /**
3
+ * Service page data interface
4
+ */
5
+ export interface IServicePageData extends IPageData {
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { IUser } from '@etsoo/appscript';
2
2
  /**
3
- *
3
+ * Service user interface
4
4
  */
5
5
  export interface IServiceUser extends IUser {
6
6
  }
@@ -60,7 +60,7 @@ export class ReactApp extends CoreApp {
60
60
  // API
61
61
  // Support to replace {hostname} with current hostname
62
62
  const api = createClient();
63
- api.baseUrl = settings.endpoint.replace('{hostname}', window.location.hostname);
63
+ api.baseUrl = settings.endpoint;
64
64
  return api;
65
65
  }
66
66
  static createNotifier() {
@@ -1,6 +1,7 @@
1
- import { IApi, IUser } from '@etsoo/appscript';
2
- import { IPageData } from '../states/PageState';
1
+ import { IApi } from '@etsoo/appscript';
3
2
  import { IServiceAppSettings } from './IServiceAppSettings';
3
+ import { IServicePageData } from './IServicePage';
4
+ import { IServiceUser } from './IServiceUser';
4
5
  import { ReactApp } from './ReactApp';
5
6
  /**
6
7
  * Core Service App
@@ -8,7 +9,7 @@ import { ReactApp } from './ReactApp';
8
9
  * Use the acess token to the service api, get a service access token
9
10
  * Use the new acess token and refresh token to login
10
11
  */
11
- export declare class ServiceApp<P extends IPageData, U extends IUser, S extends IServiceAppSettings = IServiceAppSettings> extends ReactApp<S, U, P> {
12
+ export declare class ServiceApp<P extends IServicePageData = IServicePageData, U extends IServiceUser = IServiceUser, S extends IServiceAppSettings = IServiceAppSettings> extends ReactApp<S, U, P> {
12
13
  /**
13
14
  * Core system API
14
15
  */
package/lib/index.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ export * from './app/InputDialogProps';
2
+ export * from './app/IServiceAppSettings';
3
+ export * from './app/IServicePage';
4
+ export * from './app/IServiceUser';
1
5
  export * from './app/Labels';
2
6
  export * from './app/ReactApp';
3
7
  export * from './app/ServiceApp';
package/lib/index.js CHANGED
@@ -1,4 +1,8 @@
1
1
  // app
2
+ export * from './app/InputDialogProps';
3
+ export * from './app/IServiceAppSettings';
4
+ export * from './app/IServicePage';
5
+ export * from './app/IServiceUser';
2
6
  export * from './app/Labels';
3
7
  export * from './app/ReactApp';
4
8
  export * from './app/ServiceApp';
@@ -32,7 +32,7 @@ export interface ItemListProps {
32
32
  /**
33
33
  * Close event
34
34
  */
35
- onClose?(item?: any): void;
35
+ onClose?(item: any, changed: boolean): void;
36
36
  /**
37
37
  * Current selected language
38
38
  */
@@ -38,11 +38,13 @@ export function ItemList(props) {
38
38
  };
39
39
  // Close handler
40
40
  const closeHandler = () => {
41
+ if (!open)
42
+ return;
41
43
  // Close the dialog
42
44
  setOpen(false);
43
45
  // Emit close event
44
46
  if (onClose) {
45
- onClose(currentItem);
47
+ onClose(currentItem, false);
46
48
  }
47
49
  };
48
50
  // Close item handler
@@ -53,7 +55,7 @@ export function ItemList(props) {
53
55
  setOpen(false);
54
56
  // Emit close event
55
57
  if (onClose) {
56
- onClose(item);
58
+ onClose(item, true);
57
59
  }
58
60
  };
59
61
  return (React.createElement(React.Fragment, null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.3.24",
3
+ "version": "1.3.28",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "@emotion/react": "^11.6.0",
51
51
  "@emotion/style": "^0.8.0",
52
52
  "@emotion/styled": "^11.6.0",
53
- "@etsoo/appscript": "^1.1.46",
53
+ "@etsoo/appscript": "^1.1.47",
54
54
  "@etsoo/notificationbase": "^1.0.93",
55
55
  "@etsoo/shared": "^1.0.74",
56
56
  "@mui/icons-material": "^5.1.1",
@@ -79,14 +79,14 @@
79
79
  "@babel/plugin-transform-runtime": "^7.16.4",
80
80
  "@babel/preset-env": "^7.16.4",
81
81
  "@babel/runtime-corejs3": "^7.16.3",
82
- "@types/jest": "^27.0.2",
82
+ "@types/jest": "^27.0.3",
83
83
  "@types/react-test-renderer": "^17.0.1",
84
84
  "@typescript-eslint/eslint-plugin": "^5.4.0",
85
85
  "@typescript-eslint/parser": "^5.4.0",
86
86
  "eslint": "^8.2.0",
87
87
  "eslint-config-airbnb-base": "^15.0.0",
88
88
  "eslint-plugin-import": "^2.25.3",
89
- "eslint-plugin-react": "^7.27.0",
89
+ "eslint-plugin-react": "^7.27.1",
90
90
  "jest": "^27.3.1",
91
91
  "react-test-renderer": "^17.0.2",
92
92
  "ts-jest": "^27.0.7",
@@ -1,11 +1,13 @@
1
1
  import { IAppSettings } from '@etsoo/appscript';
2
+ import { DataTypes } from '@etsoo/shared';
2
3
 
3
4
  /**
4
5
  * Service app settings interface
5
6
  */
6
- export interface IServiceAppSettings extends IAppSettings {
7
+ export interface IServiceAppSettings<S extends DataTypes.IdType = number>
8
+ extends IAppSettings {
7
9
  /**
8
10
  * Service id
9
11
  */
10
- readonly serviceId?: string;
12
+ readonly serviceId: S;
11
13
  }
@@ -0,0 +1,6 @@
1
+ import { IPageData } from '../states/PageState';
2
+
3
+ /**
4
+ * Service page data interface
5
+ */
6
+ export interface IServicePageData extends IPageData {}
@@ -1,8 +1,6 @@
1
1
  import { IUser } from '@etsoo/appscript';
2
2
 
3
3
  /**
4
- *
4
+ * Service user interface
5
5
  */
6
- export interface IServiceUser extends IUser {
7
-
8
- }
6
+ export interface IServiceUser extends IUser {}
@@ -118,10 +118,7 @@ export class ReactApp<
118
118
  // API
119
119
  // Support to replace {hostname} with current hostname
120
120
  const api = createClient();
121
- api.baseUrl = settings.endpoint.replace(
122
- '{hostname}',
123
- window.location.hostname
124
- );
121
+ api.baseUrl = settings.endpoint;
125
122
  return api;
126
123
  }
127
124
 
@@ -1,6 +1,7 @@
1
- import { createClient, IApi, IUser } from '@etsoo/appscript';
2
- import { IPageData } from '../states/PageState';
1
+ import { createClient, IApi } from '@etsoo/appscript';
3
2
  import { IServiceAppSettings } from './IServiceAppSettings';
3
+ import { IServicePageData } from './IServicePage';
4
+ import { IServiceUser } from './IServiceUser';
4
5
  import { ReactApp } from './ReactApp';
5
6
 
6
7
  /**
@@ -10,8 +11,8 @@ import { ReactApp } from './ReactApp';
10
11
  * Use the new acess token and refresh token to login
11
12
  */
12
13
  export class ServiceApp<
13
- P extends IPageData,
14
- U extends IUser,
14
+ P extends IServicePageData = IServicePageData,
15
+ U extends IServiceUser = IServiceUser,
15
16
  S extends IServiceAppSettings = IServiceAppSettings
16
17
  > extends ReactApp<S, U, P> {
17
18
  /**
package/src/index.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  // app
2
+ export * from './app/InputDialogProps';
3
+ export * from './app/IServiceAppSettings';
4
+ export * from './app/IServicePage';
5
+ export * from './app/IServiceUser';
2
6
  export * from './app/Labels';
3
7
  export * from './app/ReactApp';
4
8
  export * from './app/ServiceApp';
@@ -48,7 +48,7 @@ export interface ItemListProps {
48
48
  /**
49
49
  * Close event
50
50
  */
51
- onClose?(item?: any): void;
51
+ onClose?(item: any, changed: boolean): void;
52
52
 
53
53
  /**
54
54
  * Current selected language
@@ -133,12 +133,14 @@ export function ItemList(props: ItemListProps) {
133
133
 
134
134
  // Close handler
135
135
  const closeHandler = () => {
136
+ if (!open) return;
137
+
136
138
  // Close the dialog
137
139
  setOpen(false);
138
140
 
139
141
  // Emit close event
140
142
  if (onClose) {
141
- onClose(currentItem);
143
+ onClose(currentItem, false);
142
144
  }
143
145
  };
144
146
 
@@ -152,7 +154,7 @@ export function ItemList(props: ItemListProps) {
152
154
 
153
155
  // Emit close event
154
156
  if (onClose) {
155
- onClose(item);
157
+ onClose(item, true);
156
158
  }
157
159
  };
158
160