@aarhus-university/au-lib-react-components 12.5.1 → 12.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +12 -0
- package/.eslintrc.js +35 -35
- package/.storybook/main.js +34 -34
- package/.storybook/preview.js +17 -17
- package/.vscode/settings.json +22 -0
- package/README.md +19 -19
- package/__tests__/jest/AUButtonComponent.test.tsx +165 -165
- package/__tests__/jest/AUDynamicContentComponent.test.tsx +386 -0
- package/__tests__/jest/AUErrorComponent.test.tsx +142 -142
- package/__tests__/jest/AUModalComponent.test.tsx +186 -186
- package/__tests__/jest/AUNotificationComponent.test.tsx +115 -115
- package/__tests__/jest/AUSpinnerComponent.test.tsx +57 -57
- package/__tests__/jest/AUToolbarComponent.test.tsx +46 -46
- package/__tests__/jest/context.test.ts +25 -25
- package/__tests__/jest/helpers.test.ts +15 -15
- package/__tests__/jest/setupTests.ts +2 -2
- package/babel.config.js +8 -8
- package/build/umd/all.css +3 -2
- package/build/umd/all.css.map +1 -7
- package/build/umd/all.js +2 -45
- package/build/umd/all.js.map +1 -7
- package/build/umd/alphabox.js +2 -45
- package/build/umd/alphabox.js.map +1 -7
- package/build/umd/databox.js +2 -45
- package/build/umd/databox.js.map +1 -7
- package/build/umd/diagramme.js +2 -44
- package/build/umd/diagramme.js.map +1 -7
- package/build/umd/flowbox.js +2 -44
- package/build/umd/flowbox.js.map +1 -7
- package/build/umd/universe.js +1 -1
- package/build-storybook.log +386 -386
- package/esbuild.mjs +22 -22
- package/package.json +107 -105
- package/src/components/AUAlertComponent.tsx +128 -128
- package/src/components/AUAutoSuggestComponent.js +148 -148
- package/src/components/AUButtonComponent.tsx +99 -97
- package/src/components/AUCalendarComponent.tsx +497 -497
- package/src/components/AUCharacterCountComponent.tsx +56 -56
- package/src/components/AUComboBoxComponent.tsx +195 -195
- package/src/components/AUContentToggleComponent.tsx +50 -50
- package/src/components/AUDatepickerComponent.tsx +124 -124
- package/src/components/AUDialogModalComponent.tsx +124 -124
- package/src/components/AUDynamicContentComponent.tsx +137 -0
- package/src/components/AUEditorComponent.tsx +126 -117
- package/src/components/AUErrorComponent.tsx +73 -73
- package/src/components/AUMobilePrefixComponent.tsx +20 -20
- package/src/components/AUModalComponent.tsx +72 -72
- package/src/components/AUNotificationComponent.tsx +44 -44
- package/src/components/AUReceiptComponent.tsx +34 -34
- package/src/components/AUSpinnerComponent.tsx +40 -40
- package/src/components/AUStepComponent.tsx +75 -75
- package/src/components/AUSubNavComponent.tsx +57 -57
- package/src/components/AUSubmitButtonContainerComponent.tsx +38 -38
- package/src/components/AUTabbedContentComponent.tsx +154 -154
- package/src/components/AUTableComponent.tsx +29 -29
- package/src/components/AUToastComponent.tsx +104 -104
- package/src/components/AUToolbarComponent.tsx +108 -108
- package/src/components/AUTruncatorComponent.tsx +141 -141
- package/src/components/wrapping/AUEmbedComponent.js +47 -47
- package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +142 -143
- package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
- package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
- package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
- package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
- package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
- package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
- package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
- package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
- package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
- package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
- package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
- package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
- package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
- package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
- package/src/layout-2016/lib/all.js +3 -3
- package/src/layout-2016/lib/au-alphabox.js +99 -100
- package/src/layout-2016/lib/au-databox.js +399 -400
- package/src/layout-2016/lib/au-diagramme.js +85 -85
- package/src/layout-2016/lib/au-flowbox.js +119 -93
- package/src/lib/context.tsx +59 -59
- package/src/lib/dates.ts +52 -52
- package/src/lib/helpers.ts +208 -208
- package/src/lib/hooks.ts +157 -157
- package/src/lib/i18n.ts +600 -600
- package/src/lib/portals.tsx +150 -150
- package/src/lib/tinymce.ts +84 -84
- package/src/lib/wrapping.ts +21 -21
- package/src/styles/_settings.scss +10 -10
- package/src/styles/alphabox.scss +222 -222
- package/src/styles/app.scss +7 -7
- package/src/styles/autosuggest.scss +57 -57
- package/src/styles/databox.scss +563 -563
- package/src/styles/diagramme.scss +119 -119
- package/src/styles/flowbox.scss +72 -72
- package/src/styles/maps.scss +395 -395
- package/stories/AUAlertComponent.stories.tsx +133 -133
- package/stories/AUAutoSuggestComponent.stories.tsx +95 -95
- package/stories/AUButtonComponent.stories.tsx +139 -139
- package/stories/AUCharacterCountComponent.stories.tsx +121 -121
- package/stories/AUComboBoxComponent.stories.tsx +101 -101
- package/stories/AUContentToggleComponent.stories.tsx +87 -87
- package/stories/AUDialogModalComponent.stories.tsx +75 -75
- package/stories/AUDynamicContentComponent.stories.tsx +119 -0
- package/stories/AUEditorComponent.stories.tsx +66 -66
- package/stories/AUErrorComponent.stories.tsx +132 -132
- package/stories/AUModalComponent.stories.tsx +160 -160
- package/stories/AUNotificationComponent.stories.tsx +151 -151
- package/stories/AUSpinnerComponent.stories.tsx +44 -44
- package/stories/AUStepComponent.stories.tsx +91 -91
- package/stories/AUToolbarComponent.stories.tsx +389 -389
- package/stories/AUTruncatorComponent.stories.tsx +123 -123
- package/stories/lib/helpers.tsx +146 -146
- package/tsconfig.json +46 -46
- package/webpack.config.js +88 -88
- package/src/lib/tracking.ts +0 -69
|
@@ -1,400 +1,399 @@
|
|
|
1
|
-
/* eslint func-names: ["error", "never"] */
|
|
2
|
-
/* eslint no-prototype-builtins: 0 */
|
|
3
|
-
/* eslint no-restricted-syntax: 0 */
|
|
4
|
-
/* eslint max-classes-per-file: 0 */
|
|
5
|
-
/* eslint no-unused-vars: 0 */
|
|
6
|
-
/* eslint-env browser */
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import ReactDOM from 'react-dom';
|
|
9
|
-
import DataBoxComponent from '../components/databox/DataBoxComponent';
|
|
10
|
-
|
|
11
|
-
const defaultOptions = {
|
|
12
|
-
config: {
|
|
13
|
-
container: '.au_databox', // DOM-element
|
|
14
|
-
firstline: true, // skal søgefeltet stå på en række for sig selv?
|
|
15
|
-
alphabet: 2, // hvilken knap er alfabetet?
|
|
16
|
-
initLetter: 'a', // Startbogstavet for alfabetet
|
|
17
|
-
trigger: 0,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{ text: 'Dummy knap
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
box =
|
|
369
|
-
box
|
|
370
|
-
|
|
371
|
-
//
|
|
372
|
-
//
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
&& AU.responsive.state
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
window.AUDatabox = AUDatabox;
|
|
1
|
+
/* eslint func-names: ["error", "never"] */
|
|
2
|
+
/* eslint no-prototype-builtins: 0 */
|
|
3
|
+
/* eslint no-restricted-syntax: 0 */
|
|
4
|
+
/* eslint max-classes-per-file: 0 */
|
|
5
|
+
/* eslint no-unused-vars: 0 */
|
|
6
|
+
/* eslint-env browser */
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import ReactDOM from 'react-dom';
|
|
9
|
+
import DataBoxComponent from '../components/databox/DataBoxComponent';
|
|
10
|
+
|
|
11
|
+
const defaultOptions = {
|
|
12
|
+
config: {
|
|
13
|
+
container: '.au_databox', // DOM-element
|
|
14
|
+
firstline: true, // skal søgefeltet stå på en række for sig selv?
|
|
15
|
+
alphabet: 2, // hvilken knap er alfabetet?
|
|
16
|
+
initLetter: 'a', // Startbogstavet for alfabetet
|
|
17
|
+
trigger: 0,
|
|
18
|
+
buttons: [ // Teksten på knapperne - nyt!
|
|
19
|
+
{ text: 'Dummy knap 1', link: '' },
|
|
20
|
+
{ text: 'Dummy knap 2', link: '' },
|
|
21
|
+
],
|
|
22
|
+
stacked: false,
|
|
23
|
+
rememberState: false,
|
|
24
|
+
expand: false,
|
|
25
|
+
},
|
|
26
|
+
background: {
|
|
27
|
+
color: '#003d73',
|
|
28
|
+
linkColor: '#003d73',
|
|
29
|
+
src: '',
|
|
30
|
+
height: 0,
|
|
31
|
+
text: '',
|
|
32
|
+
overlay: true,
|
|
33
|
+
},
|
|
34
|
+
search: {
|
|
35
|
+
autocomplete: true,
|
|
36
|
+
index: 1,
|
|
37
|
+
minLength: 1,
|
|
38
|
+
placeHolder: '',
|
|
39
|
+
},
|
|
40
|
+
data: {
|
|
41
|
+
mode: 'json',
|
|
42
|
+
source: '',
|
|
43
|
+
callback: null,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
class AUDataboxParser {
|
|
48
|
+
static json(source, callback) {
|
|
49
|
+
if (source) {
|
|
50
|
+
let sourceArr = [];
|
|
51
|
+
if (!Array.isArray(source)) {
|
|
52
|
+
sourceArr.push(source);
|
|
53
|
+
} else {
|
|
54
|
+
sourceArr = source;
|
|
55
|
+
}
|
|
56
|
+
const promises = [];
|
|
57
|
+
sourceArr.forEach((s) => {
|
|
58
|
+
promises.push(new Promise((resolve) => {
|
|
59
|
+
fetch(s).then((promise) => promise.json()).then((data) => {
|
|
60
|
+
resolve(data);
|
|
61
|
+
});
|
|
62
|
+
}));
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
Promise.all(promises).then((values) => {
|
|
66
|
+
callback({
|
|
67
|
+
items: values.map((x) => x.items)[0],
|
|
68
|
+
groupings: values.map((x) => x.groupings)[0] || [],
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static xml(source, callback) {
|
|
75
|
+
const xmlFunc = (data) => {
|
|
76
|
+
const items = [];
|
|
77
|
+
const children = [];
|
|
78
|
+
const associations = [];
|
|
79
|
+
|
|
80
|
+
let assocXML = [];
|
|
81
|
+
let count = 1;
|
|
82
|
+
|
|
83
|
+
do {
|
|
84
|
+
assocXML = $(data).find(`associations${count} > item`);
|
|
85
|
+
|
|
86
|
+
const assoc = [];
|
|
87
|
+
for (let i = 0; i < assocXML.length; i += 1) {
|
|
88
|
+
assoc.push({
|
|
89
|
+
id: $(assocXML[i]).attr('id'),
|
|
90
|
+
name: $(assocXML[i]).attr('name'),
|
|
91
|
+
items: [],
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (assoc.length > 0) {
|
|
96
|
+
associations.push(assoc);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
count += 1;
|
|
100
|
+
} while (assocXML.length > 0);
|
|
101
|
+
|
|
102
|
+
const itemsXML = $(data).find('items > item');
|
|
103
|
+
$.each(itemsXML, function () {
|
|
104
|
+
const extraXML = $(this).find('extra');
|
|
105
|
+
const extra = [];
|
|
106
|
+
$.each(extraXML.find('param'), () => {
|
|
107
|
+
extra.push({
|
|
108
|
+
param: $(this).text(),
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
const obj = {
|
|
112
|
+
id: $(this).attr('id'),
|
|
113
|
+
name: $(this).attr('name'),
|
|
114
|
+
url: $(this).attr('url'),
|
|
115
|
+
parent: $(this).attr('parent'),
|
|
116
|
+
extra,
|
|
117
|
+
children: [],
|
|
118
|
+
associations: [],
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
for (let i = 0; i < associations.length; i += 1) {
|
|
122
|
+
const objAssoc = $(this).find(`association${parseInt(i + 1, 10)}`);
|
|
123
|
+
|
|
124
|
+
obj.associations.push([]);
|
|
125
|
+
|
|
126
|
+
for (let j = 0; j < objAssoc.length; j += 1) {
|
|
127
|
+
const id = parseInt($(objAssoc[j]).attr('id'), 10) - 1;
|
|
128
|
+
obj.associations[i].push({
|
|
129
|
+
id: associations[i][id].id,
|
|
130
|
+
name: associations[i][id].name,
|
|
131
|
+
});
|
|
132
|
+
associations[i][id].items.push(obj);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
items.push(obj);
|
|
137
|
+
if (typeof obj.parent !== 'undefined' && obj.parent !== '') {
|
|
138
|
+
children.push(obj);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
for (let c = 0; c < children.length; c += 1) {
|
|
143
|
+
const pid = children[c].parent;
|
|
144
|
+
for (let p = 0; p < items.length; p += 1) {
|
|
145
|
+
if (items[p].id === pid) {
|
|
146
|
+
items[p].children.push(children[c]);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const groupings = [];
|
|
153
|
+
for (let i = 0; i < associations.length; i += 1) {
|
|
154
|
+
groupings.push({
|
|
155
|
+
id: i,
|
|
156
|
+
associations: associations[i],
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
callback({
|
|
161
|
+
rawData: data,
|
|
162
|
+
items,
|
|
163
|
+
groupings,
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
AU.helpers.getXML(source, (data) => {
|
|
168
|
+
xmlFunc(data);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
static table(source, callback) {
|
|
173
|
+
const table = $(`${source} > table`);
|
|
174
|
+
const list = $(`${source} > ul`);
|
|
175
|
+
|
|
176
|
+
const items = [];
|
|
177
|
+
const children = [];
|
|
178
|
+
const associations = [];
|
|
179
|
+
|
|
180
|
+
$('li', list).each(function () {
|
|
181
|
+
const assoc = [];
|
|
182
|
+
$('> ul > li', this).each(function (i) {
|
|
183
|
+
assoc.push({
|
|
184
|
+
id: i,
|
|
185
|
+
name: $(this).text(),
|
|
186
|
+
items: [],
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
if (assoc.length > 0) {
|
|
191
|
+
associations.push(assoc);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
$('tr', table).each(function (i) {
|
|
196
|
+
if (i > 0) {
|
|
197
|
+
const cells = $('td', this);
|
|
198
|
+
|
|
199
|
+
const id = parseInt(cells.eq(0).text(), 10);
|
|
200
|
+
const parent = parseInt(cells.eq(1).text(), 10);
|
|
201
|
+
let name = cells.eq(2).text();
|
|
202
|
+
name = name.trim();
|
|
203
|
+
const url = $('a', cells.eq(2)).attr('href');
|
|
204
|
+
const skip = 3; // Antallet af celler, som ikke angiver associations!
|
|
205
|
+
|
|
206
|
+
const obj = {
|
|
207
|
+
id,
|
|
208
|
+
name,
|
|
209
|
+
url,
|
|
210
|
+
parent,
|
|
211
|
+
extra: [],
|
|
212
|
+
children: [],
|
|
213
|
+
associations: [],
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
for (let j = 0; j < associations.length; j += 1) {
|
|
217
|
+
const assocCell = cells.eq(j + skip).text();
|
|
218
|
+
const assocCellSplit = assocCell.split(',');
|
|
219
|
+
|
|
220
|
+
obj.associations.push([]);
|
|
221
|
+
|
|
222
|
+
for (let k = 0; k < assocCellSplit.length; k += 1) {
|
|
223
|
+
const aid = parseInt(assocCellSplit[k], 10) - 1;
|
|
224
|
+
|
|
225
|
+
if (typeof associations[j][aid] !== 'undefined') {
|
|
226
|
+
obj.associations[j].push({
|
|
227
|
+
id: associations[j][aid].id,
|
|
228
|
+
name: associations[j][aid].name,
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
associations[j][aid].items.push(obj);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (obj.parent === 0 || obj.parent === '') {
|
|
237
|
+
items.push(obj);
|
|
238
|
+
} else {
|
|
239
|
+
children.push(obj);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
for (let c = 0; c < children.length; c += 1) {
|
|
245
|
+
const pid = children[c].parent;
|
|
246
|
+
for (let p = 0; p < items.length; p += 1) {
|
|
247
|
+
if (items[p].id === pid) {
|
|
248
|
+
items[p].children.push(children[c]);
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const groupings = [];
|
|
255
|
+
for (let i = 0; i < associations.length; i += 1) {
|
|
256
|
+
groupings.push({
|
|
257
|
+
id: i,
|
|
258
|
+
associations: associations[i],
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
callback({
|
|
263
|
+
items,
|
|
264
|
+
groupings,
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
static list(source, callback) {
|
|
269
|
+
const list = $(source);
|
|
270
|
+
const items = [];
|
|
271
|
+
$('li', list).each(function (i) {
|
|
272
|
+
items.push({
|
|
273
|
+
id: i,
|
|
274
|
+
label: $(this).text(),
|
|
275
|
+
value: $(this).text(),
|
|
276
|
+
name: $(this).text(),
|
|
277
|
+
url: $('a', this).attr('href'),
|
|
278
|
+
children: [],
|
|
279
|
+
associations: [],
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
callback({
|
|
284
|
+
items,
|
|
285
|
+
groupings: [],
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
class AUDatabox {
|
|
290
|
+
constructor(boxes) {
|
|
291
|
+
this.boxes = boxes;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
static mergeOptions(_box) {
|
|
295
|
+
const box = _box;
|
|
296
|
+
if (!box.hasOwnProperty('config')) {
|
|
297
|
+
box.config = {};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
for (const conf in defaultOptions.config) {
|
|
301
|
+
if (!box.config.hasOwnProperty(conf)) {
|
|
302
|
+
box.config[conf] = defaultOptions.config[conf];
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (!box.hasOwnProperty('background')) {
|
|
307
|
+
box.background = {};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
for (const bg in defaultOptions.background) {
|
|
311
|
+
if (!box.background.hasOwnProperty(bg)) {
|
|
312
|
+
box.background[bg] = defaultOptions.background[bg];
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (!box.hasOwnProperty('search')) {
|
|
317
|
+
box.search = {};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
for (const sch in defaultOptions.search) {
|
|
321
|
+
if (!box.search.hasOwnProperty(sch)) {
|
|
322
|
+
box.search[sch] = defaultOptions.search[sch];
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (!box.hasOwnProperty('data')) {
|
|
327
|
+
box.data = {};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
for (const data in defaultOptions.data) {
|
|
331
|
+
if (!box.data.hasOwnProperty(data)) {
|
|
332
|
+
box.data[data] = defaultOptions.data[data];
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return box;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
static legacyCleanUp(_box) {
|
|
340
|
+
const box = _box;
|
|
341
|
+
const container = $(box.config.container);
|
|
342
|
+
if (container !== null) {
|
|
343
|
+
const containerChildren = $('> *:not(.no-header)', container); // Kan både være div og h2 elementer
|
|
344
|
+
if (containerChildren.length > 0) {
|
|
345
|
+
box.config.buttons = [];
|
|
346
|
+
containerChildren.each(function () {
|
|
347
|
+
box.config.buttons.push({
|
|
348
|
+
text: $(this).text(),
|
|
349
|
+
link: '',
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
init() {
|
|
357
|
+
const parser = {
|
|
358
|
+
json: AUDataboxParser.json,
|
|
359
|
+
xml: AUDataboxParser.xml,
|
|
360
|
+
table: AUDataboxParser.table,
|
|
361
|
+
list: AUDataboxParser.list,
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
for (let i = 0; i < this.boxes.length; i += 1) {
|
|
365
|
+
let box = this.boxes[i];
|
|
366
|
+
if (!box.loaded) {
|
|
367
|
+
box = AUDatabox.mergeOptions(box);
|
|
368
|
+
box.id = i;
|
|
369
|
+
AUDatabox.legacyCleanUp(box);
|
|
370
|
+
// I stedet for at skulle rette alle gamle søgebokse,
|
|
371
|
+
// hvor knappernes tekst er sat direkte i HTML'en,
|
|
372
|
+
// finder vi knapperne her og indsætter dem som 'buttons' i config'en
|
|
373
|
+
const mountNode = document.querySelector(box.config.container);
|
|
374
|
+
const visible = mountNode && getComputedStyle(mountNode).visibility !== 'hidden';
|
|
375
|
+
if (!box.config.stacked
|
|
376
|
+
&& AU.responsive.state
|
|
377
|
+
&& AU.responsive.state.NAME === 'PHONE') {
|
|
378
|
+
box.config.stacked = true;
|
|
379
|
+
}
|
|
380
|
+
if (visible) {
|
|
381
|
+
ReactDOM.render(<DataBoxComponent
|
|
382
|
+
box={box}
|
|
383
|
+
parse={parser[box.data.mode]}
|
|
384
|
+
/>, mountNode);
|
|
385
|
+
box.loaded = true;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (box.data.mode === 'table' || box.data.mode === 'list') {
|
|
389
|
+
const dataElement = document.querySelector(box.data.source);
|
|
390
|
+
if (dataElement) {
|
|
391
|
+
dataElement.parentNode.removeChild(dataElement);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
window.AUDatabox = AUDatabox;
|