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