@m3e/web 2.1.3 → 2.2.1

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.
Files changed (210) hide show
  1. package/README.md +5 -2
  2. package/dist/all.js +2916 -391
  3. package/dist/all.js.map +1 -1
  4. package/dist/all.min.js +77 -41
  5. package/dist/all.min.js.map +1 -1
  6. package/dist/app-bar.js +14 -7
  7. package/dist/app-bar.js.map +1 -1
  8. package/dist/app-bar.min.js +1 -1
  9. package/dist/app-bar.min.js.map +1 -1
  10. package/dist/autocomplete.js +59 -23
  11. package/dist/autocomplete.js.map +1 -1
  12. package/dist/autocomplete.min.js +1 -1
  13. package/dist/autocomplete.min.js.map +1 -1
  14. package/dist/bottom-sheet.js +8 -27
  15. package/dist/bottom-sheet.js.map +1 -1
  16. package/dist/bottom-sheet.min.js +1 -1
  17. package/dist/bottom-sheet.min.js.map +1 -1
  18. package/dist/calendar.js +1082 -0
  19. package/dist/calendar.js.map +1 -0
  20. package/dist/calendar.min.js +43 -0
  21. package/dist/calendar.min.js.map +1 -0
  22. package/dist/chips.js +2 -6
  23. package/dist/chips.js.map +1 -1
  24. package/dist/chips.min.js +1 -1
  25. package/dist/chips.min.js.map +1 -1
  26. package/dist/core-a11y.js +23 -9
  27. package/dist/core-a11y.js.map +1 -1
  28. package/dist/core-a11y.min.js +4 -4
  29. package/dist/core-a11y.min.js.map +1 -1
  30. package/dist/core-anchoring.js +135 -15
  31. package/dist/core-anchoring.js.map +1 -1
  32. package/dist/core-anchoring.min.js +1 -1
  33. package/dist/core-anchoring.min.js.map +1 -1
  34. package/dist/core.js +101 -1
  35. package/dist/core.js.map +1 -1
  36. package/dist/core.min.js +1 -1
  37. package/dist/core.min.js.map +1 -1
  38. package/dist/css-custom-data.json +1146 -646
  39. package/dist/custom-elements.json +31433 -26898
  40. package/dist/datepicker.js +573 -0
  41. package/dist/datepicker.js.map +1 -0
  42. package/dist/datepicker.min.js +7 -0
  43. package/dist/datepicker.min.js.map +1 -0
  44. package/dist/drawer-container.js +10 -4
  45. package/dist/drawer-container.js.map +1 -1
  46. package/dist/drawer-container.min.js +1 -1
  47. package/dist/drawer-container.min.js.map +1 -1
  48. package/dist/fab-menu.js +1 -1
  49. package/dist/fab-menu.js.map +1 -1
  50. package/dist/fab-menu.min.js +1 -1
  51. package/dist/fab-menu.min.js.map +1 -1
  52. package/dist/form-field.js +2 -6
  53. package/dist/form-field.js.map +1 -1
  54. package/dist/form-field.min.js +3 -3
  55. package/dist/form-field.min.js.map +1 -1
  56. package/dist/html-custom-data.json +553 -187
  57. package/dist/menu.js +3 -7
  58. package/dist/menu.js.map +1 -1
  59. package/dist/menu.min.js +1 -1
  60. package/dist/menu.min.js.map +1 -1
  61. package/dist/nav-bar.js +17 -7
  62. package/dist/nav-bar.js.map +1 -1
  63. package/dist/nav-bar.min.js +1 -1
  64. package/dist/nav-bar.min.js.map +1 -1
  65. package/dist/nav-menu.js +3 -11
  66. package/dist/nav-menu.js.map +1 -1
  67. package/dist/nav-menu.min.js +1 -1
  68. package/dist/nav-menu.min.js.map +1 -1
  69. package/dist/nav-rail.js +2 -6
  70. package/dist/nav-rail.js.map +1 -1
  71. package/dist/nav-rail.min.js +1 -1
  72. package/dist/nav-rail.min.js.map +1 -1
  73. package/dist/option.js +4 -8
  74. package/dist/option.js.map +1 -1
  75. package/dist/option.min.js +1 -1
  76. package/dist/option.min.js.map +1 -1
  77. package/dist/paginator.js.map +1 -1
  78. package/dist/paginator.min.js.map +1 -1
  79. package/dist/search.js +821 -0
  80. package/dist/search.js.map +1 -0
  81. package/dist/search.min.js +7 -0
  82. package/dist/search.min.js.map +1 -0
  83. package/dist/segmented-button.js +2 -2
  84. package/dist/segmented-button.js.map +1 -1
  85. package/dist/segmented-button.min.js.map +1 -1
  86. package/dist/select.js +4 -15
  87. package/dist/select.js.map +1 -1
  88. package/dist/select.min.js +1 -1
  89. package/dist/select.min.js.map +1 -1
  90. package/dist/snackbar.js +2 -6
  91. package/dist/snackbar.js.map +1 -1
  92. package/dist/snackbar.min.js +1 -1
  93. package/dist/snackbar.min.js.map +1 -1
  94. package/dist/split-button.js +1 -1
  95. package/dist/split-button.js.map +1 -1
  96. package/dist/split-button.min.js.map +1 -1
  97. package/dist/src/all.d.ts +3 -0
  98. package/dist/src/all.d.ts.map +1 -1
  99. package/dist/src/app-bar/AppBarElement.d.ts +6 -4
  100. package/dist/src/app-bar/AppBarElement.d.ts.map +1 -1
  101. package/dist/src/autocomplete/AutocompleteElement.d.ts +7 -2
  102. package/dist/src/autocomplete/AutocompleteElement.d.ts.map +1 -1
  103. package/dist/src/autocomplete/AutocompleteQueryEventDetail.d.ts +12 -0
  104. package/dist/src/autocomplete/AutocompleteQueryEventDetail.d.ts.map +1 -0
  105. package/dist/src/autocomplete/QueryEventDetail.d.ts +3 -8
  106. package/dist/src/autocomplete/QueryEventDetail.d.ts.map +1 -1
  107. package/dist/src/autocomplete/index.d.ts +1 -0
  108. package/dist/src/autocomplete/index.d.ts.map +1 -1
  109. package/dist/src/bottom-sheet/BottomSheetElement.d.ts.map +1 -1
  110. package/dist/src/calendar/CalendarElement.d.ts +213 -0
  111. package/dist/src/calendar/CalendarElement.d.ts.map +1 -0
  112. package/dist/src/calendar/CalendarView.d.ts +3 -0
  113. package/dist/src/calendar/CalendarView.d.ts.map +1 -0
  114. package/dist/src/calendar/CalendarViewElementBase.d.ts +28 -0
  115. package/dist/src/calendar/CalendarViewElementBase.d.ts.map +1 -0
  116. package/dist/src/calendar/MonthViewElement.d.ts +36 -0
  117. package/dist/src/calendar/MonthViewElement.d.ts.map +1 -0
  118. package/dist/src/calendar/MultiYearViewElement.d.ts +27 -0
  119. package/dist/src/calendar/MultiYearViewElement.d.ts.map +1 -0
  120. package/dist/src/calendar/YearViewElement.d.ts +27 -0
  121. package/dist/src/calendar/YearViewElement.d.ts.map +1 -0
  122. package/dist/src/calendar/index.d.ts +7 -0
  123. package/dist/src/calendar/index.d.ts.map +1 -0
  124. package/dist/src/calendar/utils.d.ts +24 -0
  125. package/dist/src/calendar/utils.d.ts.map +1 -0
  126. package/dist/src/chips/InputChipSetElement.d.ts.map +1 -1
  127. package/dist/src/core/a11y/FocusTrapElement.d.ts.map +1 -1
  128. package/dist/src/core/a11y/InteractivityChecker.d.ts.map +1 -1
  129. package/dist/src/core/anchoring/AnchorOptions.d.ts +1 -1
  130. package/dist/src/core/anchoring/AnchorOptions.d.ts.map +1 -1
  131. package/dist/src/core/anchoring/FloatingPanelElement.d.ts +18 -3
  132. package/dist/src/core/anchoring/FloatingPanelElement.d.ts.map +1 -1
  133. package/dist/src/core/anchoring/positionAnchor.d.ts.map +1 -1
  134. package/dist/src/core/shared/controllers/InertController.d.ts +19 -0
  135. package/dist/src/core/shared/controllers/InertController.d.ts.map +1 -0
  136. package/dist/src/core/shared/controllers/index.d.ts +1 -0
  137. package/dist/src/core/shared/controllers/index.d.ts.map +1 -1
  138. package/dist/src/core/shared/converters/dateConverter.d.ts +4 -0
  139. package/dist/src/core/shared/converters/dateConverter.d.ts.map +1 -0
  140. package/dist/src/core/shared/converters/index.d.ts +1 -0
  141. package/dist/src/core/shared/converters/index.d.ts.map +1 -1
  142. package/dist/src/core/shared/utils/index.d.ts +1 -0
  143. package/dist/src/core/shared/utils/index.d.ts.map +1 -1
  144. package/dist/src/core/shared/utils/registerStyleSheet.d.ts +7 -0
  145. package/dist/src/core/shared/utils/registerStyleSheet.d.ts.map +1 -0
  146. package/dist/src/datepicker/DatepickerElement.d.ts +239 -0
  147. package/dist/src/datepicker/DatepickerElement.d.ts.map +1 -0
  148. package/dist/src/datepicker/DatepickerToggleElement.d.ts +21 -0
  149. package/dist/src/datepicker/DatepickerToggleElement.d.ts.map +1 -0
  150. package/dist/src/datepicker/DatepickerVariant.d.ts +3 -0
  151. package/dist/src/datepicker/DatepickerVariant.d.ts.map +1 -0
  152. package/dist/src/datepicker/index.d.ts +4 -0
  153. package/dist/src/datepicker/index.d.ts.map +1 -0
  154. package/dist/src/drawer-container/DrawerContainerElement.d.ts +2 -2
  155. package/dist/src/drawer-container/DrawerContainerElement.d.ts.map +1 -1
  156. package/dist/src/form-field/FormFieldElement.d.ts.map +1 -1
  157. package/dist/src/menu/MenuElement.d.ts.map +1 -1
  158. package/dist/src/nav-bar/NavBarElement.d.ts +3 -1
  159. package/dist/src/nav-bar/NavBarElement.d.ts.map +1 -1
  160. package/dist/src/nav-menu/NavMenuElement.d.ts.map +1 -1
  161. package/dist/src/nav-menu/NavMenuItemElement.d.ts.map +1 -1
  162. package/dist/src/nav-rail/NavRailElement.d.ts.map +1 -1
  163. package/dist/src/option/OptionPanelElement.d.ts.map +1 -1
  164. package/dist/src/paginator/PageEventDetail.d.ts +6 -11
  165. package/dist/src/paginator/PageEventDetail.d.ts.map +1 -1
  166. package/dist/src/paginator/PaginatorElement.d.ts +2 -2
  167. package/dist/src/paginator/PaginatorElement.d.ts.map +1 -1
  168. package/dist/src/paginator/PaginatorPageEventDetail.d.ts +12 -0
  169. package/dist/src/paginator/PaginatorPageEventDetail.d.ts.map +1 -0
  170. package/dist/src/paginator/index.d.ts +1 -0
  171. package/dist/src/paginator/index.d.ts.map +1 -1
  172. package/dist/src/search/SearchBarElement.d.ts +92 -0
  173. package/dist/src/search/SearchBarElement.d.ts.map +1 -0
  174. package/dist/src/search/SearchViewElement.d.ts +150 -0
  175. package/dist/src/search/SearchViewElement.d.ts.map +1 -0
  176. package/dist/src/search/SearchViewMode.d.ts +3 -0
  177. package/dist/src/search/SearchViewMode.d.ts.map +1 -0
  178. package/dist/src/search/SearchViewQueryEventDetail.d.ts +12 -0
  179. package/dist/src/search/SearchViewQueryEventDetail.d.ts.map +1 -0
  180. package/dist/src/search/index.d.ts +5 -0
  181. package/dist/src/search/index.d.ts.map +1 -0
  182. package/dist/src/search/styles/SearchBarStyle.d.ts +12 -0
  183. package/dist/src/search/styles/SearchBarStyle.d.ts.map +1 -0
  184. package/dist/src/search/styles/SearchBarToken.d.ts +27 -0
  185. package/dist/src/search/styles/SearchBarToken.d.ts.map +1 -0
  186. package/dist/src/search/styles/SearchViewStyle.d.ts +12 -0
  187. package/dist/src/search/styles/SearchViewStyle.d.ts.map +1 -0
  188. package/dist/src/search/styles/SearchViewToken.d.ts +26 -0
  189. package/dist/src/search/styles/SearchViewToken.d.ts.map +1 -0
  190. package/dist/src/search/styles/index.d.ts +3 -0
  191. package/dist/src/search/styles/index.d.ts.map +1 -0
  192. package/dist/src/segmented-button/ButtonSegmentElement.d.ts +2 -2
  193. package/dist/src/select/SelectElement.d.ts.map +1 -1
  194. package/dist/src/snackbar/SnackbarElement.d.ts.map +1 -1
  195. package/dist/src/split-button/SplitButtonElement.d.ts +1 -1
  196. package/dist/src/stepper/StepperElement.d.ts +3 -1
  197. package/dist/src/stepper/StepperElement.d.ts.map +1 -1
  198. package/dist/src/switch/SwitchElement.d.ts +2 -2
  199. package/dist/stepper.js +18 -12
  200. package/dist/stepper.js.map +1 -1
  201. package/dist/stepper.min.js +1 -1
  202. package/dist/stepper.min.js.map +1 -1
  203. package/dist/switch.js +2 -2
  204. package/dist/switch.js.map +1 -1
  205. package/dist/switch.min.js.map +1 -1
  206. package/dist/tooltip.js +1 -1
  207. package/dist/tooltip.js.map +1 -1
  208. package/dist/tooltip.min.js +1 -1
  209. package/dist/tooltip.min.js.map +1 -1
  210. package/package.json +16 -1
@@ -3,5 +3,5 @@
3
3
  * Copyright (c) 2025 matraic
4
4
  * See LICENSE file in the project root for full license text.
5
5
  */
