@ionic/core 8.7.8-dev.11761677762.1e345efd → 8.7.8-dev.11761832341.1f46802b

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.
@@ -0,0 +1,4 @@
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 a,f as s}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;n||(this.hasInteracted=!0),this.updateState(n)},this.state=1,this.isNext=!1,this.isPrevious=!1,this.hasInteracted=!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)=>{const{contentEl:t,contentElWrapper:i}=this;o||void 0===t||void 0===i?this.state=4:4!==this.state&&(void 0!==this.currentRaf&&cancelAnimationFrame(this.currentRaf),this.shouldAnimate()?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)},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&&("undefined"!=typeof window&&(!matchMedia("(prefers-reduced-motion: reduce)").matches&&!(!t.get("animated",!0)||this.accordionGroupEl&&!this.accordionGroupEl.animated))),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(),a=null==e?void 0:e.value;void 0!==a&&(this.isNext=Array.isArray(n)?n.includes(a):n===a)}},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),a=4===this.state||8===this.state,s=a?"header expanded":"header",r=a?"content expanded":"content";return this.setAria(a),i(n,{key:"c8280b871eea1335aa18ba7eae14f628ef18b582",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":this.shouldAnimate()}},i("div",{key:"58019e35314843e0c4f75f9a133cb3363a936072",onClick:()=>this.toggleExpanded(),id:"header",part:s,"aria-controls":"content",ref:o=>this.headerEl=o},i("slot",{key:"22033a83daaf9759865aa9c448da83cfb1e031de",name:"header"})),i("div",{key:"fd4fd72662822ff024d9ed633981333503bd111a",id:"content",part:r,role:"region","aria-labelledby":"header",ref:o=>this.contentEl=o},i("div",{key:"bcbb9848eaf3e4a11265f904a52a443a4e1c6c36",id:"content-wrapper",ref:o=>this.contentElWrapper=o},i("slot",{key:"1d1f8b04898ee2fe8c3d7ff4a7e0a940476f25c4",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=a(this,"ionChange",7),this.ionValueChange=a(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 a;"ArrowDown"===o.key?a=this.findNextAccordion(n,e):"ArrowUp"===o.key?a=this.findPreviousAccordion(n,e):"Home"===o.key?a=n[0]:"End"===o.key&&(a=n[n.length-1]),void 0!==a&&a!==t&&a.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:a}=this;if(!e&&!a)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)&&s(`[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,a=u(this);return i(n,{key:"fd64cd203e2c8acdfc266005f372e26c29853847",class:{[a]:!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}
@@ -25,18 +25,17 @@ export declare class Accordion implements ComponentInterface {
25
25
  private contentElWrapper;
26
26
  private headerEl;
27
27
  private currentRaf;
28
- /**
29
- * If true, the next animation will be skipped.
30
- * We want to skip the animation when the accordion
31
- * is expanded or collapsed on the initial load.
32
- * This prevents the accordion from animating when
33
- * it starts expanded or collapsed.
34
- */
35
- private skipNextAnimation;
36
28
  el?: HTMLElement;
37
29
  state: AccordionState;
38
30
  isNext: boolean;
39
31
  isPrevious: boolean;
32
+ /**
33
+ * Tracks whether a user-initiated interaction has occurred.
34
+ * Animations are disabled until the first interaction happens.
35
+ * This prevents the accordion from animating when it's programmatically
36
+ * set to an expanded or collapsed state on initial load.
37
+ */
38
+ hasInteracted: boolean;
40
39
  /**
41
40
  * The value of the accordion. Defaults to an autogenerated
42
41
  * value.
@@ -66,7 +65,6 @@ export declare class Accordion implements ComponentInterface {
66
65
  connectedCallback(): void;
67
66
  disconnectedCallback(): void;
68
67
  componentDidLoad(): void;
69
- componentDidRender(): void;
70
68
  private setItemDefaults;
71
69
  private getSlottedHeaderIonItem;
72
70
  private setAria;
package/hydrate/index.js CHANGED
@@ -4045,19 +4045,26 @@ class Accordion {
4045
4045
  this.updateListener = (ev) => {
4046
4046
  var _a, _b;
4047
4047
  const initialUpdate = (_b = (_a = ev.detail) === null || _a === void 0 ? void 0 : _a.initial) !== null && _b !== void 0 ? _b : false;
4048
+ /**
4049
+ * If this is not an initial update (meaning it's from a user interaction
4050
+ * or programmatic call after load), mark that we've had an interaction.
4051
+ * This enables animations for this and future updates.
4052
+ */
4053
+ if (!initialUpdate) {
4054
+ this.hasInteracted = true;
4055
+ }
4048
4056
  this.updateState(initialUpdate);
4049
4057
  };
4050
- /**
4051
- * If true, the next animation will be skipped.
4052
- * We want to skip the animation when the accordion
4053
- * is expanded or collapsed on the initial load.
4054
- * This prevents the accordion from animating when
4055
- * it starts expanded or collapsed.
4056
- */
4057
- this.skipNextAnimation = true;
4058
4058
  this.state = 1 /* AccordionState.Collapsed */;
4059
4059
  this.isNext = false;
4060
4060
  this.isPrevious = false;
4061
+ /**
4062
+ * Tracks whether a user-initiated interaction has occurred.
4063
+ * Animations are disabled until the first interaction happens.
4064
+ * This prevents the accordion from animating when it's programmatically
4065
+ * set to an expanded or collapsed state on initial load.
4066
+ */
4067
+ this.hasInteracted = false;
4061
4068
  /**
4062
4069
  * The value of the accordion. Defaults to an autogenerated
4063
4070
  * value.
@@ -4228,7 +4235,12 @@ class Accordion {
4228
4235
  * of what is set in the config.
4229
4236
  */
4230
4237
  this.shouldAnimate = () => {
4231
- if (this.skipNextAnimation) {
4238
+ /**
4239
+ * Don't animate until after the first user interaction.
4240
+ * This prevents animations on initial load when accordions
4241
+ * start in an expanded or collapsed state programmatically.
4242
+ */
4243
+ if (!this.hasInteracted) {
4232
4244
  return false;
4233
4245
  }
4234
4246
  if (typeof window === 'undefined') {
@@ -4255,10 +4267,6 @@ class Accordion {
4255
4267
  }
4256
4268
  const value = accordionGroup.value;
4257
4269
  const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
4258
- const shouldDisableAnimation = initialUpdate && shouldExpand;
4259
- if (shouldDisableAnimation) {
4260
- this.skipNextAnimation = true;
4261
- }
4262
4270
  if (shouldExpand) {
4263
4271
  this.expandAccordion(initialUpdate);
4264
4272
  this.isNext = this.isPrevious = false;
@@ -4339,15 +4347,15 @@ class Accordion {
4339
4347
  this.setAria(expanded);
4340
4348
  });
4341
4349
  }
4342
- componentDidRender() {
4343
- if (this.skipNextAnimation) {
4344
- this.skipNextAnimation = false;
4345
- }
4346
- }
4347
4350
  toggleExpanded() {
4348
4351
  const { accordionGroupEl, disabled, readonly, value, state } = this;
4349
4352
  if (disabled || readonly)
4350
4353
  return;
4354
+ /**
4355
+ * Mark that the user has interacted with the accordion.
4356
+ * This enables animations for all future state changes.
4357
+ */
4358
+ this.hasInteracted = true;
4351
4359
  if (accordionGroupEl) {
4352
4360
  /**
4353
4361
  * Because the accordion group may or may
@@ -4368,7 +4376,7 @@ class Accordion {
4368
4376
  const headerPart = expanded ? 'header expanded' : 'header';
4369
4377
  const contentPart = expanded ? 'content expanded' : 'content';
4370
4378
  this.setAria(expanded);
4371
- return (hAsync(Host, { key: 'd8425e5c758533712eddf4b13a42aa72022b0dc0', class: {
4379
+ return (hAsync(Host, { key: 'c8280b871eea1335aa18ba7eae14f628ef18b582', class: {
4372
4380
  [mode]: true,
4373
4381
  'accordion-expanding': this.state === 8 /* AccordionState.Expanding */,
4374
4382
  'accordion-expanded': this.state === 4 /* AccordionState.Expanded */,
@@ -4379,7 +4387,7 @@ class Accordion {
4379
4387
  'accordion-disabled': disabled,
4380
4388
  'accordion-readonly': readonly,
4381
4389
  'accordion-animated': this.shouldAnimate(),
4382
- } }, hAsync("div", { key: '1a7f7e95bb3bd7f9c81c753223763d304b630fe7', onClick: () => this.toggleExpanded(), id: "header", part: headerPart, "aria-controls": "content", ref: (headerEl) => (this.headerEl = headerEl) }, hAsync("slot", { key: 'c4c516d60111489346ab002f7c51bd54c89509bc', name: "header" })), hAsync("div", { key: 'beff73b33eb5a5adae60efae4945c98d423243af', id: "content", part: contentPart, role: "region", "aria-labelledby": "header", ref: (contentEl) => (this.contentEl = contentEl) }, hAsync("div", { key: '15046373eb2411d0536555f697e0d6672d7993f0', id: "content-wrapper", ref: (contentElWrapper) => (this.contentElWrapper = contentElWrapper) }, hAsync("slot", { key: 'fb0325497ee7bf4e4f581bb891b1e79886c21efb', name: "content" })))));
4390
+ } }, hAsync("div", { key: '58019e35314843e0c4f75f9a133cb3363a936072', onClick: () => this.toggleExpanded(), id: "header", part: headerPart, "aria-controls": "content", ref: (headerEl) => (this.headerEl = headerEl) }, hAsync("slot", { key: '22033a83daaf9759865aa9c448da83cfb1e031de', name: "header" })), hAsync("div", { key: 'fd4fd72662822ff024d9ed633981333503bd111a', id: "content", part: contentPart, role: "region", "aria-labelledby": "header", ref: (contentEl) => (this.contentEl = contentEl) }, hAsync("div", { key: 'bcbb9848eaf3e4a11265f904a52a443a4e1c6c36', id: "content-wrapper", ref: (contentElWrapper) => (this.contentElWrapper = contentElWrapper) }, hAsync("slot", { key: '1d1f8b04898ee2fe8c3d7ff4a7e0a940476f25c4', name: "content" })))));
4383
4391
  }
