@teambit/notifications 1.0.1066 → 1.0.1067
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.
|
@@ -10,6 +10,11 @@ export default class NotificationUI implements NotificationsStore {
|
|
|
10
10
|
static provider([uiRuntimeExtension]: [UiUI]): Promise<NotificationUI>;
|
|
11
11
|
constructor(uiRuntimeExtension: UiUI);
|
|
12
12
|
private dispatch?;
|
|
13
|
+
/**
|
|
14
|
+
* when the workspace ui runs in minimal mode, no notification should reach the screen,
|
|
15
|
+
* no matter which aspect (or external hook, e.g. `useDataQuery`) produced it.
|
|
16
|
+
*/
|
|
17
|
+
private isMinimal;
|
|
13
18
|
/** adds a full message to the log */
|
|
14
19
|
add: (message: string, level: MessageLevel) => string;
|
|
15
20
|
/** removes/archives a message from the log */
|
|
@@ -39,6 +39,13 @@ function _uiFoundationUiNotifications2() {
|
|
|
39
39
|
};
|
|
40
40
|
return data;
|
|
41
41
|
}
|
|
42
|
+
function _reactRouterDom() {
|
|
43
|
+
const data = require("react-router-dom");
|
|
44
|
+
_reactRouterDom = function () {
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
42
49
|
function _uiFoundationUiNotifications3() {
|
|
43
50
|
const data = require("@teambit/ui-foundation.ui.notifications.store");
|
|
44
51
|
_uiFoundationUiNotifications3 = function () {
|
|
@@ -74,8 +81,14 @@ class NotificationUI {
|
|
|
74
81
|
}
|
|
75
82
|
constructor(uiRuntimeExtension) {
|
|
76
83
|
_defineProperty(this, "dispatch", void 0);
|
|
84
|
+
/**
|
|
85
|
+
* when the workspace ui runs in minimal mode, no notification should reach the screen,
|
|
86
|
+
* no matter which aspect (or external hook, e.g. `useDataQuery`) produced it.
|
|
87
|
+
*/
|
|
88
|
+
_defineProperty(this, "isMinimal", false);
|
|
77
89
|
/** adds a full message to the log */
|
|
78
90
|
_defineProperty(this, "add", (message, level) => {
|
|
91
|
+
if (this.isMinimal) return '';
|
|
79
92
|
const id = (0, _uuid().v1)();
|
|
80
93
|
this.dispatch?.({
|
|
81
94
|
type: 'add',
|
|
@@ -105,7 +118,19 @@ class NotificationUI {
|
|
|
105
118
|
_defineProperty(this, "render", props => {
|
|
106
119
|
// this code assumes a single place of render per instance of NotificationUI
|
|
107
120
|
const [messages, dispatch] = (0, _react().useReducer)(_notificationReducer().notificationReducer, []);
|
|
121
|
+
const [searchParams] = (0, _reactRouterDom().useSearchParams)();
|
|
122
|
+
const isMinimal = searchParams.get('minimal-mode') === 'true';
|
|
108
123
|
this.dispatch = dispatch;
|
|
124
|
+
this.isMinimal = isMinimal;
|
|
125
|
+
|
|
126
|
+
// drop any queued messages when entering minimal mode, so toggling minimal
|
|
127
|
+
// mode back off later doesn't resurrect stale notifications.
|
|
128
|
+
(0, _react().useEffect)(() => {
|
|
129
|
+
if (isMinimal) dispatch({
|
|
130
|
+
type: 'clear'
|
|
131
|
+
});
|
|
132
|
+
}, [isMinimal]);
|
|
133
|
+
if (isMinimal) return null;
|
|
109
134
|
return /*#__PURE__*/_react().default.createElement(_uiFoundationUiNotifications2().NotificationCenter, _extends({}, props, {
|
|
110
135
|
notifications: messages
|
|
111
136
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ui","data","require","_react","_interopRequireWildcard","_uuid","_uiFoundationUiNotifications","_uiFoundationUiNotifications2","_uiFoundationUiNotifications3","_notificationReducer","_notifications","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","NotificationUI","provider","uiRuntimeExtension","constructor","message","level","id","v1","dispatch","type","content","time","Date","toISOString","add","MessageLevel","info","warning","error","success","props","messages","useReducer","notificationReducer","createElement","NotificationCenter","notifications","children","NotificationContext","Provider","registerHudItem","render","key","registerRenderHooks","reactContext","renderContext","dismiss","exports","UIAspect","UIRuntime","NotificationsAspect","addRuntime"],"sources":["notification.ui.runtime.tsx"],"sourcesContent":["import type { UiUI } from '@teambit/ui';\nimport { UIAspect, UIRuntime } from '@teambit/ui';\nimport type { ReactNode } from 'react';\nimport React, { useReducer } from 'react';\nimport { v1 } from 'uuid';\n\nimport { NotificationContext } from '@teambit/ui-foundation.ui.notifications.notification-context';\nimport type { NotificationCenterProps } from '@teambit/ui-foundation.ui.notifications.notification-center';\nimport { NotificationCenter } from '@teambit/ui-foundation.ui.notifications.notification-center';\nimport type { NotificationsStore } from '@teambit/ui-foundation.ui.notifications.store';\nimport { MessageLevel } from '@teambit/ui-foundation.ui.notifications.store';\nimport type { NotificationAction } from './notification-reducer';\nimport { notificationReducer } from './notification-reducer';\nimport { NotificationsAspect } from './notifications.aspect';\n\n/**\n * extension\n */\nexport default class NotificationUI implements NotificationsStore {\n static dependencies = [UIAspect];\n\n static runtime = UIRuntime;\n\n static async provider([uiRuntimeExtension]: [UiUI]) {\n return new NotificationUI(uiRuntimeExtension);\n }\n\n constructor(uiRuntimeExtension: UiUI) {\n uiRuntimeExtension.registerHudItem(<this.render key=\"NotificationUI\" />);\n uiRuntimeExtension.registerRenderHooks({ reactContext: this.renderContext });\n }\n\n private dispatch?: React.Dispatch<NotificationAction>;\n\n /** adds a full message to the log */\n add = (message: string, level: MessageLevel) => {\n const id = v1();\n\n this.dispatch?.({\n type: 'add',\n content: {\n id,\n message,\n level,\n time: new Date().toISOString(),\n },\n });\n\n return id;\n };\n\n /** removes/archives a message from the log */\n dismiss(id: string) {\n this.dispatch?.({\n type: 'dismiss',\n id,\n });\n }\n\n /** adds a message with level \"info\" to the log */\n log = (message: string) => this.add(message, MessageLevel.info);\n /** adds a message with level \"warning\" to the log */\n warn = (message: string) => this.add(message, MessageLevel.warning);\n /** adds a message with level \"error\" to the log */\n error = (message: string) => this.add(message, MessageLevel.error);\n /** adds a message with level \"success\" to the log */\n success = (message: string) => this.add(message, MessageLevel.success);\n\n /** removes all notifications */\n clear = () => {\n this.dispatch?.({\n type: 'clear',\n });\n };\n\n private render = (props: Omit<NotificationCenterProps, 'notifications'>) => {\n // this code assumes a single place of render per instance of NotificationUI\n const [messages, dispatch] = useReducer(notificationReducer, []);\n this.dispatch = dispatch;\n\n return <NotificationCenter {...props} notifications={messages} />;\n };\n\n private renderContext = ({ children }: { children: ReactNode }) => {\n return <NotificationContext.Provider value={this}>{children}</NotificationContext.Provider>;\n };\n}\n\nNotificationsAspect.addRuntime(NotificationUI);\n"],"mappings":";;;;;;AACA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAG,uBAAA,CAAAF,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,6BAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,4BAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,8BAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,6BAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,8BAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,6BAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAQ,qBAAA;EAAA,MAAAR,IAAA,GAAAC,OAAA;EAAAO,oBAAA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,wBAEuB,CAAC;MAAEuC;IAAkC,CAAC,KAAK;MACjE,oBAAOxE,MAAA,GAAAkB,OAAA,CAAAmD,aAAA,CAAClE,4BAAA,GAAAsE,mBAAmB,CAACC,QAAQ;QAACvC,KAAK,EAAE;MAAK,GAAEqC,QAAuC,CAAC;IAC7F,CAAC;IAzDCzB,kBAAkB,CAAC4B,eAAe,cAAC3E,MAAA,GAAAkB,OAAA,CAAAmD,aAAA,MAAMO,MAAM;MAACC,GAAG,EAAC;IAAgB,CAAE,CAAC,CAAC;IACxE9B,kBAAkB,CAAC+B,mBAAmB,CAAC;MAAEC,YAAY,EAAE,IAAI,CAACC;IAAc,CAAC,CAAC;EAC9E;EAqBA;EACAC,OAAOA,CAAC9B,EAAU,EAAE;IAClB,IAAI,CAACE,QAAQ,GAAG;MACdC,IAAI,EAAE,SAAS;MACfH;IACF,CAAC,CAAC;EACJ;AA6BF;AAAC+B,OAAA,CAAAhE,OAAA,GAAA2B,cAAA;AAAAZ,eAAA,CApEoBY,cAAc,kBACX,CAACsC,cAAQ,CAAC;AAAAlD,eAAA,CADbY,cAAc,aAGhBuC,eAAS;AAmE5BC,oCAAmB,CAACC,UAAU,CAACzC,cAAc,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_ui","data","require","_react","_interopRequireWildcard","_uuid","_uiFoundationUiNotifications","_uiFoundationUiNotifications2","_reactRouterDom","_uiFoundationUiNotifications3","_notificationReducer","_notifications","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","NotificationUI","provider","uiRuntimeExtension","constructor","message","level","isMinimal","id","v1","dispatch","type","content","time","Date","toISOString","add","MessageLevel","info","warning","error","success","props","messages","useReducer","notificationReducer","searchParams","useSearchParams","useEffect","createElement","NotificationCenter","notifications","children","NotificationContext","Provider","registerHudItem","render","key","registerRenderHooks","reactContext","renderContext","dismiss","exports","UIAspect","UIRuntime","NotificationsAspect","addRuntime"],"sources":["notification.ui.runtime.tsx"],"sourcesContent":["import type { UiUI } from '@teambit/ui';\nimport { UIAspect, UIRuntime } from '@teambit/ui';\nimport type { ReactNode } from 'react';\nimport React, { useEffect, useReducer } from 'react';\nimport { v1 } from 'uuid';\n\nimport { NotificationContext } from '@teambit/ui-foundation.ui.notifications.notification-context';\nimport type { NotificationCenterProps } from '@teambit/ui-foundation.ui.notifications.notification-center';\nimport { NotificationCenter } from '@teambit/ui-foundation.ui.notifications.notification-center';\nimport { useSearchParams } from 'react-router-dom';\nimport type { NotificationsStore } from '@teambit/ui-foundation.ui.notifications.store';\nimport { MessageLevel } from '@teambit/ui-foundation.ui.notifications.store';\nimport type { NotificationAction } from './notification-reducer';\nimport { notificationReducer } from './notification-reducer';\nimport { NotificationsAspect } from './notifications.aspect';\n\n/**\n * extension\n */\nexport default class NotificationUI implements NotificationsStore {\n static dependencies = [UIAspect];\n\n static runtime = UIRuntime;\n\n static async provider([uiRuntimeExtension]: [UiUI]) {\n return new NotificationUI(uiRuntimeExtension);\n }\n\n constructor(uiRuntimeExtension: UiUI) {\n uiRuntimeExtension.registerHudItem(<this.render key=\"NotificationUI\" />);\n uiRuntimeExtension.registerRenderHooks({ reactContext: this.renderContext });\n }\n\n private dispatch?: React.Dispatch<NotificationAction>;\n\n /**\n * when the workspace ui runs in minimal mode, no notification should reach the screen,\n * no matter which aspect (or external hook, e.g. `useDataQuery`) produced it.\n */\n private isMinimal = false;\n\n /** adds a full message to the log */\n add = (message: string, level: MessageLevel) => {\n if (this.isMinimal) return '';\n\n const id = v1();\n\n this.dispatch?.({\n type: 'add',\n content: {\n id,\n message,\n level,\n time: new Date().toISOString(),\n },\n });\n\n return id;\n };\n\n /** removes/archives a message from the log */\n dismiss(id: string) {\n this.dispatch?.({\n type: 'dismiss',\n id,\n });\n }\n\n /** adds a message with level \"info\" to the log */\n log = (message: string) => this.add(message, MessageLevel.info);\n /** adds a message with level \"warning\" to the log */\n warn = (message: string) => this.add(message, MessageLevel.warning);\n /** adds a message with level \"error\" to the log */\n error = (message: string) => this.add(message, MessageLevel.error);\n /** adds a message with level \"success\" to the log */\n success = (message: string) => this.add(message, MessageLevel.success);\n\n /** removes all notifications */\n clear = () => {\n this.dispatch?.({\n type: 'clear',\n });\n };\n\n private render = (props: Omit<NotificationCenterProps, 'notifications'>) => {\n // this code assumes a single place of render per instance of NotificationUI\n const [messages, dispatch] = useReducer(notificationReducer, []);\n const [searchParams] = useSearchParams();\n const isMinimal = searchParams.get('minimal-mode') === 'true';\n this.dispatch = dispatch;\n this.isMinimal = isMinimal;\n\n // drop any queued messages when entering minimal mode, so toggling minimal\n // mode back off later doesn't resurrect stale notifications.\n useEffect(() => {\n if (isMinimal) dispatch({ type: 'clear' });\n }, [isMinimal]);\n\n if (isMinimal) return null;\n\n return <NotificationCenter {...props} notifications={messages} />;\n };\n\n private renderContext = ({ children }: { children: ReactNode }) => {\n return <NotificationContext.Provider value={this}>{children}</NotificationContext.Provider>;\n };\n}\n\nNotificationsAspect.addRuntime(NotificationUI);\n"],"mappings":";;;;;;AACA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAG,uBAAA,CAAAF,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,6BAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,4BAAA,YAAAA,CAAA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ChF,MAAA,GAAAmB,OAAA,CAAAuD,aAAA,MAAMO,MAAM;MAACC,GAAG,EAAC;IAAgB,CAAE,CAAC,CAAC;IACxElC,kBAAkB,CAACmC,mBAAmB,CAAC;MAAEC,YAAY,EAAE,IAAI,CAACC;IAAc,CAAC,CAAC;EAC9E;EA6BA;EACAC,OAAOA,CAACjC,EAAU,EAAE;IAClB,IAAI,CAACE,QAAQ,GAAG;MACdC,IAAI,EAAE,SAAS;MACfH;IACF,CAAC,CAAC;EACJ;AAwCF;AAACkC,OAAA,CAAApE,OAAA,GAAA2B,cAAA;AAAAZ,eAAA,CAvFoBY,cAAc,kBACX,CAAC0C,cAAQ,CAAC;AAAAtD,eAAA,CADbY,cAAc,aAGhB2C,eAAS;AAsF5BC,oCAAmB,CAACC,UAAU,CAAC7C,cAAc,CAAC","ignoreList":[]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { UiUI } from '@teambit/ui';
|
|
2
2
|
import { UIAspect, UIRuntime } from '@teambit/ui';
|
|
3
3
|
import type { ReactNode } from 'react';
|
|
4
|
-
import React, { useReducer } from 'react';
|
|
4
|
+
import React, { useEffect, useReducer } from 'react';
|
|
5
5
|
import { v1 } from 'uuid';
|
|
6
6
|
|
|
7
7
|
import { NotificationContext } from '@teambit/ui-foundation.ui.notifications.notification-context';
|
|
8
8
|
import type { NotificationCenterProps } from '@teambit/ui-foundation.ui.notifications.notification-center';
|
|
9
9
|
import { NotificationCenter } from '@teambit/ui-foundation.ui.notifications.notification-center';
|
|
10
|
+
import { useSearchParams } from 'react-router-dom';
|
|
10
11
|
import type { NotificationsStore } from '@teambit/ui-foundation.ui.notifications.store';
|
|
11
12
|
import { MessageLevel } from '@teambit/ui-foundation.ui.notifications.store';
|
|
12
13
|
import type { NotificationAction } from './notification-reducer';
|
|
@@ -32,8 +33,16 @@ export default class NotificationUI implements NotificationsStore {
|
|
|
32
33
|
|
|
33
34
|
private dispatch?: React.Dispatch<NotificationAction>;
|
|
34
35
|
|
|
36
|
+
/**
|
|
37
|
+
* when the workspace ui runs in minimal mode, no notification should reach the screen,
|
|
38
|
+
* no matter which aspect (or external hook, e.g. `useDataQuery`) produced it.
|
|
39
|
+
*/
|
|
40
|
+
private isMinimal = false;
|
|
41
|
+
|
|
35
42
|
/** adds a full message to the log */
|
|
36
43
|
add = (message: string, level: MessageLevel) => {
|
|
44
|
+
if (this.isMinimal) return '';
|
|
45
|
+
|
|
37
46
|
const id = v1();
|
|
38
47
|
|
|
39
48
|
this.dispatch?.({
|
|
@@ -76,7 +85,18 @@ export default class NotificationUI implements NotificationsStore {
|
|
|
76
85
|
private render = (props: Omit<NotificationCenterProps, 'notifications'>) => {
|
|
77
86
|
// this code assumes a single place of render per instance of NotificationUI
|
|
78
87
|
const [messages, dispatch] = useReducer(notificationReducer, []);
|
|
88
|
+
const [searchParams] = useSearchParams();
|
|
89
|
+
const isMinimal = searchParams.get('minimal-mode') === 'true';
|
|
79
90
|
this.dispatch = dispatch;
|
|
91
|
+
this.isMinimal = isMinimal;
|
|
92
|
+
|
|
93
|
+
// drop any queued messages when entering minimal mode, so toggling minimal
|
|
94
|
+
// mode back off later doesn't resurrect stale notifications.
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (isMinimal) dispatch({ type: 'clear' });
|
|
97
|
+
}, [isMinimal]);
|
|
98
|
+
|
|
99
|
+
if (isMinimal) return null;
|
|
80
100
|
|
|
81
101
|
return <NotificationCenter {...props} notifications={messages} />;
|
|
82
102
|
};
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/notifications",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1067",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/ui-foundation/notifications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.ui-foundation",
|
|
8
8
|
"name": "notifications",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.1067"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"uuid": "8.3.2",
|
|
13
13
|
"@teambit/ui-foundation.ui.notifications.store": "0.0.500",
|
|
14
14
|
"@teambit/ui-foundation.ui.notifications.notification-center": "0.0.523",
|
|
15
15
|
"@teambit/ui-foundation.ui.notifications.notification-context": "0.0.501",
|
|
16
|
-
"@teambit/
|
|
17
|
-
"@teambit/
|
|
16
|
+
"@teambit/ui": "1.0.1066",
|
|
17
|
+
"@teambit/harmony": "0.4.12"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/uuid": "8.3.4",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"@teambit/harmony.envs.core-aspect-env": "1.0.2"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
25
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
26
|
+
"react-router-dom": "^6.16.0"
|
|
26
27
|
},
|
|
27
28
|
"license": "Apache-2.0",
|
|
28
29
|
"optionalDependencies": {},
|
|
File without changes
|