6
- import{__classPrivateFieldGet as t,__classPrivateFieldSet as e,__decorate as i}from"tslib";import{LitElement as s,html as a,css as n}from"lit";import{property as h}from"lit/decorators.js";import{HtmlFor as o,MutationController as l,setCustomState as r,deleteCustomState as c,prefersReducedMotion as d,scrollIntoViewIfNeeded as f,forcedColorsActive as u,addCustomState as m,customElement as p}from"@m3e/web/core";import{ListKeyManager as v,M3eLiveAnnouncer as g}from"@m3e/web/core/a11y";import{M3eOptGroupElement as b}from"@m3e/web/option";var y,w,L,M,E,k,A,C,S,_,K,W,I,D,q,x,N,P,T,B,U,O,$,H,R,j,F,V,X,z,G,J,Q,Y,Z,tt,et,it,st,at,nt,ht,ot,lt,rt,ct,dt,ft,ut,mt;let pt=mt=class extends(o(s)){constructor(){super(),y.add(this),w.set(this,`m3e-autocomplete-${mt.__nextId}`),L.set(this,`${t(this,w,"f")}-menu`),this._options=new Array,M.set(this,void 0),E.set(this,!1),k.set(this,void 0),A.set(this,!1),C.set(this,!1),S.set(this,!1),_.set(this,void 0),K.set(this,()=>t(this,y,"m",V).call(this)),W.set(this,()=>t(this,y,"m",X).call(this)),I.set(this,()=>t(this,y,"m",z).call(this)),D.set(this,()=>t(this,y,"m",G).call(this)),q.set(this,e=>t(this,y,"m",Y).call(this,e)),x.set(this,e=>t(this,y,"m",J).call(this,e)),N.set(this,()=>t(this,y,"m",Q).call(this)),P.set(this,e=>t(this,y,"m",tt).call(this,e)),T.set(this,e=>t(this,y,"m",Z).call(this,e)),this._listKeyManager=(new v).withWrap().withHomeAndEnd().withPageUpAndDown().withVerticalOrientation().withSkipPredicate(t=>t.disabled||t.hidden).onActiveItemChange(()=>{this._listKeyManager.activeItem&&t(this,y,"m",ht).call(this,this._listKeyManager.activeItem)}),this.hideSelectionIndicator=!1,this.required=!1,this.autoActivate=!1,this.caseSensitive=!1,this.filter="contains",this.loading=!1,this.hideNoData=!1,this.hideLoading=!1,this.loadingLabel="Loading...",this.noDataLabel="No options",this.resultsLabel=t=>`${t} options`,this.panelClass="",new l(this,{config:{childList:!0,subtree:!0},callback:()=>t(this,y,"m",F).call(this)})}get options(){return this._options??[]}attach(e){e instanceof HTMLInputElement&&(super.attach(e),e.autocomplete="off",e.role="combobox",e.ariaAutoComplete="list",e.ariaExpanded="false",e.addEventListener("click",t(this,K,"f")),e.addEventListener("focus",t(this,I,"f")),e.addEventListener("blur",t(this,D,"f")),e.addEventListener("keydown",t(this,q,"f")),e.addEventListener("input",t(this,x,"f")),e.addEventListener("change",t(this,N,"f")),t(this,y,"a",j)?.addEventListener("pointerdown",t(this,W,"f")))}detach(){this.control&&(t(this,y,"a",j)?.removeEventListener("pointerdown",t(this,W,"f")),this.control.role=null,this.control.ariaAutoComplete=null,this.control.ariaExpanded=null,this.control.removeEventListener("click",t(this,K,"f")),this.control.removeEventListener("focus",t(this,I,"f")),this.control.removeEventListener("blur",t(this,D,"f")),this.control.removeEventListener("keydown",t(this,q,"f")),this.control.removeEventListener("input",t(this,x,"f")),this.control.removeEventListener("change",t(this,N,"f"))),super.detach()}clear(e=!1){t(this,y,"a",U)&&(t(this,y,"a",U).value="",t(this,y,"m",ct).call(this),e?t(this,y,"a",U).focus():t(this,y,"m",nt).call(this))}connectedCallback(){super.connectedCallback(),t(this,y,"m",F).call(this)}update(e){super.update(e),e.has("hideNoData")&&this.hideNoData&&t(this,k,"f")&&r(t(this,k,"f"),"-no-data",!1),e.has("loading")&&(this.loading?t(this,S,"f")&&(this.loadingLabel&&g.announce(this.loadingLabel,"polite"),!t(this,k,"f")&&t(this,y,"a",H)&&t(this,y,"m",it).call(this)):t(this,k,"f")&&!t(this,y,"a",H)?t(this,y,"m",nt).call(this):t(this,k,"f")?c(t(this,k,"f"),"-loading"):t(this,S,"f")&&t(this,y,"m",it).call(this))}render(){return a`<div class="options" aria-hidden="true"><slot></slot></div>`}};w=new WeakMap,L=new WeakMap,M=new WeakMap,E=new WeakMap,k=new WeakMap,A=new WeakMap,C=new WeakMap,S=new WeakMap,_=new WeakMap,K=new WeakMap,W=new WeakMap,I=new WeakMap,D=new WeakMap,q=new WeakMap,x=new WeakMap,N=new WeakMap,P=new WeakMap,T=new WeakMap,y=new WeakSet,B=function(){return this._listKeyManager?.items??[]},U=function(){return this.control?this.control:null},O=function(){return null!==(t(this,M,"f")?.querySelector("[slot='no-data']")??null)},$=function(){return null!==(t(this,M,"f")?.querySelector("[slot='loading']")??null)},H=function(){return t(this,y,"a",B).some(t=>!t.hidden)||this.loading&&!this.hideLoading&&this.loadingLabel.length>0||!this.loading&&!this.hideNoData&&this.noDataLabel.length>0},R=function(){const e=t(this,y,"a",j);return`${e?e.menuAnchor.clientWidth:this.control?.clientWidth??0}px`},j=function(){return this.control?.closest("m3e-form-field")??null},F=async function(){t(this,_,"f")&&t(this,_,"f").abort();const i=new AbortController;e(this,_,i,"f");const s=[...this.querySelectorAll("m3e-option")];for(const t of s){if(i.signal.aborted)break;t.isUpdatePending&&await t.updateComplete}if(i.signal.aborted)return;this._options=s,e(this,M,this.cloneNode(!0),"f");const{added:a}=this._listKeyManager.setItems([...t(this,M,"f").querySelectorAll("m3e-option")]);if(a.forEach(e=>{e.id=e.id||`${t(this,w,"f")}-option-${this._listKeyManager.items.indexOf(e)}`,r(e,"-hide-selection-indicator",this.hideSelectionIndicator)}),t(this,k,"f")){const e=t(this,y,"m",ct).call(this);t(this,y,"m",st).call(this),t(this,y,"a",H)?t(this,y,"m",at).call(this,t(this,k,"f"),e):t(this,y,"m",nt).call(this)}},V=function(){e(this,E,!0,"f"),t(this,y,"m",it).call(this)},X=function(){e(this,A,!0,"f")},z=function(){e(this,S,!0,"f"),e(this,E,!0,"f"),0!=this.options.length||this.control.readOnly||this.dispatchEvent(new CustomEvent("query",{detail:{term:t(this,y,"a",U)?.value??""},bubbles:!0,composed:!0})),t(this,y,"m",it).call(this)},G=function(){e(this,S,!1,"f"),t(this,A,"f")||t(this,y,"m",nt).call(this),e(this,A,!1,"f")},J=function(i){if(t(this,y,"a",U)&&!i.defaultPrevented){this.dispatchEvent(new CustomEvent("query",{detail:{term:t(this,y,"a",U).value},bubbles:!0,composed:!0})),e(this,C,!0,"f");try{t(this,k,"f")?(t(this,y,"m",ct).call(this),t(this,y,"a",H)||t(this,y,"m",nt).call(this)):t(this,y,"m",it).call(this)}finally{e(this,C,!1,"f"),t(this,y,"a",j)?.notifyControlStateChange(!0)}}},Q=function(){t(this,y,"a",U)&&this.required&&!t(this,y,"a",B).some(t=>t.selected&&!t.disabled)&&(t(this,y,"a",U).value="")},Y=function(i){if(!i.defaultPrevented)switch(e(this,E,!1,"f"),i.key){case"Backspace":case"Delete":t(this,y,"a",U)&&!t(this,y,"a",U).value&&t(this,y,"m",nt).call(this);break;case"Enter":t(this,k,"f")&&this._listKeyManager.activeItem?(i.preventDefault(),t(this,y,"m",lt).call(this,this._listKeyManager.activeItem),d()?t(this,y,"m",nt).call(this):setTimeout(()=>t(this,y,"m",nt).call(this),150)):t(this,k,"f")&&setTimeout(()=>{t(this,y,"a",U)&&!t(this,y,"a",U).value&&t(this,y,"m",nt).call(this)});break;case"Escape":case"Tab":t(this,y,"m",nt).call(this);break;case"Up":case"ArrowUp":i.altKey?t(this,y,"m",nt).call(this):this._listKeyManager.onKeyDown(i);break;case"Down":case"ArrowDown":t(this,k,"f")?this._listKeyManager.onKeyDown(i):(t(this,y,"m",it).call(this),i.preventDefault());break;default:this._listKeyManager.onKeyDown(i)}},Z=function(e){if(2===e.button)return;e.preventDefault(),e.stopImmediatePropagation();const i=e.composedPath().find(t=>t instanceof HTMLElement&&"M3E-OPTION"===t.tagName);i&&!i.disabled&&(this._listKeyManager.setActiveItem(i),t(this,y,"m",lt).call(this,i),d()?t(this,y,"m",nt).call(this):setTimeout(()=>t(this,y,"m",nt).call(this),150))},tt=function(e){if(t(this,k,"f"))if("closed"!==e.newState){const i=t(this,y,"a",B).find(t=>t.selected&&!t.disabled);i?(this._listKeyManager.setActiveItem(i),f(i,t(this,k,"f"))):t(this,y,"m",ft).call(this),this.dispatchEvent(new ToggleEvent("toggle",{oldState:e.oldState,newState:e.newState}))}else d()?t(this,y,"m",et).call(this,e):setTimeout(()=>t(this,y,"m",et).call(this,e),100)},et=function(i){t(this,k,"f")&&(t(this,M,"f")?.replaceChildren(...t(this,k,"f").childNodes),t(this,k,"f").remove(),t(this,k,"f").removeEventListener("toggle",t(this,P,"f")),t(this,k,"f").removeEventListener("pointerdown",t(this,T,"f")),e(this,k,void 0,"f"),t(this,y,"a",U)&&(t(this,y,"a",U).ariaExpanded="false",t(this,y,"a",U).removeAttribute("aria-controls"),t(this,y,"a",U).removeAttribute("aria-owns")),this.requestUpdate(),t(this,y,"a",j)?.notifyControlStateChange(),this.dispatchEvent(new ToggleEvent("toggle",{oldState:i.oldState,newState:i.newState})))},it=function(){if(t(this,k,"f")||!t(this,y,"a",U)||t(this,y,"a",U).readOnly||t(this,y,"a",U).disabled)return;const i=t(this,y,"m",ct).call(this);if(!t(this,y,"a",H))return;if(e(this,k,document.createElement("m3e-option-panel"),"f"),t(this,k,"f").id=t(this,L,"f"),this.panelClass)for(const e of this.panelClass.split(/\s+/).map(t=>t.trim()).filter(Boolean))t(this,k,"f").classList.add(e);t(this,k,"f").scrollStrategy="reposition",t(this,k,"f").style.overflowX="hidden",t(this,k,"f").style.minWidth=t(this,y,"a",R),t(this,k,"f").addEventListener("toggle",t(this,P,"f")),t(this,k,"f").addEventListener("pointerdown",t(this,T,"f")),t(this,y,"m",st).call(this),t(this,y,"m",at).call(this,t(this,k,"f"),i),(t(this,y,"a",j)??t(this,y,"a",U)).insertAdjacentElement("afterend",t(this,k,"f")),t(this,y,"a",U).setAttribute("aria-controls",t(this,L,"f")),t(this,y,"a",U).setAttribute("aria-owns",t(this,L,"f")),t(this,y,"a",j)?.notifyControlStateChange(),this._listKeyManager.activeItem&&this.autoActivate&&t(this,y,"m",ht).call(this,this._listKeyManager.activeItem,!0);const s=t(this,y,"a",U);setTimeout(()=>t(this,k,"f")?.show(s,t(this,y,"a",j)?.menuAnchor))},st=function(){if(!t(this,M,"f")||!t(this,k,"f"))return;const e=[...t(this,M,"f").childNodes];if(!t(this,y,"a",O)&&this.noDataLabel){const t=document.createElement("span");t.slot="no-data",t.textContent=this.noDataLabel,e.push(t)}if(!t(this,y,"a",$)&&this.loadingLabel){const t=document.createElement("span");t.slot="loading",t.textContent=this.loadingLabel,e.push(t)}t(this,k,"f").replaceChildren(...e)},at=function(t,e){r(t,"-loading",this.loading),r(t,"-no-data",0==e)},nt=function(){t(this,k,"f")?.hide(),t(this,y,"a",U)?.removeAttribute("aria-activedescendant")},ht=function(e,i=!1){if(t(this,y,"a",U)&&(t(this,y,"a",U).setAttribute("aria-activedescendant",e.id),t(this,k,"f"))){f(e,t(this,k,"f"),{block:"nearest",behavior:"instant"});const s=i||!t(this,E,"f")&&(t(this,y,"a",U).matches(":focus-visible")||u());t(this,y,"a",B).forEach(t=>{t===e&&s?(t.focusRing?.show(),t.stateLayer?.show("focused")):(t.focusRing?.hide(),t.stateLayer?.hide("focused"))})}},ot=async function(t){const e=this._options[this._listKeyManager.items.indexOf(t)];e&&(e.selected=t.selected,e.isUpdatePending&&await e.updateComplete)},lt=async function(e){e.selected||(e.selected=!0,await t(this,y,"m",ot).call(this,e),e.isUpdatePending&&await e.updateComplete,this.requestUpdate(),this.isUpdatePending&&await this.updateComplete,t(this,y,"a",U)&&(t(this,y,"a",U).value=e.value),t(this,y,"a",j)?.notifyControlStateChange(!0))},rt=function(t,e,i,s){const a=this.caseSensitive?e.value:e.value.toLowerCase();switch(this.filter){case"starts-with":return t.term=s,t.highlightMode=this.filter,a.startsWith(i);case"ends-with":return t.term=s,t.highlightMode=this.filter,a.endsWith(i);case"contains":return t.term=s,t.highlightMode=this.filter,a.includes(i);case"none":return t.disableHighlight=!0,!0;default:return t.disableHighlight=!0,this.filter(e,s)}},ct=function(){if(!t(this,y,"a",U))return 0;const i=t(this,y,"a",B).filter(t=>!t.hidden).length,s=!this.loading&&t(this,C,"f");e(this,C,!1,"f");const a=t(this,y,"a",U).value,n=this.caseSensitive?a:a.toLocaleLowerCase();let h,o=0,l=!1;for(let e=0;e<t(this,y,"a",B).length;e++){const i=t(this,y,"a",B)[e],s=this._options[e];i.hidden=!t(this,y,"m",rt).call(this,i,s,n,a),i.hidden?(t(this,y,"m",ut).call(this,i),c(i,"-first"),c(i,"-last")):(o++,l||i.parentElement instanceof b?(c(i,"-first"),h&&c(h,"-last"),m(i,"-last"),h=i):(m(i,"-first"),l=!0,m(i,"-last"),h=i)),i.selected&&s.value!==a&&(i.selected=!1,t(this,y,"m",ot).call(this,i))}t(this,k,"f")&&t(this,y,"m",at).call(this,t(this,k,"f"),o);const r=t(this,k,"f")?.querySelectorAll("m3e-optgroup")??t(this,M,"f")?.querySelectorAll("m3e-optgroup")??[];for(const t of r)t.hidden=[...t.querySelectorAll("m3e-option")].every(t=>t.hidden);return s&&t(this,y,"m",dt).call(this,i,o),t(this,y,"m",ft).call(this),o},dt=function(e,i){if(t(this,S,"f"))if(0==i)e>0&&this.noDataLabel&&g.announce(this.noDataLabel,"polite");else if(e!=i){const t=this.resultsLabel instanceof Function?this.resultsLabel(i):this.resultsLabel;t&&g.announce(t,"polite")}},ft=function(){if(this.autoActivate&&(!this._listKeyManager.activeItem||!this._listKeyManager.activeItem.selected)){const e=t(this,y,"a",B).find(t=>!t.disabled&&!t.hidden);e&&(this._listKeyManager.setActiveItem(e),t(this,k,"f")&&f(e,t(this,k,"f"),{block:"nearest",behavior:"instant"}))}},ut=function(e){e.focusRing?.hide(),e.stateLayer?.hide("focused"),e===this._listKeyManager.activeItem&&(this._listKeyManager.updateActiveItem(null),t(this,y,"a",U)?.removeAttribute("aria-activedescendant"))},pt.styles=n`:host { display: contents; } .options { display: none; }`,pt.__nextId=0,i([h({attribute:"hide-selection-indicator",type:Boolean})],pt.prototype,"hideSelectionIndicator",void 0),i([h({type:Boolean,reflect:!0})],pt.prototype,"required",void 0),i([h({attribute:"auto-activate",type:Boolean})],pt.prototype,"autoActivate",void 0),i([h({attribute:"case-sensitive",type:Boolean})],pt.prototype,"caseSensitive",void 0),i([h({converter:{fromAttribute:t=>null===t?"contains":"starts-with"===t||"ends-with"===t||"contains"===t||"none"===t?t:"contains"}})],pt.prototype,"filter",void 0),i([h({type:Boolean})],pt.prototype,"loading",void 0),i([h({attribute:"hide-no-data",type:Boolean})],pt.prototype,"hideNoData",void 0),i([h({attribute:"hide-loading",type:Boolean})],pt.prototype,"hideLoading",void 0),i([h({attribute:"loading-label"})],pt.prototype,"loadingLabel",void 0),i([h({attribute:"no-data-label"})],pt.prototype,"noDataLabel",void 0),i([h({attribute:"results-label"})],pt.prototype,"resultsLabel",void 0),i([h({attribute:"panel-class"})],pt.prototype,"panelClass",void 0),pt=mt=i([p("m3e-autocomplete")],pt);export{pt as M3eAutocompleteElement};
6
+ import{__classPrivateFieldGet as t,__classPrivateFieldSet as e,__decorate as i}from"tslib";import{LitElement as s,html as a,css as n}from"lit";import{property as h}from"lit/decorators.js";import{EventAttribute as o,HtmlFor as l,MutationController as r,setCustomState as c,deleteCustomState as d,prefersReducedMotion as f,scrollIntoViewIfNeeded as u,forcedColorsActive as m,addCustomState as p,customElement as v}from"@m3e/web/core";import{ListKeyManager as g,M3eLiveAnnouncer as b}from"@m3e/web/core/a11y";import{M3eOptGroupElement as y}from"@m3e/web/option";var w,E,L,M,k,A,C,S,_,K,I,W,D,q,N,P,T,x,U,B,O,H,$,R,j,F,V,X,z,G,J,Q,Y,Z,tt,et,it,st,at,nt,ht,ot,lt,rt,ct,dt,ft,ut,mt,pt;let vt=pt=class extends(o(l(s),"query")){constructor(){super(),w.add(this),E.set(this,`m3e-autocomplete-${pt.__nextId}`),L.set(this,`${t(this,E,"f")}-menu`),this._options=new Array,M.set(this,void 0),k.set(this,!1),A.set(this,void 0),C.set(this,!1),S.set(this,!1),_.set(this,!1),K.set(this,void 0),I.set(this,()=>t(this,w,"m",V).call(this)),W.set(this,()=>t(this,w,"m",X).call(this)),D.set(this,()=>t(this,w,"m",z).call(this)),q.set(this,()=>t(this,w,"m",G).call(this)),N.set(this,e=>t(this,w,"m",Y).call(this,e)),P.set(this,e=>t(this,w,"m",J).call(this,e)),T.set(this,()=>t(this,w,"m",Q).call(this)),x.set(this,e=>t(this,w,"m",tt).call(this,e)),U.set(this,e=>t(this,w,"m",Z).call(this,e)),this._listKeyManager=(new g).withWrap().withHomeAndEnd().withPageUpAndDown().withVerticalOrientation().withSkipPredicate(t=>t.disabled||!0===t.hidden).onActiveItemChange(()=>{this._listKeyManager.activeItem&&t(this,w,"m",ht).call(this,this._listKeyManager.activeItem)}),this.hideSelectionIndicator=!1,this.required=!1,this.autoActivate=!1,this.caseSensitive=!1,this.filter="contains",this.loading=!1,this.hideNoData=!1,this.hideLoading=!1,this.loadingLabel="Loading...",this.noDataLabel="No options",this.resultsLabel=t=>`${t} options`,this.panelClass="",new r(this,{config:{childList:!0,subtree:!0},callback:()=>t(this,w,"m",F).call(this)})}get options(){return this._options??[]}get selected(){return this.options.find(t=>t.selected)??null}get value(){const t=this.selected;return t&&!t.disabled?t.value:null}attach(e){e instanceof HTMLInputElement&&(super.attach(e),e.autocomplete="off",e.role="combobox",e.ariaAutoComplete="list",e.ariaExpanded="false",e.addEventListener("click",t(this,I,"f")),e.addEventListener("focus",t(this,D,"f")),e.addEventListener("blur",t(this,q,"f")),e.addEventListener("keydown",t(this,N,"f")),e.addEventListener("input",t(this,P,"f")),e.addEventListener("change",t(this,T,"f")),t(this,w,"a",j)?.addEventListener("pointerdown",t(this,W,"f")))}detach(){this.control&&(t(this,w,"a",j)?.removeEventListener("pointerdown",t(this,W,"f")),this.control.role=null,this.control.ariaAutoComplete=null,this.control.ariaExpanded=null,this.control.removeEventListener("click",t(this,I,"f")),this.control.removeEventListener("focus",t(this,D,"f")),this.control.removeEventListener("blur",t(this,q,"f")),this.control.removeEventListener("keydown",t(this,N,"f")),this.control.removeEventListener("input",t(this,P,"f")),this.control.removeEventListener("change",t(this,T,"f"))),super.detach()}clear(e=!1){t(this,w,"a",O)&&(t(this,w,"a",O).value="",t(this,w,"m",dt).call(this)&&this.dispatchEvent(new Event("change",{bubbles:!0})),t(this,w,"m",ct).call(this),e?t(this,w,"a",O).focus():t(this,w,"m",nt).call(this))}connectedCallback(){super.connectedCallback(),t(this,w,"m",F).call(this)}update(e){super.update(e),e.has("hideNoData")&&this.hideNoData&&t(this,A,"f")&&c(t(this,A,"f"),"-no-data",!1),e.has("loading")&&(this.loading?t(this,_,"f")&&(this.loadingLabel&&b.announce(this.loadingLabel,"polite"),!t(this,A,"f")&&t(this,w,"a",R)&&t(this,w,"m",it).call(this)):t(this,A,"f")&&!t(this,w,"a",R)?t(this,w,"m",nt).call(this):t(this,A,"f")?d(t(this,A,"f"),"-loading"):t(this,_,"f")&&t(this,w,"m",it).call(this))}render(){return a`<div class="options" aria-hidden="true"><slot></slot></div>`}};E=new WeakMap,L=new WeakMap,M=new WeakMap,k=new WeakMap,A=new WeakMap,C=new WeakMap,S=new WeakMap,_=new WeakMap,K=new WeakMap,I=new WeakMap,W=new WeakMap,D=new WeakMap,q=new WeakMap,N=new WeakMap,P=new WeakMap,T=new WeakMap,x=new WeakMap,U=new WeakMap,w=new WeakSet,B=function(){return this._listKeyManager?.items??[]},O=function(){return this.control?this.control:null},H=function(){return null!==(t(this,M,"f")?.querySelector("[slot='no-data']")??null)},$=function(){return null!==(t(this,M,"f")?.querySelector("[slot='loading']")??null)},R=function(){return t(this,w,"a",B).some(t=>!1===t.hidden)||this.loading&&!this.hideLoading&&this.loadingLabel.length>0||!this.loading&&!this.hideNoData&&this.noDataLabel.length>0},j=function(){return this.control?.closest("m3e-form-field")??null},F=async function(){t(this,K,"f")&&t(this,K,"f").abort();const i=new AbortController;e(this,K,i,"f");const s=[...this.querySelectorAll("m3e-option")];for(const t of s){if(i.signal.aborted)break;t.isUpdatePending&&await t.updateComplete}if(i.signal.aborted)return;this._options=s,e(this,M,this.cloneNode(!0),"f");const{added:a}=this._listKeyManager.setItems([...t(this,M,"f").querySelectorAll("m3e-option")]);if(a.forEach(e=>{e.id=e.id||`${t(this,E,"f")}-option-${this._listKeyManager.items.indexOf(e)}`,c(e,"-hide-selection-indicator",this.hideSelectionIndicator)}),t(this,A,"f")){const e=t(this,w,"m",ct).call(this);t(this,w,"m",st).call(this),t(this,w,"a",R)?t(this,w,"m",at).call(this,t(this,A,"f"),e):t(this,w,"m",nt).call(this)}},V=function(){e(this,k,!0,"f"),t(this,w,"m",it).call(this)},X=function(){e(this,C,!0,"f")},z=function(){e(this,_,!0,"f"),e(this,k,!0,"f"),0!=this.options.length||this.control.readOnly||this.dispatchEvent(new CustomEvent("query",{detail:{term:t(this,w,"a",O)?.value??""},bubbles:!0,composed:!0})),t(this,w,"m",it).call(this)},G=function(){e(this,_,!1,"f"),t(this,C,"f")||t(this,w,"m",nt).call(this),e(this,C,!1,"f")},J=function(i){if(t(this,w,"a",O)&&!i.defaultPrevented){this.dispatchEvent(new CustomEvent("query",{detail:{term:t(this,w,"a",O).value},bubbles:!0,composed:!0})),""===t(this,w,"a",O).value&&t(this,w,"m",dt).call(this)&&this.dispatchEvent(new Event("change",{bubbles:!0})),e(this,S,!0,"f");try{t(this,A,"f")?(t(this,w,"m",ct).call(this),t(this,w,"a",R)||t(this,w,"m",nt).call(this)):t(this,w,"m",it).call(this)}finally{e(this,S,!1,"f"),t(this,w,"a",j)?.notifyControlStateChange(!0)}}},Q=function(){if(t(this,w,"a",O)){const e=this.selected;this.required?t(this,w,"a",O).value=e?.label??"":e&&e.label!==t(this,w,"a",O).value&&t(this,w,"m",dt).call(this)&&this.dispatchEvent(new Event("change",{bubbles:!0}))}},Y=function(i){if(!i.defaultPrevented)switch(e(this,k,!1,"f"),i.key){case"Backspace":case"Delete":t(this,w,"a",O)&&!t(this,w,"a",O).value&&t(this,w,"m",nt).call(this);break;case"Enter":t(this,A,"f")&&this._listKeyManager.activeItem?(i.preventDefault(),t(this,w,"m",lt).call(this,this._listKeyManager.activeItem),f()?t(this,w,"m",nt).call(this):setTimeout(()=>t(this,w,"m",nt).call(this),150)):t(this,A,"f")&&setTimeout(()=>{t(this,w,"a",O)&&!t(this,w,"a",O).value&&t(this,w,"m",nt).call(this)});break;case"Escape":case"Tab":t(this,w,"m",nt).call(this);break;case"Up":case"ArrowUp":i.altKey?t(this,w,"m",nt).call(this):this._listKeyManager.onKeyDown(i);break;case"Down":case"ArrowDown":t(this,A,"f")?this._listKeyManager.onKeyDown(i):(t(this,w,"m",it).call(this),i.preventDefault());break;default:this._listKeyManager.onKeyDown(i)}},Z=function(e){if(2===e.button)return;e.preventDefault(),e.stopImmediatePropagation();const i=e.composedPath().find(t=>t instanceof HTMLElement&&"M3E-OPTION"===t.tagName);i&&!i.disabled&&(this._listKeyManager.setActiveItem(i),t(this,w,"m",lt).call(this,i),f()?t(this,w,"m",nt).call(this):setTimeout(()=>t(this,w,"m",nt).call(this),150))},tt=function(e){if(t(this,A,"f"))if("closed"!==e.newState){const i=t(this,w,"a",B).find(t=>t.selected&&!t.disabled);i?(this._listKeyManager.setActiveItem(i),u(i,t(this,A,"f"))):t(this,w,"m",ut).call(this),this.dispatchEvent(new ToggleEvent("toggle",{oldState:e.oldState,newState:e.newState}))}else f()?t(this,w,"m",et).call(this,e):setTimeout(()=>t(this,w,"m",et).call(this,e),100)},et=function(i){t(this,A,"f")&&(t(this,M,"f")?.replaceChildren(...t(this,A,"f").childNodes),t(this,A,"f").remove(),t(this,A,"f").removeEventListener("toggle",t(this,x,"f")),t(this,A,"f").removeEventListener("pointerdown",t(this,U,"f")),e(this,A,void 0,"f"),t(this,w,"a",O)&&(t(this,w,"a",O).ariaExpanded="false",t(this,w,"a",O).removeAttribute("aria-controls"),t(this,w,"a",O).removeAttribute("aria-owns"),t(this,w,"a",O).removeAttribute("aria-activedescendant")),this.requestUpdate(),t(this,w,"a",j)?.notifyControlStateChange(),this.dispatchEvent(new ToggleEvent("toggle",{oldState:i.oldState,newState:i.newState})),"input"===t(this,w,"a",O)?.slot&&"M3E-INPUT-CHIP-SET"===t(this,w,"a",O).parentElement?.tagName&&t(this,w,"m",dt).call(this))},it=function(){if(t(this,A,"f")||!t(this,w,"a",O)||t(this,w,"a",O).readOnly||t(this,w,"a",O).disabled)return;const i=t(this,w,"m",ct).call(this);if(!t(this,w,"a",R))return;if(e(this,A,document.createElement("m3e-option-panel"),"f"),t(this,A,"f").id=t(this,L,"f"),this.panelClass)for(const e of this.panelClass.split(/\s+/).map(t=>t.trim()).filter(Boolean))t(this,A,"f").classList.add(e);t(this,A,"f").style.overflowX="hidden",t(this,A,"f").scrollStrategy="reposition",t(this,A,"f").fitAnchorWidth=!0,t(this,A,"f").addEventListener("toggle",t(this,x,"f")),t(this,A,"f").addEventListener("pointerdown",t(this,U,"f")),t(this,w,"m",st).call(this),t(this,w,"m",at).call(this,t(this,A,"f"),i),(t(this,w,"a",j)??t(this,w,"a",O)).insertAdjacentElement("afterend",t(this,A,"f")),t(this,w,"a",O).setAttribute("aria-controls",t(this,L,"f")),t(this,w,"a",O).setAttribute("aria-owns",t(this,L,"f")),t(this,w,"a",j)?.notifyControlStateChange(),this._listKeyManager.activeItem&&this.autoActivate&&t(this,w,"m",ht).call(this,this._listKeyManager.activeItem,!0);const s=t(this,w,"a",O);setTimeout(()=>t(this,A,"f")?.show(s,t(this,w,"a",j)?.menuAnchor))},st=function(){if(!t(this,M,"f")||!t(this,A,"f"))return;const e=[...t(this,M,"f").childNodes];if(!t(this,w,"a",H)&&this.noDataLabel){const t=document.createElement("span");t.slot="no-data",t.textContent=this.noDataLabel,e.push(t)}if(!t(this,w,"a",$)&&this.loadingLabel){const t=document.createElement("span");t.slot="loading",t.textContent=this.loadingLabel,e.push(t)}t(this,A,"f").replaceChildren(...e)},at=function(t,e){c(t,"-loading",this.loading),c(t,"-no-data",0==e)},nt=function(){t(this,A,"f")?.hide()},ht=function(e,i=!1){if(t(this,w,"a",O)&&(t(this,w,"a",O).setAttribute("aria-activedescendant",e.id),t(this,A,"f"))){u(e,t(this,A,"f"),{block:"nearest",behavior:"instant"});const s=i||!t(this,k,"f")&&(t(this,w,"a",O).matches(":focus-visible")||m());t(this,w,"a",B).forEach(t=>{t===e&&s?(t.focusRing?.show(),t.stateLayer?.show("focused")):(t.focusRing?.hide(),t.stateLayer?.hide("focused"))})}},ot=async function(t){const e=this._options[this._listKeyManager.items.indexOf(t)];e&&(e.selected=t.selected,e.isUpdatePending&&await e.updateComplete)},lt=async function(e){e.selected||(e.selected=!0,await t(this,w,"m",ot).call(this,e),e.isUpdatePending&&await e.updateComplete,this.requestUpdate(),this.isUpdatePending&&await this.updateComplete,t(this,w,"a",O)&&(t(this,w,"a",O).value=e.label),this.dispatchEvent(new Event("change",{bubbles:!0})),t(this,w,"a",j)?.notifyControlStateChange(!0))},rt=function(t,e,i,s){const a=this.caseSensitive?e.value:e.value.toLowerCase();switch(this.filter){case"starts-with":return t.term=s,t.highlightMode=this.filter,a.startsWith(i);case"ends-with":return t.term=s,t.highlightMode=this.filter,a.endsWith(i);case"contains":return t.term=s,t.highlightMode=this.filter,a.includes(i);case"none":return t.disableHighlight=!0,!0;default:return t.disableHighlight=!0,this.filter(e,s)}},ct=function(){if(!t(this,w,"a",O))return 0;const i=t(this,w,"a",B).filter(t=>!1===t.hidden).length,s=!this.loading&&t(this,S,"f");e(this,S,!1,"f");const a=t(this,w,"a",O).value,n=this.caseSensitive?a:a.toLocaleLowerCase();let h,o=0,l=!1;for(let e=0;e<t(this,w,"a",B).length;e++){const i=t(this,w,"a",B)[e],s=this._options[e];i.hidden=!t(this,w,"m",rt).call(this,i,s,n,a),!0===i.hidden?(t(this,w,"m",mt).call(this,i),d(i,"-first"),d(i,"-last")):(o++,l||i.parentElement instanceof y?(d(i,"-first"),h&&d(h,"-last"),p(i,"-last"),h=i):(p(i,"-first"),l=!0,p(i,"-last"),h=i))}t(this,A,"f")&&t(this,w,"m",at).call(this,t(this,A,"f"),o);const r=t(this,A,"f")?.querySelectorAll("m3e-optgroup")??t(this,M,"f")?.querySelectorAll("m3e-optgroup")??[];for(const t of r)t.hidden=[...t.querySelectorAll("m3e-option")].every(t=>!0===t.hidden);return s&&t(this,w,"m",ft).call(this,i,o),t(this,w,"m",ut).call(this),o},dt=function(){const e=this._listKeyManager.items.filter(t=>t.selected);return e.length>0&&(e.forEach(e=>{e.selected=!1,t(this,w,"m",ot).call(this,e)}),!0)},ft=function(e,i){if(t(this,_,"f"))if(0==i)e>0&&this.noDataLabel&&b.announce(this.noDataLabel,"polite");else if(e!=i){const t=this.resultsLabel instanceof Function?this.resultsLabel(i):this.resultsLabel;t&&b.announce(t,"polite")}},ut=function(){if(this.autoActivate&&(!this._listKeyManager.activeItem||!this._listKeyManager.activeItem.selected)){const e=t(this,w,"a",B).find(t=>!t.disabled&&!1===t.hidden);e&&(this._listKeyManager.setActiveItem(e),t(this,A,"f")&&u(e,t(this,A,"f"),{block:"nearest",behavior:"instant"}))}},mt=function(e){e.focusRing?.hide(),e.stateLayer?.hide("focused"),e===this._listKeyManager.activeItem&&(this._listKeyManager.updateActiveItem(null),t(this,w,"a",O)?.removeAttribute("aria-activedescendant"))},vt.styles=n`:host { display: contents; } .options { display: none; }`,vt.__nextId=0,i([h({attribute:"hide-selection-indicator",type:Boolean})],vt.prototype,"hideSelectionIndicator",void 0),i([h({type:Boolean,reflect:!0})],vt.prototype,"required",void 0),i([h({attribute:"auto-activate",type:Boolean})],vt.prototype,"autoActivate",void 0),i([h({attribute:"case-sensitive",type:Boolean})],vt.prototype,"caseSensitive",void 0),i([h({converter:{fromAttribute:t=>null===t?"contains":"starts-with"===t||"ends-with"===t||"contains"===t||"none"===t?t:"contains"}})],vt.prototype,"filter",void 0),i([h({type:Boolean})],vt.prototype,"loading",void 0),i([h({attribute:"hide-no-data",type:Boolean})],vt.prototype,"hideNoData",void 0),i([h({attribute:"hide-loading",type:Boolean})],vt.prototype,"hideLoading",void 0),i([h({attribute:"loading-label"})],vt.prototype,"loadingLabel",void 0),i([h({attribute:"no-data-label"})],vt.prototype,"noDataLabel",void 0),i([h({attribute:"results-label"})],vt.prototype,"resultsLabel",void 0),i([h({attribute:"panel-class"})],vt.prototype,"panelClass",void 0),vt=pt=i([v("m3e-autocomplete")],vt);export{vt as M3eAutocompleteElement};
7
7
  //# sourceMappingURL=autocomplete.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.min.js","sources":["../../src/autocomplete/AutocompleteElement.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\r\nimport { css, CSSResultGroup, html, LitElement, PropertyValues } from \"lit\";\r\nimport { property } from \"lit/decorators.js\";\r\n\r\nimport {\r\n HtmlFor,\r\n prefersReducedMotion,\r\n scrollIntoViewIfNeeded,\r\n forcedColorsActive,\r\n setCustomState,\r\n deleteCustomState,\r\n addCustomState,\r\n customElement,\r\n MutationController,\r\n} from \"@m3e/web/core\";\r\n\r\nimport { ListKeyManager, M3eLiveAnnouncer } from \"@m3e/web/core/a11y\";\r\nimport { M3eOptGroupElement, M3eOptionElement, M3eOptionPanelElement } from \"@m3e/web/option\";\r\nimport type { M3eFormFieldElement } from \"@m3e/web/form-field\";\r\n\r\nimport { AutocompleteFilterMode } from \"./AutocompleteFilterMode\";\r\nimport { QueryEventDetail } from \"./QueryEventDetail\";\r\n\r\n/**\r\n * Enhances a text input with suggested options.\r\n *\r\n * @description\r\n * The `m3e-autocomplete` component augments a text input field with a dynamically positioned menu of filterable suggestions,\r\n * following Material Design 3 principles. It provides real-time filtering, keyboard navigation, automatic option activation,\r\n * and text highlighting to guide user selection. The component manages focus, selection state, and menu visibility while\r\n * integrating seamlessly with form field containers and supporting both required and optional selection modes.\r\n *\r\n * @example\r\n * The following example illustrates use of the `m3e-autocomplete` paired with a `m3e-form-field`.\r\n * ```html\r\n * <m3e-form-field>\r\n * <label slot=\"label\" for=\"fruit\">Choose your favorite fruit</label>\r\n * <input id=\"fruit\" />\r\n * </m3e-form-field>\r\n * <m3e-autocomplete for=\"fruit\">\r\n * <m3e-option>Apples</m3e-option>\r\n * <m3e-option>Oranges</m3e-option>\r\n * <m3e-option>Bananas</m3e-option>\r\n * <m3e-option>Grapes</m3e-option>\r\n * </m3e-autocomplete>\r\n * ```\r\n *\r\n * @tag m3e-autocomplete\r\n *\r\n * @attr auto-activate - Whether the first option should be automatically activated.\r\n * @attr case-sensitive - Whether filtering is case sensitive.\r\n * @attr filter - Mode in which to filter options.\r\n * @attr hide-selection-indicator - Whether to hide the selection indicator.\r\n * @attr hide-loading - Whether to hide the menu when loading options.\r\n * @attr hide-no-data - Whether to hide the menu when there are no options to show.\r\n * @attr loading - Whether options are being loaded.\r\n * @attr loading-label - The text announced and presented when loading options.\r\n * @attr no-data-label - The text announced and presented when no options are available for the current term.\r\n * @attr panel-class - Class or list of classes to be applied to the autocomplete's overlay panel.\r\n * @attr required - Whether the user is required to make a selection when interacting with the autocomplete.\r\n * @attr results-label - The text announced when available options change for the current term.\r\n *\r\n * @slot - Renders the options of the autocomplete.\r\n * @slot loading - Renders content when loading options.\r\n * @slot no-data - Renders content when there are no options to show.\r\n *\r\n * @fires toggle - Emitted when the options menu opens or closes.\r\n * @fires query - Emitted when the input is focused or when the user modifies its value.\r\n */\r\n@customElement(\"m3e-autocomplete\")\r\nexport class M3eAutocompleteElement extends HtmlFor(LitElement) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: contents;\r\n }\r\n .options {\r\n display: none;\r\n }\r\n `;\r\n\r\n /** @private */ private static __nextId = 0;\r\n\r\n /** @private */ readonly #id = `m3e-autocomplete-${M3eAutocompleteElement.__nextId}`;\r\n /** @private */ readonly #menuId = `${this.#id}-menu`;\r\n /** @private */ private _options = new Array<M3eOptionElement>();\r\n /** @private */ #clone?: HTMLElement;\r\n /** @private */ #ignoreFocusVisible = false;\r\n /** @private */ #menu?: M3eOptionPanelElement;\r\n /** @private */ #ignoreHideMenuOnBlur = false;\r\n /** @private */ #inputChanged = false;\r\n /** @private */ #hasFocus = false;\r\n /** @private */ #mutationAbortController?: AbortController;\r\n\r\n /** @private */ readonly #clickHandler = () => this.#handleClick();\r\n /** @private */ readonly #formFieldPointerDownHandler = () => this.#handleFormFieldPointerDown();\r\n /** @private */ readonly #focusHandler = () => this.#handleFocus();\r\n /** @private */ readonly #blurHandler = () => this.#handleBlur();\r\n /** @private */ readonly #keyDownHandler = (e: KeyboardEvent) => this.#handleKeyDown(e);\r\n /** @private */ readonly #inputHandler = (e: Event) => this.#handleInput(e);\r\n /** @private */ readonly #changeHandler = () => this.#handleChange();\r\n /** @private */ readonly #menuToggleHandler = (e: ToggleEvent) => this.#handleMenuToggle(e);\r\n /** @private */ readonly #menuPointerDownHandler = (e: PointerEvent) => this.#handleMenuPointerDown(e);\r\n\r\n /** @private */ private readonly _listKeyManager = new ListKeyManager<M3eOptionElement>()\r\n .withWrap()\r\n .withHomeAndEnd()\r\n .withPageUpAndDown()\r\n .withVerticalOrientation()\r\n .withSkipPredicate((item) => item.disabled || item.hidden)\r\n .onActiveItemChange(() => {\r\n if (this._listKeyManager.activeItem) {\r\n this.#activateOption(this._listKeyManager.activeItem);\r\n }\r\n });\r\n\r\n constructor() {\r\n super();\r\n\r\n new MutationController(this, {\r\n config: {\r\n childList: true,\r\n subtree: true,\r\n },\r\n callback: () => this.#handleMutation(),\r\n });\r\n }\r\n\r\n /**\r\n * Whether to hide the selection indicator.\r\n * @default false\r\n */\r\n @property({ attribute: \"hide-selection-indicator\", type: Boolean }) hideSelectionIndicator = false;\r\n\r\n /**\r\n * Whether the user is required to make a selection when interacting with the autocomplete.\r\n * @default false\r\n */\r\n @property({ type: Boolean, reflect: true }) required = false;\r\n\r\n /**\r\n * Whether the first option should be automatically activated.\r\n * @default false\r\n */\r\n @property({ attribute: \"auto-activate\", type: Boolean }) autoActivate = false;\r\n\r\n /**\r\n * Whether filtering is case sensitive.\r\n * @default false\r\n */\r\n @property({ attribute: \"case-sensitive\", type: Boolean }) caseSensitive = false;\r\n\r\n /**\r\n * Mode in which to filter options.\r\n * @default \"contains\"\r\n */\r\n @property({\r\n converter: {\r\n fromAttribute(value: string | null): AutocompleteFilterMode {\r\n if (value === null) return \"contains\";\r\n if (value === \"starts-with\" || value === \"ends-with\" || value === \"contains\" || value === \"none\") {\r\n return value;\r\n }\r\n return \"contains\";\r\n },\r\n },\r\n })\r\n filter: AutocompleteFilterMode | ((option: M3eOptionElement, term: string) => boolean) = \"contains\";\r\n\r\n /**\r\n * Whether options are being loaded.\r\n * @default false\r\n */\r\n @property({ type: Boolean }) loading = false;\r\n\r\n /**\r\n * Whether to hide the menu when there are no options to show.\r\n * @default false\r\n */\r\n @property({ attribute: \"hide-no-data\", type: Boolean }) hideNoData = false;\r\n\r\n /**\r\n * Whether to hide the menu when loading options.\r\n * @default false\r\n */\r\n @property({ attribute: \"hide-loading\", type: Boolean }) hideLoading = false;\r\n\r\n /**\r\n * The text announced and presented when loading options.\r\n * @default \"Loading...\"\r\n */\r\n @property({ attribute: \"loading-label\" }) loadingLabel = \"Loading...\";\r\n\r\n /**\r\n * The text announced and presented when no options are available for the current term.\r\n * @default \"No options\"\r\n */\r\n @property({ attribute: \"no-data-label\" }) noDataLabel = \"No options\";\r\n\r\n /**\r\n * The text announced when available options change for the current term.\r\n * @default (count) => `${count} options`\r\n */\r\n @property({ attribute: \"results-label\" }) resultsLabel: string | ((count: number) => string) = (count) =>\r\n `${count} options`;\r\n\r\n /**\r\n * Class or list of classes to be applied to the autocomplete's overlay panel.\r\n * @default \"\"\r\n */\r\n @property({ attribute: \"panel-class\" }) panelClass = \"\";\r\n\r\n /** The options that can be selected. */\r\n get options(): readonly M3eOptionElement[] {\r\n return this._options ?? [];\r\n }\r\n\r\n /** @private */\r\n get #options(): readonly M3eOptionElement[] {\r\n return this._listKeyManager?.items ?? [];\r\n }\r\n\r\n /** @private */\r\n get #input(): HTMLInputElement | null {\r\n return this.control ? <HTMLInputElement>this.control : null;\r\n }\r\n\r\n /** @private */\r\n get #hasNoDataSlot(): boolean {\r\n return (this.#clone?.querySelector(\"[slot='no-data']\") ?? null) !== null;\r\n }\r\n\r\n /** @private */\r\n get #hasLoadingSlot(): boolean {\r\n return (this.#clone?.querySelector(\"[slot='loading']\") ?? null) !== null;\r\n }\r\n\r\n /** @private */\r\n get #shouldShowMenu(): boolean {\r\n return (\r\n this.#options.some((x) => !x.hidden) ||\r\n (this.loading && !this.hideLoading && this.loadingLabel.length > 0) ||\r\n (!this.loading && !this.hideNoData && this.noDataLabel.length > 0)\r\n );\r\n }\r\n\r\n /** @private */\r\n get #minMenuWidth(): string {\r\n const formField = this.#formField;\r\n return `${formField ? formField.menuAnchor.clientWidth : (this.control?.clientWidth ?? 0)}px`;\r\n }\r\n\r\n /** @private */\r\n get #formField(): M3eFormFieldElement | null {\r\n return this.control?.closest(\"m3e-form-field\") ?? null;\r\n }\r\n\r\n /** @inheritdoc */\r\n override attach(control: HTMLElement): void {\r\n if (!(control instanceof HTMLInputElement)) return;\r\n\r\n super.attach(control);\r\n\r\n control.autocomplete = \"off\";\r\n control.role = \"combobox\";\r\n control.ariaAutoComplete = \"list\";\r\n control.ariaExpanded = \"false\";\r\n\r\n control.addEventListener(\"click\", this.#clickHandler);\r\n control.addEventListener(\"focus\", this.#focusHandler);\r\n control.addEventListener(\"blur\", this.#blurHandler);\r\n control.addEventListener(\"keydown\", this.#keyDownHandler);\r\n control.addEventListener(\"input\", this.#inputHandler);\r\n control.addEventListener(\"change\", this.#changeHandler);\r\n\r\n this.#formField?.addEventListener(\"pointerdown\", this.#formFieldPointerDownHandler);\r\n }\r\n\r\n /** @inheritdoc */\r\n override detach(): void {\r\n if (this.control) {\r\n this.#formField?.removeEventListener(\"pointerdown\", this.#formFieldPointerDownHandler);\r\n\r\n this.control.role = null;\r\n this.control.ariaAutoComplete = null;\r\n this.control.ariaExpanded = null;\r\n\r\n this.control.removeEventListener(\"click\", this.#clickHandler);\r\n this.control.removeEventListener(\"focus\", this.#focusHandler);\r\n this.control.removeEventListener(\"blur\", this.#blurHandler);\r\n this.control.removeEventListener(\"keydown\", this.#keyDownHandler);\r\n this.control.removeEventListener(\"input\", this.#inputHandler);\r\n this.control.removeEventListener(\"change\", this.#changeHandler);\r\n }\r\n super.detach();\r\n }\r\n\r\n /**\r\n * Clears the value of the element.\r\n * @param [restoreFocus=false] Whether to restore input focus.\r\n */\r\n clear(restoreFocus = false): void {\r\n if (!this.#input) return;\r\n\r\n this.#input.value = \"\";\r\n this.#filterOptions();\r\n\r\n if (restoreFocus) {\r\n this.#input.focus();\r\n } else {\r\n this.#hideMenu();\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n override connectedCallback(): void {\r\n super.connectedCallback();\r\n this.#handleMutation();\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override update(changedProperties: PropertyValues<this>): void {\r\n super.update(changedProperties);\r\n\r\n if (changedProperties.has(\"hideNoData\") && this.hideNoData && this.#menu) {\r\n setCustomState(this.#menu, \"-no-data\", false);\r\n }\r\n\r\n if (changedProperties.has(\"loading\")) {\r\n if (this.loading) {\r\n if (this.#hasFocus) {\r\n if (this.loadingLabel) {\r\n M3eLiveAnnouncer.announce(this.loadingLabel, \"polite\");\r\n }\r\n if (!this.#menu && this.#shouldShowMenu) {\r\n this.#showMenu();\r\n }\r\n }\r\n } else if (this.#menu && !this.#shouldShowMenu) {\r\n this.#hideMenu();\r\n } else if (this.#menu) {\r\n deleteCustomState(this.#menu, \"-loading\");\r\n } else if (this.#hasFocus) {\r\n this.#showMenu();\r\n }\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return html`<div class=\"options\" aria-hidden=\"true\">\r\n <slot></slot>\r\n </div>`;\r\n }\r\n\r\n /** @private */\r\n async #handleMutation(): Promise<void> {\r\n if (this.#mutationAbortController) {\r\n this.#mutationAbortController.abort();\r\n }\r\n const mutationAbortController = new AbortController();\r\n this.#mutationAbortController = mutationAbortController;\r\n\r\n const options = [...this.querySelectorAll(\"m3e-option\")];\r\n\r\n for (const option of options) {\r\n if (mutationAbortController.signal.aborted) {\r\n break;\r\n }\r\n if (option.isUpdatePending) {\r\n await option.updateComplete;\r\n }\r\n }\r\n\r\n if (mutationAbortController.signal.aborted) {\r\n return;\r\n }\r\n\r\n this._options = options;\r\n\r\n this.#clone = <HTMLElement>this.cloneNode(true);\r\n\r\n const { added } = this._listKeyManager.setItems([...this.#clone.querySelectorAll(\"m3e-option\")]);\r\n added.forEach((x) => {\r\n x.id = x.id || `${this.#id}-option-${this._listKeyManager.items.indexOf(x)}`;\r\n setCustomState(x, \"-hide-selection-indicator\", this.hideSelectionIndicator);\r\n });\r\n\r\n if (this.#menu) {\r\n const count = this.#filterOptions();\r\n this.#projectClone();\r\n if (!this.#shouldShowMenu) {\r\n this.#hideMenu();\r\n } else {\r\n this.#updateMenuState(this.#menu, count);\r\n }\r\n }\r\n }\r\n\r\n /** @private */\r\n #handleClick(): void {\r\n this.#ignoreFocusVisible = true;\r\n this.#showMenu();\r\n }\r\n\r\n /** @private */\r\n #handleFormFieldPointerDown(): void {\r\n this.#ignoreHideMenuOnBlur = true;\r\n }\r\n\r\n /** @private */\r\n #handleFocus(): void {\r\n this.#hasFocus = true;\r\n this.#ignoreFocusVisible = true;\r\n\r\n if (this.options.length == 0 && !(<HTMLInputElement>this.control).readOnly) {\r\n this.dispatchEvent(\r\n new CustomEvent<QueryEventDetail>(\"query\", {\r\n detail: { term: this.#input?.value ?? \"\" },\r\n bubbles: true,\r\n composed: true,\r\n }),\r\n );\r\n }\r\n\r\n this.#showMenu();\r\n }\r\n\r\n /** @private */\r\n #handleBlur(): void {\r\n this.#hasFocus = false;\r\n if (!this.#ignoreHideMenuOnBlur) {\r\n this.#hideMenu();\r\n }\r\n this.#ignoreHideMenuOnBlur = false;\r\n }\r\n\r\n /** @private */\r\n #handleInput(e: Event): void {\r\n if (!this.#input || e.defaultPrevented) return;\r\n\r\n this.dispatchEvent(\r\n new CustomEvent<QueryEventDetail>(\"query\", {\r\n detail: { term: this.#input.value },\r\n bubbles: true,\r\n composed: true,\r\n }),\r\n );\r\n\r\n this.#inputChanged = true;\r\n try {\r\n if (!this.#menu) {\r\n this.#showMenu();\r\n } else {\r\n this.#filterOptions();\r\n if (!this.#shouldShowMenu) {\r\n this.#hideMenu();\r\n }\r\n }\r\n } finally {\r\n this.#inputChanged = false;\r\n this.#formField?.notifyControlStateChange(true);\r\n }\r\n }\r\n\r\n /** @private */\r\n #handleChange(): void {\r\n if (this.#input && this.required && !this.#options.some((x) => x.selected && !x.disabled)) {\r\n this.#input.value = \"\";\r\n }\r\n }\r\n\r\n /** @private */\r\n #handleKeyDown(e: KeyboardEvent): void {\r\n if (e.defaultPrevented) return;\r\n\r\n this.#ignoreFocusVisible = false;\r\n\r\n switch (e.key) {\r\n case \"Backspace\":\r\n case \"Delete\":\r\n if (this.#input && !this.#input.value) {\r\n this.#hideMenu();\r\n }\r\n break;\r\n\r\n case \"Enter\":\r\n if (this.#menu && this._listKeyManager.activeItem) {\r\n e.preventDefault();\r\n this.#selectOption(this._listKeyManager.activeItem);\r\n if (!prefersReducedMotion()) {\r\n setTimeout(() => this.#hideMenu(), 150);\r\n } else {\r\n this.#hideMenu();\r\n }\r\n } else if (this.#menu) {\r\n setTimeout(() => {\r\n if (this.#input && !this.#input.value) {\r\n this.#hideMenu();\r\n }\r\n });\r\n }\r\n break;\r\n\r\n case \"Escape\":\r\n case \"Tab\":\r\n this.#hideMenu();\r\n break;\r\n\r\n case \"Up\":\r\n case \"ArrowUp\":\r\n if (e.altKey) {\r\n this.#hideMenu();\r\n } else {\r\n this._listKeyManager.onKeyDown(e);\r\n }\r\n break;\r\n\r\n case \"Down\":\r\n case \"ArrowDown\":\r\n if (!this.#menu) {\r\n this.#showMenu();\r\n e.preventDefault();\r\n } else {\r\n this._listKeyManager.onKeyDown(e);\r\n }\r\n break;\r\n\r\n default:\r\n this._listKeyManager.onKeyDown(e);\r\n break;\r\n }\r\n }\r\n\r\n /** @private */\r\n #handleMenuPointerDown(e: PointerEvent): void {\r\n if (e.button === 2) return;\r\n e.preventDefault();\r\n e.stopImmediatePropagation();\r\n\r\n const option = <M3eOptionElement | undefined>(\r\n e.composedPath().find((x) => x instanceof HTMLElement && x.tagName === \"M3E-OPTION\")\r\n );\r\n\r\n if (option && !option.disabled) {\r\n this._listKeyManager.setActiveItem(option);\r\n this.#selectOption(option);\r\n if (!prefersReducedMotion()) {\r\n setTimeout(() => this.#hideMenu(), 150);\r\n } else {\r\n this.#hideMenu();\r\n }\r\n }\r\n }\r\n\r\n /** @private */\r\n #handleMenuToggle(e: ToggleEvent): void {\r\n if (!this.#menu) return;\r\n\r\n if (e.newState !== \"closed\") {\r\n const option = this.#options.find((x) => x.selected && !x.disabled);\r\n if (option) {\r\n this._listKeyManager.setActiveItem(option);\r\n scrollIntoViewIfNeeded(option, this.#menu);\r\n } else {\r\n this.#autoActivate();\r\n }\r\n\r\n this.dispatchEvent(\r\n new ToggleEvent(\"toggle\", {\r\n oldState: e.oldState,\r\n newState: e.newState,\r\n }),\r\n );\r\n } else {\r\n if (prefersReducedMotion()) {\r\n this.#destroyMenu(e);\r\n } else {\r\n // NOTE: use transitionend is preferred but doesn't fire when used here.\r\n // This is a workaround until that is fixed.\r\n setTimeout(() => this.#destroyMenu(e), 100);\r\n }\r\n }\r\n }\r\n\r\n /** @private*/\r\n #destroyMenu(e: ToggleEvent): void {\r\n if (!this.#menu) return;\r\n\r\n this.#clone?.replaceChildren(...this.#menu.childNodes);\r\n\r\n this.#menu.remove();\r\n this.#menu.removeEventListener(\"toggle\", this.#menuToggleHandler);\r\n this.#menu.removeEventListener(\"pointerdown\", this.#menuPointerDownHandler);\r\n this.#menu = undefined;\r\n\r\n if (this.#input) {\r\n this.#input.ariaExpanded = \"false\";\r\n this.#input.removeAttribute(\"aria-controls\");\r\n this.#input.removeAttribute(\"aria-owns\");\r\n }\r\n this.requestUpdate();\r\n\r\n this.#formField?.notifyControlStateChange();\r\n\r\n this.dispatchEvent(\r\n new ToggleEvent(\"toggle\", {\r\n oldState: e.oldState,\r\n newState: e.newState,\r\n }),\r\n );\r\n }\r\n\r\n /** @private */\r\n #showMenu(): void {\r\n if (this.#menu || !this.#input || this.#input.readOnly || this.#input.disabled) return;\r\n\r\n const count = this.#filterOptions();\r\n\r\n if (!this.#shouldShowMenu) return;\r\n\r\n this.#menu = document.createElement(\"m3e-option-panel\");\r\n this.#menu.id = this.#menuId;\r\n\r\n if (this.panelClass) {\r\n for (const klass of this.panelClass\r\n .split(/\\s+/)\r\n .map((d) => d.trim())\r\n .filter(Boolean)) {\r\n this.#menu.classList.add(klass);\r\n }\r\n }\r\n\r\n this.#menu.scrollStrategy = \"reposition\";\r\n this.#menu.style.overflowX = \"hidden\";\r\n this.#menu.style.minWidth = this.#minMenuWidth;\r\n this.#menu.addEventListener(\"toggle\", this.#menuToggleHandler);\r\n this.#menu.addEventListener(\"pointerdown\", this.#menuPointerDownHandler);\r\n\r\n this.#projectClone();\r\n\r\n this.#updateMenuState(this.#menu, count);\r\n\r\n (this.#formField ?? this.#input).insertAdjacentElement(\"afterend\", this.#menu);\r\n\r\n this.#input.setAttribute(\"aria-controls\", this.#menuId);\r\n this.#input.setAttribute(\"aria-owns\", this.#menuId);\r\n\r\n this.#formField?.notifyControlStateChange();\r\n\r\n if (this._listKeyManager.activeItem && this.autoActivate) {\r\n this.#activateOption(this._listKeyManager.activeItem, true);\r\n }\r\n\r\n const input = this.#input;\r\n setTimeout(() => this.#menu?.show(input, this.#formField?.menuAnchor));\r\n }\r\n\r\n /** @private */\r\n #projectClone(): void {\r\n if (!this.#clone || !this.#menu) return;\r\n const children = [...this.#clone.childNodes];\r\n if (!this.#hasNoDataSlot && this.noDataLabel) {\r\n const noDataSpan = document.createElement(\"span\");\r\n noDataSpan.slot = \"no-data\";\r\n noDataSpan.textContent = this.noDataLabel;\r\n children.push(noDataSpan);\r\n }\r\n if (!this.#hasLoadingSlot && this.loadingLabel) {\r\n const loadingSpan = document.createElement(\"span\");\r\n loadingSpan.slot = \"loading\";\r\n loadingSpan.textContent = this.loadingLabel;\r\n children.push(loadingSpan);\r\n }\r\n this.#menu.replaceChildren(...children);\r\n }\r\n\r\n /** @private */\r\n #updateMenuState(menu: M3eOptionPanelElement, count: number): void {\r\n setCustomState(menu, \"-loading\", this.loading);\r\n setCustomState(menu, \"-no-data\", count == 0);\r\n }\r\n\r\n /** @private */\r\n #hideMenu(): void {\r\n this.#menu?.hide();\r\n this.#input?.removeAttribute(\"aria-activedescendant\");\r\n }\r\n\r\n /** @private */\r\n #activateOption(option: M3eOptionElement, forceFocusVisible = false): void {\r\n if (!this.#input) return;\r\n\r\n this.#input.setAttribute(\"aria-activedescendant\", option.id);\r\n\r\n if (this.#menu) {\r\n scrollIntoViewIfNeeded(option, this.#menu, { block: \"nearest\", behavior: \"instant\" });\r\n\r\n const focusVisible =\r\n forceFocusVisible ||\r\n (!this.#ignoreFocusVisible && (this.#input.matches(\":focus-visible\") || forcedColorsActive()));\r\n\r\n this.#options.forEach((x) => {\r\n const active = x === option && focusVisible;\r\n if (active) {\r\n x.focusRing?.show();\r\n x.stateLayer?.show(\"focused\");\r\n } else {\r\n x.focusRing?.hide();\r\n x.stateLayer?.hide(\"focused\");\r\n }\r\n });\r\n }\r\n }\r\n\r\n /** @private */\r\n async #updateSelectionState(clone: M3eOptionElement): Promise<void> {\r\n const option = this._options[this._listKeyManager.items.indexOf(clone)];\r\n if (option) {\r\n option.selected = clone.selected;\r\n if (option.isUpdatePending) {\r\n await option.updateComplete;\r\n }\r\n }\r\n }\r\n\r\n /** @private */\r\n async #selectOption(option: M3eOptionElement): Promise<void> {\r\n if (option.selected) return;\r\n\r\n option.selected = true;\r\n await this.#updateSelectionState(option);\r\n if (option.isUpdatePending) {\r\n await option.updateComplete;\r\n }\r\n\r\n this.requestUpdate();\r\n if (this.isUpdatePending) {\r\n await this.updateComplete;\r\n }\r\n\r\n if (this.#input) {\r\n this.#input.value = option.value;\r\n }\r\n\r\n this.#formField?.notifyControlStateChange(true);\r\n }\r\n\r\n /** @private */\r\n #filterOption(clone: M3eOptionElement, option: M3eOptionElement, term: string, exactTerm: string): boolean {\r\n const value = this.caseSensitive ? option.value : option.value.toLowerCase();\r\n switch (this.filter) {\r\n case \"starts-with\":\r\n clone.term = exactTerm;\r\n clone.highlightMode = this.filter;\r\n return value.startsWith(term);\r\n case \"ends-with\":\r\n clone.term = exactTerm;\r\n clone.highlightMode = this.filter;\r\n return value.endsWith(term);\r\n case \"contains\":\r\n clone.term = exactTerm;\r\n clone.highlightMode = this.filter;\r\n return value.includes(term);\r\n case \"none\":\r\n clone.disableHighlight = true;\r\n return true;\r\n default:\r\n clone.disableHighlight = true;\r\n return this.filter(option, exactTerm);\r\n }\r\n }\r\n\r\n /** @private */\r\n #filterOptions(): number {\r\n if (!this.#input) return 0;\r\n\r\n const oldCount = this.#options.filter((x) => !x.hidden).length;\r\n const shouldAnnounce = !this.loading && this.#inputChanged;\r\n this.#inputChanged = false;\r\n\r\n const exactTerm = this.#input.value;\r\n const term = this.caseSensitive ? exactTerm : exactTerm.toLocaleLowerCase();\r\n\r\n let newCount = 0;\r\n let first = false;\r\n let last: M3eOptionElement | undefined;\r\n\r\n for (let i = 0; i < this.#options.length; i++) {\r\n const clone = this.#options[i];\r\n const option = this._options[i];\r\n clone.hidden = !this.#filterOption(clone, option, term, exactTerm);\r\n\r\n if (clone.hidden) {\r\n this.#deactivateOption(clone);\r\n deleteCustomState(clone, \"-first\");\r\n deleteCustomState(clone, \"-last\");\r\n } else {\r\n newCount++;\r\n if (!first && !(clone.parentElement instanceof M3eOptGroupElement)) {\r\n addCustomState(clone, \"-first\");\r\n first = true;\r\n addCustomState(clone, \"-last\");\r\n last = clone;\r\n } else {\r\n deleteCustomState(clone, \"-first\");\r\n if (last) {\r\n deleteCustomState(last, \"-last\");\r\n }\r\n addCustomState(clone, \"-last\");\r\n last = clone;\r\n }\r\n }\r\n\r\n if (clone.selected && option.value !== exactTerm) {\r\n clone.selected = false;\r\n this.#updateSelectionState(clone);\r\n }\r\n }\r\n\r\n if (this.#menu) {\r\n this.#updateMenuState(this.#menu, newCount);\r\n }\r\n\r\n const groups = this.#menu?.querySelectorAll(\"m3e-optgroup\") ?? this.#clone?.querySelectorAll(\"m3e-optgroup\") ?? [];\r\n for (const group of groups) {\r\n group.hidden = [...group.querySelectorAll(\"m3e-option\")].every((x) => x.hidden);\r\n }\r\n\r\n if (shouldAnnounce) {\r\n this.#announceResults(oldCount, newCount);\r\n }\r\n\r\n this.#autoActivate();\r\n return newCount;\r\n }\r\n\r\n /** @private */\r\n #announceResults(oldCount: number, newCount: number): void {\r\n if (!this.#hasFocus) return;\r\n if (newCount == 0) {\r\n if (oldCount > 0 && this.noDataLabel) {\r\n M3eLiveAnnouncer.announce(this.noDataLabel, \"polite\");\r\n }\r\n } else if (oldCount != newCount) {\r\n const message = this.resultsLabel instanceof Function ? this.resultsLabel(newCount) : this.resultsLabel;\r\n if (message) {\r\n M3eLiveAnnouncer.announce(message, \"polite\");\r\n }\r\n }\r\n }\r\n\r\n /** @private */\r\n #autoActivate(): void {\r\n if (this.autoActivate && (!this._listKeyManager.activeItem || !this._listKeyManager.activeItem.selected)) {\r\n const option = this.#options.find((x) => !x.disabled && !x.hidden);\r\n if (option) {\r\n this._listKeyManager.setActiveItem(option);\r\n if (this.#menu) {\r\n scrollIntoViewIfNeeded(option, this.#menu, { block: \"nearest\", behavior: \"instant\" });\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** @private */\r\n #deactivateOption(option: M3eOptionElement): void {\r\n option.focusRing?.hide();\r\n option.stateLayer?.hide(\"focused\");\r\n if (option === this._listKeyManager.activeItem) {\r\n this._listKeyManager.updateActiveItem(null);\r\n this.#input?.removeAttribute(\"aria-activedescendant\");\r\n }\r\n }\r\n}\r\n\r\ninterface M3eAutocompleteElementEventMap extends HTMLElementEventMap {\r\n toggle: ToggleEvent;\r\n query: CustomEvent<QueryEventDetail>;\r\n}\r\n\r\nexport interface M3eAutocompleteElement {\r\n addEventListener<K extends keyof M3eAutocompleteElementEventMap>(\r\n type: K,\r\n listener: (this: M3eAutocompleteElement, ev: M3eAutocompleteElementEventMap[K]) => void,\r\n options?: boolean | AddEventListenerOptions,\r\n ): void;\r\n\r\n addEventListener(\r\n type: string,\r\n listener: EventListenerOrEventListenerObject,\r\n options?: boolean | AddEventListenerOptions,\r\n ): void;\r\n\r\n removeEventListener<K extends keyof M3eAutocompleteElementEventMap>(\r\n type: K,\r\n listener: (this: M3eAutocompleteElement, ev: M3eAutocompleteElementEventMap[K]) => void,\r\n options?: boolean | EventListenerOptions,\r\n ): void;\r\n\r\n removeEventListener(\r\n type: string,\r\n listener: EventListenerOrEventListenerObject,\r\n options?: boolean | EventListenerOptions,\r\n ): void;\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-autocomplete\": M3eAutocompleteElement;\r\n }\r\n}\r\n"],"names":["M3eAutocompleteElement","HtmlFor","LitElement","constructor","super","_M3eAutocompleteElement_id","set","this","M3eAutocompleteElement_1","__nextId","_M3eAutocompleteElement_menuId","__classPrivateFieldGet","_options","Array","_M3eAutocompleteElement_clone","_M3eAutocompleteElement_ignoreFocusVisible","_M3eAutocompleteElement_menu","_M3eAutocompleteElement_ignoreHideMenuOnBlur","_M3eAutocompleteElement_inputChanged","_M3eAutocompleteElement_hasFocus","_M3eAutocompleteElement_mutationAbortController","_M3eAutocompleteElement_clickHandler","_M3eAutocompleteElement_instances","_M3eAutocompleteElement_handleClick","call","_M3eAutocompleteElement_formFieldPointerDownHandler","_M3eAutocompleteElement_handleFormFieldPointerDown","_M3eAutocompleteElement_focusHandler","_M3eAutocompleteElement_handleFocus","_M3eAutocompleteElement_blurHandler","_M3eAutocompleteElement_handleBlur","_M3eAutocompleteElement_keyDownHandler","e","_M3eAutocompleteElement_inputHandler","_M3eAutocompleteElement_changeHandler","_M3eAutocompleteElement_handleChange","_M3eAutocompleteElement_menuToggleHandler","_M3eAutocompleteElement_menuPointerDownHandler","_listKeyManager","ListKeyManager","withWrap","withHomeAndEnd","withPageUpAndDown","withVerticalOrientation","withSkipPredicate","item","disabled","hidden","onActiveItemChange","activeItem","_M3eAutocompleteElement_activateOption","hideSelectionIndicator","required","autoActivate","caseSensitive","filter","loading","hideNoData","hideLoading","loadingLabel","noDataLabel","resultsLabel","count","panelClass","MutationController","config","childList","subtree","callback","_M3eAutocompleteElement_handleMutation","options","attach","control","HTMLInputElement","autocomplete","role","ariaAutoComplete","ariaExpanded","addEventListener","_M3eAutocompleteElement_formField_get","detach","removeEventListener","clear","restoreFocus","_M3eAutocompleteElement_input_get","value","_M3eAutocompleteElement_filterOptions","focus","_M3eAutocompleteElement_hideMenu","connectedCallback","update","changedProperties","has","setCustomState","M3eLiveAnnouncer","announce","_M3eAutocompleteElement_shouldShowMenu_get","_M3eAutocompleteElement_showMenu","deleteCustomState","render","html","items","querySelector","_M3eAutocompleteElement_options_get","some","x","length","formField","menuAnchor","clientWidth","closest","async","abort","mutationAbortController","AbortController","__classPrivateFieldSet","querySelectorAll","option","signal","aborted","isUpdatePending","updateComplete","cloneNode","added","setItems","forEach","id","indexOf","_M3eAutocompleteElement_projectClone","_M3eAutocompleteElement_updateMenuState","readOnly","dispatchEvent","CustomEvent","detail","term","bubbles","composed","defaultPrevented","notifyControlStateChange","selected","key","preventDefault","_M3eAutocompleteElement_selectOption","prefersReducedMotion","setTimeout","altKey","onKeyDown","button","stopImmediatePropagation","composedPath","find","HTMLElement","tagName","setActiveItem","newState","scrollIntoViewIfNeeded","_M3eAutocompleteElement_autoActivate","ToggleEvent","oldState","_M3eAutocompleteElement_destroyMenu","replaceChildren","childNodes","remove","undefined","removeAttribute","requestUpdate","document","createElement","klass","split","map","d","trim","Boolean","classList","add","scrollStrategy","style","overflowX","minWidth","_M3eAutocompleteElement_minMenuWidth_get","insertAdjacentElement","setAttribute","input","show","children","_M3eAutocompleteElement_hasNoDataSlot_get","noDataSpan","slot","textContent","push","_M3eAutocompleteElement_hasLoadingSlot_get","loadingSpan","menu","hide","forceFocusVisible","block","behavior","focusVisible","matches","forcedColorsActive","focusRing","stateLayer","clone","_M3eAutocompleteElement_updateSelectionState","_M3eAutocompleteElement_filterOption","exactTerm","toLowerCase","highlightMode","startsWith","endsWith","includes","disableHighlight","oldCount","shouldAnnounce","toLocaleLowerCase","last","newCount","first","i","_M3eAutocompleteElement_deactivateOption","parentElement","M3eOptGroupElement","addCustomState","groups","group","every","_M3eAutocompleteElement_announceResults","message","Function","updateActiveItem","styles","css","__decorate","property","attribute","type","prototype","reflect","converter","fromAttribute","customElement"],"mappings":";;;;;kpBAsEO,IAAMA,MAAN,cAAqC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S,CAAEC,UAAW,eAAgBC,KAAM/D,WAA+B7K,GAAA6O,UAAA,mBAAA,GAMlCJ,EAAA,CAAzCC,EAAS,CAAEC,UAAW,mBAA+C3O,GAAA6O,UAAA,oBAAA,GAM5BJ,EAAA,CAAzCC,EAAS,CAAEC,UAAW,mBAA8C3O,GAAA6O,UAAA,mBAAA,GAM3BJ,EAAA,CAAzCC,EAAS,CAAEC,UAAW,mBACF3O,GAAA6O,UAAA,oBAAA,GAMmBJ,EAAA,CAAvCC,EAAS,CAAEC,UAAW,iBAAiC3O,GAAA6O,UAAA,kBAAA,GA5I7C7O,GAAsBQ,GAAAiO,EAAA,CADlCQ,EAAc,qBACFjP"}
