@kaizen/components 1.70.4 → 1.70.6
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/dist/cjs/KaizenProvider/KaizenProvider.cjs +2 -6
- package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.cjs +19 -17
- package/dist/esm/KaizenProvider/KaizenProvider.mjs +2 -6
- package/dist/esm/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.mjs +20 -18
- package/dist/styles.css +8573 -8573
- package/package.json +1 -1
- package/src/KaizenProvider/KaizenProvider.tsx +2 -4
- package/src/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.tsx +24 -25
- package/src/__rc__/Menu/MenuItem.module.css +1 -1
package/package.json
CHANGED
|
@@ -11,21 +11,19 @@ export type KaizenProviderProps = {
|
|
|
11
11
|
|
|
12
12
|
export const KaizenProvider = ({ children, locale = 'en' }: KaizenProviderProps): JSX.Element => {
|
|
13
13
|
const [documentIsAvailable, setDocumentIsAvailable] = useState<boolean>(false)
|
|
14
|
-
const [notificationsList, setNotificationsList] = useState<JSX.Element>()
|
|
15
14
|
|
|
16
15
|
useEffect(() => {
|
|
17
16
|
// SSR does not have a document, which is required for ToastNotificationsList.
|
|
18
17
|
// Await document render before rendering the component.
|
|
19
18
|
if (document !== undefined) {
|
|
20
|
-
setNotificationsList(<ToastNotificationsList />)
|
|
21
19
|
setDocumentIsAvailable(true)
|
|
22
20
|
}
|
|
23
|
-
}, [
|
|
21
|
+
}, [])
|
|
24
22
|
|
|
25
23
|
return (
|
|
26
24
|
<OptionalIntlProvider locale={locale}>
|
|
27
25
|
<ToastNotificationProvider>
|
|
28
|
-
{
|
|
26
|
+
{documentIsAvailable && <ToastNotificationsList />}
|
|
29
27
|
{children}
|
|
30
28
|
</ToastNotificationProvider>
|
|
31
29
|
<FontDefinitions />
|
package/src/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.tsx
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { createPortal } from 'react-dom'
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
3
2
|
import { useToastNotificationContext } from '../context/ToastNotificationContext'
|
|
4
3
|
import { ToastNotificationsMap } from './subcomponents/ToastNotificationsMap'
|
|
5
4
|
import styles from './ToastNotificationsList.module.scss'
|
|
6
5
|
|
|
6
|
+
const toastNotificationListId = 'toast-notifications-list'
|
|
7
|
+
|
|
7
8
|
export const ToastNotificationsList = (): JSX.Element => {
|
|
8
9
|
const { notifications, removeToastNotification } = useToastNotificationContext()
|
|
10
|
+
const [toastContainer, setToastContainer] = useState<Element | null>(null)
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
// this is to ensure that the container is created only once. Regardless of how many KaizenProvider is set up, they will also reuse the same container.
|
|
14
|
+
let container = document.querySelector(`[id="${toastNotificationListId}"]`)
|
|
15
|
+
if (!container) {
|
|
16
|
+
container = document.createElement('div')
|
|
17
|
+
container.setAttribute('id', toastNotificationListId)
|
|
18
|
+
container.setAttribute('role', 'status')
|
|
19
|
+
container.className = styles.toastNotificationsList
|
|
20
|
+
document.body.appendChild(container)
|
|
21
|
+
}
|
|
22
|
+
setToastContainer(container)
|
|
23
|
+
}, [])
|
|
20
24
|
|
|
21
|
-
return
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
onHide={removeToastNotification}
|
|
30
|
-
container={containers[0]}
|
|
31
|
-
/>
|
|
32
|
-
</div>,
|
|
33
|
-
document.body,
|
|
25
|
+
return toastContainer ? (
|
|
26
|
+
<ToastNotificationsMap
|
|
27
|
+
notifications={notifications}
|
|
28
|
+
onHide={removeToastNotification}
|
|
29
|
+
container={toastContainer}
|
|
30
|
+
/>
|
|
31
|
+
) : (
|
|
32
|
+
<></>
|
|
34
33
|
)
|
|
35
34
|
}
|
|
36
35
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
letter-spacing: var(--typography-paragraph-body-letter-spacing);
|
|
6
6
|
font-weight: var(--typography-paragraph-body-font-weight);
|
|
7
7
|
line-height: var(--typography-paragraph-body-line-height);
|
|
8
|
-
color:
|
|
8
|
+
color: var(--color-purple-800);
|
|
9
9
|
padding: var(--spacing-6) var(--spacing-8);
|
|
10
10
|
border: var(--border-focus-ring-border-width) var(--border-focus-ring-border-style) transparent;
|
|
11
11
|
border-radius: 4px;
|