@open-pioneer/notifier 3.0.0-dev.20250221111321 → 4.0.0-dev-chakra-3.20250225100939

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/CHANGELOG.md CHANGED
@@ -1,6 +1,43 @@
1
1
  # @open-pioneer/notifier
2
2
 
3
- ## 3.0.0-dev.20250221111321
3
+ ## 4.0.0-dev-chakra-3.20250225100939
4
+
5
+ ### Major Changes
6
+
7
+ - 804d332: **Breaking**: The `position` property has moved from the `<Notifier />` component to package properties.
8
+ In order to change to location of notifications, you need to customize the package properties.
9
+
10
+ Before:
11
+
12
+ ```jsx
13
+ // App.jsx
14
+ <Notifier position="top-right" />
15
+ ```
16
+
17
+ After:
18
+
19
+ ```ts
20
+ // app.ts
21
+ const Element = createCustomElement({
22
+ // ...
23
+ config: {
24
+ properties: {
25
+ "@open-pioneer/notifier": {
26
+ position: "top-right"
27
+ } satisfies NotifierProperties
28
+ }
29
+ }
30
+ // or use resolveConfig()
31
+ });
32
+ ```
33
+
34
+ ### Patch Changes
35
+
36
+ - @open-pioneer/core@4.0.0-dev-chakra-3.20250225100939
37
+ - @open-pioneer/react-utils@4.0.0-dev-chakra-3.20250225100939
38
+ - @open-pioneer/runtime@4.0.0-dev-chakra-3.20250225100939
39
+
40
+ ## 3.0.0
4
41
 
5
42
  ### Major Changes
6
43
 
@@ -17,10 +54,10 @@
17
54
  ### Patch Changes
18
55
 
19
56
  - Updated dependencies [9477e54]
20
- - @open-pioneer/chakra-integration@3.0.0-dev.20250221111321
21
- - @open-pioneer/core@3.0.0-dev.20250221111321
22
- - @open-pioneer/react-utils@3.0.0-dev.20250221111321
23
- - @open-pioneer/runtime@3.0.0-dev.20250221111321
57
+ - @open-pioneer/chakra-integration@3.0.0
58
+ - @open-pioneer/core@3.0.0
59
+ - @open-pioneer/react-utils@3.0.0
60
+ - @open-pioneer/runtime@3.0.0
24
61
 
25
62
  ## 2.4.0
26
63
 
@@ -1,34 +1,22 @@
1
- import type { NotificationLevel, NotificationOptions, NotificationService, SimpleNotificationOptions } from "./api";
1
+ import { CreateToasterReturn } from "@chakra-ui/react";
2
+ import type { NotificationOptions, NotificationService, SimpleNotificationOptions } from "./api";
2
3
  import { Resource } from "@open-pioneer/core";
