@aarhus-university/au-lib-react-components 8.20.2 → 8.82.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 (167) hide show
  1. package/.eslintrc.js +44 -0
  2. package/README.md +19 -20
  3. package/babel.config.js +7 -0
  4. package/build/umd/all.css +1 -2
  5. package/build/umd/all.css.map +1 -1
  6. package/build/umd/all.js +1 -1
  7. package/build/umd/all.js.map +1 -1
  8. package/build/umd/alphabox.js +1 -1
  9. package/build/umd/alphabox.js.map +1 -1
  10. package/build/umd/databox.js +1 -6
  11. package/build/umd/databox.js.map +1 -1
  12. package/build/umd/diagramme.js +1 -1
  13. package/build/umd/diagramme.js.map +1 -1
  14. package/build/umd/flowbox.js +1 -1
  15. package/build/umd/flowbox.js.map +1 -1
  16. package/build/umd/universe.js +1 -1
  17. package/build/umd/universe.js.map +1 -1
  18. package/package.json +66 -65
  19. package/src/components/AUAlertComponent.tsx +70 -0
  20. package/src/components/{AutoSuggestComponent.js → AUAutoSuggestComponent.js} +45 -19
  21. package/src/components/AUCalendarComponent.tsx +493 -0
  22. package/src/components/AUContentToggleComponent.tsx +33 -0
  23. package/src/components/AUDatepickerComponent.tsx +117 -0
  24. package/src/components/AUMobilePrefixComponent.tsx +15 -0
  25. package/src/components/{delphinus/AUModalComponent.js → AUModalComponent.tsx} +78 -76
  26. package/src/components/{form/AUReceiptComponent.js → AUReceiptComponent.tsx} +33 -40
  27. package/src/components/AUSpinnerComponent.tsx +64 -0
  28. package/src/components/{delphinus/AUSubNavComponent.js → AUSubNavComponent.tsx} +38 -53
  29. package/src/components/{form/AUSubmitButtonContainerComponent.js → AUSubmitButtonContainerComponent.tsx} +31 -39
  30. package/src/components/AUTabbedContentComponent.tsx +145 -0
  31. package/src/components/{delphinus/AUTableComponent.js → AUTableComponent.tsx} +24 -28
  32. package/src/components/{delphinus/AUToastComponent.js → AUToastComponent.tsx} +104 -91
  33. package/src/components/{delphinus/AUToolbarComponent.js → AUToolbarComponent.tsx} +45 -48
  34. package/src/components/profile/AUProfileActions.js +128 -113
  35. package/src/components/profile/AUProfileAvatarComponent.js +83 -83
  36. package/src/components/profile/AUProfileAvatarV2Component.js +91 -0
  37. package/src/components/profile/AUProfileAvatarV3Component.tsx +42 -0
  38. package/src/components/profile/AUProfileContainerComponent.js +283 -285
  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.js → AUProfileLoginComponent.tsx} +3 -18
  43. package/src/components/profile/AUProfileMailComponent.js +307 -299
  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 -210
  48. package/src/components/profile/AUProfileWidgetComponent.js +95 -95
  49. package/src/components/profile/AUProfileWidgetV2Component.js +116 -0
  50. package/src/components/profile/AUProfileWidgetV3Component.tsx +122 -0
  51. package/src/components/wrapping/AUEmbedComponent.js +47 -47
  52. package/src/{components → layout-2016/components}/alphabox/AlphaBoxComponent.js +29 -28
  53. package/src/{components → layout-2016/components}/alphabox/AlphaBoxContentComponent.js +25 -14
  54. package/src/{components → layout-2016/components/common}/AUCollapsibleComponent.js +1 -22
  55. package/src/{components → layout-2016/components/common}/AUSpinnerComponent.js +2 -24
  56. package/src/{components → layout-2016/components}/databox/DataBoxAlphabetComponent.js +1 -1
  57. package/src/{components → layout-2016/components}/databox/DataBoxAssociationComponent.js +2 -2
  58. package/src/{components → layout-2016/components}/databox/DataBoxButtonComponent.js +7 -3
  59. package/src/{components → layout-2016/components}/databox/DataBoxComponent.js +2 -2
  60. package/src/{components → layout-2016/components}/databox/DataBoxGroupingComponent.js +2 -0
  61. package/src/{components → layout-2016/components}/databox/DataBoxSearchResultComponent.js +1 -5
  62. package/src/{components → layout-2016/components}/databox/DataBoxStackedAssociationComponent.js +1 -5
  63. package/src/{components → layout-2016/components}/databox/DataBoxSuggestionComponent.js +0 -0
  64. package/src/{components → layout-2016/components/diagramme}/AUDiagrammeComponent.js +5 -6
  65. package/src/{components → layout-2016/components}/flowbox/FlowBoxComponent.js +8 -8
  66. package/src/{components → layout-2016/components}/flowbox/FlowBoxPhoneComponent.js +3 -5
  67. package/src/{components → layout-2016/components}/profile/AUProfileAvatar2016Component.js +6 -2
  68. package/src/{components → layout-2016/components}/universe/StaffTopComponent.js +4 -3
  69. package/src/{components → layout-2016/components}/universe/StudentTopComponent.js +0 -0
  70. package/src/{components → layout-2016/components}/universe/UniverseContainerComponent.js +11 -8
  71. package/src/layout-2016/lib/all.js +3 -0
  72. package/src/{lib → layout-2016/lib}/au-alphabox.js +1 -3
  73. package/src/{lib → layout-2016/lib}/au-databox.js +6 -9
  74. package/src/{lib → layout-2016/lib}/au-diagramme.js +2 -4
  75. package/src/{lib → layout-2016/lib}/au-flowbox.js +1 -3
  76. package/src/{lib → layout-2016/lib}/universe.js +0 -0
  77. package/src/lib/{helpers.js → helpers.ts} +41 -66
  78. package/src/{components/delphinus/hooks.js → lib/hooks.ts} +33 -26
  79. package/src/lib/{i18n.js → i18n.ts} +600 -595
  80. package/src/lib/tracking.ts +69 -0
  81. package/src/lib/{wrapping.js → wrapping.ts} +21 -16
  82. package/src/styles/_settings.scss +11 -11
  83. package/src/styles/alphabox.scss +222 -209
  84. package/src/styles/app.scss +7 -12
  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 +396 -0
  90. package/tsconfig.json +47 -0
  91. package/types/common/interfaces.d.ts +91 -0
  92. package/types/common/main.d.ts +4 -0
  93. package/types/common/package.json +5 -0
  94. package/types/common/payloads.d.ts +0 -0
  95. package/types/common/props.d.ts +165 -0
  96. package/webpack.config.js +89 -0
  97. package/.eslintrc +0 -19
  98. package/DOCUMENTATION.md +0 -369
  99. package/build/cjs/auAuth.js +0 -2
  100. package/build/cjs/auAuth.js.map +0 -1
  101. package/build/dev.html +0 -329
  102. package/build/umd/auAuth.js +0 -2
  103. package/build/umd/auAuth.js.map +0 -1
  104. package/build/umd/news.js +0 -2
  105. package/build/umd/news.js.map +0 -1
  106. package/src/all.js +0 -3
  107. package/src/app.js +0 -263
  108. package/src/components/AUAlertComponent.js +0 -158
  109. package/src/components/AUAmountComponent.js +0 -84
  110. package/src/components/AUBannerComponent.js +0 -99
  111. package/src/components/AUCalendarComponent.js +0 -393
  112. package/src/components/AUDatepickerComponent.js +0 -105
  113. package/src/components/AUFilterCheckboxComponent.js +0 -122
  114. package/src/components/AUFocusComponent.js +0 -55
  115. package/src/components/AUModalComponent.js +0 -94
  116. package/src/components/AUPaginationComponent.js +0 -103
  117. package/src/components/context/AUUserContextComponent.js +0 -91
  118. package/src/components/context/ImpersonateComponent.js +0 -54
  119. package/src/components/delphinus/AUCalendarComponent.js +0 -422
  120. package/src/components/delphinus/AUContentToggleComponent.js +0 -32
  121. package/src/components/delphinus/AUDatepickerComponent.js +0 -113
  122. package/src/components/delphinus/AULoginComponent.js +0 -65
  123. package/src/components/delphinus/AUSpinnerComponent.js +0 -114
  124. package/src/components/delphinus/AUTabbedContentComponent.js +0 -53
  125. package/src/components/form/AUMobilePrefixComponent.js +0 -18
  126. package/src/components/news/EventLayout1Component.js +0 -94
  127. package/src/components/news/EventLayout2Component.js +0 -90
  128. package/src/components/news/EventLayout3Component.js +0 -68
  129. package/src/components/news/NewsCategoriesComponent.js +0 -21
  130. package/src/components/news/NewsCollageBannerComponent.js +0 -71
  131. package/src/components/news/NewsColumnsComponent.js +0 -125
  132. package/src/components/news/NewsLanguageChangeComponent.js +0 -74
  133. package/src/components/news/NewsLayout1Component.js +0 -80
  134. package/src/components/news/NewsLayout2Component.js +0 -80
  135. package/src/components/news/NewsLayout3Component.js +0 -81
  136. package/src/components/news/NewsLayout4Component.js +0 -80
  137. package/src/components/news/NewsLayout5Component.js +0 -61
  138. package/src/components/news/NewsLayout6Component.js +0 -55
  139. package/src/components/news/NewsLayout7Component.js +0 -58
  140. package/src/components/news/NewsLayout8Component.js +0 -57
  141. package/src/components/news/NewsListComponent.js +0 -291
  142. package/src/components/news/NewsPopUpComponent.js +0 -591
  143. package/src/components/news/NewsRSSComponent.js +0 -74
  144. package/src/components/news/NewsSocialComponent.js +0 -104
  145. package/src/components/news/NewsSubHeaderComponent.js +0 -19
  146. package/src/components/password/AUChangePasswordComponent.js +0 -177
  147. package/src/components/password/AUCurrentPasswordComponent.js +0 -72
  148. package/src/components/password/AUNewPasswordComponent.js +0 -143
  149. package/src/components/password/AUPasswordActions.js +0 -101
  150. package/src/components/password/AUPasswordHooks.js +0 -47
  151. package/src/components/password/AUPasswordReducer.js +0 -78
  152. package/src/components/password/AUPasswordRequirementsComponent.js +0 -29
  153. package/src/config/webpack.cjs.config.js +0 -75
  154. package/src/config/webpack.dev.config.js +0 -61
  155. package/src/config/webpack.umd.config.js +0 -107
  156. package/src/index.js +0 -6
  157. package/src/lib/au-auth.js +0 -221
  158. package/src/lib/au-news.js +0 -306
  159. package/src/lib/menu.js +0 -10
  160. package/src/lib/urlHandler.js +0 -63
  161. package/src/lib/validation.js +0 -181
  162. package/src/styles/alert.scss +0 -39
  163. package/src/styles/calendar.scss +0 -112
  164. package/src/styles/filtercheckbox.scss +0 -5
  165. package/src/styles/modal.scss +0 -35
  166. package/src/styles/pagination.scss +0 -11
  167. package/src/styles/spinner.scss +0 -30
