impulse_view_components 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2ca819dd465cf051e5f491cf15e443b4d613ddb4d558cd027cd4bde2717fb98
4
- data.tar.gz: d652ab57246abb80813b1d5a4a9d88e32049955b65a469348682adc087d5bb4c
3
+ metadata.gz: c85a72c048edb99f2439af9f408ab3fdc30794889e24335e6c2d0926daa1fd36
4
+ data.tar.gz: b5369b1cf7a7d5b76b229f4b1597e93e71e7a558f1ce4b17ce9af3cb8ff7c6e4
5
5
  SHA512:
6
- metadata.gz: 7b5cabae9226e3dbbb47d480483671b1e70331feea18d1fc190d285bf8170abcfd62c28e1ebe070032ba1730c8b546e4d54a4607f6ce908f34c8e86b3204359a
7
- data.tar.gz: '0833b9322fb8faf1b4d44ee47af57d40f749807891cea90dd15dc92a179cc52eafb12585592ff750510cde4c1c6ec0fa1df07d095c9d0f5981bd723a691ec07b'
6
+ metadata.gz: cc592005753da244fbe40ed11b73bc6490cd179d8e5f18c46bbb2644d91885aec1085112a5ed2c2b7e113f0baea45263780be3a541e992e892f96df765400ba4
7
+ data.tar.gz: a351fdbf9ed384466945c2e39bbc4d1122c5b1ba11d9be6e9ee4754c50540fd863bec5d6197a562fb9b990d7cf4b42ac25eb58db4dd6a298faa8a7fe822cb3fe
data/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.2] - 2023-07-31
11
+
12
+ ### Changed
13
+
14
+ - Drop build target to `2017`
15
+ - Bump impulse version
16
+
10
17
  ## [0.1.1] - 2023-07-31
11
18
 
12
19
  ### Fixed
@@ -20,5 +27,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
20
27
  - Everything!
21
28
 
22
29
  [unreleased]: https://github.com/Ambiki/impulse_view_components/compare/v0.1.1...HEAD
30
+ [0.1.2]: https://github.com/Ambiki/impulse_view_components/compare/v0.1.1...v0.1.2
23
31
  [0.1.1]: https://github.com/Ambiki/impulse_view_components/compare/v0.1.0...v0.1.1
