@etsoo/react 1.8.85 → 1.8.86
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.
|
@@ -113,6 +113,7 @@ export declare abstract class NotifierReact extends NotificationContainer<React.
|
|
|
113
113
|
* Singleton instance
|
|
114
114
|
*/
|
|
115
115
|
static get instance(): INotifierReact;
|
|
116
|
+
private static _cache;
|
|
116
117
|
/**
|
|
117
118
|
* Update notifier
|
|
118
119
|
* @param notifier Notifier
|
|
@@ -139,5 +140,10 @@ export declare abstract class NotifierReact extends NotificationContainer<React.
|
|
|
139
140
|
* @returns Provider
|
|
140
141
|
*/
|
|
141
142
|
createProvider(className?: string, debug?: boolean): React.FunctionComponent<React.PropsWithChildren<NotificationReactRenderProps>>;
|
|
143
|
+
/**
|
|
144
|
+
* Remove cache
|
|
145
|
+
* @param id Notification id
|
|
146
|
+
*/
|
|
147
|
+
removeCache(id: string): void;
|
|
142
148
|
}
|
|
143
149
|
export {};
|
|
@@ -25,6 +25,8 @@ class NotifierReact extends notificationbase_1.NotificationContainer {
|
|
|
25
25
|
static get instance() {
|
|
26
26
|
return NotifierReact._instance;
|
|
27
27
|
}
|
|
28
|
+
// Cache
|
|
29
|
+
static _cache = {};
|
|
28
30
|
/**
|
|
29
31
|
* Update notifier
|
|
30
32
|
* @param notifier Notifier
|
|
@@ -66,7 +68,18 @@ class NotifierReact extends notificationbase_1.NotificationContainer {
|
|
|
66
68
|
// Notifications under the align
|
|
67
69
|
const notifications = state[align];
|
|
68
70
|
// UI collections
|
|
69
|
-
const ui = notifications.map((notification) =>
|
|
71
|
+
const ui = notifications.map((notification) => {
|
|
72
|
+
// Id
|
|
73
|
+
const id = notification.id;
|
|
74
|
+
// Try cache
|
|
75
|
+
const cache = NotifierReact._cache[id];
|
|
76
|
+
if (cache)
|
|
77
|
+
return cache;
|
|
78
|
+
const element = notification.render(props, className ? className + "-item" : className);
|
|
79
|
+
// Cache the element
|
|
80
|
+
NotifierReact._cache[id] = element;
|
|
81
|
+
return element;
|
|
82
|
+
});
|
|
70
83
|
// Add to the collection
|
|
71
84
|
aligns.push(this.createContainer(Number(align), ui));
|
|
72
85
|
}
|
|
@@ -84,5 +97,12 @@ class NotifierReact extends notificationbase_1.NotificationContainer {
|
|
|
84
97
|
}, this.notifications, {}, creator);
|
|
85
98
|
return provider;
|
|
86
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Remove cache
|
|
102
|
+
* @param id Notification id
|
|
103
|
+
*/
|
|
104
|
+
removeCache(id) {
|
|
105
|
+
delete NotifierReact._cache[id];
|
|
106
|
+
}
|
|
87
107
|
}
|
|
88
108
|
exports.NotifierReact = NotifierReact;
|
|
@@ -113,6 +113,7 @@ export declare abstract class NotifierReact extends NotificationContainer<React.
|
|
|
113
113
|
* Singleton instance
|
|
114
114
|
*/
|
|
115
115
|
static get instance(): INotifierReact;
|
|
116
|
+
private static _cache;
|
|
116
117
|
/**
|
|
117
118
|
* Update notifier
|
|
118
119
|
* @param notifier Notifier
|
|
@@ -139,5 +140,10 @@ export declare abstract class NotifierReact extends NotificationContainer<React.
|
|
|
139
140
|
* @returns Provider
|
|
140
141
|
*/
|
|
141
142
|
createProvider(className?: string, debug?: boolean): React.FunctionComponent<React.PropsWithChildren<NotificationReactRenderProps>>;
|
|
143
|
+
/**
|
|
144
|
+
* Remove cache
|
|
145
|
+
* @param id Notification id
|
|
146
|
+
*/
|
|
147
|
+
removeCache(id: string): void;
|
|
142
148
|
}
|
|
143
149
|
export {};
|
|
@@ -18,6 +18,8 @@ export class NotifierReact extends NotificationContainer {
|
|
|
18
18
|
static get instance() {
|
|
19
19
|
return NotifierReact._instance;
|
|
20
20
|
}
|
|
21
|
+
// Cache
|
|
22
|
+
static _cache = {};
|
|
21
23
|
/**
|
|
22
24
|
* Update notifier
|
|
23
25
|
* @param notifier Notifier
|
|
@@ -59,7 +61,18 @@ export class NotifierReact extends NotificationContainer {
|
|
|
59
61
|
// Notifications under the align
|
|
60
62
|
const notifications = state[align];
|
|
61
63
|
// UI collections
|
|
62
|
-
const ui = notifications.map((notification) =>
|
|
64
|
+
const ui = notifications.map((notification) => {
|
|
65
|
+
// Id
|
|
66
|
+
const id = notification.id;
|
|
67
|
+
// Try cache
|
|
68
|
+
const cache = NotifierReact._cache[id];
|
|
69
|
+
if (cache)
|
|
70
|
+
return cache;
|
|
71
|
+
const element = notification.render(props, className ? className + "-item" : className);
|
|
72
|
+
// Cache the element
|
|
73
|
+
NotifierReact._cache[id] = element;
|
|
74
|
+
return element;
|
|
75
|
+
});
|
|
63
76
|
// Add to the collection
|
|
64
77
|
aligns.push(this.createContainer(Number(align), ui));
|
|
65
78
|
}
|
|
@@ -77,4 +90,11 @@ export class NotifierReact extends NotificationContainer {
|
|
|
77
90
|
}, this.notifications, {}, creator);
|
|
78
91
|
return provider;
|
|
79
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Remove cache
|
|
95
|
+
* @param id Notification id
|
|
96
|
+
*/
|
|
97
|
+
removeCache(id) {
|
|
98
|
+
delete NotifierReact._cache[id];
|
|
99
|
+
}
|
|
80
100
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.86",
|
|
4
4
|
"description": "TypeScript ReactJs UI Independent Framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@emotion/css": "^11.13.5",
|
|
39
39
|
"@emotion/react": "^11.14.0",
|
|
40
40
|
"@emotion/styled": "^11.14.1",
|
|
41
|
-
"@etsoo/appscript": "^1.6.
|
|
42
|
-
"@etsoo/notificationbase": "^1.1.
|
|
41
|
+
"@etsoo/appscript": "^1.6.62",
|
|
42
|
+
"@etsoo/notificationbase": "^1.1.70",
|
|
43
43
|
"@etsoo/shared": "^1.2.83",
|
|
44
44
|
"react": "^19.2.5",
|
|
45
45
|
"react-dom": "^19.2.5",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@types/react-dom": "^19.2.3",
|
|
58
58
|
"@vitejs/plugin-react": "^6.0.1",
|
|
59
59
|
"jsdom": "^29.0.2",
|
|
60
|
-
"typescript": "^6.0.
|
|
60
|
+
"typescript": "^6.0.3",
|
|
61
61
|
"vitest": "^4.1.4"
|
|
62
62
|
}
|
|
63
63
|
}
|
package/src/notifier/Notifier.ts
CHANGED
|
@@ -93,17 +93,23 @@ export interface NotificationReactCallProps extends NotificationCallProps {
|
|
|
93
93
|
/**
|
|
94
94
|
* React notification interface
|
|
95
95
|
*/
|
|
96
|
-
export interface INotificationReact
|
|
97
|
-
|
|
96
|
+
export interface INotificationReact extends INotification<
|
|
97
|
+
React.ReactNode,
|
|
98
|
+
NotificationReactCallProps
|
|
99
|
+
> {}
|
|
98
100
|
|
|
99
101
|
/**
|
|
100
102
|
* React notification base interface
|
|
101
103
|
*/
|
|
102
|
-
export interface INotificationBaseReact
|
|
103
|
-
|
|
104
|
+
export interface INotificationBaseReact extends INotificaseBase<
|
|
105
|
+
React.ReactNode,
|
|
106
|
+
NotificationReactCallProps
|
|
107
|
+
> {}
|
|
104
108
|
|
|
105
|
-
interface ReactNotifications
|
|
106
|
-
|
|
109
|
+
interface ReactNotifications extends NotificationDictionary<
|
|
110
|
+
React.ReactNode,
|
|
111
|
+
NotificationReactCallProps
|
|
112
|
+
> {}
|
|
107
113
|
|
|
108
114
|
/**
|
|
109
115
|
* Action to manage the notifier
|
|
@@ -131,14 +137,15 @@ export abstract class NotificationReact
|
|
|
131
137
|
* React notification render props
|
|
132
138
|
*/
|
|
133
139
|
export interface NotificationReactRenderProps
|
|
134
|
-
extends NotificationRenderProps,
|
|
135
|
-
IProviderProps<INotifierAction> {}
|
|
140
|
+
extends NotificationRenderProps, IProviderProps<INotifierAction> {}
|
|
136
141
|
|
|
137
142
|
/**
|
|
138
143
|
* Notifier interface
|
|
139
144
|
*/
|
|
140
|
-
export interface INotifierReact
|
|
141
|
-
|
|
145
|
+
export interface INotifierReact extends INotifier<
|
|
146
|
+
React.ReactNode,
|
|
147
|
+
NotificationReactCallProps
|
|
148
|
+
> {
|
|
142
149
|
/**
|
|
143
150
|
* Create state provider
|
|
144
151
|
* @param className Style class name
|
|
@@ -168,6 +175,9 @@ export abstract class NotifierReact
|
|
|
168
175
|
return NotifierReact._instance;
|
|
169
176
|
}
|
|
170
177
|
|
|
178
|
+
// Cache
|
|
179
|
+
private static _cache: Record<string, React.ReactNode | null> = {};
|
|
180
|
+
|
|
171
181
|
/**
|
|
172
182
|
* Update notifier
|
|
173
183
|
* @param notifier Notifier
|
|
@@ -234,12 +244,24 @@ export abstract class NotifierReact
|
|
|
234
244
|
const notifications = state[align];
|
|
235
245
|
|
|
236
246
|
// UI collections
|
|
237
|
-
const ui = notifications.map((notification) =>
|
|
238
|
-
|
|
247
|
+
const ui = notifications.map((notification) => {
|
|
248
|
+
// Id
|
|
249
|
+
const id = notification.id;
|
|
250
|
+
|
|
251
|
+
// Try cache
|
|
252
|
+
const cache = NotifierReact._cache[id];
|
|
253
|
+
if (cache) return cache;
|
|
254
|
+
|
|
255
|
+
const element = notification.render(
|
|
239
256
|
props,
|
|
240
257
|
className ? className + "-item" : className
|
|
241
|
-
)
|
|
242
|
-
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
// Cache the element
|
|
261
|
+
NotifierReact._cache[id] = element;
|
|
262
|
+
|
|
263
|
+
return element;
|
|
264
|
+
});
|
|
243
265
|
|
|
244
266
|
// Add to the collection
|
|
245
267
|
aligns.push(this.createContainer(Number(align), ui));
|
|
@@ -276,4 +298,12 @@ export abstract class NotifierReact
|
|
|
276
298
|
|
|
277
299
|
return provider;
|
|
278
300
|
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Remove cache
|
|
304
|
+
* @param id Notification id
|
|
305
|
+
*/
|
|
306
|
+
override removeCache(id: string): void {
|
|
307
|
+
delete NotifierReact._cache[id];
|
|
308
|
+
}
|
|
279
309
|
}
|