@aarhus-university/au-lib-react-components 11.5.1 → 11.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 (100) hide show
  1. package/.eslintrc.js +34 -34
  2. package/.storybook/main.js +20 -20
  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/AUErrorComponent.test.tsx +142 -142
  7. package/__tests__/jest/AUModalComponent.test.tsx +186 -186
  8. package/__tests__/jest/AUNotificationComponent.test.tsx +115 -115
  9. package/__tests__/jest/AUSpinnerComponent.test.tsx +57 -57
  10. package/__tests__/jest/AUToolbarComponent.test.tsx +46 -46
  11. package/__tests__/jest/context.test.ts +25 -25
  12. package/__tests__/jest/helpers.test.ts +15 -15
  13. package/__tests__/jest/setupTests.ts +2 -2
  14. package/babel.config.js +8 -8
  15. package/build/umd/all.css +2 -2
  16. package/build/umd/all.js +1 -1
  17. package/build/umd/alphabox.js +1 -1
  18. package/build/umd/databox.js +1 -1
  19. package/build/umd/diagramme.js +1 -1
  20. package/build/umd/flowbox.js +1 -1
  21. package/build/umd/universe.js +1 -1
  22. package/build-storybook.log +367 -367
  23. package/package.json +114 -114
  24. package/src/components/AUAlertComponent.tsx +113 -113
  25. package/src/components/AUAutoSuggestComponent.js +158 -158
  26. package/src/components/AUButtonComponent.tsx +87 -87
  27. package/src/components/AUCalendarComponent.tsx +493 -493
  28. package/src/components/AUContentToggleComponent.tsx +47 -47
  29. package/src/components/AUDatepickerComponent.tsx +121 -121
  30. package/src/components/AUEditFilterComponent.tsx +24 -67
  31. package/src/components/AUErrorComponent.tsx +78 -78
  32. package/src/components/AUMobilePrefixComponent.tsx +15 -15
  33. package/src/components/AUModalComponent.tsx +68 -68
  34. package/src/components/AUNotificationComponent.tsx +43 -43
  35. package/src/components/AUReceiptComponent.tsx +33 -33
  36. package/src/components/AUSpinnerComponent.tsx +36 -36
  37. package/src/components/AUStepComponent.tsx +47 -47
  38. package/src/components/AUSubNavComponent.tsx +48 -48
  39. package/src/components/AUSubmitButtonContainerComponent.tsx +30 -29
  40. package/src/components/AUTabbedContentComponent.tsx +145 -145
  41. package/src/components/AUTableComponent.tsx +24 -24
  42. package/src/components/AUToastComponent.tsx +104 -104
  43. package/src/components/AUToolbarComponent.tsx +101 -106
  44. package/src/components/AUTruncatorComponent.tsx +124 -124
  45. package/src/components/wrapping/AUEmbedComponent.js +47 -47
  46. package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +143 -143
  47. package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
  48. package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
  49. package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
  50. package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
  51. package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
  52. package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
  53. package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
  54. package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
  55. package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
  56. package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
  57. package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
  58. package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
  59. package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
  60. package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
  61. package/src/layout-2016/components/profile/AUProfileAvatar2016Component.js +103 -103
  62. package/src/layout-2016/components/universe/StaffTopComponent.js +363 -363
  63. package/src/layout-2016/components/universe/StudentTopComponent.js +137 -137
  64. package/src/layout-2016/components/universe/UniverseContainerComponent.js +65 -65
  65. package/src/layout-2016/lib/all.js +3 -3
  66. package/src/layout-2016/lib/au-alphabox.js +100 -100
  67. package/src/layout-2016/lib/au-databox.js +400 -400
  68. package/src/layout-2016/lib/au-diagramme.js +85 -85
  69. package/src/layout-2016/lib/au-flowbox.js +93 -93
  70. package/src/layout-2016/lib/universe.js +9 -9
  71. package/src/lib/context.tsx +51 -51
  72. package/src/lib/dates.ts +50 -50
  73. package/src/lib/helpers.ts +208 -208
  74. package/src/lib/hooks.ts +75 -75
  75. package/src/lib/i18n.ts +600 -600
  76. package/src/lib/portals.tsx +145 -119
  77. package/src/lib/tracking.ts +69 -69
  78. package/src/lib/wrapping.ts +21 -21
  79. package/src/styles/_settings.scss +10 -10
  80. package/src/styles/alphabox.scss +222 -222
  81. package/src/styles/app.scss +7 -7
  82. package/src/styles/autosuggest.scss +57 -57
  83. package/src/styles/databox.scss +563 -563
  84. package/src/styles/diagramme.scss +119 -119
  85. package/src/styles/flowbox.scss +72 -72
  86. package/src/styles/maps.scss +395 -395
  87. package/stories/AUAlertComponent.stories.tsx +120 -120
  88. package/stories/AUButtonComponent.stories.tsx +127 -127
  89. package/stories/AUContentToggleComponent.stories.tsx +63 -63
  90. package/stories/AUEditFilterComponent.stories.tsx +29 -29
  91. package/stories/AUErrorComponent.stories.tsx +98 -98
  92. package/stories/AUModalComponent.stories.tsx +84 -84
  93. package/stories/AUNotificationComponent.stories.tsx +116 -116
  94. package/stories/AUSpinnerComponent.stories.tsx +41 -41
  95. package/stories/AUStepComponent.stories.tsx +40 -40
  96. package/stories/AUToolbarComponent.stories.tsx +326 -327
  97. package/stories/AUTruncatorComponent.stories.tsx +101 -101
  98. package/stories/lib/helpers.tsx +128 -128
  99. package/tsconfig.json +46 -46
  100. 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,67 +1,24 @@
