@etsoo/notificationbase 1.1.0 → 1.1.3

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/README.md CHANGED
@@ -102,14 +102,16 @@ Methods:
102
102
  add(notification: INotification<UI, C>, top?: boolean): void;
103
103
 
104
104
  /**
105
- * Report error
106
- * @param error Error message
105
+ * Report error or message
106
+ * @param errorOrTitle Error message or title
107
107
  * @param callback Callback
108
+ * @param type Type, default is Error
108
109
  * @param props Props
109
110
  */
110
111
  alert(
111
- error: NotificationContent<UI>,
112
+ error: NotificationContent<UI> | [NotificationContent<UI>, NotificationContent<UI>],
112
113
  callback?: NotificationReturn<void>,
114
+ type?: NotificationMessageType,
113
115
  props?: C
114
116
  ): INotification<UI, C>;
115
117
 
@@ -30,13 +30,13 @@ export interface INotifier<UI, C extends NotificationCallProps> {
30
30
  */
31
31
  add(notification: INotification<UI, C>, top?: boolean): void;
32
32
  /**
33
- * Report error
34
- * @param error Error message
33
+ * Report error or message
34
+ * @param errorOrTitle Error message or title
35
35
  * @param callback Callback
36
36
  * @param type Type, default is Error
37
37
  * @param props Props
38
38
  */
39
- alert(error: NotificationContent<UI>, callback?: NotificationReturn<void>, type?: NotificationMessageType, props?: C): INotification<UI, C>;
39
+ alert(errorOrTitle: NotificationContent<UI> | [NotificationContent<UI>, NotificationContent<UI>], callback?: NotificationReturn<void>, type?: NotificationMessageType, props?: C): INotification<UI, C>;
40
40
  /**
41
41
  * Align all notification count
42
42
  * @param align Align
@@ -182,13 +182,13 @@ export declare abstract class NotificationContainer<UI, C extends NotificationCa
182
182
  */
183
183
  getById(id: string): INotification<UI, C> | undefined;
184
184
  /**
185
- * Report error
186
- * @param error Error message
185
+ * Report error or message
186
+ * @param errorOrTitle Error message or title
187
187
  * @param callback Callback
188
188
  * @param type Type, default is Error
189
189
  * @param props Props
190
190
  */
191
- alert(error: string, callback?: NotificationReturn<void>, type?: NotificationMessageType, props?: C): INotification<UI, C>;
191
+ alert(errorOrTitle: NotificationContent<UI> | [NotificationContent<UI>, NotificationContent<UI>], callback?: NotificationReturn<void>, type?: NotificationMessageType, props?: C): INotification<UI, C>;
192
192
  /**
193
193
  * Confirm action
194
194
  * @param message Message
@@ -137,17 +137,27 @@ export class NotificationContainer {
137
137
  return undefined;
138
138
  }
139
139
  /**
140
- * Report error
141
- * @param error Error message
140
+ * Report error or message
141
+ * @param errorOrTitle Error message or title
142
142
  * @param callback Callback
143
143
  * @param type Type, default is Error
144
144
  * @param props Props
145
145
  */
146
- alert(error, callback, type, props) {
146
+ alert(errorOrTitle, callback, type, props) {
147
+ // Parse messange and title
148
+ let error, title;
149
+ if (Array.isArray(errorOrTitle)) {
150
+ error = errorOrTitle[0];
151
+ title = errorOrTitle[1];
152
+ }
153
+ else {
154
+ error = errorOrTitle;
155
+ }
147
156
  // Setup
148
157
  const n = {
149
158
  inputProps: props,
150
159
  type: type !== null && type !== void 0 ? type : NotificationType.Error,
160
+ title,
151
161
  content: error,
152
162
  onReturn: callback
153
163
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/notificationbase",
3
- "version": "1.1.0",
3
+ "version": "1.1.3",
4
4
  "description": "TypeScript notification component for extending with all features described and partially implemented",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -45,22 +45,23 @@
45
45
  },
46
46
  "homepage": "https://github.com/ETSOO/NotificationBase#readme",
47
47
  "dependencies": {
48
- "@etsoo/shared": "^1.0.97"
48
+ "@etsoo/shared": "^1.1.38"
49
49
  },
50
50
  "devDependencies": {
51
- "@babel/core": "^7.16.7",
52
- "@babel/plugin-transform-runtime": "^7.16.7",
53
- "@babel/preset-env": "^7.16.7",
54
- "@babel/runtime-corejs3": "^7.16.7",
55
- "@types/jest": "^27.4.0",
56
- "@typescript-eslint/eslint-plugin": "^5.8.1",
57
- "@typescript-eslint/parser": "^5.8.1",
58
- "babel-jest": "^27.4.5",
59
- "eslint": "^8.5.0",
51
+ "@babel/core": "^7.18.0",
52
+ "@babel/plugin-transform-runtime": "^7.18.0",
53
+ "@babel/preset-env": "^7.18.0",
54
+ "@babel/runtime-corejs3": "^7.18.0",
55
+ "@types/jest": "^27.5.1",
56
+ "@typescript-eslint/eslint-plugin": "^5.25.0",
57
+ "@typescript-eslint/parser": "^5.25.0",
58
+ "babel-jest": "^28.1.0",
59
+ "eslint": "^8.16.0",
60
60
  "eslint-config-airbnb-base": "^15.0.0",
61
- "eslint-plugin-import": "^2.25.3",
62
- "jest": "^27.4.5",
63
- "ts-jest": "^27.1.2",
64
- "typescript": "^4.5.4"
61
+ "eslint-plugin-import": "^2.26.0",
62
+ "jest": "^28.1.0",
63
+ "jest-environment-jsdom": "^28.1.0",
64
+ "ts-jest": "^28.0.2",
65
+ "typescript": "^4.6.4"
65
66
  }
66
67
  }
@@ -47,14 +47,16 @@ export interface INotifier<UI, C extends NotificationCallProps> {
47
47
  add(notification: INotification<UI, C>, top?: boolean): void;
48
48
 
49
49
  /**
50
- * Report error
51
- * @param error Error message
50
+ * Report error or message
51
+ * @param errorOrTitle Error message or title
52
52
  * @param callback Callback
53
53
  * @param type Type, default is Error
54
54
  * @param props Props
55
55
  */
56
56
  alert(
57
- error: NotificationContent<UI>,
57
+ errorOrTitle:
58
+ | NotificationContent<UI>
59
+ | [NotificationContent<UI>, NotificationContent<UI>],
58
60
  callback?: NotificationReturn<void>,
59
61
  type?: NotificationMessageType,
60
62
  props?: C
@@ -349,22 +351,35 @@ export abstract class NotificationContainer<UI, C extends NotificationCallProps>
349
351
  }
350
352
 
351
353
  /**
352
- * Report error
353
- * @param error Error message
354
+ * Report error or message
355
+ * @param errorOrTitle Error message or title
354
356
  * @param callback Callback
355
357
  * @param type Type, default is Error
356
358
  * @param props Props
357
359
  */
358
360
  alert(
359
- error: string,
361
+ errorOrTitle:
362
+ | NotificationContent<UI>
363
+ | [NotificationContent<UI>, NotificationContent<UI>],
360
364
  callback?: NotificationReturn<void>,
361
365
  type?: NotificationMessageType,
362
366
  props?: C
363
367
  ) {
368
+ // Parse messange and title
369
+ let error: NotificationContent<UI>,
370
+ title: NotificationContent<UI> | undefined;
371
+ if (Array.isArray(errorOrTitle)) {
372
+ error = errorOrTitle[0];
373
+ title = errorOrTitle[1];
374
+ } else {
375
+ error = errorOrTitle;
376
+ }
377
+
364
378
  // Setup
365
379
  const n: INotificaseBase<UI, C> = {
366
380
  inputProps: props,
367
381
  type: type ?? NotificationType.Error,
382
+ title,
368
383
  content: error,
369
384
  onReturn: callback
370
385
  };