24
32
  [0.1.0]: https://github.com/Ambiki/impulse_view_components/releases/tag/v0.1.0
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@floating-ui/dom")):"function"==typeof define&&define.amd?define(["@floating-ui/dom"],e):e(("undefined"!=typeof globalThis?globalThis:t||self).FloatingUIDOM)}(this,function(g){"use strict";function t(t,e,i,s){var n,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;0<=a;a--)(n=t[a])&&(r=(o<3?n(r):3<o?n(e,i,r):n(e,i))||r);return 3<o&&r&&Object.defineProperty(e,i,r),r}var e=0;function s(){return e+=1,`ambiki-${Math.random().toString().slice(2,6)}-`+e}function i(t){return!t.hasAttribute("disabled")&&"true"!==t.getAttribute("aria-disabled")}var D=!!navigator.userAgent.match(/Macintosh/),q=class{input;list;multiple;isMouseMoving=!1;constructor(t,e,{multiple:i=!1}={}){this.input=t,this.list=e,this.multiple=i,this.list.id||(this.list.id=s()),this.input.getAttribute("aria-expanded")||this.input.setAttribute("aria-expanded","false"),this.multiple&&this.input.setAttribute("aria-multiselectable","true"),this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-haspopup","listbox"),this.input.setAttribute("aria-autocomplete","list"),this.list.setAttribute("role","listbox"),this.onKeydown=this.onKeydown.bind(this),this.onClick=this.onClick.bind(this),this.onListMouseover=this.onListMouseover.bind(this),this.onListMousemove=this.onListMousemove.bind(this)}start(){this.isMouseMoving=!1,this.input.setAttribute("aria-expanded","true"),this.input.setAttribute("aria-controls",this.list.id),this.input.addEventListener("keydown",this.onKeydown),this.list.addEventListener("click",this.onClick),this.list.addEventListener("mouseover",this.onListMouseover),this.list.addEventListener("mousemove",this.onListMousemove),this.initializeOptions()}stop(){this.isMouseMoving=!1,this.input.setAttribute("aria-expanded","false"),this.input.removeAttribute("aria-controls"),this.input.removeEventListener("keydown",this.onKeydown),this.list.removeEventListener("click",this.onClick),this.list.removeEventListener("mouseover",this.onListMouseover),this.list.removeEventListener("mousemove",this.onListMousemove),this.deselectAll(),this.deactivate()}onKeydown(t){if(this.isMouseMoving=!1,!(t.shiftKey||t.metaKey||t.altKey||!D&&t.ctrlKey))switch(t.key){case"Enter":case"Tab":this.activeOption&&i(this.activeOption)&&(t.preventDefault(),t.stopPropagation(),this.activeOption.click());break;case"Escape":this.deactivate();break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.activeOption?this.move(1):this.activate(this.visibleOptions[0],{scroll:!0});break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),this.activeOption?this.move(-1):this.activate(this.visibleOptions[this.visibleOptions.length-1],{scroll:!0});break;case"Home":t.preventDefault(),t.stopPropagation(),this.activate(this.visibleOptions[0],{scroll:!0});break;case"End":t.preventDefault(),t.stopPropagation(),this.activate(this.visibleOptions[this.visibleOptions.length-1],{scroll:!0});break;default:t.ctrlKey||this.deactivate()}}onClick(t){t=n(t.target);t&&i(t)&&(this.multiple&&this.isSelected(t)?this.deselect(t):this.select(t),t.dispatchEvent(new CustomEvent("combobox:commit",{bubbles:!0})))}onListMouseover(t){var e;this.isMouseMoving?(e=n(t.target))&&this.activate(e):t.preventDefault()}onListMousemove(t){!this.isMouseMoving&&(this.isMouseMoving=!0,t=n(t.target))&&this.activate(t)}select(t){if(this.multiple)t.setAttribute("aria-selected","true");else for(var e of this.options)e.setAttribute("aria-selected",(e===t).toString())}deselect(t){t.setAttribute("aria-selected","false")}deselectAll(){for(var t of this.options)this.deselect(t)}activate(t,{scroll:e=!1}={}){for(var i of this.options)i.id===t.id?(i.setAttribute("data-active",""),this.input.setAttribute("aria-activedescendant",i.id),e&&i.scrollIntoView({block:"nearest"})):i.removeAttribute("data-active")}deactivate(){this.input.removeAttribute("aria-activedescendant");for(var t of Array.from(this.list.querySelectorAll('[role="option"][data-active]')))t.removeAttribute("data-active")}isSelected(t){return"true"===t.getAttribute("aria-selected")}get options(){return Array.from(this.list.querySelectorAll('[role="option"]'))}get visibleOptions(){return this.options.filter(K)}get activeOption(){return this.list.querySelector("[data-active]")}move(t){this.activeOption&&(t=function(t,e,i){let s=t.indexOf(e),n=(s===t.length-1&&1===i&&(s=-1),1===i?0:t.length-1);return t[n=e&&0<=s&&0<=(e=s+i)&&e<t.length?e:n]}(this.visibleOptions,this.activeOption,t),this.activate(t,{scroll:!0}))}initializeOptions(){for(var t of this.options)t.setAttribute("tabindex","-1"),t.id||(t.id=s()),t.hasAttribute("aria-selected")||this.deselect(t)}};function n(t){return t&&t.closest('[role="option"]')||!1}function K(t){return!t.hidden&&!(t instanceof HTMLInputElement&&"hidden"===t.type)&&(0<t.offsetWidth||0<t.offsetHeight)}const o=Symbol.for("impulse");class r{constructor(t,e){this.proto=t,this.name=e,this.map=new Map,this.proto=t,this.name=e,this.initialize()}add(t){this.value?.add(t)}get value(){return this.map.get(this.name)}initialize(){Object.prototype.hasOwnProperty.call(this.proto,o)||(this.proto[o]=new Map),this.map=this.proto[o],this.map.has(this.name)||this.map.set(this.name,new Set)}}function a({type:i=String}={}){return(t,e)=>{new r(t,"property").add({key:e,type:i})}}function l(e){return t=>{try{window.customElements.define(e,t),window[t.name]=customElements.get(e)}catch(t){if(!(t instanceof DOMException&&"NotSupportedError"===t.name))throw t}}}function c(){return(t,e)=>{new r(t,"target").add({key:e})}}const F=/^(?:(.+?)?(?:@(window|document))?->)?(.+)#(.+)?$/;function U(t){var[,t,e,i,s]=t.trim().match(F)||[];return{eventName:t,eventTarget:"window"===(t=e)?window:"document"===t?document:void 0,methodName:s,identifier:i}}class j{constructor(){this.map=new Map}add(t,e){h(this.map,t).add(e)}delete(t,e){h(this.map,t).delete(e),0===this.get(t)?.size&&this.map.delete(t)}clear(){this.map.clear()}get values(){return Array.from(this.map.values()).reduce((t,e)=>t.concat(Array.from(e)),[])}get(t){return this.map.get(t)}has(t,e){return!!this.get(t)?.has(e)}}function h(t,e){let i=t.get(e);return i||(i=new Set,t.set(e,i)),i}class B{constructor(t,e,i,s){this.instance=t,this.eventTarget=e,this.eventName=i,this.methodName=s,this.instance=t,this.eventTarget=e,this.eventName=i,this.methodName=s}start(){this.eventTarget.addEventListener(this.eventName,this)}stop(){this.eventTarget.removeEventListener(this.eventName,this)}handleEvent(t){var e=this.instance[this.methodName];"function"==typeof e&&e.call(this.instance,t)}}function u(t,e){return t.getAttribute(e)?.trim().split(/\s+/)||[]}class z{constructor(t,e,i){this.element=t,this.delegate=e,this.observerOptions=i,this.started=!1,this.element=t,this.delegate=e,this.observer=new MutationObserver(t=>this.processMutations(t)),this.observerOptions=i}start(){this.started||(this.started=!0,this.observer.observe(this.element,{childList:!0,subtree:!0,...this.observerOptions}))}stop(){this.started&&(this.observer.takeRecords(),this.observer.disconnect(),this.started=!1)}processMutations(t){if(this.started)for(const e of t)this.processMutation(e)}processMutation(t){"attributes"===t.type&&t.target instanceof Element?this.processAttributeChange(t.target,t.attributeName):"childList"===t.type&&(this.processRemovedNodes(t.removedNodes),this.processAddedNodes(t.addedNodes))}processAttributeChange(t,e){e&&this.delegate.elementAttributeChanged(t,e)}processRemovedNodes(t){for(const i of Array.from(t)){var e=this.elementFromNode(i);e&&this.delegate.elementDisconnected(e)}}processAddedNodes(t){for(const i of Array.from(t)){var e=this.elementFromNode(i);e&&this.elementIsActive(e)&&this.delegate.elementConnected(e)}}elementFromNode(t){if(t.nodeType===Node.ELEMENT_NODE)return t}elementIsActive(t){return t.isConnected===this.element.isConnected&&this.element.contains(t)}}class d{constructor(t,e,i){this.instance=t,this.attributeName=e,this.delegate=i,this.instance=t,this.attributeName=e,this.elementObserver=new z(this.instance,this,{attributeFilter:[this.attributeName]}),this.delegate=i}start(){this.elementObserver.start()}stop(){this.elementObserver.stop()}elementConnected(t){var e=Array.from(t.querySelectorAll(`[${this.attributeName}]`));t.hasAttribute(this.attributeName)&&e.push(t);for(const i of e)this.delegate.elementConnected(i)}elementDisconnected(t){var e=Array.from(t.querySelectorAll(`[${this.attributeName}]`));t.hasAttribute(this.attributeName)&&e.push(t);for(const i of e)this.delegate.elementDisconnected(i)}elementAttributeChanged(t,e){e===this.attributeName&&this.delegate.elementAttributeChanged?.(t,e)}}const p="data-action";class ${constructor(t){this.instance=t,this.eventListenerMap=new j,this.instance=t,this.attributeObserver=new d(this.instance,p,this)}start(){this.attributeObserver.start();var t=Array.from(this.instance.querySelectorAll(`[${p}]`));this.instance.hasAttribute(p)&&t.push(this.instance),t.forEach(t=>this.bindActions(t))}stop(){this.eventListenerMap.values.forEach(t=>t.stop()),this.eventListenerMap.clear(),this.attributeObserver.stop()}elementConnected(t){this.bindActions(t)}elementDisconnected(t){this.unbindActions(t)}elementAttributeChanged(t){this.unbindActions(t),this.bindActions(t)}bindActions(n){u(n,p).forEach(t=>{var{eventName:t,eventTarget:e,methodName:i,identifier:s}=U(t);t&&s===this.identifier&&i&&(s=new B(this.instance,e||n,t,i),this.eventListenerMap.add(n,s),s.start())})}unbindActions(e){var t=this.eventListenerMap.get(e);t&&t.forEach(t=>{t.stop(),this.eventListenerMap.delete(e,t)})}get identifier(){return this.instance.identifier}}const _=/(-|_|\.|\s)+(.)?/g,H=/(^|\/)([A-Z])/g,J=/[ _]/g,Q=/([a-z\d])([A-Z])/g;function m(t){return t.replace(Q,"$1_$2").toLowerCase().replace(J,"-")}function f(t,e=""){if(!t)return e;try{return JSON.parse(t)}catch{return e}}class Z{constructor(t){this.instance=t,this.instance=t,this.store=new r(Object.getPrototypeOf(this.instance),"property")}start(){for(var[{key:t,type:e}]of this.values.entries())this.initializeProperty(t,e)}stop(){}initializeProperty(t,e){var i=m(t),s=this.instance[t],e={configurable:!0,...function(e,i,t){switch(t){case Number:return{get:()=>Number(e.getAttribute(i)||0),set:t=>e.setAttribute(i,(t||0).toString())};case Boolean:return{get:()=>e.hasAttribute(i)&&"false"!==e.getAttribute(i),set:t=>{t?e.setAttribute(i,""):e.removeAttribute(i)}};case Array:return{get:()=>JSON.parse(e.getAttribute(i)||"[]"),set:t=>e.setAttribute(i,JSON.stringify(t)||"[]")};case Object:return{get:()=>JSON.parse(e.getAttribute(i)||"{}"),set:t=>e.setAttribute(i,JSON.stringify(t)||"{}")};default:return{get:()=>e.getAttribute(i)||"",set:t=>e.setAttribute(i,t||"")}}}(this.instance,i,e)};Object.defineProperty(this.instance,t,e),this.instance.hasAttribute(i)||e.set?.(s)}get values(){return this.store.value}}const v="data-target";class G{constructor(t){this.instance=t,this.instance=t,this.store=new r(Object.getPrototypeOf(this.instance),"target"),this.attributeObserver=new d(this.instance,v,this)}start(){this.attributeObserver.start(),this.targetKeys.forEach(t=>this.initializeKey(t))}stop(){this.targetKeys.forEach(t=>this.terminateKey(t)),this.attributeObserver.stop()}elementConnected(i){u(i,v).forEach(t=>{var[t,e]=t.split(".");t&&e&&t===this.identifier&&this.targetKeys.includes(e)&&(this.defineProperty(e,i),this.processAddedElement(e,i))})}elementDisconnected(i){u(i,v).forEach(t=>{var[t,e]=t.split(".");t&&e&&t===this.identifier&&this.targetKeys.includes(e)&&(this.processRemovedElement(e,i),this.defineProperty(e,null))})}initializeKey(t){var e;this.targetKeys.includes(t)&&(e=this.findTarget(t),this.defineProperty(t,e),e)&&this.processAddedElement(t,e)}terminateKey(t){var e;this.targetKeys.includes(t)&&(e=this.findTarget(t))&&this.processRemovedElement(t,e)}defineProperty(t,e){Object.defineProperty(this.instance,t,{configurable:!0,get:()=>e})}processAddedElement(t,e){t=this.instance[t+"Connected"];"function"==typeof t&&t.call(this.instance,e)}processRemovedElement(t,e){t=this.instance[t+"Disconnected"];"function"==typeof t&&t.call(this.instance,e)}findTarget(t){t=`[${v}~="${this.identifier}.${t}"]`;return this.instance.querySelector(t)}get targetKeys(){return Array.from(this.store.value).map(({key:t})=>t)}get identifier(){return this.instance.identifier}}const b="data-target";class W{constructor(t){this.instance=t,this.instance=t,this.store=new r(Object.getPrototypeOf(this.instance),"targets"),this.attributeObserver=new d(this.instance,b,this)}start(){this.attributeObserver.start(),this.targetKeys.forEach(t=>this.initializeKey(t))}stop(){this.targetKeys.forEach(t=>this.terminateKey(t)),this.attributeObserver.stop()}elementConnected(i){u(i,b).forEach(t=>{var[t,e]=t.split(".");t&&e&&t===this.identifier&&this.targetKeys.includes(e)&&(this.defineProperty(e,this.findTargets(e)),this.processAddedElement(e,i))})}elementDisconnected(i){u(i,b).forEach(t=>{var[t,e]=t.split(".");t&&e&&t===this.identifier&&this.targetKeys.includes(e)&&(this.processRemovedElement(e,i),this.defineProperty(e,this.findTargets(e)))})}initializeKey(e){var t;this.targetKeys.includes(e)&&(t=this.findTargets(e),this.defineProperty(e,t),t.forEach(t=>this.processAddedElement(e,t)))}terminateKey(e){this.targetKeys.includes(e)&&this.findTargets(e).forEach(t=>this.processRemovedElement(e,t))}defineProperty(t,e){Object.defineProperty(this.instance,t,{configurable:!0,get:()=>e})}processAddedElement(t,e){t=this.instance[t+"Connected"];"function"==typeof t&&t.call(this.instance,e)}processRemovedElement(t,e){t=this.instance[t+"Disconnected"];"function"==typeof t&&t.call(this.instance,e)}findTargets(t){t=`[${b}~="${this.identifier}.${t}"]`;return Array.from(this.instance.querySelectorAll(t))}get targetKeys(){return Array.from(this.store.value).map(({key:t})=>t)}get identifier(){return this.instance.identifier}}class y extends HTMLElement{constructor(){super(...arguments),this.property=new Z(this),this.targets=new W(this),this.target=new G(this),this.action=new $(this),this._started=!1}async connectedCallback(){await new Promise(t=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>t()):t()}),customElements.upgrade(this),this.property.start(),await this._resolveUndefinedElements(),this.targets.start(),this.target.start(),this.action.start(),this._started=!0,this.setAttribute("data-impulse-element",""),this.connected()}static get observedAttributes(){var t=new r(this.prototype,"property");return Array.from(t.value).map(({key:t})=>m(t))}attributeChangedCallback(t,e,i){if(this._started&&e!==i){const o=t.replace(_,(t,e,i)=>i?i.toUpperCase():"").replace(H,t=>t.toLowerCase());var s=this[o+"Changed"];if("function"==typeof s){var n=new r(Object.getPrototypeOf(this),"property"),n=Array.from(n.value).map(({key:t,type:e})=>({key:t,type:e})).find(({key:t})=>t===o);if(!n)throw new Error(`Unregistered attribute changed: ${t}. Register the attribute using the @property() decorator.`);var{newValue:t,oldValue:i}=function(t,e,i){switch(i){case Boolean:var s=t=>null!==t&&"false"!==t;return{newValue:s(t),oldValue:s(e)};case Number:return{newValue:Number(t),oldValue:Number(e)};case Array:return{newValue:f(t,[]),oldValue:f(e,[])};case Object:return{newValue:f(t,{}),oldValue:f(e,{})};default:return{newValue:t,oldValue:e}}}(i,e,n.type);s.call(this,t,i)}}}disconnectedCallback(){this.action.stop(),this.target.stop(),this.targets.stop(),this.property.stop(),this.disconnected(),this._started=!1}connected(){}disconnected(){}emit(t,{target:e=this,prefix:i=this.identifier,detail:s={},...n}={}){i=new CustomEvent(i?i+":"+t:t,{bubbles:!0,composed:!0,detail:s,...n});return e.dispatchEvent(i),i}get identifier(){return this.tagName.toLowerCase()}async _resolveUndefinedElements(){var t=Array.from(this.querySelectorAll(":not(:defined)")).map(t=>customElements.whenDefined(t.localName));await Promise.all(t)}}function w(r,{referenceElement:a,popupElement:l,arrowElement:c,arrowPadding:h=0,middleware:u=[],offsetOptions:d=0,placement:p="bottom-start",flipOptions:m,shiftOptions:f,strategy:v="fixed",sync:b}){let e;async function t(){if(r.open&&a){var t=[g.offset(d)];b?t.push(g.size({apply:({rects:t})=>{var e="height"===b||"both"===b;l.style.width="width"===b||"both"===b?t.reference.width+"px":"",l.style.height=e?t.reference.height+"px":""}})):(l.style.width="",l.style.height=""),t.push(g.flip(m)),t.push(g.shift(f)),c&&t.push(g.arrow({element:c,padding:h})),t.concat(u);const{x:e,y:i,placement:s,strategy:n,middlewareData:o}=await g.computePosition(a,l,{placement:p,middleware:t,strategy:v});if(Object.assign(l.style,{left:e+"px",top:i+"px",position:n}),o.arrow&&c){const{x:e,y:i}=o.arrow;Object.assign(c.style,{left:"number"==typeof e?e+"px":"",top:"number"==typeof i?i+"px":""})}l.setAttribute("x-placement",s)}}function i(){l.style.position=v,l.style.top="0px",l.style.left="0px",a&&(e=g.autoUpdate(a,l,t))}async function s(){return new Promise(t=>{e?(e(),e=void 0,requestAnimationFrame(()=>t())):t()})}i();const n=r.disconnected.bind(r);return Object.assign(r,{disconnected(){s(),n()}}),{start:i,update:async function(){await t()},stop:s}}function A(n,{boundaries:o,callback:r}){let a=null;function t(t){a=t.composedPath?.()?.[0]||t.target}function e(t,e){if(a&&n.open&&!t.defaultPrevented){var i=e(t);if(i&&i.getRootNode().contains(i)){for(const s of o)if(null!==s){if(s.contains(i))return;if(t.composed&&t.composedPath().includes(s))return}r(t,i),a=null}}}document.addEventListener("mousedown",t,!0),document.addEventListener("click",t=>e(t,()=>a),!0);const i=n.disconnected.bind(n);Object.assign(n,{disconnected(){document.removeEventListener("mousedown",t,!0),document.removeEventListener("click",t=>e(t,()=>a),!0),i()}})}function E(t){return t.getAttribute("value")||""}function O(t){return t.getAttribute("data-text")||t.innerText.trim()}class X{constructor(t){this.autocomplete=t,this.selectedValues=new Set,this.defaultSelectedValues=[],this.autocomplete=t}connected(){(function(t){try{return JSON.parse(t).map(t=>t.toString())}catch{return[]}})(this.autocomplete.value).forEach(t=>this.selectedValues.add(t)),this.defaultSelectedValues=this.persistedTags.map(t=>({value:E(t),text:O(t)}))}disconnected(){this.clear(),this.defaultSelectedValues.length=0}start(){for(const t of this.autocomplete.options)this.selectedValues.has(E(t))?this.autocomplete.combobox.select(t):this.autocomplete.combobox.deselect(t)}stop(){this.clearInputField()}async commit(t){this.clearInputField();const e=E(t);t=O(t);if(this.selectedValues.has(e)?this.removeValue(e):this.setValue(e,t),this.autocomplete.src){await this.autocomplete.makeRequest(""),this.start();t=this.autocomplete.visibleOptions.find(t=>E(t)===e)||this.autocomplete.visibleOptions[0];t&&this.autocomplete.activate(t)}else for(const t of this.autocomplete.options)t.hidden=!1}clear(){this.selectedValues.forEach(t=>this.removeValue(t))}reset(){this.clear(),this.defaultSelectedValues.forEach(({value:t,text:e})=>this.setValue(t,e,{persisted:!0}))}setValue(e,t,{persisted:i=!1}={}){this.selectedValues.has(e)||(this.selectedValues.add(e),this.insertTag(e,t,{persisted:i}),this.updateElementValue(),this.setRequiredAttribute(this.autocomplete.required),this.autocomplete.open&&(t=this.autocomplete.options.find(t=>E(t)===e))&&this.autocomplete.combobox.select(t))}removeValue(e){var t;this.selectedValues.has(e)&&(this.selectedValues.delete(e),this.removeTag(e),this.updateElementValue(),this.setRequiredAttribute(this.autocomplete.required),t=this.autocomplete.options.find(t=>E(t)===e))&&this.autocomplete.combobox.deselect(t)}setRequiredAttribute(t){!t||0<this.selectedValues.size?this.autocomplete.input.required=!1:this.autocomplete.input.required=!0}insertTag(t,e,{persisted:i=!1}={}){var s=this.template.content.cloneNode(!0),n=s.querySelector('[data-behavior="tag"]'),o=s.querySelector('[data-behavior="text"]'),r=s.querySelector('[data-behavior="hidden-field"]');n?.setAttribute("value",t),n?.toggleAttribute("data-persisted",i),o&&(o.innerText=e),r&&(r.value=t),this.autocomplete.control.insertBefore(s,this.template)}removeTag(e){this.tags.find(t=>E(t)===e)?.remove()}updateElementValue(){var t=Array.from(this.selectedValues.values());this.autocomplete.value=JSON.stringify(t)}clearInputField(){this.autocomplete.input.value&&(this.autocomplete.input.value="")}get firstActiveOption(){return this.autocomplete.visibleOptions.find(t=>this.selectedValues.has(E(t)))||this.autocomplete.visibleOptions[0]}get tags(){return Array.from(this.autocomplete.querySelectorAll('[data-behavior="tag"]'))}get persistedTags(){return this.tags.filter(t=>t.hasAttribute("data-persisted"))}get template(){return this.autocomplete.querySelector('[data-behavior="tag-template"]')}}class Y{constructor(t){this.autocomplete=t,this.defaultValue="",this.defaultText="",this.autocomplete=t}connected(){this.defaultValue=this.hiddenField.value,this.defaultText=this.hiddenField.getAttribute("data-text")||""}disconnected(){this.clear(),this.defaultValue="",this.defaultText=""}start(){this.selectedOption&&this.autocomplete.combobox.select(this.selectedOption)}stop(){this.autocomplete.input.value=this.hiddenField.getAttribute("data-text")||""}commit(t){var e=E(t),t=O(t);this.setValue(e,t),this.autocomplete.open=!1}clear(){this.setValue(null,null)}reset(){this.setValue(this.defaultValue,this.defaultText)}setValue(t,e){this.autocomplete.value=t||"",this.autocomplete.input.value=e||"",this.hiddenField.value=t||"",this.hiddenField.setAttribute("data-text",e||""),null===t?this.autocomplete.combobox.deselectAll():this.autocomplete.open&&(e=this.autocomplete.options.find(t=>E(t)===this.defaultValue))&&this.autocomplete.combobox.select(e)}removeValue(){this.clear()}setRequiredAttribute(t){this.autocomplete.input.required=t}get firstActiveOption(){return this.selectedOption||this.autocomplete.visibleOptions[0]}get selectedOption(){return this.autocomplete.options.find(t=>this.isSelected(t))}isSelected(t){return E(t)===this.autocomplete.value}get hiddenField(){return this.autocomplete.querySelector('[data-behavior="hidden-field"]')}}let S=class extends y{constructor(){super(),this.open=!1,this.disabled=!1,this.required=!1,this.multiple=!1,this.param="q",this.singleSelect=new Y(this),this.multipleSelect=new X(this),this.firstFocus=!0,this.remoteSearch=function(e,i){let s;function t(...t){clearTimeout(s),s=setTimeout(()=>{e.apply(this,t)},i)}return t.clear=()=>{clearTimeout(s)},t}(this.remoteSearch.bind(this),300),this.handleFormReset=this.handleFormReset.bind(this)}connected(){this.floatingUI=w(this,{referenceElement:this.control,popupElement:this.listbox,placement:"bottom",sync:"width",offsetOptions:4}),A(this,{boundaries:[this.control,this.listbox],callback:()=>{this.open=!1}}),this.combobox=new q(this.input,this.listbox,{multiple:this.multiple}),this.selectVariant=this.multiple?this.multipleSelect:this.singleSelect,this.selectVariant.connected(),this.form?.addEventListener("reset",this.handleFormReset),this.selectVariant.setRequiredAttribute(this.required)}disconnected(){this.open=!1,this.removeAttribute("data-focus"),this.firstFocus=!0,this.selectVariant.disconnected(),this.abortController=void 0,this.form?.removeEventListener("reset",this.handleFormReset)}async openChanged(t){if(t)this.emit("show"),this.combobox.start(),this.listbox.hidden=!1,this.floatingUI.start(),this.src?await this.makeRequest(""):this.checkIfListIsEmpty(),this.selectVariant.start(),this.selectVariant.firstActiveOption&&this.activate(this.selectVariant.firstActiveOption),this.emit("shown");else{if(this.emit("hide"),this.listbox.hidden=!0,this.abortController?.abort(),this.selectVariant.stop(),this.combobox.stop(),!this.src)for(const e of this.options)e.hidden=!1;this.removeAttribute("no-options"),this.removeAttribute("error"),this.currentQuery=void 0,await this.floatingUI.stop(),this.emit("hidden")}}valueChanged(t){this.classList.toggle("awc-autocomplete--selected",""!==t&&"[]"!==t)}disabledChanged(t){if(this.input.disabled=t,this.clearBtn.disabled=t,this.multiple&&this.tagDismissBtns)for(const e of this.tagDismissBtns)e.disabled=t}requiredChanged(t){this.selectVariant.setRequiredAttribute(t)}handleMousedown(t){t.target!==this.input&&t.preventDefault()}handleClick(t){this.disabled||(this.input.focus(),t=t.target["classList"],(t.contains("awc-autocomplete-control")||t.contains("awc-autocomplete-end-adornment"))&&(this.open=!0),this.firstFocus&&this.input.value&&this.input.select(),this.firstFocus=!1)}handleInputMousedown(){this.open=!0}handleInputFocus(){this.setAttribute("data-focus","")}handleInputBlur(){this.open=!1,this.removeAttribute("data-focus"),this.firstFocus=!0}handleInputKeydown(t){switch(t.key){case"Enter":this.open&&t.preventDefault();break;case"Escape":this.open&&(t.preventDefault(),t.stopPropagation(),this.open=!1);break;case"ArrowDown":t.altKey&&!this.open&&(t.preventDefault(),this.open=!0);break;case"ArrowUp":t.altKey&&this.open&&(t.preventDefault(),this.open=!1);break;case"Backspace":var e;""===this.input.value&&this.multiple&&(e=this.multipleSelect["tags"],e=e[e.length-1])&&(t.preventDefault(),this.multipleSelect.removeValue(E(e)))}}async handleInput(t){var t=t["target"];t instanceof HTMLInputElement&&(t=t.value.trim(),this.src?await this.remoteSearch(t):this.search(t))}async handleCommit(t){t.stopPropagation();t=t.target;t instanceof HTMLElement&&(await this.selectVariant.commit(t),this.emit("commit",{detail:{target:t}}))}handleClear(){this.open=!1,this.clear(),this.emit("clear")}handleTagRemove(t){t=t.target.closest('[data-behavior="tag"]');t&&(this.multipleSelect.removeValue(E(t)),this.emit("remove",{detail:{target:t}}))}handleFormReset(){this.open=!1,this.reset(),this.emit("reset")}setValue(t,e){this.selectVariant.setValue(t,e)}removeValue(t){this.multiple&&t?this.multipleSelect.removeValue(t):this.singleSelect.removeValue()}activate(t,{scroll:e=!0}={}){this.combobox.activate(t,{scroll:e})}deactivate(){this.combobox.deactivate()}clear(){this.selectVariant.clear(),this.currentQuery=void 0}reset(){this.selectVariant.reset(),this.currentQuery=void 0}search(t){var i;this.open=!0,this.options.forEach((i=t,t=>{var e;i?(e=O(t)?.toLowerCase().includes(i.toLowerCase()),t.hidden=!e):t.hidden=!1})),this.checkIfListIsEmpty(),this.visibleOptions[0]&&this.activate(this.visibleOptions[0])}async remoteSearch(t){this.open=!0,await this.makeRequest(t),this.selectVariant.start(),this.visibleOptions[0]&&this.activate(this.visibleOptions[0])}async makeRequest(t){if(this.currentQuery!==t){this.currentQuery=t,this.abortController?this.abortController.abort():(this.setAttribute("loading",""),this.emit("loadstart",{bubbles:!1,prefix:!1})),this.removeAttribute("error"),this.abortController=new AbortController;var e=new URL(this.src,window.location.href),i=new URLSearchParams(e.search.slice(1));i.append(this.param,t),e.search=i.toString();try{var s=await fetch(e.toString(),{signal:this.abortController.signal,credentials:"same-origin",headers:{accept:"text/fragment+html"}});if(!s.ok)throw new Error;this.optionsContainer.innerHTML=await s.text(),this.checkIfListIsEmpty(),this.combobox.initializeOptions(),this.abortController=void 0,await this.floatingUI.update(),this.emit("load",{bubbles:!1,prefix:!1})}catch(t){t instanceof Error&&"AbortError"!==t.name&&(this.abortController=void 0,this.setAttribute("error",""),this.emit("error",{bubbles:!1,prefix:!1}))}finally{this.removeAttribute("loading"),this.emit("loadend",{bubbles:!1,prefix:!1})}}}checkIfListIsEmpty(){this.toggleAttribute("no-options",0===this.visibleOptions.length)}get activeOption(){return this.combobox.activeOption}get visibleOptions(){return this.options.filter(t=>!t.hidden)}get options(){return this.combobox.options}get form(){return this.closest("form")}};t([a({type:Boolean})],S.prototype,"open",void 0),t([a()],S.prototype,"value",void 0),t([a({type:Boolean})],S.prototype,"disabled",void 0),t([a({type:Boolean})],S.prototype,"required",void 0),t([a({type:Boolean})],S.prototype,"multiple",void 0),t([a()],S.prototype,"src",void 0),t([a()],S.prototype,"param",void 0),t([c()],S.prototype,"input",void 0),t([c()],S.prototype,"listbox",void 0),t([c()],S.prototype,"control",void 0),t([c()],S.prototype,"optionsContainer",void 0),t([c()],S.prototype,"clearBtn",void 0),t([(t,e)=>{new r(t,"targets").add({key:e})}],S.prototype,"tagDismissBtns",void 0),S=t([l("awc-autocomplete")],S);function x(t,e){void 0===e&&(e=!0);var i=null==t||null==(i=t.getAttribute)?void 0:i.call(t,"inert");return""===i||"true"===i||e&&t&&x(t.parentNode)}function C(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))}function N(t){var e,i;if(t)return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||""===(i=null==(e=t)||null==(i=e.getAttribute)?void 0:i.call(e,"contenteditable"))||"true"===i)&&!C(t)?0:t.tabIndex;throw new Error("No node provided")}function tt(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex}function V(t){return"INPUT"===t.tagName}function et(t){if(!t.name)return 1;function e(t){return i.querySelectorAll('input[type="radio"][name="'+t+'"]')}var i=t.form||T(t);if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)s=e(window.CSS.escape(t.name));else try{s=e(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),0}var s=function(t,e){for(var i=0;i<t.length;i++)if(t[i].checked&&t[i].form===e)return t[i]}(s,t.form);return!s||s===t}function it(t){return V(e=t)&&"radio"===e.type&&!et(t);var e}function L(t){var e=(t=t.getBoundingClientRect()).width,t=t.height;return 0===e&&0===t}function st(t,e){var i=e.displayCheck,s=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return 1;if(e=M.call(t,"details>summary:first-of-type")?t.parentElement:t,M.call(e,"details:not([open]) *"))return 1;if(i&&"full"!==i&&"legacy-full"!==i){if("non-zero-area"===i)return L(t)}else{if("function"==typeof s){for(e=t;t;){var n=t.parentElement,o=T(t);if(n&&!n.shadowRoot&&!0===s(n))return L(t);t=t.assignedSlot||(n||o===t.ownerDocument?n:o.host)}t=e}if(function(t){var e,i=t&&T(t),s=null==(e=i)?void 0:e.host,n=!1;if(i&&i!==t)for(n=!!(null!=(e=s)&&null!=(e=e.ownerDocument)&&e.contains(s)||null!=t&&null!=(e=t.ownerDocument)&&e.contains(t));!n&&s;)var o,n=!(null==(o=s=null==(o=i=T(s))?void 0:o.host)||null==(o=o.ownerDocument)||!o.contains(s));return n}(t))return!t.getClientRects().length;if("legacy-full"!==i)return 1}}var k=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"].join(","),nt="undefined"==typeof Element,M=nt?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,T=!nt&&Element.prototype.getRootNode?function(t){var e;return null==t||null==(e=t.getRootNode)?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},ot=function(t,e,i){var s;return x(t)?[]:(s=Array.prototype.slice.apply(t.querySelectorAll(k)),e&&M.call(t,k)&&s.unshift(t),s.filter(i))},rt=function t(e,i,s){for(var n=[],o=Array.from(e);o.length;){var r,a,l=o.shift();x(l,!1)||("SLOT"===l.tagName?(r=t((r=l.assignedElements()).length?r:l.children,!0,s),s.flatten?n.push.apply(n,r):n.push({scopeParent:l,candidates:r})):(M.call(l,k)&&s.filter(l)&&(i||!e.includes(l))&&n.push(l),r=l.shadowRoot||"function"==typeof s.getShadowRoot&&s.getShadowRoot(l),a=!x(r,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(l)),r&&a?(a=t((!0===r?l:r).children,!0,s),s.flatten?n.push.apply(n,a):n.push({scopeParent:l,candidates:a})):o.unshift.apply(o,l.children)))}return n},R=function(t,e){var i;return!(e.disabled||x(e)||V(i=e)&&"hidden"===i.type||st(e,t)||"DETAILS"===(i=e).tagName&&Array.prototype.slice.apply(i.children).some(function(t){return"SUMMARY"===t.tagName})||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var i=0;i<e.children.length;i++){var s=e.children.item(i);if("LEGEND"===s.tagName)return!!M.call(e,"fieldset[disabled] *")||!s.contains(t)}return!0}e=e.parentElement}return!1}(e))},at=function(t,e){return!(it(e)||N(e)<0||!R(t,e))},lt=function(t){t=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(t)||0<=t)},ct=function a(t){var l=[],c=[];return t.forEach(function(t,e){var i,s=!!t.scopeParent,n=s?t.scopeParent:t,o=(o=s,(i=N(r=n))<0&&o&&!C(r)?0:i),r=s?a(t.candidates):n;0===o?s?l.push.apply(l,r):l.push(n):c.push({documentOrder:e,tabIndex:o,item:t,isScope:s,content:r})}),c.sort(tt).reduce(function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t},[]).concat(l)};const P=[];function ht(t,{trap:s}){let e,n;function i(t){"Tab"===t.key&&(t.preventDefault(),r(function(t,e,i){let s=t.indexOf(e),n=(s===t.length-1&&1===i&&(s=-1),1===i?0:t.length-1);return t[n=e&&0<=s&&0<=(e=s+i)&&e<t.length?e:n]}(function(t,e){t=(e=e||{}).getShadowRoot?rt([t],e.includeContainer,{filter:at.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:lt}):ot(t,e.includeContainer,at.bind(null,e));return ct(t)}(s),s.contains(document.activeElement)?document.activeElement:null,t.shiftKey?-1:1)))}function o(t){var e=t.composedPath?.()?.[0]||t.target;for(const i of P)if(i.contains(e))return void(n=e);r(n||s)}function r(t){t?t!==document.activeElement&&(t.focus({preventScroll:!0}),n=t):r(s)}function a(t){return!t.hasAttribute("data-autofocus")&&(t.querySelector("[data-autofocus]")||(e=t,((i=i||{}).getShadowRoot?rt([e],i.includeContainer,{filter:R.bind(null,i),flatten:!0,getShadowRoot:i.getShadowRoot}):ot(e,i.includeContainer,R.bind(null,i)))[0]))||t;var e,i}s.addEventListener("keydown",i,!0),document.addEventListener("focusin",o,!0);const l=t.disconnected.bind(t);return Object.assign(t,{disconnected(){s.removeEventListener("keydown",i,!0),document.removeEventListener("focusin",o,!0),l()}}),{start:function(){e=document.activeElement,P.push(s),r(a(s))},stop:function(){var t=P.indexOf(s);-1!==t&&(P.splice(t,1),r(e))}}}let I=class extends y{constructor(){super(...arguments),this.open=!1,this.placement="bottom"}connected(){this.floatingUI=w(this,{referenceElement:this.button,popupElement:this.panel,arrowElement:this.arrow,arrowPadding:this.arrowPadding,placement:this.placement,offsetOptions:8,flipOptions:{fallbackAxisSideDirection:"end"}}),A(this,{boundaries:[this.button,this.panel],callback:()=>{this.open=!1}}),this.focusTrap=ht(this,{trap:this.panel}),this.open&&(this.panel.hidden=!1,this.button.setAttribute("aria-expanded","true"),this.floatingUI.start())}disconnected(){this.open=!1}async openChanged(t){t?(this.panel.hidden=!1,this.button.setAttribute("aria-expanded","true"),this.floatingUI.start(),this.focusTrap.start()):(this.panel.hidden=!0,this.button.setAttribute("aria-expanded","false"),this.button.focus(),await this.floatingUI.stop(),this.focusTrap.stop())}handleButtonClick(){this.button.hasAttribute("disabled")||"true"===this.button.getAttribute("aria-disabled")||this.toggle()}toggle(){this.open=!this.open}show(){this.open||(this.open=!0)}hide(){this.open&&(this.open=!1)}handleKeydown(t){"Escape"===t.key&&this.open&&(t.preventDefault(),t.stopPropagation(),this.open=!1)}async updatePosition(){await this.floatingUI.update()}get arrowPadding(){var t=getComputedStyle(this.panel).borderRadius;return Number(t.replace(/[^-\d.]/g,""))||2}};t([a({type:Boolean})],I.prototype,"open",void 0),t([a()],I.prototype,"placement",void 0),t([c()],I.prototype,"button",void 0),t([c()],I.prototype,"panel",void 0),t([c()],I.prototype,"arrow",void 0),I=t([l("awc-popover")],I)});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@floating-ui/dom")):"function"==typeof define&&define.amd?define(["@floating-ui/dom"],e):e(("undefined"!=typeof globalThis?globalThis:t||self).FloatingUIDOM)}(this,function(g){"use strict";function t(t,e,i,s){var n,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;0<=a;a--)(n=t[a])&&(r=(o<3?n(r):3<o?n(e,i,r):n(e,i))||r);return 3<o&&r&&Object.defineProperty(e,i,r),r}var e=0;function s(){return e+=1,`ambiki-${Math.random().toString().slice(2,6)}-`+e}function i(t){return!t.hasAttribute("disabled")&&"true"!==t.getAttribute("aria-disabled")}var D=!!navigator.userAgent.match(/Macintosh/),q=class{input;list;multiple;isMouseMoving=!1;constructor(t,e,{multiple:i=!1}={}){this.input=t,this.list=e,this.multiple=i,this.list.id||(this.list.id=s()),this.input.getAttribute("aria-expanded")||this.input.setAttribute("aria-expanded","false"),this.multiple&&this.input.setAttribute("aria-multiselectable","true"),this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-haspopup","listbox"),this.input.setAttribute("aria-autocomplete","list"),this.list.setAttribute("role","listbox"),this.onKeydown=this.onKeydown.bind(this),this.onClick=this.onClick.bind(this),this.onListMouseover=this.onListMouseover.bind(this),this.onListMousemove=this.onListMousemove.bind(this)}start(){this.isMouseMoving=!1,this.input.setAttribute("aria-expanded","true"),this.input.setAttribute("aria-controls",this.list.id),this.input.addEventListener("keydown",this.onKeydown),this.list.addEventListener("click",this.onClick),this.list.addEventListener("mouseover",this.onListMouseover),this.list.addEventListener("mousemove",this.onListMousemove),this.initializeOptions()}stop(){this.isMouseMoving=!1,this.input.setAttribute("aria-expanded","false"),this.input.removeAttribute("aria-controls"),this.input.removeEventListener("keydown",this.onKeydown),this.list.removeEventListener("click",this.onClick),this.list.removeEventListener("mouseover",this.onListMouseover),this.list.removeEventListener("mousemove",this.onListMousemove),this.deselectAll(),this.deactivate()}onKeydown(t){if(this.isMouseMoving=!1,!(t.shiftKey||t.metaKey||t.altKey||!D&&t.ctrlKey))switch(t.key){case"Enter":case"Tab":this.activeOption&&i(this.activeOption)&&(t.preventDefault(),t.stopPropagation(),this.activeOption.click());break;case"Escape":this.deactivate();break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.activeOption?this.move(1):this.activate(this.visibleOptions[0],{scroll:!0});break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),this.activeOption?this.move(-1):this.activate(this.visibleOptions[this.visibleOptions.length-1],{scroll:!0});break;case"Home":t.preventDefault(),t.stopPropagation(),this.activate(this.visibleOptions[0],{scroll:!0});break;case"End":t.preventDefault(),t.stopPropagation(),this.activate(this.visibleOptions[this.visibleOptions.length-1],{scroll:!0});break;default:t.ctrlKey||this.deactivate()}}onClick(t){t=n(t.target);t&&i(t)&&(this.multiple&&this.isSelected(t)?this.deselect(t):this.select(t),t.dispatchEvent(new CustomEvent("combobox:commit",{bubbles:!0})))}onListMouseover(t){var e;this.isMouseMoving?(e=n(t.target))&&this.activate(e):t.preventDefault()}onListMousemove(t){!this.isMouseMoving&&(this.isMouseMoving=!0,t=n(t.target))&&this.activate(t)}select(t){if(this.multiple)t.setAttribute("aria-selected","true");else for(var e of this.options)e.setAttribute("aria-selected",(e===t).toString())}deselect(t){t.setAttribute("aria-selected","false")}deselectAll(){for(var t of this.options)this.deselect(t)}activate(t,{scroll:e=!1}={}){for(var i of this.options)i.id===t.id?(i.setAttribute("data-active",""),this.input.setAttribute("aria-activedescendant",i.id),e&&i.scrollIntoView({block:"nearest"})):i.removeAttribute("data-active")}deactivate(){this.input.removeAttribute("aria-activedescendant");for(var t of Array.from(this.list.querySelectorAll('[role="option"][data-active]')))t.removeAttribute("data-active")}isSelected(t){return"true"===t.getAttribute("aria-selected")}get options(){return Array.from(this.list.querySelectorAll('[role="option"]'))}get visibleOptions(){return this.options.filter(K)}get activeOption(){return this.list.querySelector("[data-active]")}move(t){this.activeOption&&(t=function(t,e,i){let s=t.indexOf(e),n=(s===t.length-1&&1===i&&(s=-1),1===i?0:t.length-1);return t[n=e&&0<=s&&0<=(e=s+i)&&e<t.length?e:n]}(this.visibleOptions,this.activeOption,t),this.activate(t,{scroll:!0}))}initializeOptions(){for(var t of this.options)t.setAttribute("tabindex","-1"),t.id||(t.id=s()),t.hasAttribute("aria-selected")||this.deselect(t)}};function n(t){return t&&t.closest('[role="option"]')||!1}function K(t){return!t.hidden&&!(t instanceof HTMLInputElement&&"hidden"===t.type)&&(0<t.offsetWidth||0<t.offsetHeight)}const o=Symbol.for("impulse");class r{constructor(t,e){this.proto=t,this.name=e,this.map=new Map,this.proto=t,this.name=e,this.initialize()}add(t){var e;null!=(e=this.value)&&e.add(t)}get value(){return this.map.get(this.name)}initialize(){Object.prototype.hasOwnProperty.call(this.proto,o)||(this.proto[o]=new Map),this.map=this.proto[o],this.map.has(this.name)||this.map.set(this.name,new Set)}}function a({type:i=String}={}){return(t,e)=>{new r(t,"property").add({key:e,type:i})}}function l(e){return t=>{try{window.customElements.define(e,t),window[t.name]=customElements.get(e)}catch(t){if(!(t instanceof DOMException&&"NotSupportedError"===t.name))throw t}}}function c(){return(t,e)=>{new r(t,"target").add({key:e})}}const F=/^(?:(.+?)?(?:@(window|document))?->)?(.+)#(.+)?$/;function j(t){var[,t,e,i,s]=t.trim().match(F)||[];return{eventName:t,eventTarget:"window"===(t=e)?window:"document"===t?document:void 0,methodName:s,identifier:i}}class U{constructor(){this.map=new Map}add(t,e){h(this.map,t).add(e)}delete(t,e){h(this.map,t).delete(e),0===(null==(e=this.get(t))?void 0:e.size)&&this.map.delete(t)}clear(){this.map.clear()}get values(){return Array.from(this.map.values()).reduce((t,e)=>t.concat(Array.from(e)),[])}get(t){return this.map.get(t)}has(t,e){return!(null==(t=this.get(t))||!t.has(e))}}function h(t,e){let i=t.get(e);return i||(i=new Set,t.set(e,i)),i}class B{constructor(t,e,i,s){this.instance=t,this.eventTarget=e,this.eventName=i,this.methodName=s,this.instance=t,this.eventTarget=e,this.eventName=i,this.methodName=s}start(){this.eventTarget.addEventListener(this.eventName,this)}stop(){this.eventTarget.removeEventListener(this.eventName,this)}handleEvent(t){var e=this.instance[this.methodName];"function"==typeof e&&e.call(this.instance,t)}}function u(t,e){return(null==(t=t.getAttribute(e))?void 0:t.trim().split(/\s+/))||[]}class z{constructor(t,e,i){this.element=t,this.delegate=e,this.observerOptions=i,this.started=!1,this.element=t,this.delegate=e,this.observer=new MutationObserver(t=>this.processMutations(t)),this.observerOptions=i}start(){this.started||(this.started=!0,this.observer.observe(this.element,Object.assign({childList:!0,subtree:!0},this.observerOptions)))}stop(){this.started&&(this.observer.takeRecords(),this.observer.disconnect(),this.started=!1)}processMutations(t){if(this.started)for(const e of t)this.processMutation(e)}processMutation(t){"attributes"===t.type&&t.target instanceof Element?this.processAttributeChange(t.target,t.attributeName):"childList"===t.type&&(this.processRemovedNodes(t.removedNodes),this.processAddedNodes(t.addedNodes))}processAttributeChange(t,e){e&&this.delegate.elementAttributeChanged(t,e)}processRemovedNodes(t){for(const i of Array.from(t)){var e=this.elementFromNode(i);e&&this.delegate.elementDisconnected(e)}}processAddedNodes(t){for(const i of Array.from(t)){var e=this.elementFromNode(i);e&&this.elementIsActive(e)&&this.delegate.elementConnected(e)}}elementFromNode(t){if(t.nodeType===Node.ELEMENT_NODE)return t}elementIsActive(t){return t.isConnected===this.element.isConnected&&this.element.contains(t)}}class d{constructor(t,e,i){this.instance=t,this.attributeName=e,this.delegate=i,this.instance=t,this.attributeName=e,this.elementObserver=new z(this.instance,this,{attributeFilter:[this.attributeName]}),this.delegate=i}start(){this.elementObserver.start()}stop(){this.elementObserver.stop()}elementConnected(t){var e=Array.from(t.querySelectorAll(`[${this.attributeName}]`));t.hasAttribute(this.attributeName)&&e.push(t);for(const i of e)this.delegate.elementConnected(i)}elementDisconnected(t){var e=Array.from(t.querySelectorAll(`[${this.attributeName}]`));t.hasAttribute(this.attributeName)&&e.push(t);for(const i of e)this.delegate.elementDisconnected(i)}elementAttributeChanged(t,e){var i,s;e===this.attributeName&&null!=(s=(i=this.delegate).elementAttributeChanged)&&s.call(i,t,e)}}const p="data-action";class ${constructor(t){this.instance=t,this.eventListenerMap=new U,this.instance=t,this.attributeObserver=new d(this.instance,p,this)}start(){this.attributeObserver.start();var t=Array.from(this.instance.querySelectorAll(`[${p}]`));this.instance.hasAttribute(p)&&t.push(this.instance),t.forEach(t=>this.bindActions(t))}stop(){this.eventListenerMap.values.forEach(t=>t.stop()),this.eventListenerMap.clear(),this.attributeObserver.stop()}elementConnected(t){this.bindActions(t)}elementDisconnected(t){this.unbindActions(t)}elementAttributeChanged(t){this.unbindActions(t),this.bindActions(t)}bindActions(n){u(n,p).forEach(t=>{var{eventName:t,eventTarget:e,methodName:i,identifier:s}=j(t);t&&s===this.identifier&&i&&(s=new B(this.instance,e||n,t,i),this.eventListenerMap.add(n,s),s.start())})}unbindActions(e){var t=this.eventListenerMap.get(e);t&&t.forEach(t=>{t.stop(),this.eventListenerMap.delete(e,t)})}get identifier(){return this.instance.identifier}}const _=/(-|_|\.|\s)+(.)?/g,H=/(^|\/)([A-Z])/g,J=/[ _]/g,Q=/([a-z\d])([A-Z])/g;function m(t){return t.replace(Q,"$1_$2").toLowerCase().replace(J,"-")}function f(t,e=""){if(!t)return e;try{return JSON.parse(t)}catch(t){return e}}class Z{constructor(t){this.instance=t,this.instance=t,this.store=new r(Object.getPrototypeOf(this.instance),"property")}start(){for(var[{key:t,type:e}]of this.values.entries())this.initializeProperty(t,e)}stop(){}initializeProperty(t,e){var i=m(t),s=this.instance[t],e=Object.assign({configurable:!0},function(e,i,t){switch(t){case Number:return{get:()=>Number(e.getAttribute(i)||0),set:t=>e.setAttribute(i,(t||0).toString())};case Boolean:return{get:()=>e.hasAttribute(i)&&"false"!==e.getAttribute(i),set:t=>{t?e.setAttribute(i,""):e.removeAttribute(i)}};case Array:return{get:()=>JSON.parse(e.getAttribute(i)||"[]"),set:t=>e.setAttribute(i,JSON.stringify(t)||"[]")};case Object:return{get:()=>JSON.parse(e.getAttribute(i)||"{}"),set:t=>e.setAttribute(i,JSON.stringify(t)||"{}")};default:return{get:()=>e.getAttribute(i)||"",set:t=>e.setAttribute(i,t||"")}}}(this.instance,i,e));Object.defineProperty(this.instance,t,e),this.instance.hasAttribute(i)||null!=(t=e.set)&&t.call(e,s)}get values(){return this.store.value}}const v="data-target";class G{constructor(t){this.instance=t,this.instance=t,this.store=new r(Object.getPrototypeOf(this.instance),"target"),this.attributeObserver=new d(this.instance,v,this)}start(){this.attributeObserver.start(),this.targetKeys.forEach(t=>this.initializeKey(t))}stop(){this.targetKeys.forEach(t=>this.terminateKey(t)),this.attributeObserver.stop()}elementConnected(i){u(i,v).forEach(t=>{var[t,e]=t.split(".");t&&e&&t===this.identifier&&this.targetKeys.includes(e)&&(this.defineProperty(e,i),this.processAddedElement(e,i))})}elementDisconnected(i){u(i,v).forEach(t=>{var[t,e]=t.split(".");t&&e&&t===this.identifier&&this.targetKeys.includes(e)&&(this.processRemovedElement(e,i),this.defineProperty(e,null))})}initializeKey(t){var e;this.targetKeys.includes(t)&&(e=this.findTarget(t),this.defineProperty(t,e),e)&&this.processAddedElement(t,e)}terminateKey(t){var e;this.targetKeys.includes(t)&&(e=this.findTarget(t))&&this.processRemovedElement(t,e)}defineProperty(t,e){Object.defineProperty(this.instance,t,{configurable:!0,get:()=>e})}processAddedElement(t,e){t=this.instance[t+"Connected"];"function"==typeof t&&t.call(this.instance,e)}processRemovedElement(t,e){t=this.instance[t+"Disconnected"];"function"==typeof t&&t.call(this.instance,e)}findTarget(t){t=`[${v}~="${this.identifier}.${t}"]`;return this.instance.querySelector(t)}get targetKeys(){return Array.from(this.store.value).map(({key:t})=>t)}get identifier(){return this.instance.identifier}}const b="data-target";class W{constructor(t){this.instance=t,this.instance=t,this.store=new r(Object.getPrototypeOf(this.instance),"targets"),this.attributeObserver=new d(this.instance,b,this)}start(){this.attributeObserver.start(),this.targetKeys.forEach(t=>this.initializeKey(t))}stop(){this.targetKeys.forEach(t=>this.terminateKey(t)),this.attributeObserver.stop()}elementConnected(i){u(i,b).forEach(t=>{var[t,e]=t.split(".");t&&e&&t===this.identifier&&this.targetKeys.includes(e)&&(this.defineProperty(e,this.findTargets(e)),this.processAddedElement(e,i))})}elementDisconnected(i){u(i,b).forEach(t=>{var[t,e]=t.split(".");t&&e&&t===this.identifier&&this.targetKeys.includes(e)&&(this.processRemovedElement(e,i),this.defineProperty(e,this.findTargets(e)))})}initializeKey(e){var t;this.targetKeys.includes(e)&&(t=this.findTargets(e),this.defineProperty(e,t),t.forEach(t=>this.processAddedElement(e,t)))}terminateKey(e){this.targetKeys.includes(e)&&this.findTargets(e).forEach(t=>this.processRemovedElement(e,t))}defineProperty(t,e){Object.defineProperty(this.instance,t,{configurable:!0,get:()=>e})}processAddedElement(t,e){t=this.instance[t+"Connected"];"function"==typeof t&&t.call(this.instance,e)}processRemovedElement(t,e){t=this.instance[t+"Disconnected"];"function"==typeof t&&t.call(this.instance,e)}findTargets(t){t=`[${b}~="${this.identifier}.${t}"]`;return Array.from(this.instance.querySelectorAll(t))}get targetKeys(){return Array.from(this.store.value).map(({key:t})=>t)}get identifier(){return this.instance.identifier}}class y extends HTMLElement{constructor(){super(...arguments),this.property=new Z(this),this.targets=new W(this),this.target=new G(this),this.action=new $(this),this._started=!1}async connectedCallback(){await new Promise(t=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>t()):t()}),customElements.upgrade(this),this.property.start(),await this._resolveUndefinedElements(),this.targets.start(),this.target.start(),this.action.start(),this._started=!0,this.setAttribute("data-impulse-element",""),this.connected()}static get observedAttributes(){var t=new r(this.prototype,"property");return Array.from(t.value).map(({key:t})=>m(t))}attributeChangedCallback(t,e,i){if(this._started&&e!==i){const o=t.replace(_,(t,e,i)=>i?i.toUpperCase():"").replace(H,t=>t.toLowerCase());var s=this[o+"Changed"];if("function"==typeof s){var n=new r(Object.getPrototypeOf(this),"property"),n=Array.from(n.value).map(({key:t,type:e})=>({key:t,type:e})).find(({key:t})=>t===o);if(!n)throw new Error(`Unregistered attribute changed: ${t}. Register the attribute using the @property() decorator.`);var{newValue:t,oldValue:i}=function(t,e,i){switch(i){case Boolean:var s=t=>null!==t&&"false"!==t;return{newValue:s(t),oldValue:s(e)};case Number:return{newValue:Number(t),oldValue:Number(e)};case Array:return{newValue:f(t,[]),oldValue:f(e,[])};case Object:return{newValue:f(t,{}),oldValue:f(e,{})};default:return{newValue:t,oldValue:e}}}(i,e,n.type);s.call(this,t,i)}}}disconnectedCallback(){this.action.stop(),this.target.stop(),this.targets.stop(),this.property.stop(),this.disconnected(),this._started=!1}connected(){}disconnected(){}emit(t,e={}){var{target:i=this,prefix:s=this.identifier,detail:n={}}=e,e=function(t,e){var i={};for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(i[n[s]]=t[n[s]]);return i}(e,["target","prefix","detail"]),s=new CustomEvent(s?s+":"+t:t,Object.assign({bubbles:!0,composed:!0,detail:n},e));return i.dispatchEvent(s),s}get identifier(){return this.tagName.toLowerCase()}async _resolveUndefinedElements(){var t=Array.from(this.querySelectorAll(":not(:defined)")).map(t=>customElements.whenDefined(t.localName));await Promise.all(t)}}function w(r,{referenceElement:a,popupElement:l,arrowElement:c,arrowPadding:h=0,middleware:u=[],offsetOptions:d=0,placement:p="bottom-start",flipOptions:m,shiftOptions:f,strategy:v="fixed",sync:b}){let e;async function t(){if(r.open&&a){var t=[g.offset(d)];b?t.push(g.size({apply:({rects:t})=>{var e="height"===b||"both"===b;l.style.width="width"===b||"both"===b?t.reference.width+"px":"",l.style.height=e?t.reference.height+"px":""}})):(l.style.width="",l.style.height=""),t.push(g.flip(m)),t.push(g.shift(f)),c&&t.push(g.arrow({element:c,padding:h})),t.concat(u);const{x:e,y:i,placement:s,strategy:n,middlewareData:o}=await g.computePosition(a,l,{placement:p,middleware:t,strategy:v});if(Object.assign(l.style,{left:e+"px",top:i+"px",position:n}),o.arrow&&c){const{x:e,y:i}=o.arrow;Object.assign(c.style,{left:"number"==typeof e?e+"px":"",top:"number"==typeof i?i+"px":""})}l.setAttribute("x-placement",s)}}function i(){l.style.position=v,l.style.top="0px",l.style.left="0px",a&&(e=g.autoUpdate(a,l,t))}async function s(){return new Promise(t=>{e?(e(),e=void 0,requestAnimationFrame(()=>t())):t()})}i();const n=r.disconnected.bind(r);return Object.assign(r,{disconnected(){s(),n()}}),{start:i,update:async function(){await t()},stop:s}}function A(n,{boundaries:o,callback:r}){let a=null;function t(t){var e;a=(null==(e=null==(e=t.composedPath)?void 0:e.call(t))?void 0:e[0])||t.target}function e(t,e){if(a&&n.open&&!t.defaultPrevented){var i=e(t);if(i&&i.getRootNode().contains(i)){for(const s of o)if(null!==s){if(s.contains(i))return;if(t.composed&&t.composedPath().includes(s))return}r(t,i),a=null}}}document.addEventListener("mousedown",t,!0),document.addEventListener("click",t=>e(t,()=>a),!0);const i=n.disconnected.bind(n);Object.assign(n,{disconnected(){document.removeEventListener("mousedown",t,!0),document.removeEventListener("click",t=>e(t,()=>a),!0),i()}})}function E(t){return t.getAttribute("value")||""}function O(t){return t.getAttribute("data-text")||t.innerText.trim()}class X{constructor(t){this.autocomplete=t,this.selectedValues=new Set,this.defaultSelectedValues=[],this.autocomplete=t}connected(){(function(t){try{return JSON.parse(t).map(t=>t.toString())}catch(t){return[]}})(this.autocomplete.value).forEach(t=>this.selectedValues.add(t)),this.defaultSelectedValues=this.persistedTags.map(t=>({value:E(t),text:O(t)}))}disconnected(){this.clear(),this.defaultSelectedValues.length=0}start(){for(const t of this.autocomplete.options)this.selectedValues.has(E(t))?this.autocomplete.combobox.select(t):this.autocomplete.combobox.deselect(t)}stop(){this.clearInputField()}async commit(t){this.clearInputField();const e=E(t);t=O(t);if(this.selectedValues.has(e)?this.removeValue(e):this.setValue(e,t),this.autocomplete.src){await this.autocomplete.makeRequest(""),this.start();t=this.autocomplete.visibleOptions.find(t=>E(t)===e)||this.autocomplete.visibleOptions[0];t&&this.autocomplete.activate(t)}else for(const t of this.autocomplete.options)t.hidden=!1}clear(){this.selectedValues.forEach(t=>this.removeValue(t))}reset(){this.clear(),this.defaultSelectedValues.forEach(({value:t,text:e})=>this.setValue(t,e,{persisted:!0}))}setValue(e,t,{persisted:i=!1}={}){this.selectedValues.has(e)||(this.selectedValues.add(e),this.insertTag(e,t,{persisted:i}),this.updateElementValue(),this.setRequiredAttribute(this.autocomplete.required),this.autocomplete.open&&(t=this.autocomplete.options.find(t=>E(t)===e))&&this.autocomplete.combobox.select(t))}removeValue(e){var t;this.selectedValues.has(e)&&(this.selectedValues.delete(e),this.removeTag(e),this.updateElementValue(),this.setRequiredAttribute(this.autocomplete.required),t=this.autocomplete.options.find(t=>E(t)===e))&&this.autocomplete.combobox.deselect(t)}setRequiredAttribute(t){!t||0<this.selectedValues.size?this.autocomplete.input.required=!1:this.autocomplete.input.required=!0}insertTag(t,e,{persisted:i=!1}={}){var s=this.template.content.cloneNode(!0),n=s.querySelector('[data-behavior="tag"]'),o=s.querySelector('[data-behavior="text"]'),r=s.querySelector('[data-behavior="hidden-field"]');null!=n&&n.setAttribute("value",t),null!=n&&n.toggleAttribute("data-persisted",i),o&&(o.innerText=e),r&&(r.value=t),this.autocomplete.control.insertBefore(s,this.template)}removeTag(e){var t=this.tags.find(t=>E(t)===e);null!=t&&t.remove()}updateElementValue(){var t=Array.from(this.selectedValues.values());this.autocomplete.value=JSON.stringify(t)}clearInputField(){this.autocomplete.input.value&&(this.autocomplete.input.value="")}get firstActiveOption(){return this.autocomplete.visibleOptions.find(t=>this.selectedValues.has(E(t)))||this.autocomplete.visibleOptions[0]}get tags(){return Array.from(this.autocomplete.querySelectorAll('[data-behavior="tag"]'))}get persistedTags(){return this.tags.filter(t=>t.hasAttribute("data-persisted"))}get template(){return this.autocomplete.querySelector('[data-behavior="tag-template"]')}}class Y{constructor(t){this.autocomplete=t,this.defaultValue="",this.defaultText="",this.autocomplete=t}connected(){this.defaultValue=this.hiddenField.value,this.defaultText=this.hiddenField.getAttribute("data-text")||""}disconnected(){this.clear(),this.defaultValue="",this.defaultText=""}start(){this.selectedOption&&this.autocomplete.combobox.select(this.selectedOption)}stop(){this.autocomplete.input.value=this.hiddenField.getAttribute("data-text")||""}commit(t){var e=E(t),t=O(t);this.setValue(e,t),this.autocomplete.open=!1}clear(){this.setValue(null,null)}reset(){this.setValue(this.defaultValue,this.defaultText)}setValue(t,e){this.autocomplete.value=t||"",this.autocomplete.input.value=e||"",this.hiddenField.value=t||"",this.hiddenField.setAttribute("data-text",e||""),null===t?this.autocomplete.combobox.deselectAll():this.autocomplete.open&&(e=this.autocomplete.options.find(t=>E(t)===this.defaultValue))&&this.autocomplete.combobox.select(e)}removeValue(){this.clear()}setRequiredAttribute(t){this.autocomplete.input.required=t}get firstActiveOption(){return this.selectedOption||this.autocomplete.visibleOptions[0]}get selectedOption(){return this.autocomplete.options.find(t=>this.isSelected(t))}isSelected(t){return E(t)===this.autocomplete.value}get hiddenField(){return this.autocomplete.querySelector('[data-behavior="hidden-field"]')}}let S=class extends y{constructor(){super(),this.open=!1,this.disabled=!1,this.required=!1,this.multiple=!1,this.param="q",this.singleSelect=new Y(this),this.multipleSelect=new X(this),this.firstFocus=!0,this.remoteSearch=function(e,i){let s;function t(...t){clearTimeout(s),s=setTimeout(()=>{e.apply(this,t)},i)}return t.clear=()=>{clearTimeout(s)},t}(this.remoteSearch.bind(this),300),this.handleFormReset=this.handleFormReset.bind(this)}connected(){var t;this.floatingUI=w(this,{referenceElement:this.control,popupElement:this.listbox,placement:"bottom",sync:"width",offsetOptions:4}),A(this,{boundaries:[this.control,this.listbox],callback:()=>{this.open=!1}}),this.combobox=new q(this.input,this.listbox,{multiple:this.multiple}),this.selectVariant=this.multiple?this.multipleSelect:this.singleSelect,this.selectVariant.connected(),null!=(t=this.form)&&t.addEventListener("reset",this.handleFormReset),this.selectVariant.setRequiredAttribute(this.required)}disconnected(){var t;this.open=!1,this.removeAttribute("data-focus"),this.firstFocus=!0,this.selectVariant.disconnected(),this.abortController=void 0,null!=(t=this.form)&&t.removeEventListener("reset",this.handleFormReset)}async openChanged(t){if(t)this.emit("show"),this.combobox.start(),this.listbox.hidden=!1,this.floatingUI.start(),this.src?await this.makeRequest(""):this.checkIfListIsEmpty(),this.selectVariant.start(),this.selectVariant.firstActiveOption&&this.activate(this.selectVariant.firstActiveOption),this.emit("shown");else{if(this.emit("hide"),this.listbox.hidden=!0,null!=(t=this.abortController)&&t.abort(),this.selectVariant.stop(),this.combobox.stop(),!this.src)for(const e of this.options)e.hidden=!1;this.removeAttribute("no-options"),this.removeAttribute("error"),this.currentQuery=void 0,await this.floatingUI.stop(),this.emit("hidden")}}valueChanged(t){this.classList.toggle("awc-autocomplete--selected",""!==t&&"[]"!==t)}disabledChanged(t){if(this.input.disabled=t,this.clearBtn.disabled=t,this.multiple&&this.tagDismissBtns)for(const e of this.tagDismissBtns)e.disabled=t}requiredChanged(t){this.selectVariant.setRequiredAttribute(t)}handleMousedown(t){t.target!==this.input&&t.preventDefault()}handleClick(t){this.disabled||(this.input.focus(),t=t.target["classList"],(t.contains("awc-autocomplete-control")||t.contains("awc-autocomplete-end-adornment"))&&(this.open=!0),this.firstFocus&&this.input.value&&this.input.select(),this.firstFocus=!1)}handleInputMousedown(){this.open=!0}handleInputFocus(){this.setAttribute("data-focus","")}handleInputBlur(){this.open=!1,this.removeAttribute("data-focus"),this.firstFocus=!0}handleInputKeydown(t){switch(t.key){case"Enter":this.open&&t.preventDefault();break;case"Escape":this.open&&(t.preventDefault(),t.stopPropagation(),this.open=!1);break;case"ArrowDown":t.altKey&&!this.open&&(t.preventDefault(),this.open=!0);break;case"ArrowUp":t.altKey&&this.open&&(t.preventDefault(),this.open=!1);break;case"Backspace":var e;""===this.input.value&&this.multiple&&(e=this.multipleSelect["tags"],e=e[e.length-1])&&(t.preventDefault(),this.multipleSelect.removeValue(E(e)))}}async handleInput(t){var t=t["target"];t instanceof HTMLInputElement&&(t=t.value.trim(),this.src?await this.remoteSearch(t):this.search(t))}async handleCommit(t){t.stopPropagation();t=t.target;t instanceof HTMLElement&&(await this.selectVariant.commit(t),this.emit("commit",{detail:{target:t}}))}handleClear(){this.open=!1,this.clear(),this.emit("clear")}handleTagRemove(t){t=t.target.closest('[data-behavior="tag"]');t&&(this.multipleSelect.removeValue(E(t)),this.emit("remove",{detail:{target:t}}))}handleFormReset(){this.open=!1,this.reset(),this.emit("reset")}setValue(t,e){this.selectVariant.setValue(t,e)}removeValue(t){this.multiple&&t?this.multipleSelect.removeValue(t):this.singleSelect.removeValue()}activate(t,{scroll:e=!0}={}){this.combobox.activate(t,{scroll:e})}deactivate(){this.combobox.deactivate()}clear(){this.selectVariant.clear(),this.currentQuery=void 0}reset(){this.selectVariant.reset(),this.currentQuery=void 0}search(t){var i;this.open=!0,this.options.forEach((i=t,t=>{var e;i?(e=null==(e=O(t))?void 0:e.toLowerCase().includes(i.toLowerCase()),t.hidden=!e):t.hidden=!1})),this.checkIfListIsEmpty(),this.visibleOptions[0]&&this.activate(this.visibleOptions[0])}async remoteSearch(t){this.open=!0,await this.makeRequest(t),this.selectVariant.start(),this.visibleOptions[0]&&this.activate(this.visibleOptions[0])}async makeRequest(t){if(this.currentQuery!==t){this.currentQuery=t,this.abortController?this.abortController.abort():(this.setAttribute("loading",""),this.emit("loadstart",{bubbles:!1,prefix:!1})),this.removeAttribute("error"),this.abortController=new AbortController;var e=new URL(this.src,window.location.href),i=new URLSearchParams(e.search.slice(1));i.append(this.param,t),e.search=i.toString();try{var s=await fetch(e.toString(),{signal:this.abortController.signal,credentials:"same-origin",headers:{accept:"text/fragment+html"}});if(!s.ok)throw new Error;this.optionsContainer.innerHTML=await s.text(),this.checkIfListIsEmpty(),this.combobox.initializeOptions(),this.abortController=void 0,await this.floatingUI.update(),this.emit("load",{bubbles:!1,prefix:!1})}catch(t){t instanceof Error&&"AbortError"!==t.name&&(this.abortController=void 0,this.setAttribute("error",""),this.emit("error",{bubbles:!1,prefix:!1}))}finally{this.removeAttribute("loading"),this.emit("loadend",{bubbles:!1,prefix:!1})}}}checkIfListIsEmpty(){this.toggleAttribute("no-options",0===this.visibleOptions.length)}get activeOption(){return this.combobox.activeOption}get visibleOptions(){return this.options.filter(t=>!t.hidden)}get options(){return this.combobox.options}get form(){return this.closest("form")}};t([a({type:Boolean})],S.prototype,"open",void 0),t([a()],S.prototype,"value",void 0),t([a({type:Boolean})],S.prototype,"disabled",void 0),t([a({type:Boolean})],S.prototype,"required",void 0),t([a({type:Boolean})],S.prototype,"multiple",void 0),t([a()],S.prototype,"src",void 0),t([a()],S.prototype,"param",void 0),t([c()],S.prototype,"input",void 0),t([c()],S.prototype,"listbox",void 0),t([c()],S.prototype,"control",void 0),t([c()],S.prototype,"optionsContainer",void 0),t([c()],S.prototype,"clearBtn",void 0),t([(t,e)=>{new r(t,"targets").add({key:e})}],S.prototype,"tagDismissBtns",void 0),S=t([l("awc-autocomplete")],S);function x(t,e){void 0===e&&(e=!0);var i=null==t||null==(i=t.getAttribute)?void 0:i.call(t,"inert");return""===i||"true"===i||e&&t&&x(t.parentNode)}function C(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))}function N(t){var e,i;if(t)return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||""===(i=null==(e=t)||null==(i=e.getAttribute)?void 0:i.call(e,"contenteditable"))||"true"===i)&&!C(t)?0:t.tabIndex;throw new Error("No node provided")}function tt(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex}function V(t){return"INPUT"===t.tagName}function et(t){if(!t.name)return 1;function e(t){return i.querySelectorAll('input[type="radio"][name="'+t+'"]')}var i=t.form||T(t);if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)s=e(window.CSS.escape(t.name));else try{s=e(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),0}var s=function(t,e){for(var i=0;i<t.length;i++)if(t[i].checked&&t[i].form===e)return t[i]}(s,t.form);return!s||s===t}function it(t){return V(e=t)&&"radio"===e.type&&!et(t);var e}function L(t){var e=(t=t.getBoundingClientRect()).width,t=t.height;return 0===e&&0===t}function st(t,e){var i=e.displayCheck,s=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return 1;if(e=M.call(t,"details>summary:first-of-type")?t.parentElement:t,M.call(e,"details:not([open]) *"))return 1;if(i&&"full"!==i&&"legacy-full"!==i){if("non-zero-area"===i)return L(t)}else{if("function"==typeof s){for(e=t;t;){var n=t.parentElement,o=T(t);if(n&&!n.shadowRoot&&!0===s(n))return L(t);t=t.assignedSlot||(n||o===t.ownerDocument?n:o.host)}t=e}if(function(t){var e,i=t&&T(t),s=null==(e=i)?void 0:e.host,n=!1;if(i&&i!==t)for(n=!!(null!=(e=s)&&null!=(e=e.ownerDocument)&&e.contains(s)||null!=t&&null!=(e=t.ownerDocument)&&e.contains(t));!n&&s;)var o,n=!(null==(o=s=null==(o=i=T(s))?void 0:o.host)||null==(o=o.ownerDocument)||!o.contains(s));return n}(t))return!t.getClientRects().length;if("legacy-full"!==i)return 1}}var k=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"].join(","),nt="undefined"==typeof Element,M=nt?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,T=!nt&&Element.prototype.getRootNode?function(t){var e;return null==t||null==(e=t.getRootNode)?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},ot=function(t,e,i){var s;return x(t)?[]:(s=Array.prototype.slice.apply(t.querySelectorAll(k)),e&&M.call(t,k)&&s.unshift(t),s.filter(i))},rt=function t(e,i,s){for(var n=[],o=Array.from(e);o.length;){var r,a,l=o.shift();x(l,!1)||("SLOT"===l.tagName?(r=t((r=l.assignedElements()).length?r:l.children,!0,s),s.flatten?n.push.apply(n,r):n.push({scopeParent:l,candidates:r})):(M.call(l,k)&&s.filter(l)&&(i||!e.includes(l))&&n.push(l),r=l.shadowRoot||"function"==typeof s.getShadowRoot&&s.getShadowRoot(l),a=!x(r,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(l)),r&&a?(a=t((!0===r?l:r).children,!0,s),s.flatten?n.push.apply(n,a):n.push({scopeParent:l,candidates:a})):o.unshift.apply(o,l.children)))}return n},R=function(t,e){var i;return!(e.disabled||x(e)||V(i=e)&&"hidden"===i.type||st(e,t)||"DETAILS"===(i=e).tagName&&Array.prototype.slice.apply(i.children).some(function(t){return"SUMMARY"===t.tagName})||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var i=0;i<e.children.length;i++){var s=e.children.item(i);if("LEGEND"===s.tagName)return!!M.call(e,"fieldset[disabled] *")||!s.contains(t)}return!0}e=e.parentElement}return!1}(e))},at=function(t,e){return!(it(e)||N(e)<0||!R(t,e))},lt=function(t){t=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(t)||0<=t)},ct=function a(t){var l=[],c=[];return t.forEach(function(t,e){var i,s=!!t.scopeParent,n=s?t.scopeParent:t,o=(o=s,(i=N(r=n))<0&&o&&!C(r)?0:i),r=s?a(t.candidates):n;0===o?s?l.push.apply(l,r):l.push(n):c.push({documentOrder:e,tabIndex:o,item:t,isScope:s,content:r})}),c.sort(tt).reduce(function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t},[]).concat(l)};const P=[];function ht(t,{trap:n}){let e,o;function i(t){"Tab"===t.key&&(t.preventDefault(),r(function(t,e,i){let s=t.indexOf(e),n=(s===t.length-1&&1===i&&(s=-1),1===i?0:t.length-1);return t[n=e&&0<=s&&0<=(e=s+i)&&e<t.length?e:n]}(function(t,e){t=(e=e||{}).getShadowRoot?rt([t],e.includeContainer,{filter:at.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:lt}):ot(t,e.includeContainer,at.bind(null,e));return ct(t)}(n),n.contains(document.activeElement)?document.activeElement:null,t.shiftKey?-1:1)))}function s(t){var e,i=(null==(e=null==(e=t.composedPath)?void 0:e.call(t))?void 0:e[0])||t.target;for(const s of P)if(s.contains(i))return void(o=i);r(o||n)}function r(t){t?t!==document.activeElement&&(t.focus({preventScroll:!0}),o=t):r(n)}function a(t){return!t.hasAttribute("data-autofocus")&&(t.querySelector("[data-autofocus]")||(e=t,((i=i||{}).getShadowRoot?rt([e],i.includeContainer,{filter:R.bind(null,i),flatten:!0,getShadowRoot:i.getShadowRoot}):ot(e,i.includeContainer,R.bind(null,i)))[0]))||t;var e,i}n.addEventListener("keydown",i,!0),document.addEventListener("focusin",s,!0);const l=t.disconnected.bind(t);return Object.assign(t,{disconnected(){n.removeEventListener("keydown",i,!0),document.removeEventListener("focusin",s,!0),l()}}),{start:function(){e=document.activeElement,P.push(n),r(a(n))},stop:function(){var t=P.indexOf(n);-1!==t&&(P.splice(t,1),r(e))}}}let I=class extends y{constructor(){super(...arguments),this.open=!1,this.placement="bottom"}connected(){this.floatingUI=w(this,{referenceElement:this.button,popupElement:this.panel,arrowElement:this.arrow,arrowPadding:this.arrowPadding,placement:this.placement,offsetOptions:8,flipOptions:{fallbackAxisSideDirection:"end"}}),A(this,{boundaries:[this.button,this.panel],callback:()=>{this.open=!1}}),this.focusTrap=ht(this,{trap:this.panel}),this.open&&(this.panel.hidden=!1,this.button.setAttribute("aria-expanded","true"),this.floatingUI.start())}disconnected(){this.open=!1}async openChanged(t){t?(this.panel.hidden=!1,this.button.setAttribute("aria-expanded","true"),this.floatingUI.start(),this.focusTrap.start()):(this.panel.hidden=!0,this.button.setAttribute("aria-expanded","false"),this.button.focus(),await this.floatingUI.stop(),this.focusTrap.stop())}handleButtonClick(){this.button.hasAttribute("disabled")||"true"===this.button.getAttribute("aria-disabled")||this.toggle()}toggle(){this.open=!this.open}show(){this.open||(this.open=!0)}hide(){this.open&&(this.open=!1)}handleKeydown(t){"Escape"===t.key&&this.open&&(t.preventDefault(),t.stopPropagation(),this.open=!1)}async updatePosition(){await this.floatingUI.update()}get arrowPadding(){var t=getComputedStyle(this.panel).borderRadius;return Number(t.replace(/[^-\d.]/g,""))||2}};t([a({type:Boolean})],I.prototype,"open",void 0),t([a()],I.prototype,"placement",void 0),t([c()],I.prototype,"button",void 0),t([c()],I.prototype,"panel",void 0),t([c()],I.prototype,"arrow",void 0),I=t([l("awc-popover")],I)});
@@ -1,5 +1,5 @@
1
1
  module Impulse
2
2
  module ViewComponents
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: impulse_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - abeidahmed