@@ -1,422 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import moment from 'moment';
4
-
5
- const months = {
6
- da: ['Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December'],
7
- en: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
8
- };
9
- const dayTitles = {
10
- da: ['Man', 'Tir', 'Ons', 'Tor', 'Fre', 'Lør', 'Søn'],
11
- en: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
12
- };
13
-
14
- const daysInMonth = (year, month) => new Date(year, month, 0).getDate();
15
-
16
- const addDays = (days, date) => new Date(date.getTime() + days * 60 * 24 * 60000);
17
-
18
- const calcEaster = (year) => {
19
- const a = year % 19;
20
- const b = Math.floor(year / 100);
21
- const c = year % 100;
22
- const d = Math.floor(b / 4);
23
- const e = b % 4;
24
- const f = Math.floor((b + 8) / 25);
25
- const g = Math.floor((b - f + 1) / 3);
26
- const h = (19 * a + b - d - g + 15) % 30;
27
- const i = Math.floor(c / 4);
28
- const k = c % 4;
29
- const l = (32 + 2 * e + 2 * i - h - k) % 7;
30
- const m = Math.floor((a + 11 * h + 22 * l) / 451);
31
- const n0 = (h + l + 7 * m + 114);
32
- const n = Math.floor(n0 / 31) - 1;
33
- const p = (n0 % 31) + 1;
34
- const date = new Date(year, n, p);
35
- return date;
36
- };
37
-
38
- const isHoliday = (date) => {
39
- const year = date.getFullYear();
40
- const holidays = [];
41
- const newYear = new Date(year, 0, 1);
42
- holidays.push(newYear);
43
- const easter = calcEaster(year);
44
- holidays.push(easter);
45
- const easterThu = addDays(-3, easter);
46
- holidays.push(easterThu);
47
- const easterFri = addDays(-2, easter);
48
- holidays.push(easterFri);
49
- const easter2 = addDays(1, easter);
50
- holidays.push(easter2);
51
- const stBededag = addDays(26, easter);
52
- holidays.push(stBededag);
53
- const kristiHf = addDays(39, easter);
54
- holidays.push(kristiHf);
55
- const whitsun = addDays(49, easter);
56
- holidays.push(whitsun);
57
- const whitsun2 = addDays(1, whitsun);
58
- holidays.push(whitsun2);
59
- const grundlov = new Date(year, 5, 5);
60
- holidays.push(grundlov);
61
- const christmas = new Date(year, 11, 25);
62
- holidays.push(christmas);
63
- const christmas2 = addDays(1, christmas);
64
- holidays.push(christmas2);
65
-
66
- return holidays.map((h) => h.toString()).find((x) => x === date.toString());
67
- };
68
-
69
- class AUCalendarComponent extends React.Component {
70
- constructor(props) {
71
- super(props);
72
-
73
- this.state = {
74
- day: props.day,
75
- month: props.month,
76
- year: props.year,
77
- hour: props.hour,
78
- minute: props.minute,
79
- selected: props.selected,
80
- };
81
-
82
- this.skipDays = [6, 0, 1, 2, 3, 4, 5];
83
- this.goBack = this.goBack.bind(this);
84
- this.goForward = this.goForward.bind(this);
85
-
86
- moment.locale(props.lang);
87
- }
88
-
89
- goBack() {
90
- const { month, year } = this.state;
91
- const newMonth = month - 1 < 1 ? 12 : (month - 1);
92
- const newYear = newMonth === 12 ? (year - 1) : year;
93
- this.setState({
94
- month: newMonth,
95
- year: newYear,
96
- });
97
- }
98
-
99
- goForward() {
100
- const { month, year } = this.state;
101
- const newMonth = month + 1 > 12 ? 1 : (month + 1);
102
- const newYear = newMonth === 1 ? (year + 1) : year;
103
- this.setState({
104
- month: newMonth,
105
- year: newYear,
106
- });
107
- }
108
-
109
- render() {
110
- const {
111
- day,
112
- month,
113
- year,
114
- hour,
115
- minute,
116
- selected,
117
- } = this.state;
118
- const {
119
- lang,
120
- onSelected,
121
- highlightWeekend,
122
- highlightHolidays,
123
- yearSpan,
124
- minuteInterval,
125
- showTime,
126
- closeable,
127
- onClose,
128
- controls,
129
- } = this.props;
130
-
131
- const renderMonths = months[lang].map(
132
- (m, i) => (
133
- <option key={m} value={i + 1}>
134
- {m}
135
- </option>
136
- ),
137
- );
138
-
139
- const yearArr = [];
140
- for (let y = year - yearSpan; y <= year + yearSpan; y += 1) {
141
- yearArr.push(y);
142
- }
143
-
144
- const renderYears = yearArr.map(
145
- (y) => (
146
- <option key={y}>
147
- {y}
148
- </option>
149
- ),
150
- );
151
-
152
- const renderWeekDays = dayTitles[lang].map(
153
- (w) => (
154
- <span key={w} className="calendar__days__day">
155
- {w}
156
- </span>
157
- ),
158
- );
159
-
160
- const firstDayInMonth = new Date(year, month - 1, 1);
161
- const emptyDays = this.skipDays[firstDayInMonth.getDay()];
162
- const prevYear = month === 1 ? year - 1 : year;
163
- const prevMonth = month === 1 ? 12 : month - 1;
164
- const numberOfDaysInPrevMonth = daysInMonth(
165
- prevYear, prevMonth,
166
- );
167
-
168
- let rowCount = -1;
169
- const renderEmptyDaysBefore = Array(emptyDays).fill().map((e, i) => {
170
- rowCount = i;
171
- const beforeDay = numberOfDaysInPrevMonth - emptyDays + i + 1;
172
- const isWeekend = (highlightWeekend && rowCount > 4)
173
- || (highlightHolidays
174
- && isHoliday(new Date(prevYear, prevMonth - 1, beforeDay)));
175
- return (
176
- <button
177
- type="button"
178
- key={rowCount}
179
- className={`calendar__days__date ${isWeekend ? 'calendar__days__date--weekend calendar__days__date--empty' : 'calendar__days__date--empty'}`}
180
- onClick={() => {
181
- this.goBack();
182
- }}
183
- aria-label={moment(new Date(prevYear, prevMonth - 1, beforeDay)).format('LL')}
184
- >
185
- {beforeDay}
186
- </button>
187
- );
188
- });
189
-
190
- const renderDays = Array(daysInMonth(year, month)).fill().map((d, i) => {
191
- const key = i; // suck it
192
- if (rowCount === 6) {
193
- rowCount = 0;
194
- } else {
195
- rowCount += 1;
196
- }
197
- const newDay = i + 1;
198
- const isSelected = (
199
- newDay === selected.getDate()
200
- && year === selected.getFullYear()
201
- && month === selected.getMonth() + 1
202
- );
203
- const isWeekend = (highlightWeekend && rowCount > 4)
204
- || (highlightHolidays && isHoliday(new Date(year, month - 1, newDay)));
205
- let className = 'calendar__days__date';
206
- if (isSelected) {
207
- className = `${className} calendar__days__date--selected`;
208
- }
209
- if (isWeekend) {
210
- className = `${className} calendar__days__date--weekend`;
211
- }
212
- return (
213
- <button
214
- key={key}
215
- type="button"
216
- className={className}
217
- onClick={() => {
218
- const newSelected = new Date(year, month - 1, newDay, hour, minute);
219
- this.setState({
220
- day: newDay,
221
- selected: newSelected,
222
- }, () => {
223
- onSelected(newSelected);
224
- });
225
- }}
226
- aria-label={moment(new Date(year, month - 1, newDay, hour, minute)).format('LL')}
227
- >
228
- {i + 1}
229
- </button>
230
- );
231
- });
232
-
233
- const nextYear = month === 12 ? (year + 1) : year;
234
- const nextMonth = month === 12 ? 1 : (month + 1);
235
- const renderEmptyDaysAfter = Array(6 - rowCount).fill().map((e, i) => {
236
- const key = i;
237
- const afterDay = i + 1;
238
- if (rowCount === 6) {
239
- rowCount = 0;
240
- } else {
241
- rowCount += 1;
242
- }
243
- const isWeekend = (highlightWeekend && rowCount > 4)
244
- || (highlightHolidays
245
- && isHoliday(new Date(nextYear, nextMonth - 1, afterDay)));
246
- return (
247
- <button
248
- type="button"
249
- key={key}
250
- className={`calendar__days__date ${isWeekend ? 'calendar__days__date--weekend calendar__days__date--empty' : 'calendar__days__date--empty'}`}
251
- onClick={() => {
252
- this.goForward();
253
- }}
254
- aria-label={moment(new Date(nextYear, nextMonth - 1, afterDay)).format('LL')}
255
- >
256
- {afterDay}
257
- </button>
258
- );
259
- });
260
-
261
- const renderHours = Array(24).fill().map((h, i) => {
262
- const key = i;
263
- const optHour = i < 10 ? `0${i}` : i;
264
- return (
265
- <option key={key} value={i}>
266
- {optHour}
267
- </option>
268
- );
269
- });
270
-
271
- const renderMinutes = Array(60).fill().map((h, i) => {
272
- const key = i;
273
- if (i % minuteInterval === 0) {
274
- const optMinute = i < 10 ? `0${i}` : i;
275
- return (
276
- <option key={key} value={i}>
277
- {optMinute}
278
- </option>
279
- );
280
- }
281
- return null;
282
- });
283
-
284
- return (
285
- <div id={`${controls}-calendar`} className="calendar" aria-controls={controls}>
286
- <div className="calendar__year-month">
287
- <div className="form__field">
288
- <select
289
- value={month}
290
- title={lang === 'da' ? 'Vælg måned' : 'Select month'}
291
- onChange={(e) => {
292
- const newMonth = parseInt(e.target.value, 10);
293
- const newSelected = new Date(year, newMonth - 1, day, hour, minute);
294
- this.setState({
295
- month: newMonth,
296
- selected: newSelected,
297
- }, () => {
298
- onSelected(newSelected);
299
- });
300
- }}
301
- >
302
- {renderMonths}
303
- </select>
304
- </div>
305
- <div className="form__field">
306
- <select
307
- value={year}
308
- title={lang === 'da' ? 'Vælg år' : 'Select year'}
309
- onChange={(e) => {
310
- const newYear = parseInt(e.target.value, 10);
311
- const newSelected = new Date(newYear, month - 1, day, hour, minute);
312
- this.setState({
313
- year: newYear,
314
- selected: newSelected,
315
- }, () => {
316
- onSelected(newSelected);
317
- });
318
- }}
319
- >
320
- {renderYears}
321
- </select>
322
- </div>
323
- {
324
- closeable && (
325
- <button
326
- className="button button--icon--hide-label button--small button--icon"
327
- type="button"
328
- data-icon=""
329
- onClick={onClose}
330
- >
331
- {lang === 'da' ? 'Luk' : 'Close'}
332
- </button>
333
- )
334
- }
335
- </div>
336
- <div className="calendar__days">
337
- {renderWeekDays}
338
- {renderEmptyDaysBefore}
339
- {renderDays}
340
- {renderEmptyDaysAfter}
341
- </div>
342
- {
343
- showTime && (
344
- <div className="calendar__time">
345
- <div className="form__field">
346
- <select
347
- value={hour}
348
- title={lang === 'da' ? 'Vælg time' : 'Select hour'}
349
- onChange={(e) => {
350
- const newHour = parseInt(e.target.value, 10);
351
- const newSelected = new Date(year, month - 1, day, newHour, minute);
352
- this.setState({
353
- hour: newHour,
354
- selected: newSelected,
355
- }, () => {
356
- onSelected(newSelected);
357
- });
358
- }}
359
- >
360
- {renderHours}
361
- </select>
362
- </div>
363
- <div className="form__field">
364
- <select
365
- value={minute}
366
- title={lang === 'da' ? 'Vælg minut' : 'Select minute'}
367
- onChange={(e) => {
368
- const newMinute = parseInt(e.target.value, 10);
369
- const newSelected = new Date(year, month - 1, day, hour, newMinute);
370
- this.setState({
371
- minute: parseInt(e.target.value, 10),
372
- selected: newSelected,
373
- }, () => {
374
- onSelected(newSelected);
375
- });
376
- }}
377
- >
378
- {renderMinutes}
379
- </select>
380
- </div>
381
- </div>
382
- )
383
- }
384
- </div>
385
- );
386
- }
387
- }
388
-
389
- AUCalendarComponent.defaultProps = {
390
- lang: 'da',
391
- selected: new Date(),
392
- onSelected: () => { },
393
- highlightWeekend: true,
394
- highlightHolidays: true,
395
- yearSpan: 5,
396
- minuteInterval: 5,
397
- showTime: true,
398
- closeable: false,
399
- onClose: () => { },
400
- };
401
-
402
- AUCalendarComponent.propTypes = {
403
- lang: PropTypes.string,
404
- selected: PropTypes.instanceOf(Date),
405
- day: PropTypes.number.isRequired,
406
- month: PropTypes.number.isRequired,
407
- year: PropTypes.number.isRequired,
408
- hour: PropTypes.number.isRequired,
409
- minute: PropTypes.number.isRequired,
410
- highlightWeekend: PropTypes.bool,
411
- highlightHolidays: PropTypes.bool,
412
- onSelected: PropTypes.func,
413
- yearSpan: PropTypes.number,
414
- minuteInterval: PropTypes.number,
415
- showTime: PropTypes.bool,
416
- closeable: PropTypes.bool,
417
- onClose: PropTypes.func,
418
- controls: PropTypes.string.isRequired,
419
- };
420
-
421
- AUCalendarComponent.displayName = 'AUCalendarComponent';
422
- export default AUCalendarComponent;
@@ -1,32 +0,0 @@
1
- import React, { useEffect, useRef } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { setContentToggle } from '@aarhus-university/au-designsystem-delphinus/source/js/components/content-toggle';
4
-
5
- const AUContentToggleComponent = ({ toggled, classNames, children }) => {
6
- const toggleContainer = useRef();
7
- useEffect(() => {
8
- const toggle = toggleContainer.current.querySelector('.content-toggle__content');
9
- if (toggle) {
10
- const button = setContentToggle(toggle);
11
- button.setAttribute('aria-expanded', toggled);
12
- }
13
- }, []);
14
- return (
15
- <div ref={toggleContainer} className={classNames}>
16
- {children}
17
- </div>
18
- );
19
- };
20
-
21
- AUContentToggleComponent.defaultProps = {
22
- children: null,
23
- classNames: null,
24
- };
25
-
26
- AUContentToggleComponent.propTypes = {
27
- children: PropTypes.element,
28
- toggled: PropTypes.bool.isRequired,
29
- classNames: PropTypes.string,
30
- };
31
- AUContentToggleComponent.displayName = 'AUContentToggleComponent';
32
- export default AUContentToggleComponent;
@@ -1,113 +0,0 @@
1
- /* eslint-env browser */
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
- import moment from 'moment';
5
- import AUCalendarComponent from './AUCalendarComponent';
6
-
7
- class AUDatepickerComponent extends React.Component {
8
- constructor(props) {
9
- super(props);
10
-
11
- this.state = {
12
- showCalendar: false,
13
- date: props.date,
14
- dateFormatted: props.date ? moment(props.date).format(props.format) : '',
15
- };
16
-
17
- this.hideDatePicker = this.hideDatePicker.bind(this);
18
- }
19
-
20
- hideDatePicker() {
21
- const { onHide } = this.props;
22
- const { date, dateFormatted } = this.state;
23
- this.setState({
24
- showCalendar: false,
25
- }, () => {
26
- onHide(date, dateFormatted);
27
- });
28
- }
29
-
30
- render() {
31
- const { showCalendar, dateFormatted } = this.state;
32
- let { date } = this.state;
33
- if (!date) {
34
- date = new Date();
35
- }
36
- const {
37
- onDateChange,
38
- format,
39
- showTime,
40
- id,
41
- lang,
42
- } = this.props;
43
- return (
44
- <div className="datepicker" aria-owns={`${id}-calendar`} aria-haspopup="true" aria-expanded={showCalendar}>
45
- <div className="form__field">
46
- <input
47
- id={id}
48
- type="text"
49
- value={dateFormatted}
50
- title={lang === 'da' ? 'Klik for at åbne datovælger' : 'Click to open datepicker'}
51
- readOnly
52
- onClick={() => {
53
- this.setState((prevState) => ({
54
- showCalendar: !prevState.showCalendar,
55
- }));
56
- }}
57
- />
58
- </div>
59
- {
60
- showCalendar && (
61
- <div className="datepicker__calendar-container">
62
- <AUCalendarComponent
63
- key={showCalendar}
64
- minuteInterval={1}
65
- selected={date}
66
- day={date.getDate()}
67
- month={date.getMonth() + 1}
68
- year={date.getFullYear()}
69
- hour={date.getHours()}
70
- minute={date.getMinutes()}
71
- onSelected={(selected) => {
72
- const formatted = moment(selected).format(format);
73
- this.setState({
74
- date: selected,
75
- dateFormatted: formatted,
76
- }, () => {
77
- onDateChange(selected, formatted);
78
- });
79
- }}
80
- showTime={showTime}
81
- closeable
82
- onClose={this.hideDatePicker}
83
- controls={id}
84
- />
85
- </div>
86
- )
87
- }
88
- </div>
89
- );
90
- }
91
- }
92
-
93
- AUDatepickerComponent.defaultProps = {
94
- date: null,
95
- onDateChange: () => { },
96
- onHide: () => { },
97
- format: 'YYYY-MM-DD HH:mm',
98
- showTime: true,
99
- lang: 'da',
100
- };
101
-
102
- AUDatepickerComponent.propTypes = {
103
- id: PropTypes.string.isRequired,
104
- lang: PropTypes.string,
105
- date: PropTypes.instanceOf(Date),
106
- onDateChange: PropTypes.func,
107
- onHide: PropTypes.func,
108
- format: PropTypes.string,
109
- showTime: PropTypes.bool,
110
- };
111
-
112
- AUDatepickerComponent.displayName = 'AUDatepickerComponent';
113
- export default AUDatepickerComponent;
@@ -1,65 +0,0 @@
1
- /* eslint-env browser */
2
- import React, { useEffect } from 'react';
3
- import PropTypes from 'prop-types';
4
-
5
- const mitstudieLabels = {
6
- da: {
7
- frontHeadline: 'Mit studie',
8
- frontText: 'En samlet indgang til dit studieoverblik, studieinformation<br />og selvbetjeningssystemer.',
9
- signIn: 'Log ind',
10
- },
11
- en: {
12
- frontHeadline: 'My studies',
13
- frontText: 'A single point of access to study information and self-service systems.',
14
- signIn: 'Sign in',
15
- },
16
- };
17
-
18
- const AULoginComponent = ({ labels, signInUri, notification }) => {
19
- useEffect(() => {
20
- document.querySelector('main').classList.remove('theme--normal');
21
- const pageNavTop = document.querySelector('.page__navigation-top');
22
- if (pageNavTop) {
23
- pageNavTop.classList.remove('theme--normal');
24
- }
25
- }, []);
26
- const redirectUri = window.location.pathname;
27
- return (
28
- <>
29
- <div className="page__content__block">
30
- <h1>
31
- <strong>
32
- {labels[window.appLang].frontHeadline}
33
- </strong>
34
- </h1>
35
- <p className="text--intro" dangerouslySetInnerHTML={{ __html: labels[window.appLang].frontText }} />
36
- <a
37
- className="button button--large"
38
- href={`/${window.appLang}/${signInUri}?redirectUri=${redirectUri}`}
39
- >
40
- {labels[window.appLang].signIn}
41
- </a>
42
- </div>
43
- {notification}
44
- </>
45
- );
46
- };
47
-
48
- AULoginComponent.defaultProps = {
49
- labels: mitstudieLabels,
50
- signInUri: 'account/signin',
51
- notification: null,
52
- };
53
-
54
- AULoginComponent.propTypes = {
55
- labels: PropTypes.shape({
56
- frontHeadline: PropTypes.string.isRequired,
57
- frontText: PropTypes.string.isRequired,
58
- signIn: PropTypes.string.isRequired,
59
- }),
60
- signInUri: PropTypes.string,
61
- notification: PropTypes.element,
62
- };
63
-
64
- AULoginComponent.displayName = 'AULoginComponent';
65
- export default AULoginComponent;