@aarhus-university/au-designsystem-delphinus 0.26.6 → 0.26.7
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/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
## 0.26.7 (June 21, 2022)
|
|
2
|
+
|
|
3
|
+
### Core Delphinus Updates
|
|
4
|
+
* Return types on navigational functions for useEffect in React 18.
|
|
5
|
+
### Delphinus Projects Updates
|
|
6
|
+
None
|
|
1
7
|
## 0.26.6 (June 21, 2022)
|
|
2
8
|
|
|
3
9
|
### Core Delphinus Updates
|
|
4
10
|
* Removal of event listeners (before re-adding) in scripts in preparation for StrictMode in React 18.
|
|
11
|
+
### Delphinus Projects Updates
|
|
12
|
+
None
|
|
5
13
|
|
|
6
14
|
## 0.26.5 (June 20, 2022)
|
|
7
15
|
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ const closeResponsiveNav = (navElements: NodeListOf<Element>, keepOpen: HTMLElem
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
const setResponsiveToggle = (navElements: NodeListOf<Element>):
|
|
30
|
+
const setResponsiveToggle = (navElements: NodeListOf<Element>): CleanUpPair[] => {
|
|
31
31
|
const toggleMenu = (button: HTMLElement) => {
|
|
32
32
|
const parent = findNav(button);
|
|
33
33
|
|
|
@@ -49,6 +49,8 @@ const setResponsiveToggle = (navElements: NodeListOf<Element>): void => {
|
|
|
49
49
|
return parent;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
const cleanUp: CleanUpPair[] = [];
|
|
53
|
+
|
|
52
54
|
const toggle = document.querySelectorAll('.nav__toggle');
|
|
53
55
|
toggle.forEach((button) => {
|
|
54
56
|
const clickEvent = () => {
|
|
@@ -57,12 +59,22 @@ const setResponsiveToggle = (navElements: NodeListOf<Element>): void => {
|
|
|
57
59
|
button.setAttribute('aria-expanded', ariaExpanded === 'false' ? 'true' : 'false');
|
|
58
60
|
closeResponsiveNav(navElements, nav);
|
|
59
61
|
};
|
|
60
|
-
|
|
62
|
+
|
|
63
|
+
cleanUp.push({
|
|
64
|
+
element: button,
|
|
65
|
+
clickEvent,
|
|
66
|
+
});
|
|
67
|
+
|
|
61
68
|
button.addEventListener('click', clickEvent);
|
|
62
69
|
});
|
|
70
|
+
|
|
71
|
+
return cleanUp;
|
|
63
72
|
};
|
|
64
73
|
|
|
65
|
-
const setResponsiveNav = (
|
|
74
|
+
const setResponsiveNav = (
|
|
75
|
+
navElements: NodeListOf<Element>,
|
|
76
|
+
navElement: Element,
|
|
77
|
+
): SetResponsiveNavCleanUp => {
|
|
66
78
|
const navToggledClass = 'nav--toggled';
|
|
67
79
|
const navItemsClass = 'nav__items';
|
|
68
80
|
// gitlab #117
|
|
@@ -99,17 +111,19 @@ const setResponsiveNav = (navElements: NodeListOf<Element>, navElement: Element)
|
|
|
99
111
|
}
|
|
100
112
|
|
|
101
113
|
// gitlab #115
|
|
102
|
-
const bodyClickEvent = (e: MouseEvent)
|
|
114
|
+
const bodyClickEvent = (e: MouseEvent) => {
|
|
103
115
|
if (!(e.target as HTMLElement).classList.contains('nav__toggle')
|
|
104
116
|
&& !isElementWithClassNameInEventPath(e, navItemsClass)) {
|
|
105
117
|
closeResponsiveNav(navElements);
|
|
106
118
|
}
|
|
107
119
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
120
|
+
|
|
121
|
+
document.querySelector('body')?.addEventListener('click', bodyClickEvent);
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
element: document.querySelector('body'),
|
|
125
|
+
clickEvent: bodyClickEvent,
|
|
126
|
+
};
|
|
113
127
|
};
|
|
114
128
|
|
|
115
129
|
const closeSubNav = (buttons: NodeListOf<Element>, keepOpen: Element | null = null) => {
|
|
@@ -125,9 +139,9 @@ const closeSubNav = (buttons: NodeListOf<Element>, keepOpen: Element | null = nu
|
|
|
125
139
|
});
|
|
126
140
|
};
|
|
127
141
|
|
|
128
|
-
const setSubNavToggle = (buttons: NodeListOf<Element>, button: Element):
|
|
142
|
+
const setSubNavToggle = (buttons: NodeListOf<Element>, button: Element): SetSubNavToggleCleanUp => {
|
|
129
143
|
const subNavClass = 'sub-nav--toggled';
|
|
130
|
-
const
|
|
144
|
+
const buttonClickEvent = () => {
|
|
131
145
|
button?.parentElement?.classList.toggle(subNavClass);
|
|
132
146
|
if (button?.parentElement?.classList.contains(subNavClass)) {
|
|
133
147
|
button.setAttribute('aria-expanded', 'true');
|
|
@@ -136,8 +150,8 @@ const setSubNavToggle = (buttons: NodeListOf<Element>, button: Element): void =>
|
|
|
136
150
|
}
|
|
137
151
|
closeSubNav(buttons, button);
|
|
138
152
|
};
|
|
139
|
-
|
|
140
|
-
button.addEventListener('click',
|
|
153
|
+
|
|
154
|
+
button.addEventListener('click', buttonClickEvent);
|
|
141
155
|
|
|
142
156
|
// gitlab #115
|
|
143
157
|
const bodyClickEvent = (e: MouseEvent) => {
|
|
@@ -145,11 +159,13 @@ const setSubNavToggle = (buttons: NodeListOf<Element>, button: Element): void =>
|
|
|
145
159
|
closeSubNav(buttons);
|
|
146
160
|
}
|
|
147
161
|
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
162
|
+
|
|
163
|
+
document.querySelector('body')?.addEventListener('click', bodyClickEvent);
|
|
164
|
+
return {
|
|
165
|
+
buttonClickEvent,
|
|
166
|
+
element: document.querySelector('body'),
|
|
167
|
+
bodyClickEvent,
|
|
168
|
+
};
|
|
153
169
|
};
|
|
154
170
|
|
|
155
171
|
const setCopyToClipboard = (lang = 'da'): void => {
|
|
@@ -10,7 +10,8 @@ const removeOverlay = (containers: NodeListOf<Element>): void => {
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const setSelectionListOverlays = ():
|
|
13
|
+
const setSelectionListOverlays = (): setSelectionListOverlaysCleanUp => {
|
|
14
|
+
const cleanUp: CleanUpPair[] = [];
|
|
14
15
|
const containers = document.querySelectorAll('.selection-list-overlay-container');
|
|
15
16
|
containers.forEach((container) => {
|
|
16
17
|
const btn = container.querySelector('button') as HTMLElement; // Assumes only one button pr container
|
|
@@ -21,7 +22,11 @@ const setSelectionListOverlays = (): void => {
|
|
|
21
22
|
sibling.classList.add('selection-list--toggled');
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
|
-
|
|
25
|
+
cleanUp.push({
|
|
26
|
+
element: btn,
|
|
27
|
+
clickEvent,
|
|
28
|
+
});
|
|
29
|
+
|
|
25
30
|
btn.addEventListener('click', clickEvent);
|
|
26
31
|
});
|
|
27
32
|
|
|
@@ -32,6 +37,12 @@ const setSelectionListOverlays = (): void => {
|
|
|
32
37
|
}
|
|
33
38
|
};
|
|
34
39
|
document.querySelector('body')?.addEventListener('click', bodyClickEvent);
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
pairs: cleanUp,
|
|
43
|
+
element: document.querySelector('body'),
|
|
44
|
+
clickEvent: bodyClickEvent,
|
|
45
|
+
};
|
|
35
46
|
};
|
|
36
47
|
|
|
37
48
|
export {
|
|
@@ -40,7 +40,8 @@ const setToolbars = (): void => {
|
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
const setToolbarToggle = ():
|
|
43
|
+
const setToolbarToggle = (): CleanUpPair[] => {
|
|
44
|
+
const cleanUp: CleanUpPair[] = [];
|
|
44
45
|
const buttons = document.querySelectorAll('.toolbar .toolbar__toggle');
|
|
45
46
|
buttons.forEach((button) => {
|
|
46
47
|
const clickEvent = () => {
|
|
@@ -55,9 +56,13 @@ const setToolbarToggle = (): void => {
|
|
|
55
56
|
button.setAttribute('aria-expanded', ariaExpanded === 'false' ? 'true' : 'false');
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
cleanUp.push({
|
|
60
|
+
element: button,
|
|
61
|
+
clickEvent,
|
|
62
|
+
});
|
|
59
63
|
button.addEventListener('click', clickEvent);
|
|
60
64
|
});
|
|
65
|
+
return cleanUp;
|
|
61
66
|
};
|
|
62
67
|
|
|
63
68
|
export {
|
package/types/common/main.d.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface CleanUpPair {
|
|
2
|
+
element: Element,
|
|
3
|
+
clickEvent: () => void,
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface SetResponsiveNavCleanUp {
|
|
7
|
+
element: Element | null,
|
|
8
|
+
clickEvent: (event: MouseEvent) => void,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface SetSubNavToggleCleanUp {
|
|
12
|
+
buttonClickEvent: () => void,
|
|
13
|
+
element: Element | null,
|
|
14
|
+
bodyClickEvent: (e: MouseEvent) => void,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface setSelectionListOverlaysCleanUp {
|
|
18
|
+
pairs: CleanUpPair[],
|
|
19
|
+
element: Element | null,
|
|
20
|
+
clickEvent: (event: MouseEvent) => void,
|
|
21
|
+
}
|