4384
4392
  static get delegatesFocus() { return true; }
4385
4393
  get el() { return getElement(this); }
@@ -4401,7 +4409,8 @@ class Accordion {
4401
4409
  "toggleIconSlot": [1, "toggle-icon-slot"],
4402
4410
  "state": [32],
4403
4411
  "isNext": [32],
4404
- "isPrevious": [32]
4412
+ "isPrevious": [32],
4413
+ "hasInteracted": [32]
4405
4414
  },
4406
4415
  "$listeners$": undefined,
4407
4416
  "$lazyBundleId$": "-",
package/hydrate/index.mjs CHANGED
@@ -4043,19 +4043,26 @@ class Accordion {
4043
4043
  this.updateListener = (ev) => {
4044
4044
  var _a, _b;
4045
4045
  const initialUpdate = (_b = (_a = ev.detail) === null || _a === void 0 ? void 0 : _a.initial) !== null && _b !== void 0 ? _b : false;
4046
+ /**
4047
+ * If this is not an initial update (meaning it's from a user interaction
4048
+ * or programmatic call after load), mark that we've had an interaction.
4049
+ * This enables animations for this and future updates.
4050
+ */
4051
+ if (!initialUpdate) {
4052
+ this.hasInteracted = true;
4053
+ }
4046
4054
  this.updateState(initialUpdate);
4047
4055
  };
4048
- /**
4049
- * If true, the next animation will be skipped.
4050
- * We want to skip the animation when the accordion
4051
- * is expanded or collapsed on the initial load.
4052
- * This prevents the accordion from animating when
4053
- * it starts expanded or collapsed.
4054
- */
4055
- this.skipNextAnimation = true;
4056
4056
  this.state = 1 /* AccordionState.Collapsed */;
4057
4057
  this.isNext = false;
4058
4058
  this.isPrevious = false;
4059
+ /**
4060
+ * Tracks whether a user-initiated interaction has occurred.
4061
+ * Animations are disabled until the first interaction happens.
4062
+ * This prevents the accordion from animating when it's programmatically
4063
+ * set to an expanded or collapsed state on initial load.
4064
+ */
4065
+ this.hasInteracted = false;
4059
4066
  /**
4060
4067
  * The value of the accordion. Defaults to an autogenerated
4061
4068
  * value.
@@ -4226,7 +4233,12 @@ class Accordion {
4226
4233
  * of what is set in the config.
4227
4234
  */
4228
4235
  this.shouldAnimate = () => {
4229
- if (this.skipNextAnimation) {
4236
+ /**
4237
+ * Don't animate until after the first user interaction.
4238
+ * This prevents animations on initial load when accordions
4239
+ * start in an expanded or collapsed state programmatically.
4240
+ */
4241
+ if (!this.hasInteracted) {
4230
4242
  return false;
4231
4243
  }
4232
4244
  if (typeof window === 'undefined') {
@@ -4253,10 +4265,6 @@ class Accordion {
4253
4265
  }
4254
4266
  const value = accordionGroup.value;
4255
4267
  const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
4256
- const shouldDisableAnimation = initialUpdate && shouldExpand;
4257
- if (shouldDisableAnimation) {
4258
- this.skipNextAnimation = true;
4259
- }
4260
4268
  if (shouldExpand) {
4261
4269
  this.expandAccordion(initialUpdate);
4262
4270
  this.isNext = this.isPrevious = false;
@@ -4337,15 +4345,15 @@ class Accordion {
4337
4345
  this.setAria(expanded);
4338
4346
  });
4339
4347
  }
4340
- componentDidRender() {
4341
- if (this.skipNextAnimation) {
4342
- this.skipNextAnimation = false;
4343
- }
4344
- }
4345
4348
  toggleExpanded() {
4346
4349
  const { accordionGroupEl, disabled, readonly, value, state } = this;
4347
4350
  if (disabled || readonly)
4348
4351
  return;
4352
+ /**
4353
+ * Mark that the user has interacted with the accordion.
4354
+ * This enables animations for all future state changes.
4355
+ */
4356
+ this.hasInteracted = true;
4349
4357
  if (accordionGroupEl) {
4350
4358
  /**
4351
4359
  * Because the accordion group may or may
@@ -4366,7 +4374,7 @@ class Accordion {
4366
4374
  const headerPart = expanded ? 'header expanded' : 'header';
4367
4375
  const contentPart = expanded ? 'content expanded' : 'content';
4368
4376
  this.setAria(expanded);
4369
- return (hAsync(Host, { key: 'd8425e5c758533712eddf4b13a42aa72022b0dc0', class: {
4377
+ return (hAsync(Host, { key: 'c8280b871eea1335aa18ba7eae14f628ef18b582', class: {
4370
4378
  [mode]: true,
4371
4379
  'accordion-expanding': this.state === 8 /* AccordionState.Expanding */,
4372
4380
  'accordion-expanded': this.state === 4 /* AccordionState.Expanded */,
@@ -4377,7 +4385,7 @@ class Accordion {
4377
4385
  'accordion-disabled': disabled,
4378
4386
  'accordion-readonly': readonly,
4379
4387
  'accordion-animated': this.shouldAnimate(),
4380
- } }, hAsync("div", { key: '1a7f7e95bb3bd7f9c81c753223763d304b630fe7', onClick: () => this.toggleExpanded(), id: "header", part: headerPart, "aria-controls": "content", ref: (headerEl) => (this.headerEl = headerEl) }, hAsync("slot", { key: 'c4c516d60111489346ab002f7c51bd54c89509bc', name: "header" })), hAsync("div", { key: 'beff73b33eb5a5adae60efae4945c98d423243af', id: "content", part: contentPart, role: "region", "aria-labelledby": "header", ref: (contentEl) => (this.contentEl = contentEl) }, hAsync("div", { key: '15046373eb2411d0536555f697e0d6672d7993f0', id: "content-wrapper", ref: (contentElWrapper) => (this.contentElWrapper = contentElWrapper) }, hAsync("slot", { key: 'fb0325497ee7bf4e4f581bb891b1e79886c21efb', name: "content" })))));
4388
+ } }, hAsync("div", { key: '58019e35314843e0c4f75f9a133cb3363a936072', onClick: () => this.toggleExpanded(), id: "header", part: headerPart, "aria-controls": "content", ref: (headerEl) => (this.headerEl = headerEl) }, hAsync("slot", { key: '22033a83daaf9759865aa9c448da83cfb1e031de', name: "header" })), hAsync("div", { key: 'fd4fd72662822ff024d9ed633981333503bd111a', id: "content", part: contentPart, role: "region", "aria-labelledby": "header", ref: (contentEl) => (this.contentEl = contentEl) }, hAsync("div", { key: 'bcbb9848eaf3e4a11265f904a52a443a4e1c6c36', id: "content-wrapper", ref: (contentElWrapper) => (this.contentElWrapper = contentElWrapper) }, hAsync("slot", { key: '1d1f8b04898ee2fe8c3d7ff4a7e0a940476f25c4', name: "content" })))));
4381
4389
  }