1
+ {"version":3,"file":"autocomplete.min.js","sources":["../../src/autocomplete/AutocompleteElement.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\r\nimport { css, CSSResultGroup, html, LitElement, PropertyValues } from \"lit\";\r\nimport { property } from \"lit/decorators.js\";\r\n\r\nimport {\r\n HtmlFor,\r\n prefersReducedMotion,\r\n scrollIntoViewIfNeeded,\r\n forcedColorsActive,\r\n setCustomState,\r\n deleteCustomState,\r\n addCustomState,\r\n customElement,\r\n MutationController,\r\n EventAttribute,\r\n} from \"@m3e/web/core\";\r\n\r\nimport { ListKeyManager, M3eLiveAnnouncer } from \"@m3e/web/core/a11y\";\r\nimport { M3eOptGroupElement, M3eOptionElement, M3eOptionPanelElement } from \"@m3e/web/option\";\r\nimport type { M3eFormFieldElement } from \"@m3e/web/form-field\";\r\n\r\nimport { AutocompleteFilterMode } from \"./AutocompleteFilterMode\";\r\nimport { AutocompleteQueryEventDetail } from \"./AutocompleteQueryEventDetail\";\r\n\r\n/**\r\n * Enhances a text input with suggested options.\r\n *\r\n * @description\r\n * The `m3e-autocomplete` component augments a text input field with a dynamically positioned menu of filterable suggestions,\r\n * following Material Design 3 principles. It provides real-time filtering, keyboard navigation, automatic option activation,\r\n * and text highlighting to guide user selection. The component manages focus, selection state, and menu visibility while\r\n * integrating seamlessly with form field containers and supporting both required and optional selection modes.\r\n *\r\n * @example\r\n * The following example illustrates use of the `m3e-autocomplete` paired with a `m3e-form-field`.\r\n * ```html\r\n * <m3e-form-field>\r\n * <label slot=\"label\" for=\"fruit\">Choose your favorite fruit</label>\r\n * <input id=\"fruit\" />\r\n * </m3e-form-field>\r\n * <m3e-autocomplete for=\"fruit\">\r\n * <m3e-option>Apples</m3e-option>\r\n * <m3e-option>Oranges</m3e-option>\r\n * <m3e-option>Bananas</m3e-option>\r\n * <m3e-option>Grapes</m3e-option>\r\n * </m3e-autocomplete>\r\n * ```\r\n *\r\n * @tag m3e-autocomplete\r\n *\r\n * @attr auto-activate - Whether the first option should be automatically activated.\r\n * @attr case-sensitive - Whether filtering is case sensitive.\r\n * @attr filter - Mode in which to filter options.\r\n * @attr hide-selection-indicator - Whether to hide the selection indicator.\r\n * @attr hide-loading - Whether to hide the menu when loading options.\r\n * @attr hide-no-data - Whether to hide the menu when there are no options to show.\r\n * @attr loading - Whether options are being loaded.\r\n * @attr loading-label - The text announced and presented when loading options.\r\n * @attr no-data-label - The text announced and presented when no options are available for the current term.\r\n * @attr panel-class - Class or list of classes to be applied to the autocomplete's overlay panel.\r\n * @attr required - Whether the user is required to make a selection when interacting with the autocomplete.\r\n * @attr results-label - The text announced when available options change for the current term.\r\n *\r\n * @slot - Renders the options of the autocomplete.\r\n * @slot loading - Renders content when loading options.\r\n * @slot no-data - Renders content when there are no options to show.\r\n *\r\n * @fires toggle - Emitted when the options menu opens or closes.\r\n * @fires query - Emitted when the input is focused or when the user modifies its value.\r\n * @fires change - Emitted when the committed value changes due to selecting an option or clearing the input.\r\n */\r\n@customElement(\"m3e-autocomplete\")\r\nexport class M3eAutocompleteElement extends EventAttribute(HtmlFor(LitElement), \"query\") {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: contents;\r\n }\r\n .options {\r\n display: none;\r\n }\r\n `;\r\n\r\n /** @private */ private static __nextId = 0;\r\n\r\n /** @private */ readonly #id = `m3e-autocomplete-${M3eAutocompleteElement.__nextId}`;\r\n /** @private */ readonly #menuId = `${this.#id}-menu`;\r\n /** @private */ private _options = new Array<M3eOptionElement>();\r\n /** @private */ #clone?: HTMLElement;\r\n /** @private */ #ignoreFocusVisible = false;\r\n /** @private */ #menu?: M3eOptionPanelElement;\r\n /** @private */ #ignoreHideMenuOnBlur = false;\r\n /** @private */ #inputChanged = false;\r\n /** @private */ #hasFocus = false;\r\n /** @private */ #mutationAbortController?: AbortController;\r\n\r\n /** @private */ readonly #clickHandler = () => this.#handleClick();\r\n /** @private */ readonly #formFieldPointerDownHandler = () => this.#handleFormFieldPointerDown();\r\n /** @private */ readonly #focusHandler = () => this.#handleFocus();\r\n /** @private */ readonly #blurHandler = () => this.#handleBlur();\r\n /** @private */ readonly #keyDownHandler = (e: KeyboardEvent) => this.#handleKeyDown(e);\r\n /** @private */ readonly #inputHandler = (e: Event) => this.#handleInput(e);\r\n /** @private */ readonly #changeHandler = () => this.#handleChange();\r\n /** @private */ readonly #menuToggleHandler = (e: ToggleEvent) => this.#handleMenuToggle(e);\r\n /** @private */ readonly #menuPointerDownHandler = (e: PointerEvent) => this.#handleMenuPointerDown(e);\r\n\r\n /** @private */ private readonly _listKeyManager = new ListKeyManager<M3eOptionElement>()\r\n .withWrap()\r\n .withHomeAndEnd()\r\n .withPageUpAndDown()\r\n .withVerticalOrientation()\r\n .withSkipPredicate((item) => item.disabled || item.hidden === true)\r\n .onActiveItemChange(() => {\r\n if (this._listKeyManager.activeItem) {\r\n this.#activateOption(this._listKeyManager.activeItem);\r\n }\r\n });\r\n\r\n constructor() {\r\n super();\r\n\r\n new MutationController(this, {\r\n config: {\r\n childList: true,\r\n subtree: true,\r\n },\r\n callback: () => this.#handleMutation(),\r\n });\r\n }\r\n\r\n /**\r\n * Whether to hide the selection indicator.\r\n * @default false\r\n */\r\n @property({ attribute: \"hide-selection-indicator\", type: Boolean }) hideSelectionIndicator = false;\r\n\r\n /**\r\n * Whether the user is required to make a selection when interacting with the autocomplete.\r\n * @default false\r\n */\r\n @property({ type: Boolean, reflect: true }) required = false;\r\n\r\n /**\r\n * Whether the first option should be automatically activated.\r\n * @default false\r\n */\r\n @property({ attribute: \"auto-activate\", type: Boolean }) autoActivate = false;\r\n\r\n /**\r\n * Whether filtering is case sensitive.\r\n * @default false\r\n */\r\n @property({ attribute: \"case-sensitive\", type: Boolean }) caseSensitive = false;\r\n\r\n /**\r\n * Mode in which to filter options.\r\n * @default \"contains\"\r\n */\r\n @property({\r\n converter: {\r\n fromAttribute(value: string | null): AutocompleteFilterMode {\r\n if (value === null) return \"contains\";\r\n if (value === \"starts-with\" || value === \"ends-with\" || value === \"contains\" || value === \"none\") {\r\n return value;\r\n }\r\n return \"contains\";\r\n },\r\n },\r\n })\r\n filter: AutocompleteFilterMode | ((option: M3eOptionElement, term: string) => boolean) = \"contains\";\r\n\r\n /**\r\n * Whether options are being loaded.\r\n * @default false\r\n */\r\n @property({ type: Boolean }) loading = false;\r\n\r\n /**\r\n * Whether to hide the menu when there are no options to show.\r\n * @default false\r\n */\r\n @property({ attribute: \"hide-no-data\", type: Boolean }) hideNoData = false;\r\n\r\n /**\r\n * Whether to hide the menu when loading options.\r\n * @default false\r\n */\r\n @property({ attribute: \"hide-loading\", type: Boolean }) hideLoading = false;\r\n\r\n /**\r\n * The text announced and presented when loading options.\r\n * @default \"Loading...\"\r\n */\r\n @property({ attribute: \"loading-label\" }) loadingLabel = \"Loading...\";\r\n\r\n /**\r\n * The text announced and presented when no options are available for the current term.\r\n * @default \"No options\"\r\n */\r\n @property({ attribute: \"no-data-label\" }) noDataLabel = \"No options\";\r\n\r\n /**\r\n * The text announced when available options change for the current term.\r\n * @default (count) => `${count} options`\r\n */\r\n @property({ attribute: \"results-label\" }) resultsLabel: string | ((count: number) => string) = (count) =>\r\n `${count} options`;\r\n\r\n /**\r\n * Class or list of classes to be applied to the autocomplete's overlay panel.\r\n * @default \"\"\r\n */\r\n @property({ attribute: \"panel-class\" }) panelClass = \"\";\r\n\r\n /** The options that can be selected. */\r\n get options(): readonly M3eOptionElement[] {\r\n return this._options ?? [];\r\n }\r\n\r\n /** The selected option. */\r\n get selected(): M3eOptionElement | null {\r\n return this.options.find((x) => x.selected) ?? null;\r\n }\r\n\r\n /** The selected (enabled) value. */\r\n get value(): string | null {\r\n const selected = this.selected;\r\n return selected && !selected.disabled ? selected.value : null;\r\n }\r\n\r\n /** @private */\r\n get #options(): readonly M3eOptionElement[] {\r\n return this._listKeyManager?.items ?? [];\r\n }\r\n\r\n /** @private */\r\n get #input(): HTMLInputElement | null {\r\n return this.control ? <HTMLInputElement>this.control : null;\r\n }\r\n\r\n /** @private */\r\n get #hasNoDataSlot(): boolean {\r\n return (this.#clone?.querySelector(\"[slot='no-data']\") ?? null) !== null;\r\n }\r\n\r\n /** @private */\r\n get #hasLoadingSlot(): boolean {\r\n return (this.#clone?.querySelector(\"[slot='loading']\") ?? null) !== null;\r\n }\r\n\r\n /** @private */\r\n get #shouldShowMenu(): boolean {\r\n return (\r\n this.#options.some((x) => x.hidden === false) ||\r\n (this.loading && !this.hideLoading && this.loadingLabel.length > 0) ||\r\n (!this.loading && !this.hideNoData && this.noDataLabel.length > 0)\r\n );\r\n }\r\n\r\n /** @private */\r\n get #formField(): M3eFormFieldElement | null {\r\n return this.control?.closest(\"m3e-form-field\") ?? null;\r\n }\r\n\r\n /** @inheritdoc */\r\n override attach(control: HTMLElement): void {\r\n if (!(control instanceof HTMLInputElement)) return;\r\n\r\n super.attach(control);\r\n\r\n control.autocomplete = \"off\";\r\n control.role = \"combobox\";\r\n control.ariaAutoComplete = \"list\";\r\n control.ariaExpanded = \"false\";\r\n\r\n control.addEventListener(\"click\", this.#clickHandler);\r\n control.addEventListener(\"focus\", this.#focusHandler);\r\n control.addEventListener(\"blur\", this.#blurHandler);\r\n control.addEventListener(\"keydown\", this.#keyDownHandler);\r\n control.addEventListener(\"input\", this.#inputHandler);\r\n control.addEventListener(\"change\", this.#changeHandler);\r\n\r\n this.#formField?.addEventListener(\"pointerdown\", this.#formFieldPointerDownHandler);\r\n }\r\n\r\n /** @inheritdoc */\r\n override detach(): void {\r\n if (this.control) {\r\n this.#formField?.removeEventListener(\"pointerdown\", this.#formFieldPointerDownHandler);\r\n\r\n this.control.role = null;\r\n this.control.ariaAutoComplete = null;\r\n this.control.ariaExpanded = null;\r\n\r\n this.control.removeEventListener(\"click\", this.#clickHandler);\r\n this.control.removeEventListener(\"focus\", this.#focusHandler);\r\n this.control.removeEventListener(\"blur\", this.#blurHandler);\r\n this.control.removeEventListener(\"keydown\", this.#keyDownHandler);\r\n this.control.removeEventListener(\"input\", this.#inputHandler);\r\n this.control.removeEventListener(\"change\", this.#changeHandler);\r\n }\r\n super.detach();\r\n }\r\n\r\n /**\r\n * Clears the value of the element.\r\n * @param [restoreFocus=false] Whether to restore input focus.\r\n */\r\n clear(restoreFocus = false): void {\r\n if (!this.#input) return;\r\n\r\n this.#input.value = \"\";\r\n if (this.#clearOptions()) {\r\n this.dispatchEvent(new Event(\"change\", { bubbles: true }));\r\n }\r\n this.#filterOptions();\r\n\r\n if (restoreFocus) {\r\n this.#input.focus();\r\n } else {\r\n this.#hideMenu();\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n override connectedCallback(): void {\r\n super.connectedCallback();\r\n this.#handleMutation();\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override update(changedProperties: PropertyValues<this>): void {\r\n super.update(changedProperties);\r\n\r\n if (changedProperties.has(\"hideNoData\") && this.hideNoData && this.#menu) {\r\n setCustomState(this.#menu, \"-no-data\", false);\r\n }\r\n\r\n if (changedProperties.has(\"loading\")) {\r\n if (this.loading) {\r\n if (this.#hasFocus) {\r\n if (this.loadingLabel) {\r\n M3eLiveAnnouncer.announce(this.loadingLabel, \"polite\");\r\n }\r\n if (!this.#menu && this.#shouldShowMenu) {\r\n this.#showMenu();\r\n }\r\n }\r\n } else if (this.#menu && !this.#shouldShowMenu) {\r\n this.#hideMenu();\r\n } else if (this.#menu) {\r\n deleteCustomState(this.#menu, \"-loading\");\r\n } else if (this.#hasFocus) {\r\n this.#showMenu();\r\n }\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return html`<div class=\"options\" aria-hidden=\"true\">\r\n <slot></slot>\r\n </div>`;\r\n }\r\n\r\n /** @private */\r\n async #handleMutation(): Promise<void> {\r\n if (this.#mutationAbortController) {\r\n this.#mutationAbortController.abort();\r\n }\r\n const mutationAbortController = new AbortController();\r\n this.#mutationAbortController = mutationAbortController;\r\n\r\n const options = [...this.querySelectorAll(\"m3e-option\")];\r\n\r\n for (const option of options) {\r\n if (mutationAbortController.signal.aborted) {\r\n break;\r\n }\r\n if (option.isUpdatePending) {\r\n await option.updateComplete;\r\n }\r\n }\r\n\r\n if (mutationAbortController.signal.aborted) {\r\n return;\r\n }\r\n\r\n this._options = options;\r\n\r\n this.#clone = <HTMLElement>this.cloneNode(true);\r\n\r\n const { added } = this._listKeyManager.setItems([...this.#clone.querySelectorAll(\"m3e-option\")]);\r\n added.forEach((x) => {\r\n x.id = x.id || `${this.#id}-option-${this._listKeyManager.items.indexOf(x)}`;\r\n setCustomState(x, \"-hide-selection-indicator\", this.hideSelectionIndicator);\r\n });\r\n\r\n if (this.#menu) {\r\n const count = this.#filterOptions();\r\n this.#projectClone();\r\n if (!this.#shouldShowMenu) {\r\n this.#hideMenu();\r\n } else {\r\n this.#updateMenuState(this.#menu, count);\r\n }\r\n }\r\n }\r\n\r\n /** @private */\r\n #handleClick(): void {\r\n this.#ignoreFocusVisible = true;\r\n this.#showMenu();\r\n }\r\n\r\n /** @private */\r\n #handleFormFieldPointerDown(): void {\r\n this.#ignoreHideMenuOnBlur = true;\r\n }\r\n\r\n /** @private */\r\n #handleFocus(): void {\r\n this.#hasFocus = true;\r\n this.#ignoreFocusVisible = true;\r\n\r\n if (this.options.length == 0 && !(<HTMLInputElement>this.control).readOnly) {\r\n this.dispatchEvent(\r\n new CustomEvent<AutocompleteQueryEventDetail>(\"query\", {\r\n detail: { term: this.#input?.value ?? \"\" },\r\n bubbles: true,\r\n composed: true,\r\n }),\r\n );\r\n }\r\n\r\n this.#showMenu();\r\n }\r\n\r\n /** @private */\r\n #handleBlur(): void {\r\n this.#hasFocus = false;\r\n if (!this.#ignoreHideMenuOnBlur) {\r\n this.#hideMenu();\r\n }\r\n this.#ignoreHideMenuOnBlur = false;\r\n }\r\n\r\n /** @private */\r\n #handleInput(e: Event): void {\r\n if (!this.#input || e.defaultPrevented) return;\r\n\r\n this.dispatchEvent(\r\n new CustomEvent<AutocompleteQueryEventDetail>(\"query\", {\r\n detail: { term: this.#input.value },\r\n bubbles: true,\r\n composed: true,\r\n }),\r\n );\r\n\r\n if (this.#input.value === \"\" && this.#clearOptions()) {\r\n this.dispatchEvent(new Event(\"change\", { bubbles: true }));\r\n }\r\n\r\n this.#inputChanged = true;\r\n try {\r\n if (!this.#menu) {\r\n this.#showMenu();\r\n } else {\r\n this.#filterOptions();\r\n if (!this.#shouldShowMenu) {\r\n this.#hideMenu();\r\n }\r\n }\r\n } finally {\r\n this.#inputChanged = false;\r\n this.#formField?.notifyControlStateChange(true);\r\n }\r\n }\r\n\r\n /** @private */\r\n #handleChange(): void {\r\n if (this.#input) {\r\n const selected = this.selected;\r\n if (this.required) {\r\n this.#input.value = selected?.label ?? \"\";\r\n } else if (selected && selected.label !== this.#input.value && this.#clearOptions()) {\r\n this.dispatchEvent(new Event(\"change\", { bubbles: true }));\r\n }\r\n }\r\n }\r\n\r\n /** @private */\r\n #handleKeyDown(e: KeyboardEvent): void {\r\n if (e.defaultPrevented) return;\r\n\r\n this.#ignoreFocusVisible = false;\r\n\r\n switch (e.key) {\r\n case \"Backspace\":\r\n case \"Delete\":\r\n if (this.#input && !this.#input.value) {\r\n this.#hideMenu();\r\n }\r\n break;\r\n\r\n case \"Enter\":\r\n if (this.#menu && this._listKeyManager.activeItem) {\r\n e.preventDefault();\r\n this.#selectOption(this._listKeyManager.activeItem);\r\n if (!prefersReducedMotion()) {\r\n setTimeout(() => this.#hideMenu(), 150);\r\n } else {\r\n this.#hideMenu();\r\n }\r\n } else if (this.#menu) {\r\n setTimeout(() => {\r\n if (this.#input && !this.#input.value) {\r\n this.#hideMenu();\r\n }\r\n });\r\n }\r\n break;\r\n\r\n case \"Escape\":\r\n case \"Tab\":\r\n this.#hideMenu();\r\n break;\r\n\r\n case \"Up\":\r\n case \"ArrowUp\":\r\n if (e.altKey) {\r\n this.#hideMenu();\r\n } else {\r\n this._listKeyManager.onKeyDown(e);\r\n }\r\n break;\r\n\r\n case \"Down\":\r\n case \"ArrowDown\":\r\n if (!this.#menu) {\r\n this.#showMenu();\r\n e.preventDefault();\r\n } else {\r\n this._listKeyManager.onKeyDown(e);\r\n }\r\n break;\r\n\r\n default:\r\n this._listKeyManager.onKeyDown(e);\r\n break;\r\n }\r\n }\r\n\r\n /** @private */\r\n #handleMenuPointerDown(e: PointerEvent): void {\r\n if (e.button === 2) return;\r\n e.preventDefault();\r\n e.stopImmediatePropagation();\r\n\r\n const option = <M3eOptionElement | undefined>(\r\n e.composedPath().find((x) => x instanceof HTMLElement && x.tagName === \"M3E-OPTION\")\r\n );\r\n\r\n if (option && !option.disabled) {\r\n this._listKeyManager.setActiveItem(option);\r\n this.#selectOption(option);\r\n if (!prefersReducedMotion()) {\r\n setTimeout(() => this.#hideMenu(), 150);\r\n } else {\r\n this.#hideMenu();\r\n }\r\n }\r\n }\r\n\r\n /** @private */\r\n #handleMenuToggle(e: ToggleEvent): void {\r\n if (!this.#menu) return;\r\n\r\n if (e.newState !== \"closed\") {\r\n const option = this.#options.find((x) => x.selected && !x.disabled);\r\n if (option) {\r\n this._listKeyManager.setActiveItem(option);\r\n scrollIntoViewIfNeeded(option, this.#menu);\r\n } else {\r\n this.#autoActivate();\r\n }\r\n\r\n this.dispatchEvent(\r\n new ToggleEvent(\"toggle\", {\r\n oldState: e.oldState,\r\n newState: e.newState,\r\n }),\r\n );\r\n } else {\r\n if (prefersReducedMotion()) {\r\n this.#destroyMenu(e);\r\n } else {\r\n // NOTE: use transitionend is preferred but doesn't fire when used here.\r\n // This is a workaround until that is fixed.\r\n setTimeout(() => this.#destroyMenu(e), 100);\r\n }\r\n }\r\n }\r\n\r\n /** @private*/\r\n #destroyMenu(e: ToggleEvent): void {\r\n if (!this.#menu) return;\r\n\r\n this.#clone?.replaceChildren(...this.#menu.childNodes);\r\n\r\n this.#menu.remove();\r\n this.#menu.removeEventListener(\"toggle\", this.#menuToggleHandler);\r\n this.#menu.removeEventListener(\"pointerdown\", this.#menuPointerDownHandler);\r\n this.#menu = undefined;\r\n\r\n if (this.#input) {\r\n this.#input.ariaExpanded = \"false\";\r\n this.#input.removeAttribute(\"aria-controls\");\r\n this.#input.removeAttribute(\"aria-owns\");\r\n this.#input.removeAttribute(\"aria-activedescendant\");\r\n }\r\n this.requestUpdate();\r\n\r\n this.#formField?.notifyControlStateChange();\r\n\r\n this.dispatchEvent(\r\n new ToggleEvent(\"toggle\", {\r\n oldState: e.oldState,\r\n newState: e.newState,\r\n }),\r\n );\r\n\r\n if (this.#input?.slot === \"input\" && this.#input.parentElement?.tagName === \"M3E-INPUT-CHIP-SET\") {\r\n this.#clearOptions();\r\n }\r\n }\r\n\r\n /** @private */\r\n #showMenu(): void {\r\n if (this.#menu || !this.#input || this.#input.readOnly || this.#input.disabled) return;\r\n\r\n const count = this.#filterOptions();\r\n\r\n if (!this.#shouldShowMenu) return;\r\n\r\n this.#menu = document.createElement(\"m3e-option-panel\");\r\n this.#menu.id = this.#menuId;\r\n\r\n if (this.panelClass) {\r\n for (const klass of this.panelClass\r\n .split(/\\s+/)\r\n .map((d) => d.trim())\r\n .filter(Boolean)) {\r\n this.#menu.classList.add(klass);\r\n }\r\n }\r\n\r\n this.#menu.style.overflowX = \"hidden\";\r\n this.#menu.scrollStrategy = \"reposition\";\r\n this.#menu.fitAnchorWidth = true;\r\n this.#menu.addEventListener(\"toggle\", this.#menuToggleHandler);\r\n this.#menu.addEventListener(\"pointerdown\", this.#menuPointerDownHandler);\r\n\r\n this.#projectClone();\r\n\r\n this.#updateMenuState(this.#menu, count);\r\n\r\n (this.#formField ?? this.#input).insertAdjacentElement(\"afterend\", this.#menu);\r\n\r\n this.#input.setAttribute(\"aria-controls\", this.#menuId);\r\n this.#input.setAttribute(\"aria-owns\", this.#menuId);\r\n\r\n this.#formField?.notifyControlStateChange();\r\n\r\n if (this._listKeyManager.activeItem && this.autoActivate) {\r\n this.#activateOption(this._listKeyManager.activeItem, true);\r\n }\r\n\r\n const input = this.#input;\r\n setTimeout(() => this.#menu?.show(input, this.#formField?.menuAnchor));\r\n }\r\n\r\n /** @private */\r\n #projectClone(): void {\r\n if (!this.#clone || !this.#menu) return;\r\n const children = [...this.#clone.childNodes];\r\n if (!this.#hasNoDataSlot && this.noDataLabel) {\r\n const noDataSpan = document.createElement(\"span\");\r\n noDataSpan.slot = \"no-data\";\r\n noDataSpan.textContent = this.noDataLabel;\r\n children.push(noDataSpan);\r\n }\r\n if (!this.#hasLoadingSlot && this.loadingLabel) {\r\n const loadingSpan = document.createElement(\"span\");\r\n loadingSpan.slot = \"loading\";\r\n loadingSpan.textContent = this.loadingLabel;\r\n children.push(loadingSpan);\r\n }\r\n this.#menu.replaceChildren(...children);\r\n }\r\n\r\n /** @private */\r\n #updateMenuState(menu: M3eOptionPanelElement, count: number): void {\r\n setCustomState(menu, \"-loading\", this.loading);\r\n setCustomState(menu, \"-no-data\", count == 0);\r\n }\r\n\r\n /** @private */\r\n #hideMenu(): void {\r\n this.#menu?.hide();\r\n }\r\n\r\n /** @private */\r\n #activateOption(option: M3eOptionElement, forceFocusVisible = false): void {\r\n if (!this.#input) return;\r\n\r\n this.#input.setAttribute(\"aria-activedescendant\", option.id);\r\n\r\n if (this.#menu) {\r\n scrollIntoViewIfNeeded(option, this.#menu, { block: \"nearest\", behavior: \"instant\" });\r\n\r\n const focusVisible =\r\n forceFocusVisible ||\r\n (!this.#ignoreFocusVisible && (this.#input.matches(\":focus-visible\") || forcedColorsActive()));\r\n\r\n this.#options.forEach((x) => {\r\n const active = x === option && focusVisible;\r\n if (active) {\r\n x.focusRing?.show();\r\n x.stateLayer?.show(\"focused\");\r\n } else {\r\n x.focusRing?.hide();\r\n x.stateLayer?.hide(\"focused\");\r\n }\r\n });\r\n }\r\n }\r\n\r\n /** @private */\r\n async #updateSelectionState(clone: M3eOptionElement): Promise<void> {\r\n const option = this._options[this._listKeyManager.items.indexOf(clone)];\r\n if (option) {\r\n option.selected = clone.selected;\r\n if (option.isUpdatePending) {\r\n await option.updateComplete;\r\n }\r\n }\r\n }\r\n\r\n /** @private */\r\n async #selectOption(option: M3eOptionElement): Promise<void> {\r\n if (option.selected) return;\r\n\r\n option.selected = true;\r\n await this.#updateSelectionState(option);\r\n if (option.isUpdatePending) {\r\n await option.updateComplete;\r\n }\r\n\r\n this.requestUpdate();\r\n if (this.isUpdatePending) {\r\n await this.updateComplete;\r\n }\r\n\r\n if (this.#input) {\r\n this.#input.value = option.label;\r\n }\r\n\r\n this.dispatchEvent(new Event(\"change\", { bubbles: true }));\r\n\r\n this.#formField?.notifyControlStateChange(true);\r\n }\r\n\r\n /** @private */\r\n #filterOption(clone: M3eOptionElement, option: M3eOptionElement, term: string, exactTerm: string): boolean {\r\n const value = this.caseSensitive ? option.value : option.value.toLowerCase();\r\n switch (this.filter) {\r\n case \"starts-with\":\r\n clone.term = exactTerm;\r\n clone.highlightMode = this.filter;\r\n return value.startsWith(term);\r\n case \"ends-with\":\r\n clone.term = exactTerm;\r\n clone.highlightMode = this.filter;\r\n return value.endsWith(term);\r\n case \"contains\":\r\n clone.term = exactTerm;\r\n clone.highlightMode = this.filter;\r\n return value.includes(term);\r\n case \"none\":\r\n clone.disableHighlight = true;\r\n return true;\r\n default:\r\n clone.disableHighlight = true;\r\n return this.filter(option, exactTerm);\r\n }\r\n }\r\n\r\n /** @private */\r\n #filterOptions(): number {\r\n if (!this.#input) return 0;\r\n\r\n const oldCount = this.#options.filter((x) => x.hidden === false).length;\r\n const shouldAnnounce = !this.loading && this.#inputChanged;\r\n this.#inputChanged = false;\r\n\r\n const exactTerm = this.#input.value;\r\n const term = this.caseSensitive ? exactTerm : exactTerm.toLocaleLowerCase();\r\n\r\n let newCount = 0;\r\n let first = false;\r\n let last: M3eOptionElement | undefined;\r\n\r\n for (let i = 0; i < this.#options.length; i++) {\r\n const clone = this.#options[i];\r\n const option = this._options[i];\r\n clone.hidden = !this.#filterOption(clone, option, term, exactTerm);\r\n\r\n if (clone.hidden === true) {\r\n this.#deactivateOption(clone);\r\n deleteCustomState(clone, \"-first\");\r\n deleteCustomState(clone, \"-last\");\r\n } else {\r\n newCount++;\r\n if (!first && !(clone.parentElement instanceof M3eOptGroupElement)) {\r\n addCustomState(clone, \"-first\");\r\n first = true;\r\n addCustomState(clone, \"-last\");\r\n last = clone;\r\n } else {\r\n deleteCustomState(clone, \"-first\");\r\n if (last) {\r\n deleteCustomState(last, \"-last\");\r\n }\r\n addCustomState(clone, \"-last\");\r\n last = clone;\r\n }\r\n }\r\n }\r\n\r\n if (this.#menu) {\r\n this.#updateMenuState(this.#menu, newCount);\r\n }\r\n\r\n const groups = this.#menu?.querySelectorAll(\"m3e-optgroup\") ?? this.#clone?.querySelectorAll(\"m3e-optgroup\") ?? [];\r\n for (const group of groups) {\r\n group.hidden = [...group.querySelectorAll(\"m3e-option\")].every((x) => x.hidden === true);\r\n }\r\n\r\n if (shouldAnnounce) {\r\n this.#announceResults(oldCount, newCount);\r\n }\r\n\r\n this.#autoActivate();\r\n return newCount;\r\n }\r\n\r\n /** @private */\r\n #clearOptions(): boolean {\r\n const selected = this._listKeyManager.items.filter((x) => x.selected);\r\n if (selected.length > 0) {\r\n selected.forEach((x) => {\r\n x.selected = false;\r\n this.#updateSelectionState(x);\r\n });\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /** @private */\r\n #announceResults(oldCount: number, newCount: number): void {\r\n if (!this.#hasFocus) return;\r\n if (newCount == 0) {\r\n if (oldCount > 0 && this.noDataLabel) {\r\n M3eLiveAnnouncer.announce(this.noDataLabel, \"polite\");\r\n }\r\n } else if (oldCount != newCount) {\r\n const message = this.resultsLabel instanceof Function ? this.resultsLabel(newCount) : this.resultsLabel;\r\n if (message) {\r\n M3eLiveAnnouncer.announce(message, \"polite\");\r\n }\r\n }\r\n }\r\n\r\n /** @private */\r\n #autoActivate(): void {\r\n if (this.autoActivate && (!this._listKeyManager.activeItem || !this._listKeyManager.activeItem.selected)) {\r\n const option = this.#options.find((x) => !x.disabled && x.hidden === false);\r\n if (option) {\r\n this._listKeyManager.setActiveItem(option);\r\n if (this.#menu) {\r\n scrollIntoViewIfNeeded(option, this.#menu, { block: \"nearest\", behavior: \"instant\" });\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** @private */\r\n #deactivateOption(option: M3eOptionElement): void {\r\n option.focusRing?.hide();\r\n option.stateLayer?.hide(\"focused\");\r\n if (option === this._listKeyManager.activeItem) {\r\n this._listKeyManager.updateActiveItem(null);\r\n this.#input?.removeAttribute(\"aria-activedescendant\");\r\n }\r\n }\r\n}\r\n\r\ninterface M3eAutocompleteElementEventMap extends HTMLElementEventMap {\r\n toggle: ToggleEvent;\r\n query: CustomEvent<AutocompleteQueryEventDetail>;\r\n}\r\n\r\nexport interface M3eAutocompleteElement {\r\n addEventListener<K extends keyof M3eAutocompleteElementEventMap>(\r\n type: K,\r\n listener: (this: M3eAutocompleteElement, ev: M3eAutocompleteElementEventMap[K]) => void,\r\n options?: boolean | AddEventListenerOptions,\r\n ): void;\r\n\r\n addEventListener(\r\n type: string,\r\n listener: EventListenerOrEventListenerObject,\r\n options?: boolean | AddEventListenerOptions,\r\n ): void;\r\n\r\n removeEventListener<K extends keyof M3eAutocompleteElementEventMap>(\r\n type: K,\r\n listener: (this: M3eAutocompleteElement, ev: M3eAutocompleteElementEventMap[K]) => void,\r\n options?: boolean | EventListenerOptions,\r\n ): void;\r\n\r\n removeEventListener(\r\n type: string,\r\n listener: EventListenerOrEventListenerObject,\r\n options?: boolean | EventListenerOptions,\r\n ): void;\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-autocomplete\": M3eAutocompleteElement;\r\n }\r\n}\r\n"],"names":["M3eAutocompleteElement","M3eAutocompleteElement_1","EventAttribute","HtmlFor","LitElement","constructor","super","_M3eAutocompleteElement_id","set","this","__nextId","_M3eAutocompleteElement_menuId","__classPrivateFieldGet","_options","Array","_M3eAutocompleteElement_clone","_M3eAutocompleteElement_ignoreFocusVisible","_M3eAutocompleteElement_menu","_M3eAutocompleteElement_ignoreHideMenuOnBlur","_M3eAutocompleteElement_inputChanged","_M3eAutocompleteElement_hasFocus","_M3eAutocompleteElement_mutationAbortController","_M3eAutocompleteElement_clickHandler","_M3eAutocompleteElement_instances","_M3eAutocompleteElement_handleClick","call","_M3eAutocompleteElement_formFieldPointerDownHandler","_M3eAutocompleteElement_handleFormFieldPointerDown","_M3eAutocompleteElement_focusHandler","_M3eAutocompleteElement_handleFocus","_M3eAutocompleteElement_blurHandler","_M3eAutocompleteElement_handleBlur","_M3eAutocompleteElement_keyDownHandler","e","_M3eAutocompleteElement_inputHandler","_M3eAutocompleteElement_changeHandler","_M3eAutocompleteElement_handleChange","_M3eAutocompleteElement_menuToggleHandler","_M3eAutocompleteElement_menuPointerDownHandler","_listKeyManager","ListKeyManager","withWrap","withHomeAndEnd","withPageUpAndDown","withVerticalOrientation","withSkipPredicate","item","disabled","hidden","onActiveItemChange","activeItem","_M3eAutocompleteElement_activateOption","hideSelectionIndicator","required","autoActivate","caseSensitive","filter","loading","hideNoData","hideLoading","loadingLabel","noDataLabel","resultsLabel","count","panelClass","MutationController","config","childList","subtree","callback","_M3eAutocompleteElement_handleMutation","options","selected","find","x","value","attach","control","HTMLInputElement","autocomplete","role","ariaAutoComplete","ariaExpanded","addEventListener","_M3eAutocompleteElement_formField_get","detach","removeEventListener","clear","restoreFocus","_M3eAutocompleteElement_input_get","_M3eAutocompleteElement_clearOptions","dispatchEvent","Event","bubbles","_M3eAutocompleteElement_filterOptions","focus","_M3eAutocompleteElement_hideMenu","connectedCallback","update","changedProperties","has","setCustomState","M3eLiveAnnouncer","announce","_M3eAutocompleteElement_shouldShowMenu_get","_M3eAutocompleteElement_showMenu","deleteCustomState","render","html","items","querySelector","_M3eAutocompleteElement_options_get","some","length","closest","async","abort","mutationAbortController","AbortController","__classPrivateFieldSet","querySelectorAll","option","signal","aborted","isUpdatePending","updateComplete","cloneNode","added","setItems","forEach","id","indexOf","_M3eAutocompleteElement_projectClone","_M3eAutocompleteElement_updateMenuState","readOnly","CustomEvent","detail","term","composed","defaultPrevented","notifyControlStateChange","label","key","preventDefault","_M3eAutocompleteElement_selectOption","prefersReducedMotion","setTimeout","altKey","onKeyDown","button","stopImmediatePropagation","composedPath","HTMLElement","tagName","setActiveItem","newState","scrollIntoViewIfNeeded","_M3eAutocompleteElement_autoActivate","ToggleEvent","oldState","_M3eAutocompleteElement_destroyMenu","replaceChildren","childNodes","remove","undefined","removeAttribute","requestUpdate","slot","parentElement","document","createElement","klass","split","map","d","trim","Boolean","classList","add","style","overflowX","scrollStrategy","fitAnchorWidth","insertAdjacentElement","setAttribute","input","show","menuAnchor","children","_M3eAutocompleteElement_hasNoDataSlot_get","noDataSpan","textContent","push","_M3eAutocompleteElement_hasLoadingSlot_get","loadingSpan","menu","hide","forceFocusVisible","block","behavior","focusVisible","matches","forcedColorsActive","focusRing","stateLayer","clone","_M3eAutocompleteElement_updateSelectionState","_M3eAutocompleteElement_filterOption","exactTerm","toLowerCase","highlightMode","startsWith","endsWith","includes","disableHighlight","oldCount","shouldAnnounce","toLocaleLowerCase","last","newCount","first","i","_M3eAutocompleteElement_deactivateOption","M3eOptGroupElement","addCustomState","groups","group","every","_M3eAutocompleteElement_announceResults","message","Function","updateActiveItem","styles","css","__decorate","property","attribute","type","prototype","reflect","converter","fromAttribute","customElement"],"mappings":";;;;;uqBAwEO,IAAMA,G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 'tslib';
7
- import { customElement, ActionElementBase, EventAttribute, ReconnectedCallback, SuppressInitialAnimation, AttachInternals, VelocityTracker, ScrollLockController, ResizeController, focusWhenReady, setCustomState, hasAssignedNodes, hasCustomState, computeCssSize, prefersReducedMotion, DesignToken, spaceSeparatedStringConverter, HtmlFor } from '@m3e/web/core';
7
+ import { customElement, ActionElementBase, EventAttribute, ReconnectedCallback, SuppressInitialAnimation, AttachInternals, VelocityTracker, ScrollLockController, InertController, ResizeController, focusWhenReady, setCustomState, hasAssignedNodes, hasCustomState, computeCssSize, prefersReducedMotion, registerStyleSheet, DesignToken, spaceSeparatedStringConverter, HtmlFor } from '@m3e/web/core';
8
8
  import { LitElement, nothing, html, css, unsafeCSS } from 'lit';
9
9
  import { property } from 'lit/decorators.js';
10
10
  import { M3eInteractivityChecker, isModifierAllowed, addAriaReferencedId, removeAriaReferencedId } from '@m3e/web/core/a11y';
@@ -23,7 +23,7 @@ let M3eBottomSheetActionElement = class M3eBottomSheetActionElement extends Acti
23
23
  };
