@1024pix/pix-ui 55.31.1 → 55.32.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.
- package/addon/components/pix-navigation.hbs +1 -1
- package/addon/components/pix-navigation.js +11 -1
- package/addon/components/pix-structure-switcher.hbs +20 -19
- package/addon/modifiers/on-arrow-down-up-action.js +14 -8
- package/addon/styles/_pix-structure-switcher.scss +13 -0
- package/package.json +1 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { warn } from '@ember/debug';
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
3
|
import { guidFor } from '@ember/object/internals';
|
|
4
|
+
import { inject as service } from '@ember/service';
|
|
4
5
|
import Component from '@glimmer/component';
|
|
5
6
|
import { tracked } from '@glimmer/tracking';
|
|
6
7
|
|
|
7
8
|
export default class PixMNavigation extends Component {
|
|
9
|
+
@service router;
|
|
10
|
+
|
|
8
11
|
constructor(...args) {
|
|
9
12
|
super(...args);
|
|
10
13
|
this._navigationId = 'navigation-' + guidFor(this);
|
|
@@ -23,11 +26,18 @@ export default class PixMNavigation extends Component {
|
|
|
23
26
|
@action
|
|
24
27
|
toggleNavigationMenu() {
|
|
25
28
|
this.navigationMenuOpened = !this.navigationMenuOpened;
|
|
29
|
+
|
|
30
|
+
if (this.navigationMenuOpened) {
|
|
31
|
+
this.router.on('routeDidChange', this.closeNavigation);
|
|
32
|
+
} else {
|
|
33
|
+
this.router.off('routeDidChange', this.closeNavigation);
|
|
34
|
+
}
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
@action
|
|
29
|
-
|
|
38
|
+
closeNavigation() {
|
|
30
39
|
this.navigationMenuOpened = false;
|
|
40
|
+
this.router.off('routeDidChange', this.closeNavigation);
|
|
31
41
|
}
|
|
32
42
|
|
|
33
43
|
get navigationId() {
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
...attributes
|
|
9
9
|
>
|
|
10
10
|
<PopperJS @placement="right-end" as |reference popover|>
|
|
11
|
-
|
|
12
11
|
<PixButton
|
|
13
12
|
{{reference}}
|
|
14
13
|
@size="small"
|
|
@@ -18,23 +17,25 @@
|
|
|
18
17
|
@triggerAction={{this.toggleMenu}}
|
|
19
18
|
aria-expanded={{this.isMenuOpen}}
|
|
20
19
|
>{{@label}}</PixButton>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
{{#if this.isMenuOpen}}
|
|
21
|
+
<div
|
|
22
|
+
{{popover}}
|
|
23
|
+
class="pix-select__dropdown {{unless this.isMenuOpen 'pix-select__dropdown--closed'}}"
|
|
24
|
+
>
|
|
25
|
+
<PixSelectList
|
|
26
|
+
aria-labelledby={{this.switcherId}}
|
|
27
|
+
{{on "transitionend" this.focus}}
|
|
28
|
+
@hideDefaultOption={{true}}
|
|
29
|
+
@listId={{this.listId}}
|
|
30
|
+
@selectId={{this.switcherId}}
|
|
31
|
+
@value={{@value}}
|
|
32
|
+
@onChange={{this.onSelectListChange}}
|
|
33
|
+
@defaultOption={{@defaultOption}}
|
|
34
|
+
@isExpanded={{this.isMenuOpen}}
|
|
35
|
+
@options={{@structures}}
|
|
36
|
+
@defaultOptionValue={{@label}}
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
{{/if}}
|
|
39
40
|
</PopperJS>
|
|
40
41
|
</div>
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { modifier } from 'ember-modifier';
|
|
2
2
|
|
|
3
3
|
export default modifier((element, [elementId, callback, isExpanded]) => {
|
|
4
|
-
const elementToTarget = document.getElementById(elementId);
|
|
5
|
-
|
|
6
4
|
element.addEventListener('keydown', handleKeyDown);
|
|
7
5
|
|
|
8
6
|
return () => {
|
|
@@ -19,7 +17,10 @@ export default modifier((element, [elementId, callback, isExpanded]) => {
|
|
|
19
17
|
event.preventDefault();
|
|
20
18
|
|
|
21
19
|
const focusElement = () => {
|
|
22
|
-
const
|
|
20
|
+
const targetElement = document.getElementById(elementId);
|
|
21
|
+
if (!targetElement) return;
|
|
22
|
+
|
|
23
|
+
const focusableElements = findFocusableElements(targetElement);
|
|
23
24
|
|
|
24
25
|
const [firstFocusableElement] = focusableElements;
|
|
25
26
|
const lastFocusableElement = focusableElements[focusableElements.length - 1];
|
|
@@ -60,15 +61,20 @@ export default modifier((element, [elementId, callback, isExpanded]) => {
|
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
if (!isExpanded) {
|
|
63
|
-
elementToTarget.addEventListener('transitionend', focusElement);
|
|
64
|
-
|
|
65
64
|
callback(event);
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
const waitForElement = () => {
|
|
67
|
+
const targetElement = document.getElementById(elementId);
|
|
68
|
+
if (targetElement) {
|
|
69
|
+
targetElement.addEventListener('transitionend', focusElement, { once: true });
|
|
70
|
+
} else {
|
|
71
|
+
requestAnimationFrame(waitForElement);
|
|
72
|
+
}
|
|
69
73
|
};
|
|
74
|
+
|
|
75
|
+
waitForElement();
|
|
70
76
|
} else {
|
|
71
|
-
focusElement(
|
|
77
|
+
focusElement();
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
});
|
|
@@ -35,6 +35,9 @@
|
|
|
35
35
|
margin-left: calc(-1 * var(--pix-spacing-4x)) !important;
|
|
36
36
|
overflow-y: auto;
|
|
37
37
|
border-radius: 8px;
|
|
38
|
+
opacity: 0;
|
|
39
|
+
animation: fade-in-dropdown 150ms ease-in-out forwards;
|
|
40
|
+
animation-delay: 50ms;
|
|
38
41
|
|
|
39
42
|
@include breakpoints.device-is('mobile') {
|
|
40
43
|
position: static !important;
|
|
@@ -100,3 +103,13 @@
|
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
}
|
|
106
|
+
|
|
107
|
+
@keyframes fade-in-dropdown {
|
|
108
|
+
from {
|
|
109
|
+
opacity: 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
to {
|
|
113
|
+
opacity: 1;
|
|
114
|
+
}
|
|
115
|
+
}
|