@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
package/hydrate/index.mjs
CHANGED
|
@@ -4040,20 +4040,36 @@ const accordionMdCss = ":host{display:block;position:relative;width:100%;backgro
|
|
|
4040
4040
|
class Accordion {
|
|
4041
4041
|
constructor(hostRef) {
|
|
4042
4042
|
registerInstance(this, hostRef);
|
|
4043
|
-
this.updateListener = (
|
|
4044
|
-
var _a, _b;
|
|
4045
|
-
const initialUpdate = (_b = (_a = ev.detail) === null || _a === void 0 ? void 0 : _a.initial) !== null && _b !== void 0 ? _b : false;
|
|
4046
|
-
console.log('[Accordion]', this.value, 'updateListener - initial:', initialUpdate, 'hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
4043
|
+
this.updateListener = () => {
|
|
4047
4044
|
/**
|
|
4048
|
-
*
|
|
4049
|
-
*
|
|
4050
|
-
* This enables animations for this and future updates.
|
|
4045
|
+
* Determine if this update will cause an actual state change.
|
|
4046
|
+
* We only want to mark as "interacted" if the state is changing.
|
|
4051
4047
|
*/
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4048
|
+
const accordionGroup = this.accordionGroupEl;
|
|
4049
|
+
if (accordionGroup) {
|
|
4050
|
+
const value = accordionGroup.value;
|
|
4051
|
+
const accordionValue = this.value;
|
|
4052
|
+
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
4053
|
+
const isExpanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
4054
|
+
const stateWillChange = shouldExpand !== isExpanded;
|
|
4055
|
+
/**
|
|
4056
|
+
* Only mark as interacted if:
|
|
4057
|
+
* 1. This is not the first update we've received with a defined value
|
|
4058
|
+
* 2. The state is actually changing (prevents redundant updates from enabling animations)
|
|
4059
|
+
*/
|
|
4060
|
+
if (this.hasReceivedFirstUpdate && stateWillChange) {
|
|
4061
|
+
this.hasInteracted = true;
|
|
4062
|
+
}
|
|
4063
|
+
/**
|
|
4064
|
+
* Only count this as the first update if the group value is defined.
|
|
4065
|
+
* This prevents the initial undefined value from the group's componentDidLoad
|
|
4066
|
+
* from being treated as the first real update.
|
|
4067
|
+
*/
|
|
4068
|
+
if (value !== undefined) {
|
|
4069
|
+
this.hasReceivedFirstUpdate = true;
|
|
4070
|
+
}
|
|
4055
4071
|
}
|
|
4056
|
-
this.updateState(
|
|
4072
|
+
this.updateState();
|
|
4057
4073
|
};
|
|
4058
4074
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
4059
4075
|
this.isNext = false;
|
|
@@ -4070,6 +4086,11 @@ class Accordion {
|
|
|
4070
4086
|
* Used to prevent the first expansion from animating.
|
|
4071
4087
|
*/
|
|
4072
4088
|
this.hasEverBeenExpanded = false;
|
|
4089
|
+
/**
|
|
4090
|
+
* Tracks if this accordion has received its first update from the group.
|
|
4091
|
+
* Used to distinguish initial programmatic sets from user interactions.
|
|
4092
|
+
*/
|
|
4093
|
+
this.hasReceivedFirstUpdate = false;
|
|
4073
4094
|
/**
|
|
4074
4095
|
* The value of the accordion. Defaults to an autogenerated
|
|
4075
4096
|
* value.
|
|
@@ -4174,21 +4195,18 @@ class Accordion {
|
|
|
4174
4195
|
iconEl.setAttribute('aria-hidden', 'true');
|
|
4175
4196
|
ionItem.appendChild(iconEl);
|
|
4176
4197
|
};
|
|
4177
|
-
this.expandAccordion = (
|
|
4178
|
-
console.log('[Accordion]', this.value, 'expandAccordion - initialUpdate:', initialUpdate, 'state:', this.state);
|
|
4198
|
+
this.expandAccordion = () => {
|
|
4179
4199
|
const { contentEl, contentElWrapper } = this;
|
|
4180
|
-
|
|
4200
|
+
/**
|
|
4201
|
+
* If the content elements aren't available yet, just set the state.
|
|
4202
|
+
* This happens on initial render before the DOM is ready.
|
|
4203
|
+
*/
|
|
4204
|
+
if (contentEl === undefined || contentElWrapper === undefined) {
|
|
4181
4205
|
this.state = 4 /* AccordionState.Expanded */;
|
|
4182
|
-
/**
|
|
4183
|
-
* Mark that this accordion has been expanded at least once.
|
|
4184
|
-
* Do this even on initial expansion so future interactions animate.
|
|
4185
|
-
*/
|
|
4186
4206
|
this.hasEverBeenExpanded = true;
|
|
4187
|
-
console.log('[Accordion]', this.value, 'expandAccordion early return - hasEverBeenExpanded set to true');
|
|
4188
4207
|
return;
|
|
4189
4208
|
}
|
|
4190
4209
|
if (this.state === 4 /* AccordionState.Expanded */) {
|
|
4191
|
-
console.log('[Accordion]', this.value, 'expandAccordion - already expanded, returning');
|
|
4192
4210
|
return;
|
|
4193
4211
|
}
|
|
4194
4212
|
if (this.currentRaf !== undefined) {
|
|
@@ -4199,9 +4217,7 @@ class Accordion {
|
|
|
4199
4217
|
* This allows subsequent expansions to animate.
|
|
4200
4218
|
*/
|
|
4201
4219
|
this.hasEverBeenExpanded = true;
|
|
4202
|
-
console.log('[Accordion]', this.value, 'expandAccordion - hasEverBeenExpanded set to true');
|
|
4203
4220
|
if (this.shouldAnimate()) {
|
|
4204
|
-
console.log('[Accordion]', this.value, 'expandAccordion - will animate');
|
|
4205
4221
|
raf(() => {
|
|
4206
4222
|
this.state = 8 /* AccordionState.Expanding */;
|
|
4207
4223
|
this.currentRaf = raf(async () => {
|
|
@@ -4218,9 +4234,13 @@ class Accordion {
|
|
|
4218
4234
|
this.state = 4 /* AccordionState.Expanded */;
|
|
4219
4235
|
}
|
|
4220
4236
|
};
|
|
4221
|
-
this.collapseAccordion = (
|
|
4237
|
+
this.collapseAccordion = () => {
|
|
4222
4238
|
const { contentEl } = this;
|
|
4223
|
-
|
|
4239
|
+
/**
|
|
4240
|
+
* If the content element isn't available yet, just set the state.
|
|
4241
|
+
* This happens on initial render before the DOM is ready.
|
|
4242
|
+
*/
|
|
4243
|
+
if (contentEl === undefined) {
|
|
4224
4244
|
this.state = 1 /* AccordionState.Collapsed */;
|
|
4225
4245
|
return;
|
|
4226
4246
|
}
|
|
@@ -4265,7 +4285,6 @@ class Accordion {
|
|
|
4265
4285
|
* where effects run twice and might incorrectly mark as interacted.
|
|
4266
4286
|
*/
|
|
4267
4287
|
if (!this.hasInteracted || !this.hasEverBeenExpanded) {
|
|
4268
|
-
console.log('[Accordion]', this.value, 'shouldAnimate: false - hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
4269
4288
|
return false;
|
|
4270
4289
|
}
|
|
4271
4290
|
if (typeof window === 'undefined') {
|
|
@@ -4284,7 +4303,7 @@ class Accordion {
|
|
|
4284
4303
|
}
|
|
4285
4304
|
return true;
|
|
4286
4305
|
};
|
|
4287
|
-
this.updateState = async (
|
|
4306
|
+
this.updateState = async () => {
|
|
4288
4307
|
const accordionGroup = this.accordionGroupEl;
|
|
4289
4308
|
const accordionValue = this.value;
|
|
4290
4309
|
if (!accordionGroup) {
|
|
@@ -4293,11 +4312,11 @@ class Accordion {
|
|
|
4293
4312
|
const value = accordionGroup.value;
|
|
4294
4313
|
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
|
|
4295
4314
|
if (shouldExpand) {
|
|
4296
|
-
this.expandAccordion(
|
|
4315
|
+
this.expandAccordion();
|
|
4297
4316
|
this.isNext = this.isPrevious = false;
|
|
4298
4317
|
}
|
|
4299
4318
|
else {
|
|
4300
|
-
this.collapseAccordion(
|
|
4319
|
+
this.collapseAccordion();
|
|
4301
4320
|
/**
|
|
4302
4321
|
* When using popout or inset,
|
|
4303
4322
|
* the collapsed accordion items
|
|
@@ -4345,7 +4364,7 @@ class Accordion {
|
|
|
4345
4364
|
var _a;
|
|
4346
4365
|
const accordionGroupEl = (this.accordionGroupEl = (_a = this.el) === null || _a === void 0 ? void 0 : _a.closest('ion-accordion-group'));
|
|
4347
4366
|
if (accordionGroupEl) {
|
|
4348
|
-
this.updateState(
|
|
4367
|
+
this.updateState();
|
|
4349
4368
|
addEventListener$1(accordionGroupEl, 'ionValueChange', this.updateListener);
|
|
4350
4369
|
}
|
|
4351
4370
|
}
|
|
@@ -4400,10 +4419,8 @@ class Accordion {
|
|
|
4400
4419
|
const expanded = this.state === 4 /* AccordionState.Expanded */ || this.state === 8 /* AccordionState.Expanding */;
|
|
4401
4420
|
const headerPart = expanded ? 'header expanded' : 'header';
|
|
4402
4421
|
const contentPart = expanded ? 'content expanded' : 'content';
|
|
4403
|
-
const shouldAnimate = this.shouldAnimate();
|
|
4404
|
-
console.log('[Accordion]', this.value, 'render - state:', this.state, 'shouldAnimate:', shouldAnimate, 'hasInteracted:', this.hasInteracted, 'hasEverBeenExpanded:', this.hasEverBeenExpanded);
|
|
4405
4422
|
this.setAria(expanded);
|
|
4406
|
-
return (hAsync(Host, { key: '
|
|
4423
|
+
return (hAsync(Host, { key: '0f3b65e32d6908f466e0b0535fbdad1d6d6c4c88', class: {
|
|
4407
4424
|
[mode]: true,
|
|
4408
4425
|
'accordion-expanding': this.state === 8 /* AccordionState.Expanding */,
|
|
4409
4426
|
'accordion-expanded': this.state === 4 /* AccordionState.Expanded */,
|
|
@@ -4413,8 +4430,8 @@ class Accordion {
|
|
|
4413
4430
|
'accordion-previous': this.isPrevious,
|
|
4414
4431
|
'accordion-disabled': disabled,
|
|
4415
4432
|
'accordion-readonly': readonly,
|
|
4416
|
-
'accordion-animated': shouldAnimate,
|
|
4417
|
-
} }, hAsync("div", { key: '
|
|
4433
|
+
'accordion-animated': this.shouldAnimate(),
|
|
4434
|
+
} }, hAsync("div", { key: '79e49dde14246e65fab5ee991a9f06fda649b8a4', onClick: () => this.toggleExpanded(), id: "header", part: headerPart, "aria-controls": "content", ref: (headerEl) => (this.headerEl = headerEl) }, hAsync("slot", { key: '8938988b9a5f87357b8351ecf5ca37ae80461170', name: "header" })), hAsync("div", { key: '636a23a49fd8daae92a584452bc3f5b35072110d', id: "content", part: contentPart, role: "region", "aria-labelledby": "header", ref: (contentEl) => (this.contentEl = contentEl) }, hAsync("div", { key: 'dd28ba52dbd28690561206aac205190aebecb793', id: "content-wrapper", ref: (contentElWrapper) => (this.contentElWrapper = contentElWrapper) }, hAsync("slot", { key: '133fb1680990303ba55b61e3fed741a31295acdf', name: "content" })))));
|
|
4418
4435
|
}
|
|
4419
4436
|
static get delegatesFocus() { return true; }
|
|
4420
4437
|
get el() { return getElement(this); }
|
|
@@ -4479,12 +4496,9 @@ class AccordionGroup {
|
|
|
4479
4496
|
* Defaults to `"compact"`.
|
|
4480
4497
|
*/
|
|
4481
4498
|
this.expand = 'compact';
|
|
4482
|
-
this.hasEmittedInitialValue = false;
|
|
4483
|
-
this.isUserInitiatedChange = false;
|
|
4484
4499
|
}
|
|
4485
4500
|
valueChanged() {
|
|
4486
|
-
this.
|
|
4487
|
-
this.isUserInitiatedChange = false;
|
|
4501
|
+
this.ionValueChange.emit({ value: this.value });
|
|
4488
4502
|
}
|
|
4489
4503
|
async disabledChanged() {
|
|
4490
4504
|
const { disabled } = this;
|
|
@@ -4558,12 +4572,11 @@ class AccordionGroup {
|
|
|
4558
4572
|
* it is possible for the value to be set after the Web Component
|
|
4559
4573
|
* initializes but before the value watcher is set up in Stencil.
|
|
4560
4574
|
* As a result, the watcher callback may not be fired.
|
|
4561
|
-
* We work around this by manually
|
|
4562
|
-
* has loaded and the watcher
|
|
4575
|
+
* We work around this by manually calling the watcher
|
|
4576
|
+
* callback when the component has loaded and the watcher
|
|
4577
|
+
* is configured.
|
|
4563
4578
|
*/
|
|
4564
|
-
|
|
4565
|
-
this.emitValueChange(true);
|
|
4566
|
-
}
|
|
4579
|
+
this.valueChanged();
|
|
4567
4580
|
}
|
|
4568
4581
|
/**
|
|
4569
4582
|
* Sets the value property and emits ionChange.
|
|
@@ -4574,7 +4587,6 @@ class AccordionGroup {
|
|
|
4574
4587
|
* accordion group to an array.
|
|
4575
4588
|
*/
|
|
4576
4589
|
setValue(accordionValue) {
|
|
4577
|
-
this.isUserInitiatedChange = true;
|
|
4578
4590
|
const value = (this.value = accordionValue);
|
|
4579
4591
|
this.ionChange.emit({ value });
|
|
4580
4592
|
}
|
|
@@ -4644,41 +4656,15 @@ class AccordionGroup {
|
|
|
4644
4656
|
async getAccordions() {
|
|
4645
4657
|
return Array.from(this.el.querySelectorAll(':scope > ion-accordion'));
|
|
4646
4658
|
}
|
|
4647
|
-
emitValueChange(initial, isUserInitiated = false) {
|
|
4648
|
-
const { value, multiple } = this;
|
|
4649
|
-
if (!multiple && Array.isArray(value)) {
|
|
4650
|
-
/**
|
|
4651
|
-
* We do some processing on the `value` array so
|
|
4652
|
-
* that it looks more like an array when logged to
|
|
4653
|
-
* the console.
|
|
4654
|
-
* Example given ['a', 'b']
|
|
4655
|
-
* Default toString() behavior: a,b
|
|
4656
|
-
* Custom behavior: ['a', 'b']
|
|
4657
|
-
*/
|
|
4658
|
-
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".
|
|
4659
|
-
|
|
4660
|
-
Value Passed: [${value.map((v) => `'${v}'`).join(', ')}]
|
|
4661
|
-
`, this.el);
|
|
4662
|
-
}
|
|
4663
|
-
/**
|
|
4664
|
-
* Track if this is the initial value update so accordions
|
|
4665
|
-
* can skip transition animations when they first render.
|
|
4666
|
-
*/
|
|
4667
|
-
const shouldMarkInitial = initial || (!this.hasEmittedInitialValue && value !== undefined && !isUserInitiated);
|
|
4668
|
-
this.ionValueChange.emit({ value, initial: shouldMarkInitial });
|
|
4669
|
-
if (value !== undefined) {
|
|
4670
|
-
this.hasEmittedInitialValue = true;
|
|
4671
|
-
}
|
|
4672
|
-
}
|
|
4673
4659
|
render() {
|
|
4674
4660
|
const { disabled, readonly, expand } = this;
|
|
4675
4661
|
const mode = getIonMode$1(this);
|
|
4676
|
-
return (hAsync(Host, { key: '
|
|
4662
|
+
return (hAsync(Host, { key: '9a4a3b7811e63a0748cdcda82a840179cdfb26e1', class: {
|
|
4677
4663
|
[mode]: true,
|
|
4678
4664
|
'accordion-group-disabled': disabled,
|
|
4679
4665
|
'accordion-group-readonly': readonly,
|
|
4680
4666
|
[`accordion-group-expand-${expand}`]: true,
|
|
4681
|
-
}, role: "presentation" }, hAsync("slot", { key: '
|
|
4667
|
+
}, role: "presentation" }, hAsync("slot", { key: '183cebf7e0eb468b5c28c4105f23ec5aed36be1b' })));
|
|
4682
4668
|
}
|
|
4683
4669
|
get el() { return getElement(this); }
|
|
4684
4670
|
static get watchers() { return {
|
package/package.json
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* (C) Ionic http://ionicframework.com - MIT License
|
|
3
|
-
*/
|
|
4
|
-
import{r as o,e as t,h as i,d as n,g as e,c as s,f as a}from"./p-C8IsBmNU.js";import{g as r,r as d,f as c,m as h,t as l}from"./p-CTfR9YZG.js";import{l as p}from"./p-DV3sJJW8.js";import{b as u}from"./p-BFvmZNyx.js";const g=class{constructor(i){o(this,i),this.updateListener=o=>{var t,i;const n=null!==(i=null===(t=o.detail)||void 0===t?void 0:t.initial)&&void 0!==i&&i;console.log("[Accordion]",this.value,"updateListener - initial:",n,"hasInteracted:",this.hasInteracted,"hasEverBeenExpanded:",this.hasEverBeenExpanded),n||(console.log("[Accordion]",this.value,"Setting hasInteracted to true"),this.hasInteracted=!0),this.updateState(n)},this.state=1,this.isNext=!1,this.isPrevious=!1,this.hasInteracted=!1,this.hasEverBeenExpanded=!1,this.value="ion-accordion-"+x++,this.disabled=!1,this.readonly=!1,this.toggleIcon=p,this.toggleIconSlot="end",this.setItemDefaults=()=>{const o=this.getSlottedHeaderIonItem();o&&(o.button=!0,o.detail=!1,void 0===o.lines&&(o.lines="full"))},this.getSlottedHeaderIonItem=()=>{const{headerEl:o}=this;if(!o)return;const t=o.querySelector("slot");return t&&void 0!==t.assignedElements?t.assignedElements().find((o=>"ION-ITEM"===o.tagName)):void 0},this.setAria=(o=!1)=>{const t=this.getSlottedHeaderIonItem();if(!t)return;const i=r(t).querySelector("button");i&&i.setAttribute("aria-expanded",`${o}`)},this.slotToggleIcon=()=>{const o=this.getSlottedHeaderIonItem();if(!o)return;const{toggleIconSlot:t,toggleIcon:i}=this;if(o.querySelector(".ion-accordion-toggle-icon"))return;const n=document.createElement("ion-icon");n.slot=t,n.lazy=!1,n.classList.add("ion-accordion-toggle-icon"),n.icon=i,n.setAttribute("aria-hidden","true"),o.appendChild(n)},this.expandAccordion=(o=!1)=>{console.log("[Accordion]",this.value,"expandAccordion - initialUpdate:",o,"state:",this.state);const{contentEl:t,contentElWrapper:i}=this;if(o||void 0===t||void 0===i)return this.state=4,this.hasEverBeenExpanded=!0,void console.log("[Accordion]",this.value,"expandAccordion early return - hasEverBeenExpanded set to true");4!==this.state?(void 0!==this.currentRaf&&cancelAnimationFrame(this.currentRaf),this.hasEverBeenExpanded=!0,console.log("[Accordion]",this.value,"expandAccordion - hasEverBeenExpanded set to true"),this.shouldAnimate()?(console.log("[Accordion]",this.value,"expandAccordion - will animate"),d((()=>{this.state=8,this.currentRaf=d((async()=>{const o=i.offsetHeight,n=l(t,2e3);t.style.setProperty("max-height",`${o}px`),await n,this.state=4,t.style.removeProperty("max-height")}))}))):this.state=4):console.log("[Accordion]",this.value,"expandAccordion - already expanded, returning")},this.collapseAccordion=(o=!1)=>{const{contentEl:t}=this;o||void 0===t?this.state=1:1!==this.state&&(void 0!==this.currentRaf&&cancelAnimationFrame(this.currentRaf),this.shouldAnimate()?this.currentRaf=d((async()=>{t.style.setProperty("max-height",`${t.offsetHeight}px`),d((async()=>{const o=l(t,2e3);this.state=2,await o,this.state=1,t.style.removeProperty("max-height")}))})):this.state=1)},this.shouldAnimate=()=>this.hasInteracted&&this.hasEverBeenExpanded?"undefined"!=typeof window&&(!matchMedia("(prefers-reduced-motion: reduce)").matches&&!(!t.get("animated",!0)||this.accordionGroupEl&&!this.accordionGroupEl.animated)):(console.log("[Accordion]",this.value,"shouldAnimate: false - hasInteracted:",this.hasInteracted,"hasEverBeenExpanded:",this.hasEverBeenExpanded),!1),this.updateState=async(o=!1)=>{const t=this.accordionGroupEl,i=this.value;if(!t)return;const n=t.value;if(Array.isArray(n)?n.includes(i):n===i)this.expandAccordion(o),this.isNext=this.isPrevious=!1;else{this.collapseAccordion(o);const t=this.getNextSibling(),i=null==t?void 0:t.value;void 0!==i&&(this.isPrevious=Array.isArray(n)?n.includes(i):n===i);const e=this.getPreviousSibling(),s=null==e?void 0:e.value;void 0!==s&&(this.isNext=Array.isArray(n)?n.includes(s):n===s)}},this.getNextSibling=()=>{if(!this.el)return;const o=this.el.nextElementSibling;return"ION-ACCORDION"===(null==o?void 0:o.tagName)?o:void 0},this.getPreviousSibling=()=>{if(!this.el)return;const o=this.el.previousElementSibling;return"ION-ACCORDION"===(null==o?void 0:o.tagName)?o:void 0}}valueChanged(){this.updateState()}connectedCallback(){var o;const t=this.accordionGroupEl=null===(o=this.el)||void 0===o?void 0:o.closest("ion-accordion-group");t&&(this.updateState(!0),c(t,"ionValueChange",this.updateListener))}disconnectedCallback(){const o=this.accordionGroupEl;o&&h(o,"ionValueChange",this.updateListener)}componentDidLoad(){this.setItemDefaults(),this.slotToggleIcon(),d((()=>{this.setAria(4===this.state||8===this.state)}))}toggleExpanded(){const{accordionGroupEl:o,disabled:t,readonly:i,value:n,state:e}=this;t||i||(this.hasInteracted=!0,!o)||o.requestAccordionToggle(n,1===e||2===e)}render(){const{disabled:o,readonly:t}=this,e=u(this),s=4===this.state||8===this.state,a=s?"header expanded":"header",r=s?"content expanded":"content",d=this.shouldAnimate();return console.log("[Accordion]",this.value,"render - state:",this.state,"shouldAnimate:",d,"hasInteracted:",this.hasInteracted,"hasEverBeenExpanded:",this.hasEverBeenExpanded),this.setAria(s),i(n,{key:"9f73d0ed2ced6269234bdade7c0b95ec1bc697de",class:{[e]:!0,"accordion-expanding":8===this.state,"accordion-expanded":4===this.state,"accordion-collapsing":2===this.state,"accordion-collapsed":1===this.state,"accordion-next":this.isNext,"accordion-previous":this.isPrevious,"accordion-disabled":o,"accordion-readonly":t,"accordion-animated":d}},i("div",{key:"a58ed92158e49220057517759084d81d69f64cf9",onClick:()=>this.toggleExpanded(),id:"header",part:a,"aria-controls":"content",ref:o=>this.headerEl=o},i("slot",{key:"0d7fb864762d109ffee42e1d64f3dfc08986fa63",name:"header"})),i("div",{key:"b506df416bcdbd5a0a1bb28017eac44806bba6f0",id:"content",part:r,role:"region","aria-labelledby":"header",ref:o=>this.contentEl=o},i("div",{key:"304e77c2605f2c947afd9f97f608ef0ab11def03",id:"content-wrapper",ref:o=>this.contentElWrapper=o},i("slot",{key:"df5490817fd493ed807d0666d872850612ff986c",name:"content"}))))}static get delegatesFocus(){return!0}get el(){return e(this)}static get watchers(){return{value:["valueChanged"]}}};let x=0;g.style={ios:":host{display:block;position:relative;width:100%;background-color:var(--ion-background-color, #ffffff);overflow:hidden;z-index:0}:host(.accordion-expanding) ::slotted(ion-item[slot=header]),:host(.accordion-expanded) ::slotted(ion-item[slot=header]){--border-width:0px}:host(.accordion-animated){-webkit-transition:all 300ms cubic-bezier(0.25, 0.8, 0.5, 1);transition:all 300ms cubic-bezier(0.25, 0.8, 0.5, 1)}:host(.accordion-animated) #content{-webkit-transition:max-height 300ms cubic-bezier(0.25, 0.8, 0.5, 1);transition:max-height 300ms cubic-bezier(0.25, 0.8, 0.5, 1)}#content{overflow:hidden;will-change:max-height}:host(.accordion-collapsing) #content{max-height:0 !important}:host(.accordion-collapsed) #content{display:none}:host(.accordion-expanding) #content{max-height:0}:host(.accordion-expanding) #content-wrapper{overflow:auto}:host(.accordion-disabled) #header,:host(.accordion-readonly) #header,:host(.accordion-disabled) #content,:host(.accordion-readonly) #content{pointer-events:none}:host(.accordion-disabled) #header,:host(.accordion-disabled) #content{opacity:0.4}@media (prefers-reduced-motion: reduce){:host,#content{-webkit-transition:none !important;transition:none !important}}:host(.accordion-next) ::slotted(ion-item[slot=header]){--border-width:0.55px 0px 0.55px 0px}",md:":host{display:block;position:relative;width:100%;background-color:var(--ion-background-color, #ffffff);overflow:hidden;z-index:0}:host(.accordion-expanding) ::slotted(ion-item[slot=header]),:host(.accordion-expanded) ::slotted(ion-item[slot=header]){--border-width:0px}:host(.accordion-animated){-webkit-transition:all 300ms cubic-bezier(0.25, 0.8, 0.5, 1);transition:all 300ms cubic-bezier(0.25, 0.8, 0.5, 1)}:host(.accordion-animated) #content{-webkit-transition:max-height 300ms cubic-bezier(0.25, 0.8, 0.5, 1);transition:max-height 300ms cubic-bezier(0.25, 0.8, 0.5, 1)}#content{overflow:hidden;will-change:max-height}:host(.accordion-collapsing) #content{max-height:0 !important}:host(.accordion-collapsed) #content{display:none}:host(.accordion-expanding) #content{max-height:0}:host(.accordion-expanding) #content-wrapper{overflow:auto}:host(.accordion-disabled) #header,:host(.accordion-readonly) #header,:host(.accordion-disabled) #content,:host(.accordion-readonly) #content{pointer-events:none}:host(.accordion-disabled) #header,:host(.accordion-disabled) #content{opacity:0.4}@media (prefers-reduced-motion: reduce){:host,#content{-webkit-transition:none !important;transition:none !important}}"};const m=class{constructor(t){o(this,t),this.ionChange=s(this,"ionChange",7),this.ionValueChange=s(this,"ionValueChange",7),this.animated=!0,this.disabled=!1,this.readonly=!1,this.expand="compact",this.hasEmittedInitialValue=!1,this.isUserInitiatedChange=!1}valueChanged(){this.emitValueChange(!1,this.isUserInitiatedChange),this.isUserInitiatedChange=!1}async disabledChanged(){const{disabled:o}=this,t=await this.getAccordions();for(const i of t)i.disabled=o}async readonlyChanged(){const{readonly:o}=this,t=await this.getAccordions();for(const i of t)i.readonly=o}async onKeydown(o){const t=document.activeElement;if(!t)return;if(!t.closest('ion-accordion [slot="header"]'))return;const i="ION-ACCORDION"===t.tagName?t:t.closest("ion-accordion");if(!i)return;if(i.closest("ion-accordion-group")!==this.el)return;const n=await this.getAccordions(),e=n.findIndex((o=>o===i));if(-1===e)return;let s;"ArrowDown"===o.key?s=this.findNextAccordion(n,e):"ArrowUp"===o.key?s=this.findPreviousAccordion(n,e):"Home"===o.key?s=n[0]:"End"===o.key&&(s=n[n.length-1]),void 0!==s&&s!==t&&s.focus()}async componentDidLoad(){this.disabled&&this.disabledChanged(),this.readonly&&this.readonlyChanged(),this.hasEmittedInitialValue||this.emitValueChange(!0)}setValue(o){this.isUserInitiatedChange=!0;const t=this.value=o;this.ionChange.emit({value:t})}async requestAccordionToggle(o,t){const{multiple:i,value:n,readonly:e,disabled:s}=this;if(!e&&!s)if(t)if(i){const t=null!=n?n:[],i=Array.isArray(t)?t:[t];void 0===i.find((t=>t===o))&&void 0!==o&&this.setValue([...i,o])}else this.setValue(o);else if(i){const t=null!=n?n:[],i=Array.isArray(t)?t:[t];this.setValue(i.filter((t=>t!==o)))}else this.setValue(void 0)}findNextAccordion(o,t){const i=o[t+1];return void 0===i?o[0]:i}findPreviousAccordion(o,t){const i=o[t-1];return void 0===i?o[o.length-1]:i}async getAccordions(){return Array.from(this.el.querySelectorAll(":scope > ion-accordion"))}emitValueChange(o,t=!1){const{value:i,multiple:n}=this;!n&&Array.isArray(i)&&a(`[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".\n\n Value Passed: [${i.map((o=>`'${o}'`)).join(", ")}]\n`,this.el),this.ionValueChange.emit({value:i,initial:o||!this.hasEmittedInitialValue&&void 0!==i&&!t}),void 0!==i&&(this.hasEmittedInitialValue=!0)}render(){const{disabled:o,readonly:t,expand:e}=this,s=u(this);return i(n,{key:"fd64cd203e2c8acdfc266005f372e26c29853847",class:{[s]:!0,"accordion-group-disabled":o,"accordion-group-readonly":t,[`accordion-group-expand-${e}`]:!0},role:"presentation"},i("slot",{key:"bdd9f419fc6e20f5de6f0f52ac93af7ec9a380ef"}))}get el(){return e(this)}static get watchers(){return{value:["valueChanged"],disabled:["disabledChanged"],readonly:["readonlyChanged"]}}};m.style={ios:":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}",md:":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){-webkit-box-shadow:0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12);box-shadow:0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12)}:host(.accordion-group-expand-inset) ::slotted(ion-accordion.accordion-expanding),:host(.accordion-group-expand-inset) ::slotted(ion-accordion.accordion-expanded){margin-left:0;margin-right:0;margin-top:16px;margin-bottom:16px;border-radius:6px}:host(.accordion-group-expand-inset) ::slotted(ion-accordion.accordion-previous){border-end-end-radius:6px;border-end-start-radius:6px}:host(.accordion-group-expand-inset) ::slotted(ion-accordion.accordion-next){border-start-start-radius:6px;border-start-end-radius:6px}:host(.accordion-group-expand-inset) ::slotted(ion-accordion):first-of-type{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0}"};export{g as ion_accordion,m as ion_accordion_group}
|