@aarhus-university/au-lib-react-components 12.6.2 → 12.6.3

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 (109) hide show
  1. package/.eslintrc.js +35 -35
  2. package/.storybook/main.js +34 -34
  3. package/.storybook/preview.js +17 -17
  4. package/README.md +19 -19
  5. package/__tests__/jest/AUButtonComponent.test.tsx +165 -165
  6. package/__tests__/jest/AUDynamicContentComponent.test.tsx +386 -386
  7. package/__tests__/jest/AUErrorComponent.test.tsx +142 -142
  8. package/__tests__/jest/AUModalComponent.test.tsx +186 -186
  9. package/__tests__/jest/AUNotificationComponent.test.tsx +115 -115
  10. package/__tests__/jest/AUSpinnerComponent.test.tsx +57 -57
  11. package/__tests__/jest/AUToolbarComponent.test.tsx +46 -46
  12. package/__tests__/jest/context.test.ts +25 -25
  13. package/__tests__/jest/helpers.test.ts +15 -15
  14. package/__tests__/jest/setupTests.ts +2 -2
  15. package/babel.config.js +8 -8
  16. package/build/umd/all.css +2 -2
  17. package/build/umd/all.js +1 -1
  18. package/build/umd/alphabox.js +1 -1
  19. package/build/umd/databox.js +1 -1
  20. package/build/umd/diagramme.js +1 -1
  21. package/build/umd/flowbox.js +1 -1
  22. package/build/umd/flowbox.js.map +1 -1
  23. package/build/umd/universe.js +1 -1
  24. package/build-storybook.log +386 -386
  25. package/esbuild.mjs +22 -22
  26. package/package.json +107 -107
  27. package/src/components/AUAlertComponent.tsx +128 -128
  28. package/src/components/AUAutoSuggestComponent.js +148 -148
  29. package/src/components/AUButtonComponent.tsx +99 -99
  30. package/src/components/AUCalendarComponent.tsx +497 -497
  31. package/src/components/AUCharacterCountComponent.tsx +56 -56
  32. package/src/components/AUComboBoxComponent.tsx +195 -195
  33. package/src/components/AUContentToggleComponent.tsx +50 -50
  34. package/src/components/AUDatepickerComponent.tsx +124 -124
  35. package/src/components/AUDialogModalComponent.tsx +124 -124
  36. package/src/components/AUDynamicContentComponent.tsx +137 -137
  37. package/src/components/AUEditorComponent.tsx +126 -126
  38. package/src/components/AUErrorComponent.tsx +73 -73
  39. package/src/components/AUMobilePrefixComponent.tsx +20 -20
  40. package/src/components/AUModalComponent.tsx +72 -72
  41. package/src/components/AUNotificationComponent.tsx +44 -44
  42. package/src/components/AUReceiptComponent.tsx +34 -34
  43. package/src/components/AUSpinnerComponent.tsx +40 -40
  44. package/src/components/AUStepComponent.tsx +75 -75
  45. package/src/components/AUSubNavComponent.tsx +57 -57
  46. package/src/components/AUSubmitButtonContainerComponent.tsx +38 -38
  47. package/src/components/AUTabbedContentComponent.tsx +154 -154
  48. package/src/components/AUTableComponent.tsx +29 -29
  49. package/src/components/AUToastComponent.tsx +104 -104
  50. package/src/components/AUToolbarComponent.tsx +108 -108
  51. package/src/components/AUTruncatorComponent.tsx +141 -141
  52. package/src/components/wrapping/AUEmbedComponent.js +47 -47
  53. package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +142 -142
  54. package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
  55. package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
  56. package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
  57. package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
  58. package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
  59. package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
  60. package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
  61. package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
  62. package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
  63. package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
  64. package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
  65. package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
  66. package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
  67. package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
  68. package/src/layout-2016/lib/all.js +3 -3
  69. package/src/layout-2016/lib/au-alphabox.js +99 -99
  70. package/src/layout-2016/lib/au-databox.js +399 -399
  71. package/src/layout-2016/lib/au-diagramme.js +85 -85
  72. package/src/layout-2016/lib/au-flowbox.js +116 -119
  73. package/src/lib/context.tsx +59 -59
  74. package/src/lib/dates.ts +52 -52
  75. package/src/lib/helpers.ts +208 -208
  76. package/src/lib/hooks.ts +157 -157
  77. package/src/lib/i18n.ts +600 -600
  78. package/src/lib/portals.tsx +150 -150
  79. package/src/lib/tinymce.ts +84 -84
  80. package/src/lib/wrapping.ts +21 -21
  81. package/src/styles/_settings.scss +10 -10
  82. package/src/styles/alphabox.scss +222 -222
  83. package/src/styles/app.scss +7 -7
  84. package/src/styles/autosuggest.scss +57 -57
  85. package/src/styles/databox.scss +563 -563
  86. package/src/styles/diagramme.scss +119 -119
  87. package/src/styles/flowbox.scss +72 -72
  88. package/src/styles/maps.scss +395 -395
  89. package/stories/AUAlertComponent.stories.tsx +133 -133
  90. package/stories/AUAutoSuggestComponent.stories.tsx +95 -95
  91. package/stories/AUButtonComponent.stories.tsx +139 -139
  92. package/stories/AUCharacterCountComponent.stories.tsx +121 -121
  93. package/stories/AUComboBoxComponent.stories.tsx +101 -101
  94. package/stories/AUContentToggleComponent.stories.tsx +87 -87
  95. package/stories/AUDialogModalComponent.stories.tsx +75 -75
  96. package/stories/AUDynamicContentComponent.stories.tsx +119 -119
  97. package/stories/AUEditorComponent.stories.tsx +66 -66
  98. package/stories/AUErrorComponent.stories.tsx +132 -132
  99. package/stories/AUModalComponent.stories.tsx +160 -160
  100. package/stories/AUNotificationComponent.stories.tsx +151 -151
  101. package/stories/AUSpinnerComponent.stories.tsx +44 -44
  102. package/stories/AUStepComponent.stories.tsx +91 -91
  103. package/stories/AUToolbarComponent.stories.tsx +389 -389
  104. package/stories/AUTruncatorComponent.stories.tsx +123 -123
  105. package/stories/lib/helpers.tsx +146 -146
  106. package/tsconfig.json +46 -46
  107. package/webpack.config.js +88 -88
  108. package/.claude/settings.local.json +0 -12
  109. package/.vscode/settings.json +0 -22
