@aarhus-university/au-lib-react-components 10.6.0 → 10.9.0

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 (97) hide show
  1. package/.eslintrc.js +34 -34
  2. package/.storybook/main.js +20 -7
  3. package/.storybook/preview.js +10 -10
  4. package/README.md +19 -19
  5. package/__tests__/jest/AUButtonComponent.test.tsx +165 -163
  6. package/__tests__/jest/AUErrorComponent.test.tsx +142 -0
  7. package/__tests__/jest/AUModalComponent.test.tsx +186 -0
  8. package/__tests__/jest/AUNotificationComponent.test.tsx +115 -0
  9. package/__tests__/jest/AUSpinnerComponent.test.tsx +57 -57
  10. package/__tests__/jest/AUToolbarComponent.test.tsx +46 -0
  11. package/__tests__/jest/helpers.test.ts +15 -15
  12. package/__tests__/jest/setupTests.ts +2 -2
  13. package/babel.config.js +8 -8
  14. package/build/umd/universe.js.map +1 -1
  15. package/package.json +108 -107
  16. package/src/components/AUAlertComponent.tsx +70 -70
  17. package/src/components/AUAutoSuggestComponent.js +158 -158
  18. package/src/components/AUButtonComponent.tsx +83 -77
  19. package/src/components/AUCalendarComponent.tsx +493 -493
  20. package/src/components/AUContentToggleComponent.tsx +33 -33
  21. package/src/components/AUDatepickerComponent.tsx +117 -117
  22. package/src/components/AUErrorComponent.tsx +78 -0
  23. package/src/components/AUMobilePrefixComponent.tsx +15 -15
  24. package/src/components/AUModalComponent.tsx +64 -80
  25. package/src/components/AUNotificationComponent.tsx +42 -0
  26. package/src/components/AUReceiptComponent.tsx +33 -33
  27. package/src/components/AUSpinnerComponent.tsx +33 -33
  28. package/src/components/AUSubNavComponent.tsx +48 -48
  29. package/src/components/AUSubmitButtonContainerComponent.tsx +31 -31
  30. package/src/components/AUTabbedContentComponent.tsx +145 -145
  31. package/src/components/AUTableComponent.tsx +24 -24
  32. package/src/components/AUToastComponent.tsx +103 -103
  33. package/src/components/AUToolbarComponent.tsx +52 -45
  34. package/src/components/profile/AUProfileActions.js +128 -128
  35. package/src/components/profile/AUProfileAvatarComponent.js +83 -83
  36. package/src/components/profile/AUProfileAvatarV2Component.js +91 -91
  37. package/src/components/profile/AUProfileAvatarV3Component.tsx +42 -42
  38. package/src/components/profile/AUProfileContainerComponent.js +283 -283
  39. package/src/components/profile/AUProfileHooks.js +30 -30
  40. package/src/components/profile/AUProfileItemComponent.js +54 -54
  41. package/src/components/profile/AUProfileLanguageComponent.js +131 -131
  42. package/src/components/profile/AUProfileLoginComponent.tsx +26 -26
  43. package/src/components/profile/AUProfileMailComponent.js +307 -307
  44. package/src/components/profile/AUProfileMobileComponent.js +164 -164
  45. package/src/components/profile/AUProfileNameComponent.js +253 -253
  46. package/src/components/profile/AUProfileNextOfKinComponent.js +216 -216
  47. package/src/components/profile/AUProfileReducer.js +230 -230
  48. package/src/components/profile/AUProfileWidgetComponent.js +95 -95
  49. package/src/components/profile/AUProfileWidgetV2Component.js +116 -116
  50. package/src/components/profile/AUProfileWidgetV3Component.tsx +122 -122
  51. package/src/components/wrapping/AUEmbedComponent.js +47 -47
  52. package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +143 -143
  53. package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
  54. package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
  55. package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
  56. package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
  57. package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
  58. package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
  59. package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
  60. package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
  61. package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
  62. package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
  63. package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
  64. package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
  65. package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
  66. package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
  67. package/src/layout-2016/components/profile/AUProfileAvatar2016Component.js +103 -103
  68. package/src/layout-2016/components/universe/StaffTopComponent.js +363 -363
  69. package/src/layout-2016/components/universe/StudentTopComponent.js +137 -137
  70. package/src/layout-2016/components/universe/UniverseContainerComponent.js +65 -65
  71. package/src/layout-2016/lib/all.js +3 -3
  72. package/src/layout-2016/lib/au-alphabox.js +100 -100
  73. package/src/layout-2016/lib/au-databox.js +400 -400
  74. package/src/layout-2016/lib/au-diagramme.js +85 -85
  75. package/src/layout-2016/lib/au-flowbox.js +93 -93
  76. package/src/layout-2016/lib/universe.js +9 -9
  77. package/src/lib/helpers.ts +194 -194
  78. package/src/lib/hooks.ts +37 -33
  79. package/src/lib/i18n.ts +600 -600
  80. package/src/lib/tracking.ts +69 -69
  81. package/src/lib/wrapping.ts +21 -21
  82. package/src/styles/_settings.scss +10 -10
  83. package/src/styles/alphabox.scss +222 -222
  84. package/src/styles/app.scss +7 -7
  85. package/src/styles/autosuggest.scss +57 -57
  86. package/src/styles/databox.scss +563 -563
  87. package/src/styles/diagramme.scss +119 -119
  88. package/src/styles/flowbox.scss +72 -72
  89. package/src/styles/maps.scss +395 -395
  90. package/stories/AUButtonComponent.stories.tsx +85 -85
  91. package/stories/AUErrorComponent.stories.tsx +117 -0
  92. package/stories/AUModalComponent.stories.tsx +92 -0
  93. package/stories/AUNotificationComponent.stories.tsx +116 -0
  94. package/stories/AUSpinnerComponent.stories.tsx +41 -41
  95. package/stories/AUToolbarComponent.stories.tsx +96 -0
  96. package/tsconfig.json +46 -46
  97. package/webpack.config.js +89 -89
