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