@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,393 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- const months = ['Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December'];
5
- const dayTitles = ['Man', 'Tir', 'Ons', 'Tor', 'Fre', 'Lør', 'Søn'];
6
-
7
- /**
8
- * AU Kalender Komponent
9
- *
10
- * Eksempel:
11
- * ```jsx
12
- * <AUCalendarComponent />
13
- * ```
14
- */
15
-
16
- class AUCalendarComponent extends React.Component {
17
- static daysInMonth(year, month) {
18
- return new Date(year, month, 0).getDate();
19
- // Month er 0-index, så det, man returnerer, er reelt sidste dag i foregående måned:
20
- // Fx er juni = 5, så første dag i måned 5 er 1. juni, mens 0. dag i måned 5 er 31. maj.
21
- }
22
-
23
- static calcEaster(year) {
24
- const a = year % 19;
25
- const b = Math.floor(year / 100);
26
- const c = year % 100;
27
- const d = Math.floor(b / 4);
28
- const e = b % 4;
29
- const f = Math.floor((b + 8) / 25);
30
- const g = Math.floor((b - f + 1) / 3);
31
- const h = (19 * a + b - d - g + 15) % 30;
32
- const i = Math.floor(c / 4);
33
- const k = c % 4;
34
- const l = (32 + 2 * e + 2 * i - h - k) % 7;
35
- const m = Math.floor((a + 11 * h + 22 * l) / 451);
36
- const n0 = (h + l + 7 * m + 114);
37
- const n = Math.floor(n0 / 31) - 1;
38
- const p = (n0 % 31) + 1;
39
- const date = new Date(year, n, p);
40
- return date;
41
- }
42
-
43
- static addDays(days, date) {
44
- return new Date(date.getTime() + days * 60 * 24 * 60000);
45
- }
46
-
47
- static isHoliday(date) {
48
- const year = date.getFullYear();
49
- const holidays = [];
50
- const newYear = new Date(year, 0, 1);
51
- holidays.push(newYear);
52
- const easter = AUCalendarComponent.calcEaster(year);
53
- holidays.push(easter);
54
- const easterThu = AUCalendarComponent.addDays(-3, easter);
55
- holidays.push(easterThu);
56
- const easterFri = AUCalendarComponent.addDays(-2, easter);
57
- holidays.push(easterFri);
58
- const easter2 = AUCalendarComponent.addDays(1, easter);
59
- holidays.push(easter2);
60
- const stBededag = AUCalendarComponent.addDays(26, easter);
61
- holidays.push(stBededag);
62
- const kristiHf = AUCalendarComponent.addDays(39, easter);
63
- holidays.push(kristiHf);
64
- const whitsun = AUCalendarComponent.addDays(49, easter);
65
- holidays.push(whitsun);
66
- const whitsun2 = AUCalendarComponent.addDays(1, whitsun);
67
- holidays.push(whitsun2);
68
- const grundlov = new Date(year, 5, 5);
69
- holidays.push(grundlov);
70
- const christmas = new Date(year, 11, 25);
71
- holidays.push(christmas);
72
- const christmas2 = AUCalendarComponent.addDays(1, christmas);
73
- holidays.push(christmas2);
74
-
75
- return holidays.map((h) => h.toString()).find((x) => x === date.toString());
76
- }
77
-
78
- constructor(props) {
79
- super(props);
80
-
81
- this.state = {
82
- day: props.day,
83
- month: props.month,
84
- year: props.year,
85
- hour: props.hour,
86
- minute: props.minute,
87
- selected: props.selected,
88
- };
89
-
90
- this.skipDays = [6, 0, 1, 2, 3, 4, 5];
91
- this.goBack = this.goBack.bind(this);
92
- this.goForward = this.goForward.bind(this);
93
- }
94
-
95
- goBack() {
96
- const { month, year } = this.state;
97
- const newMonth = month - 1 < 1 ? 12 : (month - 1);
98
- const newYear = newMonth === 12 ? (year - 1) : year;
99
- this.setState({
100
- month: newMonth,
101
- year: newYear,
102
- });
103
- }
104
-
105
- goForward() {
106
- const { month, year } = this.state;
107
- const newMonth = month + 1 > 12 ? 1 : (month + 1);
108
- const newYear = newMonth === 1 ? (year + 1) : year;
109
- this.setState({
110
- month: newMonth,
111
- year: newYear,
112
- });
113
- }
114
-
115
- render() {
116
- const {
117
- day,
118
- month,
119
- year,
120
- hour,
121
- minute,
122
- selected,
123
- } = this.state;
124
- const {
125
- onSelected,
126
- highlightWeekend,
127
- highlightHolidays,
128
- yearSpan,
129
- minuteInterval,
130
- showTime,
131
- } = this.props;
132
-
133
- const renderMonths = months.map(
134
- (m, i) => (
135
- <option key={m} value={i + 1}>
136
- {m}
137
- </option>
138
- ),
139
- );
140
-
141
- const yearArr = [];
142
- for (let y = year - yearSpan; y <= year + yearSpan; y += 1) {
143
- yearArr.push(y);
144
- }
145
-
146
- const renderYears = yearArr.map(
147
- (y) => (
148
- <option key={y}>
149
- {y}
150
- </option>
151
- ),
152
- );
153
-
154
- const renderWeekDays = dayTitles.map(
155
- (w) => (
156
- <span key={w}>
157
- {w}
158
- </span>
159
- ),
160
- );
161
-
162
- const firstDayInMonth = new Date(year, month - 1, 1);
163
- const emptyDays = this.skipDays[firstDayInMonth.getDay()];
164
- const prevYear = month === 1 ? year - 1 : year;
165
- const prevMonth = month === 1 ? 12 : month - 1;
166
- const numberOfDaysInPrevMonth = AUCalendarComponent.daysInMonth(
167
- prevYear, prevMonth,
168
- );
169
-
170
- let rowCount = -1;
171
- const renderEmptyDaysBefore = Array(emptyDays).fill().map((e, i) => {
172
- rowCount = i;
173
- const beforeDay = numberOfDaysInPrevMonth - emptyDays + i + 1;
174
- const isWeekend = (highlightWeekend && rowCount > 4)
175
- || (highlightHolidays
176
- && AUCalendarComponent.isHoliday(new Date(prevYear, prevMonth - 1, beforeDay)));
177
- return (
178
- <button
179
- type="button"
180
- key={rowCount}
181
- className={isWeekend ? 'weekend empty' : 'empty'}
182
- onClick={() => {
183
- this.goBack();
184
- }}
185
- >
186
- {beforeDay}
187
- </button>
188
- );
189
- });
190
-
191
- const renderDays = Array(AUCalendarComponent.daysInMonth(year, month)).fill().map((d, i) => {
192
- const key = i; // suck it
193
- if (rowCount === 6) {
194
- rowCount = 0;
195
- } else {
196
- rowCount += 1;
197
- }
198
- const newDay = i + 1;
199
- const isSelected = (
200
- newDay === selected.getDate()
201
- && year === selected.getFullYear()
202
- && month === selected.getMonth() + 1
203
- );
204
- const isWeekend = (highlightWeekend && rowCount > 4)
205
- || (highlightHolidays && AUCalendarComponent.isHoliday(new Date(year, month - 1, newDay)));
206
- let className = '';
207
- if (isSelected) {
208
- className = 'selected';
209
- }
210
- if (isWeekend) {
211
- className += `${isSelected ? ' ' : ''}weekend`;
212
- }
213
- return (
214
- <button
215
- key={key}
216
- type="button"
217
- className={isWeekend || isSelected ? className : null}
218
- onClick={() => {
219
- const newSelected = new Date(year, month - 1, newDay, hour, minute);
220
- this.setState({
221
- day: newDay,
222
- selected: newSelected,
223
- }, () => {
224
- onSelected(newSelected);
225
- });
226
- }}
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
- && AUCalendarComponent.isHoliday(new Date(nextYear, nextMonth - 1, afterDay)));
246
- return (
247
- <button
248
- type="button"
249
- key={key}
250
- className={isWeekend ? 'weekend empty' : 'empty'}
251
- onClick={() => {
252
- this.goForward();
253
- }}
254
- >
255
- {afterDay}
256
- </button>
257
- );
258
- });
259
-
260
- const renderHours = Array(24).fill().map((h, i) => {
261
- const key = i;
262
- const optHour = i < 10 ? `0${i}` : i;
263
- return (
264
- <option key={key} value={i}>
265
- {optHour}
266
- </option>
267
- );
268
- });
269
-
270
- const renderMinutes = Array(60).fill().map((h, i) => {
271
- const key = i;
272
- if (i % minuteInterval === 0) {
273
- const optMinute = i < 10 ? `0${i}` : i;
274
- return (
275
- <option key={key} value={i}>
276
- {optMinute}
277
- </option>
278
- );
279
- }
280
- return null;
281
- });
282
-
283
- return (
284
- <div className="au-calendar">
285
- <div className="au-calendar-year-month">
286
- <select
287
- value={month}
288
- onChange={(e) => {
289
- const newMonth = parseInt(e.target.value, 10);
290
- const newSelected = new Date(year, newMonth - 1, day, hour, minute);
291
- this.setState({
292
- month: newMonth,
293
- selected: newSelected,
294
- }, () => {
295
- onSelected(newSelected);
296
- });
297
- }}
298
- >
299
- {renderMonths}
300
- </select>
301
- <select
302
- value={year}
303
- onChange={(e) => {
304
- const newYear = parseInt(e.target.value, 10);
305
- const newSelected = new Date(newYear, month - 1, day, hour, minute);
306
- this.setState({
307
- year: newYear,
308
- selected: newSelected,
309
- }, () => {
310
- onSelected(newSelected);
311
- });
312
- }}
313
- >
314
- {renderYears}
315
- </select>
316
- </div>
317
- <div className="au-calendar-days">
318
- {renderWeekDays}
319
- {renderEmptyDaysBefore}
320
- {renderDays}
321
- {renderEmptyDaysAfter}
322
- </div>
323
- {(() => {
324
- if (showTime) {
325
- return (
326
- <div className="au-calendar-time">
327
- <select
328
- value={hour}
329
- onChange={(e) => {
330
- const newHour = parseInt(e.target.value, 10);
331
- const newSelected = new Date(year, month - 1, day, newHour, minute);
332
- this.setState({
333
- hour: newHour,
334
- selected: newSelected,
335
- }, () => {
336
- onSelected(newSelected);
337
- });
338
- }}
339
- >
340
- {renderHours}
341
- </select>
342
- <select
343
- value={minute}
344
- onChange={(e) => {
345
- const newMinute = parseInt(e.target.value, 10);
346
- const newSelected = new Date(year, month - 1, day, hour, newMinute);
347
- this.setState({
348
- minute: parseInt(e.target.value, 10),
349
- selected: newSelected,
350
- }, () => {
351
- onSelected(newSelected);
352
- });
353
- }}
354
- >
355
- {renderMinutes}
356
- </select>
357
- </div>
358
- );
359
- }
360
- return null;
361
- })()}
362
- </div>
363
- );
364
- }
365
- }
366
-
367
- AUCalendarComponent.defaultProps = {
368
- selected: new Date(),
369
- onSelected: () => { },
370
- highlightWeekend: true,
371
- highlightHolidays: true,
372
- yearSpan: 5,
373
- minuteInterval: 5,
374
- showTime: true,
375
- };
376
-
377
- AUCalendarComponent.propTypes = {
378
- selected: PropTypes.instanceOf(Date),
379
- day: PropTypes.number.isRequired,
380
- month: PropTypes.number.isRequired,
381
- year: PropTypes.number.isRequired,
382
- hour: PropTypes.number.isRequired,
383
- minute: PropTypes.number.isRequired,
384
- highlightWeekend: PropTypes.bool,
385
- highlightHolidays: PropTypes.bool,
386
- onSelected: PropTypes.func,
387
- yearSpan: PropTypes.number,
388
- minuteInterval: PropTypes.number,
389
- showTime: PropTypes.bool,
390
- };
391
-
392
- AUCalendarComponent.displayName = 'AUCalendarComponent';
393
- export default AUCalendarComponent;
@@ -1,105 +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 { onDateChange, format, showTime } = this.props;
37
- return (
38
- <div className="au-datepicker">
39
- <input
40
- type="text"
41
- value={dateFormatted}
42
- readOnly
43
- onClick={() => {
44
- this.setState((prevState) => ({
45
- showCalendar: !prevState.showCalendar,
46
- }));
47
- }}
48
- />
49
- {
50
- showCalendar && [
51
- <div key={0} className="au-calendar-close">
52
- <button
53
- type="button"
54
- onClick={() => {
55
- this.hideDatePicker();
56
- }}
57
- >
58
- c
59
- </button>
60
- </div>,
61
- <AUCalendarComponent
62
- key={showCalendar}
63
- minuteInterval={1}
64
- selected={date}
65
- day={date.getDate()}
66
- month={date.getMonth() + 1}
67
- year={date.getFullYear()}
68
- hour={date.getHours()}
69
- minute={date.getMinutes()}
70
- onSelected={(selected) => {
71
- const formatted = moment(selected).format(format);
72
- this.setState({
73
- date: selected,
74
- dateFormatted: formatted,
75
- }, () => {
76
- onDateChange(selected, formatted);
77
- });
78
- }}
79
- showTime={showTime}
80
- />,
81
- ]
82
- }
83
- </div>
84
- );
85
- }
86
- }
87
-
88
- AUDatepickerComponent.defaultProps = {
89
- date: null,
90
- onDateChange: () => { },
91
- onHide: () => { },
92
- format: 'YYYY-MM-DD HH:mm',
93
- showTime: true,
94
- };
95
-
96
- AUDatepickerComponent.propTypes = {
97
- date: PropTypes.instanceOf(Date),
98
- onDateChange: PropTypes.func,
99
- onHide: PropTypes.func,
100
- format: PropTypes.string,
101
- showTime: PropTypes.bool,
102
- };
103
-
104
- AUDatepickerComponent.displayName = 'AUDatepickerComponent';
105
- export default AUDatepickerComponent;
@@ -1,122 +0,0 @@
1
- /* eslint jsx-a11y/label-has-associated-control: 0 */
2
- /* eslint jsx-a11y/label-has-for: 0 */
3
- import React from 'react';
4
- import PropTypes from 'prop-types';
5
-
6
- class AUFilterCheckboxComponent extends React.Component {
7
- constructor(props) {
8
- super(props);
9
-
10
- this.state = {
11
- filter: props.value,
12
- };
13
- }
14
-
15
- componentDidMount() {
16
- this.input.focus();
17
- }
18
-
19
- render() {
20
- const { filter } = this.state;
21
- const {
22
- items,
23
- onFilterSelect,
24
- onFilterType,
25
- lang,
26
- } = this.props;
27
- const renderFiltered = items.map((_f, i) => {
28
- const f = _f;
29
- const key = i;
30
- const liClassName = f.visible ? 'visible' : null;
31
- const labelClassName = f.selected ? 'selected' : null;
32
- return (
33
- <li key={key} className={liClassName}>
34
- <label className={labelClassName}>
35
- <input
36
- type="checkbox"
37
- value={f.value}
38
- checked={f.selected}
39
- onChange={(e) => {
40
- f.selected = e.target.checked;
41
- if (typeof onFilterSelect === 'function') {
42
- onFilterSelect(items.filter(x => x.selected));
43
- }
44
- }}
45
- />
46
- {f.name}
47
- </label>
48
- </li>
49
- );
50
- });
51
-
52
- const allSelected = items.filter(x => x.selected).length === 0;
53
-
54
- return (
55
- <div className="au-filter-checkbox">
56
- <input
57
- ref={(node) => { this.input = node; }}
58
- type="text"
59
- value={filter}
60
- onChange={(e) => {
61
- const { value } = e.target;
62
- items.forEach((_f) => {
63
- const f = _f;
64
- f.visible = (`${f.name}`).toLowerCase().indexOf(value.toLowerCase().trim()) > -1;
65
- });
66
- this.setState({
67
- filter: value,
68
- }, () => {
69
- if (typeof onFilterType === 'function') {
70
- onFilterType(value);
71
- }
72
- });
73
- }}
74
- />
75
- <ul className="resetlist">
76
- <li className={filter === '' ? 'visible' : null}>
77
- <label className={allSelected ? 'selected' : null}>
78
- <input
79
- type="checkbox"
80
- value=""
81
- checked={allSelected}
82
- onChange={(e) => {
83
- if (e.target.checked) {
84
- items.forEach((_f) => {
85
- const f = _f;
86
- f.selected = false;
87
- });
88
- if (typeof onFilterSelect === 'function') {
89
- onFilterSelect(items.filter(x => x.selected));
90
- }
91
- }
92
- }}
93
- />
94
- {lang === 'da' ? 'Vælg alle' : 'Select all'}
95
- </label>
96
- </li>
97
- {renderFiltered}
98
- </ul>
99
- </div>
100
- );
101
- }
102
- }
103
-
104
- AUFilterCheckboxComponent.defaultProps = {
105
- onFilterSelect: null,
106
- onFilterType: null,
107
- lang: 'da',
108
- value: '',
109
- };
110
-
111
- AUFilterCheckboxComponent.propTypes = {
112
- items: PropTypes.arrayOf(PropTypes.shape({
113
-
114
- })).isRequired,
115
- onFilterSelect: PropTypes.func,
116
- onFilterType: PropTypes.func,
117
- lang: PropTypes.string,
118
- value: PropTypes.string,
119
- };
120
-
121
- AUFilterCheckboxComponent.displayName = 'AUFilterCheckboxComponent';
122
- export default AUFilterCheckboxComponent;
@@ -1,55 +0,0 @@
1
- /* eslint-env browser */
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
-
5
- /**
6
- * AU Focus Komponent
7
- *
8
- * Eksempel:
9
- * ```jsx
10
- * <AUFocusComponent
11
- key="focus"
12
- header={<h1>Fokusfelt</h1>}
13
- text={<p>Noget tekst</p>}
14
- links={<ul><li style={{ backgroundColor: 'rgba(0, 61, 133, .75)' }}><a href="http://www.au.dk">Link</a></li></ul>}
15
- style={{
16
- backgroundImage: 'url(http://ps.au.dk/uploads/tx_templavoila/BSS_Foto_outdoor-51_fokusfelt_72ppi_04.jpg)',
17
- height: '270px',
18
- }}
19
- />
20
- * ```
21
- */
22
-
23
- const AUFocusComponent = (props) => {
24
- const {
25
- style,
26
- header,
27
- text,
28
- links,
29
- } = props;
30
- return (
31
- <div className="au_focus" style={style}>
32
- <div className="au_focus_content">
33
- {header}
34
- {text}
35
- {links}
36
- </div>
37
- </div>
38
- );
39
- };
40
-
41
- AUFocusComponent.defaultProps = {
42
- text: null,
43
- header: null,
44
- links: null,
45
- };
46
-
47
- AUFocusComponent.propTypes = {
48
- header: PropTypes.element,
49
- text: PropTypes.element,
50
- style: PropTypes.shape({}).isRequired,
51
- links: PropTypes.element,
52
- };
53
-
54
- AUFocusComponent.displayName = 'AUFocusComponent';
55
- export default AUFocusComponent;