@aarhus-university/au-lib-react-components 12.5.1 → 12.6.1

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.
Files changed (115) hide show
  1. package/.claude/settings.local.json +12 -0
  2. package/.eslintrc.js +35 -35
  3. package/.storybook/main.js +34 -34
  4. package/.storybook/preview.js +17 -17
  5. package/.vscode/settings.json +22 -0
  6. package/README.md +19 -19
  7. package/__tests__/jest/AUButtonComponent.test.tsx +165 -165
  8. package/__tests__/jest/AUDynamicContentComponent.test.tsx +386 -0
  9. package/__tests__/jest/AUErrorComponent.test.tsx +142 -142
  10. package/__tests__/jest/AUModalComponent.test.tsx +186 -186
  11. package/__tests__/jest/AUNotificationComponent.test.tsx +115 -115
  12. package/__tests__/jest/AUSpinnerComponent.test.tsx +57 -57
  13. package/__tests__/jest/AUToolbarComponent.test.tsx +46 -46
  14. package/__tests__/jest/context.test.ts +25 -25
  15. package/__tests__/jest/helpers.test.ts +15 -15
  16. package/__tests__/jest/setupTests.ts +2 -2
  17. package/babel.config.js +8 -8
  18. package/build/umd/all.css +3 -2
  19. package/build/umd/all.css.map +1 -7
  20. package/build/umd/all.js +2 -45
  21. package/build/umd/all.js.map +1 -7
  22. package/build/umd/alphabox.js +2 -45
  23. package/build/umd/alphabox.js.map +1 -7
  24. package/build/umd/databox.js +2 -45
  25. package/build/umd/databox.js.map +1 -7
  26. package/build/umd/diagramme.js +2 -44
  27. package/build/umd/diagramme.js.map +1 -7
  28. package/build/umd/flowbox.js +2 -44
  29. package/build/umd/flowbox.js.map +1 -7
  30. package/build/umd/universe.js +1 -1
  31. package/build-storybook.log +386 -386
  32. package/esbuild.mjs +22 -22
  33. package/package.json +107 -105
  34. package/src/components/AUAlertComponent.tsx +128 -128
  35. package/src/components/AUAutoSuggestComponent.js +148 -148
  36. package/src/components/AUButtonComponent.tsx +99 -97
  37. package/src/components/AUCalendarComponent.tsx +497 -497
  38. package/src/components/AUCharacterCountComponent.tsx +56 -56
  39. package/src/components/AUComboBoxComponent.tsx +195 -195
  40. package/src/components/AUContentToggleComponent.tsx +50 -50
  41. package/src/components/AUDatepickerComponent.tsx +124 -124
  42. package/src/components/AUDialogModalComponent.tsx +124 -124
  43. package/src/components/AUDynamicContentComponent.tsx +137 -0
  44. package/src/components/AUEditorComponent.tsx +126 -117
  45. package/src/components/AUErrorComponent.tsx +73 -73
  46. package/src/components/AUMobilePrefixComponent.tsx +20 -20
  47. package/src/components/AUModalComponent.tsx +72 -72
  48. package/src/components/AUNotificationComponent.tsx +44 -44
  49. package/src/components/AUReceiptComponent.tsx +34 -34
  50. package/src/components/AUSpinnerComponent.tsx +40 -40
  51. package/src/components/AUStepComponent.tsx +75 -75
  52. package/src/components/AUSubNavComponent.tsx +57 -57
  53. package/src/components/AUSubmitButtonContainerComponent.tsx +38 -38
  54. package/src/components/AUTabbedContentComponent.tsx +154 -154
  55. package/src/components/AUTableComponent.tsx +29 -29
  56. package/src/components/AUToastComponent.tsx +104 -104
  57. package/src/components/AUToolbarComponent.tsx +108 -108
  58. package/src/components/AUTruncatorComponent.tsx +141 -141
  59. package/src/components/wrapping/AUEmbedComponent.js +47 -47
  60. package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +142 -143
  61. package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
  62. package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
  63. package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
  64. package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
  65. package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
  66. package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
  67. package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
  68. package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
  69. package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
  70. package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
  71. package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
  72. package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
  73. package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
  74. package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
  75. package/src/layout-2016/lib/all.js +3 -3
  76. package/src/layout-2016/lib/au-alphabox.js +99 -100
  77. package/src/layout-2016/lib/au-databox.js +399 -400
  78. package/src/layout-2016/lib/au-diagramme.js +85 -85
  79. package/src/layout-2016/lib/au-flowbox.js +119 -93
  80. package/src/lib/context.tsx +59 -59
  81. package/src/lib/dates.ts +52 -52
  82. package/src/lib/helpers.ts +208 -208
  83. package/src/lib/hooks.ts +157 -157
  84. package/src/lib/i18n.ts +600 -600
  85. package/src/lib/portals.tsx +150 -150
  86. package/src/lib/tinymce.ts +84 -84
  87. package/src/lib/wrapping.ts +21 -21
  88. package/src/styles/_settings.scss +10 -10
  89. package/src/styles/alphabox.scss +222 -222
  90. package/src/styles/app.scss +7 -7
  91. package/src/styles/autosuggest.scss +57 -57
  92. package/src/styles/databox.scss +563 -563
  93. package/src/styles/diagramme.scss +119 -119
  94. package/src/styles/flowbox.scss +72 -72
  95. package/src/styles/maps.scss +395 -395
  96. package/stories/AUAlertComponent.stories.tsx +133 -133
  97. package/stories/AUAutoSuggestComponent.stories.tsx +95 -95
  98. package/stories/AUButtonComponent.stories.tsx +139 -139
  99. package/stories/AUCharacterCountComponent.stories.tsx +121 -121
  100. package/stories/AUComboBoxComponent.stories.tsx +101 -101
  101. package/stories/AUContentToggleComponent.stories.tsx +87 -87
  102. package/stories/AUDialogModalComponent.stories.tsx +75 -75
  103. package/stories/AUDynamicContentComponent.stories.tsx +119 -0
  104. package/stories/AUEditorComponent.stories.tsx +66 -66
  105. package/stories/AUErrorComponent.stories.tsx +132 -132
  106. package/stories/AUModalComponent.stories.tsx +160 -160
  107. package/stories/AUNotificationComponent.stories.tsx +151 -151
  108. package/stories/AUSpinnerComponent.stories.tsx +44 -44
  109. package/stories/AUStepComponent.stories.tsx +91 -91
  110. package/stories/AUToolbarComponent.stories.tsx +389 -389
  111. package/stories/AUTruncatorComponent.stories.tsx +123 -123
  112. package/stories/lib/helpers.tsx +146 -146
  113. package/tsconfig.json +46 -46
  114. package/webpack.config.js +88 -88
  115. package/src/lib/tracking.ts +0 -69