24
24
  M3eBottomSheetActionElement = __decorate([customElement("m3e-bottom-sheet-action")], M3eBottomSheetActionElement);
25
25
 
26
- var _M3eBottomSheetElement_instances, _M3eBottomSheetElement_documentClickHandler, _M3eBottomSheetElement_documentKeyDownHandler, _M3eBottomSheetElement_windowResizeHandler, _M3eBottomSheetElement_inerts, _M3eBottomSheetElement_velocityTracker, _M3eBottomSheetElement_scrollLockController, _M3eBottomSheetElement_resizeController, _M3eBottomSheetElement_trigger, _M3eBottomSheetElement_dragState, _M3eBottomSheetElement_dragged, _M3eBottomSheetElement_activeDetent, _M3eBottomSheetElement_requestDetent, _M3eBottomSheetElement_cachedContentHeight, _M3eBottomSheetElement_cachedHeaderHeight, _M3eBottomSheetElement_snapAnimation, _M3eBottomSheetElement_initialize, _M3eBottomSheetElement_handleHeaderSlotChange, _M3eBottomSheetElement_handleHeaderPointerDown, _M3eBottomSheetElement_handleHeaderPointerMove, _M3eBottomSheetElement_handleHeaderPointerUp, _M3eBottomSheetElement_handleDocumentClick, _M3eBottomSheetElement_handleDocumentKeyDown, _M3eBottomSheetElement_handleWindowResize, _M3eBottomSheetElement_handleDragHandleClick, _M3eBottomSheetElement_handleDragHandleKeyDown, _M3eBottomSheetElement_getNextHigherDetent, _M3eBottomSheetElement_getNextLowerDetent, _M3eBottomSheetElement_getClosestDetent, _M3eBottomSheetElement_computeDetentHeight, _M3eBottomSheetElement_computeMaxHeight, _M3eBottomSheetElement_computeMinHeight, _M3eBottomSheetElement_computePeekHeight, _M3eBottomSheetElement_computeFitHeight, _M3eBottomSheetElement_handleSectionResize, _M3eBottomSheetElement_snapToDetent, _M3eBottomSheetElement_snapToHeight, _M3eBottomSheetElement_updateHeight, _M3eBottomSheetElement_applyInert, _M3eBottomSheetElement_restoreInert;
26
+ var _M3eBottomSheetElement_instances, _M3eBottomSheetElement_documentClickHandler, _M3eBottomSheetElement_documentKeyDownHandler, _M3eBottomSheetElement_windowResizeHandler, _M3eBottomSheetElement_velocityTracker, _M3eBottomSheetElement_scrollLockController, _M3eBottomSheetElement_inertController, _M3eBottomSheetElement_resizeController, _M3eBottomSheetElement_trigger, _M3eBottomSheetElement_dragState, _M3eBottomSheetElement_dragged, _M3eBottomSheetElement_activeDetent, _M3eBottomSheetElement_requestDetent, _M3eBottomSheetElement_cachedContentHeight, _M3eBottomSheetElement_cachedHeaderHeight, _M3eBottomSheetElement_snapAnimation, _M3eBottomSheetElement_initialize, _M3eBottomSheetElement_handleHeaderSlotChange, _M3eBottomSheetElement_handleHeaderPointerDown, _M3eBottomSheetElement_handleHeaderPointerMove, _M3eBottomSheetElement_handleHeaderPointerUp, _M3eBottomSheetElement_handleDocumentClick, _M3eBottomSheetElement_handleDocumentKeyDown, _M3eBottomSheetElement_handleWindowResize, _M3eBottomSheetElement_handleDragHandleClick, _M3eBottomSheetElement_handleDragHandleKeyDown, _M3eBottomSheetElement_getNextHigherDetent, _M3eBottomSheetElement_getNextLowerDetent, _M3eBottomSheetElement_getClosestDetent, _M3eBottomSheetElement_computeDetentHeight, _M3eBottomSheetElement_computeMaxHeight, _M3eBottomSheetElement_computeMinHeight, _M3eBottomSheetElement_computePeekHeight, _M3eBottomSheetElement_computeFitHeight, _M3eBottomSheetElement_handleSectionResize, _M3eBottomSheetElement_snapToDetent, _M3eBottomSheetElement_snapToHeight, _M3eBottomSheetElement_updateHeight;
27
27
  var M3eBottomSheetElement_1;
