@shoper/phoenix_design_system 1.18.11-13 → 1.18.11-15
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/build/cjs/packages/phoenix/src/components/accordion/accordion_content.js +100 -32
- package/build/cjs/packages/phoenix/src/components/accordion/accordion_content.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/accordion/accordion_content.d.ts +8 -2
- package/build/esm/packages/phoenix/src/components/accordion/accordion_content.js +100 -32
- package/build/esm/packages/phoenix/src/components/accordion/accordion_content.js.map +1 -1
- package/package.json +1 -1
|
@@ -18,9 +18,31 @@ exports.HAccordionContent = class HAccordionContent extends phoenix_light_lit_el
|
|
|
18
18
|
constructor() {
|
|
19
19
|
super();
|
|
20
20
|
this.transitionName = 'accordion-toggle';
|
|
21
|
+
this.isDevAccordionOptimizationFlagEnabled = false;
|
|
22
|
+
this._resizeObserver = null;
|
|
23
|
+
this._isTransitioning = false;
|
|
21
24
|
this._resizeDebounceTimer = null;
|
|
22
25
|
this._mutationDebounceTimer = null;
|
|
23
26
|
this._mutationObserver = null;
|
|
27
|
+
this._handleResizeObserver = () => {
|
|
28
|
+
if (this._isTransitioning)
|
|
29
|
+
return;
|
|
30
|
+
if (this.hidden || this.style.height === '0px')
|
|
31
|
+
return;
|
|
32
|
+
this._cacheScrollHeight();
|
|
33
|
+
};
|
|
34
|
+
this._measureOriginalHeight = () => {
|
|
35
|
+
const previousDisplay = this.style.display;
|
|
36
|
+
this.style.setProperty('display', 'block', 'important');
|
|
37
|
+
this._cacheScrollHeight();
|
|
38
|
+
this.style.display = previousDisplay;
|
|
39
|
+
};
|
|
40
|
+
this._cacheScrollHeight = () => {
|
|
41
|
+
const newHeight = this.scrollHeight;
|
|
42
|
+
if (newHeight !== 0 || this.children.length === 0) {
|
|
43
|
+
this._originalHeight = `${newHeight}px`;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
24
46
|
this._handleResize = () => {
|
|
25
47
|
if (this._resizeDebounceTimer !== null) {
|
|
26
48
|
window.cancelAnimationFrame(this._resizeDebounceTimer);
|
|
@@ -36,13 +58,19 @@ exports.HAccordionContent = class HAccordionContent extends phoenix_light_lit_el
|
|
|
36
58
|
const previousDisplay = this.style.display;
|
|
37
59
|
this.style.setProperty('display', 'block', 'important');
|
|
38
60
|
this.style.height = 'auto';
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
61
|
+
requestAnimationFrame(() => {
|
|
62
|
+
this._setOriginalHeightValue();
|
|
63
|
+
this.style.display = previousDisplay;
|
|
64
|
+
this.style.height = this.hidden ? '0px' : this._originalHeight;
|
|
65
|
+
});
|
|
44
66
|
});
|
|
45
67
|
};
|
|
68
|
+
this._setOriginalHeightValue = () => {
|
|
69
|
+
const newHeight = this.getBoundingClientRect().height;
|
|
70
|
+
if (newHeight !== 0 || this.children.length === 0) {
|
|
71
|
+
this._originalHeight = `${newHeight}px`;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
46
74
|
this._handleMutation = () => {
|
|
47
75
|
if (this._mutationDebounceTimer !== null) {
|
|
48
76
|
window.clearTimeout(this._mutationDebounceTimer);
|
|
@@ -50,38 +78,55 @@ exports.HAccordionContent = class HAccordionContent extends phoenix_light_lit_el
|
|
|
50
78
|
this._mutationDebounceTimer = window.setTimeout(() => {
|
|
51
79
|
requestAnimationFrame(() => {
|
|
52
80
|
this.style.height = 'auto';
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
81
|
+
requestAnimationFrame(() => {
|
|
82
|
+
this._setOriginalHeightValue();
|
|
83
|
+
if (this.hidden) {
|
|
84
|
+
this.style.height = '0px';
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this.style.height = this._originalHeight;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
56
90
|
});
|
|
57
91
|
}, MUTATION_DEBOUNCE_MS);
|
|
58
92
|
};
|
|
59
|
-
this._setOriginalHeightValue = () => {
|
|
60
|
-
const newHeight = this.getBoundingClientRect().height;
|
|
61
|
-
if (newHeight !== 0 || this.children.length === 0) {
|
|
62
|
-
this._originalHeight = `${newHeight}px`;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
93
|
this._expand = () => {
|
|
94
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
95
|
+
this._cacheScrollHeight();
|
|
96
|
+
this._isTransitioning = true;
|
|
97
|
+
}
|
|
66
98
|
this._setHeight(this._originalHeight);
|
|
67
99
|
};
|
|
68
100
|
this._handleTransitionEnd = (e) => {
|
|
69
101
|
if (e.propertyName !== 'height' || e.target !== this) {
|
|
70
102
|
return;
|
|
71
103
|
}
|
|
104
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
105
|
+
this._isTransitioning = false;
|
|
106
|
+
}
|
|
72
107
|
if (!this.hidden && this.style.height !== '0px') {
|
|
73
108
|
this.style.height = 'auto';
|
|
74
109
|
}
|
|
75
110
|
};
|
|
76
111
|
this._collapse = () => {
|
|
112
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
113
|
+
this._isTransitioning = true;
|
|
114
|
+
}
|
|
77
115
|
const currentHeight = this.getBoundingClientRect().height;
|
|
78
116
|
this._setHeight(`${currentHeight}px`);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
117
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
118
|
+
void this.offsetHeight;
|
|
119
|
+
requestAnimationFrame(() => {
|
|
120
|
+
this._setHeight('0px');
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
requestAnimationFrame(() => {
|
|
125
|
+
requestAnimationFrame(() => {
|
|
126
|
+
this._setHeight('0px');
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
85
130
|
};
|
|
86
131
|
this.setAttribute('role', 'region');
|
|
87
132
|
this._boundHandleTransitionEnd = this._handleTransitionEnd.bind(this);
|
|
@@ -91,12 +136,24 @@ exports.HAccordionContent = class HAccordionContent extends phoenix_light_lit_el
|
|
|
91
136
|
this._contextConsumer = new context_consumer_controller.ContextConsumerController(this);
|
|
92
137
|
this._transitionController = new transition_controller.TransitionController(this, this.transitionName);
|
|
93
138
|
this._subscribeObserver();
|
|
94
|
-
|
|
139
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
140
|
+
this._resizeObserver = new ResizeObserver(this._handleResizeObserver);
|
|
141
|
+
this._resizeObserver.observe(this);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
window.addEventListener('resize', this._handleResize, { passive: true });
|
|
145
|
+
}
|
|
95
146
|
this.addEventListener('transitionend', this._boundHandleTransitionEnd);
|
|
96
147
|
}
|
|
97
148
|
firstUpdated(props) {
|
|
98
149
|
super.firstUpdated(props);
|
|
99
|
-
this.
|
|
150
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
151
|
+
this._measureOriginalHeight();
|
|
152
|
+
this.style.height = this.hidden ? '0px' : this._originalHeight;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this._setStylingOptions();
|
|
156
|
+
}
|
|
100
157
|
}
|
|
101
158
|
async _subscribeObserver() {
|
|
102
159
|
this._accordionGroupProps = await this._contextConsumer.consumeAsync(accordion_constants.ACCORDION_CONTEXTS.accordionGroupProps);
|
|
@@ -105,8 +162,10 @@ exports.HAccordionContent = class HAccordionContent extends phoenix_light_lit_el
|
|
|
105
162
|
accordionProps.opened ? this._transitionController.show(this._expand) : this._transitionController.hide(this._collapse);
|
|
106
163
|
});
|
|
107
164
|
this._accordionGroupProps.subscribe(this._accordionGroupPropsObserver);
|
|
108
|
-
|
|
109
|
-
|
|
165
|
+
if (!this.isDevAccordionOptimizationFlagEnabled) {
|
|
166
|
+
this._mutationObserver = new MutationObserver(this._handleMutation);
|
|
167
|
+
this._mutationObserver.observe(this, { childList: true, subtree: true });
|
|
168
|
+
}
|
|
110
169
|
}
|
|
111
170
|
_setHeight(height) {
|
|
112
171
|
this.style.height = height;
|
|
@@ -116,24 +175,33 @@ exports.HAccordionContent = class HAccordionContent extends phoenix_light_lit_el
|
|
|
116
175
|
this.setAttribute('labelledby', regionId);
|
|
117
176
|
}
|
|
118
177
|
disconnectedCallback() {
|
|
119
|
-
var _a, _b;
|
|
178
|
+
var _a, _b, _c;
|
|
120
179
|
super.disconnectedCallback();
|
|
121
180
|
(_a = this._accordionGroupProps) === null || _a === void 0 ? void 0 : _a.unsubscribe(this._accordionGroupPropsObserver);
|
|
122
|
-
(
|
|
123
|
-
|
|
124
|
-
this.removeEventListener('transitionend', this._boundHandleTransitionEnd);
|
|
125
|
-
if (this._resizeDebounceTimer !== null) {
|
|
126
|
-
window.cancelAnimationFrame(this._resizeDebounceTimer);
|
|
181
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
182
|
+
(_b = this._resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
127
183
|
}
|
|
128
|
-
|
|
129
|
-
|
|
184
|
+
else {
|
|
185
|
+
(_c = this._mutationObserver) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
186
|
+
window.removeEventListener('resize', this._handleResize);
|
|
187
|
+
if (this._resizeDebounceTimer !== null) {
|
|
188
|
+
window.cancelAnimationFrame(this._resizeDebounceTimer);
|
|
189
|
+
}
|
|
190
|
+
if (this._mutationDebounceTimer !== null) {
|
|
191
|
+
window.clearTimeout(this._mutationDebounceTimer);
|
|
192
|
+
}
|
|
130
193
|
}
|
|
194
|
+
this.removeEventListener('transitionend', this._boundHandleTransitionEnd);
|
|
131
195
|
}
|
|
132
196
|
};
|
|
133
197
|
tslib_es6.__decorate([
|
|
134
198
|
decorators.property(),
|
|
135
199
|
tslib_es6.__metadata("design:type", Object)
|
|
136
200
|
], exports.HAccordionContent.prototype, "transitionName", void 0);
|
|
201
|
+
tslib_es6.__decorate([
|
|
202
|
+
decorators.property({ type: Boolean, attribute: 'is-dev-accordion-optimization-flag-enabled' }),
|
|
203
|
+
tslib_es6.__metadata("design:type", Boolean)
|
|
204
|
+
], exports.HAccordionContent.prototype, "isDevAccordionOptimizationFlagEnabled", void 0);
|
|
137
205
|
exports.HAccordionContent = tslib_es6.__decorate([
|
|
138
206
|
phoenix_custom_element.phoenixCustomElement('h-accordion-content'),
|
|
139
207
|
tslib_es6.__metadata("design:paramtypes", [])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -2,11 +2,14 @@ import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/pho
|
|
|
2
2
|
import { PropertyValues } from 'lit';
|
|
3
3
|
export declare class HAccordionContent extends PhoenixLightLitElement {
|
|
4
4
|
transitionName: string;
|
|
5
|
+
isDevAccordionOptimizationFlagEnabled: boolean;
|
|
5
6
|
private _transitionController;
|
|
6
7
|
private _contextConsumer;
|
|
7
8
|
private _accordionGroupProps;
|
|
8
9
|
private _accordionGroupPropsObserver;
|
|
9
10
|
private _originalHeight;
|
|
11
|
+
private _resizeObserver;
|
|
12
|
+
private _isTransitioning;
|
|
10
13
|
private _resizeDebounceTimer;
|
|
11
14
|
private _mutationDebounceTimer;
|
|
12
15
|
private _mutationObserver;
|
|
@@ -14,11 +17,14 @@ export declare class HAccordionContent extends PhoenixLightLitElement {
|
|
|
14
17
|
constructor();
|
|
15
18
|
connectedCallback(): void;
|
|
16
19
|
firstUpdated(props: PropertyValues): void;
|
|
20
|
+
private _handleResizeObserver;
|
|
21
|
+
private _measureOriginalHeight;
|
|
22
|
+
private _cacheScrollHeight;
|
|
17
23
|
private _handleResize;
|
|
18
24
|
private _setStylingOptions;
|
|
19
|
-
private _subscribeObserver;
|
|
20
|
-
private _handleMutation;
|
|
21
25
|
private _setOriginalHeightValue;
|
|
26
|
+
private _handleMutation;
|
|
27
|
+
private _subscribeObserver;
|
|
22
28
|
private _expand;
|
|
23
29
|
private _handleTransitionEnd;
|
|
24
30
|
private _collapse;
|
|
@@ -14,9 +14,31 @@ let HAccordionContent = class HAccordionContent extends PhoenixLightLitElement {
|
|
|
14
14
|
constructor() {
|
|
15
15
|
super();
|
|
16
16
|
this.transitionName = 'accordion-toggle';
|
|
17
|
+
this.isDevAccordionOptimizationFlagEnabled = false;
|
|
18
|
+
this._resizeObserver = null;
|
|
19
|
+
this._isTransitioning = false;
|
|
17
20
|
this._resizeDebounceTimer = null;
|
|
18
21
|
this._mutationDebounceTimer = null;
|
|
19
22
|
this._mutationObserver = null;
|
|
23
|
+
this._handleResizeObserver = () => {
|
|
24
|
+
if (this._isTransitioning)
|
|
25
|
+
return;
|
|
26
|
+
if (this.hidden || this.style.height === '0px')
|
|
27
|
+
return;
|
|
28
|
+
this._cacheScrollHeight();
|
|
29
|
+
};
|
|
30
|
+
this._measureOriginalHeight = () => {
|
|
31
|
+
const previousDisplay = this.style.display;
|
|
32
|
+
this.style.setProperty('display', 'block', 'important');
|
|
33
|
+
this._cacheScrollHeight();
|
|
34
|
+
this.style.display = previousDisplay;
|
|
35
|
+
};
|
|
36
|
+
this._cacheScrollHeight = () => {
|
|
37
|
+
const newHeight = this.scrollHeight;
|
|
38
|
+
if (newHeight !== 0 || this.children.length === 0) {
|
|
39
|
+
this._originalHeight = `${newHeight}px`;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
20
42
|
this._handleResize = () => {
|
|
21
43
|
if (this._resizeDebounceTimer !== null) {
|
|
22
44
|
window.cancelAnimationFrame(this._resizeDebounceTimer);
|
|
@@ -32,13 +54,19 @@ let HAccordionContent = class HAccordionContent extends PhoenixLightLitElement {
|
|
|
32
54
|
const previousDisplay = this.style.display;
|
|
33
55
|
this.style.setProperty('display', 'block', 'important');
|
|
34
56
|
this.style.height = 'auto';
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
57
|
+
requestAnimationFrame(() => {
|
|
58
|
+
this._setOriginalHeightValue();
|
|
59
|
+
this.style.display = previousDisplay;
|
|
60
|
+
this.style.height = this.hidden ? '0px' : this._originalHeight;
|
|
61
|
+
});
|
|
40
62
|
});
|
|
41
63
|
};
|
|
64
|
+
this._setOriginalHeightValue = () => {
|
|
65
|
+
const newHeight = this.getBoundingClientRect().height;
|
|
66
|
+
if (newHeight !== 0 || this.children.length === 0) {
|
|
67
|
+
this._originalHeight = `${newHeight}px`;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
42
70
|
this._handleMutation = () => {
|
|
43
71
|
if (this._mutationDebounceTimer !== null) {
|
|
44
72
|
window.clearTimeout(this._mutationDebounceTimer);
|
|
@@ -46,38 +74,55 @@ let HAccordionContent = class HAccordionContent extends PhoenixLightLitElement {
|
|
|
46
74
|
this._mutationDebounceTimer = window.setTimeout(() => {
|
|
47
75
|
requestAnimationFrame(() => {
|
|
48
76
|
this.style.height = 'auto';
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
77
|
+
requestAnimationFrame(() => {
|
|
78
|
+
this._setOriginalHeightValue();
|
|
79
|
+
if (this.hidden) {
|
|
80
|
+
this.style.height = '0px';
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this.style.height = this._originalHeight;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
52
86
|
});
|
|
53
87
|
}, MUTATION_DEBOUNCE_MS);
|
|
54
88
|
};
|
|
55
|
-
this._setOriginalHeightValue = () => {
|
|
56
|
-
const newHeight = this.getBoundingClientRect().height;
|
|
57
|
-
if (newHeight !== 0 || this.children.length === 0) {
|
|
58
|
-
this._originalHeight = `${newHeight}px`;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
89
|
this._expand = () => {
|
|
90
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
91
|
+
this._cacheScrollHeight();
|
|
92
|
+
this._isTransitioning = true;
|
|
93
|
+
}
|
|
62
94
|
this._setHeight(this._originalHeight);
|
|
63
95
|
};
|
|
64
96
|
this._handleTransitionEnd = (e) => {
|
|
65
97
|
if (e.propertyName !== 'height' || e.target !== this) {
|
|
66
98
|
return;
|
|
67
99
|
}
|
|
100
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
101
|
+
this._isTransitioning = false;
|
|
102
|
+
}
|
|
68
103
|
if (!this.hidden && this.style.height !== '0px') {
|
|
69
104
|
this.style.height = 'auto';
|
|
70
105
|
}
|
|
71
106
|
};
|
|
72
107
|
this._collapse = () => {
|
|
108
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
109
|
+
this._isTransitioning = true;
|
|
110
|
+
}
|
|
73
111
|
const currentHeight = this.getBoundingClientRect().height;
|
|
74
112
|
this._setHeight(`${currentHeight}px`);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
113
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
114
|
+
void this.offsetHeight;
|
|
115
|
+
requestAnimationFrame(() => {
|
|
116
|
+
this._setHeight('0px');
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
requestAnimationFrame(() => {
|
|
121
|
+
requestAnimationFrame(() => {
|
|
122
|
+
this._setHeight('0px');
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
81
126
|
};
|
|
82
127
|
this.setAttribute('role', 'region');
|
|
83
128
|
this._boundHandleTransitionEnd = this._handleTransitionEnd.bind(this);
|
|
@@ -87,12 +132,24 @@ let HAccordionContent = class HAccordionContent extends PhoenixLightLitElement {
|
|
|
87
132
|
this._contextConsumer = new ContextConsumerController(this);
|
|
88
133
|
this._transitionController = new TransitionController(this, this.transitionName);
|
|
89
134
|
this._subscribeObserver();
|
|
90
|
-
|
|
135
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
136
|
+
this._resizeObserver = new ResizeObserver(this._handleResizeObserver);
|
|
137
|
+
this._resizeObserver.observe(this);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
window.addEventListener('resize', this._handleResize, { passive: true });
|
|
141
|
+
}
|
|
91
142
|
this.addEventListener('transitionend', this._boundHandleTransitionEnd);
|
|
92
143
|
}
|
|
93
144
|
firstUpdated(props) {
|
|
94
145
|
super.firstUpdated(props);
|
|
95
|
-
this.
|
|
146
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
147
|
+
this._measureOriginalHeight();
|
|
148
|
+
this.style.height = this.hidden ? '0px' : this._originalHeight;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
this._setStylingOptions();
|
|
152
|
+
}
|
|
96
153
|
}
|
|
97
154
|
async _subscribeObserver() {
|
|
98
155
|
this._accordionGroupProps = await this._contextConsumer.consumeAsync(ACCORDION_CONTEXTS.accordionGroupProps);
|
|
@@ -101,8 +158,10 @@ let HAccordionContent = class HAccordionContent extends PhoenixLightLitElement {
|
|
|
101
158
|
accordionProps.opened ? this._transitionController.show(this._expand) : this._transitionController.hide(this._collapse);
|
|
102
159
|
});
|
|
103
160
|
this._accordionGroupProps.subscribe(this._accordionGroupPropsObserver);
|
|
104
|
-
|
|
105
|
-
|
|
161
|
+
if (!this.isDevAccordionOptimizationFlagEnabled) {
|
|
162
|
+
this._mutationObserver = new MutationObserver(this._handleMutation);
|
|
163
|
+
this._mutationObserver.observe(this, { childList: true, subtree: true });
|
|
164
|
+
}
|
|
106
165
|
}
|
|
107
166
|
_setHeight(height) {
|
|
108
167
|
this.style.height = height;
|
|
@@ -112,24 +171,33 @@ let HAccordionContent = class HAccordionContent extends PhoenixLightLitElement {
|
|
|
112
171
|
this.setAttribute('labelledby', regionId);
|
|
113
172
|
}
|
|
114
173
|
disconnectedCallback() {
|
|
115
|
-
var _a, _b;
|
|
174
|
+
var _a, _b, _c;
|
|
116
175
|
super.disconnectedCallback();
|
|
117
176
|
(_a = this._accordionGroupProps) === null || _a === void 0 ? void 0 : _a.unsubscribe(this._accordionGroupPropsObserver);
|
|
118
|
-
(
|
|
119
|
-
|
|
120
|
-
this.removeEventListener('transitionend', this._boundHandleTransitionEnd);
|
|
121
|
-
if (this._resizeDebounceTimer !== null) {
|
|
122
|
-
window.cancelAnimationFrame(this._resizeDebounceTimer);
|
|
177
|
+
if (this.isDevAccordionOptimizationFlagEnabled) {
|
|
178
|
+
(_b = this._resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
123
179
|
}
|
|
124
|
-
|
|
125
|
-
|
|
180
|
+
else {
|
|
181
|
+
(_c = this._mutationObserver) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
182
|
+
window.removeEventListener('resize', this._handleResize);
|
|
183
|
+
if (this._resizeDebounceTimer !== null) {
|
|
184
|
+
window.cancelAnimationFrame(this._resizeDebounceTimer);
|
|
185
|
+
}
|
|
186
|
+
if (this._mutationDebounceTimer !== null) {
|
|
187
|
+
window.clearTimeout(this._mutationDebounceTimer);
|
|
188
|
+
}
|
|
126
189
|
}
|
|
190
|
+
this.removeEventListener('transitionend', this._boundHandleTransitionEnd);
|
|
127
191
|
}
|
|
128
192
|
};
|
|
129
193
|
__decorate([
|
|
130
194
|
property(),
|
|
131
195
|
__metadata("design:type", Object)
|
|
132
196
|
], HAccordionContent.prototype, "transitionName", void 0);
|
|
197
|
+
__decorate([
|
|
198
|
+
property({ type: Boolean, attribute: 'is-dev-accordion-optimization-flag-enabled' }),
|
|
199
|
+
__metadata("design:type", Boolean)
|
|
200
|
+
], HAccordionContent.prototype, "isDevAccordionOptimizationFlagEnabled", void 0);
|
|
133
201
|
HAccordionContent = __decorate([
|
|
134
202
|
phoenixCustomElement('h-accordion-content'),
|
|
135
203
|
__metadata("design:paramtypes", [])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/package.json
CHANGED