@cerberus-design/react 0.7.4-next-92f76bb → 0.7.4-next-02f723e
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/build/legacy/_tsup-dts-rollup.d.ts +144 -5
- package/build/legacy/{chunk-7BB66W4A.js → chunk-4EMJR2AY.js} +2 -2
- package/build/legacy/{chunk-OLQQB53X.js → chunk-BEYPMC73.js} +2 -2
- package/build/legacy/chunk-BYDTAFCU.js +76 -0
- package/build/legacy/chunk-BYDTAFCU.js.map +1 -0
- package/build/legacy/{chunk-3RZUW5KH.js → chunk-DB2OA5PU.js} +3 -3
- package/build/legacy/{chunk-GIHAFJYX.js → chunk-GVNPFXKL.js} +9 -2
- package/build/legacy/chunk-GVNPFXKL.js.map +1 -0
- package/build/legacy/chunk-I5FPKT7H.js +122 -0
- package/build/legacy/chunk-I5FPKT7H.js.map +1 -0
- package/build/legacy/{chunk-ANXV7JDK.js → chunk-IL5ELPTT.js} +2 -2
- package/build/legacy/chunk-NWMNEJGU.js +16 -0
- package/build/legacy/chunk-NWMNEJGU.js.map +1 -0
- package/build/legacy/chunk-SINTHADQ.js +22 -0
- package/build/legacy/chunk-SINTHADQ.js.map +1 -0
- package/build/legacy/{chunk-DCI4IKCI.js → chunk-X5JR5LSC.js} +2 -2
- package/build/legacy/{chunk-DED42MIR.js → chunk-XB4ZRAH4.js} +2 -2
- package/build/legacy/components/FileUploader.js +3 -3
- package/build/legacy/components/Input.js +3 -3
- package/build/legacy/components/Notification.js +11 -0
- package/build/legacy/components/Notification.js.map +1 -0
- package/build/legacy/components/NotificationDescription.js +7 -0
- package/build/legacy/components/NotificationDescription.js.map +1 -0
- package/build/legacy/components/NotificationHeading.js +7 -0
- package/build/legacy/components/NotificationHeading.js.map +1 -0
- package/build/legacy/components/Toggle.js +3 -3
- package/build/legacy/config/cerbIcons.js +1 -1
- package/build/legacy/config/defineIcons.js +2 -2
- package/build/legacy/context/confirm-modal.js +3 -3
- package/build/legacy/context/notification-center.js +19 -0
- package/build/legacy/context/notification-center.js.map +1 -0
- package/build/legacy/context/prompt-modal.js +4 -4
- package/build/legacy/index.js +37 -19
- package/build/legacy/index.js.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +144 -5
- package/build/modern/{chunk-2NSXMFKX.js → chunk-3YORUZIQ.js} +2 -2
- package/build/modern/{chunk-OLQQB53X.js → chunk-BEYPMC73.js} +2 -2
- package/build/modern/{chunk-DKHQ5GBY.js → chunk-BMQ7I2PL.js} +3 -3
- package/build/modern/{chunk-GIHAFJYX.js → chunk-GVNPFXKL.js} +9 -2
- package/build/modern/chunk-GVNPFXKL.js.map +1 -0
- package/build/modern/{chunk-ANXV7JDK.js → chunk-IL5ELPTT.js} +2 -2
- package/build/modern/chunk-NWMNEJGU.js +16 -0
- package/build/modern/chunk-NWMNEJGU.js.map +1 -0
- package/build/modern/chunk-NZWANWYC.js +122 -0
- package/build/modern/chunk-NZWANWYC.js.map +1 -0
- package/build/modern/chunk-SINTHADQ.js +22 -0
- package/build/modern/chunk-SINTHADQ.js.map +1 -0
- package/build/modern/chunk-U5QWMMKZ.js +76 -0
- package/build/modern/chunk-U5QWMMKZ.js.map +1 -0
- package/build/modern/{chunk-DED42MIR.js → chunk-XB4ZRAH4.js} +2 -2
- package/build/modern/{chunk-SHNZS357.js → chunk-ZPWSMCZ5.js} +2 -2
- package/build/modern/components/FileUploader.js +3 -3
- package/build/modern/components/Input.js +3 -3
- package/build/modern/components/Notification.js +11 -0
- package/build/modern/components/Notification.js.map +1 -0
- package/build/modern/components/NotificationDescription.js +7 -0
- package/build/modern/components/NotificationDescription.js.map +1 -0
- package/build/modern/components/NotificationHeading.js +7 -0
- package/build/modern/components/NotificationHeading.js.map +1 -0
- package/build/modern/components/Toggle.js +3 -3
- package/build/modern/config/cerbIcons.js +1 -1
- package/build/modern/config/defineIcons.js +2 -2
- package/build/modern/context/confirm-modal.js +3 -3
- package/build/modern/context/notification-center.js +19 -0
- package/build/modern/context/notification-center.js.map +1 -0
- package/build/modern/context/prompt-modal.js +4 -4
- package/build/modern/index.js +37 -19
- package/build/modern/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Notification.tsx +98 -0
- package/src/components/NotificationDescription.tsx +31 -0
- package/src/components/NotificationHeading.tsx +28 -0
- package/src/config/cerbIcons.ts +19 -6
- package/src/context/notification-center.tsx +181 -0
- package/src/index.ts +4 -0
- package/build/legacy/chunk-GIHAFJYX.js.map +0 -1
- package/build/modern/chunk-GIHAFJYX.js.map +0 -1
- /package/build/legacy/{chunk-7BB66W4A.js.map → chunk-4EMJR2AY.js.map} +0 -0
- /package/build/legacy/{chunk-OLQQB53X.js.map → chunk-BEYPMC73.js.map} +0 -0
- /package/build/legacy/{chunk-3RZUW5KH.js.map → chunk-DB2OA5PU.js.map} +0 -0
- /package/build/legacy/{chunk-ANXV7JDK.js.map → chunk-IL5ELPTT.js.map} +0 -0
- /package/build/legacy/{chunk-DCI4IKCI.js.map → chunk-X5JR5LSC.js.map} +0 -0
- /package/build/legacy/{chunk-DED42MIR.js.map → chunk-XB4ZRAH4.js.map} +0 -0
- /package/build/modern/{chunk-2NSXMFKX.js.map → chunk-3YORUZIQ.js.map} +0 -0
- /package/build/modern/{chunk-OLQQB53X.js.map → chunk-BEYPMC73.js.map} +0 -0
- /package/build/modern/{chunk-DKHQ5GBY.js.map → chunk-BMQ7I2PL.js.map} +0 -0
- /package/build/modern/{chunk-ANXV7JDK.js.map → chunk-IL5ELPTT.js.map} +0 -0
- /package/build/modern/{chunk-DED42MIR.js.map → chunk-XB4ZRAH4.js.map} +0 -0
- /package/build/modern/{chunk-SHNZS357.js.map → chunk-ZPWSMCZ5.js.map} +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { cx } from '@cerberus-design/styled-system/css'
|
|
4
|
+
import { hstack, vstack } from '@cerberus-design/styled-system/patterns'
|
|
5
|
+
import {
|
|
6
|
+
notification,
|
|
7
|
+
type NotificationVariantProps,
|
|
8
|
+
} from '@cerberus-design/styled-system/recipes'
|
|
9
|
+
import {
|
|
10
|
+
useRef,
|
|
11
|
+
type DialogHTMLAttributes,
|
|
12
|
+
type PropsWithChildren,
|
|
13
|
+
type MouseEvent,
|
|
14
|
+
} from 'react'
|
|
15
|
+
import { Close } from '@cerberus/icons'
|
|
16
|
+
import { $cerberusIcons } from '../config/defineIcons'
|
|
17
|
+
import type { IconType } from '../config/cerbIcons'
|
|
18
|
+
import { trapFocus } from '../aria-helpers/trap-focus.aria'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This module exports the Notification component.
|
|
22
|
+
* @module
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
function MatchNotificationIcon(props: NotificationVariantProps) {
|
|
26
|
+
const palette = props.palette || 'info'
|
|
27
|
+
const key = `${palette}Notification` as keyof typeof $cerberusIcons
|
|
28
|
+
const Icon = $cerberusIcons[key] as IconType
|
|
29
|
+
return <Icon />
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface NotificationBaseProps
|
|
33
|
+
extends Omit<DialogHTMLAttributes<HTMLDialogElement>, 'onClose'> {
|
|
34
|
+
id: string
|
|
35
|
+
onClose?: (e: MouseEvent<HTMLButtonElement>) => void
|
|
36
|
+
}
|
|
37
|
+
export type NotificationProps = NotificationBaseProps & NotificationVariantProps
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The info notification component.
|
|
41
|
+
* @param props - The component props.
|
|
42
|
+
* @returns The info notification component.
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* <Notification id="info:1" open>
|
|
46
|
+
* <NotificationHeading>Info Notification</NotificationHeading>
|
|
47
|
+
* <NotificationDescription>
|
|
48
|
+
* This is a description with a <a href="#">link</a> in the message.
|
|
49
|
+
* </NotificationDescription>
|
|
50
|
+
* </Notification>
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export function Notification(props: PropsWithChildren<NotificationProps>) {
|
|
54
|
+
const { children, palette, onClose, ...nativeProps } = props
|
|
55
|
+
const ref = useRef<HTMLDialogElement>(null)
|
|
56
|
+
const onKeyDown = trapFocus(ref)
|
|
57
|
+
const styles = notification({ palette })
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<dialog
|
|
61
|
+
{...nativeProps}
|
|
62
|
+
className={cx(
|
|
63
|
+
nativeProps.className,
|
|
64
|
+
hstack({
|
|
65
|
+
position: 'relative',
|
|
66
|
+
gap: '4',
|
|
67
|
+
}),
|
|
68
|
+
styles.dialog,
|
|
69
|
+
)}
|
|
70
|
+
onKeyDown={onKeyDown}
|
|
71
|
+
ref={ref}
|
|
72
|
+
role="alert"
|
|
73
|
+
>
|
|
74
|
+
<span className={styles.icon}>
|
|
75
|
+
<MatchNotificationIcon palette={palette} />
|
|
76
|
+
</span>
|
|
77
|
+
|
|
78
|
+
<div
|
|
79
|
+
className={vstack({
|
|
80
|
+
alignItems: 'flex-start',
|
|
81
|
+
gap: '0',
|
|
82
|
+
py: '2',
|
|
83
|
+
})}
|
|
84
|
+
>
|
|
85
|
+
{children}
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<button
|
|
89
|
+
aria-label="Close"
|
|
90
|
+
className={styles.close}
|
|
91
|
+
onClick={onClose}
|
|
92
|
+
value={props.id}
|
|
93
|
+
>
|
|
94
|
+
<Close />
|
|
95
|
+
</button>
|
|
96
|
+
</dialog>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module exports the NotificationDescription component.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { cx } from '@cerberus-design/styled-system/css'
|
|
7
|
+
import {
|
|
8
|
+
notification,
|
|
9
|
+
type NotificationVariantProps,
|
|
10
|
+
} from '@cerberus-design/styled-system/recipes'
|
|
11
|
+
import type { HTMLAttributes } from 'react'
|
|
12
|
+
|
|
13
|
+
export interface BaseNotificationDescriptionProps
|
|
14
|
+
extends HTMLAttributes<HTMLParagraphElement> {}
|
|
15
|
+
export type NotificationDescriptionProps = BaseNotificationDescriptionProps &
|
|
16
|
+
NotificationVariantProps
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The NotificationDescription component is used to render the description of a notification.
|
|
20
|
+
* @param props - The anything a HTMLParagraphElement can accept.
|
|
21
|
+
*/
|
|
22
|
+
export function NotificationDescription(props: NotificationDescriptionProps) {
|
|
23
|
+
const { palette, ...nativeProps } = props
|
|
24
|
+
const styles = notification({ palette })
|
|
25
|
+
return (
|
|
26
|
+
<p
|
|
27
|
+
className={cx(nativeProps.className, styles.description)}
|
|
28
|
+
{...nativeProps}
|
|
29
|
+
/>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module exports the NotificationHeading component.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { cx } from '@cerberus-design/styled-system/css'
|
|
7
|
+
import {
|
|
8
|
+
notification,
|
|
9
|
+
type NotificationVariantProps,
|
|
10
|
+
} from '@cerberus-design/styled-system/recipes'
|
|
11
|
+
import type { HTMLAttributes } from 'react'
|
|
12
|
+
|
|
13
|
+
export interface BaseNotificationHeadingProps
|
|
14
|
+
extends HTMLAttributes<HTMLParagraphElement> {}
|
|
15
|
+
export type NotificationHeadingProps = BaseNotificationHeadingProps &
|
|
16
|
+
NotificationVariantProps
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The NotificationHeading component is used to render the heading of a notification.
|
|
20
|
+
* @param props - The anything a HTMLParagraphElement can accept.
|
|
21
|
+
*/
|
|
22
|
+
export function NotificationHeading(props: NotificationHeadingProps) {
|
|
23
|
+
const { palette, ...nativeProps } = props
|
|
24
|
+
const styles = notification({ palette })
|
|
25
|
+
return (
|
|
26
|
+
<p className={cx(nativeProps.className, styles.heading)} {...nativeProps} />
|
|
27
|
+
)
|
|
28
|
+
}
|
package/src/config/cerbIcons.ts
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Checkmark,
|
|
3
|
+
CheckmarkFilled,
|
|
3
4
|
CloudUpload,
|
|
5
|
+
ErrorFilled,
|
|
4
6
|
Information,
|
|
7
|
+
InformationFilled,
|
|
5
8
|
WarningFilled,
|
|
6
9
|
type CarbonIconType,
|
|
7
10
|
} from '@cerberus/icons'
|
|
8
11
|
import type { ElementType } from 'react'
|
|
9
12
|
|
|
13
|
+
export type IconType = CarbonIconType | ElementType
|
|
14
|
+
|
|
10
15
|
export interface DefinedIcons {
|
|
11
|
-
confirmModal?:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
confirmModal?: IconType
|
|
17
|
+
promptModal?: IconType
|
|
18
|
+
fileUploader?: IconType
|
|
19
|
+
infoNotification?: IconType
|
|
20
|
+
successNotification?: IconType
|
|
21
|
+
warningNotification?: IconType
|
|
22
|
+
dangerNotification?: IconType
|
|
23
|
+
invalid: IconType
|
|
24
|
+
toggleChecked?: IconType
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
export const defaultIcons: DefinedIcons = {
|
|
19
28
|
confirmModal: Information,
|
|
20
|
-
fileUploader: CloudUpload,
|
|
21
29
|
promptModal: Information,
|
|
30
|
+
fileUploader: CloudUpload,
|
|
31
|
+
infoNotification: InformationFilled,
|
|
32
|
+
successNotification: CheckmarkFilled,
|
|
33
|
+
warningNotification: WarningFilled,
|
|
34
|
+
dangerNotification: ErrorFilled,
|
|
22
35
|
invalid: WarningFilled,
|
|
23
36
|
toggleChecked: Checkmark,
|
|
24
37
|
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useCallback,
|
|
6
|
+
useContext,
|
|
7
|
+
useMemo,
|
|
8
|
+
useState,
|
|
9
|
+
type MouseEvent,
|
|
10
|
+
type PropsWithChildren,
|
|
11
|
+
type ReactNode,
|
|
12
|
+
} from 'react'
|
|
13
|
+
import { Show } from '../components/Show'
|
|
14
|
+
import { NotificationHeading } from '../components/NotificationHeading'
|
|
15
|
+
import { NotificationDescription } from '../components/NotificationDescription'
|
|
16
|
+
import { Notification } from '../components/Notification'
|
|
17
|
+
import { animateIn, vstack } from '@cerberus-design/styled-system/patterns'
|
|
18
|
+
import { Portal, type PortalProps } from '../components/Portal'
|
|
19
|
+
import { notification } from '@cerberus-design/styled-system/recipes'
|
|
20
|
+
import { Button } from '../components/Button'
|
|
21
|
+
import { cx } from '@cerberus-design/styled-system/css'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This module provides a context and hook for notifications.
|
|
25
|
+
* @module
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
export interface NotifyOptions {
|
|
29
|
+
palette: 'info' | 'success' | 'warning' | 'danger'
|
|
30
|
+
heading: string
|
|
31
|
+
id?: string
|
|
32
|
+
description?: ReactNode
|
|
33
|
+
onClose?: () => void
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface NotificationsValue {
|
|
37
|
+
notify: (options: NotifyOptions) => void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const NotificationsContext = createContext<NotificationsValue | null>(null)
|
|
41
|
+
|
|
42
|
+
export interface NotificationsProviderProps extends PortalProps {}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Provides a notification center to the app.
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* // Wrap the Provider around the root of the feature.
|
|
49
|
+
* <Notifications>
|
|
50
|
+
* <SomeFeatureSection />
|
|
51
|
+
* </Notifications>
|
|
52
|
+
*
|
|
53
|
+
* // Use the hook to show a notification.
|
|
54
|
+
* const notify = useNotifications()
|
|
55
|
+
*
|
|
56
|
+
* const handleClick = useCallback(() => {
|
|
57
|
+
* notify({
|
|
58
|
+
* palette: 'info',
|
|
59
|
+
* heading: 'New feature!',
|
|
60
|
+
* description: 'We have added a new feature to the app.',
|
|
61
|
+
* })
|
|
62
|
+
* }, [notify])
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export function NotificationCenter(
|
|
66
|
+
props: PropsWithChildren<NotificationsProviderProps>,
|
|
67
|
+
) {
|
|
68
|
+
const [activeNotifications, setActiveNotifications] = useState<
|
|
69
|
+
NotifyOptions[]
|
|
70
|
+
>([])
|
|
71
|
+
const styles = notification()
|
|
72
|
+
|
|
73
|
+
const handleNotify = useCallback((options: NotifyOptions) => {
|
|
74
|
+
setActiveNotifications((prev) => {
|
|
75
|
+
const id = `${options.palette}:${prev.length + 1}`
|
|
76
|
+
return [...prev, { ...options, id }]
|
|
77
|
+
})
|
|
78
|
+
}, [])
|
|
79
|
+
|
|
80
|
+
const handleClose = useCallback((e: MouseEvent<HTMLButtonElement>) => {
|
|
81
|
+
const target = e.currentTarget as HTMLButtonElement
|
|
82
|
+
setActiveNotifications((prev) => {
|
|
83
|
+
const item = prev.find((option) => option.id === target.value)
|
|
84
|
+
if (item?.onClose) item.onClose()
|
|
85
|
+
return prev.filter((option) => option.id !== target.value)
|
|
86
|
+
})
|
|
87
|
+
}, [])
|
|
88
|
+
|
|
89
|
+
const handleCloseAll = useCallback(() => {
|
|
90
|
+
setActiveNotifications((prev) => {
|
|
91
|
+
prev.forEach((item) => {
|
|
92
|
+
if (item.onClose) item.onClose()
|
|
93
|
+
})
|
|
94
|
+
return []
|
|
95
|
+
})
|
|
96
|
+
}, [])
|
|
97
|
+
|
|
98
|
+
const value = useMemo(
|
|
99
|
+
() => ({
|
|
100
|
+
notify: handleNotify,
|
|
101
|
+
}),
|
|
102
|
+
[handleNotify],
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
// For some reason, the vstack pattern alignItems is not registering here.
|
|
106
|
+
// So we are forcing it with the style prop.
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<NotificationsContext.Provider value={value}>
|
|
110
|
+
{props.children}
|
|
111
|
+
|
|
112
|
+
<Show when={activeNotifications.length > 0}>
|
|
113
|
+
<Portal container={props.container}>
|
|
114
|
+
<div className={styles.center}>
|
|
115
|
+
<Show when={activeNotifications.length >= 4}>
|
|
116
|
+
<Button
|
|
117
|
+
className={cx(styles.closeAll, animateIn())}
|
|
118
|
+
onClick={handleCloseAll}
|
|
119
|
+
palette="action"
|
|
120
|
+
shape="rounded"
|
|
121
|
+
size="sm"
|
|
122
|
+
usage="text"
|
|
123
|
+
>
|
|
124
|
+
Close all
|
|
125
|
+
</Button>
|
|
126
|
+
</Show>
|
|
127
|
+
<div
|
|
128
|
+
className={vstack({
|
|
129
|
+
alignItems: 'flex-end',
|
|
130
|
+
gap: '4',
|
|
131
|
+
})}
|
|
132
|
+
style={{
|
|
133
|
+
alignItems: 'flex-end',
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
{activeNotifications.map((option) => (
|
|
137
|
+
<Notification
|
|
138
|
+
id={option.id!}
|
|
139
|
+
key={option.id}
|
|
140
|
+
onClose={handleClose}
|
|
141
|
+
open
|
|
142
|
+
palette={option.palette}
|
|
143
|
+
>
|
|
144
|
+
<NotificationHeading palette={option.palette}>
|
|
145
|
+
{option.heading}
|
|
146
|
+
</NotificationHeading>
|
|
147
|
+
<NotificationDescription palette={option.palette}>
|
|
148
|
+
{option.description}
|
|
149
|
+
</NotificationDescription>
|
|
150
|
+
</Notification>
|
|
151
|
+
))}
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
</Portal>
|
|
155
|
+
</Show>
|
|
156
|
+
</NotificationsContext.Provider>
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The hook to use the NotificationCenter.
|
|
162
|
+
* @returns The notify method to trigger a notification.
|
|
163
|
+
* @example
|
|
164
|
+
* ```tsx
|
|
165
|
+
* const {notify} = useNotificationCenter()
|
|
166
|
+
* notify({
|
|
167
|
+
* palette: 'info',
|
|
168
|
+
* heading: 'New feature',
|
|
169
|
+
* description: 'We have added a new feature to the app.',
|
|
170
|
+
* })
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export function useNotificationCenter(): NotificationsValue {
|
|
174
|
+
const context = useContext(NotificationsContext)
|
|
175
|
+
if (!context) {
|
|
176
|
+
throw new Error(
|
|
177
|
+
'useNotificationCenter must be used within a NotificationsProvider',
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
return context
|
|
181
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -21,6 +21,9 @@ export * from './components/ModalIcon'
|
|
|
21
21
|
export * from './components/NavMenuTrigger'
|
|
22
22
|
export * from './components/NavMenuList'
|
|
23
23
|
export * from './components/NavMenuLink'
|
|
24
|
+
export * from './components/Notification'
|
|
25
|
+
export * from './components/NotificationHeading'
|
|
26
|
+
export * from './components/NotificationDescription'
|
|
24
27
|
export * from './components/Portal'
|
|
25
28
|
export * from './components/Radio'
|
|
26
29
|
export * from './components/Tab'
|
|
@@ -37,6 +40,7 @@ export * from './context/confirm-modal'
|
|
|
37
40
|
export * from './context/feature-flags'
|
|
38
41
|
export * from './context/field'
|
|
39
42
|
export * from './context/navMenu'
|
|
43
|
+
export * from './context/notification-center'
|
|
40
44
|
export * from './context/prompt-modal'
|
|
41
45
|
export * from './context/tabs'
|
|
42
46
|
export * from './context/theme'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/cerbIcons.ts"],"sourcesContent":["import {\n Checkmark,\n CloudUpload,\n Information,\n WarningFilled,\n type CarbonIconType,\n} from '@cerberus/icons'\nimport type { ElementType } from 'react'\n\nexport interface DefinedIcons {\n confirmModal?: CarbonIconType | ElementType\n fileUploader?: CarbonIconType | ElementType\n promptModal?: CarbonIconType | ElementType\n invalid: CarbonIconType | ElementType\n toggleChecked?: CarbonIconType | ElementType\n}\n\nexport const defaultIcons: DefinedIcons = {\n confirmModal: Information,\n fileUploader: CloudUpload,\n promptModal: Information,\n invalid: WarningFilled,\n toggleChecked: Checkmark,\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAWA,IAAM,eAA6B;AAAA,EACxC,cAAc;AAAA,EACd,cAAc;AAAA,EACd,aAAa;AAAA,EACb,SAAS;AAAA,EACT,eAAe;AACjB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/cerbIcons.ts"],"sourcesContent":["import {\n Checkmark,\n CloudUpload,\n Information,\n WarningFilled,\n type CarbonIconType,\n} from '@cerberus/icons'\nimport type { ElementType } from 'react'\n\nexport interface DefinedIcons {\n confirmModal?: CarbonIconType | ElementType\n fileUploader?: CarbonIconType | ElementType\n promptModal?: CarbonIconType | ElementType\n invalid: CarbonIconType | ElementType\n toggleChecked?: CarbonIconType | ElementType\n}\n\nexport const defaultIcons: DefinedIcons = {\n confirmModal: Information,\n fileUploader: CloudUpload,\n promptModal: Information,\n invalid: WarningFilled,\n toggleChecked: Checkmark,\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAWA,IAAM,eAA6B;AAAA,EACxC,cAAc;AAAA,EACd,cAAc;AAAA,EACd,aAAa;AAAA,EACb,SAAS;AAAA,EACT,eAAe;AACjB;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|