28
28
  /**
29
29
  * A sheet used to show secondary content anchored to the bottom of the screen.
@@ -133,12 +133,12 @@ let M3eBottomSheetElement = M3eBottomSheetElement_1 = class M3eBottomSheetElemen
133
133
  /** @private */
134
134
  _M3eBottomSheetElement_windowResizeHandler.set(this, () => __classPrivateFieldGet(this, _M3eBottomSheetElement_instances, "m", _M3eBottomSheetElement_handleWindowResize).call(this));
135
135
  /** @private */
136
- _M3eBottomSheetElement_inerts.set(this, new Array());
137
- /** @private */
138
136
  _M3eBottomSheetElement_velocityTracker.set(this, new VelocityTracker());
139
137
  /** @private */
140
138
  _M3eBottomSheetElement_scrollLockController.set(this, new ScrollLockController(this));
141
139
  /** @private */
140
+ _M3eBottomSheetElement_inertController.set(this, new InertController(this));
141
+ /** @private */
142
142
  _M3eBottomSheetElement_resizeController.set(this, new ResizeController(this, {
143
143
  target: null,
144
144
  skipInitial: true,
@@ -308,7 +308,7 @@ let M3eBottomSheetElement = M3eBottomSheetElement_1 = class M3eBottomSheetElemen
308
308
  if (this.modal) {
309
309
  if (this.open) {
310
310
  __classPrivateFieldSet(this, _M3eBottomSheetElement_trigger, document.activeElement, "f");
311
- __classPrivateFieldGet(this, _M3eBottomSheetElement_instances, "m", _M3eBottomSheetElement_applyInert).call(this);
311
+ __classPrivateFieldGet(this, _M3eBottomSheetElement_inertController, "f").lock();
312
312
  __classPrivateFieldGet(this, _M3eBottomSheetElement_scrollLockController, "f").lock();
313
313
  this.showPopover();
314
314
  requestAnimationFrame(() => {
@@ -324,7 +324,7 @@ let M3eBottomSheetElement = M3eBottomSheetElement_1 = class M3eBottomSheetElemen
324
324
  }
325
325
  } else {
326
326
  __classPrivateFieldGet(this, _M3eBottomSheetElement_instances, "m", _M3eBottomSheetElement_snapToHeight).call(this, 0).then(() => {
327
- __classPrivateFieldGet(this, _M3eBottomSheetElement_instances, "m", _M3eBottomSheetElement_restoreInert).call(this);
327
+ __classPrivateFieldGet(this, _M3eBottomSheetElement_inertController, "f").unlock();
328
328
  __classPrivateFieldGet(this, _M3eBottomSheetElement_scrollLockController, "f").unlock();
329
329
  document.removeEventListener("click", __classPrivateFieldGet(this, _M3eBottomSheetElement_documentClickHandler, "f"));
330
330
  document.removeEventListener("keydown", __classPrivateFieldGet(this, _M3eBottomSheetElement_documentKeyDownHandler, "f"));
@@ -347,9 +347,9 @@ let M3eBottomSheetElement = M3eBottomSheetElement_1 = class M3eBottomSheetElemen
347
347
  _M3eBottomSheetElement_documentClickHandler = new WeakMap();
348
348
  _M3eBottomSheetElement_documentKeyDownHandler = new WeakMap();
349
349
  _M3eBottomSheetElement_windowResizeHandler = new WeakMap();
350
- _M3eBottomSheetElement_inerts = new WeakMap();
351
350
  _M3eBottomSheetElement_velocityTracker = new WeakMap();
352
351
  _M3eBottomSheetElement_scrollLockController = new WeakMap();
352
+ _M3eBottomSheetElement_inertController = new WeakMap();
353
353
  _M3eBottomSheetElement_resizeController = new WeakMap();
354
354
  _M3eBottomSheetElement_trigger = new WeakMap();
355
355
  _M3eBottomSheetElement_dragState = new WeakMap();
@@ -658,27 +658,8 @@ _M3eBottomSheetElement_updateHeight = function _M3eBottomSheetElement_updateHeig
658
658
  content.inert = height <= __classPrivateFieldGet(this, _M3eBottomSheetElement_instances, "m", _M3eBottomSheetElement_computePeekHeight).call(this);
659
659
  }
660
660
  };
661
- _M3eBottomSheetElement_applyInert = function _M3eBottomSheetElement_applyInert() {
662
- __classPrivateFieldGet(this, _M3eBottomSheetElement_inerts, "f").length = 0;
663
- for (let current = this; current.parentNode && current.parentNode !== document.documentElement; current = current.parentNode) {
664
- for (const sibling of current.parentNode.children) {
665
- if (sibling instanceof HTMLElement && sibling !== current && !sibling.inert) {
666
- sibling.inert = true;
667
- __classPrivateFieldGet(this, _M3eBottomSheetElement_inerts, "f").push(sibling);
668
- }
669
- }
670
- }
671
- };
672
- _M3eBottomSheetElement_restoreInert = function _M3eBottomSheetElement_restoreInert() {
673
- __classPrivateFieldGet(this, _M3eBottomSheetElement_inerts, "f").forEach(x => x.inert = false);
674
- __classPrivateFieldGet(this, _M3eBottomSheetElement_inerts, "f").length = 0;
675
- };
676
661
  (() => {
677
- if (typeof window !== "undefined") {
678
- const lightDomStyle = new CSSStyleSheet();
679
- lightDomStyle.replaceSync(css`@property --_bottom-sheet-height { syntax: "<length>"; inherits: false; initial-value: 50vh; } m3e-bottom-sheet > [slot="header"] { margin-block-end: var(--m3e-bottom-sheet-padding-block, 0.5rem); margin-inline: var(--m3e-bottom-sheet-padding-inline, 1rem); }</length>`.toString());
680
- document.adoptedStyleSheets.push(lightDomStyle);
681
- }
662
+ registerStyleSheet(css`@property --_bottom-sheet-height { syntax: "<length>"; inherits: false; initial-value: 50vh; } m3e-bottom-sheet > [slot="header"] { margin-block-end: var(--m3e-bottom-sheet-padding-block, 0.5rem); margin-inline: var(--m3e-bottom-sheet-padding-inline, 1rem); }</length>`);
682
663
  })();
683
664
  /** The styles of the element. */
684
665
  M3eBottomSheetElement.styles = css`:host { display: block; position: fixed; left: 50%; top: calc(100vh - var(--_bottom-sheet-height)); margin: 0; padding: 0; outline: none; overflow: hidden; border: none; box-sizing: border-box; width: var(--m3e-bottom-sheet-width, 100%); max-width: var(--m3e-bottom-sheet-max-width, 40rem); height: var(--_bottom-sheet-height); color: var(--m3e-bottom-sheet-color, ${DesignToken.color.onSurface}); background-color: var(--m3e-bottom-sheet-container-color, ${DesignToken.color.surfaceContainerLow}); } :host(:not(:state(-no-animate))) { transition: ${unsafeCSS(`transform ${DesignToken.motion.duration.medium2} ${DesignToken.motion.easing.standardDecelerate},