@open-pioneer/notifier 4.9.0-dev.20261029090037 → 4.10.0-dev.20261119090001
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 +12 -1
- package/Notifier.js +2 -8
- package/Notifier.js.map +1 -1
- package/README.md +13 -0
- package/icons.d.ts +19 -0
- package/icons.js +11 -0
- package/icons.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# @open-pioneer/notifier
|
|
2
2
|
|
|
3
|
-
## 4.
|
|
3
|
+
## 4.10.0-dev.20261119090001
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 57b5b4f: Enable trusted publishing for this package.
|
|
8
|
+
- 93d2a9f: Update dependencies
|
|
9
|
+
|
|
10
|
+
## 4.9.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 3e6931d: Export the `defaultIcons` used by the notifier.
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
6
17
|
|
package/Notifier.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import { Portal, Toaster as Toaster$1, Toast, Spinner, Stack, useToastStyles, Icon } from '@chakra-ui/react';
|
|
3
3
|
import { useIntl, useService } from './_virtual/hooks.js';
|
|
4
4
|
import { memo, useState, useEffect } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { defaultIcons } from './icons.js';
|
|
6
6
|
|
|
7
7
|
function Notifier(props) {
|
|
8
8
|
const notificationService = useService(
|
|
@@ -55,15 +55,9 @@ const Toaster = memo(function Toaster2(props) {
|
|
|
55
55
|
}
|
|
56
56
|
) });
|
|
57
57
|
});
|
|
58
|
-
const icons = {
|
|
59
|
-
info: LuInfo,
|
|
60
|
-
success: LuCircleCheck,
|
|
61
|
-
warning: LuCircleAlert,
|
|
62
|
-
error: LuTriangleAlert
|
|
63
|
-
};
|
|
64
58
|
function ToastIndicator(props) {
|
|
65
59
|
const styles = useToastStyles();
|
|
66
|
-
const Component =
|
|
60
|
+
const Component = defaultIcons[props.type];
|
|
67
61
|
if (!Component) return null;
|
|
68
62
|
return /* @__PURE__ */ jsx(Icon, { css: styles.indicator, children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Component, { style: { width: "100%", height: "100%" } }) }) });
|
|
69
63
|
}
|
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\n\nimport {\n BoxProps,\n Toaster as ChakraToaster,\n Icon,\n Portal,\n Spinner,\n Stack,\n Toast,\n ToasterProps,\n useToastStyles\n} from \"@chakra-ui/react\";\nimport { useIntl, useService } from \"open-pioneer:react-hooks\";\nimport { memo, useEffect, useState } from \"react\";\nimport {
|
|
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\n\nimport {\n BoxProps,\n Toaster as ChakraToaster,\n Icon,\n Portal,\n Spinner,\n Stack,\n Toast,\n ToasterProps,\n useToastStyles\n} from \"@chakra-ui/react\";\nimport { useIntl, useService } from \"open-pioneer:react-hooks\";\nimport { memo, useEffect, useState } from \"react\";\nimport { IconType } from \"react-icons/lib\";\nimport { defaultIcons } from \"./icons\";\nimport { InternalNotificationAPI, ToasterObject } from \"./NotificationServiceImpl\";\n\n/** Props supported by the {@link Notifier} component. */\nexport interface NotifierProps {\n /**\n * Props to be added to the notifier's root container.\n *\n * NOTE: Chakra's toaster currently hard codes many style properties using element styles.\n * These styles cannot be easily overwritten, unless one uses `!important`.\n **/\n rootProps?: BoxProps;\n}\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 rootProps={props.rootProps} toaster={notificationService.toaster} />;\n}\n\nconst Toaster = memo(function Toaster(props: { rootProps?: BoxProps; toaster: ToasterObject }) {\n const { rootProps, toaster } = props;\n const intl = useIntl();\n\n return (\n <Portal>\n <ChakraToaster\n insetInline={{ mdDown: \"4\" }}\n aria-label={intl.formatMessage({\n id: \"regionLabel\"\n })}\n className=\"notifier-toast-group\"\n {...(rootProps as ToasterProps | undefined)}\n toaster={toaster}\n >\n {(toast) => (\n <Toast.Root className=\"notifier-toast\" width={{ md: \"sm\" }} alignItems=\"center\">\n {toast.type === \"loading\" ? (\n <Spinner size=\"sm\" color=\"blue.solid\" />\n ) : (\n <ToastIndicator type={toast.type ?? \"\"} />\n )}\n {/* Adjust max width down from 100% (should match internal gaps). Otherwise, the container may grow too large for its parent. */}\n <Stack gap=\"1\" flex=\"1\" maxWidth={\"calc( 100% - {sizes.5} - {spacing.2} )\"}>\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\nfunction ToastIndicator(props: { type: string }) {\n const styles = useToastStyles();\n\n const Component = defaultIcons[props.type as keyof typeof defaultIcons] as IconType | undefined;\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":";;;;;;AAkDO,SAAS,SAAS,KAAA,EAAsB;AAC3C,EAAA,MAAM,mBAAA,GAAsB,UAAA;AAAA,IACxB;AAAA,GACJ;AACA,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAAS,KAAK,CAAA;AAE1C,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,MAAM,MAAA,GAAS,oBAAoB,UAAA,EAAW;AAC9C,IAAA,IAAI,CAAC,MAAA,EAAQ;AACT,MAAA;AAAA,IACJ;AAEA,IAAA,SAAA,CAAU,IAAI,CAAA;AACd,IAAA,OAAO,MAAM;AACT,MAAA,SAAA,CAAU,KAAK,CAAA;AACf,MAAA,MAAA,CAAO,OAAA,EAAQ;AAAA,IACnB,CAAA;AAAA,EACJ,CAAA,EAAG,CAAC,mBAAmB,CAAC,CAAA;AAExB,EAAA,OAAO,MAAA,wBAAW,OAAA,EAAA,EAAQ,SAAA,EAAW,MAAM,SAAA,EAAW,OAAA,EAAS,oBAAoB,OAAA,EAAS,CAAA;AAChG;AAEA,MAAM,OAAA,GAAU,IAAA,CAAK,SAASA,QAAAA,CAAQ,KAAA,EAAyD;AAC3F,EAAA,MAAM,EAAE,SAAA,EAAW,OAAA,EAAQ,GAAI,KAAA;AAC/B,EAAA,MAAM,OAAO,OAAA,EAAQ;AAErB,EAAA,2BACK,MAAA,EAAA,EACG,QAAA,kBAAA,GAAA;AAAA,IAACC,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,EAAA,EAAI;AAAA,aACP;AAAA;AAAA;AACL,OAAA,EAER;AAAA;AAAA,GAER,EACJ,CAAA;AAER,CAAC,CAAA;AAED,SAAS,eAAe,KAAA,EAAyB;AAC7C,EAAA,MAAM,SAAS,cAAA,EAAe;AAE9B,EAAA,MAAM,SAAA,GAAY,YAAA,CAAa,KAAA,CAAM,IAAiC,CAAA;AACtE,EAAA,IAAI,CAAC,WAAW,OAAO,IAAA;AAEvB,EAAA,2BACK,IAAA,EAAA,EAAK,GAAA,EAAK,MAAA,CAAO,SAAA,EACd,8BAAC,MAAA,EAAA,EACG,QAAA,kBAAA,GAAA,CAAC,SAAA,EAAA,EAAU,KAAA,EAAO,EAAE,KAAA,EAAO,MAAA,EAAQ,QAAQ,MAAA,EAAO,EAAG,GACzD,CAAA,EACJ,CAAA;AAER;;"}
|
package/README.md
CHANGED
|
@@ -119,6 +119,19 @@ const notificationService = ...; // injected
|
|
|
119
119
|
notificationService.closeAll();
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
+
### Default icons
|
|
123
|
+
|
|
124
|
+
This package exports the default icons that will be used by its notifications.
|
|
125
|
+
You can use those icons to implement components with a consistent look:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { Icon } from "@chakra-ui/react";
|
|
129
|
+
import { defaultIcons } from "@open-pioneer/notifier";
|
|
130
|
+
|
|
131
|
+
// Prefer `Icon` over raw <defaultIcons.info /> because it automatically applies aria-hidden and also supports chakra's styling props.
|
|
132
|
+
<Icon as={defaultIcons.info} />;
|
|
133
|
+
```
|
|
134
|
+
|
|
122
135
|
## License
|
|
123
136
|
|
|
124
137
|
Apache-2.0 (see `LICENSE` file)
|
package/icons.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default icons used by the `Notifier` component.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
*
|
|
6
|
+
* ```tsx
|
|
7
|
+
* import { Icon } from "@chakra-ui/react";
|
|
8
|
+
* import { defaultIcons } from "@open-pioneer/notifier";
|
|
9
|
+
*
|
|
10
|
+
* // Prefer `Icon` over raw svg because it automatically applies aria-hidden and also supports chakra's styling props.
|
|
11
|
+
* <Icon as={defaultIcons.info} />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const defaultIcons: Readonly<{
|
|
15
|
+
readonly info: import("react-icons/lib").IconType;
|
|
16
|
+
readonly success: import("react-icons/lib").IconType;
|
|
17
|
+
readonly warning: import("react-icons/lib").IconType;
|
|
18
|
+
readonly error: import("react-icons/lib").IconType;
|
|
19
|
+
}>;
|
package/icons.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LuTriangleAlert, LuCircleAlert, LuCircleCheck, LuInfo } from 'react-icons/lu';
|
|
2
|
+
|
|
3
|
+
const defaultIcons = Object.freeze({
|
|
4
|
+
info: LuInfo,
|
|
5
|
+
success: LuCircleCheck,
|
|
6
|
+
warning: LuCircleAlert,
|
|
7
|
+
error: LuTriangleAlert
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { defaultIcons };
|
|
11
|
+
//# sourceMappingURL=icons.js.map
|
package/icons.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.js","sources":["icons.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { LuCircleAlert, LuCircleCheck, LuInfo, LuTriangleAlert } from \"react-icons/lu\";\n\n/**\n * The default icons used by the `Notifier` component.\n *\n * Usage:\n *\n * ```tsx\n * import { Icon } from \"@chakra-ui/react\";\n * import { defaultIcons } from \"@open-pioneer/notifier\";\n *\n * // Prefer `Icon` over raw svg because it automatically applies aria-hidden and also supports chakra's styling props.\n * <Icon as={defaultIcons.info} />\n * ```\n */\nexport const defaultIcons = Object.freeze({\n info: LuInfo,\n success: LuCircleCheck,\n warning: LuCircleAlert,\n error: LuTriangleAlert\n} as const);\n"],"names":[],"mappings":";;AAkBO,MAAM,YAAA,GAAe,OAAO,MAAA,CAAO;AAAA,EACtC,IAAA,EAAM,MAAA;AAAA,EACN,OAAA,EAAS,aAAA;AAAA,EACT,OAAA,EAAS,aAAA;AAAA,EACT,KAAA,EAAO;AACX,CAAU;;"}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/notifier",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.10.0-dev.20261119090001",
|
|
5
5
|
"description": "Provides support for application-wide notifications.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"directory": "src/packages/notifier"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@chakra-ui/react": "^3.
|
|
18
|
-
"@open-pioneer/core": "4.
|
|
19
|
-
"@open-pioneer/runtime": "4.
|
|
17
|
+
"@chakra-ui/react": "^3.38.0",
|
|
18
|
+
"@open-pioneer/core": "4.10.0-dev.20261119090001",
|
|
19
|
+
"@open-pioneer/runtime": "4.10.0-dev.20261119090001",
|
|
20
20
|
"react": "^19.3.1",
|
|
21
21
|
"react-icons": "^5.7.0"
|
|
22
22
|
},
|