@aarhus-university/au-lib-react-components 11.4.0 → 11.4.2
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/.eslintrc.js +34 -34
- package/.storybook/main.js +20 -20
- package/.storybook/preview.js +17 -17
- package/README.md +19 -19
- package/__tests__/jest/AUButtonComponent.test.tsx +165 -165
- package/__tests__/jest/AUErrorComponent.test.tsx +142 -142
- package/__tests__/jest/AUModalComponent.test.tsx +186 -186
- package/__tests__/jest/AUNotificationComponent.test.tsx +115 -115
- package/__tests__/jest/AUSpinnerComponent.test.tsx +57 -57
- package/__tests__/jest/AUToolbarComponent.test.tsx +46 -46
- package/__tests__/jest/context.test.ts +25 -25
- package/__tests__/jest/helpers.test.ts +15 -15
- package/__tests__/jest/setupTests.ts +2 -2
- package/babel.config.js +8 -8
- package/build/umd/all.css +2 -2
- package/build/umd/all.js +1 -1
- package/build/umd/alphabox.js +1 -1
- package/build/umd/databox.js +1 -1
- package/build/umd/diagramme.js +1 -1
- package/build/umd/flowbox.js +1 -1
- package/build/umd/universe.js +1 -1
- package/build-storybook.log +367 -367
- package/package.json +114 -114
- package/src/components/AUAlertComponent.tsx +70 -70
- package/src/components/AUAutoSuggestComponent.js +158 -158
- package/src/components/AUButtonComponent.tsx +84 -84
- package/src/components/AUCalendarComponent.tsx +493 -493
- package/src/components/AUContentToggleComponent.tsx +47 -47
- package/src/components/AUDatepickerComponent.tsx +121 -121
- package/src/components/AUErrorComponent.tsx +78 -78
- package/src/components/AUMobilePrefixComponent.tsx +15 -15
- package/src/components/AUModalComponent.tsx +68 -68
- package/src/components/AUNotificationComponent.tsx +43 -43
- package/src/components/AUReceiptComponent.tsx +33 -33
- package/src/components/AUSpinnerComponent.tsx +36 -36
- package/src/components/AUStepComponent.tsx +47 -47
- package/src/components/AUSubNavComponent.tsx +48 -48
- package/src/components/AUSubmitButtonContainerComponent.tsx +29 -29
- package/src/components/AUTabbedContentComponent.tsx +145 -145
- package/src/components/AUTableComponent.tsx +24 -24
- package/src/components/AUToastComponent.tsx +104 -104
- package/src/components/AUToolbarComponent.tsx +101 -101
- package/src/components/AUTruncatorComponent.tsx +124 -124
- package/src/components/wrapping/AUEmbedComponent.js +47 -47
- package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +143 -143
- package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
- package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
- package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
- package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
- package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
- package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
- package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
- package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
- package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
- package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
- package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
- package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
- package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
- package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
- package/src/layout-2016/components/profile/AUProfileAvatar2016Component.js +103 -103
- package/src/layout-2016/components/universe/StaffTopComponent.js +363 -363
- package/src/layout-2016/components/universe/StudentTopComponent.js +137 -137
- package/src/layout-2016/components/universe/UniverseContainerComponent.js +65 -65
- package/src/layout-2016/lib/all.js +3 -3
- package/src/layout-2016/lib/au-alphabox.js +100 -100
- package/src/layout-2016/lib/au-databox.js +400 -400
- package/src/layout-2016/lib/au-diagramme.js +85 -85
- package/src/layout-2016/lib/au-flowbox.js +93 -93
- package/src/layout-2016/lib/universe.js +9 -9
- package/src/lib/context.tsx +51 -51
- package/src/lib/dates.ts +50 -50
- package/src/lib/helpers.ts +208 -208
- package/src/lib/hooks.ts +75 -75
- package/src/lib/i18n.ts +600 -600
- package/src/lib/portals.tsx +119 -119
- package/src/lib/tracking.ts +69 -69
- package/src/lib/wrapping.ts +21 -21
- package/src/styles/_settings.scss +10 -10
- package/src/styles/alphabox.scss +222 -222
- package/src/styles/app.scss +7 -7
- package/src/styles/autosuggest.scss +57 -57
- package/src/styles/databox.scss +563 -563
- package/src/styles/diagramme.scss +119 -119
- package/src/styles/flowbox.scss +72 -72
- package/src/styles/maps.scss +395 -395
- package/stories/AUButtonComponent.stories.tsx +127 -127
- package/stories/AUContentToggleComponent.stories.tsx +63 -63
- package/stories/AUErrorComponent.stories.tsx +98 -98
- package/stories/AUModalComponent.stories.tsx +83 -83
- package/stories/AUNotificationComponent.stories.tsx +116 -116
- package/stories/AUSpinnerComponent.stories.tsx +41 -41
- package/stories/AUStepComponent.stories.tsx +40 -40
- package/stories/AUToolbarComponent.stories.tsx +326 -326
- package/stories/AUTruncatorComponent.stories.tsx +101 -101
- package/stories/lib/helpers.tsx +128 -128
- package/tsconfig.json +46 -46
- package/webpack.config.js +89 -89
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useEffect,
|
|
3
|
-
useRef,
|
|
4
|
-
FC,
|
|
5
|
-
} from 'react';
|
|
6
|
-
import { setContentToggle } from '@aarhus-university/au-designsystem-delphinus/source/js/components/content-toggle';
|
|
7
|
-
|
|
8
|
-
const AUContentToggleComponent: FC<AUContentToggleComponentProps> = ({
|
|
9
|
-
toggled,
|
|
10
|
-
classNames,
|
|
11
|
-
children,
|
|
12
|
-
onClick,
|
|
13
|
-
beforeCallback,
|
|
14
|
-
afterCallback,
|
|
15
|
-
}: AUContentToggleComponentProps) => {
|
|
16
|
-
const toggleContainer = useRef<HTMLDivElement>(null);
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
const toggle = toggleContainer?.current?.querySelector('.content-toggle__content');
|
|
19
|
-
let cleanUp: CleanUpPair[];
|
|
20
|
-
if (toggle) {
|
|
21
|
-
cleanUp = setContentToggle(toggle, onClick, beforeCallback, afterCallback);
|
|
22
|
-
if (cleanUp.length > 0) { // Den første er altid knappen (og ikke luk-knappen)
|
|
23
|
-
cleanUp[0].element.setAttribute('aria-expanded', toggled ? 'true' : 'false');
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return () => {
|
|
28
|
-
cleanUp.forEach((c) => {
|
|
29
|
-
c.element.removeEventListener('click', c.clickEvent);
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
}, []);
|
|
33
|
-
return (
|
|
34
|
-
<div ref={toggleContainer} className={classNames}>
|
|
35
|
-
{children}
|
|
36
|
-
</div>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
AUContentToggleComponent.defaultProps = {
|
|
41
|
-
classNames: undefined,
|
|
42
|
-
beforeCallback: undefined,
|
|
43
|
-
afterCallback: undefined,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
AUContentToggleComponent.displayName = 'AUContentToggleComponent';
|
|
47
|
-
export default AUContentToggleComponent;
|
|
1
|
+
import React, {
|
|
2
|
+
useEffect,
|
|
3
|
+
useRef,
|
|
4
|
+
FC,
|
|
5
|
+
} from 'react';
|
|
6
|
+
import { setContentToggle } from '@aarhus-university/au-designsystem-delphinus/source/js/components/content-toggle';
|
|
7
|
+
|
|
8
|
+
const AUContentToggleComponent: FC<AUContentToggleComponentProps> = ({
|
|
9
|
+
toggled,
|
|
10
|
+
classNames,
|
|
11
|
+
children,
|
|
12
|
+
onClick,
|
|
13
|
+
beforeCallback,
|
|
14
|
+
afterCallback,
|
|
15
|
+
}: AUContentToggleComponentProps) => {
|
|
16
|
+
const toggleContainer = useRef<HTMLDivElement>(null);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const toggle = toggleContainer?.current?.querySelector('.content-toggle__content');
|
|
19
|
+
let cleanUp: CleanUpPair[];
|
|
20
|
+
if (toggle) {
|
|
21
|
+
cleanUp = setContentToggle(toggle, onClick, beforeCallback, afterCallback);
|
|
22
|
+
if (cleanUp.length > 0) { // Den første er altid knappen (og ikke luk-knappen)
|
|
23
|
+
cleanUp[0].element.setAttribute('aria-expanded', toggled ? 'true' : 'false');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return () => {
|
|
28
|
+
cleanUp.forEach((c) => {
|
|
29
|
+
c.element.removeEventListener('click', c.clickEvent);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
}, []);
|
|
33
|
+
return (
|
|
34
|
+
<div ref={toggleContainer} className={classNames}>
|
|
35
|
+
{children}
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
AUContentToggleComponent.defaultProps = {
|
|
41
|
+
classNames: undefined,
|
|
42
|
+
beforeCallback: undefined,
|
|
43
|
+
afterCallback: undefined,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
AUContentToggleComponent.displayName = 'AUContentToggleComponent';
|
|
47
|
+
export default AUContentToggleComponent;
|
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
import React, { FC, useState } from 'react';
|
|
3
|
-
import dayjs from 'dayjs';
|
|
4
|
-
import AUCalendarComponent from './AUCalendarComponent';
|
|
5
|
-
|
|
6
|
-
const AUDatepickerComponent: FC<AUDatepickerComponentProps> = ({
|
|
7
|
-
id,
|
|
8
|
-
lang,
|
|
9
|
-
date,
|
|
10
|
-
onDateChange,
|
|
11
|
-
onHide,
|
|
12
|
-
format,
|
|
13
|
-
showTime,
|
|
14
|
-
showLabel,
|
|
15
|
-
labelInline,
|
|
16
|
-
labelText,
|
|
17
|
-
fullWidth,
|
|
18
|
-
yearSpanMinus,
|
|
19
|
-
yearSpanPlus,
|
|
20
|
-
limitStart,
|
|
21
|
-
limitEnd,
|
|
22
|
-
disabled,
|
|
23
|
-
sideBySideGrowth,
|
|
24
|
-
}: AUDatepickerComponentProps) => {
|
|
25
|
-
const [showCalendar, setShowCalendar] = useState(false);
|
|
26
|
-
const [sDate, setDate] = useState<Date>(date as Date);
|
|
27
|
-
const dateFormatted = dayjs(sDate).format(format);
|
|
28
|
-
|
|
29
|
-
const hideDatePicker = () => {
|
|
30
|
-
setShowCalendar(false);
|
|
31
|
-
onHide(sDate, dateFormatted);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
let className = 'datepicker form__field';
|
|
35
|
-
if (fullWidth) {
|
|
36
|
-
className = `${className} form__field--full-width`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (labelInline) {
|
|
40
|
-
className = `${className} form__field--inline-label`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (disabled) {
|
|
44
|
-
className = `${className} visually-disabled`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (typeof sideBySideGrowth !== 'undefined' && sideBySideGrowth > 0) {
|
|
48
|
-
className = `${className} form__field--width-relative-${sideBySideGrowth}`;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<div
|
|
53
|
-
className={className}
|
|
54
|
-
aria-owns={`${id}-calendar`}
|
|
55
|
-
aria-haspopup="true"
|
|
56
|
-
aria-expanded={showCalendar}
|
|
57
|
-
>
|
|
58
|
-
{showLabel && <label htmlFor={id}>{labelText}</label>}
|
|
59
|
-
<input
|
|
60
|
-
id={id}
|
|
61
|
-
type="text"
|
|
62
|
-
value={dateFormatted}
|
|
63
|
-
title={
|
|
64
|
-
lang === 'da'
|
|
65
|
-
? 'Klik for at åbne datovælger'
|
|
66
|
-
: 'Click to open datepicker'
|
|
67
|
-
}
|
|
68
|
-
readOnly
|
|
69
|
-
disabled={disabled}
|
|
70
|
-
onClick={() => setShowCalendar(!showCalendar)}
|
|
71
|
-
/>
|
|
72
|
-
{showCalendar && (
|
|
73
|
-
<div className="datepicker__calendar-container">
|
|
74
|
-
<AUCalendarComponent
|
|
75
|
-
key={`${showCalendar}`}
|
|
76
|
-
minuteInterval={1}
|
|
77
|
-
selected={date}
|
|
78
|
-
day={(date as Date).getDate()}
|
|
79
|
-
month={(date as Date).getMonth() + 1}
|
|
80
|
-
year={(date as Date).getFullYear()}
|
|
81
|
-
hour={(date as Date).getHours()}
|
|
82
|
-
minute={(date as Date).getMinutes()}
|
|
83
|
-
onSelected={(selected) => {
|
|
84
|
-
const formatted = dayjs(selected).format(format);
|
|
85
|
-
setDate(selected);
|
|
86
|
-
onDateChange(selected, formatted);
|
|
87
|
-
}}
|
|
88
|
-
showTime={showTime}
|
|
89
|
-
yearSpanMinus={yearSpanMinus}
|
|
90
|
-
yearSpanPlus={yearSpanPlus}
|
|
91
|
-
closeable
|
|
92
|
-
onClose={hideDatePicker}
|
|
93
|
-
controls={id}
|
|
94
|
-
limitStart={limitStart}
|
|
95
|
-
limitEnd={limitEnd}
|
|
96
|
-
/>
|
|
97
|
-
</div>
|
|
98
|
-
)}
|
|
99
|
-
</div>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
AUDatepickerComponent.defaultProps = {
|
|
104
|
-
date: new Date(),
|
|
105
|
-
format: 'YYYY-MM-DD HH:mm',
|
|
106
|
-
showTime: true,
|
|
107
|
-
lang: 'da',
|
|
108
|
-
showLabel: false,
|
|
109
|
-
labelInline: false,
|
|
110
|
-
labelText: 'Vælg dato:',
|
|
111
|
-
fullWidth: true,
|
|
112
|
-
yearSpanMinus: 5,
|
|
113
|
-
yearSpanPlus: 5,
|
|
114
|
-
limitStart: null,
|
|
115
|
-
limitEnd: null,
|
|
116
|
-
disabled: false,
|
|
117
|
-
sideBySideGrowth: 0,
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
AUDatepickerComponent.displayName = 'AUDatepickerComponent';
|
|
121
|
-
export default AUDatepickerComponent;
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
import React, { FC, useState } from 'react';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
import AUCalendarComponent from './AUCalendarComponent';
|
|
5
|
+
|
|
6
|
+
const AUDatepickerComponent: FC<AUDatepickerComponentProps> = ({
|
|
7
|
+
id,
|
|
8
|
+
lang,
|
|
9
|
+
date,
|
|
10
|
+
onDateChange,
|
|
11
|
+
onHide,
|
|
12
|
+
format,
|
|
13
|
+
showTime,
|
|
14
|
+
showLabel,
|
|
15
|
+
labelInline,
|
|
16
|
+
labelText,
|
|
17
|
+
fullWidth,
|
|
18
|
+
yearSpanMinus,
|
|
19
|
+
yearSpanPlus,
|
|
20
|
+
limitStart,
|
|
21
|
+
limitEnd,
|
|
22
|
+
disabled,
|
|
23
|
+
sideBySideGrowth,
|
|
24
|
+
}: AUDatepickerComponentProps) => {
|
|
25
|
+
const [showCalendar, setShowCalendar] = useState(false);
|
|
26
|
+
const [sDate, setDate] = useState<Date>(date as Date);
|
|
27
|
+
const dateFormatted = dayjs(sDate).format(format);
|
|
28
|
+
|
|
29
|
+
const hideDatePicker = () => {
|
|
30
|
+
setShowCalendar(false);
|
|
31
|
+
onHide(sDate, dateFormatted);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
let className = 'datepicker form__field';
|
|
35
|
+
if (fullWidth) {
|
|
36
|
+
className = `${className} form__field--full-width`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (labelInline) {
|
|
40
|
+
className = `${className} form__field--inline-label`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (disabled) {
|
|
44
|
+
className = `${className} visually-disabled`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (typeof sideBySideGrowth !== 'undefined' && sideBySideGrowth > 0) {
|
|
48
|
+
className = `${className} form__field--width-relative-${sideBySideGrowth}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
className={className}
|
|
54
|
+
aria-owns={`${id}-calendar`}
|
|
55
|
+
aria-haspopup="true"
|
|
56
|
+
aria-expanded={showCalendar}
|
|
57
|
+
>
|
|
58
|
+
{showLabel && <label htmlFor={id}>{labelText}</label>}
|
|
59
|
+
<input
|
|
60
|
+
id={id}
|
|
61
|
+
type="text"
|
|
62
|
+
value={dateFormatted}
|
|
63
|
+
title={
|
|
64
|
+
lang === 'da'
|
|
65
|
+
? 'Klik for at åbne datovælger'
|
|
66
|
+
: 'Click to open datepicker'
|
|
67
|
+
}
|
|
68
|
+
readOnly
|
|
69
|
+
disabled={disabled}
|
|
70
|
+
onClick={() => setShowCalendar(!showCalendar)}
|
|
71
|
+
/>
|
|
72
|
+
{showCalendar && (
|
|
73
|
+
<div className="datepicker__calendar-container">
|
|
74
|
+
<AUCalendarComponent
|
|
75
|
+
key={`${showCalendar}`}
|
|
76
|
+
minuteInterval={1}
|
|
77
|
+
selected={date}
|
|
78
|
+
day={(date as Date).getDate()}
|
|
79
|
+
month={(date as Date).getMonth() + 1}
|
|
80
|
+
year={(date as Date).getFullYear()}
|
|
81
|
+
hour={(date as Date).getHours()}
|
|
82
|
+
minute={(date as Date).getMinutes()}
|
|
83
|
+
onSelected={(selected) => {
|
|
84
|
+
const formatted = dayjs(selected).format(format);
|
|
85
|
+
setDate(selected);
|
|
86
|
+
onDateChange(selected, formatted);
|
|
87
|
+
}}
|
|
88
|
+
showTime={showTime}
|
|
89
|
+
yearSpanMinus={yearSpanMinus}
|
|
90
|
+
yearSpanPlus={yearSpanPlus}
|
|
91
|
+
closeable
|
|
92
|
+
onClose={hideDatePicker}
|
|
93
|
+
controls={id}
|
|
94
|
+
limitStart={limitStart}
|
|
95
|
+
limitEnd={limitEnd}
|
|
96
|
+
/>
|
|
97
|
+
</div>
|
|
98
|
+
)}
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
AUDatepickerComponent.defaultProps = {
|
|
104
|
+
date: new Date(),
|
|
105
|
+
format: 'YYYY-MM-DD HH:mm',
|
|
106
|
+
showTime: true,
|
|
107
|
+
lang: 'da',
|
|
108
|
+
showLabel: false,
|
|
109
|
+
labelInline: false,
|
|
110
|
+
labelText: 'Vælg dato:',
|
|
111
|
+
fullWidth: true,
|
|
112
|
+
yearSpanMinus: 5,
|
|
113
|
+
yearSpanPlus: 5,
|
|
114
|
+
limitStart: null,
|
|
115
|
+
limitEnd: null,
|
|
116
|
+
disabled: false,
|
|
117
|
+
sideBySideGrowth: 0,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
AUDatepickerComponent.displayName = 'AUDatepickerComponent';
|
|
121
|
+
export default AUDatepickerComponent;
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { SerializedError } from '@reduxjs/toolkit';
|
|
2
|
-
import { FetchBaseQueryError } from '@reduxjs/toolkit/dist/query';
|
|
3
|
-
import React, { FC } from 'react';
|
|
4
|
-
import AUNotificationComponent from './AUNotificationComponent';
|
|
5
|
-
|
|
6
|
-
interface AUErrorComponentExtendedProps extends AUErrorComponentProps {
|
|
7
|
-
fetchError?: FetchBaseQueryError,
|
|
8
|
-
serializedError?: SerializedError,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const AUErrorComponent: FC<AUErrorComponentExtendedProps> = ({
|
|
12
|
-
error: auError,
|
|
13
|
-
fetchError,
|
|
14
|
-
serializedError,
|
|
15
|
-
withStatus,
|
|
16
|
-
}: AUErrorComponentExtendedProps) => {
|
|
17
|
-
if (auError) {
|
|
18
|
-
const { status, header, message } = auError;
|
|
19
|
-
return (
|
|
20
|
-
<AUNotificationComponent
|
|
21
|
-
type="warning"
|
|
22
|
-
header={`${withStatus ? `${status}: ` : ''}${header}`}
|
|
23
|
-
content={[
|
|
24
|
-
<p dangerouslySetInnerHTML={{ __html: message }} />,
|
|
25
|
-
]}
|
|
26
|
-
/>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
if (fetchError && 'error' in fetchError) {
|
|
30
|
-
const { status, error } = fetchError;
|
|
31
|
-
return (
|
|
32
|
-
<AUNotificationComponent
|
|
33
|
-
type="warning"
|
|
34
|
-
header={withStatus ? status : undefined}
|
|
35
|
-
content={[
|
|
36
|
-
<p dangerouslySetInnerHTML={{ __html: error }} />,
|
|
37
|
-
]}
|
|
38
|
-
/>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
if (fetchError && 'data' in fetchError) {
|
|
42
|
-
const { status, data } = fetchError;
|
|
43
|
-
return (
|
|
44
|
-
<AUNotificationComponent
|
|
45
|
-
type="warning"
|
|
46
|
-
header={withStatus ? `${status}` : undefined}
|
|
47
|
-
content={[
|
|
48
|
-
<p dangerouslySetInnerHTML={{ __html: JSON.stringify(data) }} />,
|
|
49
|
-
]}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
if (serializedError && 'message' in serializedError) {
|
|
54
|
-
const { code, message } = serializedError;
|
|
55
|
-
return (
|
|
56
|
-
<AUNotificationComponent
|
|
57
|
-
type="warning"
|
|
58
|
-
header={withStatus ? code : undefined}
|
|
59
|
-
content={[
|
|
60
|
-
<p dangerouslySetInnerHTML={{ __html: message || '' }} />,
|
|
61
|
-
]}
|
|
62
|
-
/>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
AUErrorComponent.defaultProps = {
|
|
69
|
-
// eslint-disable-next-line react/default-props-match-prop-types
|
|
70
|
-
error: undefined,
|
|
71
|
-
fetchError: undefined,
|
|
72
|
-
serializedError: undefined,
|
|
73
|
-
// eslint-disable-next-line react/default-props-match-prop-types
|
|
74
|
-
withStatus: false,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
AUErrorComponent.displayName = 'AUErrorComponent';
|
|
78
|
-
export default AUErrorComponent;
|
|
1
|
+
import { SerializedError } from '@reduxjs/toolkit';
|
|
2
|
+
import { FetchBaseQueryError } from '@reduxjs/toolkit/dist/query';
|
|
3
|
+
import React, { FC } from 'react';
|
|
4
|
+
import AUNotificationComponent from './AUNotificationComponent';
|
|
5
|
+
|
|
6
|
+
interface AUErrorComponentExtendedProps extends AUErrorComponentProps {
|
|
7
|
+
fetchError?: FetchBaseQueryError,
|
|
8
|
+
serializedError?: SerializedError,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const AUErrorComponent: FC<AUErrorComponentExtendedProps> = ({
|
|
12
|
+
error: auError,
|
|
13
|
+
fetchError,
|
|
14
|
+
serializedError,
|
|
15
|
+
withStatus,
|
|
16
|
+
}: AUErrorComponentExtendedProps) => {
|
|
17
|
+
if (auError) {
|
|
18
|
+
const { status, header, message } = auError;
|
|
19
|
+
return (
|
|
20
|
+
<AUNotificationComponent
|
|
21
|
+
type="warning"
|
|
22
|
+
header={`${withStatus ? `${status}: ` : ''}${header}`}
|
|
23
|
+
content={[
|
|
24
|
+
<p dangerouslySetInnerHTML={{ __html: message }} />,
|
|
25
|
+
]}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
if (fetchError && 'error' in fetchError) {
|
|
30
|
+
const { status, error } = fetchError;
|
|
31
|
+
return (
|
|
32
|
+
<AUNotificationComponent
|
|
33
|
+
type="warning"
|
|
34
|
+
header={withStatus ? status : undefined}
|
|
35
|
+
content={[
|
|
36
|
+
<p dangerouslySetInnerHTML={{ __html: error }} />,
|
|
37
|
+
]}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
if (fetchError && 'data' in fetchError) {
|
|
42
|
+
const { status, data } = fetchError;
|
|
43
|
+
return (
|
|
44
|
+
<AUNotificationComponent
|
|
45
|
+
type="warning"
|
|
46
|
+
header={withStatus ? `${status}` : undefined}
|
|
47
|
+
content={[
|
|
48
|
+
<p dangerouslySetInnerHTML={{ __html: JSON.stringify(data) }} />,
|
|
49
|
+
]}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (serializedError && 'message' in serializedError) {
|
|
54
|
+
const { code, message } = serializedError;
|
|
55
|
+
return (
|
|
56
|
+
<AUNotificationComponent
|
|
57
|
+
type="warning"
|
|
58
|
+
header={withStatus ? code : undefined}
|
|
59
|
+
content={[
|
|
60
|
+
<p dangerouslySetInnerHTML={{ __html: message || '' }} />,
|
|
61
|
+
]}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
AUErrorComponent.defaultProps = {
|
|
69
|
+
// eslint-disable-next-line react/default-props-match-prop-types
|
|
70
|
+
error: undefined,
|
|
71
|
+
fetchError: undefined,
|
|
72
|
+
serializedError: undefined,
|
|
73
|
+
// eslint-disable-next-line react/default-props-match-prop-types
|
|
74
|
+
withStatus: false,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
AUErrorComponent.displayName = 'AUErrorComponent';
|
|
78
|
+
export default AUErrorComponent;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
|
|
3
|
-
const AUMobilePrefixComponent: FC<AUMobilePrefixComponentProps> = ({
|
|
4
|
-
countryCodes,
|
|
5
|
-
important,
|
|
6
|
-
}: AUMobilePrefixComponentProps) => {
|
|
7
|
-
const renderCountryCodes = (codes:AU.ICountryCode[]) => codes.map(c => <option key={c.da} value={`+${c.code}`}>{`${c.da} (+${c.code})`}</option>);
|
|
8
|
-
if (important) {
|
|
9
|
-
return <>{renderCountryCodes(countryCodes.filter(c => c.important))}</>;
|
|
10
|
-
}
|
|
11
|
-
return <>{renderCountryCodes(countryCodes)}</>;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
AUMobilePrefixComponent.displayName = 'AUMobilePrefixComponent';
|
|
15
|
-
export default AUMobilePrefixComponent;
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
const AUMobilePrefixComponent: FC<AUMobilePrefixComponentProps> = ({
|
|
4
|
+
countryCodes,
|
|
5
|
+
important,
|
|
6
|
+
}: AUMobilePrefixComponentProps) => {
|
|
7
|
+
const renderCountryCodes = (codes:AU.ICountryCode[]) => codes.map(c => <option key={c.da} value={`+${c.code}`}>{`${c.da} (+${c.code})`}</option>);
|
|
8
|
+
if (important) {
|
|
9
|
+
return <>{renderCountryCodes(countryCodes.filter(c => c.important))}</>;
|
|
10
|
+
}
|
|
11
|
+
return <>{renderCountryCodes(countryCodes)}</>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
AUMobilePrefixComponent.displayName = 'AUMobilePrefixComponent';
|
|
15
|
+
export default AUMobilePrefixComponent;
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
/* eslint jsx-a11y/click-events-have-key-events: 0 */
|
|
3
|
-
/* eslint jsx-a11y/no-noninteractive-element-interactions: 0 */
|
|
4
|
-
/* eslint jsx-a11y/no-static-element-interactions: 0 */
|
|
5
|
-
import React, { FC } from 'react';
|
|
6
|
-
import ReactDOM from 'react-dom';
|
|
7
|
-
import AUButtonComponent from './AUButtonComponent';
|
|
8
|
-
import { useModal } from '../lib/hooks';
|
|
9
|
-
|
|
10
|
-
const AUModalComponent: FC<AUModalComponentProps> = ({
|
|
11
|
-
lang,
|
|
12
|
-
domId,
|
|
13
|
-
className,
|
|
14
|
-
children,
|
|
15
|
-
closeButton,
|
|
16
|
-
closeButtonDisabled,
|
|
17
|
-
sender,
|
|
18
|
-
show,
|
|
19
|
-
onClose,
|
|
20
|
-
}: AUModalComponentProps) => {
|
|
21
|
-
useModal(domId, sender, show, !closeButtonDisabled, onClose);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
ReactDOM.createPortal(
|
|
25
|
-
<div
|
|
26
|
-
id={domId}
|
|
27
|
-
className={className}
|
|
28
|
-
>
|
|
29
|
-
<div className="modal-view__wrapper theme--normal">
|
|
30
|
-
{
|
|
31
|
-
closeButton && (
|
|
32
|
-
<AUButtonComponent
|
|
33
|
-
label={lang === 'da' ? 'Luk' : 'Close'}
|
|
34
|
-
disabled={closeButtonDisabled}
|
|
35
|
-
icon="close"
|
|
36
|
-
hideLabel
|
|
37
|
-
classNames={['modal-view__close']}
|
|
38
|
-
dataGtm="au-btn-modal-close"
|
|
39
|
-
onClick={() => {
|
|
40
|
-
if (typeof onClose === 'function') {
|
|
41
|
-
onClose();
|
|
42
|
-
}
|
|
43
|
-
}}
|
|
44
|
-
/>
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
<div className="modal-view__container">
|
|
48
|
-
<div className="modal-view__body">
|
|
49
|
-
{children}
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
</div>,
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
55
|
-
document.querySelector('body')!,
|
|
56
|
-
)
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
AUModalComponent.defaultProps = {
|
|
61
|
-
domId: 'modal-view1',
|
|
62
|
-
closeButton: true,
|
|
63
|
-
lang: 'da',
|
|
64
|
-
className: 'modal-view',
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
AUModalComponent.displayName = 'AUModalComponent';
|
|
68
|
-
export default AUModalComponent;
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
/* eslint jsx-a11y/click-events-have-key-events: 0 */
|
|
3
|
+
/* eslint jsx-a11y/no-noninteractive-element-interactions: 0 */
|
|
4
|
+
/* eslint jsx-a11y/no-static-element-interactions: 0 */
|
|
5
|
+
import React, { FC } from 'react';
|
|
6
|
+
import ReactDOM from 'react-dom';
|
|
7
|
+
import AUButtonComponent from './AUButtonComponent';
|
|
8
|
+
import { useModal } from '../lib/hooks';
|
|
9
|
+
|
|
10
|
+
const AUModalComponent: FC<AUModalComponentProps> = ({
|
|
11
|
+
lang,
|
|
12
|
+
domId,
|
|
13
|
+
className,
|
|
14
|
+
children,
|
|
15
|
+
closeButton,
|
|
16
|
+
closeButtonDisabled,
|
|
17
|
+
sender,
|
|
18
|
+
show,
|
|
19
|
+
onClose,
|
|
20
|
+
}: AUModalComponentProps) => {
|
|
21
|
+
useModal(domId, sender, show, !closeButtonDisabled, onClose);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
ReactDOM.createPortal(
|
|
25
|
+
<div
|
|
26
|
+
id={domId}
|
|
27
|
+
className={className}
|
|
28
|
+
>
|
|
29
|
+
<div className="modal-view__wrapper theme--normal">
|
|
30
|
+
{
|
|
31
|
+
closeButton && (
|
|
32
|
+
<AUButtonComponent
|
|
33
|
+
label={lang === 'da' ? 'Luk' : 'Close'}
|
|
34
|
+
disabled={closeButtonDisabled}
|
|
35
|
+
icon="close"
|
|
36
|
+
hideLabel
|
|
37
|
+
classNames={['modal-view__close']}
|
|
38
|
+
dataGtm="au-btn-modal-close"
|
|
39
|
+
onClick={() => {
|
|
40
|
+
if (typeof onClose === 'function') {
|
|
41
|
+
onClose();
|
|
42
|
+
}
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
<div className="modal-view__container">
|
|
48
|
+
<div className="modal-view__body">
|
|
49
|
+
{children}
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>,
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
55
|
+
document.querySelector('body')!,
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
AUModalComponent.defaultProps = {
|
|
61
|
+
domId: 'modal-view1',
|
|
62
|
+
closeButton: true,
|
|
63
|
+
lang: 'da',
|
|
64
|
+
className: 'modal-view',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
AUModalComponent.displayName = 'AUModalComponent';
|
|
68
|
+
export default AUModalComponent;
|