@@ -1,54 +1,54 @@
1
- /* eslint-disable react/no-array-index-key */
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
-
5
- const AUProfileItemComponent = ({
6
- header,
7
- values,
8
- empty,
9
- linkElement,
10
- appendix,
11
- }) => {
12
- const renderValues = values.map((value, i) => <div key={`${value}-${i}`} className="settings-list__item__value">{value}</div>);
13
- const renderEmpty = empty.map((e) => <div key={e} className="settings-list__item__value settings-list__item__value--empty">{e}</div>);
14
- return (
15
- <li className="settings-list__item">
16
- {(() => {
17
- if (appendix) {
18
- return (
19
- <div className="settings-list__item__label settings-list__item__label--with-appendix">
20
- <span>{header}</span>
21
- {appendix}
22
- </div>
23
- );
24
- }
25
- return (
26
- <div className="settings-list__item__label">
27
- {header}
28
- </div>
29
- );
30
- })()}
31
- <div className="settings-list__item__values">
32
- {renderValues}
33
- {renderEmpty}
34
- </div>
35
- {linkElement}
36
- </li>
37
- );
38
- };
39
-
40
- AUProfileItemComponent.defaultProps = {
41
- empty: [],
42
- appendix: null,
43
- };
44
-
45
- AUProfileItemComponent.propTypes = {
46
- header: PropTypes.string.isRequired,
47
- values: PropTypes.arrayOf(PropTypes.string).isRequired,
48
- empty: PropTypes.arrayOf(PropTypes.string),
49
- linkElement: PropTypes.element.isRequired,
50
- appendix: PropTypes.element,
51
- };
52
-
53
- AUProfileItemComponent.displayName = 'AUProfileItemComponent';
54
- export default AUProfileItemComponent;
1
+ /* eslint-disable react/no-array-index-key */
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+
5
+ const AUProfileItemComponent = ({
6
+ header,
7
+ values,
8
+ empty,
9
+ linkElement,
10
+ appendix,
11
+ }) => {
12
+ const renderValues = values.map((value, i) => <div key={`${value}-${i}`} className="settings-list__item__value">{value}</div>);
13
+ const renderEmpty = empty.map((e) => <div key={e} className="settings-list__item__value settings-list__item__value--empty">{e}</div>);
14
+ return (
15
+ <li className="settings-list__item">
16
+ {(() => {
17
+ if (appendix) {
18
+ return (
19
+ <div className="settings-list__item__label settings-list__item__label--with-appendix">
20
+ <span>{header}</span>
21
+ {appendix}
22
+ </div>
23
+ );
24
+ }
25
+ return (
26
+ <div className="settings-list__item__label">
27
+ {header}
28
+ </div>
29
+ );
30
+ })()}
31
+ <div className="settings-list__item__values">
32
+ {renderValues}
33
+ {renderEmpty}
34
+ </div>
35
+ {linkElement}
36
+ </li>
37
+ );
38
+ };
39
+
40
+ AUProfileItemComponent.defaultProps = {
41
+ empty: [],
42
+ appendix: null,
43
+ };
44
+
45
+ AUProfileItemComponent.propTypes = {
46
+ header: PropTypes.string.isRequired,
47
+ values: PropTypes.arrayOf(PropTypes.string).isRequired,
48
+ empty: PropTypes.arrayOf(PropTypes.string),
49
+ linkElement: PropTypes.element.isRequired,
50
+ appendix: PropTypes.element,
51
+ };
52
+
53
+ AUProfileItemComponent.displayName = 'AUProfileItemComponent';
54
+ export default AUProfileItemComponent;
@@ -1,131 +1,131 @@
1
- /* eslint-env browser */
2
- /* eslint-disable jsx-a11y/label-has-associated-control */
3
- /* eslint-disable jsx-a11y/label-has-for */
4
- /* eslint-disable max-len */
5
- import React, { useState, useEffect } from 'react';
6
- import PropTypes from 'prop-types';
7
- import { Link } from 'react-router-dom';
8
- import AUSubmitButtonContainerComponent from '../form/AUSubmitButtonContainerComponent';
9
- import { useProfileForm } from './AUProfileHooks';
10
- import { scrollTo } from '../../lib/helpers';
11
- import { profileLabels } from '../../lib/i18n';
12
-
13
- const AUProfileLanguageComponent = ({
14
- lang,
15
- routeProps: { history },
16
- path,
17
- preferredLanguage: pPreferredLanguage,
18
- onSave,
19
- onSaveAction,
20
- saving,
21
- saved,
22
- dismissMessages,
23
- clear,
24
- }) => {
25
- const [preferredLanguage, setLanguage] = useState(pPreferredLanguage);
26
- const [onCancel] = useProfileForm(saved, history, lang, clear);
27
-
28
- useEffect(() => {
29
- scrollTo();
30
- dismissMessages();
31
- }, []);
32
-
33
- return [
34
- <div key="header" className="list-navigator">
35
- <h1 className="list-navigator__header">{profileLabels[lang].headerLanguage}</h1>
36
- <Link className="list-navigator__list-name" to={path}>{profileLabels[lang].headerContainer}</Link>
37
- </div>,
38
- <form key="form" className="form" noValidate="novalidate">
39
- <fieldset>
40
- <legend>
41
- <div className="fieldset__legend-wrapper">
42
- {profileLabels[lang].languageLegend}
43
- <div className="form-info__hint">
44
- {profileLabels[lang].legendNameHint}
45
- </div>
46
- </div>
47
- </legend>
48
- <div className="form__field form__field--horizontal">
49
- <label htmlFor="language-da">
50
- Dansk
51
- </label>
52
- <input
53
- type="radio"
54
- id="language-da"
55
- checked={preferredLanguage === 'da'}
56
- onChange={() => {
57
- setLanguage('da');
58
- }}
59
- disabled={saving}
60
- />
61
- </div>
62
- <div className="form__field form__field--horizontal">
63
- <label htmlFor="language-en">
64
- English
65
- </label>
66
- <input
67
- type="radio"
68
- id="language-en"
69
- checked={preferredLanguage === 'en'}
70
- onChange={() => {
71
- setLanguage('en');
72
- }}
73
- disabled={saving}
74
- />
75
- </div>
76
- </fieldset>
77
- <AUSubmitButtonContainerComponent
78
- lang={pPreferredLanguage}
79
- disabled={saving}
80
- onSubmit={(e) => {
81
- e.preventDefault();
82
- onSave({
83
- preferredLanguage,
84
- }, onSaveAction);
85
- }}
86
- onCancel={onCancel}
87
- />
88
- </form>,
89
- ];
90
- };
91
-
92
- AUProfileLanguageComponent.defaultProps = {
93
- onSaveAction: (data, callback) => {
94
- const putData = async () => {
95
- let url = `${window.profileApiUri}/UpdatePreferredLanguage`;
96
- if (typeof window.API_AUID !== 'undefined') {
97
- url = `${url}?auid=${window.API_AUID}`;
98
- }
99
- const response = await fetch(url, {
100
- method: 'PUT',
101
- credentials: 'include',
102
- headers: {
103
- 'Content-Type': 'application/json',
104
- },
105
- body: JSON.stringify(data),
106
- });
107
- const json = await response.json();
108
- callback(response.ok, response.status, json);
109
-
110
- // clear context cache
111
- window.auAuth.setUserContext(window.API_AUID || 0, 'profile-clear-cache', true, () => {}, () => {}, true, window.authenticated);
112
- };
113
- putData();
114
- },
115
- };
116
-
117
- AUProfileLanguageComponent.propTypes = {
118
- lang: PropTypes.string.isRequired,
119
- routeProps: PropTypes.shape({}).isRequired,
120
- path: PropTypes.string.isRequired,
121
- preferredLanguage: PropTypes.string.isRequired,
122
- onSave: PropTypes.func.isRequired,
123
- onSaveAction: PropTypes.func,
124
- saving: PropTypes.bool.isRequired,
125
- saved: PropTypes.bool.isRequired,
126
- dismissMessages: PropTypes.func.isRequired,
127
- clear: PropTypes.func.isRequired,
128
- };
129
-
130
- AUProfileLanguageComponent.displayName = 'AUProfileLanguageComponent';
131
- export default AUProfileLanguageComponent;
1
+ /* eslint-env browser */
2
+ /* eslint-disable jsx-a11y/label-has-associated-control */
3
+ /* eslint-disable jsx-a11y/label-has-for */
4
+ /* eslint-disable max-len */
5
+ import React, { useState, useEffect } from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import { Link } from 'react-router-dom';
8
+ import AUSubmitButtonContainerComponent from '../form/AUSubmitButtonContainerComponent';
9
+ import { useProfileForm } from './AUProfileHooks';
10
+ import { scrollTo } from '../../lib/helpers';
11
+ import { profileLabels } from '../../lib/i18n';
12
+
13
+ const AUProfileLanguageComponent = ({
14
+ lang,
15
+ routeProps: { history },
16
+ path,
17
+ preferredLanguage: pPreferredLanguage,
18
+ onSave,
19
+ onSaveAction,
20
+ saving,
21
+ saved,
22
+ dismissMessages,
23
+ clear,
24
+ }) => {
25
+ const [preferredLanguage, setLanguage] = useState(pPreferredLanguage);
26
+ const [onCancel] = useProfileForm(saved, history, lang, clear);
27
+
28
+ useEffect(() => {
29
+ scrollTo();
30
+ dismissMessages();
31
+ }, []);
32
+
33
+ return [
34
+ <div key="header" className="list-navigator">
35
+ <h1 className="list-navigator__header">{profileLabels[lang].headerLanguage}</h1>
36
+ <Link className="list-navigator__list-name" to={path}>{profileLabels[lang].headerContainer}</Link>
37
+ </div>,
38
+ <form key="form" className="form" noValidate="novalidate">
39
+ <fieldset>
40
+ <legend>
41
+ <div className="fieldset__legend-wrapper">
42
+ {profileLabels[lang].languageLegend}
43
+ <div className="form-info__hint">
44
+ {profileLabels[lang].legendNameHint}
45
+ </div>
46
+ </div>
47
+ </legend>
48
+ <div className="form__field form__field--horizontal">
49
+ <label htmlFor="language-da">
50
+ Dansk
51
+ </label>
52
+ <input
53
+ type="radio"
54
+ id="language-da"
55
+ checked={preferredLanguage === 'da'}
56
+ onChange={() => {
57
+ setLanguage('da');
58
+ }}
59
+ disabled={saving}
60
+ />
61
+ </div>
62
+ <div className="form__field form__field--horizontal">
63
+ <label htmlFor="language-en">
64
+ English
65
+ </label>
66
+ <input
67
+ type="radio"
68
+ id="language-en"
69
+ checked={preferredLanguage === 'en'}
70
+ onChange={() => {
71
+ setLanguage('en');
72
+ }}
73
+ disabled={saving}
74
+ />
75
+ </div>
76
+ </fieldset>
77
+ <AUSubmitButtonContainerComponent
78
+ lang={pPreferredLanguage}
79
+ disabled={saving}
80
+ onSubmit={(e) => {
81
+ e.preventDefault();
82
+ onSave({
83
+ preferredLanguage,
84
+ }, onSaveAction);
85
+ }}
86
+ onCancel={onCancel}
87
+ />
88
+ </form>,
89
+ ];
90
+ };
91
+
92
+ AUProfileLanguageComponent.defaultProps = {
93
+ onSaveAction: (data, callback) => {
94
+ const putData = async () => {
95
+ let url = `${window.profileApiUri}/UpdatePreferredLanguage`;
96
+ if (typeof window.API_AUID !== 'undefined') {
97
+ url = `${url}?auid=${window.API_AUID}`;
98
+ }
99
+ const response = await fetch(url, {
100
+ method: 'PUT',
101
+ credentials: 'include',
102
+ headers: {
103
+ 'Content-Type': 'application/json',
104
+ },
105
+ body: JSON.stringify(data),
106
+ });
107
+ const json = await response.json();
108
+ callback(response.ok, response.status, json);
109
+
110
+ // clear context cache
111
+ window.auAuth.setUserContext(window.API_AUID || 0, 'profile-clear-cache', true, () => {}, () => {}, true, window.authenticated);
112
+ };
113
+ putData();
114
+ },
115
+ };
116
+
117
+ AUProfileLanguageComponent.propTypes = {
118
+ lang: PropTypes.string.isRequired,
119
+ routeProps: PropTypes.shape({}).isRequired,
120
+ path: PropTypes.string.isRequired,
121
+ preferredLanguage: PropTypes.string.isRequired,
122
+ onSave: PropTypes.func.isRequired,
123
+ onSaveAction: PropTypes.func,
124
+ saving: PropTypes.bool.isRequired,
125
+ saved: PropTypes.bool.isRequired,
126
+ dismissMessages: PropTypes.func.isRequired,
127
+ clear: PropTypes.func.isRequired,
128
+ };
129
+
130
+ AUProfileLanguageComponent.displayName = 'AUProfileLanguageComponent';
131
+ export default AUProfileLanguageComponent;
@@ -1,26 +1,26 @@
1
- /* eslint-env browser */
2
- import React, { FC } from 'react';
3
-
4
- const AUProfileLoginComponent: FC<AUProfileLoginComponentProps> = ({
5
- loggedIn,
6
- loginUri,
7
- children,
8
- text,
9
- }: AUProfileLoginComponentProps) => {
10
- if (!loggedIn) {
11
- return (
12
- <a
13
- className="nav__item nav__item--icon nav__item--icon--right nav__item--icon--always-show-label"
14
- data-icon=""
15
- href={loginUri}
16
- >
17
- {text}
18
- </a>
19
- );
20
- }
21
-
22
- return children;
23
- };
24
-
25
- AUProfileLoginComponent.displayName = 'AUProfileLoginComponent';
26
- export default AUProfileLoginComponent;
1
+ /* eslint-env browser */
2
+ import React, { FC } from 'react';
3
+
4
+ const AUProfileLoginComponent: FC<AUProfileLoginComponentProps> = ({
5
+ loggedIn,
6
+ loginUri,
7
+ children,
8
+ text,
9
+ }: AUProfileLoginComponentProps) => {
10
+ if (!loggedIn) {
11
+ return (
12
+ <a
13
+ className="nav__item nav__item--icon nav__item--icon--right nav__item--icon--always-show-label"
14
+ data-icon=""
15
+ href={loginUri}
16
+ >
17
+ {text}
18
+ </a>
19
+ );
20
+ }
21
+
22
+ return children;
23
+ };
24
+
25
+ AUProfileLoginComponent.displayName = 'AUProfileLoginComponent';
26
+ export default AUProfileLoginComponent;