3
- import type { ReactNode } from "react";
4
- export interface Notification {
5
- title: ReactNode;
6
- message: ReactNode;
7
- level: NotificationLevel;
8
- displayDuration: number | undefined;
9
- }
10
- /**
11
- * The notification handler is implemented by the UI in order to receive events.
12
- * There can only be one handler at a time.
13
- *
14
- * Calls to the handler may be buffered to allow for notifications before the UI has become ready.
15
- */
16
- export interface NotificationHandler {
17
- /** Called by the service to emit the notification. */
18
- showNotification(notification: Notification): void;
19
- /** Removes all active notifications. */
20
- closeAll(): void;
4
+ import { ApplicationContext, ServiceOptions } from "@open-pioneer/runtime";
5
+ export type ToasterObject = CreateToasterReturn;
6
+ export interface ToastMeta {
7
+ closable: boolean;
21
8
  }
22
9
  export interface InternalNotificationAPI extends NotificationService {
23
- /**
24
- * Registers the notification handler.
25
- * The returned resource can be used to unregister it again.
26
- */
27
- registerHandler(handler: NotificationHandler): Resource;
10
+ readonly toaster: ToasterObject;
11
+ registerUI(): Resource | undefined;
12
+ }
13
+ interface References {
14
+ appCtx: ApplicationContext;
28
15
  }
29
16
  export declare class NotificationServiceImpl implements InternalNotificationAPI {
30
17
  #private;
31
- constructor();
18
+ readonly toaster: ToasterObject;
19
+ constructor({ references: { appCtx }, properties }: ServiceOptions<References>);
32
20
  destroy(): void;
33
21
  notify(options: NotificationOptions): void;
34
22
  success(options: SimpleNotificationOptions): void;
@@ -36,5 +24,6 @@ export declare class NotificationServiceImpl implements InternalNotificationAPI
36
24
  warning(options: SimpleNotificationOptions): void;
37
25
  error(options: SimpleNotificationOptions): void;
38
26
  closeAll(): void;
39
- registerHandler(handler: NotificationHandler): Resource;
27
+ registerUI(): Resource | undefined;
40
28
  }
29
+ export {};
@@ -1,29 +1,46 @@
1
+ import { createToaster } from '@chakra-ui/react';
1
2
  import { createLogger } from '@open-pioneer/core';
2
3
 
3
4
  const LOG = createLogger("notifier:NotificationService");
5
+ const PERSISTENT_TIMEOUT = 7 * 24 * 60 * 60 * 1e3;
4
6
  class NotificationServiceImpl {
5
- #handler;
6
- #buffered;
7
- #checkTimeoutId;
7
+ #uiPresent = false;
8
+ #uiCheckTimeoutId;
8
9
  // eslint-disable-line @typescript-eslint/no-explicit-any
9
- constructor() {
10
+ toaster;
11
+ constructor({ references: { appCtx }, properties }) {
12
+ const typedProperties = properties;
13
+ const rootNode = appCtx.getShadowRoot();
14
+ this.toaster = createToaster({
15
+ placement: getPlacement(typedProperties.position),
16
+ pauseOnPageIdle: true,
17
+ // Needed for `.getElementById()` queries
18
+ getRootNode: () => rootNode
19
+ });
10
20
  if (import.meta.env.DEV) {
11
- this.#checkTimeoutId = setTimeout(() => {
12
- this.#checkHandlerRegistration();
13
- this.#checkTimeoutId = void 0;
21
+ this.#uiCheckTimeoutId = setTimeout(() => {
22
+ this.#checkUiNotification();
23
+ this.#uiCheckTimeoutId = void 0;
14
24
  }, 5e3);
15
25
  }
16
26
  }
17
27
  destroy() {
18
- clearTimeout(this.#checkTimeoutId);
19
- this.#checkTimeoutId = void 0;
28
+ clearTimeout(this.#uiCheckTimeoutId);
29
+ this.#uiCheckTimeoutId = void 0;
20
30
  }
21
31
  notify(options) {
22
- this.#dispatchHandlerMethod("showNotification", {
23
- title: options.title ?? void 0,
24
- message: options.message ?? void 0,
25
- level: options.level ?? "info",
26
- displayDuration: options.displayDuration
32
+ this.toaster.create({
33
+ type: options.level,
34
+ title: options.title,
35
+ description: options.message,
36
+ // Chakra currently has no concept of persistent toasts (other than type "loading"),
37
+ // so we just use a very long timeout instead.
38
+ // Note: MAX_VALUE or Infinity does not work either (probably too big for some computations made internally).
39
+ duration: options.displayDuration ?? PERSISTENT_TIMEOUT,
40
+ // Additional data for the toast (can be arbitrary)
41
+ meta: {
42
+ closable: true
43
+ }
27
44
  });
28
45
  }
29
46
  success(options) {
@@ -45,27 +62,16 @@ class NotificationServiceImpl {
45
62
  this.notify({ ...options, level });
46
63
  }
47
64
  closeAll() {
48
- this.#dispatchHandlerMethod("closeAll");
65
+ this.toaster.dismiss();
49
66
  }
50
- registerHandler(handler) {
51
- if (this.#handler) {
67
+ registerUI() {
68
+ if (this.#uiPresent) {
52
69
  LOG.warn(
53
- "A notification handler has already been registered; this new handler will be ignored.\nThe <Notifier /> component has likely been used twice in your application."
70
+ "A notifier UI has already been registered; this new component will be ignored.\nThe <Notifier /> component has likely been used twice in your application."
54
71
  );
55
- return {
56
- destroy() {
57
- return void 0;
58
- }
59
- };
60
- }
61
- this.#handler = handler;
62
- const buffered = this.#buffered;
63
- this.#buffered = void 0;
64
- if (buffered) {
65
- for (const [name, ...args] of buffered) {
66
- handler[name](...args);
67
- }
72
+ return void 0;
68
73
  }
74
+ this.#uiPresent = true;
69
75
  let destroyed = false;
70
76
  return {
71
77
  destroy: () => {
@@ -73,36 +79,37 @@ class NotificationServiceImpl {
73
79
  return;
74
80
  }
75
81
  destroyed = true;
76
- if (this.#handler === handler) {
77
- this.#handler = void 0;
78
- }
82
+ this.#uiPresent = false;
79
83
  }
80
84
  };
81
85
  }
82
- #dispatchHandlerMethod(method, ...args) {
83
- if (this.#handler) {
84
- this.#handler[method](...args);
85
- } else {
86
- const buffered = this.#buffered ??= [];
87
- if (buffered.length >= 1024) {
88
- LOG.error(
89
- "Internal notification buffer overflow: this event will be dropped to prevent a memory leak.\nMake sure that the UI is configured to display notifications (use <Notifier />).",
90
- { method, args }
91
- );
92
- return;
93
- }
94
- buffered.push([method, ...args]);
95
- }
96
- }
97
- #checkHandlerRegistration() {
98
- if (!this.#handler) {
86
+ #checkUiNotification() {
87
+ if (!this.#uiPresent) {
99
88
  LOG.warn(
100
- `No notification handler has been registered: notifications will not be visible.
89
+ `No notifier UI has been registered: notifications will not be visible.
101
90
  Make sure that your app contains the <Notifier /> component.`
102
91
  );
103
92
  }
104
93
  }
105
94
  }
95
+ function getPlacement(configPosition = "top-right") {
96
+ switch (configPosition) {
97
+ case "top":
98
+ return "top";
99
+ case "top-left":
100
+ return "top-start";
101
+ case "top-right":
102
+ return "top-end";
103
+ case "bottom":
104
+ return "bottom";
105
+ case "bottom-left":
106
+ return "bottom-start";
107
+ case "bottom-right":
108
+ return "bottom-end";
109
+ default:
110
+ return "top-end";
111
+ }
112
+ }
106
113
 
107
114
  export { NotificationServiceImpl };
108
115
  //# sourceMappingURL=NotificationServiceImpl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationServiceImpl.js","sources":["NotificationServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type {\n NotificationLevel,\n NotificationOptions,\n NotificationService,\n SimpleNotificationOptions\n} from \"./api\";\nimport { Resource, createLogger } from \"@open-pioneer/core\";\nimport type { ReactNode } from \"react\";\nconst LOG = createLogger(\"notifier:NotificationService\");\n\nexport interface Notification {\n title: ReactNode;\n message: ReactNode;\n level: NotificationLevel;\n displayDuration: number | undefined;\n}\n\n/**\n * The notification handler is implemented by the UI in order to receive events.\n * There can only be one handler at a time.\n *\n * Calls to the handler may be buffered to allow for notifications before the UI has become ready.\n */\nexport interface NotificationHandler {\n /** Called by the service to emit the notification. */\n showNotification(notification: Notification): void;\n\n /** Removes all active notifications. */\n closeAll(): void;\n}\n\nexport interface InternalNotificationAPI extends NotificationService {\n /**\n * Registers the notification handler.\n * The returned resource can be used to unregister it again.\n */\n registerHandler(handler: NotificationHandler): Resource;\n}\n\nexport class NotificationServiceImpl implements InternalNotificationAPI {\n #handler: NotificationHandler | undefined;\n #buffered: [keyof NotificationHandler, ...unknown[]][] | undefined;\n #checkTimeoutId: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n constructor() {\n if (import.meta.env.DEV) {\n this.#checkTimeoutId = setTimeout(() => {\n this.#checkHandlerRegistration();\n this.#checkTimeoutId = undefined;\n }, 5000);\n }\n }\n\n destroy() {\n clearTimeout(this.#checkTimeoutId);\n this.#checkTimeoutId = undefined;\n }\n\n notify(options: NotificationOptions): void {\n this.#dispatchHandlerMethod(\"showNotification\", {\n title: options.title ?? undefined,\n message: options.message ?? undefined,\n level: options.level ?? \"info\",\n displayDuration: options.displayDuration\n });\n }\n\n success(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"success\", options);\n }\n\n info(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"info\", options);\n }\n\n warning(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"warning\", options);\n }\n\n error(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"error\", options);\n }\n\n #sendSimpleNotification(level: NotificationLevel, options: SimpleNotificationOptions): void {\n if (typeof options === \"string\") {\n options = { message: options };\n }\n this.notify({ ...options, level });\n }\n\n closeAll(): void {\n this.#dispatchHandlerMethod(\"closeAll\");\n }\n\n registerHandler(handler: NotificationHandler): Resource {\n // We only support exactly one handler.\n if (this.#handler) {\n LOG.warn(\n \"A notification handler has already been registered; this new handler will be ignored.\\n\" +\n \"The <Notifier /> component has likely been used twice in your application.\"\n );\n return {\n destroy() {\n return undefined;\n }\n };\n }\n\n // Dispatch buffered calls (if any).\n // These happened during the time no handler was registered.\n this.#handler = handler;\n const buffered = this.#buffered;\n this.#buffered = undefined;\n if (buffered) {\n for (const [name, ...args] of buffered) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (handler[name] as any)(...args);\n }\n }\n\n // Return a resource to undo the registration\n let destroyed = false;\n return {\n destroy: () => {\n if (destroyed) {\n return;\n }\n\n destroyed = true;\n if (this.#handler === handler) {\n this.#handler = undefined;\n }\n }\n };\n }\n\n /**\n * Calls a method on the handler (if present) or buffers the method call for later once the handler\n * has arrived.\n */\n #dispatchHandlerMethod<Method extends keyof NotificationHandler>(\n method: Method,\n ...args: Parameters<NotificationHandler[Method]>\n ): void;\n #dispatchHandlerMethod(method: keyof NotificationHandler, ...args: unknown[]): void {\n if (this.#handler) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this.#handler[method] as any)(...args);\n } else {\n const buffered = (this.#buffered ??= []);\n if (buffered.length >= 1024) {\n LOG.error(\n \"Internal notification buffer overflow: this event will be dropped to prevent a memory leak.\\n\" +\n \"Make sure that the UI is configured to display notifications (use <Notifier />).\",\n { method, args }\n );\n return;\n }\n buffered.push([method, ...args]);\n }\n }\n\n #checkHandlerRegistration() {\n if (!this.#handler) {\n LOG.warn(\n `No notification handler has been registered: notifications will not be visible.\\n` +\n `Make sure that your app contains the <Notifier /> component.`\n );\n }\n }\n}\n"],"names":[],"mappings":";;AAUA,MAAM,GAAA,GAAM,aAAa,8BAA8B,CAAA;AA+BhD,MAAM,uBAA2D,CAAA;AAAA,EACpE,QAAA;AAAA,EACA,SAAA;AAAA,EACA,eAAA;AAAA;AAAA,EAEA,WAAc,GAAA;AACV,IAAI,IAAA,MAAA,CAAA,IAAA,CAAY,IAAI,GAAK,EAAA;AACrB,MAAK,IAAA,CAAA,eAAA,GAAkB,WAAW,MAAM;AACpC,QAAA,IAAA,CAAK,yBAA0B,EAAA;AAC/B,QAAA,IAAA,CAAK,eAAkB,GAAA,MAAA;AAAA,SACxB,GAAI,CAAA;AAAA;AACX;AACJ,EAEA,OAAU,GAAA;AACN,IAAA,YAAA,CAAa,KAAK,eAAe,CAAA;AACjC,IAAA,IAAA,CAAK,eAAkB,GAAA,MAAA;AAAA;AAC3B,EAEA,OAAO,OAAoC,EAAA;AACvC,IAAA,IAAA,CAAK,uBAAuB,kBAAoB,EAAA;AAAA,MAC5C,KAAA,EAAO,QAAQ,KAAS,IAAA,MAAA;AAAA,MACxB,OAAA,EAAS,QAAQ,OAAW,IAAA,MAAA;AAAA,MAC5B,KAAA,EAAO,QAAQ,KAAS,IAAA,MAAA;AAAA,MACxB,iBAAiB,OAAQ,CAAA;AAAA,KAC5B,CAAA;AAAA;AACL,EAEA,QA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OAAA;AAAA,MACH,SAAS,MAAM;AACX,QAAA,IAAI,SAAW,EAAA;AACX,UAAA;AAAA;AAGJ,QAAY,SAAA,GAAA,IAAA;AACZ,QAAI,IAAA,IAAA,CAAK,aAAa,OAAS,EAAA;AAC3B,UAAA,IAAA,CAAK,QAAW,GAAA,MAAA;AAAA;AACpB;AACJ,KACJ;AAAA;AACJ,EAUA,sBAAA,CAAuB,WAAsC,IAAuB,EAAA;AAChF,IAAA,IAAI,KAAK,QAAU,EAAA;AAEf,MAAC,IAAK,CAAA,QAAA,CAAS,MAAM,CAAA,CAAU,GAAG,IAAI,CAAA;AAAA,KACnC,MAAA;AACH,MAAM,MAAA,QAAA,GAAY,IAAK,CAAA,SAAA,KAAc,EAAC;AACtC,MAAI,IAAA,QAAA,CAAS,UAAU,IAAM,EAAA;AACzB,QAAI,GAAA,CAAA,KAAA;AAAA,UACA,+KAAA;AAAA,UAEA,EAAE,QAAQ,IAAK;AAAA,SACnB;AACA,QAAA;AAAA;AAEJ,MAAA,QAAA,CAAS,IAAK,CAAA,CAAC,MAAQ,EAAA,GAAG,IAAI,CAAC,CAAA;AAAA;AACnC;AACJ,EAEA,yBAA4B,GAAA;AACxB,IAAI,IAAA,CAAC,KAAK,QAAU,EAAA;AAChB,MAAI,GAAA,CAAA,IAAA;AAAA,QACA,CAAA;AAAA,4DAAA;AAAA,OAEJ;AAAA;AACJ;AAER;;;;"}
1
+ {"version":3,"file":"NotificationServiceImpl.js","sources":["NotificationServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createToaster, CreateToasterProps, CreateToasterReturn } from \"@chakra-ui/react\";\nimport type {\n NotificationLevel,\n NotificationOptions,\n NotificationService,\n NotifierProperties,\n SimpleNotificationOptions\n} from \"./api\";\nimport { Resource, createLogger } from \"@open-pioneer/core\";\nimport { ApplicationContext, ServiceOptions } from \"@open-pioneer/runtime\";\nconst LOG = createLogger(\"notifier:NotificationService\");\n\nexport type ToasterObject = CreateToasterReturn;\n\nexport interface ToastMeta {\n closable: boolean;\n}\n\nexport interface InternalNotificationAPI extends NotificationService {\n // Toasts in here carry `ToastMeta` metadata\n readonly toaster: ToasterObject;\n registerUI(): Resource | undefined;\n}\n\ninterface References {\n appCtx: ApplicationContext;\n}\n\n// 7 days\nconst PERSISTENT_TIMEOUT = 7 * 24 * 60 * 60 * 1000;\n\nexport class NotificationServiceImpl implements InternalNotificationAPI {\n #uiPresent = false;\n #uiCheckTimeoutId: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n readonly toaster: ToasterObject;\n\n constructor({ references: { appCtx }, properties }: ServiceOptions<References>) {\n const typedProperties = properties as NotifierProperties;\n\n const rootNode = appCtx.getShadowRoot();\n this.toaster = createToaster({\n placement: getPlacement(typedProperties.position),\n pauseOnPageIdle: true,\n\n // Needed for `.getElementById()` queries\n getRootNode: () => rootNode\n });\n\n if (import.meta.env.DEV) {\n this.#uiCheckTimeoutId = setTimeout(() => {\n this.#checkUiNotification();\n this.#uiCheckTimeoutId = undefined;\n }, 5000);\n }\n }\n\n destroy() {\n clearTimeout(this.#uiCheckTimeoutId);\n this.#uiCheckTimeoutId = undefined;\n }\n\n notify(options: NotificationOptions): void {\n this.toaster.create({\n type: options.level,\n title: options.title,\n description: options.message,\n\n // Chakra currently has no concept of persistent toasts (other than type \"loading\"),\n // so we just use a very long timeout instead.\n // Note: MAX_VALUE or Infinity does not work either (probably too big for some computations made internally).\n duration: options.displayDuration ?? PERSISTENT_TIMEOUT,\n\n // Additional data for the toast (can be arbitrary)\n meta: {\n closable: true\n } satisfies ToastMeta\n });\n }\n\n success(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"success\", options);\n }\n\n info(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"info\", options);\n }\n\n warning(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"warning\", options);\n }\n\n error(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"error\", options);\n }\n\n #sendSimpleNotification(level: NotificationLevel, options: SimpleNotificationOptions): void {\n if (typeof options === \"string\") {\n options = { message: options };\n }\n this.notify({ ...options, level });\n }\n\n closeAll(): void {\n this.toaster.dismiss();\n }\n\n registerUI(): Resource | undefined {\n // We only support exactly one handler.\n if (this.#uiPresent) {\n LOG.warn(\n \"A notifier UI has already been registered; this new component will be ignored.\\n\" +\n \"The <Notifier /> component has likely been used twice in your application.\"\n );\n return undefined;\n }\n\n this.#uiPresent = true;\n let destroyed = false;\n return {\n destroy: () => {\n if (destroyed) {\n return;\n }\n\n destroyed = true;\n this.#uiPresent = false;\n }\n };\n }\n\n #checkUiNotification() {\n if (!this.#uiPresent) {\n LOG.warn(\n `No notifier UI has been registered: notifications will not be visible.\\n` +\n `Make sure that your app contains the <Notifier /> component.`\n );\n }\n }\n}\n\n// Map to chakra placement\nfunction getPlacement(\n configPosition: NotifierProperties[\"position\"] = \"top-right\"\n): CreateToasterProps[\"placement\"] {\n switch (configPosition) {\n case \"top\":\n return \"top\";\n case \"top-left\":\n return \"top-start\";\n case \"top-right\":\n return \"top-end\";\n case \"bottom\":\n return \"bottom\";\n case \"bottom-left\":\n return \"bottom-start\";\n case \"bottom-right\":\n return \"bottom-end\";\n default:\n return \"top-end\";\n }\n}\n"],"names":[],"mappings":";;;AAYA,MAAM,GAAA,GAAM,aAAa,8BAA8B,CAAA;AAmBvD,MAAM,kBAAqB,GAAA,CAAA,GAAI,EAAK,GAAA,EAAA,GAAK,EAAK,GAAA,GAAA;AAEvC,MAAM,uBAA2D,CAAA;AAAA,EACpE,UAAa,GAAA,KAAA;AAAA,EACb,iBAAA;AAAA;AAAA,EAES,OAAA;AAAA,EAET,YAAY,EAAE,UAAA,EAAY,EAAE,MAAO,EAAA,EAAG,YAA0C,EAAA;AAC5E,IAAA,MAAM,eAAkB,GAAA,UAAA;AAExB,IAAM,MAAA,QAAA,GAAW,OAAO,aAAc,EAAA;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A;AAAA,IACX;AACI,MAAO,OAAA,SAAA;AAAA;AAEnB;;;;"}
package/Notifier.d.ts CHANGED
@@ -1,12 +1,5 @@
1
- import { ReactElement } from "react";
2
1
  /** Props supported by the {@link Notifier} component. */
3
2
  export interface NotifierProps {
4
- /**
5
- * The position for new notifications.
6
- *
7
- * @default "top-right"
8
- */
9
- position?: "top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right";
10
3
  }
11
4
  /**
12
5
  * Shows notifications sent via the `NotificationService`.
@@ -20,11 +13,11 @@ export interface NotifierProps {
20
13
  * export function AppUI() {
21
14
  * return (
22
15
  * <>
23
- * <Notifier position="top-right" />
16
+ * <Notifier />
24
17
  * <h1>Your application</h1>
25
18
  * </>
26
19
  * );
27
20
  * }
28
21
  * ```
29
22
  */
30
- export declare function Notifier(props: NotifierProps): ReactElement;
23
+ export declare function Notifier(_props: NotifierProps): false | import("react/jsx-runtime").JSX.Element;
package/Notifier.js CHANGED
@@ -1,44 +1,68 @@
1
- import { jsx, Fragment } from 'react/jsx-runtime';
2
- import { useToast } from '@open-pioneer/chakra-integration';
3
- import { useEvent } from '@open-pioneer/react-utils';
4
- import { useService } from './_virtual/_virtual-pioneer-module_react-hooks.js';
5
- import { useState, useEffect } from 'react';
6
- import { WarningTwoIcon } from '@chakra-ui/icons';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { Portal, Toaster as Toaster$1, Toast, Spinner, Stack, useToastStyles, Icon } from '@chakra-ui/react';
3
+ import { useIntl, useService } from './_virtual/_virtual-pioneer-module_react-hooks.js';
4
+ import { memo, useState, useEffect } from 'react';
5
+ import { FiAlertTriangle, FiAlertCircle, FiCheckCircle, FiInfo } from 'react-icons/fi';
7
6
 
8
- const isDev = import.meta.env.DEV;
9
- function Notifier(props) {
10
- const { position = "top-right" } = props;
11
- const toast = useToast();
12
- const notifications = useService("notifier.NotificationService");
13
- const [ready, setReady] = useState(!isDev);
14
- const showNotification = useEvent((notification) => {
15
- const icon = notification.level === "error" ? /* @__PURE__ */ jsx(WarningTwoIcon, { h: "100%", w: "100%" }) : void 0;
16
- toast({
17
- position,
18
- title: notification.title,
19
- description: notification.message || null,
20
- status: notification.level,
21
- isClosable: true,
22
- duration: notification.displayDuration ?? null,
23
- // Null: does not auto-close
24
- icon
25
- });
26
- });
27
- const closeAll = useEvent(() => {
28
- toast.closeAll();
29
- });
7
+ function Notifier(_props) {
8
+ const notificationService = useService(
9
+ "notifier.NotificationService"
10
+ );
11
+ const [active, setActive] = useState(false);
30
12
  useEffect(() => {
31
- if (isDev && !ready) {
32
- const id = setTimeout(() => setReady(true), 100);
33
- return () => clearTimeout(id);
13
+ const handle = notificationService.registerUI();
14
+ if (!handle) {
15
+ return;
34
16
  }
35
- const handle = notifications.registerHandler({
36
- showNotification,
37
- closeAll
38
- });
39
- return () => handle.destroy();
40
- }, [ready, notifications, showNotification, closeAll]);
41
- return /* @__PURE__ */ jsx(Fragment, {});
17
+ setActive(true);
18
+ return () => {
19
+ setActive(false);
20
+ handle.destroy();
21
+ };
22
+ }, [notificationService]);
23
+ return active && /* @__PURE__ */ jsx(Toaster, { toaster: notificationService.toaster });
24
+ }
25
+ const Toaster = memo(function Toaster2(props) {
26
+ const intl = useIntl();
27
+ return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(
28
+ Toaster$1,
29
+ {
30
+ toaster: props.toaster,
31
+ insetInline: { mdDown: "4" },
32
+ "aria-label": intl.formatMessage({
33
+ id: "regionLabel"
34
+ }),
35
+ children: (toast) => /* @__PURE__ */ jsxs(Toast.Root, { width: { md: "sm" }, alignItems: "center", children: [
36
+ toast.type === "loading" ? /* @__PURE__ */ jsx(Spinner, { size: "sm", color: "blue.solid" }) : /* @__PURE__ */ jsx(ToastIndicator, { type: toast.type ?? "" }),
37
+ /* @__PURE__ */ jsxs(Stack, { gap: "1", flex: "1", maxWidth: "100%", children: [
38
+ toast.title && /* @__PURE__ */ jsx(Toast.Title, { children: toast.title }),
39
+ toast.description && /* @__PURE__ */ jsx(Toast.Description, { children: toast.description })
40
+ ] }),
41
+ toast.action && /* @__PURE__ */ jsx(Toast.ActionTrigger, { children: toast.action.label }),
42
+ toast.meta?.closable && /* @__PURE__ */ jsx(
43
+ Toast.CloseTrigger,
44
+ {
45
+ cursor: "pointer",
46
+ "aria-label": intl.formatMessage({
47
+ id: "notification.close"
48
+ })
49
+ }
50
+ )
51
+ ] })
52
+ }
53
+ ) });
54
+ });
55
+ const icons = {
56
+ info: FiInfo,
57
+ success: FiCheckCircle,
58
+ warning: FiAlertCircle,
59
+ error: FiAlertTriangle
60
+ };
61
+ function ToastIndicator(props) {
62
+ const styles = useToastStyles();
63
+ const Component = icons[props.type];
64
+ if (!Component) return null;
65
+ return /* @__PURE__ */ jsx(Icon, { css: styles.indicator, children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Component, { style: { width: "100%", height: "100%" } }) }) });
42
66
  }
43
67
 
44
68
  export { Notifier };
package/Notifier.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Notifier.js","sources":["Notifier.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useToast } from \"@open-pioneer/chakra-integration\";\nimport { useEvent } from \"@open-pioneer/react-utils\";\nimport { useService } from \"open-pioneer:react-hooks\";\nimport { ReactElement, useEffect, useState } from \"react\";\nimport { InternalNotificationAPI, Notification } from \"./NotificationServiceImpl\";\nimport { WarningTwoIcon } from \"@chakra-ui/icons\";\n\n/** Props supported by the {@link Notifier} component. */\nexport interface NotifierProps {\n /**\n * The position for new notifications.\n *\n * @default \"top-right\"\n */\n position?: \"top\" | \"top-left\" | \"top-right\" | \"bottom\" | \"bottom-left\" | \"bottom-right\";\n}\n\nconst isDev = import.meta.env.DEV;\n\n/**\n * Shows notifications sent via the `NotificationService`.\n *\n * Only one instance of `<Notifier />` should be present in the application.\n * It currently does not matter where the Notifier is located in the react tree.\n *\n * ```ts\n * import { Notifier } from \"@open-pioneer/notifier\";\n *\n * export function AppUI() {\n * return (\n * <>\n * <Notifier position=\"top-right\" />\n * <h1>Your application</h1>\n * </>\n * );\n * }\n * ```\n */\nexport function Notifier(props: NotifierProps): ReactElement {\n const { position = \"top-right\" } = props;\n const toast = useToast();\n const notifications = useService(\"notifier.NotificationService\") as InternalNotificationAPI;\n const [ready, setReady] = useState(!isDev);\n\n const showNotification = useEvent((notification: Notification) => {\n // use different icons for warning and error\n const icon =\n notification.level === \"error\" ? <WarningTwoIcon h=\"100%\" w=\"100%\" /> : undefined;\n toast({\n position,\n title: notification.title,\n description: notification.message || null,\n status: notification.level,\n isClosable: true,\n duration: notification.displayDuration ?? null, // Null: does not auto-close\n icon\n });\n });\n const closeAll = useEvent(() => {\n toast.closeAll();\n });\n\n useEffect(() => {\n /*\n * Delay registering the notification handler a bit during development.\n * Chakra's toast implementation clears its store when it gets unmounted.\n * During development, that may also happen during initialization because of React's\n * StrictMode (https://react.dev/reference/react/StrictMode).\n *\n * Unfortunately, that means that toasts that were emitted very early (such as in service constructors)\n * will be deleted. Waiting for a few milliseconds prevents this issue and has no effect on production.\n */\n if (isDev && !ready) {\n const id = setTimeout(() => setReady(true), 100);\n return () => clearTimeout(id);\n }\n\n const handle = notifications.registerHandler({\n showNotification,\n closeAll\n });\n return () => handle.destroy();\n }, [ready, notifications, showNotification, closeAll]);\n\n // No actual UI representation right now\n return <></>;\n}\n"],"names":[],"mappings":";;;;;;;AAmBA,MAAM,KAAA,GAAQ,YAAY,GAAI,CAAA,GAAA;AAqBvB,SAAS,SAAS,KAAoC,EAAA;AACzD,EAAM,MAAA,EAAE,QAAW,GAAA,WAAA,EAAgB,GAAA,KAAA;AACnC,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAM,MAAA,aAAA,GAAgB,WAAW,8BAA8B,CAAA;AAC/D,EAAA,MAAM,CAAC,KAAO,EAAA,QAAQ,CAAI,GAAA,QAAA,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n// SPDX-License-Identifier: Apache-2.0\nimport {\n Toaster as ChakraToaster,\n Icon,\n Portal,\n Spinner,\n Stack,\n Toast,\n useToastStyles\n} from \"@chakra-ui/react\";\nimport { useIntl, useService } from \"open-pioneer:react-hooks\";\nimport { memo, useEffect, useState } from \"react\";\nimport { FiAlertCircle, FiAlertTriangle, FiCheckCircle, FiInfo } from \"react-icons/fi\";\nimport { InternalNotificationAPI, ToasterObject } from \"./NotificationServiceImpl\";\n\n/** Props supported by the {@link Notifier} component. */\nexport interface NotifierProps {}\n\n/**\n * Shows notifications sent via the `NotificationService`.\n *\n * Only one instance of `<Notifier />` should be present in the application.\n * It currently does not matter where the Notifier is located in the react tree.\n *\n * ```ts\n * import { Notifier } from \"@open-pioneer/notifier\";\n *\n * export function AppUI() {\n * return (\n * <>\n * <Notifier />\n * <h1>Your application</h1>\n * </>\n * );\n * }\n * ```\n */\nexport function Notifier(_props: NotifierProps) {\n const notificationService = useService(\n \"notifier.NotificationService\"\n ) as InternalNotificationAPI;\n const [active, setActive] = useState(false);\n\n useEffect(() => {\n const handle = notificationService.registerUI();\n if (!handle) {\n return;\n }\n\n setActive(true);\n return () => {\n setActive(false);\n handle.destroy();\n };\n }, [notificationService]);\n\n return active && <Toaster toaster={notificationService.toaster} />;\n}\n\nconst Toaster = memo(function Toaster(props: { toaster: ToasterObject }) {\n const intl = useIntl();\n return (\n <Portal>\n <ChakraToaster\n toaster={props.toaster}\n insetInline={{ mdDown: \"4\" }}\n aria-label={intl.formatMessage({\n id: \"regionLabel\"\n })}\n >\n {(toast) => (\n <Toast.Root width={{ md: \"sm\" }} alignItems=\"center\">\n {toast.type === \"loading\" ? (\n <Spinner size=\"sm\" color=\"blue.solid\" />\n ) : (\n <ToastIndicator type={toast.type ?? \"\"} />\n )}\n <Stack gap=\"1\" flex=\"1\" maxWidth=\"100%\">\n {toast.title && <Toast.Title>{toast.title}</Toast.Title>}\n {toast.description && (\n <Toast.Description>{toast.description}</Toast.Description>\n )}\n </Stack>\n {toast.action && (\n <Toast.ActionTrigger>{toast.action.label}</Toast.ActionTrigger>\n )}\n {toast.meta?.closable && (\n <Toast.CloseTrigger\n cursor=\"pointer\"\n aria-label={intl.formatMessage({\n id: \"notification.close\"\n })}\n />\n )}\n </Toast.Root>\n )}\n </ChakraToaster>\n </Portal>\n );\n});\n\nconst icons: Record<string, React.ElementType> = {\n info: FiInfo,\n success: FiCheckCircle,\n warning: FiAlertCircle,\n error: FiAlertTriangle\n};\n\nfunction ToastIndicator(props: { type: string }) {\n const styles = useToastStyles();\n\n const Component = icons[props.type];\n if (!Component) return null;\n\n return (\n <Icon css={styles.indicator}>\n <span>\n <Component style={{ width: \"100%\", height: \"100%\" }} />\n </span>\n </Icon>\n );\n}\n"],"names":["Toaster","ChakraToaster"],"mappings":";;;;;;AAsCO,SAAS,SAAS,MAAuB,EAAA;AAC5C,EAAA,MAAM,mBAAsB,GAAA,UAAA;AAAA,IACxB;AAAA,GACJ;AACA,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAAS,KAAK,CAAA;AAE1C,EAAA,SAAA,CAAU,MAAM;AACZ,IAAM,MAAA,MAAA,GAAS,oBAAoB,UAAW,EAAA;AAC9C,IAAA,IAAI,CAAC,MAAQ,EAAA;AACT,MAAA;AAAA;AAGJ,IAAA,SAAA,CAAU,IAAI,CAAA;AACd,IAAA,OAAO,MAAM;AACT,MAAA,SAAA,CAAU,KAAK,CAAA;AACf,MAAA,MAAA,CAAO,OAAQ,EAAA;AAAA,KACnB;AAAA,GACJ,EAAG,CAAC,mBAAmB,CAAC,CAAA;AAExB,EAAA,OAAO,MAAU,oBAAA,GAAA,CAAC,OAAQ,EAAA,EAAA,OAAA,EAAS,oBAAoB,OAAS,EAAA,CAAA;AACpE;AAEA,MAAM,OAAU,GAAA,IAAA,CAAK,SAASA,QAAAA,CAAQ,KAAmC,EAAA;AACrE,EAAA,MAAM,OAAO,OAAQ,EAAA;AACrB,EAAA,2BACK,MACG,EAAA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AAAA,aACP;AAAA;AAAA;AACL,OAER,EAAA;AAAA;AAAA,GAGZ,EAAA,CAAA;AAER,CAAC,CAAA;AAED,MAAM,KAA2C,GAAA;AAAA,EAC7C,IAAM,EAAA,MAAA;AAAA,EACN,OAAS,EAAA,aAAA;AAAA,EACT,OAAS,EAAA,aAAA;AAAA,EACT,KAAO,EAAA;AACX,CAAA;AAEA,SAAS,eAAe,KAAyB,EAAA;AAC7C,EAAA,MAAM,SAAS,cAAe,EAAA;AAE9B,EAAM,MAAA,SAAA,GAAY,KAAM,CAAA,KAAA,CAAM,IAAI,CAAA;AAClC,EAAI,IAAA,CAAC,WAAkB,OAAA,IAAA;AAEvB,EAAA,2BACK,IAAK,EAAA,EAAA,GAAA,EAAK,MAAO,CAAA,SAAA,EACd,8BAAC,MACG,EAAA,EAAA,QAAA,kBAAA,GAAA,CAAC,SAAU,EAAA,EAAA,KAAA,EAAO,EAAE,KAAO,EAAA,MAAA,EAAQ,QAAQ,MAAO,EAAA,EAAG,GACzD,CACJ,EAAA,CAAA;AAER;;;;"}
@@ -1,7 +1,8 @@
1
- import { useServiceInternal } from '@open-pioneer/runtime/react-integration';
1
+ import { useIntlInternal, useServiceInternal } from '@open-pioneer/runtime/react-integration';
2
2
 
