@aarhus-university/au-lib-react-components 12.6.2 → 12.6.3
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/.eslintrc.js +35 -35
- package/.storybook/main.js +34 -34
- package/.storybook/preview.js +17 -17
- package/README.md +19 -19
- package/__tests__/jest/AUButtonComponent.test.tsx +165 -165
- package/__tests__/jest/AUDynamicContentComponent.test.tsx +386 -386
- 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 +2 -2
- package/build/umd/all.js +1 -1
- package/build/umd/alphabox.js +1 -1
- package/build/umd/databox.js +1 -1
- package/build/umd/diagramme.js +1 -1
- package/build/umd/flowbox.js +1 -1
- package/build/umd/flowbox.js.map +1 -1
- package/build/umd/universe.js +1 -1
- package/build-storybook.log +386 -386
- package/esbuild.mjs +22 -22
- package/package.json +107 -107
- package/src/components/AUAlertComponent.tsx +128 -128
- package/src/components/AUAutoSuggestComponent.js +148 -148
- package/src/components/AUButtonComponent.tsx +99 -99
- 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 -137
- package/src/components/AUEditorComponent.tsx +126 -126
- 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 -142
- 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 -99
- package/src/layout-2016/lib/au-databox.js +399 -399
- package/src/layout-2016/lib/au-diagramme.js +85 -85
- package/src/layout-2016/lib/au-flowbox.js +116 -119
- 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 -119
- 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/.claude/settings.local.json +0 -12
- package/.vscode/settings.json +0 -22
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
/* eslint no-prototype-builtins: 0 */
|
|
2
|
-
/* eslint no-restricted-syntax: 0 */
|
|
3
|
-
/* eslint no-unused-vars: 0 */
|
|
4
|
-
/* eslint-env browser */
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import ReactDOM from 'react-dom';
|
|
7
|
-
import AUDiagrammeComponent from '../components/diagramme/AUDiagrammeComponent';
|
|
8
|
-
|
|
9
|
-
const defaultOptions = {
|
|
10
|
-
config: {
|
|
11
|
-
container: '.au_edutable_eddi_container',
|
|
12
|
-
courseID: 0,
|
|
13
|
-
track: 0,
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
class AUDiagramme {
|
|
18
|
-
constructor(lang, tables) {
|
|
19
|
-
this.tables = tables;
|
|
20
|
-
this.lang = lang;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static mergeOptions(_table) {
|
|
24
|
-
const table = _table;
|
|
25
|
-
if (!table.hasOwnProperty('config')) {
|
|
26
|
-
table.config = {};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
for (const conf in defaultOptions.config) {
|
|
30
|
-
if (!table.config.hasOwnProperty(conf)) {
|
|
31
|
-
table.config[conf] = defaultOptions.config[conf];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
init() {
|
|
37
|
-
const qsCourses = AU.helpers.getQuerystring('coursesprint');
|
|
38
|
-
if (qsCourses !== '') {
|
|
39
|
-
const coursesSplit = qsCourses.split(',');
|
|
40
|
-
for (let j = 0; j < coursesSplit.length; j += 1) {
|
|
41
|
-
const trackSplit = coursesSplit[j].split('|');
|
|
42
|
-
if (trackSplit.length > 1) {
|
|
43
|
-
this.tables.push({
|
|
44
|
-
config: {
|
|
45
|
-
container: `#print_course_${j}`,
|
|
46
|
-
courseID: parseInt(trackSplit[0], 10),
|
|
47
|
-
track: parseInt(trackSplit[1], 10),
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
} else {
|
|
51
|
-
this.tables.push({
|
|
52
|
-
config: {
|
|
53
|
-
container: `#print_course_${j}`,
|
|
54
|
-
courseID: parseInt(trackSplit[0], 10),
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
ReactDOM.render(<div id={`print_course_${j}`} />, document.querySelector('body'));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
for (let i = 0; i < this.tables.length; i += 1) {
|
|
62
|
-
const table = this.tables[i];
|
|
63
|
-
table.id = i;
|
|
64
|
-
AUDiagramme.mergeOptions(table);
|
|
65
|
-
const url = `https://eddiprod.au.dk/EDDI/webservices/StudieoversigtService2.cfc?method=getLinjeListByDokordningId&tjekForVisningIstudieDiagram=true&allowOrigin=true&dokordningId=${table.config.courseID}`;
|
|
66
|
-
fetch(url).then((promise) => promise.json()).then((data) => {
|
|
67
|
-
const mountNode = document.querySelector(table.config.container);
|
|
68
|
-
if (mountNode) {
|
|
69
|
-
ReactDOM.render(
|
|
70
|
-
<AUDiagrammeComponent
|
|
71
|
-
lang={this.lang}
|
|
72
|
-
response={data}
|
|
73
|
-
course={table.config.courseID}
|
|
74
|
-
track={table.config.track}
|
|
75
|
-
print={qsCourses !== ''}
|
|
76
|
-
/>,
|
|
77
|
-
mountNode,
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
window.AUDiagramme = AUDiagramme;
|
|
1
|
+
/* eslint no-prototype-builtins: 0 */
|
|
2
|
+
/* eslint no-restricted-syntax: 0 */
|
|
3
|
+
/* eslint no-unused-vars: 0 */
|
|
4
|
+
/* eslint-env browser */
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import ReactDOM from 'react-dom';
|
|
7
|
+
import AUDiagrammeComponent from '../components/diagramme/AUDiagrammeComponent';
|
|
8
|
+
|
|
9
|
+
const defaultOptions = {
|
|
10
|
+
config: {
|
|
11
|
+
container: '.au_edutable_eddi_container',
|
|
12
|
+
courseID: 0,
|
|
13
|
+
track: 0,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
class AUDiagramme {
|
|
18
|
+
constructor(lang, tables) {
|
|
19
|
+
this.tables = tables;
|
|
20
|
+
this.lang = lang;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static mergeOptions(_table) {
|
|
24
|
+
const table = _table;
|
|
25
|
+
if (!table.hasOwnProperty('config')) {
|
|
26
|
+
table.config = {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
for (const conf in defaultOptions.config) {
|
|
30
|
+
if (!table.config.hasOwnProperty(conf)) {
|
|
31
|
+
table.config[conf] = defaultOptions.config[conf];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
init() {
|
|
37
|
+
const qsCourses = AU.helpers.getQuerystring('coursesprint');
|
|
38
|
+
if (qsCourses !== '') {
|
|
39
|
+
const coursesSplit = qsCourses.split(',');
|
|
40
|
+
for (let j = 0; j < coursesSplit.length; j += 1) {
|
|
41
|
+
const trackSplit = coursesSplit[j].split('|');
|
|
42
|
+
if (trackSplit.length > 1) {
|
|
43
|
+
this.tables.push({
|
|
44
|
+
config: {
|
|
45
|
+
container: `#print_course_${j}`,
|
|
46
|
+
courseID: parseInt(trackSplit[0], 10),
|
|
47
|
+
track: parseInt(trackSplit[1], 10),
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
this.tables.push({
|
|
52
|
+
config: {
|
|
53
|
+
container: `#print_course_${j}`,
|
|
54
|
+
courseID: parseInt(trackSplit[0], 10),
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
ReactDOM.render(<div id={`print_course_${j}`} />, document.querySelector('body'));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (let i = 0; i < this.tables.length; i += 1) {
|
|
62
|
+
const table = this.tables[i];
|
|
63
|
+
table.id = i;
|
|
64
|
+
AUDiagramme.mergeOptions(table);
|
|
65
|
+
const url = `https://eddiprod.au.dk/EDDI/webservices/StudieoversigtService2.cfc?method=getLinjeListByDokordningId&tjekForVisningIstudieDiagram=true&allowOrigin=true&dokordningId=${table.config.courseID}`;
|
|
66
|
+
fetch(url).then((promise) => promise.json()).then((data) => {
|
|
67
|
+
const mountNode = document.querySelector(table.config.container);
|
|
68
|
+
if (mountNode) {
|
|
69
|
+
ReactDOM.render(
|
|
70
|
+
<AUDiagrammeComponent
|
|
71
|
+
lang={this.lang}
|
|
72
|
+
response={data}
|
|
73
|
+
course={table.config.courseID}
|
|
74
|
+
track={table.config.track}
|
|
75
|
+
print={qsCourses !== ''}
|
|
76
|
+
/>,
|
|
77
|
+
mountNode,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
window.AUDiagramme = AUDiagramme;
|
|
@@ -1,119 +1,116 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
/* eslint no-prototype-builtins: 0 */
|
|
3
|
-
/* eslint no-restricted-syntax: 0 */
|
|
4
|
-
/* eslint no-unused-vars: 0 */
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import ReactDOM from 'react-dom';
|
|
7
|
-
import FlowBoxComponent from '../components/flowbox/FlowBoxComponent';
|
|
8
|
-
|
|
9
|
-
const defaultOptions = {
|
|
10
|
-
config: {
|
|
11
|
-
container: '.au_flowbox',
|
|
12
|
-
render: 'ul',
|
|
13
|
-
},
|
|
14
|
-
data: {
|
|
15
|
-
mode: 'list',
|
|
16
|
-
source: '.au_flowbox_list',
|
|
17
|
-
headline: 'Overskrift',
|
|
18
|
-
prepend: '',
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
class AUFlowbox {
|
|
23
|
-
constructor(lang, boxes) {
|
|
24
|
-
this.boxes = boxes;
|
|
25
|
-
this.lang = lang;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static mergeOptions(_box) {
|
|
29
|
-
const box = _box;
|
|
30
|
-
if (!box.hasOwnProperty('config')) {
|
|
31
|
-
box.config = {};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
for (const conf in defaultOptions.config) {
|
|
35
|
-
if (!box.config.hasOwnProperty(conf)) {
|
|
36
|
-
box.config[conf] = defaultOptions.config[conf];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!box.hasOwnProperty('data')) {
|
|
41
|
-
box.data = {};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
for (const data in defaultOptions.data) {
|
|
45
|
-
if (!box.data.hasOwnProperty(data)) {
|
|
46
|
-
box.data[data] = defaultOptions.data[data];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static parse(box) {
|
|
52
|
-
const getLabelFromLi = (li) => {
|
|
53
|
-
// Primært: TYPO3v10/“p-wrapped” eller global content hvor der kommer en wrapper ind
|
|
54
|
-
const labelEl = li.querySelector(':scope > p')
|
|
55
|
-
|| li.querySelector(':scope > div > p')
|
|
56
|
-
|| li.querySelector(':scope > div > p > span') // hvis editoren putter spans ind
|
|
57
|
-
|| null;
|
|
58
|
-
|
|
59
|
-
if (labelEl) {
|
|
60
|
-
return labelEl.innerHTML.trim();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Sekundært:
|
|
64
|
-
//
|
|
65
|
-
const
|
|
66
|
-
.filter((n) => n.nodeType === Node.
|
|
67
|
-
|
|
68
|
-
.
|
|
69
|
-
.
|
|
70
|
-
.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
window.AUFlowbox = AUFlowbox;
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
/* eslint no-prototype-builtins: 0 */
|
|
3
|
+
/* eslint no-restricted-syntax: 0 */
|
|
4
|
+
/* eslint no-unused-vars: 0 */
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import ReactDOM from 'react-dom';
|
|
7
|
+
import FlowBoxComponent from '../components/flowbox/FlowBoxComponent';
|
|
8
|
+
|
|
9
|
+
const defaultOptions = {
|
|
10
|
+
config: {
|
|
11
|
+
container: '.au_flowbox',
|
|
12
|
+
render: 'ul',
|
|
13
|
+
},
|
|
14
|
+
data: {
|
|
15
|
+
mode: 'list',
|
|
16
|
+
source: '.au_flowbox_list',
|
|
17
|
+
headline: 'Overskrift',
|
|
18
|
+
prepend: '',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
class AUFlowbox {
|
|
23
|
+
constructor(lang, boxes) {
|
|
24
|
+
this.boxes = boxes;
|
|
25
|
+
this.lang = lang;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static mergeOptions(_box) {
|
|
29
|
+
const box = _box;
|
|
30
|
+
if (!box.hasOwnProperty('config')) {
|
|
31
|
+
box.config = {};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
for (const conf in defaultOptions.config) {
|
|
35
|
+
if (!box.config.hasOwnProperty(conf)) {
|
|
36
|
+
box.config[conf] = defaultOptions.config[conf];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!box.hasOwnProperty('data')) {
|
|
41
|
+
box.data = {};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
for (const data in defaultOptions.data) {
|
|
45
|
+
if (!box.data.hasOwnProperty(data)) {
|
|
46
|
+
box.data[data] = defaultOptions.data[data];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static parse(box) {
|
|
52
|
+
const getLabelFromLi = (li) => {
|
|
53
|
+
// Primært: TYPO3v10/“p-wrapped” eller global content hvor der kommer en wrapper ind
|
|
54
|
+
const labelEl = li.querySelector(':scope > p')
|
|
55
|
+
|| li.querySelector(':scope > div > p')
|
|
56
|
+
|| li.querySelector(':scope > div > p > span') // hvis editoren putter spans ind
|
|
57
|
+
|| null;
|
|
58
|
+
|
|
59
|
+
if (labelEl) {
|
|
60
|
+
return labelEl.innerHTML.trim();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Sekundært: mixed content direkte i <li>
|
|
64
|
+
// Ignorer <ul> og <ol>, men behold alle andre nodes inkl. inline elementer
|
|
65
|
+
const html = Array.from(li.childNodes)
|
|
66
|
+
.filter((n) => !(n.nodeType === Node.ELEMENT_NODE
|
|
67
|
+
&& (n.tagName === 'UL' || n.tagName === 'OL')))
|
|
68
|
+
.map((n) => (n.nodeType === Node.TEXT_NODE ? n.textContent : n.outerHTML))
|
|
69
|
+
.join('')
|
|
70
|
+
.replace(/\s+/g, ' ')
|
|
71
|
+
.trim();
|
|
72
|
+
|
|
73
|
+
return html;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const parseUl = (data, ulElements) => {
|
|
77
|
+
ulElements.forEach((ul) => {
|
|
78
|
+
const lis = ul.querySelectorAll(':scope > li');
|
|
79
|
+
lis.forEach((li) => {
|
|
80
|
+
const name = getLabelFromLi(li);
|
|
81
|
+
if (!name) return;
|
|
82
|
+
|
|
83
|
+
const obj = { name, children: [], parent: data };
|
|
84
|
+
data.children.push(obj);
|
|
85
|
+
|
|
86
|
+
const childUls = li.querySelectorAll(':scope > ul');
|
|
87
|
+
if (childUls.length > 0) {
|
|
88
|
+
parseUl(obj, childUls); // Det her skal vi altid gøre
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Start: find root UL’er fra box.data.source (som før)
|
|
95
|
+
const roots = document.querySelectorAll(box.data.source);
|
|
96
|
+
parseUl(box.item, roots);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
init() {
|
|
100
|
+
for (let i = 0; i < this.boxes.length; i += 1) {
|
|
101
|
+
const box = this.boxes[i];
|
|
102
|
+
AUFlowbox.mergeOptions(box);
|
|
103
|
+
box.id = i;
|
|
104
|
+
box.item = {
|
|
105
|
+
name: box.data.headline,
|
|
106
|
+
children: [],
|
|
107
|
+
parent: null,
|
|
108
|
+
};
|
|
109
|
+
AUFlowbox.parse(box);
|
|
110
|
+
const mountNode = document.querySelector(box.config.container);
|
|
111
|
+
ReactDOM.render(<FlowBoxComponent box={box} lang={this.lang} />, mountNode);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
window.AUFlowbox = AUFlowbox;
|
package/src/lib/context.tsx
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import React, { createContext, useContext } from 'react';
|
|
2
|
-
import { setLocale } from './dates';
|
|
3
|
-
import { getPortalByName } from './portals';
|
|
4
|
-
|
|
5
|
-
export const LangContext = createContext<string>('da');
|
|
6
|
-
export const useLangContext = (): string => {
|
|
7
|
-
const lang = useContext(LangContext);
|
|
8
|
-
setLocale(lang);
|
|
9
|
-
return lang;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const AuthenticationContext = createContext<boolean>(false);
|
|
13
|
-
export const useAuthenticationContext = (): boolean => useContext(AuthenticationContext);
|
|
14
|
-
|
|
15
|
-
export const UserContext = createContext<AU.IUserContext | null>(null);
|
|
16
|
-
export const useUserContext = (): AU.IUserContext | null => {
|
|
17
|
-
const user = useContext(UserContext);
|
|
18
|
-
return user;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const PortalContext = createContext<AU.IPortalContext | null>(null);
|
|
22
|
-
|
|
23
|
-
type PortalContextProviderProps = {
|
|
24
|
-
name: AU.portalNames;
|
|
25
|
-
children: JSX.Element;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const AUPortal = {
|
|
29
|
-
Provider: ({
|
|
30
|
-
name,
|
|
31
|
-
children,
|
|
32
|
-
}: PortalContextProviderProps) => {
|
|
33
|
-
const lang = useLangContext();
|
|
34
|
-
const portal = getPortalByName(lang || 'da', name);
|
|
35
|
-
return (
|
|
36
|
-
<PortalContext.Provider value={portal}>
|
|
37
|
-
<AuthenticationContext.Provider value={typeof window.authenticated === 'undefined' ? false : window.authenticated}>
|
|
38
|
-
{children}
|
|
39
|
-
</AuthenticationContext.Provider>
|
|
40
|
-
</PortalContext.Provider>
|
|
41
|
-
);
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const usePortalContext = (): AU.IPortalContext | null => {
|
|
46
|
-
const portal = useContext(PortalContext);
|
|
47
|
-
return portal;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const ImpersonationContext = createContext<AU.IImpersonationContext>({
|
|
51
|
-
canImpersonate: false,
|
|
52
|
-
isImpersonating: false,
|
|
53
|
-
impersonatateError: false,
|
|
54
|
-
});
|
|
55
|
-
// eslint-disable-next-line max-len
|
|
56
|
-
export const useImpersonationContext = (): AU.IImpersonationContext => useContext(ImpersonationContext);
|
|
57
|
-
|
|
58
|
-
export const AUDialogModalContext = createContext<(() => void) | null>(null);
|
|
59
|
-
export const useAUDialogModalContext = (): (() => void) | null => useContext(AUDialogModalContext);
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
|
+
import { setLocale } from './dates';
|
|
3
|
+
import { getPortalByName } from './portals';
|
|
4
|
+
|
|
5
|
+
export const LangContext = createContext<string>('da');
|
|
6
|
+
export const useLangContext = (): string => {
|
|
7
|
+
const lang = useContext(LangContext);
|
|
8
|
+
setLocale(lang);
|
|
9
|
+
return lang;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const AuthenticationContext = createContext<boolean>(false);
|
|
13
|
+
export const useAuthenticationContext = (): boolean => useContext(AuthenticationContext);
|
|
14
|
+
|
|
15
|
+
export const UserContext = createContext<AU.IUserContext | null>(null);
|
|
16
|
+
export const useUserContext = (): AU.IUserContext | null => {
|
|
17
|
+
const user = useContext(UserContext);
|
|
18
|
+
return user;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const PortalContext = createContext<AU.IPortalContext | null>(null);
|
|
22
|
+
|
|
23
|
+
type PortalContextProviderProps = {
|
|
24
|
+
name: AU.portalNames;
|
|
25
|
+
children: JSX.Element;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const AUPortal = {
|
|
29
|
+
Provider: ({
|
|
30
|
+
name,
|
|
31
|
+
children,
|
|
32
|
+
}: PortalContextProviderProps) => {
|
|
33
|
+
const lang = useLangContext();
|
|
34
|
+
const portal = getPortalByName(lang || 'da', name);
|
|
35
|
+
return (
|
|
36
|
+
<PortalContext.Provider value={portal}>
|
|
37
|
+
<AuthenticationContext.Provider value={typeof window.authenticated === 'undefined' ? false : window.authenticated}>
|
|
38
|
+
{children}
|
|
39
|
+
</AuthenticationContext.Provider>
|
|
40
|
+
</PortalContext.Provider>
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const usePortalContext = (): AU.IPortalContext | null => {
|
|
46
|
+
const portal = useContext(PortalContext);
|
|
47
|
+
return portal;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const ImpersonationContext = createContext<AU.IImpersonationContext>({
|
|
51
|
+
canImpersonate: false,
|
|
52
|
+
isImpersonating: false,
|
|
53
|
+
impersonatateError: false,
|
|
54
|
+
});
|
|
55
|
+
// eslint-disable-next-line max-len
|
|
56
|
+
export const useImpersonationContext = (): AU.IImpersonationContext => useContext(ImpersonationContext);
|
|
57
|
+
|
|
58
|
+
export const AUDialogModalContext = createContext<(() => void) | null>(null);
|
|
59
|
+
export const useAUDialogModalContext = (): (() => void) | null => useContext(AUDialogModalContext);
|
package/src/lib/dates.ts
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import 'dayjs/locale/da';
|
|
3
|
-
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
4
|
-
import weekday from 'dayjs/plugin/weekday';
|
|
5
|
-
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
6
|
-
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
7
|
-
import updateLocale from 'dayjs/plugin/updateLocale';
|
|
8
|
-
|
|
9
|
-
dayjs.extend(isoWeek);
|
|
10
|
-
dayjs.extend(weekday);
|
|
11
|
-
dayjs.extend(advancedFormat);
|
|
12
|
-
dayjs.extend(localizedFormat);
|
|
13
|
-
dayjs.extend(updateLocale);
|
|
14
|
-
|
|
15
|
-
dayjs.updateLocale('da', {
|
|
16
|
-
weekdaysShort: 'søn_man_tir_ons_tor_fre_lør'.split('_'),
|
|
17
|
-
monthsShort: 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export const formatTime = (date: Date, format = 'HH:mm'): string => dayjs(date).format(format);
|
|
21
|
-
export const getLocale = (): string => dayjs.locale();
|
|
22
|
-
export const setLocale = (locale: string): string => dayjs.locale(locale);
|
|
23
|
-
export const getThisYear = (): number => dayjs().year();
|
|
24
|
-
export const getYearToString = (date: Date): string => formatTime(date, 'YYYY');
|
|
25
|
-
export const getNumberOfWeeksInYear = (year: number): number => dayjs(`${year}-12-31`).isoWeek();
|
|
26
|
-
export const skipWeeks = (date: Date, multiplier: number): Date => dayjs(date).clone().add(multiplier * 7, 'days').toDate();
|
|
27
|
-
export const getWeek = (date: Date): number => dayjs(date).isoWeek();
|
|
28
|
-
// eslint-disable-next-line max-len
|
|
29
|
-
export const getDateByWeekday = (date: Date, index: number, locale = 'da'): Date => {
|
|
30
|
-
const currentLocale = getLocale();
|
|
31
|
-
setLocale(locale);
|
|
32
|
-
const newDate = dayjs(date).weekday(index).toDate();
|
|
33
|
-
if (currentLocale !== locale) {
|
|
34
|
-
setLocale(currentLocale);
|
|
35
|
-
}
|
|
36
|
-
return newDate;
|
|
37
|
-
};
|
|
38
|
-
const dateIsSameMonthAsCurrent = (date: Date): boolean => formatTime(new Date(), 'M') === formatTime(date, 'M');
|
|
39
|
-
export const getLongDate = (date: Date): string => formatTime(date, 'dddd, Do MMMM YYYY');
|
|
40
|
-
export const getShortDate = (date: Date): string => formatTime(date, `ddd D${(dateIsSameMonthAsCurrent(date) ? '' : `${getLocale() === 'da' ? '.' : ''} MMM`)}`);
|
|
41
|
-
export const isToday = (date: Date): boolean => dayjs(date).isSame(dayjs());
|
|
42
|
-
export const multipleDaysFormatTime = (date: Date, index: number, format = 'ddd HH:mm', firstLetterToUpper = true): string => {
|
|
43
|
-
if (index > 0) {
|
|
44
|
-
const formatted = formatTime(date, format);
|
|
45
|
-
if (firstLetterToUpper) {
|
|
46
|
-
return formatted.charAt(0).toUpperCase() + formatted.slice(1);
|
|
47
|
-
}
|
|
48
|
-
return formatted;
|
|
49
|
-
}
|
|
50
|
-
return formatTime(date);
|
|
51
|
-
};
|
|
52
|
-
export const formatDayOfWeek = (date: Date): string => formatTime(date, 'dddd').charAt(0).toUpperCase() + formatTime(date, 'dddd').slice(1);
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import 'dayjs/locale/da';
|
|
3
|
+
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
4
|
+
import weekday from 'dayjs/plugin/weekday';
|
|
5
|
+
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
6
|
+
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
7
|
+
import updateLocale from 'dayjs/plugin/updateLocale';
|
|
8
|
+
|
|
9
|
+
dayjs.extend(isoWeek);
|
|
10
|
+
dayjs.extend(weekday);
|
|
11
|
+
dayjs.extend(advancedFormat);
|
|
12
|
+
dayjs.extend(localizedFormat);
|
|
13
|
+
dayjs.extend(updateLocale);
|
|
14
|
+
|
|
15
|
+
dayjs.updateLocale('da', {
|
|
16
|
+
weekdaysShort: 'søn_man_tir_ons_tor_fre_lør'.split('_'),
|
|
17
|
+
monthsShort: 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const formatTime = (date: Date, format = 'HH:mm'): string => dayjs(date).format(format);
|
|
21
|
+
export const getLocale = (): string => dayjs.locale();
|
|
22
|
+
export const setLocale = (locale: string): string => dayjs.locale(locale);
|
|
23
|
+
export const getThisYear = (): number => dayjs().year();
|
|
24
|
+
export const getYearToString = (date: Date): string => formatTime(date, 'YYYY');
|
|
25
|
+
export const getNumberOfWeeksInYear = (year: number): number => dayjs(`${year}-12-31`).isoWeek();
|
|
26
|
+
export const skipWeeks = (date: Date, multiplier: number): Date => dayjs(date).clone().add(multiplier * 7, 'days').toDate();
|
|
27
|
+
export const getWeek = (date: Date): number => dayjs(date).isoWeek();
|
|
28
|
+
// eslint-disable-next-line max-len
|
|
29
|
+
export const getDateByWeekday = (date: Date, index: number, locale = 'da'): Date => {
|
|
30
|
+
const currentLocale = getLocale();
|
|
31
|
+
setLocale(locale);
|
|
32
|
+
const newDate = dayjs(date).weekday(index).toDate();
|
|
33
|
+
if (currentLocale !== locale) {
|
|
34
|
+
setLocale(currentLocale);
|
|
35
|
+
}
|
|
36
|
+
return newDate;
|
|
37
|
+
};
|
|
38
|
+
const dateIsSameMonthAsCurrent = (date: Date): boolean => formatTime(new Date(), 'M') === formatTime(date, 'M');
|
|
39
|
+
export const getLongDate = (date: Date): string => formatTime(date, 'dddd, Do MMMM YYYY');
|
|
40
|
+
export const getShortDate = (date: Date): string => formatTime(date, `ddd D${(dateIsSameMonthAsCurrent(date) ? '' : `${getLocale() === 'da' ? '.' : ''} MMM`)}`);
|
|
41
|
+
export const isToday = (date: Date): boolean => dayjs(date).isSame(dayjs());
|
|
42
|
+
export const multipleDaysFormatTime = (date: Date, index: number, format = 'ddd HH:mm', firstLetterToUpper = true): string => {
|
|
43
|
+
if (index > 0) {
|
|
44
|
+
const formatted = formatTime(date, format);
|
|
45
|
+
if (firstLetterToUpper) {
|
|
46
|
+
return formatted.charAt(0).toUpperCase() + formatted.slice(1);
|
|
47
|
+
}
|
|
48
|
+
return formatted;
|
|
49
|
+
}
|
|
50
|
+
return formatTime(date);
|
|
51
|
+
};
|
|
52
|
+
export const formatDayOfWeek = (date: Date): string => formatTime(date, 'dddd').charAt(0).toUpperCase() + formatTime(date, 'dddd').slice(1);
|