@@ -1,57 +1,57 @@
1
- /* eslint-env browser */
2
- import React, { useEffect, useRef, FC } from 'react';
3
- import { setSubNavToggle } from '@aarhus-university/au-designsystem-delphinus/source/js/components/nav';
4
-
5
- type Props = {
6
- children: JSX.Element;
7
- className: string;
8
- dataIcon: string;
9
- text: string;
10
- ariaLabel: string;
11
- id: string;
12
- };
13
-
14
- const AUSubNavComponent: FC<Props> = ({
15
- children,
16
- className,
17
- dataIcon,
18
- text,
19
- ariaLabel,
20
- id,
21
- }) => {
22
- const buttonRef = useRef<HTMLButtonElement>(null);
23
- useEffect(() => {
24
- const subNavBtns = document.querySelectorAll('.sub-nav > button.nav__item');
25
- const {
26
- element,
27
- bodyClickEvent,
28
- buttonClickEvent,
29
- } = setSubNavToggle(subNavBtns, buttonRef.current as Element);
30
- return () => {
31
- if (element) {
32
- element.removeEventListener('click', bodyClickEvent);
33
- }
34
- buttonRef.current?.removeEventListener('click', buttonClickEvent);
35
- };
36
- }, []);
37
-
38
- return (
39
- <div className="sub-nav">
40
- <button
41
- ref={buttonRef}
42
- id={id}
43
- type="button"
44
- className={className}
45
- data-icon={dataIcon}
46
- aria-label={ariaLabel}
47
- aria-expanded={false}
48
- >
49
- {text}
50
- </button>
51
- {children}
52
- </div>
53
- );
54
- };
55
-
56
- AUSubNavComponent.displayName = 'AUSubNavComponent';
57
- export default AUSubNavComponent;
1
+ /* eslint-env browser */
2
+ import React, { useEffect, useRef, FC } from 'react';
3
+ import { setSubNavToggle } from '@aarhus-university/au-designsystem-delphinus/source/js/components/nav';
4
+
5
+ type Props = {
6
+ children: JSX.Element;
7
+ className: string;
8
+ dataIcon: string;
9
+ text: string;
10
+ ariaLabel: string;
11
+ id: string;
12
+ };
13
+
14
+ const AUSubNavComponent: FC<Props> = ({
15
+ children,
16
+ className,
17
+ dataIcon,
18
+ text,
19
+ ariaLabel,
20
+ id,
21
+ }) => {
22
+ const buttonRef = useRef<HTMLButtonElement>(null);
23
+ useEffect(() => {
24
+ const subNavBtns = document.querySelectorAll('.sub-nav > button.nav__item');
25
+ const {
26
+ element,
27
+ bodyClickEvent,
28
+ buttonClickEvent,
29
+ } = setSubNavToggle(subNavBtns, buttonRef.current as Element);
30
+ return () => {
31
+ if (element) {
32
+ element.removeEventListener('click', bodyClickEvent);
33
+ }
34
+ buttonRef.current?.removeEventListener('click', buttonClickEvent);
35
+ };
36
+ }, []);
37
+
38
+ return (
39
+ <div className="sub-nav">
40
+ <button
41
+ ref={buttonRef}
42
+ id={id}
43
+ type="button"
44
+ className={className}
45
+ data-icon={dataIcon}
46
+ aria-label={ariaLabel}
47
+ aria-expanded={false}
48
+ >
49
+ {text}
50
+ </button>
51
+ {children}
52
+ </div>
53
+ );
54
+ };
55
+
56
+ AUSubNavComponent.displayName = 'AUSubNavComponent';
57
+ export default AUSubNavComponent;
@@ -1,38 +1,38 @@
1
- import React, { FC } from 'react';
2
- import AUButtonComponent from './AUButtonComponent';
3
-
4
- type Props = {
5
- disabled: boolean;
6
- submitText: string;
7
- cancelText: string;
8
- onSubmit: (event: React.MouseEvent<HTMLButtonElement>) => void;
9
- onCancel: (event: React.MouseEvent<HTMLButtonElement>) => void;
10
- };
11
-
12
- const AUSubmitButtonContainerComponent: FC<Props> = ({
13
- disabled,
14
- submitText,
15
- cancelText,
16
- onSubmit,
17
- onCancel,
18
- }) => (
19
- <div className="submit button-container">
20
- <AUButtonComponent
21
- asSubmit
22
- label={submitText}
23
- classNames={[disabled ? 'button--processing' : '']}
24
- disabled={disabled}
25
- mode={disabled ? 'processing' : 'none'}
26
- onClick={onSubmit}
27
- />
28
- <AUButtonComponent
29
- label={cancelText}
30
- type="text"
31
- disabled={disabled}
32
- onClick={onCancel}
33
- />
34
- </div>
35
- );
36
-
37
- AUSubmitButtonContainerComponent.displayName = 'AUSubmitButtonContainerComponent';
38
- export default AUSubmitButtonContainerComponent;
1
+ import React, { FC } from 'react';
2
+ import AUButtonComponent from './AUButtonComponent';
3
+
4
+ type Props = {
5
+ disabled: boolean;
6
+ submitText: string;
7
+ cancelText: string;
8
+ onSubmit: (event: React.MouseEvent<HTMLButtonElement>) => void;
9
+ onCancel: (event: React.MouseEvent<HTMLButtonElement>) => void;
10
+ };
11
+
12
+ const AUSubmitButtonContainerComponent: FC<Props> = ({
13
+ disabled,
14
+ submitText,
15
+ cancelText,
16
+ onSubmit,
17
+ onCancel,
18
+ }) => (
19
+ <div className="submit button-container">
20
+ <AUButtonComponent
21
+ asSubmit
22
+ label={submitText}
23
+ classNames={[disabled ? 'button--processing' : '']}
24
+ disabled={disabled}
25
+ mode={disabled ? 'processing' : 'none'}
26
+ onClick={onSubmit}
27
+ />
28
+ <AUButtonComponent
29
+ label={cancelText}
30
+ type="text"
31
+ disabled={disabled}
32
+ onClick={onCancel}
33
+ />
34
+ </div>
35
+ );
36
+
37
+ AUSubmitButtonContainerComponent.displayName = 'AUSubmitButtonContainerComponent';
38
+ export default AUSubmitButtonContainerComponent;
@@ -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;