3
3
  const PACKAGE_NAME = "@open-pioneer/notifier";
4
4
  const useService = /*@__PURE__*/ useServiceInternal.bind(undefined, PACKAGE_NAME);
5
+ const useIntl = /*@__PURE__*/ useIntlInternal.bind(undefined, PACKAGE_NAME);
5
6
 
6
- export { useService };
7
+ export { useIntl, useService };
7
8
  //# sourceMappingURL=_virtual-pioneer-module_react-hooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_virtual-pioneer-module_react-hooks.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
1
+ {"version":3,"file":"_virtual-pioneer-module_react-hooks.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
package/api.d.ts CHANGED
@@ -58,3 +58,14 @@ export interface NotificationService extends DeclaredService<"notifier.Notificat
58
58
  /** Closes all active notifications. */
59
59
  closeAll(): void;
60
60
  }
61
+ /**
62
+ * Properties supported by this package.
63
+ */
64
+ export interface NotifierProperties {
65
+ /**
66
+ * The position for new notifications.
67
+ *
68
+ * @default "top-right"
69
+ */
70
+ position?: "top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right";
71
+ }
package/i18n/de.yaml ADDED
@@ -0,0 +1,5 @@
1
+ messages:
2
+ regionLabel: "Benachrichtigungen"
3
+
4
+ notification:
5
+ close: "Benachrichtigung schließen"
package/i18n/en.yaml ADDED
@@ -0,0 +1,5 @@
1
+ messages:
2
+ regionLabel: "Notifications"
3
+
4
+ notification:
5
+ close: "Close notification"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/notifier",
4
- "version": "3.0.0-dev.20250221111321",
4
+ "version": "4.0.0-dev-chakra-3.20250225100939",
5
5
  "description": "Provides support for application-wide notifications.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -14,12 +14,12 @@