4382
4390
  static get delegatesFocus() { return true; }
4383
4391
  get el() { return getElement(this); }
@@ -4399,7 +4407,8 @@ class Accordion {
4399
4407
  "toggleIconSlot": [1, "toggle-icon-slot"],
4400
4408
  "state": [32],
4401
4409
  "isNext": [32],
4402
- "isPrevious": [32]
4410
+ "isPrevious": [32],
4411
+ "hasInteracted": [32]
4403
4412
  },
4404
4413
  "$listeners$": undefined,
4405
4414
  "$lazyBundleId$": "-",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ionic/core",
3
- "version": "8.7.8-dev.11761677762.1e345efd",
3
+ "version": "8.7.8-dev.11761832341.1f46802b",
4
4
  "description": "Base components for Ionic",
5
5
  "keywords": [
6
6
  "ionic",
@@ -1,4 +0,0 @@
1
- /*!
2
- * (C) Ionic http://ionicframework.com - MIT License
3
- */
4
- import{r as o,e as t,i,h as n,d as e,g as a,c as s,f as r}from"./p-C8IsBmNU.js";import{g as d,r as c,f as h,m as l,t as p}from"./p-CTfR9YZG.js";import{l as u}from"./p-DV3sJJW8.js";import{b as g}from"./p-BFvmZNyx.js";const x=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;this.updateState(n)},this.skipNextAnimation=!0,this.state=1,this.isNext=!1,this.isPrevious=!1,this.value="ion-accordion-"+b++,this.disabled=!1,this.readonly=!1,this.toggleIcon=u,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=d(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)=>{const{contentEl:t,contentElWrapper:i}=this;o||void 0===t||void 0===i?this.state=4:4!==this.state&&(void 0!==this.currentRaf&&cancelAnimationFrame(this.currentRaf),this.shouldAnimate()?c((()=>{this.state=8,this.currentRaf=c((async()=>{const o=i.offsetHeight,n=p(t,2e3);t.style.setProperty("max-height",`${o}px`),await n,this.state=4,t.style.removeProperty("max-height")}))})):this.state=4)},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=c((async()=>{t.style.setProperty("max-height",`${t.offsetHeight}px`),c((async()=>{const o=p(t,2e3);this.state=2,await o,this.state=1,t.style.removeProperty("max-height")}))})):this.state=1)},this.shouldAnimate=()=>!this.skipNextAnimation&&("undefined"!=typeof window&&(!matchMedia("(prefers-reduced-motion: reduce)").matches&&!(!t.get("animated",!0)||this.accordionGroupEl&&!this.accordionGroupEl.animated))),this.updateState=async(o=!1)=>{const t=this.accordionGroupEl,i=this.value;if(!t)return;const n=t.value,e=Array.isArray(n)?n.includes(i):n===i;if(o&&e&&(this.skipNextAnimation=!0),e)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(),a=null==e?void 0:e.value;void 0!==a&&(this.isNext=Array.isArray(n)?n.includes(a):n===a)}},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),h(t,"ionValueChange",this.updateListener))}disconnectedCallback(){const o=this.accordionGroupEl;o&&l(o,"ionValueChange",this.updateListener)}componentDidLoad(){this.setItemDefaults(),this.slotToggleIcon(),c((()=>{this.setAria(4===this.state||8===this.state)}))}componentDidRender(){this.skipNextAnimation&&(this.skipNextAnimation=!1,i(this))}toggleExpanded(){const{accordionGroupEl:o,disabled:t,readonly:i,value:n,state:e}=this;t||i||!o||o.requestAccordionToggle(n,1===e||2===e)}render(){const{disabled:o,readonly:t}=this,i=g(this),a=4===this.state||8===this.state,s=a?"header expanded":"header",r=a?"content expanded":"content";return this.setAria(a),n(e,{key:"d8425e5c758533712eddf4b13a42aa72022b0dc0",class:{[i]:!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":this.shouldAnimate()}},n("div",{key:"1a7f7e95bb3bd7f9c81c753223763d304b630fe7",onClick:()=>this.toggleExpanded(),id:"header",part:s,"aria-controls":"content",ref:o=>this.headerEl=o},n("slot",{key:"c4c516d60111489346ab002f7c51bd54c89509bc",name:"header"})),n("div",{key:"beff73b33eb5a5adae60efae4945c98d423243af",id:"content",part:r,role:"region","aria-labelledby":"header",ref:o=>this.contentEl=o},n("div",{key:"15046373eb2411d0536555f697e0d6672d7993f0",id:"content-wrapper",ref:o=>this.contentElWrapper=o},n("slot",{key:"fb0325497ee7bf4e4f581bb891b1e79886c21efb",name:"content"}))))}static get delegatesFocus(){return!0}get el(){return a(this)}static get watchers(){return{value:["valueChanged"]}}};let b=0;x.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 a;"ArrowDown"===o.key?a=this.findNextAccordion(n,e):"ArrowUp"===o.key?a=this.findPreviousAccordion(n,e):"Home"===o.key?a=n[0]:"End"===o.key&&(a=n[n.length-1]),void 0!==a&&a!==t&&a.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:a}=this;if(!e&&!a)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)&&r(`[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:i}=this,a=g(this);return n(e,{key:"fd64cd203e2c8acdfc266005f372e26c29853847",class:{[a]:!0,"accordion-group-disabled":o,"accordion-group-readonly":t,[`accordion-group-expand-${i}`]:!0},role:"presentation"},n("slot",{key:"bdd9f419fc6e20f5de6f0f52ac93af7ec9a380ef"}))}get el(){return a(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{x as ion_accordion,m as ion_accordion_group}