@@ -1,154 +1,154 @@
1
- /* eslint-disable @typescript-eslint/no-empty-function */
2
- /* eslint-env browser */
3
- /* eslint-disable max-len */
4
- import React, { useEffect, useRef, FC } from 'react';
5
- import {
6
- BrowserRouter as Router,
7
- Routes,
8
- Route,
9
- NavLink,
10
- useLocation,
11
- } from 'react-router-dom';
12
- import { setTabbedContent, isBelowViewportLimit, destroyTabs } from '@aarhus-university/au-designsystem-delphinus/source/js/components/tabs';
13
-
14
- type TabRoutesProps = {
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
- onRouteChange: (location: any) => void; // Noget react-router-dom halløj her der ikke spiller...
17
- content: JSX.Element[];
18
- };
19
-
20
- const TabRoutes: FC<TabRoutesProps> = ({ onRouteChange, content }: TabRoutesProps) => {
21
- const location = useLocation();
22
- useEffect(() => {
23
- onRouteChange(location);
24
- }, [location]);
25
-
26
- return (
27
- <Routes>
28
- {content}
29
- </Routes>
30
- );
31
- };
32
-
33
- TabRoutes.displayName = 'Routes';
34
-
35
- let windowInnerWidth = 0;
36
- let tabbedObject: ITabbedObject | null = null;
37
-
38
- type Props = {
39
- tabKey?: number;
40
- tabs: ITabbedTab[];
41
- tabContent?: ITabbedObject[] | null;
42
- children?: JSX.Element | null;
43
- focus?: boolean;
44
- initial?: number;
45
- lang?: string;
46
- callback?: (tabIndex: number) => void;
47
- withRouter?: boolean;
48
- classNames?: string;
49
- };
50
-
51
- const AUTabbedContentComponent: FC<Props> = ({
52
- tabKey = 0,
53
- tabs,
54
- tabContent = null,
55
- children = null,
56
- focus = true,
57
- initial = 0,
58
- lang = 'da',
59
- callback = () => { },
60
- withRouter = false,
61
- classNames = 'tabbed-content',
62
- }) => {
63
- const tabsElement = useRef<HTMLDivElement>(null);
64
-
65
- const setTabs = (initTab: number) => {
66
- if (tabbedObject != null) {
67
- if (isBelowViewportLimit(tabbedObject.domElement.classList)) {
68
- if (!tabbedObject.rendered) {
69
- setTabbedContent(tabKey as number, tabbedObject.domElement, initTab, focus, callback);
70
- tabbedObject.rendered = true;
71
- }
72
- } else if (tabbedObject.rendered) {
73
- destroyTabs(tabbedObject.domElement);
74
- tabbedObject.rendered = false;
75
- }
76
- }
77
- };
78
-
79
- useEffect(() => {
80
- if (!withRouter) {
81
- tabbedObject = {
82
- domElement: tabsElement.current as HTMLElement,
83
- rendered: false,
84
- };
85
- setTabs(initial);
86
- windowInnerWidth = window.innerWidth;
87
- const resizeHandler = () => {
88
- if (windowInnerWidth > 0 && window.innerWidth !== windowInnerWidth) {
89
- windowInnerWidth = window.innerWidth;
90
- setTabs(initial);
91
- }
92
- };
93
- window.removeEventListener('resize', resizeHandler);
94
- window.addEventListener('resize', resizeHandler);
95
- }
96
- }, [initial]);
97
-
98
- if (withRouter) {
99
- const renderRouteTabs = tabs.map((tab) => (
100
- <NavLink
101
- key={tab.href}
102
- to={tab.href}
103
- className={({ isActive }) => (isActive ? 'nav__item nav__item--active' : 'nav__item')}
104
- dangerouslySetInnerHTML={{ __html: tab.text }}
105
- />
106
- ));
107
- const renderContent = (tabContent || []).map((content, index: number) => (
108
- <Route
109
- key={tabs[index].href}
110
- path={tabs[index].href}
111
- >
112
- {content?.content}
113
- </Route>
114
- ));
115
-
116
- return (
117
- <Router>
118
- <div ref={tabsElement} className={classNames}>
119
- <div className="nav nav--has-active-item">
120
- <div className="nav__items">
121
- {renderRouteTabs}
122
- </div>
123
- </div>
124
- <TabRoutes
125
- content={renderContent}
126
- onRouteChange={() => {
127
- if (typeof callback === 'function') {
128
- callback(0);
129
- }
130
- }}
131
- />
132
- </div>
133
- </Router>
134
- );
135
- }
136
-
137
- // eslint-disable-next-line jsx-a11y/control-has-associated-label
138
- const renderTabs = tabs.map((tab: ITabbedTab) => <a key={tab.href} href={tab.href} className="nav__item" data-gtm={tab.dataGtm} dangerouslySetInnerHTML={{ __html: tab.text }} />);
139
-
140
- return (
141
- <div ref={tabsElement} className={classNames}>
142
- <div className="nav nav--has-active-item">
143
- <div className="nav__items">
144
- {renderTabs}
145
- </div>
146
- <button type="button" className="nav__toggle">{lang === 'da' ? 'Mere' : 'More'}</button>
147
- </div>
148
- {children}
149
- </div>
150
- );
151
- };
152
-
153
- AUTabbedContentComponent.displayName = 'AUTabbedContentComponent';
154
- export default AUTabbedContentComponent;
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
2
+ /* eslint-env browser */
3
+ /* eslint-disable max-len */
4
+ import React, { useEffect, useRef, FC } from 'react';
5
+ import {
6
+ BrowserRouter as Router,
7
+ Routes,
8
+ Route,
9
+ NavLink,
10
+ useLocation,
11
+ } from 'react-router-dom';
12
+ import { setTabbedContent, isBelowViewportLimit, destroyTabs } from '@aarhus-university/au-designsystem-delphinus/source/js/components/tabs';
13
+
14
+ type TabRoutesProps = {
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ onRouteChange: (location: any) => void; // Noget react-router-dom halløj her der ikke spiller...
17
+ content: JSX.Element[];
18
+ };
19
+
20
+ const TabRoutes: FC<TabRoutesProps> = ({ onRouteChange, content }: TabRoutesProps) => {
21
+ const location = useLocation();
22
+ useEffect(() => {
23
+ onRouteChange(location);
24
+ }, [location]);
25
+
26
+ return (
27
+ <Routes>
28
+ {content}
29
+ </Routes>
30
+ );
31
+ };
32
+
33
+ TabRoutes.displayName = 'Routes';
34
+
35
+ let windowInnerWidth = 0;
36
+ let tabbedObject: ITabbedObject | null = null;
37
+
38
+ type Props = {
39
+ tabKey?: number;
40
+ tabs: ITabbedTab[];
41
+ tabContent?: ITabbedObject[] | null;
42
+ children?: JSX.Element | null;
43
+ focus?: boolean;
44
+ initial?: number;
45
+ lang?: string;
46
+ callback?: (tabIndex: number) => void;
47
+ withRouter?: boolean;
48
+ classNames?: string;
49
+ };
50
+
51
+ const AUTabbedContentComponent: FC<Props> = ({
52
+ tabKey = 0,
53
+ tabs,
54
+ tabContent = null,
55
+ children = null,
56
+ focus = true,
57
+ initial = 0,
58
+ lang = 'da',
59
+ callback = () => { },
60
+ withRouter = false,
61
+ classNames = 'tabbed-content',
62
+ }) => {
63
+ const tabsElement = useRef<HTMLDivElement>(null);
64
+
65
+ const setTabs = (initTab: number) => {
66
+ if (tabbedObject != null) {
67
+ if (isBelowViewportLimit(tabbedObject.domElement.classList)) {
68
+ if (!tabbedObject.rendered) {
69
+ setTabbedContent(tabKey as number, tabbedObject.domElement, initTab, focus, callback);
70
+ tabbedObject.rendered = true;
71
+ }
72
+ } else if (tabbedObject.rendered) {
73
+ destroyTabs(tabbedObject.domElement);
74
+ tabbedObject.rendered = false;
75
+ }
76
+ }
77
+ };
78
+
79
+ useEffect(() => {
80
+ if (!withRouter) {
81
+ tabbedObject = {
82
+ domElement: tabsElement.current as HTMLElement,
83
+ rendered: false,
84
+ };
85
+ setTabs(initial);
86
+ windowInnerWidth = window.innerWidth;
87
+ const resizeHandler = () => {
88
+ if (windowInnerWidth > 0 && window.innerWidth !== windowInnerWidth) {
89
+ windowInnerWidth = window.innerWidth;
90
+ setTabs(initial);
91
+ }
92
+ };
93
+ window.removeEventListener('resize', resizeHandler);
94
+ window.addEventListener('resize', resizeHandler);
95
+ }
96
+ }, [initial]);
97
+
98
+ if (withRouter) {
99
+ const renderRouteTabs = tabs.map((tab) => (
100
+ <NavLink
101
+ key={tab.href}
102
+ to={tab.href}
103
+ className={({ isActive }) => (isActive ? 'nav__item nav__item--active' : 'nav__item')}
104
+ dangerouslySetInnerHTML={{ __html: tab.text }}
105
+ />
106
+ ));
107
+ const renderContent = (tabContent || []).map((content, index: number) => (
108
+ <Route
109
+ key={tabs[index].href}
110
+ path={tabs[index].href}
111
+ >
112
+ {content?.content}
113
+ </Route>
114
+ ));
115
+
116
+ return (
117
+ <Router>
118
+ <div ref={tabsElement} className={classNames}>
119
+ <div className="nav nav--has-active-item">
120
+ <div className="nav__items">
121
+ {renderRouteTabs}
122
+ </div>
123
+ </div>
124
+ <TabRoutes
125
+ content={renderContent}
126
+ onRouteChange={() => {
127
+ if (typeof callback === 'function') {
128
+ callback(0);
129
+ }
130
+ }}
131
+ />
132
+ </div>
133
+ </Router>
134
+ );
135
+ }
136
+
137
+ // eslint-disable-next-line jsx-a11y/control-has-associated-label
138
+ const renderTabs = tabs.map((tab: ITabbedTab) => <a key={tab.href} href={tab.href} className="nav__item" data-gtm={tab.dataGtm} dangerouslySetInnerHTML={{ __html: tab.text }} />);
139
+
140
+ return (
141
+ <div ref={tabsElement} className={classNames}>
142
+ <div className="nav nav--has-active-item">
143
+ <div className="nav__items">
144
+ {renderTabs}
145
+ </div>
146
+ <button type="button" className="nav__toggle">{lang === 'da' ? 'Mere' : 'More'}</button>
147
+ </div>
148
+ {children}
149
+ </div>
150
+ );
151
+ };
152
+
153
+ AUTabbedContentComponent.displayName = 'AUTabbedContentComponent';
154
+ export default AUTabbedContentComponent;
@@ -1,29 +1,29 @@
1
- import React, { useLayoutEffect, useRef, FC } from 'react';
2
- import { setResponsiveTable } from '@aarhus-university/au-designsystem-delphinus/source/js/components/table';
3
-
4
- type Props = {
5
- children: JSX.Element;
6
- className: string;
7
- };
8
-
9
- const AUTableComponent: FC<Props> = ({
10
- children,
11
- className,
12
- }) => {
13
- const tableRef = useRef<HTMLTableElement>(null);
14
- useLayoutEffect(() => {
15
- const element = tableRef.current;
16
- if (element) {
17
- setResponsiveTable(element);
18
- }
19
- }, []);
20
-
21
- return (
22
- <table ref={tableRef} className={className}>
23
- {children}
24
- </table>
25
- );
26
- };
27
-
28
- AUTableComponent.displayName = 'AUTableComponent';
29
- export default AUTableComponent;
1
+ import React, { useLayoutEffect, useRef, FC } from 'react';
2
+ import { setResponsiveTable } from '@aarhus-university/au-designsystem-delphinus/source/js/components/table';
3
+
4
+ type Props = {
5
+ children: JSX.Element;
6
+ className: string;
7
+ };
8
+
9
+ const AUTableComponent: FC<Props> = ({
10
+ children,
11
+ className,
12
+ }) => {
13
+ const tableRef = useRef<HTMLTableElement>(null);
14
+ useLayoutEffect(() => {
15
+ const element = tableRef.current;
16
+ if (element) {
17
+ setResponsiveTable(element);
18
+ }
19
+ }, []);
20
+
21
+ return (
22
+ <table ref={tableRef} className={className}>
23
+ {children}
24
+ </table>
25
+ );
26
+ };
27
+
28
+ AUTableComponent.displayName = 'AUTableComponent';
29
+ export default AUTableComponent;
@@ -1,104 +1,104 @@
1
- /* eslint-disable @typescript-eslint/no-empty-function */
2
- /* eslint-env browser */
3
- import React, {
4
- useEffect, useLayoutEffect, useRef, FC,
5
- } from 'react';
6
- import AUButtonComponent from './AUButtonComponent';
7
-
8
- const dismissTimeout = 5000;
9
- let timeoutId: NodeJS.Timeout | null = null;
10
-
11
- type Props = {
12
- message: IToastMessage;
13
- buttonText?: string;
14
- dismiss?: () => void;
15
- onOpen?: () => void;
16
- };
17
-
18
- const AUToastComponent: FC<Props> = ({
19
- message: pMessage,
20
- buttonText = 'OK',
21
- dismiss = () => { },
22
- onOpen = () => { },
23
- }) => {
24
- const { type, message, header } = pMessage;
25
- const toastRef = useRef<HTMLDivElement>(null);
26
- const persistent = type !== 'confirm';
27
-
28
- const moveOut = (element: HTMLElement): void => {
29
- const moveOutClass = 'toast-notification--move-out';
30
- element.classList.add(moveOutClass);
31
- const moveOutElement = document.querySelector(`.${moveOutClass}`);
32
- if (moveOutElement && typeof dismiss === 'function') {
33
- moveOutElement.addEventListener('animationend', () => {
34
- dismiss();
35
- });
36
- }
37
- };
38
-
39
- useEffect(() => {
40
- if (typeof onOpen === 'function') {
41
- onOpen();
42
- }
43
- }, []);
44
-
45
- useLayoutEffect(() => {
46
- const element = toastRef.current;
47
- if (!persistent) {
48
- if (element) {
49
- element.addEventListener('animationend', () => {
50
- timeoutId = setTimeout(() => {
51
- moveOut(element);
52
- }, dismissTimeout);
53
- });
54
- element.addEventListener('mouseenter', () => {
55
- if (timeoutId) {
56
- clearTimeout(timeoutId);
57
- element.addEventListener('mouseleave', () => {
58
- moveOut(element);
59
- });
60
- }
61
- });
62
- }
63
- } else {
64
- element?.querySelector('button')?.focus();
65
- }
66
- }, []);
67
-
68
- let className = 'toast-notification';
69
- if (persistent) {
70
- className = `${className} toast-notification--persistent`;
71
- }
72
- if (type !== 'default') {
73
- className = `${className} toast-notification--${type}`;
74
- }
75
- return (
76
- <div ref={toastRef} className={className}>
77
- <div className="toast-notification__content">
78
- {
79
- header && (
80
- <h2 className="toast-notification__header">
81
- {header}
82
- </h2>
83
- )
84
- }
85
- <p dangerouslySetInnerHTML={{ __html: message }} />
86
- </div>
87
- {
88
- persistent && (
89
- <AUButtonComponent
90
- label={buttonText as string}
91
- onClick={() => {
92
- if (toastRef.current) {
93
- moveOut(toastRef.current);
94
- }
95
- }}
96
- />
97
- )
98
- }
99
- </div>
100
- );
101
- };
102
-
103
- AUToastComponent.displayName = 'AUToastComponent';
104
- export default AUToastComponent;
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
2
+ /* eslint-env browser */
3
+ import React, {
4
+ useEffect, useLayoutEffect, useRef, FC,
5
+ } from 'react';
6
+ import AUButtonComponent from './AUButtonComponent';
7
+
8
+ const dismissTimeout = 5000;
9
+ let timeoutId: NodeJS.Timeout | null = null;
10
+
11
+ type Props = {
12
+ message: IToastMessage;
13
+ buttonText?: string;
14
+ dismiss?: () => void;
15
+ onOpen?: () => void;
16
+ };
17
+
18
+ const AUToastComponent: FC<Props> = ({
19
+ message: pMessage,
20
+ buttonText = 'OK',
21
+ dismiss = () => { },
22
+ onOpen = () => { },
23
+ }) => {
24
+ const { type, message, header } = pMessage;
25
+ const toastRef = useRef<HTMLDivElement>(null);
26
+ const persistent = type !== 'confirm';
27
+
28
+ const moveOut = (element: HTMLElement): void => {
29
+ const moveOutClass = 'toast-notification--move-out';
30
+ element.classList.add(moveOutClass);
31
+ const moveOutElement = document.querySelector(`.${moveOutClass}`);
32
+ if (moveOutElement && typeof dismiss === 'function') {
33
+ moveOutElement.addEventListener('animationend', () => {
34
+ dismiss();
35
+ });
36
+ }
37
+ };
38
+
39
+ useEffect(() => {
40
+ if (typeof onOpen === 'function') {
41
+ onOpen();
42
+ }
43
+ }, []);
44
+
45
+ useLayoutEffect(() => {
46
+ const element = toastRef.current;
47
+ if (!persistent) {
48
+ if (element) {
49
+ element.addEventListener('animationend', () => {
50
+ timeoutId = setTimeout(() => {
51
+ moveOut(element);
52
+ }, dismissTimeout);
53
+ });
54
+ element.addEventListener('mouseenter', () => {
55
+ if (timeoutId) {
56
+ clearTimeout(timeoutId);
57
+ element.addEventListener('mouseleave', () => {
58
+ moveOut(element);
59
+ });
60
+ }
61
+ });
62
+ }
63
+ } else {
64
+ element?.querySelector('button')?.focus();
65
+ }
66
+ }, []);
67
+
68
+ let className = 'toast-notification';
69
+ if (persistent) {
70
+ className = `${className} toast-notification--persistent`;
71
+ }
72
+ if (type !== 'default') {
73
+ className = `${className} toast-notification--${type}`;
74
+ }
75
+ return (
76
+ <div ref={toastRef} className={className}>
77
+ <div className="toast-notification__content">
78
+ {
79
+ header && (
80
+ <h2 className="toast-notification__header">
81
+ {header}
82
+ </h2>
83
+ )
84
+ }
85
+ <p dangerouslySetInnerHTML={{ __html: message }} />
86
+ </div>
87
+ {
88
+ persistent && (
89
+ <AUButtonComponent
90
+ label={buttonText as string}
91
+ onClick={() => {
92
+ if (toastRef.current) {
93
+ moveOut(toastRef.current);
94
+ }
95
+ }}
96
+ />
97
+ )
98
+ }
99
+ </div>
100
+ );
101
+ };
102
+
103
+ AUToastComponent.displayName = 'AUToastComponent';
104
+ export default AUToastComponent;