@ionic/core 8.7.8-dev.11761837781.122f452f → 8.7.8-dev.11761840817.1bede576
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/components/ion-accordion-group.js +7 -39
- package/components/ion-accordion.js +38 -34
- package/dist/cjs/ion-accordion_2.cjs.entry.js +45 -72
- package/dist/collection/components/accordion/accordion.js +38 -34
- package/dist/collection/components/accordion-group/accordion-group.js +7 -39
- package/dist/docs.json +2 -2
- package/dist/esm/ion-accordion_2.entry.js +46 -73
- package/dist/ionic/ionic.esm.js +1 -1
- package/dist/ionic/p-5ed15aa7.entry.js +4 -0
- package/dist/types/components/accordion/accordion.d.ts +5 -0
- package/dist/types/components/accordion-group/accordion-group-interface.d.ts +0 -1
- package/dist/types/components/accordion-group/accordion-group.d.ts +0 -3
- package/hydrate/index.js +45 -72
- package/hydrate/index.mjs +45 -72
- package/package.json +1 -1
- package/dist/ionic/p-18d454c8.entry.js +0 -4
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* (C) Ionic http://ionicframework.com - MIT License
|
|
3
3
|
*/
|
|
4
4
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
5
|
-
import { p as printIonWarning } from './index4.js';
|
|
6
5
|
import { b as getIonMode } from './ionic-global.js';
|
|
7
6
|
|
|
8
7
|
const accordionGroupIosCss = ":host{display:block}:host(.accordion-group-expand-inset){-webkit-margin-start:16px;margin-inline-start:16px;-webkit-margin-end:16px;margin-inline-end:16px;margin-top:16px;margin-bottom:16px}:host(.accordion-group-expand-inset) ::slotted(ion-accordion.accordion-expanding),:host(.accordion-group-expand-inset) ::slotted(ion-accordion.accordion-expanded){border-bottom:none}";
|
|
@@ -39,12 +38,9 @@ const AccordionGroup = /*@__PURE__*/ proxyCustomElement(class AccordionGroup ext
|
|
|
39
38
|
* Defaults to `"compact"`.
|
|
40
39
|
*/
|
|
41
40
|
this.expand = 'compact';
|
|
42
|
-
this.hasEmittedInitialValue = false;
|
|
43
|
-
this.isUserInitiatedChange = false;
|
|
44
41
|
}
|
|
45
42
|
valueChanged() {
|
|
46
|
-
this.
|
|
47
|
-
this.isUserInitiatedChange = false;
|
|
43
|
+
this.ionValueChange.emit({ value: this.value });
|
|
48
44
|
}
|
|
49
45
|
async disabledChanged() {
|
|
50
46
|
const { disabled } = this;
|
|
@@ -118,12 +114,11 @@ const AccordionGroup = /*@__PURE__*/ proxyCustomElement(class AccordionGroup ext
|
|
|
118
114
|
* it is possible for the value to be set after the Web Component
|
|
119
115
|
* initializes but before the value watcher is set up in Stencil.
|
|
120
116
|
* As a result, the watcher callback may not be fired.
|
|
121
|
-
* We work around this by manually
|
|
122
|
-
* has loaded and the watcher
|
|
117
|
+
* We work around this by manually calling the watcher
|
|
118
|
+
* callback when the component has loaded and the watcher
|
|
119
|
+
* is configured.
|
|
123
120
|
*/
|
|
124
|
-
|
|
125
|
-
this.emitValueChange(true);
|
|
126
|
-
}
|
|
121
|
+
this.valueChanged();
|
|
127
122
|
}
|
|
128
123
|
/**
|
|
129
124
|
* Sets the value property and emits ionChange.
|
|
@@ -134,7 +129,6 @@ const AccordionGroup = /*@__PURE__*/ proxyCustomElement(class AccordionGroup ext
|
|
|
134
129
|
* accordion group to an array.
|
|
135
130
|
*/
|
|
136
131
|
setValue(accordionValue) {
|
|
137
|
-
this.isUserInitiatedChange = true;
|
|
138
132
|
const value = (this.value = accordionValue);
|
|
139
133
|
this.ionChange.emit({ value });
|
|
140
134
|
}
|
|
@@ -204,41 +198,15 @@ const AccordionGroup = /*@__PURE__*/ proxyCustomElement(class AccordionGroup ext
|
|
|
204
198
|
async getAccordions() {
|
|
205
199
|
return Array.from(this.el.querySelectorAll(':scope > ion-accordion'));
|
|
206
200
|
}
|
|
207
|
-
emitValueChange(initial, isUserInitiated = false) {
|
|
208
|
-
const { value, multiple } = this;
|
|
209
|
-
if (!multiple && Array.isArray(value)) {
|
|
210
|
-
/**
|
|
211
|
-
* We do some processing on the `value` array so
|
|
212
|
-
* that it looks more like an array when logged to
|
|
213
|
-
* the console.
|
|
214
|
-
* Example given ['a', 'b']
|
|
215
|
-
* Default toString() behavior: a,b
|
|
216
|
-
* Custom behavior: ['a', 'b']
|
|
217
|
-
*/
|
|
218
|
-
printIonWarning(`[ion-accordion-group] - An array of values was passed, but multiple is "false". This is incorrect usage and may result in unexpected behaviors. To dismiss this warning, pass a string to the "value" property when multiple="false".
|
|
219
|
-
|
|
220
|
-
Value Passed: [${value.map((v) => `'${v}'`).join(', ')}]
|
|
221
|
-
`, this.el);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Track if this is the initial value update so accordions
|
|
225
|
-
* can skip transition animations when they first render.
|
|
226
|
-
*/
|
|
227
|
-
const shouldMarkInitial = initial || (!this.hasEmittedInitialValue && value !== undefined && !isUserInitiated);
|
|
228
|
-
this.ionValueChange.emit({ value, initial: shouldMarkInitial });
|
|
229
|
-
if (value !== undefined) {
|
|
230
|
-
this.hasEmittedInitialValue = true;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
201
|
render() {
|
|
234
202
|
const { disabled, readonly, expand } = this;
|
|
235
203
|
const mode = getIonMode(this);
|
|
236
|
-
return (h(Host, { key: '
|
|
204
|
+
return (h(Host, { key: '9a4a3b7811e63a0748cdcda82a840179cdfb26e1', class: {
|
|
237
205
|
[mode]: true,
|
|
238
206
|
'accordion-group-disabled': disabled,
|
|
239
207
|
'accordion-group-readonly': readonly,
|
|
240
208
|
[`accordion-group-expand-${expand}`]: true,
|
|
241
|
-
}, role: "presentation" }, h("slot", { key: '
|
|
209
|
+
}, role: "presentation" }, h("slot", { key: '183cebf7e0eb468b5c28c4105f23ec5aed36be1b' })));
|
|
242
210
|
}
|
|
243
211
|
get el() { return this; }
|
|
244
212
|
static get watchers() { return {
|
|
@@ -19,10 +19,7 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class Accordion extends HTMLE
|
|
|
19
19
|
this.__registerHost();
|
|
20
20
|
}
|
|
21
21
|
this.__attachShadow();
|
|
22
|
-
this.updateListener = (
|
|
23
|
-
var _a, _b;
|
|
24
|
-
const initialUpdate = (_b = (_a = ev.detail) === null || _a === void 0 ? void 0 : _a.initial) !== null && _b !== void 0 ? _b : false;
|
|
25
|
-
console.log('[Accordion]', this.value, 'updateListener - initial:', initialUpdate, 'hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded, 'currentState:', this.state);
|
|
22
|
+
this.updateListener = () => {
|
|
26
23
|
/**
|
|
27
24
|
* Determine if this update will cause an actual state change.
|
|
28
25
|
* We only want to mark as "interacted" if the state is changing.
|
|
@@ -34,18 +31,24 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class Accordion extends HTMLE
|
|
|
34
31
|
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
35
32
|
const isExpanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
36
33
|
const stateWillChange = shouldExpand !== isExpanded;
|
|
37
|
-
console.log('[Accordion]', this.value, 'shouldExpand:', shouldExpand, 'isExpanded:', isExpanded, 'stateWillChange:', stateWillChange);
|
|
38
34
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* (
|
|
35
|
+
* Only mark as interacted if:
|
|
36
|
+
* 1. This is not the first update we've received with a defined value
|
|
37
|
+
* 2. The state is actually changing (prevents redundant updates from enabling animations)
|
|
42
38
|
*/
|
|
43
|
-
if (
|
|
44
|
-
console.log('[Accordion]', this.value, 'Setting hasInteracted to true');
|
|
39
|
+
if (this.hasReceivedFirstUpdate && stateWillChange) {
|
|
45
40
|
this.hasInteracted = true;
|
|
46
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Only count this as the first update if the group value is defined.
|
|
44
|
+
* This prevents the initial undefined value from the group's componentDidLoad
|
|
45
|
+
* from being treated as the first real update.
|
|
46
|
+
*/
|
|
47
|
+
if (value !== undefined) {
|
|
48
|
+
this.hasReceivedFirstUpdate = true;
|
|
49
|
+
}
|
|
47
50
|
}
|
|
48
|
-
this.updateState(
|
|
51
|
+
this.updateState();
|
|
49
52
|
};
|
|
50
53
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
51
54
|
this.isNext = false;
|
|
@@ -62,6 +65,11 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class Accordion extends HTMLE
|
|
|
62
65
|
* Used to prevent the first expansion from animating.
|
|
63
66
|
*/
|
|
64
67
|
this.hasEverBeenExpanded = false;
|
|
68
|
+
/**
|
|
69
|
+
* Tracks if this accordion has received its first update from the group.
|
|
70
|
+
* Used to distinguish initial programmatic sets from user interactions.
|
|
71
|
+
*/
|
|
72
|
+
this.hasReceivedFirstUpdate = false;
|
|
65
73
|
/**
|
|
66
74
|
* The value of the accordion. Defaults to an autogenerated
|
|
67
75
|
* value.
|
|
@@ -166,21 +174,18 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class Accordion extends HTMLE
|
|
|
166
174
|
iconEl.setAttribute('aria-hidden', 'true');
|
|
167
175
|
ionItem.appendChild(iconEl);
|
|
168
176
|
};
|
|
169
|
-
this.expandAccordion = (
|
|
170
|
-
console.log('[Accordion]', this.value, 'expandAccordion - initialUpdate:', initialUpdate, 'state:', this.state);
|
|
177
|
+
this.expandAccordion = () => {
|
|
171
178
|
const { contentEl, contentElWrapper } = this;
|
|
172
|
-
|
|
179
|
+
/**
|
|
180
|
+
* If the content elements aren't available yet, just set the state.
|
|
181
|
+
* This happens on initial render before the DOM is ready.
|
|
182
|
+
*/
|
|
183
|
+
if (contentEl === undefined || contentElWrapper === undefined) {
|
|
173
184
|
this.state = 4 /* AccordionState.Expanded */;
|
|
174
|
-
/**
|
|
175
|
-
* Mark that this accordion has been expanded at least once.
|
|
176
|
-
* Do this even on initial expansion so future interactions animate.
|
|
177
|
-
*/
|
|
178
185
|
this.hasEverBeenExpanded = true;
|
|
179
|
-
console.log('[Accordion]', this.value, 'expandAccordion early return - hasEverBeenExpanded set to true');
|
|
180
186
|
return;
|
|
181
187
|
}
|
|
182
188
|
if (this.state === 4 /* AccordionState.Expanded */) {
|
|
183
|
-
console.log('[Accordion]', this.value, 'expandAccordion - already expanded, returning');
|
|
184
189
|
return;
|
|
185
190
|
}
|
|
186
191
|
if (this.currentRaf !== undefined) {
|
|
@@ -191,9 +196,7 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class Accordion extends HTMLE
|
|
|
191
196
|
* This allows subsequent expansions to animate.
|
|
192
197
|
*/
|
|
193
198
|
this.hasEverBeenExpanded = true;
|
|
194
|
-
console.log('[Accordion]', this.value, 'expandAccordion - hasEverBeenExpanded set to true');
|
|
195
199
|
if (this.shouldAnimate()) {
|
|
196
|
-
console.log('[Accordion]', this.value, 'expandAccordion - will animate');
|
|
197
200
|
raf(() => {
|
|
198
201
|
this.state = 8 /* AccordionState.Expanding */;
|
|
199
202
|
this.currentRaf = raf(async () => {
|
|
@@ -210,9 +213,13 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class Accordion extends HTMLE
|
|
|
210
213
|
this.state = 4 /* AccordionState.Expanded */;
|
|
211
214
|
}
|
|
212
215
|
};
|
|
213
|
-
this.collapseAccordion = (
|
|
216
|
+
this.collapseAccordion = () => {
|
|
214
217
|
const { contentEl } = this;
|
|
215
|
-
|
|
218
|
+
/**
|
|
219
|
+
* If the content element isn't available yet, just set the state.
|
|
220
|
+
* This happens on initial render before the DOM is ready.
|
|
221
|
+
*/
|
|
222
|
+
if (contentEl === undefined) {
|
|
216
223
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
217
224
|
return;
|
|
218
225
|
}
|
|
@@ -257,7 +264,6 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class Accordion extends HTMLE
|
|
|
257
264
|
* where effects run twice and might incorrectly mark as interacted.
|
|
258
265
|
*/
|
|
259
266
|
if (!this.hasInteracted || !this.hasEverBeenExpanded) {
|
|
260
|
-
console.log('[Accordion]', this.value, 'shouldAnimate: false - hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
261
267
|
return false;
|
|
262
268
|
}
|
|
263
269
|
if (typeof window === 'undefined') {
|
|
@@ -276,7 +282,7 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class Accordion extends HTMLE
|
|
|
276
282
|
}
|
|
277
283
|
return true;
|
|
278
284
|
};
|
|
279
|
-
this.updateState = async (
|
|
285
|
+
this.updateState = async () => {
|
|
280
286
|
const accordionGroup = this.accordionGroupEl;
|
|
281
287
|
const accordionValue = this.value;
|
|
282
288
|
if (!accordionGroup) {
|
|
@@ -285,11 +291,11 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class Accordion extends HTMLE
|
|
|
285
291
|
const value = accordionGroup.value;
|
|
286
292
|
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
287
293
|
if (shouldExpand) {
|
|
288
|
-
this.expandAccordion(
|
|
294
|
+
this.expandAccordion();
|
|
289
295
|
this.isNext = this.isPrevious = false;
|
|
290
296
|
}
|
|
291
297
|
else {
|
|
292
|
-
this.collapseAccordion(
|
|
298
|
+
this.collapseAccordion();
|
|
293
299
|
/**
|
|
294
300
|
* When using popout or inset,
|
|
295
301
|
* the collapsed accordion items
|
|
@@ -337,7 +343,7 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class Accordion extends HTMLE
|
|
|
337
343
|
var _a;
|
|
338
344
|
const accordionGroupEl = (this.accordionGroupEl = (_a = this.el) === null || _a === void 0 ? void 0 : _a.closest('ion-accordion-group'));
|
|
339
345
|
if (accordionGroupEl) {
|
|
340
|
-
this.updateState(
|
|
346
|
+
this.updateState();
|
|
341
347
|
addEventListener(accordionGroupEl, 'ionValueChange', this.updateListener);
|
|
342
348
|
}
|
|
343
349
|
}
|
|
@@ -392,10 +398,8 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class Accordion extends HTMLE
|
|
|
392
398
|
const expanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
393
399
|
const headerPart = expanded ? 'header expanded' : 'header';
|
|
394
400
|
const contentPart = expanded ? 'content expanded' : 'content';
|
|
395
|
-
const shouldAnimate = this.shouldAnimate();
|
|
396
|
-
console.log('[Accordion]', this.value, 'render - state:', this.state, 'shouldAnimate:', shouldAnimate, 'hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
397
401
|
this.setAria(expanded);
|
|
398
|
-
return (h(Host, { key: '
|
|
402
|
+
return (h(Host, { key: '0f3b65e32d6908f466e0b0535fbdad1d6d6c4c88', class: {
|
|
399
403
|
[mode]: true,
|
|
400
404
|
'accordion-expanding': this.state === 8 /* AccordionState.Expanding */,
|
|
401
405
|
'accordion-expanded': this.state === 4 /* AccordionState.Expanded */,
|
|
@@ -405,8 +409,8 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class Accordion extends HTMLE
|
|
|
405
409
|
'accordion-previous': this.isPrevious,
|
|
406
410
|
'accordion-disabled': disabled,
|
|
407
411
|
'accordion-readonly': readonly,
|
|
408
|
-
'accordion-animated': shouldAnimate,
|
|
409
|
-
} }, h("div", { key: '
|
|
412
|
+
'accordion-animated': this.shouldAnimate(),
|
|
413
|
+
} }, h("div", { key: '79e49dde14246e65fab5ee991a9f06fda649b8a4', onClick: () => this.toggleExpanded(), id: "header", part: headerPart, "aria-controls": "content", ref: (headerEl) => (this.headerEl = headerEl) }, h("slot", { key: '8938988b9a5f87357b8351ecf5ca37ae80461170', name: "header" })), h("div", { key: '636a23a49fd8daae92a584452bc3f5b35072110d', id: "content", part: contentPart, role: "region", "aria-labelledby": "header", ref: (contentEl) => (this.contentEl = contentEl) }, h("div", { key: 'dd28ba52dbd28690561206aac205190aebecb793', id: "content-wrapper", ref: (contentElWrapper) => (this.contentElWrapper = contentElWrapper) }, h("slot", { key: '133fb1680990303ba55b61e3fed741a31295acdf', name: "content" })))));
|
|
410
414
|
}
|
|
411
415
|
static get delegatesFocus() { return true; }
|
|
412
416
|
get el() { return this; }
|
|
@@ -15,10 +15,7 @@ const accordionMdCss = ":host{display:block;position:relative;width:100%;backgro
|
|
|
15
15
|
const Accordion = class {
|
|
16
16
|
constructor(hostRef) {
|
|
17
17
|
index.registerInstance(this, hostRef);
|
|
18
|
-
this.updateListener = (
|
|
19
|
-
var _a, _b;
|
|
20
|
-
const initialUpdate = (_b = (_a = ev.detail) === null || _a === void 0 ? void 0 : _a.initial) !== null && _b !== void 0 ? _b : false;
|
|
21
|
-
console.log('[Accordion]', this.value, 'updateListener - initial:', initialUpdate, 'hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded, 'currentState:', this.state);
|
|
18
|
+
this.updateListener = () => {
|
|
22
19
|
/**
|
|
23
20
|
* Determine if this update will cause an actual state change.
|
|
24
21
|
* We only want to mark as "interacted" if the state is changing.
|
|
@@ -30,18 +27,24 @@ const Accordion = class {
|
|
|
30
27
|
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
31
28
|
const isExpanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
32
29
|
const stateWillChange = shouldExpand !== isExpanded;
|
|
33
|
-
console.log('[Accordion]', this.value, 'shouldExpand:', shouldExpand, 'isExpanded:', isExpanded, 'stateWillChange:', stateWillChange);
|
|
34
30
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* (
|
|
31
|
+
* Only mark as interacted if:
|
|
32
|
+
* 1. This is not the first update we've received with a defined value
|
|
33
|
+
* 2. The state is actually changing (prevents redundant updates from enabling animations)
|
|
38
34
|
*/
|
|
39
|
-
if (
|
|
40
|
-
console.log('[Accordion]', this.value, 'Setting hasInteracted to true');
|
|
35
|
+
if (this.hasReceivedFirstUpdate && stateWillChange) {
|
|
41
36
|
this.hasInteracted = true;
|
|
42
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Only count this as the first update if the group value is defined.
|
|
40
|
+
* This prevents the initial undefined value from the group's componentDidLoad
|
|
41
|
+
* from being treated as the first real update.
|
|
42
|
+
*/
|
|
43
|
+
if (value !== undefined) {
|
|
44
|
+
this.hasReceivedFirstUpdate = true;
|
|
45
|
+
}
|
|
43
46
|
}
|
|
44
|
-
this.updateState(
|
|
47
|
+
this.updateState();
|
|
45
48
|
};
|
|
46
49
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
47
50
|
this.isNext = false;
|
|
@@ -58,6 +61,11 @@ const Accordion = class {
|
|
|
58
61
|
* Used to prevent the first expansion from animating.
|
|
59
62
|
*/
|
|
60
63
|
this.hasEverBeenExpanded = false;
|
|
64
|
+
/**
|
|
65
|
+
* Tracks if this accordion has received its first update from the group.
|
|
66
|
+
* Used to distinguish initial programmatic sets from user interactions.
|
|
67
|
+
*/
|
|
68
|
+
this.hasReceivedFirstUpdate = false;
|
|
61
69
|
/**
|
|
62
70
|
* The value of the accordion. Defaults to an autogenerated
|
|
63
71
|
* value.
|
|
@@ -162,21 +170,18 @@ const Accordion = class {
|
|
|
162
170
|
iconEl.setAttribute('aria-hidden', 'true');
|
|
163
171
|
ionItem.appendChild(iconEl);
|
|
164
172
|
};
|
|
165
|
-
this.expandAccordion = (
|
|
166
|
-
console.log('[Accordion]', this.value, 'expandAccordion - initialUpdate:', initialUpdate, 'state:', this.state);
|
|
173
|
+
this.expandAccordion = () => {
|
|
167
174
|
const { contentEl, contentElWrapper } = this;
|
|
168
|
-
|
|
175
|
+
/**
|
|
176
|
+
* If the content elements aren't available yet, just set the state.
|
|
177
|
+
* This happens on initial render before the DOM is ready.
|
|
178
|
+
*/
|
|
179
|
+
if (contentEl === undefined || contentElWrapper === undefined) {
|
|
169
180
|
this.state = 4 /* AccordionState.Expanded */;
|
|
170
|
-
/**
|
|
171
|
-
* Mark that this accordion has been expanded at least once.
|
|
172
|
-
* Do this even on initial expansion so future interactions animate.
|
|
173
|
-
*/
|
|
174
181
|
this.hasEverBeenExpanded = true;
|
|
175
|
-
console.log('[Accordion]', this.value, 'expandAccordion early return - hasEverBeenExpanded set to true');
|
|
176
182
|
return;
|
|
177
183
|
}
|
|
178
184
|
if (this.state === 4 /* AccordionState.Expanded */) {
|
|
179
|
-
console.log('[Accordion]', this.value, 'expandAccordion - already expanded, returning');
|
|
180
185
|
return;
|
|
181
186
|
}
|
|
182
187
|
if (this.currentRaf !== undefined) {
|
|
@@ -187,9 +192,7 @@ const Accordion = class {
|
|
|
187
192
|
* This allows subsequent expansions to animate.
|
|
188
193
|
*/
|
|
189
194
|
this.hasEverBeenExpanded = true;
|
|
190
|
-
console.log('[Accordion]', this.value, 'expandAccordion - hasEverBeenExpanded set to true');
|
|
191
195
|
if (this.shouldAnimate()) {
|
|
192
|
-
console.log('[Accordion]', this.value, 'expandAccordion - will animate');
|
|
193
196
|
helpers.raf(() => {
|
|
194
197
|
this.state = 8 /* AccordionState.Expanding */;
|
|
195
198
|
this.currentRaf = helpers.raf(async () => {
|
|
@@ -206,9 +209,13 @@ const Accordion = class {
|
|
|
206
209
|
this.state = 4 /* AccordionState.Expanded */;
|
|
207
210
|
}
|
|
208
211
|
};
|
|
209
|
-
this.collapseAccordion = (
|
|
212
|
+
this.collapseAccordion = () => {
|
|
210
213
|
const { contentEl } = this;
|
|
211
|
-
|
|
214
|
+
/**
|
|
215
|
+
* If the content element isn't available yet, just set the state.
|
|
216
|
+
* This happens on initial render before the DOM is ready.
|
|
217
|
+
*/
|
|
218
|
+
if (contentEl === undefined) {
|
|
212
219
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
213
220
|
return;
|
|
214
221
|
}
|
|
@@ -253,7 +260,6 @@ const Accordion = class {
|
|
|
253
260
|
* where effects run twice and might incorrectly mark as interacted.
|
|
254
261
|
*/
|
|
255
262
|
if (!this.hasInteracted || !this.hasEverBeenExpanded) {
|
|
256
|
-
console.log('[Accordion]', this.value, 'shouldAnimate: false - hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
257
263
|
return false;
|
|
258
264
|
}
|
|
259
265
|
if (typeof window === 'undefined') {
|
|
@@ -272,7 +278,7 @@ const Accordion = class {
|
|
|
272
278
|
}
|
|
273
279
|
return true;
|
|
274
280
|
};
|
|
275
|
-
this.updateState = async (
|
|
281
|
+
this.updateState = async () => {
|
|
276
282
|
const accordionGroup = this.accordionGroupEl;
|
|
277
283
|
const accordionValue = this.value;
|
|
278
284
|
if (!accordionGroup) {
|
|
@@ -281,11 +287,11 @@ const Accordion = class {
|
|
|
281
287
|
const value = accordionGroup.value;
|
|
282
288
|
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
283
289
|
if (shouldExpand) {
|
|
284
|
-
this.expandAccordion(
|
|
290
|
+
this.expandAccordion();
|
|
285
291
|
this.isNext = this.isPrevious = false;
|
|
286
292
|
}
|
|
287
293
|
else {
|
|
288
|
-
this.collapseAccordion(
|
|
294
|
+
this.collapseAccordion();
|
|
289
295
|
/**
|
|
290
296
|
* When using popout or inset,
|
|
291
297
|
* the collapsed accordion items
|
|
@@ -333,7 +339,7 @@ const Accordion = class {
|
|
|
333
339
|
var _a;
|
|
334
340
|
const accordionGroupEl = (this.accordionGroupEl = (_a = this.el) === null || _a === void 0 ? void 0 : _a.closest('ion-accordion-group'));
|
|
335
341
|
if (accordionGroupEl) {
|
|
336
|
-
this.updateState(
|
|
342
|
+
this.updateState();
|
|
337
343
|
helpers.addEventListener(accordionGroupEl, 'ionValueChange', this.updateListener);
|
|
338
344
|
}
|
|
339
345
|
}
|
|
@@ -388,10 +394,8 @@ const Accordion = class {
|
|
|
388
394
|
const expanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
389
395
|
const headerPart = expanded ? 'header expanded' : 'header';
|
|
390
396
|
const contentPart = expanded ? 'content expanded' : 'content';
|
|
391
|
-
const shouldAnimate = this.shouldAnimate();
|
|
392
|
-
console.log('[Accordion]', this.value, 'render - state:', this.state, 'shouldAnimate:', shouldAnimate, 'hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
393
397
|
this.setAria(expanded);
|
|
394
|
-
return (index.h(index.Host, { key: '
|
|
398
|
+
return (index.h(index.Host, { key: '0f3b65e32d6908f466e0b0535fbdad1d6d6c4c88', class: {
|
|
395
399
|
[mode]: true,
|
|
396
400
|
'accordion-expanding': this.state === 8 /* AccordionState.Expanding */,
|
|
397
401
|
'accordion-expanded': this.state === 4 /* AccordionState.Expanded */,
|
|
@@ -401,8 +405,8 @@ const Accordion = class {
|
|
|
401
405
|
'accordion-previous': this.isPrevious,
|
|
402
406
|
'accordion-disabled': disabled,
|
|
403
407
|
'accordion-readonly': readonly,
|
|
404
|
-
'accordion-animated': shouldAnimate,
|
|
405
|
-
} }, index.h("div", { key: '
|
|
408
|
+
'accordion-animated': this.shouldAnimate(),
|
|
409
|
+
} }, index.h("div", { key: '79e49dde14246e65fab5ee991a9f06fda649b8a4', onClick: () => this.toggleExpanded(), id: "header", part: headerPart, "aria-controls": "content", ref: (headerEl) => (this.headerEl = headerEl) }, index.h("slot", { key: '8938988b9a5f87357b8351ecf5ca37ae80461170', name: "header" })), index.h("div", { key: '636a23a49fd8daae92a584452bc3f5b35072110d', id: "content", part: contentPart, role: "region", "aria-labelledby": "header", ref: (contentEl) => (this.contentEl = contentEl) }, index.h("div", { key: 'dd28ba52dbd28690561206aac205190aebecb793', id: "content-wrapper", ref: (contentElWrapper) => (this.contentElWrapper = contentElWrapper) }, index.h("slot", { key: '133fb1680990303ba55b61e3fed741a31295acdf', name: "content" })))));
|
|
406
410
|
}
|
|
407
411
|
static get delegatesFocus() { return true; }
|
|
408
412
|
get el() { return index.getElement(this); }
|
|
@@ -446,12 +450,9 @@ const AccordionGroup = class {
|
|
|
446
450
|
* Defaults to `"compact"`.
|
|
447
451
|
*/
|
|
448
452
|
this.expand = 'compact';
|
|
449
|
-
this.hasEmittedInitialValue = false;
|
|
450
|
-
this.isUserInitiatedChange = false;
|
|
451
453
|
}
|
|
452
454
|
valueChanged() {
|
|
453
|
-
this.
|
|
454
|
-
this.isUserInitiatedChange = false;
|
|
455
|
+
this.ionValueChange.emit({ value: this.value });
|
|
455
456
|
}
|
|
456
457
|
async disabledChanged() {
|
|
457
458
|
const { disabled } = this;
|
|
@@ -525,12 +526,11 @@ const AccordionGroup = class {
|
|
|
525
526
|
* it is possible for the value to be set after the Web Component
|
|
526
527
|
* initializes but before the value watcher is set up in Stencil.
|
|
527
528
|
* As a result, the watcher callback may not be fired.
|
|
528
|
-
* We work around this by manually
|
|
529
|
-
* has loaded and the watcher
|
|
529
|
+
* We work around this by manually calling the watcher
|
|
530
|
+
* callback when the component has loaded and the watcher
|
|
531
|
+
* is configured.
|
|
530
532
|
*/
|
|
531
|
-
|
|
532
|
-
this.emitValueChange(true);
|
|
533
|
-
}
|
|
533
|
+
this.valueChanged();
|
|
534
534
|
}
|
|
535
535
|
/**
|
|
536
536
|
* Sets the value property and emits ionChange.
|
|
@@ -541,7 +541,6 @@ const AccordionGroup = class {
|
|
|
541
541
|
* accordion group to an array.
|
|
542
542
|
*/
|
|
543
543
|
setValue(accordionValue) {
|
|
544
|
-
this.isUserInitiatedChange = true;
|
|
545
544
|
const value = (this.value = accordionValue);
|
|
546
545
|
this.ionChange.emit({ value });
|
|
547
546
|
}
|
|
@@ -611,41 +610,15 @@ const AccordionGroup = class {
|
|
|
611
610
|
async getAccordions() {
|
|
612
611
|
return Array.from(this.el.querySelectorAll(':scope > ion-accordion'));
|
|
613
612
|
}
|
|
614
|
-
emitValueChange(initial, isUserInitiated = false) {
|
|
615
|
-
const { value, multiple } = this;
|
|
616
|
-
if (!multiple && Array.isArray(value)) {
|
|
617
|
-
/**
|
|
618
|
-
* We do some processing on the `value` array so
|
|
619
|
-
* that it looks more like an array when logged to
|
|
620
|
-
* the console.
|
|
621
|
-
* Example given ['a', 'b']
|
|
622
|
-
* Default toString() behavior: a,b
|
|
623
|
-
* Custom behavior: ['a', 'b']
|
|
624
|
-
*/
|
|
625
|
-
index.printIonWarning(`[ion-accordion-group] - An array of values was passed, but multiple is "false". This is incorrect usage and may result in unexpected behaviors. To dismiss this warning, pass a string to the "value" property when multiple="false".
|
|
626
|
-
|
|
627
|
-
Value Passed: [${value.map((v) => `'${v}'`).join(', ')}]
|
|
628
|
-
`, this.el);
|
|
629
|
-
}
|
|
630
|
-
/**
|
|
631
|
-
* Track if this is the initial value update so accordions
|
|
632
|
-
* can skip transition animations when they first render.
|
|
633
|
-
*/
|
|
634
|
-
const shouldMarkInitial = initial || (!this.hasEmittedInitialValue && value !== undefined && !isUserInitiated);
|
|
635
|
-
this.ionValueChange.emit({ value, initial: shouldMarkInitial });
|
|
636
|
-
if (value !== undefined) {
|
|
637
|
-
this.hasEmittedInitialValue = true;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
613
|
render() {
|
|
641
614
|
const { disabled, readonly, expand } = this;
|
|
642
615
|
const mode = ionicGlobal.getIonMode(this);
|
|
643
|
-
return (index.h(index.Host, { key: '
|
|
616
|
+
return (index.h(index.Host, { key: '9a4a3b7811e63a0748cdcda82a840179cdfb26e1', class: {
|
|
644
617
|
[mode]: true,
|
|
645
618
|
'accordion-group-disabled': disabled,
|
|
646
619
|
'accordion-group-readonly': readonly,
|
|
647
620
|
[`accordion-group-expand-${expand}`]: true,
|
|
648
|
-
}, role: "presentation" }, index.h("slot", { key: '
|
|
621
|
+
}, role: "presentation" }, index.h("slot", { key: '183cebf7e0eb468b5c28c4105f23ec5aed36be1b' })));
|
|
649
622
|
}
|
|
650
623
|
get el() { return index.getElement(this); }
|
|
651
624
|
static get watchers() { return {
|