@aarhus-university/au-lib-react-components 11.5.1 → 11.6.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 (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 +29 -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,119 +1,145 @@
1
- /* eslint-disable import/prefer-default-export */
2
- import React from 'react';
3
- import { replace } from './helpers';
4
-
5
- const impersonationLabels = {
6
- IMPERSONATION_SELECT_OPTION_CPR: { da: 'CPR-nr.', en: 'CPR no.' },
7
- IMPERSONATION_SELECT_OPTION_EMAIL: { da: 'E-mail', en: 'Email' },
8
- IMPERSONATION_SELECT_OPTION_AUID: { da: 'AU-id', en: 'AU ID' },
9
- };
10
-
11
- declare global {
12
- interface Window {
13
- IMPERSONATE_AUID: string;
14
- IMPERSONATE_VALUE: string;
15
- IMPERSONATE_TYPE: string;
16
- PHASE: number;
17
- REAL_PHASE: number;
18
- authenticated: boolean;
19
- userContext: AU.IUserContext;
20
- impersonateError: boolean;
21
- }
22
- }
23
-
24
- const portals: (lang: string) => AU.IPortalContext[] = (lang: string) => [
25
- {
26
- name: 'mitstudie',
27
- impersonationSetup: {
28
- auid: window.IMPERSONATE_AUID,
29
- value: window.IMPERSONATE_VALUE,
30
- type: window.IMPERSONATE_TYPE,
31
- },
32
- impersonationOptions: [
33
- {
34
- value: 'auid',
35
- label: impersonationLabels.IMPERSONATION_SELECT_OPTION_AUID[lang],
36
- },
37
- ],
38
- deactivateFormContent: (
39
- activatedText: string,
40
- replaceText: string[],
41
- replaceWith: string[],
42
- portal: AU.IPortalContext,
43
- ) => (
44
- <>
45
- <div
46
- className="content-container vertical-spacing-bottom typography-dense"
47
- dangerouslySetInnerHTML={
48
- // eslint-disable-next-line max-len
49
- { __html: replace(activatedText, replaceText, replaceWith) }
50
- }
51
- />
52
- <input type="hidden" name="type" value={portal.impersonationSetup.type} />
53
- <input type="hidden" name="value" value={portal.impersonationSetup.value} />
54
- </>
55
- ),
56
- },
57
- {
58
- name: 'minansoegning',
59
- impersonationSetup: {
60
- auid: window.IMPERSONATE_AUID,
61
- value: window.IMPERSONATE_VALUE,
62
- type: window.IMPERSONATE_TYPE,
63
- phase: window.PHASE,
64
- realPhase: window.REAL_PHASE,
65
- },
66
- impersonationOptions: [
67
- {
68
- value: 'auid',
69
- label: impersonationLabels.IMPERSONATION_SELECT_OPTION_AUID[lang],
70
- },
71
- {
72
- value: 'cpr',
73
- label: impersonationLabels.IMPERSONATION_SELECT_OPTION_CPR[lang],
74
- },
75
- {
76
- value: 'email',
77
- label: impersonationLabels.IMPERSONATION_SELECT_OPTION_EMAIL[lang],
78
- },
79
- ],
80
- deactivateFormContent: (
81
- activatedText: string,
82
- replaceText: string[],
83
- replaceWith: string[],
84
- portal: AU.IPortalContext,
85
- ) => (
86
- <>
87
- <div
88
- className="content-container vertical-spacing-bottom typography-dense"
89
- dangerouslySetInnerHTML={
90
- // eslint-disable-next-line max-len
91
- { __html: replace(activatedText, replaceText, replaceWith) }
92
- }
93
- />
94
- <input type="hidden" name="type" value={portal.impersonationSetup.type} />
95
- <input type="hidden" name="value" value={portal.impersonationSetup.value} />
96
- <input type="hidden" name="phase" value={portal.impersonationSetup.phase} />
97
- </>
98
- ),
99
- },
100
- ];
101
-
102
- export const getPortalByName = (
103
- lang: string,
104
- name: string,
105
- ): AU.IPortalContext | null => portals(lang).find((portal) => portal.name === name) ?? null;
106
-
107
- export const impersonationPortalElement = document.querySelector('.page__pre-header');
108
-
109
- export const isImpersonating = (): boolean => {
110
- if (window.userContext == null) {
111
- return false;
112
- }
113
- if (window.userContext.impersonatedUser == null) {
114
- return false;
115
- }
116
- return true;
117
- };
118
-
119
- export const impersonationHasErrored = (): boolean => window.impersonateError;
1
+ /* eslint-disable import/prefer-default-export */
2
+ import React from 'react';
3
+ import { replace } from './helpers';
4
+
5
+ const impersonationLabels = {
6
+ IMPERSONATION_SELECT_OPTION_CPR: { da: 'CPR-nr.', en: 'CPR no.' },
7
+ IMPERSONATION_SELECT_OPTION_EMAIL: { da: 'E-mail', en: 'Email' },
8
+ IMPERSONATION_SELECT_OPTION_AUID: { da: 'AU-id', en: 'AU ID' },
9
+ };
10
+
11
+ declare global {
12
+ interface Window {
13
+ IMPERSONATE_AUID: string;
14
+ IMPERSONATE_VALUE: string;
15
+ IMPERSONATE_TYPE: string;
16
+ PHASE: number;
17
+ REAL_PHASE: number;
18
+ authenticated: boolean;
19
+ userContext: AU.IUserContext;
20
+ impersonateError: boolean;
21
+ }
22
+ }
23
+
24
+ const portals: (lang: string) => AU.IPortalContext[] = (lang: string) => [
25
+ {
26
+ name: 'mitstudie',
27
+ impersonationSetup: {
28
+ auid: window.IMPERSONATE_AUID,
29
+ value: window.IMPERSONATE_VALUE,
30
+ type: window.IMPERSONATE_TYPE,
31
+ },
32
+ impersonationOptions: [
33
+ {
34
+ value: 'auid',
35
+ label: impersonationLabels.IMPERSONATION_SELECT_OPTION_AUID[lang],
36
+ },
37
+ ],
38
+ deactivateFormContent: (
39
+ activatedText: string,
40
+ replaceText: string[],
41
+ replaceWith: string[],
42
+ portal: AU.IPortalContext,
43
+ ) => (
44
+ <>
45
+ <div
46
+ className="content-container vertical-spacing-bottom typography-dense"
47
+ dangerouslySetInnerHTML={
48
+ // eslint-disable-next-line max-len
49
+ { __html: replace(activatedText, replaceText, replaceWith) }
50
+ }
51
+ />
52
+ <input type="hidden" name="type" value={portal.impersonationSetup.type} />
53
+ <input type="hidden" name="value" value={portal.impersonationSetup.value} />
54
+ </>
55
+ ),
56
+ },
57
+ {
58
+ name: 'minansoegning',
59
+ impersonationSetup: {
60
+ auid: window.IMPERSONATE_AUID,
61
+ value: window.IMPERSONATE_VALUE,
62
+ type: window.IMPERSONATE_TYPE,
63
+ phase: window.PHASE,
64
+ realPhase: window.REAL_PHASE,
65
+ },
66
+ impersonationOptions: [
67
+ {
68
+ value: 'auid',
69
+ label: impersonationLabels.IMPERSONATION_SELECT_OPTION_AUID[lang],
70
+ },
71
+ {
72
+ value: 'cpr',
73
+ label: impersonationLabels.IMPERSONATION_SELECT_OPTION_CPR[lang],
74
+ },
75
+ {
76
+ value: 'email',
77
+ label: impersonationLabels.IMPERSONATION_SELECT_OPTION_EMAIL[lang],
78
+ },
79
+ ],
80
+ deactivateFormContent: (
81
+ activatedText: string,
82
+ replaceText: string[],
83
+ replaceWith: string[],
84
+ portal: AU.IPortalContext,
85
+ ) => (
86
+ <>
87
+ <div
88
+ className="content-container vertical-spacing-bottom typography-dense"
89
+ dangerouslySetInnerHTML={
90
+ // eslint-disable-next-line max-len
91
+ { __html: replace(activatedText, replaceText, replaceWith) }
92
+ }
93
+ />
94
+ <input type="hidden" name="type" value={portal.impersonationSetup.type} />
95
+ <input type="hidden" name="value" value={portal.impersonationSetup.value} />
96
+ <input type="hidden" name="phase" value={portal.impersonationSetup.phase} />
97
+ </>
98
+ ),
99
+ }, {
100
+ name: 'mitmedarbejdere',
101
+ impersonationSetup: {
102
+ auid: '',
103
+ value: '',
104
+ type: '',
105
+ },
106
+ impersonationOptions: [],
107
+ deactivateFormContent: (
108
+ activatedText: string,
109
+ replaceText: string[],
110
+ replaceWith: string[],
111
+ portal: AU.IPortalContext,
112
+ ) => (
113
+ <>
114
+ <div
115
+ className="content-container vertical-spacing-bottom typography-dense"
116
+ dangerouslySetInnerHTML={
117
+ // eslint-disable-next-line max-len
118
+ { __html: replace(activatedText, replaceText, replaceWith) }
119
+ }
120
+ />
121
+ <input type="hidden" name="type" value={portal.impersonationSetup.type} />
122
+ <input type="hidden" name="value" value={portal.impersonationSetup.value} />
123
+ </>
124
+ ),
125
+ },
126
+ ];
127
+
128
+ export const getPortalByName = (
129
+ lang: string,
130
+ name: string,
131
+ ): AU.IPortalContext | null => portals(lang).find((portal) => portal.name === name) ?? null;
132
+
133
+ export const impersonationPortalElement = document.querySelector('.page__pre-header');
134
+
135
+ export const isImpersonating = (): boolean => {
136
+ if (window.userContext == null) {
137
+ return false;
138
+ }
139
+ if (window.userContext.impersonatedUser == null) {
140
+ return false;
141
+ }
142
+ return true;
143
+ };
144
+
145
+ export const impersonationHasErrored = (): boolean => window.impersonateError;
@@ -1,69 +1,69 @@
1
- /* eslint-disable func-names */
2
- /* eslint-env browser */
3
- /* eslint-disable no-sequences */
4
- /* eslint-disable prefer-destructuring */
5
- /* eslint-disable no-param-reassign */
6
- /* eslint-disable prefer-rest-params */
7
- /* eslint-disable no-unused-expressions */
8
- /* eslint-disable dot-notation */
9
- /* eslint-disable wrap-iife */
10
- /*
11
- * Title: TRACKING
12
- * Description: Google Analytics tracking
13
- */
14
-
15
- class AUTracking {
16
- trackers: ITrackers[] = [
17
- {
18
- account: 'UA-2142081-1',
19
- name: 'default',
20
- },
21
- {
22
- account: 'UA-113308028-1',
23
- name: 'search',
24
- },
25
- ];
26
-
27
- constructor(trackers = []) {
28
- trackers.forEach((tracker) => this.trackers.push(tracker));
29
- this.init();
30
-
31
- this.trackSingle = this.trackSingle.bind(this);
32
- }
33
-
34
- init() {
35
- const gaNewElem: any = {};
36
- const gaElems: any = {};
37
- const currdate: any = new Date();
38
-
39
- ((i, s, o, g, r, a, m): void => {
40
- i['GoogleAnalyticsObject'] = r;
41
- i[r] = i[r] || function () {
42
- (i[r].q = i[r].q || []).push(arguments);
43
- }, i[r].l = 1 * currdate;
44
- a = s.createElement(o),
45
- m = s.getElementsByTagName(o)[0];
46
- a.async = 1;
47
- a.src = g;
48
- m.parentNode.insertBefore(a, m);
49
- })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga', gaNewElem, gaElems);
50
-
51
- this.trackers.forEach((tracker) => {
52
- window.ga('create', tracker.account, 'auto', tracker.name);
53
- window.ga(`${tracker.name}.require`, 'displayfeatures');
54
- window.ga(`${tracker.name}.require`, 'linkid', 'linkid.js');
55
- window.ga(`${tracker.name}.require`, 'GTM-MGFPHKR');
56
- window.ga(`${tracker.name}.set`, 'anonymizeIp', true);
57
-
58
- window.ga(`${tracker.name}.send`, 'pageview');
59
- });
60
- }
61
-
62
- trackSingle(trackerLink: string): void {
63
- if (typeof window.ga !== 'undefined') {
64
- this.trackers.forEach((tracker) => window.ga(`${tracker.name}.send`, 'pageview', trackerLink));
65
- }
66
- }
67
- }
68
-
69
- export default AUTracking;
1
+ /* eslint-disable func-names */
2
+ /* eslint-env browser */
3
+ /* eslint-disable no-sequences */
4
+ /* eslint-disable prefer-destructuring */
5
+ /* eslint-disable no-param-reassign */
6
+ /* eslint-disable prefer-rest-params */
7
+ /* eslint-disable no-unused-expressions */
8
+ /* eslint-disable dot-notation */
9
+ /* eslint-disable wrap-iife */
10
+ /*
11
+ * Title: TRACKING
12
+ * Description: Google Analytics tracking
13
+ */
14
+
15
+ class AUTracking {
16
+ trackers: ITrackers[] = [
17
+ {
18
+ account: 'UA-2142081-1',
19
+ name: 'default',
20
+ },
21
+ {
22
+ account: 'UA-113308028-1',
23
+ name: 'search',
24
+ },
25
+ ];
26
+
27
+ constructor(trackers = []) {
28
+ trackers.forEach((tracker) => this.trackers.push(tracker));
29
+ this.init();
30
+
31
+ this.trackSingle = this.trackSingle.bind(this);
32
+ }
33
+
34
+ init() {
35
+ const gaNewElem: any = {};
36
+ const gaElems: any = {};
37
+ const currdate: any = new Date();
38
+
39
+ ((i, s, o, g, r, a, m): void => {
40
+ i['GoogleAnalyticsObject'] = r;
41
+ i[r] = i[r] || function () {
42
+ (i[r].q = i[r].q || []).push(arguments);
43
+ }, i[r].l = 1 * currdate;
44
+ a = s.createElement(o),
45
+ m = s.getElementsByTagName(o)[0];
46
+ a.async = 1;
47
+ a.src = g;
48
+ m.parentNode.insertBefore(a, m);
49
+ })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga', gaNewElem, gaElems);
50
+
51
+ this.trackers.forEach((tracker) => {
52
+ window.ga('create', tracker.account, 'auto', tracker.name);
53
+ window.ga(`${tracker.name}.require`, 'displayfeatures');
54
+ window.ga(`${tracker.name}.require`, 'linkid', 'linkid.js');
55
+ window.ga(`${tracker.name}.require`, 'GTM-MGFPHKR');
56
+ window.ga(`${tracker.name}.set`, 'anonymizeIp', true);
57
+
58
+ window.ga(`${tracker.name}.send`, 'pageview');
59
+ });
60
+ }
61
+
62
+ trackSingle(trackerLink: string): void {
63
+ if (typeof window.ga !== 'undefined') {
64
+ this.trackers.forEach((tracker) => window.ga(`${tracker.name}.send`, 'pageview', trackerLink));
65
+ }
66
+ }
67
+ }
68
+
69
+ export default AUTracking;
@@ -1,21 +1,21 @@
1
- /* eslint-env browser */
2
- const getSourceForFrame = (
3
- serviceUrl: string,
4
- path: string,
5
- referrer: string,
6
- callback: (data: any) => void,
7
- ) => {
8
- const getSource = async (): Promise<void> => {
9
- const url = `${serviceUrl}?path=${path}&referrer=${referrer}`;
10
- const response = await fetch(url, {
11
- credentials: 'include',
12
- });
13
-
14
- const json = await response.json();
15
- callback(json);
16
- };
17
-
18
- getSource();
19
- };
20
-
21
- export default getSourceForFrame;
1
+ /* eslint-env browser */
2
+ const getSourceForFrame = (
3
+ serviceUrl: string,
4
+ path: string,
5
+ referrer: string,
6
+ callback: (data: any) => void,
7
+ ) => {
8
+ const getSource = async (): Promise<void> => {
9
+ const url = `${serviceUrl}?path=${path}&referrer=${referrer}`;
10
+ const response = await fetch(url, {
11
+ credentials: 'include',
12
+ });
13
+
14
+ const json = await response.json();
15
+ callback(json);
16
+ };
17
+
18
+ getSource();
19
+ };
20
+
21
+ export default getSourceForFrame;
@@ -1,11 +1,11 @@
1
- $font-passata-regular: "AUPassataRegular";
2
- $font-passata-bold: "AUPassataBold";
3
- $gray-color:#e4e4e4;
4
- $gray-secondary-color:darken($gray-color, 50%);
5
- $alert-confirm-color: #8bad3f;
6
- $alert-cancel-color: #687989;
7
- $student-color:#8bad3f;
8
- $student-secondary-color:#2a4a0f;
9
- $staff-color: #379fcb;
10
- $staff-secondary-color:#003e5c;
1
+ $font-passata-regular: "AUPassataRegular";
2
+ $font-passata-bold: "AUPassataBold";
3
+ $gray-color:#e4e4e4;
4
+ $gray-secondary-color:darken($gray-color, 50%);
5
+ $alert-confirm-color: #8bad3f;
6
+ $alert-cancel-color: #687989;
7
+ $student-color:#8bad3f;
8
+ $student-secondary-color:#2a4a0f;
9
+ $staff-color: #379fcb;
10
+ $staff-secondary-color:#003e5c;
11
11
  $findicon: 'https://cdn.au.dk/2016/assets/img/databox/find.png';