@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
|
@@ -21,10 +21,7 @@ import { getIonMode } from "../../global/ionic-global";
|
|
|
21
21
|
*/
|
|
22
22
|
export class Accordion {
|
|
23
23
|
constructor() {
|
|
24
|
-
this.updateListener = (
|
|
25
|
-
var _a, _b;
|
|
26
|
-
const initialUpdate = (_b = (_a = ev.detail) === null || _a === void 0 ? void 0 : _a.initial) !== null && _b !== void 0 ? _b : false;
|
|
27
|
-
console.log('[Accordion]', this.value, 'updateListener - initial:', initialUpdate, 'hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded, 'currentState:', this.state);
|
|
24
|
+
this.updateListener = () => {
|
|
28
25
|
/**
|
|
29
26
|
* Determine if this update will cause an actual state change.
|
|
30
27
|
* We only want to mark as "interacted" if the state is changing.
|
|
@@ -36,18 +33,24 @@ export class Accordion {
|
|
|
36
33
|
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
37
34
|
const isExpanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
38
35
|
const stateWillChange = shouldExpand !== isExpanded;
|
|
39
|
-
console.log('[Accordion]', this.value, 'shouldExpand:', shouldExpand, 'isExpanded:', isExpanded, 'stateWillChange:', stateWillChange);
|
|
40
36
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* (
|
|
37
|
+
* Only mark as interacted if:
|
|
38
|
+
* 1. This is not the first update we've received with a defined value
|
|
39
|
+
* 2. The state is actually changing (prevents redundant updates from enabling animations)
|
|
44
40
|
*/
|
|
45
|
-
if (
|
|
46
|
-
console.log('[Accordion]', this.value, 'Setting hasInteracted to true');
|
|
41
|
+
if (this.hasReceivedFirstUpdate && stateWillChange) {
|
|
47
42
|
this.hasInteracted = true;
|
|
48
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Only count this as the first update if the group value is defined.
|
|
46
|
+
* This prevents the initial undefined value from the group's componentDidLoad
|
|
47
|
+
* from being treated as the first real update.
|
|
48
|
+
*/
|
|
49
|
+
if (value !== undefined) {
|
|
50
|
+
this.hasReceivedFirstUpdate = true;
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
|
-
this.updateState(
|
|
53
|
+
this.updateState();
|
|
51
54
|
};
|
|
52
55
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
53
56
|
this.isNext = false;
|
|
@@ -64,6 +67,11 @@ export class Accordion {
|
|
|
64
67
|
* Used to prevent the first expansion from animating.
|
|
65
68
|
*/
|
|
66
69
|
this.hasEverBeenExpanded = false;
|
|
70
|
+
/**
|
|
71
|
+
* Tracks if this accordion has received its first update from the group.
|
|
72
|
+
* Used to distinguish initial programmatic sets from user interactions.
|
|
73
|
+
*/
|
|
74
|
+
this.hasReceivedFirstUpdate = false;
|
|
67
75
|
/**
|
|
68
76
|
* The value of the accordion. Defaults to an autogenerated
|
|
69
77
|
* value.
|
|
@@ -168,21 +176,18 @@ export class Accordion {
|
|
|
168
176
|
iconEl.setAttribute('aria-hidden', 'true');
|
|
169
177
|
ionItem.appendChild(iconEl);
|
|
170
178
|
};
|
|
171
|
-
this.expandAccordion = (
|
|
172
|
-
console.log('[Accordion]', this.value, 'expandAccordion - initialUpdate:', initialUpdate, 'state:', this.state);
|
|
179
|
+
this.expandAccordion = () => {
|
|
173
180
|
const { contentEl, contentElWrapper } = this;
|
|
174
|
-
|
|
181
|
+
/**
|
|
182
|
+
* If the content elements aren't available yet, just set the state.
|
|
183
|
+
* This happens on initial render before the DOM is ready.
|
|
184
|
+
*/
|
|
185
|
+
if (contentEl === undefined || contentElWrapper === undefined) {
|
|
175
186
|
this.state = 4 /* AccordionState.Expanded */;
|
|
176
|
-
/**
|
|
177
|
-
* Mark that this accordion has been expanded at least once.
|
|
178
|
-
* Do this even on initial expansion so future interactions animate.
|
|
179
|
-
*/
|
|
180
187
|
this.hasEverBeenExpanded = true;
|
|
181
|
-
console.log('[Accordion]', this.value, 'expandAccordion early return - hasEverBeenExpanded set to true');
|
|
182
188
|
return;
|
|
183
189
|
}
|
|
184
190
|
if (this.state === 4 /* AccordionState.Expanded */) {
|
|
185
|
-
console.log('[Accordion]', this.value, 'expandAccordion - already expanded, returning');
|
|
186
191
|
return;
|
|
187
192
|
}
|
|
188
193
|
if (this.currentRaf !== undefined) {
|
|
@@ -193,9 +198,7 @@ export class Accordion {
|
|
|
193
198
|
* This allows subsequent expansions to animate.
|
|
194
199
|
*/
|
|
195
200
|
this.hasEverBeenExpanded = true;
|
|
196
|
-
console.log('[Accordion]', this.value, 'expandAccordion - hasEverBeenExpanded set to true');
|
|
197
201
|
if (this.shouldAnimate()) {
|
|
198
|
-
console.log('[Accordion]', this.value, 'expandAccordion - will animate');
|
|
199
202
|
raf(() => {
|
|
200
203
|
this.state = 8 /* AccordionState.Expanding */;
|
|
201
204
|
this.currentRaf = raf(async () => {
|
|
@@ -212,9 +215,13 @@ export class Accordion {
|
|
|
212
215
|
this.state = 4 /* AccordionState.Expanded */;
|
|
213
216
|
}
|
|
214
217
|
};
|
|
215
|
-
this.collapseAccordion = (
|
|
218
|
+
this.collapseAccordion = () => {
|
|
216
219
|
const { contentEl } = this;
|
|
217
|
-
|
|
220
|
+
/**
|
|
221
|
+
* If the content element isn't available yet, just set the state.
|
|
222
|
+
* This happens on initial render before the DOM is ready.
|
|
223
|
+
*/
|
|
224
|
+
if (contentEl === undefined) {
|
|
218
225
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
219
226
|
return;
|
|
220
227
|
}
|
|
@@ -259,7 +266,6 @@ export class Accordion {
|
|
|
259
266
|
* where effects run twice and might incorrectly mark as interacted.
|
|
260
267
|
*/
|
|
261
268
|
if (!this.hasInteracted || !this.hasEverBeenExpanded) {
|
|
262
|
-
console.log('[Accordion]', this.value, 'shouldAnimate: false - hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
263
269
|
return false;
|
|
264
270
|
}
|
|
265
271
|
if (typeof window === 'undefined') {
|
|
@@ -278,7 +284,7 @@ export class Accordion {
|
|
|
278
284
|
}
|
|
279
285
|
return true;
|
|
280
286
|
};
|
|
281
|
-
this.updateState = async (
|
|
287
|
+
this.updateState = async () => {
|
|
282
288
|
const accordionGroup = this.accordionGroupEl;
|
|
283
289
|
const accordionValue = this.value;
|
|
284
290
|
if (!accordionGroup) {
|
|
@@ -287,11 +293,11 @@ export class Accordion {
|
|
|
287
293
|
const value = accordionGroup.value;
|
|
288
294
|
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
289
295
|
if (shouldExpand) {
|
|
290
|
-
this.expandAccordion(
|
|
296
|
+
this.expandAccordion();
|
|
291
297
|
this.isNext = this.isPrevious = false;
|
|
292
298
|
}
|
|
293
299
|
else {
|
|
294
|
-
this.collapseAccordion(
|
|
300
|
+
this.collapseAccordion();
|
|
295
301
|
/**
|
|
296
302
|
* When using popout or inset,
|
|
297
303
|
* the collapsed accordion items
|
|
@@ -339,7 +345,7 @@ export class Accordion {
|
|
|
339
345
|
var _a;
|
|
340
346
|
const accordionGroupEl = (this.accordionGroupEl = (_a = this.el) === null || _a === void 0 ? void 0 : _a.closest('ion-accordion-group'));
|
|
341
347
|
if (accordionGroupEl) {
|
|
342
|
-
this.updateState(
|
|
348
|
+
this.updateState();
|
|
343
349
|
addEventListener(accordionGroupEl, 'ionValueChange', this.updateListener);
|
|
344
350
|
}
|
|
345
351
|
}
|
|
@@ -394,10 +400,8 @@ export class Accordion {
|
|
|
394
400
|
const expanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
395
401
|
const headerPart = expanded ? 'header expanded' : 'header';
|
|
396
402
|
const contentPart = expanded ? 'content expanded' : 'content';
|
|
397
|
-
const shouldAnimate = this.shouldAnimate();
|
|
398
|
-
console.log('[Accordion]', this.value, 'render - state:', this.state, 'shouldAnimate:', shouldAnimate, 'hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
399
403
|
this.setAria(expanded);
|
|
400
|
-
return (h(Host, { key: '
|
|
404
|
+
return (h(Host, { key: '0f3b65e32d6908f466e0b0535fbdad1d6d6c4c88', class: {
|
|
401
405
|
[mode]: true,
|
|
402
406
|
'accordion-expanding': this.state === 8 /* AccordionState.Expanding */,
|
|
403
407
|
'accordion-expanded': this.state === 4 /* AccordionState.Expanded */,
|
|
@@ -407,8 +411,8 @@ export class Accordion {
|
|
|
407
411
|
'accordion-previous': this.isPrevious,
|
|
408
412
|
'accordion-disabled': disabled,
|
|
409
413
|
'accordion-readonly': readonly,
|
|
410
|
-
'accordion-animated': shouldAnimate,
|
|
411
|
-
} }, h("div", { key: '
|
|
414
|
+
'accordion-animated': this.shouldAnimate(),
|
|
415
|
+
} }, 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" })))));
|
|
412
416
|
}
|
|
413
417
|
static get is() { return "ion-accordion"; }
|
|
414
418
|
static get encapsulation() { return "shadow"; }
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* (C) Ionic http://ionicframework.com - MIT License
|
|
3
3
|
*/
|
|
4
4
|
import { Host, h } from "@stencil/core";
|
|
5
|
-
import { printIonWarning } from "../../utils/logging/index";
|
|
6
5
|
import { getIonMode } from "../../global/ionic-global";
|
|
7
6
|
/**
|
|
8
7
|
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
|
|
@@ -30,12 +29,9 @@ export class AccordionGroup {
|
|
|
30
29
|
* Defaults to `"compact"`.
|
|
31
30
|
*/
|
|
32
31
|
this.expand = 'compact';
|
|
33
|
-
this.hasEmittedInitialValue = false;
|
|
34
|
-
this.isUserInitiatedChange = false;
|
|
35
32
|
}
|
|
36
33
|
valueChanged() {
|
|
37
|
-
this.
|
|
38
|
-
this.isUserInitiatedChange = false;
|
|
34
|
+
this.ionValueChange.emit({ value: this.value });
|
|
39
35
|
}
|
|
40
36
|
async disabledChanged() {
|
|
41
37
|
const { disabled } = this;
|
|
@@ -109,12 +105,11 @@ export class AccordionGroup {
|
|
|
109
105
|
* it is possible for the value to be set after the Web Component
|
|
110
106
|
* initializes but before the value watcher is set up in Stencil.
|
|
111
107
|
* As a result, the watcher callback may not be fired.
|
|
112
|
-
* We work around this by manually
|
|
113
|
-
* has loaded and the watcher
|
|
108
|
+
* We work around this by manually calling the watcher
|
|
109
|
+
* callback when the component has loaded and the watcher
|
|
110
|
+
* is configured.
|
|
114
111
|
*/
|
|
115
|
-
|
|
116
|
-
this.emitValueChange(true);
|
|
117
|
-
}
|
|
112
|
+
this.valueChanged();
|
|
118
113
|
}
|
|
119
114
|
/**
|
|
120
115
|
* Sets the value property and emits ionChange.
|
|
@@ -125,7 +120,6 @@ export class AccordionGroup {
|
|
|
125
120
|
* accordion group to an array.
|
|
126
121
|
*/
|
|
127
122
|
setValue(accordionValue) {
|
|
128
|
-
this.isUserInitiatedChange = true;
|
|
129
123
|
const value = (this.value = accordionValue);
|
|
130
124
|
this.ionChange.emit({ value });
|
|
131
125
|
}
|
|
@@ -195,41 +189,15 @@ export class AccordionGroup {
|
|
|
195
189
|
async getAccordions() {
|
|
196
190
|
return Array.from(this.el.querySelectorAll(':scope > ion-accordion'));
|
|
197
191
|
}
|
|
198
|
-
emitValueChange(initial, isUserInitiated = false) {
|
|
199
|
-
const { value, multiple } = this;
|
|
200
|
-
if (!multiple && Array.isArray(value)) {
|
|
201
|
-
/**
|
|
202
|
-
* We do some processing on the `value` array so
|
|
203
|
-
* that it looks more like an array when logged to
|
|
204
|
-
* the console.
|
|
205
|
-
* Example given ['a', 'b']
|
|
206
|
-
* Default toString() behavior: a,b
|
|
207
|
-
* Custom behavior: ['a', 'b']
|
|
208
|
-
*/
|
|
209
|
-
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".
|
|
210
|
-
|
|
211
|
-
Value Passed: [${value.map((v) => `'${v}'`).join(', ')}]
|
|
212
|
-
`, this.el);
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Track if this is the initial value update so accordions
|
|
216
|
-
* can skip transition animations when they first render.
|
|
217
|
-
*/
|
|
218
|
-
const shouldMarkInitial = initial || (!this.hasEmittedInitialValue && value !== undefined && !isUserInitiated);
|
|
219
|
-
this.ionValueChange.emit({ value, initial: shouldMarkInitial });
|
|
220
|
-
if (value !== undefined) {
|
|
221
|
-
this.hasEmittedInitialValue = true;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
192
|
render() {
|
|
225
193
|
const { disabled, readonly, expand } = this;
|
|
226
194
|
const mode = getIonMode(this);
|
|
227
|
-
return (h(Host, { key: '
|
|
195
|
+
return (h(Host, { key: '9a4a3b7811e63a0748cdcda82a840179cdfb26e1', class: {
|
|
228
196
|
[mode]: true,
|
|
229
197
|
'accordion-group-disabled': disabled,
|
|
230
198
|
'accordion-group-readonly': readonly,
|
|
231
199
|
[`accordion-group-expand-${expand}`]: true,
|
|
232
|
-
}, role: "presentation" }, h("slot", { key: '
|
|
200
|
+
}, role: "presentation" }, h("slot", { key: '183cebf7e0eb468b5c28c4105f23ec5aed36be1b' })));
|
|
233
201
|
}
|
|
234
202
|
static get is() { return "ion-accordion-group"; }
|
|
235
203
|
static get encapsulation() { return "shadow"; }
|
package/dist/docs.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2025-10-
|
|
2
|
+
"timestamp": "2025-10-30T16:16:02",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
5
|
"version": "4.38.0",
|
|
@@ -37226,7 +37226,7 @@
|
|
|
37226
37226
|
],
|
|
37227
37227
|
"typeLibrary": {
|
|
37228
37228
|
"src/components/accordion-group/accordion-group-interface.ts::AccordionGroupChangeEventDetail": {
|
|
37229
|
-
"declaration": "export interface AccordionGroupChangeEventDetail<T = any> {\n value: T;\n
|
|
37229
|
+
"declaration": "export interface AccordionGroupChangeEventDetail<T = any> {\n value: T;\n}",
|
|
37230
37230
|
"docstring": "",
|
|
37231
37231
|
"path": "src/components/accordion-group/accordion-group-interface.ts"
|
|
37232
37232
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* (C) Ionic http://ionicframework.com - MIT License
|
|
3
3
|
*/
|
|
4
|
-
import { r as registerInstance, e as config, h, d as Host, g as getElement, c as createEvent
|
|
4
|
+
import { r as registerInstance, e as config, h, d as Host, g as getElement, c as createEvent } from './index-C8IsBmNU.js';
|
|
5
5
|
import { g as getElementRoot, r as raf, f as addEventListener, m as removeEventListener, t as transitionEndAsync } from './helpers-DEn3pfjm.js';
|
|
6
6
|
import { l as chevronDown } from './index-DV3sJJW8.js';
|
|
7
7
|
import { b as getIonMode } from './ionic-global-CDrldh-5.js';
|
|
@@ -13,10 +13,7 @@ const accordionMdCss = ":host{display:block;position:relative;width:100%;backgro
|
|
|
13
13
|
const Accordion = class {
|
|
14
14
|
constructor(hostRef) {
|
|
15
15
|
registerInstance(this, hostRef);
|
|
16
|
-
this.updateListener = (
|
|
17
|
-
var _a, _b;
|
|
18
|
-
const initialUpdate = (_b = (_a = ev.detail) === null || _a === void 0 ? void 0 : _a.initial) !== null && _b !== void 0 ? _b : false;
|
|
19
|
-
console.log('[Accordion]', this.value, 'updateListener - initial:', initialUpdate, 'hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded, 'currentState:', this.state);
|
|
16
|
+
this.updateListener = () => {
|
|
20
17
|
/**
|
|
21
18
|
* Determine if this update will cause an actual state change.
|
|
22
19
|
* We only want to mark as "interacted" if the state is changing.
|
|
@@ -28,18 +25,24 @@ const Accordion = class {
|
|
|
28
25
|
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
29
26
|
const isExpanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
30
27
|
const stateWillChange = shouldExpand !== isExpanded;
|
|
31
|
-
console.log('[Accordion]', this.value, 'shouldExpand:', shouldExpand, 'isExpanded:', isExpanded, 'stateWillChange:', stateWillChange);
|
|
32
28
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* (
|
|
29
|
+
* Only mark as interacted if:
|
|
30
|
+
* 1. This is not the first update we've received with a defined value
|
|
31
|
+
* 2. The state is actually changing (prevents redundant updates from enabling animations)
|
|
36
32
|
*/
|
|
37
|
-
if (
|
|
38
|
-
console.log('[Accordion]', this.value, 'Setting hasInteracted to true');
|
|
33
|
+
if (this.hasReceivedFirstUpdate && stateWillChange) {
|
|
39
34
|
this.hasInteracted = true;
|
|
40
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Only count this as the first update if the group value is defined.
|
|
38
|
+
* This prevents the initial undefined value from the group's componentDidLoad
|
|
39
|
+
* from being treated as the first real update.
|
|
40
|
+
*/
|
|
41
|
+
if (value !== undefined) {
|
|
42
|
+
this.hasReceivedFirstUpdate = true;
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
|
-
this.updateState(
|
|
45
|
+
this.updateState();
|
|
43
46
|
};
|
|
44
47
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
45
48
|
this.isNext = false;
|
|
@@ -56,6 +59,11 @@ const Accordion = class {
|
|
|
56
59
|
* Used to prevent the first expansion from animating.
|
|
57
60
|
*/
|
|
58
61
|
this.hasEverBeenExpanded = false;
|
|
62
|
+
/**
|
|
63
|
+
* Tracks if this accordion has received its first update from the group.
|
|
64
|
+
* Used to distinguish initial programmatic sets from user interactions.
|
|
65
|
+
*/
|
|
66
|
+
this.hasReceivedFirstUpdate = false;
|
|
59
67
|
/**
|
|
60
68
|
* The value of the accordion. Defaults to an autogenerated
|
|
61
69
|
* value.
|
|
@@ -160,21 +168,18 @@ const Accordion = class {
|
|
|
160
168
|
iconEl.setAttribute('aria-hidden', 'true');
|
|
161
169
|
ionItem.appendChild(iconEl);
|
|
162
170
|
};
|
|
163
|
-
this.expandAccordion = (
|
|
164
|
-
console.log('[Accordion]', this.value, 'expandAccordion - initialUpdate:', initialUpdate, 'state:', this.state);
|
|
171
|
+
this.expandAccordion = () => {
|
|
165
172
|
const { contentEl, contentElWrapper } = this;
|
|
166
|
-
|
|
173
|
+
/**
|
|
174
|
+
* If the content elements aren't available yet, just set the state.
|
|
175
|
+
* This happens on initial render before the DOM is ready.
|
|
176
|
+
*/
|
|
177
|
+
if (contentEl === undefined || contentElWrapper === undefined) {
|
|
167
178
|
this.state = 4 /* AccordionState.Expanded */;
|
|
168
|
-
/**
|
|
169
|
-
* Mark that this accordion has been expanded at least once.
|
|
170
|
-
* Do this even on initial expansion so future interactions animate.
|
|
171
|
-
*/
|
|
172
179
|
this.hasEverBeenExpanded = true;
|
|
173
|
-
console.log('[Accordion]', this.value, 'expandAccordion early return - hasEverBeenExpanded set to true');
|
|
174
180
|
return;
|
|
175
181
|
}
|
|
176
182
|
if (this.state === 4 /* AccordionState.Expanded */) {
|
|
177
|
-
console.log('[Accordion]', this.value, 'expandAccordion - already expanded, returning');
|
|
178
183
|
return;
|
|
179
184
|
}
|
|
180
185
|
if (this.currentRaf !== undefined) {
|
|
@@ -185,9 +190,7 @@ const Accordion = class {
|
|
|
185
190
|
* This allows subsequent expansions to animate.
|
|
186
191
|
*/
|
|
187
192
|
this.hasEverBeenExpanded = true;
|
|
188
|
-
console.log('[Accordion]', this.value, 'expandAccordion - hasEverBeenExpanded set to true');
|
|
189
193
|
if (this.shouldAnimate()) {
|
|
190
|
-
console.log('[Accordion]', this.value, 'expandAccordion - will animate');
|
|
191
194
|
raf(() => {
|
|
192
195
|
this.state = 8 /* AccordionState.Expanding */;
|
|
193
196
|
this.currentRaf = raf(async () => {
|
|
@@ -204,9 +207,13 @@ const Accordion = class {
|
|
|
204
207
|
this.state = 4 /* AccordionState.Expanded */;
|
|
205
208
|
}
|
|
206
209
|
};
|
|
207
|
-
this.collapseAccordion = (
|
|
210
|
+
this.collapseAccordion = () => {
|
|
208
211
|
const { contentEl } = this;
|
|
209
|
-
|
|
212
|
+
/**
|
|
213
|
+
* If the content element isn't available yet, just set the state.
|
|
214
|
+
* This happens on initial render before the DOM is ready.
|
|
215
|
+
*/
|
|
216
|
+
if (contentEl === undefined) {
|
|
210
217
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
211
218
|
return;
|
|
212
219
|
}
|
|
@@ -251,7 +258,6 @@ const Accordion = class {
|
|
|
251
258
|
* where effects run twice and might incorrectly mark as interacted.
|
|
252
259
|
*/
|
|
253
260
|
if (!this.hasInteracted || !this.hasEverBeenExpanded) {
|
|
254
|
-
console.log('[Accordion]', this.value, 'shouldAnimate: false - hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
255
261
|
return false;
|
|
256
262
|
}
|
|
257
263
|
if (typeof window === 'undefined') {
|
|
@@ -270,7 +276,7 @@ const Accordion = class {
|
|
|
270
276
|
}
|
|
271
277
|
return true;
|
|
272
278
|
};
|
|
273
|
-
this.updateState = async (
|
|
279
|
+
this.updateState = async () => {
|
|
274
280
|
const accordionGroup = this.accordionGroupEl;
|
|
275
281
|
const accordionValue = this.value;
|
|
276
282
|
if (!accordionGroup) {
|
|
@@ -279,11 +285,11 @@ const Accordion = class {
|
|
|
279
285
|
const value = accordionGroup.value;
|
|
280
286
|
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
281
287
|
if (shouldExpand) {
|
|
282
|
-
this.expandAccordion(
|
|
288
|
+
this.expandAccordion();
|
|
283
289
|
this.isNext = this.isPrevious = false;
|
|
284
290
|
}
|
|
285
291
|
else {
|
|
286
|
-
this.collapseAccordion(
|
|
292
|
+
this.collapseAccordion();
|
|
287
293
|
/**
|
|
288
294
|
* When using popout or inset,
|
|
289
295
|
* the collapsed accordion items
|
|
@@ -331,7 +337,7 @@ const Accordion = class {
|
|
|
331
337
|
var _a;
|
|
332
338
|
const accordionGroupEl = (this.accordionGroupEl = (_a = this.el) === null || _a === void 0 ? void 0 : _a.closest('ion-accordion-group'));
|
|
333
339
|
if (accordionGroupEl) {
|
|
334
|
-
this.updateState(
|
|
340
|
+
this.updateState();
|
|
335
341
|
addEventListener(accordionGroupEl, 'ionValueChange', this.updateListener);
|
|
336
342
|
}
|
|
337
343
|
}
|
|
@@ -386,10 +392,8 @@ const Accordion = class {
|
|
|
386
392
|
const expanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
387
393
|
const headerPart = expanded ? 'header expanded' : 'header';
|
|
388
394
|
const contentPart = expanded ? 'content expanded' : 'content';
|
|
389
|
-
const shouldAnimate = this.shouldAnimate();
|
|
390
|
-
console.log('[Accordion]', this.value, 'render - state:', this.state, 'shouldAnimate:', shouldAnimate, 'hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
391
395
|
this.setAria(expanded);
|
|
392
|
-
return (h(Host, { key: '
|
|
396
|
+
return (h(Host, { key: '0f3b65e32d6908f466e0b0535fbdad1d6d6c4c88', class: {
|
|
393
397
|
[mode]: true,
|
|
394
398
|
'accordion-expanding': this.state === 8 /* AccordionState.Expanding */,
|
|
395
399
|
'accordion-expanded': this.state === 4 /* AccordionState.Expanded */,
|
|
@@ -399,8 +403,8 @@ const Accordion = class {
|
|
|
399
403
|
'accordion-previous': this.isPrevious,
|
|
400
404
|
'accordion-disabled': disabled,
|
|
401
405
|
'accordion-readonly': readonly,
|
|
402
|
-
'accordion-animated': shouldAnimate,
|
|
403
|
-
} }, h("div", { key: '
|
|
406
|
+
'accordion-animated': this.shouldAnimate(),
|
|
407
|
+
} }, 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" })))));
|
|
404
408
|
}
|
|
405
409
|
static get delegatesFocus() { return true; }
|
|
406
410
|
get el() { return getElement(this); }
|
|
@@ -444,12 +448,9 @@ const AccordionGroup = class {
|
|
|
444
448
|
* Defaults to `"compact"`.
|
|
445
449
|
*/
|
|
446
450
|
this.expand = 'compact';
|
|
447
|
-
this.hasEmittedInitialValue = false;
|
|
448
|
-
this.isUserInitiatedChange = false;
|
|
449
451
|
}
|
|
450
452
|
valueChanged() {
|
|
451
|
-
this.
|
|
452
|
-
this.isUserInitiatedChange = false;
|
|
453
|
+
this.ionValueChange.emit({ value: this.value });
|
|
453
454
|
}
|
|
454
455
|
async disabledChanged() {
|
|
455
456
|
const { disabled } = this;
|
|
@@ -523,12 +524,11 @@ const AccordionGroup = class {
|
|
|
523
524
|
* it is possible for the value to be set after the Web Component
|
|
524
525
|
* initializes but before the value watcher is set up in Stencil.
|
|
525
526
|
* As a result, the watcher callback may not be fired.
|
|
526
|
-
* We work around this by manually
|
|
527
|
-
* has loaded and the watcher
|
|
527
|
+
* We work around this by manually calling the watcher
|
|
528
|
+
* callback when the component has loaded and the watcher
|
|
529
|
+
* is configured.
|
|
528
530
|
*/
|
|
529
|
-
|
|
530
|
-
this.emitValueChange(true);
|
|
531
|
-
}
|
|
531
|
+
this.valueChanged();
|
|
532
532
|
}
|
|
533
533
|
/**
|
|
534
534
|
* Sets the value property and emits ionChange.
|
|
@@ -539,7 +539,6 @@ const AccordionGroup = class {
|
|
|
539
539
|
* accordion group to an array.
|
|
540
540
|
*/
|
|
541
541
|
setValue(accordionValue) {
|
|
542
|
-
this.isUserInitiatedChange = true;
|
|
543
542
|
const value = (this.value = accordionValue);
|
|
544
543
|
this.ionChange.emit({ value });
|
|
545
544
|
}
|
|
@@ -609,41 +608,15 @@ const AccordionGroup = class {
|
|
|
609
608
|
async getAccordions() {
|
|
610
609
|
return Array.from(this.el.querySelectorAll(':scope > ion-accordion'));
|
|
611
610
|
}
|
|
612
|
-
emitValueChange(initial, isUserInitiated = false) {
|
|
613
|
-
const { value, multiple } = this;
|
|
614
|
-
if (!multiple && Array.isArray(value)) {
|
|
615
|
-
/**
|
|
616
|
-
* We do some processing on the `value` array so
|
|
617
|
-
* that it looks more like an array when logged to
|
|
618
|
-
* the console.
|
|
619
|
-
* Example given ['a', 'b']
|
|
620
|
-
* Default toString() behavior: a,b
|
|
621
|
-
* Custom behavior: ['a', 'b']
|
|
622
|
-
*/
|
|
623
|
-
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".
|
|
624
|
-
|
|
625
|
-
Value Passed: [${value.map((v) => `'${v}'`).join(', ')}]
|
|
626
|
-
`, this.el);
|
|
627
|
-
}
|
|
628
|
-
/**
|
|
629
|
-
* Track if this is the initial value update so accordions
|
|
630
|
-
* can skip transition animations when they first render.
|
|
631
|
-
*/
|
|
632
|
-
const shouldMarkInitial = initial || (!this.hasEmittedInitialValue && value !== undefined && !isUserInitiated);
|
|
633
|
-
this.ionValueChange.emit({ value, initial: shouldMarkInitial });
|
|
634
|
-
if (value !== undefined) {
|
|
635
|
-
this.hasEmittedInitialValue = true;
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
611
|
render() {
|
|
639
612
|
const { disabled, readonly, expand } = this;
|
|
640
613
|
const mode = getIonMode(this);
|
|
641
|
-
return (h(Host, { key: '
|
|
614
|
+
return (h(Host, { key: '9a4a3b7811e63a0748cdcda82a840179cdfb26e1', class: {
|
|
642
615
|
[mode]: true,
|
|
643
616
|
'accordion-group-disabled': disabled,
|
|
644
617
|
'accordion-group-readonly': readonly,
|
|
645
618
|
[`accordion-group-expand-${expand}`]: true,
|
|
646
|
-
}, role: "presentation" }, h("slot", { key: '
|
|
619
|
+
}, role: "presentation" }, h("slot", { key: '183cebf7e0eb468b5c28c4105f23ec5aed36be1b' })));
|
|
647
620
|
}
|
|
648
621
|
get el() { return getElement(this); }
|
|
649
622
|
static get watchers() { return {
|