@ionic/core 8.7.8-dev.11761837190.1db6c2b6 → 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 +51 -34
- package/dist/cjs/ion-accordion_2.cjs.entry.js +58 -72
- package/dist/collection/components/accordion/accordion.js +51 -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 +59 -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 +58 -72
- package/hydrate/index.mjs +58 -72
- package/package.json +1 -1
- package/dist/ionic/p-b331b4e6.entry.js +0 -4
|
@@ -21,20 +21,36 @@ 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);
|
|
24
|
+
this.updateListener = () => {
|
|
28
25
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* This enables animations for this and future updates.
|
|
26
|
+
* Determine if this update will cause an actual state change.
|
|
27
|
+
* We only want to mark as "interacted" if the state is changing.
|
|
32
28
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
const accordionGroup = this.accordionGroupEl;
|
|
30
|
+
if (accordionGroup) {
|
|
31
|
+
const value = accordionGroup.value;
|
|
32
|
+
const accordionValue = this.value;
|
|
33
|
+
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
34
|
+
const isExpanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
35
|
+
const stateWillChange = shouldExpand !== isExpanded;
|
|
36
|
+
/**
|
|
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)
|
|
40
|
+
*/
|
|
41
|
+
if (this.hasReceivedFirstUpdate && stateWillChange) {
|
|
42
|
+
this.hasInteracted = true;
|
|
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
|
+
}
|
|
36
52
|
}
|
|
37
|
-
this.updateState(
|
|
53
|
+
this.updateState();
|
|
38
54
|
};
|
|
39
55
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
40
56
|
this.isNext = false;
|
|
@@ -51,6 +67,11 @@ export class Accordion {
|
|
|
51
67
|
* Used to prevent the first expansion from animating.
|
|
52
68
|
*/
|
|
53
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;
|
|
54
75
|
/**
|
|
55
76
|
* The value of the accordion. Defaults to an autogenerated
|
|
56
77
|
* value.
|
|
@@ -155,21 +176,18 @@ export class Accordion {
|
|
|
155
176
|
iconEl.setAttribute('aria-hidden', 'true');
|
|
156
177
|
ionItem.appendChild(iconEl);
|
|
157
178
|
};
|
|
158
|
-
this.expandAccordion = (
|
|
159
|
-
console.log('[Accordion]', this.value, 'expandAccordion - initialUpdate:', initialUpdate, 'state:', this.state);
|
|
179
|
+
this.expandAccordion = () => {
|
|
160
180
|
const { contentEl, contentElWrapper } = this;
|
|
161
|
-
|
|
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) {
|
|
162
186
|
this.state = 4 /* AccordionState.Expanded */;
|
|
163
|
-
/**
|
|
164
|
-
* Mark that this accordion has been expanded at least once.
|
|
165
|
-
* Do this even on initial expansion so future interactions animate.
|
|
166
|
-
*/
|
|
167
187
|
this.hasEverBeenExpanded = true;
|
|
168
|
-
console.log('[Accordion]', this.value, 'expandAccordion early return - hasEverBeenExpanded set to true');
|
|
169
188
|
return;
|
|
170
189
|
}
|
|
171
190
|
if (this.state === 4 /* AccordionState.Expanded */) {
|
|
172
|
-
console.log('[Accordion]', this.value, 'expandAccordion - already expanded, returning');
|
|
173
191
|
return;
|
|
174
192
|
}
|
|
175
193
|
if (this.currentRaf !== undefined) {
|
|
@@ -180,9 +198,7 @@ export class Accordion {
|
|
|
180
198
|
* This allows subsequent expansions to animate.
|
|
181
199
|
*/
|
|
182
200
|
this.hasEverBeenExpanded = true;
|
|
183
|
-
console.log('[Accordion]', this.value, 'expandAccordion - hasEverBeenExpanded set to true');
|
|
184
201
|
if (this.shouldAnimate()) {
|
|
185
|
-
console.log('[Accordion]', this.value, 'expandAccordion - will animate');
|
|
186
202
|
raf(() => {
|
|
187
203
|
this.state = 8 /* AccordionState.Expanding */;
|
|
188
204
|
this.currentRaf = raf(async () => {
|
|
@@ -199,9 +215,13 @@ export class Accordion {
|
|
|
199
215
|
this.state = 4 /* AccordionState.Expanded */;
|
|
200
216
|
}
|
|
201
217
|
};
|
|
202
|
-
this.collapseAccordion = (
|
|
218
|
+
this.collapseAccordion = () => {
|
|
203
219
|
const { contentEl } = this;
|
|
204
|
-
|
|
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) {
|
|
205
225
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
206
226
|
return;
|
|
207
227
|
}
|
|
@@ -246,7 +266,6 @@ export class Accordion {
|
|
|
246
266
|
* where effects run twice and might incorrectly mark as interacted.
|
|
247
267
|
*/
|
|
248
268
|
if (!this.hasInteracted || !this.hasEverBeenExpanded) {
|
|
249
|
-
console.log('[Accordion]', this.value, 'shouldAnimate: false - hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
250
269
|
return false;
|
|
251
270
|
}
|
|
252
271
|
if (typeof window === 'undefined') {
|
|
@@ -265,7 +284,7 @@ export class Accordion {
|
|
|
265
284
|
}
|
|
266
285
|
return true;
|
|
267
286
|
};
|
|
268
|
-
this.updateState = async (
|
|
287
|
+
this.updateState = async () => {
|
|
269
288
|
const accordionGroup = this.accordionGroupEl;
|
|
270
289
|
const accordionValue = this.value;
|
|
271
290
|
if (!accordionGroup) {
|
|
@@ -274,11 +293,11 @@ export class Accordion {
|
|
|
274
293
|
const value = accordionGroup.value;
|
|
275
294
|
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
276
295
|
if (shouldExpand) {
|
|
277
|
-
this.expandAccordion(
|
|
296
|
+
this.expandAccordion();
|
|
278
297
|
this.isNext = this.isPrevious = false;
|
|
279
298
|
}
|
|
280
299
|
else {
|
|
281
|
-
this.collapseAccordion(
|
|
300
|
+
this.collapseAccordion();
|
|
282
301
|
/**
|
|
283
302
|
* When using popout or inset,
|
|
284
303
|
* the collapsed accordion items
|
|
@@ -326,7 +345,7 @@ export class Accordion {
|
|
|
326
345
|
var _a;
|
|
327
346
|
const accordionGroupEl = (this.accordionGroupEl = (_a = this.el) === null || _a === void 0 ? void 0 : _a.closest('ion-accordion-group'));
|
|
328
347
|
if (accordionGroupEl) {
|
|
329
|
-
this.updateState(
|
|
348
|
+
this.updateState();
|
|
330
349
|
addEventListener(accordionGroupEl, 'ionValueChange', this.updateListener);
|
|
331
350
|
}
|
|
332
351
|
}
|
|
@@ -381,10 +400,8 @@ export class Accordion {
|
|
|
381
400
|
const expanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
382
401
|
const headerPart = expanded ? 'header expanded' : 'header';
|
|
383
402
|
const contentPart = expanded ? 'content expanded' : 'content';
|
|
384
|
-
const shouldAnimate = this.shouldAnimate();
|
|
385
|
-
console.log('[Accordion]', this.value, 'render - state:', this.state, 'shouldAnimate:', shouldAnimate, 'hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
386
403
|
this.setAria(expanded);
|
|
387
|
-
return (h(Host, { key: '
|
|
404
|
+
return (h(Host, { key: '0f3b65e32d6908f466e0b0535fbdad1d6d6c4c88', class: {
|
|
388
405
|
[mode]: true,
|
|
389
406
|
'accordion-expanding': this.state === 8 /* AccordionState.Expanding */,
|
|
390
407
|
'accordion-expanded': this.state === 4 /* AccordionState.Expanded */,
|
|
@@ -394,8 +411,8 @@ export class Accordion {
|
|
|
394
411
|
'accordion-previous': this.isPrevious,
|
|
395
412
|
'accordion-disabled': disabled,
|
|
396
413
|
'accordion-readonly': readonly,
|
|
397
|
-
'accordion-animated': shouldAnimate,
|
|
398
|
-
} }, 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" })))));
|
|
399
416
|
}
|
|
400
417
|
static get is() { return "ion-accordion"; }
|
|
401
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,20 +13,36 @@ 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);
|
|
16
|
+
this.updateListener = () => {
|
|
20
17
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* This enables animations for this and future updates.
|
|
18
|
+
* Determine if this update will cause an actual state change.
|
|
19
|
+
* We only want to mark as "interacted" if the state is changing.
|
|
24
20
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const accordionGroup = this.accordionGroupEl;
|
|
22
|
+
if (accordionGroup) {
|
|
23
|
+
const value = accordionGroup.value;
|
|
24
|
+
const accordionValue = this.value;
|
|
25
|
+
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
26
|
+
const isExpanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
27
|
+
const stateWillChange = shouldExpand !== isExpanded;
|
|
28
|
+
/**
|
|
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)
|
|
32
|
+
*/
|
|
33
|
+
if (this.hasReceivedFirstUpdate && stateWillChange) {
|
|
34
|
+
this.hasInteracted = true;
|
|
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
|
+
}
|
|
28
44
|
}
|
|
29
|
-
this.updateState(
|
|
45
|
+
this.updateState();
|
|
30
46
|
};
|
|
31
47
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
32
48
|
this.isNext = false;
|
|
@@ -43,6 +59,11 @@ const Accordion = class {
|
|
|
43
59
|
* Used to prevent the first expansion from animating.
|
|
44
60
|
*/
|
|
45
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;
|
|
46
67
|
/**
|
|
47
68
|
* The value of the accordion. Defaults to an autogenerated
|
|
48
69
|
* value.
|
|
@@ -147,21 +168,18 @@ const Accordion = class {
|
|
|
147
168
|
iconEl.setAttribute('aria-hidden', 'true');
|
|
148
169
|
ionItem.appendChild(iconEl);
|
|
149
170
|
};
|
|
150
|
-
this.expandAccordion = (
|
|
151
|
-
console.log('[Accordion]', this.value, 'expandAccordion - initialUpdate:', initialUpdate, 'state:', this.state);
|
|
171
|
+
this.expandAccordion = () => {
|
|
152
172
|
const { contentEl, contentElWrapper } = this;
|
|
153
|
-
|
|
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) {
|
|
154
178
|
this.state = 4 /* AccordionState.Expanded */;
|
|
155
|
-
/**
|
|
156
|
-
* Mark that this accordion has been expanded at least once.
|
|
157
|
-
* Do this even on initial expansion so future interactions animate.
|
|
158
|
-
*/
|
|
159
179
|
this.hasEverBeenExpanded = true;
|
|
160
|
-
console.log('[Accordion]', this.value, 'expandAccordion early return - hasEverBeenExpanded set to true');
|
|
161
180
|
return;
|
|
162
181
|
}
|
|
163
182
|
if (this.state === 4 /* AccordionState.Expanded */) {
|
|
164
|
-
console.log('[Accordion]', this.value, 'expandAccordion - already expanded, returning');
|
|
165
183
|
return;
|
|
166
184
|
}
|
|
167
185
|
if (this.currentRaf !== undefined) {
|
|
@@ -172,9 +190,7 @@ const Accordion = class {
|
|
|
172
190
|
* This allows subsequent expansions to animate.
|
|
173
191
|
*/
|
|
174
192
|
this.hasEverBeenExpanded = true;
|
|
175
|
-
console.log('[Accordion]', this.value, 'expandAccordion - hasEverBeenExpanded set to true');
|
|
176
193
|
if (this.shouldAnimate()) {
|
|
177
|
-
console.log('[Accordion]', this.value, 'expandAccordion - will animate');
|
|
178
194
|
raf(() => {
|
|
179
195
|
this.state = 8 /* AccordionState.Expanding */;
|
|
180
196
|
this.currentRaf = raf(async () => {
|
|
@@ -191,9 +207,13 @@ const Accordion = class {
|
|
|
191
207
|
this.state = 4 /* AccordionState.Expanded */;
|
|
192
208
|
}
|
|
193
209
|
};
|
|
194
|
-
this.collapseAccordion = (
|
|
210
|
+
this.collapseAccordion = () => {
|
|
195
211
|
const { contentEl } = this;
|
|
196
|
-
|
|
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) {
|
|
197
217
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
198
218
|
return;
|
|
199
219
|
}
|
|
@@ -238,7 +258,6 @@ const Accordion = class {
|
|
|
238
258
|
* where effects run twice and might incorrectly mark as interacted.
|
|
239
259
|
*/
|
|
240
260
|
if (!this.hasInteracted || !this.hasEverBeenExpanded) {
|
|
241
|
-
console.log('[Accordion]', this.value, 'shouldAnimate: false - hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
242
261
|
return false;
|
|
243
262
|
}
|
|
244
263
|
if (typeof window === 'undefined') {
|
|
@@ -257,7 +276,7 @@ const Accordion = class {
|
|
|
257
276
|
}
|
|
258
277
|
return true;
|
|
259
278
|
};
|
|
260
|
-
this.updateState = async (
|
|
279
|
+
this.updateState = async () => {
|
|
261
280
|
const accordionGroup = this.accordionGroupEl;
|
|
262
281
|
const accordionValue = this.value;
|
|
263
282
|
if (!accordionGroup) {
|
|
@@ -266,11 +285,11 @@ const Accordion = class {
|
|
|
266
285
|
const value = accordionGroup.value;
|
|
267
286
|
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
268
287
|
if (shouldExpand) {
|
|
269
|
-
this.expandAccordion(
|
|
288
|
+
this.expandAccordion();
|
|
270
289
|
this.isNext = this.isPrevious = false;
|
|
271
290
|
}
|
|
272
291
|
else {
|
|
273
|
-
this.collapseAccordion(
|
|
292
|
+
this.collapseAccordion();
|
|
274
293
|
/**
|
|
275
294
|
* When using popout or inset,
|
|
276
295
|
* the collapsed accordion items
|
|
@@ -318,7 +337,7 @@ const Accordion = class {
|
|
|
318
337
|
var _a;
|
|
319
338
|
const accordionGroupEl = (this.accordionGroupEl = (_a = this.el) === null || _a === void 0 ? void 0 : _a.closest('ion-accordion-group'));
|
|
320
339
|
if (accordionGroupEl) {
|
|
321
|
-
this.updateState(
|
|
340
|
+
this.updateState();
|
|
322
341
|
addEventListener(accordionGroupEl, 'ionValueChange', this.updateListener);
|
|
323
342
|
}
|
|
324
343
|
}
|
|
@@ -373,10 +392,8 @@ const Accordion = class {
|
|
|
373
392
|
const expanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
374
393
|
const headerPart = expanded ? 'header expanded' : 'header';
|
|
375
394
|
const contentPart = expanded ? 'content expanded' : 'content';
|
|
376
|
-
const shouldAnimate = this.shouldAnimate();
|
|
377
|
-
console.log('[Accordion]', this.value, 'render - state:', this.state, 'shouldAnimate:', shouldAnimate, 'hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
378
395
|
this.setAria(expanded);
|
|
379
|
-
return (h(Host, { key: '
|
|
396
|
+
return (h(Host, { key: '0f3b65e32d6908f466e0b0535fbdad1d6d6c4c88', class: {
|
|
380
397
|
[mode]: true,
|
|
381
398
|
'accordion-expanding': this.state === 8 /* AccordionState.Expanding */,
|
|
382
399
|
'accordion-expanded': this.state === 4 /* AccordionState.Expanded */,
|
|
@@ -386,8 +403,8 @@ const Accordion = class {
|
|
|
386
403
|
'accordion-previous': this.isPrevious,
|
|
387
404
|
'accordion-disabled': disabled,
|
|
388
405
|
'accordion-readonly': readonly,
|
|
389
|
-
'accordion-animated': shouldAnimate,
|
|
390
|
-
} }, 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" })))));
|
|
391
408
|
}
|
|
392
409
|
static get delegatesFocus() { return true; }
|
|
393
410
|
get el() { return getElement(this); }
|
|
@@ -431,12 +448,9 @@ const AccordionGroup = class {
|
|
|
431
448
|
* Defaults to `"compact"`.
|
|
432
449
|
*/
|
|
433
450
|
this.expand = 'compact';
|
|
434
|
-
this.hasEmittedInitialValue = false;
|
|
435
|
-
this.isUserInitiatedChange = false;
|
|
436
451
|
}
|
|
437
452
|
valueChanged() {
|
|
438
|
-
this.
|
|
439
|
-
this.isUserInitiatedChange = false;
|
|
453
|
+
this.ionValueChange.emit({ value: this.value });
|
|
440
454
|
}
|
|
441
455
|
async disabledChanged() {
|
|
442
456
|
const { disabled } = this;
|
|
@@ -510,12 +524,11 @@ const AccordionGroup = class {
|
|
|
510
524
|
* it is possible for the value to be set after the Web Component
|
|
511
525
|
* initializes but before the value watcher is set up in Stencil.
|
|
512
526
|
* As a result, the watcher callback may not be fired.
|
|
513
|
-
* We work around this by manually
|
|
514
|
-
* 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.
|
|
515
530
|
*/
|
|
516
|
-
|
|
517
|
-
this.emitValueChange(true);
|
|
518
|
-
}
|
|
531
|
+
this.valueChanged();
|
|
519
532
|
}
|
|
520
533
|
/**
|
|
521
534
|
* Sets the value property and emits ionChange.
|
|
@@ -526,7 +539,6 @@ const AccordionGroup = class {
|
|
|
526
539
|
* accordion group to an array.
|
|
527
540
|
*/
|
|
528
541
|
setValue(accordionValue) {
|
|
529
|
-
this.isUserInitiatedChange = true;
|
|
530
542
|
const value = (this.value = accordionValue);
|
|
531
543
|
this.ionChange.emit({ value });
|
|
532
544
|
}
|
|
@@ -596,41 +608,15 @@ const AccordionGroup = class {
|
|
|
596
608
|
async getAccordions() {
|
|
597
609
|
return Array.from(this.el.querySelectorAll(':scope > ion-accordion'));
|
|
598
610
|
}
|
|
599
|
-
emitValueChange(initial, isUserInitiated = false) {
|
|
600
|
-
const { value, multiple } = this;
|
|
601
|
-
if (!multiple && Array.isArray(value)) {
|
|
602
|
-
/**
|
|
603
|
-
* We do some processing on the `value` array so
|
|
604
|
-
* that it looks more like an array when logged to
|
|
605
|
-
* the console.
|
|
606
|
-
* Example given ['a', 'b']
|
|
607
|
-
* Default toString() behavior: a,b
|
|
608
|
-
* Custom behavior: ['a', 'b']
|
|
609
|
-
*/
|
|
610
|
-
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".
|
|
611
|
-
|
|
612
|
-
Value Passed: [${value.map((v) => `'${v}'`).join(', ')}]
|
|
613
|
-
`, this.el);
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* Track if this is the initial value update so accordions
|
|
617
|
-
* can skip transition animations when they first render.
|
|
618
|
-
*/
|
|
619
|
-
const shouldMarkInitial = initial || (!this.hasEmittedInitialValue && value !== undefined && !isUserInitiated);
|
|
620
|
-
this.ionValueChange.emit({ value, initial: shouldMarkInitial });
|
|
621
|
-
if (value !== undefined) {
|
|
622
|
-
this.hasEmittedInitialValue = true;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
611
|
render() {
|
|
626
612
|
const { disabled, readonly, expand } = this;
|
|
627
613
|
const mode = getIonMode(this);
|
|
628
|
-
return (h(Host, { key: '
|
|
614
|
+
return (h(Host, { key: '9a4a3b7811e63a0748cdcda82a840179cdfb26e1', class: {
|
|
629
615
|
[mode]: true,
|
|
630
616
|
'accordion-group-disabled': disabled,
|
|
631
617
|
'accordion-group-readonly': readonly,
|
|
632
618
|
[`accordion-group-expand-${expand}`]: true,
|
|
633
|
-
}, role: "presentation" }, h("slot", { key: '
|
|
619
|
+
}, role: "presentation" }, h("slot", { key: '183cebf7e0eb468b5c28c4105f23ec5aed36be1b' })));
|
|
634
620
|
}
|
|
635
621
|
get el() { return getElement(this); }
|
|
636
622
|
static get watchers() { return {
|