14
14
  "directory": "src/packages/notifier"
15
15
  },
16
16
  "dependencies": {
17
- "@chakra-ui/icons": "^2.2.4",
17
+ "@chakra-ui/react": "^3.8.1",
18
+ "react-icons": "^5.5.0",
18
19
  "react": "^19.0.0",
19
- "@open-pioneer/core": "^3.0.0-dev.20250221111321",
20
- "@open-pioneer/chakra-integration": "^3.0.0-dev.20250221111321",
21
- "@open-pioneer/runtime": "^3.0.0-dev.20250221111321",
22
- "@open-pioneer/react-utils": "^3.0.0-dev.20250221111321"
20
+ "@open-pioneer/core": "^4.0.0-dev-chakra-3.20250225100939",
21
+ "@open-pioneer/runtime": "^4.0.0-dev-chakra-3.20250225100939",
22
+ "@open-pioneer/react-utils": "^4.0.0-dev-chakra-3.20250225100939"
23
23
  },
24
24
  "exports": {
25
25
  "./package.json": "./package.json",
@@ -41,12 +41,21 @@
41
41
  "interfaceName": "notifier.NotificationService"
42
42
  }
43
43
  ],
44
- "references": []
44
+ "references": [
45
+ {
46
+ "referenceName": "appCtx",
47
+ "type": "unique",
48
+ "interfaceName": "runtime.ApplicationContext"
49
+ }
50
+ ]
45
51
  }
46
52
  ],
47
53
  "servicesModule": "./services",
48
54
  "i18n": {
49
- "languages": []
55
+ "languages": [
56
+ "en",
57
+ "de"
58
+ ]
50
59
  },
51
60
  "ui": {
52
61
  "references": [
@@ -56,7 +65,13 @@
56
65
  }
57
66
  ]
58
67
  },
59
- "properties": [],
68
+ "properties": [
69
+ {
70
+ "propertyName": "position",
71
+ "defaultValue": "top-right",
72
+ "required": false
73
+ }
74
+ ],
60
75
  "packageFormatVersion": "1.0.0"
61
76
  }
62
77
  }