1
- /* eslint-disable jsx-a11y/label-has-associated-control */
2
- import React, { FC } from 'react';
3
-
4
- const AUEditFilterComponent: FC = () => (
5
- <form className="form">
6
- <h2>Rediger filter</h2>
7
- <div className="form__field">
8
- <label htmlFor="title">Titel</label>
9
- <input type="text" id="title" />
10
- </div>
11
- <h3>Kriterier</h3>
12
- <div>
13
- <div className="form__field">
14
- <label htmlFor="orgunit">
15
- Organisatorisk enhed
16
- </label>
17
- <input type="text" id="orgunit" />
18
- </div>
19
- <div className="search-filter">
20
- <h3 className="search-filter__label">Valgte enheder:</h3>
21
- <div className="search-filter__items">
22
- <button type="button" className="search-filter__item">
23
- <span className="search-filter__item__value">
24
- Arts
25
- </span>
26
- </button>
27
- <button type="button" className="search-filter__item">
28
- <span className="search-filter__item__value">
29
- Health
30
- </span>
31
- </button>
32
- </div>
33
- </div>
34
- </div>
35
- <div>
36
- <div className="form__field">
37
- <label htmlFor="orgunit">
38
- Uddannelser
39
- </label>
40
- <input type="text" id="orgunit" />
41
- </div>
42
- <div className="search-filter">
43
- <h3 className="search-filter__label">Valgte uddannelser:</h3>
44
- <div className="search-filter__items">
45
- <button type="button" className="search-filter__item">
46
- <span className="search-filter__item__value">
47
- Bacheloruddannelsen i Medicin
48
- </span>
49
- </button>
50
- <button type="button" className="search-filter__item">
51
- <span className="search-filter__item__value">
52
- Kandidatuddannelsen i Medicin
53
- </span>
54
- </button>
55
- <button type="button" className="search-filter__item">
56
- <span className="search-filter__item__value">
57
- Den sundhedsfaglige kandidatuddannelse
58
- </span>
59
- </button>
60
- </div>
61
- </div>
62
- </div>
63
- </form>
64
- );
65
-
66
- AUEditFilterComponent.displayName = 'AUEditFilterComponent';
67
- export default AUEditFilterComponent;
1
+ /* eslint-disable jsx-a11y/label-has-associated-control */
2
+ import React, { FC } from 'react';
3
+
4
+ const AUEditFilterComponent: FC = () => (
5
+ <form className="form">
6
+ <h2>Rediger filter</h2>
7
+ <div className="form__field">
8
+ <label htmlFor="title">Titel</label>
9
+ <input type="text" id="title" />
10
+ </div>
11
+ <h3>Kriterier</h3>
12
+ <div>
13
+ <div className="form__field">
14
+ <label htmlFor="orgunit">
15
+ Organisatorisk enhed
16
+ </label>
17
+ <input type="text" id="orgunit" />
18
+ </div>
19
+ </div>
20
+ </form>
21
+ );
22
+
23
+ AUEditFilterComponent.displayName = 'AUEditFilterComponent';
24
+ export default AUEditFilterComponent;
@@ -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;