@etsoo/notificationbase 1.1.51 → 1.1.53
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/.github/workflows/main.yml +6 -5
- package/README.md +25 -23
- package/__tests__/Notification.ts +81 -81
- package/__tests__/tsconfig.json +15 -15
- package/babel.config.json +8 -8
- package/lib/cjs/Notification.d.ts +1 -1
- package/lib/cjs/NotificationContainer.d.ts +1 -1
- package/lib/cjs/NotificationContainer.js +1 -1
- package/lib/cjs/index.d.ts +2 -2
- package/lib/mjs/Notification.d.ts +1 -1
- package/lib/mjs/Notification.js +1 -1
- package/lib/mjs/NotificationContainer.d.ts +1 -1
- package/lib/mjs/NotificationContainer.js +2 -2
- package/lib/mjs/index.d.ts +2 -2
- package/lib/mjs/index.js +2 -2
- package/package.json +7 -7
- package/src/Notification.ts +349 -349
- package/src/NotificationContainer.ts +569 -572
- package/src/index.ts +2 -2
- package/tsconfig.cjs.json +15 -15
- package/tsconfig.json +15 -15
- package/.eslintignore +0 -3
- package/.eslintrc.json +0 -29
- package/.prettierignore +0 -5
- package/.prettierrc +0 -6
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
name: Node.js Package
|
|
7
7
|
|
|
8
8
|
# Event to trigger the action
|
|
9
|
-
on:
|
|
9
|
+
on:
|
|
10
|
+
[push]
|
|
10
11
|
# release:
|
|
11
12
|
# types: [created]
|
|
12
13
|
|
|
@@ -23,13 +24,13 @@ jobs:
|
|
|
23
24
|
# https://github.com/actions/checkout, This action checks-out your repository under $GITHUB_WORKSPACE
|
|
24
25
|
# so your workflow can access it.
|
|
25
26
|
- uses: actions/checkout@v4
|
|
26
|
-
|
|
27
|
+
|
|
27
28
|
# Set up your GitHub Actions workflow with a specific version of node.js
|
|
28
29
|
# Setup .npmrc file to publish to npm
|
|
29
30
|
- uses: actions/setup-node@v4
|
|
30
31
|
with:
|
|
31
|
-
node-version:
|
|
32
|
-
registry-url:
|
|
32
|
+
node-version: "20.x"
|
|
33
|
+
registry-url: "https://registry.npmjs.org"
|
|
33
34
|
|
|
34
35
|
# Named after Continuous Integration, installs dependencies directly from package-lock.json
|
|
35
36
|
# ci vs install
|
|
@@ -45,4 +46,4 @@ jobs:
|
|
|
45
46
|
# For scoped package, make it public for free service
|
|
46
47
|
- run: npm publish --access public
|
|
47
48
|
env:
|
|
48
|
-
NODE_AUTH_TOKEN: ${{ secrets.ETSOONpmToken }}
|
|
49
|
+
NODE_AUTH_TOKEN: ${{ secrets.ETSOONpmToken }}
|
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# NotificationBase
|
|
2
|
+
|
|
2
3
|
**TypeScript notification component for extending with all features described and partially implemented.**
|
|
3
4
|
|
|
4
5
|
## Installing
|
|
@@ -16,26 +17,27 @@ $ yarn add @etsoo/notificationbase
|
|
|
16
17
|
```
|
|
17
18
|
|
|
18
19
|
## Notification
|
|
20
|
+
|
|
19
21
|
Notification object to display. INotification is the interface. INotificationBase is for data definition.
|
|
20
22
|
|
|
21
23
|
Properties:
|
|
22
24
|
|
|
23
|
-
|Name|Description|
|
|
24
|
-
|
|
25
|
-
|align|Readonly, display align|
|
|
26
|
-
|content|Content to display|
|
|
27
|
-
|id|Unique id|
|
|
28
|
-
|inputProps|Input or additional control properties|
|
|
29
|
-
|modal|Display as modal window or not|
|
|
30
|
-
|onDismiss|Dismiss callback|
|
|
31
|
-
|onReturn|Return value callback|
|
|
32
|
-
|open|Is open or not|
|
|
33
|
-
|ref|Render result reference|
|
|
34
|
-
|renderSetup|Setup callback before render|
|
|
35
|
-
|showIcon|Show icon or not|
|
|
36
|
-
|timespan|Seconds to auto dismiss|
|
|
37
|
-
|title|Title|
|
|
38
|
-
|type|Notification type|
|
|
25
|
+
| Name | Description |
|
|
26
|
+
| ----------: | -------------------------------------- |
|
|
27
|
+
| align | Readonly, display align |
|
|
28
|
+
| content | Content to display |
|
|
29
|
+
| id | Unique id |
|
|
30
|
+
| inputProps | Input or additional control properties |
|
|
31
|
+
| modal | Display as modal window or not |
|
|
32
|
+
| onDismiss | Dismiss callback |
|
|
33
|
+
| onReturn | Return value callback |
|
|
34
|
+
| open | Is open or not |
|
|
35
|
+
| ref | Render result reference |
|
|
36
|
+
| renderSetup | Setup callback before render |
|
|
37
|
+
| showIcon | Show icon or not |
|
|
38
|
+
| timespan | Seconds to auto dismiss |
|
|
39
|
+
| title | Title |
|
|
40
|
+
| type | Notification type |
|
|
39
41
|
|
|
40
42
|
Methods:
|
|
41
43
|
|
|
@@ -87,17 +89,17 @@ Methods:
|
|
|
87
89
|
returnValue(value: any): Promise<void>;
|
|
88
90
|
```
|
|
89
91
|
|
|
90
|
-
|
|
91
92
|
## NotificationContainer
|
|
93
|
+
|
|
92
94
|
NotificationContainer is to hold all notifications. INotificationContainer is the interface.
|
|
93
95
|
|
|
94
96
|
Properties:
|
|
95
97
|
|
|
96
|
-
|Name|Description|
|
|
97
|
-
|
|
98
|
-
|notifications|Readonly. Notification collection to display|
|
|
99
|
-
|isLoading|Is loading bar showing|
|
|
100
|
-
|isModeling|Is model window showing|
|
|
98
|
+
| Name | Description |
|
|
99
|
+
| ------------: | -------------------------------------------- |
|
|
100
|
+
| notifications | Readonly. Notification collection to display |
|
|
101
|
+
| isLoading | Is loading bar showing |
|
|
102
|
+
| isModeling | Is model window showing |
|
|
101
103
|
|
|
102
104
|
Methods:
|
|
103
105
|
|
|
@@ -240,4 +242,4 @@ Methods:
|
|
|
240
242
|
timespan?: number,
|
|
241
243
|
props?: C
|
|
242
244
|
): INotification<UI, C>;
|
|
243
|
-
```
|
|
245
|
+
```
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { DataTypes } from
|
|
1
|
+
import { DataTypes } from "@etsoo/shared";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from
|
|
11
|
-
import { NotificationContainer } from
|
|
3
|
+
INotificaseBase,
|
|
4
|
+
INotification,
|
|
5
|
+
Notification,
|
|
6
|
+
NotificationAlign,
|
|
7
|
+
NotificationCallProps,
|
|
8
|
+
NotificationRenderProps,
|
|
9
|
+
NotificationType
|
|
10
|
+
} from "../src/Notification";
|
|
11
|
+
import { NotificationContainer } from "../src/NotificationContainer";
|
|
12
12
|
|
|
13
13
|
// Class implementation for tests
|
|
14
14
|
class NotificationTest extends Notification<any, NotificationCallProps> {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
render(props: NotificationRenderProps, className?: string, options?: any) {
|
|
16
|
+
throw new Error("Method not implemented.");
|
|
17
|
+
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
class NotificationContainerTest extends NotificationContainer<
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
any,
|
|
22
|
+
NotificationCallProps
|
|
23
23
|
> {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
protected addRaw(
|
|
25
|
+
data: INotificaseBase<any, NotificationCallProps>
|
|
26
|
+
): INotification<any, NotificationCallProps> {
|
|
27
|
+
throw new Error("Method not implemented.");
|
|
28
|
+
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// Container
|
|
@@ -35,92 +35,92 @@ var container = new NotificationContainerTest((update) => {});
|
|
|
35
35
|
// https://jestjs.io/docs/en/timer-mocks
|
|
36
36
|
jest.useFakeTimers();
|
|
37
37
|
|
|
38
|
-
test(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
test("Tests for basic data", () => {
|
|
39
|
+
expect(Object.keys(container.notifications).length).toBe(
|
|
40
|
+
DataTypes.getEnumKeys(NotificationAlign).length
|
|
41
|
+
);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
test(
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
test("Tests for notification dismiss", () => {
|
|
45
|
+
// Arrange
|
|
46
|
+
const n = new NotificationTest(NotificationType.Loading, "Test");
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
// Spy on the method
|
|
49
|
+
const spy = jest.spyOn(n, "dismiss");
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
// Act
|
|
52
|
+
n.dismiss(2);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
// Fast forward
|
|
55
|
+
jest.runOnlyPendingTimers();
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
// dismiss should be called 2 times
|
|
58
|
+
expect(spy).toHaveBeenCalledTimes(2);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
test(
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
test("Tests for notification container add", () => {
|
|
62
|
+
// Arrange
|
|
63
|
+
const n = new NotificationTest(NotificationType.Loading, "Test");
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
// Act
|
|
66
|
+
container.add(n);
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
// One item added
|
|
69
|
+
expect(container.alignCount(n.align)).toBe(1);
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
// Dismiss will remove the item at once
|
|
72
|
+
n.dismiss();
|
|
73
|
+
expect(container.alignCount(n.align)).toBe(0);
|
|
74
|
+
expect(n.open).toBe(false);
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
// Fast forward
|
|
77
|
+
jest.runOnlyPendingTimers();
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
// Will be totally removed from the collection
|
|
80
|
+
expect(container.alignCount(n.align)).toBe(0);
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
test(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
test("Tests for notification container remove", (done) => {
|
|
84
|
+
// Arrange
|
|
85
|
+
// Reset
|
|
86
|
+
container.dispose();
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
// One notification
|
|
89
|
+
const n = new NotificationTest(NotificationType.Loading, "Test");
|
|
90
|
+
n.onDismiss = () => {
|
|
91
|
+
expect(container.isLoading).toBeFalsy();
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
// New notification
|
|
94
|
+
const newNotification = new NotificationTest(
|
|
95
|
+
NotificationType.Prompt,
|
|
96
|
+
"Prompt"
|
|
97
|
+
);
|
|
98
|
+
container.add(newNotification);
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
// Fast forward
|
|
101
|
+
jest.runOnlyPendingTimers();
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
// Clear tests
|
|
104
|
+
expect(container.alignCount(NotificationAlign.Unknown)).toBe(1);
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
container.clear();
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
expect(container.alignCount(NotificationAlign.Unknown)).toBe(1);
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
done();
|
|
111
|
+
};
|
|
112
|
+
n.timespan = 3;
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
// Act
|
|
115
|
+
container.add(n);
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
// Assert
|
|
118
|
+
// Previous test added one but a new modal type will remove it
|
|
119
|
+
expect(container.isLoading).toBeTruthy();
|
|
120
|
+
expect(container.isModeling).toBeTruthy();
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
// Fast forward
|
|
123
|
+
jest.runOnlyPendingTimers();
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
jest.clearAllTimers();
|
package/__tests__/tsconfig.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Node10",
|
|
6
|
+
"allowJs": false,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"declaration": true
|
|
15
|
+
},
|
|
16
|
+
"include": [".."]
|
|
17
17
|
}
|
package/babel.config.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
]
|
|
2
|
+
"presets": ["@babel/preset-env"],
|
|
3
|
+
"plugins": [
|
|
4
|
+
[
|
|
5
|
+
"@babel/plugin-transform-runtime",
|
|
6
|
+
{
|
|
7
|
+
"corejs": 3
|
|
8
|
+
}
|
|
10
9
|
]
|
|
10
|
+
]
|
|
11
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INotificaseBase, INotification, NotificationAlign, NotificationCallProps, NotificationContent, NotificationMessageType, NotificationParameters, NotificationReturn } from
|
|
1
|
+
import { INotificaseBase, INotification, NotificationAlign, NotificationCallProps, NotificationContent, NotificationMessageType, NotificationParameters, NotificationReturn } from "./Notification";
|
|
2
2
|
/**
|
|
3
3
|
* Notification action
|
|
4
4
|
*/
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./Notification";
|
|
2
|
+
export * from "./NotificationContainer";
|
package/lib/mjs/Notification.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes, Utils } from
|
|
1
|
+
import { DataTypes, Utils } from "@etsoo/shared";
|
|
2
2
|
// https://devimalplanet.com/typescript-how-to-extend-one-enum-from-another
|
|
3
3
|
// Number index keys are still there
|
|
4
4
|
const { MiddleLeft, MiddleRight, ...alignItems } = DataTypes.PlacementEnum;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INotificaseBase, INotification, NotificationAlign, NotificationCallProps, NotificationContent, NotificationMessageType, NotificationParameters, NotificationReturn } from
|
|
1
|
+
import { INotificaseBase, INotification, NotificationAlign, NotificationCallProps, NotificationContent, NotificationMessageType, NotificationParameters, NotificationReturn } from "./Notification";
|
|
2
2
|
/**
|
|
3
3
|
* Notification action
|
|
4
4
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NotificationAlign, NotificationMessageType, NotificationModalType, NotificationType } from
|
|
1
|
+
import { NotificationAlign, NotificationMessageType, NotificationModalType, NotificationType } from "./Notification";
|
|
2
2
|
/**
|
|
3
3
|
* Notification container class
|
|
4
4
|
*/
|
|
@@ -271,7 +271,7 @@ export class NotificationContainer {
|
|
|
271
271
|
// Setup
|
|
272
272
|
const n = {
|
|
273
273
|
type: NotificationType.Loading,
|
|
274
|
-
content: title ??
|
|
274
|
+
content: title ?? ""
|
|
275
275
|
};
|
|
276
276
|
// Add to the collection
|
|
277
277
|
// Keep the reference
|
package/lib/mjs/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./Notification";
|
|
2
|
+
export * from "./NotificationContainer";
|
package/lib/mjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./Notification";
|
|
2
|
+
export * from "./NotificationContainer";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/notificationbase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.53",
|
|
4
4
|
"description": "TypeScript notification component for extending with all features described and partially implemented",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://github.com/ETSOO/NotificationBase#readme",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@etsoo/shared": "^1.2.
|
|
55
|
+
"@etsoo/shared": "^1.2.54"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@babel/core": "^7.
|
|
59
|
-
"@babel/plugin-transform-runtime": "^7.25.
|
|
60
|
-
"@babel/preset-env": "^7.
|
|
61
|
-
"@babel/runtime-corejs3": "^7.
|
|
62
|
-
"@types/jest": "^29.5.
|
|
58
|
+
"@babel/core": "^7.26.0",
|
|
59
|
+
"@babel/plugin-transform-runtime": "^7.25.9",
|
|
60
|
+
"@babel/preset-env": "^7.26.0",
|
|
61
|
+
"@babel/runtime-corejs3": "^7.26.0",
|
|
62
|
+
"@types/jest": "^29.5.14",
|
|
63
63
|
"babel-jest": "^29.7.0",
|
|
64
64
|
"jest": "^29.7.0",
|
|
65
65
|
"jest-environment-jsdom": "^29.7.0",
|