@1024pix/pix-ui 62.2.0 → 62.3.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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { warn } from '@ember/debug';
|
|
1
2
|
import { on } from '@ember/modifier';
|
|
2
3
|
import { action } from '@ember/object';
|
|
3
4
|
import { guidFor } from '@ember/object/internals';
|
|
@@ -11,21 +12,49 @@ export default class PixAccordions extends Component {
|
|
|
11
12
|
text = 'pix-accordions';
|
|
12
13
|
contentId = 'pix-accordions-' + guidFor(this);
|
|
13
14
|
|
|
14
|
-
@tracked
|
|
15
|
-
|
|
15
|
+
@tracked isCollapsedWhenUncontrolled = true;
|
|
16
|
+
hasBeenExpandedOnce = false;
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
constructor(...args) {
|
|
19
|
+
super(...args);
|
|
20
|
+
|
|
21
|
+
warn(
|
|
22
|
+
'PixAccordions: uncontrolled mode is deprecated, use @isExpanded and @onToggle instead',
|
|
23
|
+
Boolean(this.args.onToggle),
|
|
24
|
+
{
|
|
25
|
+
id: 'pix-ui.pix-accordions.uncontrolled.deprecated',
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get isControlled() {
|
|
31
|
+
return this.args.isExpanded !== undefined && this.args.isExpanded !== null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get isExpanded() {
|
|
35
|
+
return this.isControlled ? Boolean(this.args.isExpanded) : !this.isCollapsedWhenUncontrolled;
|
|
19
36
|
}
|
|
20
37
|
|
|
21
38
|
get isContentRendered() {
|
|
22
|
-
|
|
39
|
+
if (this.isExpanded) {
|
|
40
|
+
// eslint-disable-next-line ember/no-side-effects
|
|
41
|
+
this.hasBeenExpandedOnce = true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return this.hasBeenExpandedOnce;
|
|
23
45
|
}
|
|
24
46
|
|
|
25
47
|
@action
|
|
26
48
|
toggleAccordions() {
|
|
27
|
-
|
|
28
|
-
|
|
49
|
+
const nextIsExpanded = !this.isExpanded;
|
|
50
|
+
|
|
51
|
+
if (!this.isControlled) {
|
|
52
|
+
this.isCollapsedWhenUncontrolled = !nextIsExpanded;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (this.args.onToggle) {
|
|
56
|
+
this.args.onToggle(nextIsExpanded);
|
|
57
|
+
}
|
|
29
58
|
}
|
|
30
59
|
|
|
31
60
|
get isV2Version() {
|
|
@@ -40,7 +69,7 @@ export default class PixAccordions extends Component {
|
|
|
40
69
|
type="button"
|
|
41
70
|
{{on "click" this.toggleAccordions}}
|
|
42
71
|
aria-controls={{this.contentId}}
|
|
43
|
-
aria-expanded={{if this.
|
|
72
|
+
aria-expanded={{if this.isExpanded "true" "false"}}
|
|
44
73
|
...attributes
|
|
45
74
|
>
|
|
46
75
|
|
|
@@ -66,7 +95,7 @@ export default class PixAccordions extends Component {
|
|
|
66
95
|
<PixIcon
|
|
67
96
|
class="pix-accordions{{this.isV2Version}}-title-container__toggle-icon"
|
|
68
97
|
@ariaHidden={{true}}
|
|
69
|
-
@name="{{if this.
|
|
98
|
+
@name="{{if this.isExpanded 'chevronTop' 'chevronBottom'}}"
|
|
70
99
|
/>
|
|
71
100
|
</span>
|
|
72
101
|
</button>
|
|
@@ -74,7 +103,7 @@ export default class PixAccordions extends Component {
|
|
|
74
103
|
<div
|
|
75
104
|
id={{this.contentId}}
|
|
76
105
|
class="pix-accordions{{this.isV2Version}}__content"
|
|
77
|
-
aria-hidden={{if this.
|
|
106
|
+
aria-hidden={{if this.isExpanded "false" "true"}}
|
|
78
107
|
>
|
|
79
108
|
{{#if this.isContentRendered}}
|
|
80
109
|
{{yield to="content"}}
|