@webority/ui-elements 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ Copyright (c) Webority Technologies. All rights reserved.
2
+
3
+ This software and its source code are proprietary and confidential to
4
+ Webority Technologies. Use is restricted to Webority products and teams under
5
+ internal license. Redistribution outside Webority Technologies is prohibited.
@@ -0,0 +1,63 @@
1
+ var WeborityUiElements=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=class extends HTMLElement{static formAssociated=!0;static get observedAttributes(){return[`value`,`placeholder`,`disabled`,`min-chars`,`debounce`,`remote`]}constructor(){super(),this._internals=this.attachInternals?this.attachInternals():null,this._value=``,this._label=``,this._optionsProp=null,this._loading=!1,this._active=-1,this._timer=null}connectedCallback(){this._rendered||this.render()}attributeChangedCallback(e,t,n){this._rendered&&(e===`value`?this.value=n:this.render())}get value(){return this._value}set value(e){this._value=e==null?``:String(e),this._internals?.setFormValue(this._value);let t=this._readOptions().find(e=>String(e.value)===this._value);t&&(this._label=r(t.label)),this._syncInput()}set options(e){this._optionsProp=Array.isArray(e)?e:[],this._renderOptions()}get options(){return this._readOptions()}set loading(e){this._loading=!!e,this._renderLoading()}get loading(){return this._loading}get _remote(){return this.hasAttribute(`remote`)}get _minChars(){return Math.max(0,Number(this.getAttribute(`min-chars`))||+!!this._remote)}get _debounceMs(){let e=Number(this.getAttribute(`debounce`));return Number.isFinite(e)&&e>=0?e:250}_readOptions(){return this._optionsProp?this._optionsProp:[...this.querySelectorAll(`:scope > wui-option`)].map(e=>({value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML}))}render(){let e=this.getAttribute(`placeholder`)||`Search…`;this.innerHTML=`
2
+ <div class="search-select">
3
+ <div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false">
4
+ <input class="search-select-input search-select-ac-input" placeholder="${n(e)}" aria-autocomplete="list" autocomplete="off"${this.hasAttribute(`disabled`)?` disabled`:``} />
5
+ <span class="search-select-spinner spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
6
+ <button type="button" class="search-select-clear" aria-label="Clear" hidden><i class="bi bi-x" aria-hidden="true"></i></button>
7
+ </div>
8
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" tabindex="-1" hidden>
9
+ <div class="search-select-options"></div>
10
+ <div class="search-select-empty" hidden>No matches</div>
11
+ <div class="search-select-hint" hidden>Type to search…</div>
12
+ </div>
13
+ </div>`,this._rendered=!0,this._wire(),this._syncInput(),this._renderOptions()}_refs(){return{control:this.querySelector(`.search-select-control`),input:this.querySelector(`.search-select-ac-input`),menu:this.querySelector(`.search-select-menu`),spinner:this.querySelector(`.search-select-spinner`),clear:this.querySelector(`.search-select-clear`),optionsWrap:this.querySelector(`.search-select-options`),empty:this.querySelector(`.search-select-empty`),hint:this.querySelector(`.search-select-hint`)}}_optionEls(){return[...this.querySelectorAll(`.search-select-option`)]}_syncInput(){let{input:e,clear:t}=this._refs();e&&document.activeElement!==e&&(e.value=this._label),t&&(t.hidden=!this._value&&!(e&&e.value))}_renderLoading(){let{spinner:e}=this._refs();e&&(e.hidden=!this._loading)}_renderOptions(e){let t=this._refs();if(!t.optionsWrap)return;let i=(e??(t.input?t.input.value:``)).trim().toLowerCase(),a=this._readOptions();!this._remote&&i&&(a=a.filter(e=>r(e.label).toLowerCase().includes(i))),t.optionsWrap.innerHTML=a.map(e=>{let t=String(e.value)===String(this._value);return`<button type="button" role="option" class="search-select-option${t?` selected`:``}" data-value="${n(e.value)}" aria-selected="${t}">${e.label}</button>`}).join(``),this._active=-1;let o=i.length<this._minChars;t.hint&&(t.hint.hidden=!(this._remote&&o&&!a.length)),t.empty&&(t.empty.hidden=this._loading||a.length>0||this._remote&&o)}_wire(){let e=this._refs();if(!e.control||!e.input)return;let t=()=>{let t=e.control.getBoundingClientRect();e.menu.style.position=`fixed`,e.menu.style.top=`${t.bottom+4}px`,e.menu.style.left=`${t.left}px`,e.menu.style.width=`${t.width}px`},n=()=>this._optionEls().filter(e=>!e.hidden),i=e=>{let t=n();this._active=e;for(let e of this._optionEls())e.classList.remove(`is-active`);e>=0&&t[e]&&(t[e].classList.add(`is-active`),t[e].scrollIntoView({block:`nearest`}))},a=()=>!e.menu.hidden,o=()=>{e.menu.hidden=!1,e.control.setAttribute(`aria-expanded`,`true`),e.control.classList.add(`open`),t(),this._renderOptions()},s=()=>{e.menu.hidden=!0,e.control.setAttribute(`aria-expanded`,`false`),e.control.classList.remove(`open`),i(-1),this._syncInput()},c=t=>{this._value=t.dataset.value,this._label=r(t.innerHTML),this._internals?.setFormValue(this._value),e.input.value=this._label,this.dispatchEvent(new Event(`change`,{bubbles:!0})),s(),e.input.focus()};e.input.addEventListener(`focus`,()=>o()),e.input.addEventListener(`input`,()=>{let t=e.input.value;if(e.clear&&(e.clear.hidden=!t),a()||o(),this._remote){if(this._renderOptions(t),t.trim().length<this._minChars)return;clearTimeout(this._timer),this._timer=setTimeout(()=>{this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:t}}))},this._debounceMs)}else this._renderOptions(t)}),e.input.addEventListener(`keydown`,e=>{let t=n();e.key===`ArrowDown`?(e.preventDefault(),a()||o(),i(Math.min(this._active+1,t.length-1))):e.key===`ArrowUp`?(e.preventDefault(),i(Math.max(this._active-1,0))):e.key===`Enter`?t[this._active]&&(e.preventDefault(),c(t[this._active])):e.key===`Escape`&&s()}),e.optionsWrap.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&c(t)}),e.optionsWrap.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&i(this._optionEls().indexOf(t))}),e.clear?.addEventListener(`click`,()=>{this._value=``,this._label=``,this._internals?.setFormValue(``),e.input.value=``,e.clear.hidden=!0,this._renderOptions(``),this.dispatchEvent(new Event(`change`,{bubbles:!0})),e.input.focus()}),this._onDocClick=e=>{a()&&!this.contains(e.target)&&s()},document.addEventListener(`click`,this._onDocClick),window.addEventListener(`resize`,()=>{a()&&t()})}disconnectedCallback(){this._onDocClick&&document.removeEventListener(`click`,this._onDocClick),clearTimeout(this._timer)}},n=e=>String(e??``).replace(/"/g,`&quot;`).replace(/</g,`&lt;`),r=e=>String(e??``).replace(/<[^>]*>/g,``),i=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],a=[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],o=e=>String(e).padStart(2,`0`),s=(e,t,n)=>`${e}-${o(t+1)}-${o(n)}`,c=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e||``);return t?{y:+t[1],m:t[2]-1,d:+t[3]}:null},l=e=>{let t=c(e);return t?`${o(t.d)} ${i[t.m].slice(0,3)} ${t.y}`:``},u=class extends HTMLElement{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`]}constructor(){super(),this._internals=this.attachInternals?this.attachInternals():null,this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){this._rendered||this.render()}attributeChangedCallback(e,t,n){this._rendered&&(e===`value`?(this._value=n||``,this._syncTrigger()):this.render())}get value(){return this._value}set value(e){this._value=e||``,this._internals?.setFormValue(this._value),this._syncTrigger(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}render(){this._value=this.getAttribute(`value`)||this._value;let e=this.getAttribute(`placeholder`)||`Enter Date`,t=c(this._value);t&&(this._viewY=t.y,this._viewM=t.m),this.innerHTML=`
14
+ <div class="datepicker">
15
+ <button type="button" class="input datepicker-trigger" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`disabled`)?` disabled`:``}>
16
+ <span data-trigger-label class="${t?``:`search-select-placeholder`}">${t?l(this._value):e}</span>
17
+ <i class="bi bi-calendar3" aria-hidden="true"></i>
18
+ </button>
19
+ <div class="datepicker-pop" role="dialog" hidden></div>
20
+ </div>`,this._rendered=!0,this._wire()}_internalsSet(){this._internals?.setFormValue(this._value)}_syncTrigger(){let e=this.querySelector(`[data-trigger-label]`);if(!e)return;let t=c(this._value);e.textContent=t?l(this._value):this.getAttribute(`placeholder`)||`Enter Date`,e.classList.toggle(`search-select-placeholder`,!t)}_renderMonth(){let e=this.querySelector(`.datepicker-pop`),t=new Date(this._viewY,this._viewM,1).getDay(),n=new Date(this._viewY,this._viewM+1,0).getDate(),r=c(this._value),o=c(this.getAttribute(`min`)),l=c(this.getAttribute(`max`)),u=(e,t,n)=>{let r=new Date(e,t,n).getTime();return!!(o&&r<new Date(o.y,o.m,o.d).getTime()||l&&r>new Date(l.y,l.m,l.d).getTime())},d=``;for(let e=0;e<t;e++)d+=`<span class="datepicker-day is-outside"></span>`;for(let e=1;e<=n;e++){let t=s(this._viewY,this._viewM,e),n=r&&r.y===this._viewY&&r.m===this._viewM&&r.d===e,i=u(this._viewY,this._viewM,e);d+=`<button type="button" class="datepicker-day${n?` selected`:``}" data-iso="${t}"${i?` disabled`:``}>${e}</button>`}e.innerHTML=`
21
+ <div class="datepicker-head">
22
+ <button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="Previous month"><i class="bi bi-chevron-left" aria-hidden="true"></i></button>
23
+ <span class="datepicker-month">${i[this._viewM]} ${this._viewY}</span>
24
+ <button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="Next month"><i class="bi bi-chevron-right" aria-hidden="true"></i></button>
25
+ </div>
26
+ <div class="datepicker-weekdays">${a.map(e=>`<span>${e}</span>`).join(``)}</div>
27
+ <div class="datepicker-grid">${d}</div>
28
+ <div class="datepicker-foot"><button type="button" class="datepicker-link" data-clear>Clear</button></div>`}_wire(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`.datepicker-pop`);if(!e||!t)return;let n=()=>!t.hidden,r=()=>{this._renderMonth(),t.hidden=!1,e.setAttribute(`aria-expanded`,`true`)},i=()=>{t.hidden=!0,e.setAttribute(`aria-expanded`,`false`)};e.addEventListener(`click`,()=>n()?i():r()),t.addEventListener(`click`,e=>{let t=e.target.closest(`[data-nav]`);if(t){this._viewM+=Number(t.dataset.nav),this._viewM<0?(this._viewM=11,--this._viewY):this._viewM>11&&(this._viewM=0,this._viewY+=1),this._renderMonth();return}if(e.target.closest(`[data-clear]`)){this.value=``,i();return}let n=e.target.closest(`.datepicker-day[data-iso]`);n&&!n.disabled&&(this.value=n.dataset.iso,i())}),this._onDocClick=e=>{n()&&!this.contains(e.target)&&i()},document.addEventListener(`click`,this._onDocClick),document.addEventListener(`keydown`,e=>{n()&&e.key===`Escape`&&i()}),this._internalsSet()}disconnectedCallback(){this._onDocClick&&document.removeEventListener(`click`,this._onDocClick)}},d=class extends HTMLElement{static formAssociated=!0;static get observedAttributes(){return[`placeholder`,`search-placeholder`,`searchable`,`disabled`]}constructor(){super(),this._internals=this.attachInternals?this.attachInternals():null,this._values=[],this._optionsProp=null,this._active=-1}connectedCallback(){if(!this._rendered){if(!this._valuesInit&&!this._optionsProp&&!this._values.length){let e=[...this.querySelectorAll(`:scope > wui-option[selected]`)].map(e=>e.getAttribute(`value`)??e.textContent.trim());e.length&&(this._values=e.map(String))}this._valuesInit=!0,this.render()}}attributeChangedCallback(){this._rendered&&this.render()}get values(){return this._values.slice()}set values(e){this._values=Array.isArray(e)?e.map(String):[],this._internals?.setFormValue(this._values.join(`,`)),this._rendered&&this._renderControl()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.isConnected&&this.render()}get options(){return this._readOptions()}_readOptions(){return this._optionsProp?this._optionsProp:[...this.querySelectorAll(`:scope > wui-option`)].map(e=>({value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML}))}_labelFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?t.label:e}render(){let e=this.hasAttribute(`searchable`),t=this.getAttribute(`search-placeholder`)||`Search…`;this._internals?.setFormValue(this._values.join(`,`)),this.innerHTML=`
29
+ <div class="search-select">
30
+ <div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute(`disabled`)?` aria-disabled="true"`:``}>
31
+ <div class="ms-chips" data-chips></div>
32
+ <i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
33
+ </div>
34
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" aria-multiselectable="true" tabindex="-1" hidden>
35
+ ${e?`<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${f(t)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden><i class="bi bi-x" aria-hidden="true"></i></button></div>`:``}
36
+ <div class="search-select-options"></div>
37
+ <div class="search-select-empty" hidden>No matches</div>
38
+ </div>
39
+ </div>`,this._rendered=!0,this._renderControl(),this._renderOptions(),this._wire()}_renderControl(){let e=this.querySelector(`[data-chips]`);if(!e)return;let t=this.getAttribute(`placeholder`)||`Select…`;if(!this._values.length){e.innerHTML=`<span class="search-select-placeholder">${p(t)}</span>`;return}e.innerHTML=this._values.map(e=>`<span class="chip chip-sm"><span class="chip-label">${this._labelFor(e)}</span><button type="button" class="chip-remove" data-remove="${f(e)}" aria-label="Remove"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join(``)}_renderOptions(e){let t=this.querySelector(`.search-select-options`),n=this.querySelector(`.search-select-empty`);if(!t)return;let r=(e||``).trim().toLowerCase(),i=this._readOptions();r&&(i=i.filter(e=>m(e.label).toLowerCase().includes(r))),t.innerHTML=i.map(e=>{let t=this._values.includes(String(e.value));return`<button type="button" role="option" class="search-select-option${t?` selected`:``}" data-value="${f(e.value)}" aria-selected="${t}"><span class="ms-check"><i class="bi bi-check" aria-hidden="true"></i></span><span class="ms-opt-label">${e.label}</span></button>`}).join(``),n&&(n.hidden=i.length>0),this._active=-1}_wire(){let e=this.querySelector(`.search-select-control`),t=this.querySelector(`.search-select-menu`),n=this.querySelector(`.search-select-input`),r=this.querySelector(`.search-select-clear`),i=this.querySelector(`.search-select-options`);if(this.querySelector(`[data-chips]`),!e||!t)return;let a=()=>this.hasAttribute(`disabled`),o=()=>{let n=e.getBoundingClientRect();t.style.position=`fixed`,t.style.top=`${n.bottom+4}px`,t.style.left=`${n.left}px`,t.style.width=`${n.width}px`},s=()=>[...this.querySelectorAll(`.search-select-option`)],c=()=>s().filter(e=>!e.hidden),l=e=>{let t=c();this._active=e;for(let e of s())e.classList.remove(`is-active`);e>=0&&t[e]&&(t[e].classList.add(`is-active`),t[e].scrollIntoView({block:`nearest`}))},u=()=>!t.hidden,d=()=>{a()||(t.hidden=!1,e.setAttribute(`aria-expanded`,`true`),e.classList.add(`open`),o(),n&&(n.value=``,this._renderOptions(``),n.focus()))},f=()=>{t.hidden=!0,e.setAttribute(`aria-expanded`,`false`),e.classList.remove(`open`),l(-1)},p=()=>{this._internals?.setFormValue(this._values.join(`,`)),this.dispatchEvent(new Event(`change`,{bubbles:!0}))},m=e=>{let t=String(e);this._values.includes(t)?this._values=this._values.filter(e=>e!==t):this._values=[...this._values,t],this._renderControl(),this._renderOptions(n?n.value:``),p()},h=e=>{this._values=this._values.filter(t=>t!==String(e)),this._renderControl(),this._renderOptions(n?n.value:``),p()};e.addEventListener(`click`,e=>{let t=e.target.closest(`[data-remove]`);if(t){e.stopPropagation(),h(t.dataset.remove);return}u()?f():d()}),i.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&(m(t.dataset.value),n?.focus())}),i.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&l(c().indexOf(t))}),n?.addEventListener(`input`,()=>{this._renderOptions(n.value),r&&(r.hidden=!n.value),l(-1)}),n?.addEventListener(`keydown`,t=>{let r=c();t.key===`ArrowDown`?(t.preventDefault(),l(Math.min(this._active+1,r.length-1))):t.key===`ArrowUp`?(t.preventDefault(),l(Math.max(this._active-1,0))):t.key===`Enter`?(t.preventDefault(),r[this._active]&&m(r[this._active].dataset.value)):t.key===`Escape`?(f(),e.focus()):t.key===`Backspace`&&!n.value&&this._values.length&&h(this._values[this._values.length-1])}),r?.addEventListener(`click`,()=>{n.value=``,this._renderOptions(``),r.hidden=!0,n.focus()}),e.addEventListener(`keydown`,e=>{!u()&&(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d())}),this._onDocClick=e=>{u()&&!this.contains(e.target)&&f()},document.addEventListener(`click`,this._onDocClick),window.addEventListener(`resize`,()=>{u()&&o()})}disconnectedCallback(){this._onDocClick&&document.removeEventListener(`click`,this._onDocClick)}},f=e=>String(e??``).replace(/"/g,`&quot;`).replace(/</g,`&lt;`),p=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`),m=e=>String(e??``).replace(/<[^>]*>/g,``),h=[[`IN`,`India`,`91`],[`US`,`United States`,`1`],[`GB`,`United Kingdom`,`44`],[`AE`,`United Arab Emirates`,`971`],[`SG`,`Singapore`,`65`],[`AU`,`Australia`,`61`],[`CA`,`Canada`,`1`],[`DE`,`Germany`,`49`],[`FR`,`France`,`33`],[`IT`,`Italy`,`39`],[`ES`,`Spain`,`34`],[`NL`,`Netherlands`,`31`],[`CH`,`Switzerland`,`41`],[`SE`,`Sweden`,`46`],[`NO`,`Norway`,`47`],[`DK`,`Denmark`,`45`],[`IE`,`Ireland`,`353`],[`NZ`,`New Zealand`,`64`],[`JP`,`Japan`,`81`],[`CN`,`China`,`86`],[`HK`,`Hong Kong`,`852`],[`MY`,`Malaysia`,`60`],[`ID`,`Indonesia`,`62`],[`TH`,`Thailand`,`66`],[`PH`,`Philippines`,`63`],[`VN`,`Vietnam`,`84`],[`KR`,`South Korea`,`82`],[`SA`,`Saudi Arabia`,`966`],[`QA`,`Qatar`,`974`],[`KW`,`Kuwait`,`965`],[`BH`,`Bahrain`,`973`],[`OM`,`Oman`,`968`],[`ZA`,`South Africa`,`27`],[`NG`,`Nigeria`,`234`],[`KE`,`Kenya`,`254`],[`EG`,`Egypt`,`20`],[`BR`,`Brazil`,`55`],[`MX`,`Mexico`,`52`],[`AR`,`Argentina`,`54`],[`BD`,`Bangladesh`,`880`],[`PK`,`Pakistan`,`92`],[`LK`,`Sri Lanka`,`94`],[`NP`,`Nepal`,`977`]],g=e=>e.toUpperCase().replace(/./g,e=>String.fromCodePoint(127397+e.charCodeAt(0))),_=e=>(h.find(t=>t[0]===e)||[``,``,``])[2],v=class extends HTMLElement{static formAssociated=!0;static get observedAttributes(){return[`value`,`country`,`placeholder`,`disabled`]}constructor(){super(),this._internals=this.attachInternals?this.attachInternals():null,this._country=`IN`,this._national=``}connectedCallback(){this._rendered||this.render()}attributeChangedCallback(e,t,n){this._rendered&&(e===`country`&&(this._country=n||`IN`),this.render())}get value(){return`+${_(this._country)}${this._national}`}set value(e){this._national=String(e??``).replace(/[^0-9]/g,``),this._commit()}_commit(){this._internals?.setFormValue(this.value),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}render(){let e=this.getAttribute(`placeholder`)||`Enter phone number`;this._country=this.getAttribute(`country`)||this._country;let t=h.map(([e,t,n])=>`<button type="button" role="option" class="country-dropdown-item${e===this._country?` selected`:``}" data-iso="${e}"><span class="phone-flag-lg">${g(e)}</span><span class="country-name-text">${t}<span class="country-code-text">+${n}</span></span></button>`).join(``);this.innerHTML=`
40
+ <div class="phone-input-wrap">
41
+ <div class="phone-country-adornment">
42
+ <button type="button" class="country-toggle" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute(`disabled`)?` disabled`:``}>
43
+ <span class="phone-flag" data-flag>${g(this._country)}</span>
44
+ <i class="bi bi-chevron-down phone-chevron" aria-hidden="true"></i>
45
+ <span class="phone-dial" data-dial>+${_(this._country)}</span>
46
+ </button>
47
+ <div class="country-dropdown-menu" role="listbox" hidden>
48
+ <div class="dropdown-search-wrapper"><span class="dropdown-search-icon"><i class="bi bi-search" aria-hidden="true"></i></span><input type="text" class="dropdown-search-input" placeholder="Search country or code" aria-label="Search countries" /></div>
49
+ <div class="country-list-scroll">${t}<div class="country-empty" hidden>No countries found</div></div>
50
+ </div>
51
+ </div>
52
+ <input type="tel" class="input" placeholder="${y(e)}" value="${y(this._national)}"${this.hasAttribute(`disabled`)?` disabled`:``} />
53
+ </div>`,this._rendered=!0,this._wire()}_wire(){let e=this.querySelector(`.country-toggle`),t=this.querySelector(`.country-dropdown-menu`),n=this.querySelector(`.dropdown-search-input`),r=this.querySelector(`.country-list-scroll`),i=this.querySelector(`.country-empty`),a=this.querySelector(`input[type=tel]`),o=this.querySelector(`[data-flag]`),s=this.querySelector(`[data-dial]`);if(!e||!t)return;let c=()=>!t.hidden,l=()=>{t.hidden=!1,e.setAttribute(`aria-expanded`,`true`),n.value=``,d(``),n.focus()},u=()=>{t.hidden=!0,e.setAttribute(`aria-expanded`,`false`)},d=e=>{let t=e.trim().toLowerCase(),n=0;for(let e of r.querySelectorAll(`.country-dropdown-item`)){let r=!t||e.textContent.toLowerCase().includes(t);e.hidden=!r,r&&(n+=1)}i&&(i.hidden=n>0)},f=e=>{this._country=e,this.setAttribute(`country`,e),o&&(o.textContent=g(e)),s&&(s.textContent=`+${_(e)}`);for(let t of r.querySelectorAll(`.country-dropdown-item`))t.classList.toggle(`selected`,t.dataset.iso===e);u(),this._commit()};e.addEventListener(`click`,()=>c()?u():l()),n.addEventListener(`input`,()=>d(n.value)),r.addEventListener(`click`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&f(t.dataset.iso)}),a.addEventListener(`input`,()=>{this._national=a.value.replace(/[^0-9]/g,``),this._commit()}),this._onDocClick=e=>{c()&&!this.contains(e.target)&&u()},document.addEventListener(`click`,this._onDocClick),this._internals?.setFormValue(this.value)}disconnectedCallback(){this._onDocClick&&document.removeEventListener(`click`,this._onDocClick)}},y=e=>String(e??``).replace(/"/g,`&quot;`).replace(/</g,`&lt;`),b=class extends HTMLElement{static formAssociated=!0;static get observedAttributes(){return[`value`,`placeholder`,`search-placeholder`,`searchable`,`disabled`,`compact`]}constructor(){super(),this._internals=this.attachInternals?this.attachInternals():null,this._value=``,this._optionsProp=null,this._active=-1}connectedCallback(){this._rendered||this.render()}attributeChangedCallback(e,t,n){this._rendered&&(e===`value`?this.value=n:this.render())}get value(){return this._value}set value(e){this._value=e==null?``:String(e),this._internals?.setFormValue(this._value),this._syncSelected()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.isConnected&&this.render()}get options(){return this._readOptions()}_readOptions(){return this._optionsProp?this._optionsProp:[...this.querySelectorAll(`:scope > wui-option`)].map(e=>({value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,selected:e.hasAttribute(`selected`)}))}render(){let e=this._readOptions(),t=this.hasAttribute(`searchable`),n=this.getAttribute(`placeholder`)||`Select...`,r=this.getAttribute(`search-placeholder`)||`Search...`,i=e.find(e=>String(e.value)===String(this._value))||e.find(e=>e.selected);i&&(this._value=String(i.value)),this._internals?.setFormValue(this._value);let a=e.map(e=>{let t=String(e.value)===String(this._value);return`<button type="button" role="option" class="search-select-option${t?` selected`:``}" data-value="${x(e.value)}" aria-selected="${t}">${e.label}</button>`}).join(``);this.innerHTML=`
54
+ <div class="search-select${this.hasAttribute(`compact`)?` search-select-compact`:``}">
55
+ <button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute(`disabled`)?` disabled`:``}>
56
+ <span class="${i?``:`search-select-placeholder`}" data-label>${i?i.label:n}</span>
57
+ <i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
58
+ </button>
59
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" tabindex="-1" hidden>
60
+ ${t?`<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${x(r)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden><i class="bi bi-x" aria-hidden="true"></i></button></div>`:``}
61
+ <div class="search-select-options">${a}<div class="search-select-empty" hidden>No matches</div></div>
62
+ </div>
63
+ </div>`,this._rendered=!0,this._wire()}_refs(){return{control:this.querySelector(`.search-select-control`),menu:this.querySelector(`.search-select-menu`),label:this.querySelector(`[data-label]`),search:this.querySelector(`.search-select-input`),clear:this.querySelector(`.search-select-clear`),empty:this.querySelector(`.search-select-empty`),optionsWrap:this.querySelector(`.search-select-options`)}}_optionEls(){return[...this.querySelectorAll(`.search-select-option`)]}_visible(){return this._optionEls().filter(e=>!e.hidden)}_syncSelected(){let{label:e}=this._refs(),t=this._readOptions().find(e=>String(e.value)===String(this._value));for(let e of this._optionEls()){let t=e.dataset.value===String(this._value);e.classList.toggle(`selected`,t),e.setAttribute(`aria-selected`,String(t))}e&&(e.innerHTML=t?t.label:e.innerHTML,e.classList.toggle(`search-select-placeholder`,!t))}_wire(){let e=this._refs();if(!e.control||!e.menu)return;let t=()=>{let t=e.control.getBoundingClientRect();e.menu.style.position=`fixed`,e.menu.style.top=`${t.bottom+4}px`,e.menu.style.left=`${t.left}px`,e.menu.style.width=`${t.width}px`},n=e=>{let t=this._visible();this._active=e;for(let e of this._optionEls())e.classList.remove(`is-active`);e>=0&&t[e]&&(t[e].classList.add(`is-active`),t[e].scrollIntoView({block:`nearest`}))},r=t=>{let n=t.trim().toLowerCase(),r=0;for(let e of this._optionEls()){let t=!n||e.textContent.toLowerCase().includes(n);e.hidden=!t,t&&(r+=1)}e.empty&&(e.empty.hidden=r>0),e.clear&&(e.clear.hidden=!n)},i=()=>!e.menu.hidden,a=()=>{e.menu.hidden=!1,e.control.setAttribute(`aria-expanded`,`true`),e.control.classList.add(`open`),t(),e.search&&(e.search.value=``,r(``),e.search.focus()),n(this._optionEls().findIndex(e=>e.classList.contains(`selected`)))},o=()=>{e.menu.hidden=!0,e.control.setAttribute(`aria-expanded`,`false`),e.control.classList.remove(`open`),n(-1)},s=t=>{this.value=t.dataset.value,this.dispatchEvent(new Event(`change`,{bubbles:!0})),o(),e.control.focus()},c=t=>{let r=this._visible();t.key===`ArrowDown`?(t.preventDefault(),n(Math.min(this._active+1,r.length-1))):t.key===`ArrowUp`?(t.preventDefault(),n(Math.max(this._active-1,0))):t.key===`Enter`?(t.preventDefault(),r[this._active]&&s(r[this._active])):t.key===`Escape`&&(o(),e.control.focus())};e.control.addEventListener(`click`,()=>i()?o():a()),e.control.addEventListener(`keydown`,e=>{!i()&&(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())}),e.optionsWrap.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&s(t)}),e.optionsWrap.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&n(this._visible().indexOf(t))}),e.search?.addEventListener(`input`,()=>{r(e.search.value),n(-1)}),e.search?.addEventListener(`keydown`,c),e.clear?.addEventListener(`click`,()=>{e.search.value=``,r(``),e.search.focus()}),e.menu.addEventListener(`keydown`,c),this._onDocClick=e=>{i()&&!this.contains(e.target)&&o()},document.addEventListener(`click`,this._onDocClick),window.addEventListener(`resize`,()=>{i()&&t()})}disconnectedCallback(){this._onDocClick&&document.removeEventListener(`click`,this._onDocClick)}},x=e=>String(e??``).replace(/"/g,`&quot;`).replace(/</g,`&lt;`),S=(e,t)=>{typeof customElements<`u`&&!customElements.get(e)&&customElements.define(e,t)};function C(){S(`wui-select`,b),S(`wui-phone`,v),S(`wui-datepicker`,u),S(`wui-autocomplete`,t),S(`wui-multiselect`,d)}return C(),e.WuiAutocomplete=t,e.WuiDatePicker=u,e.WuiMultiSelect=d,e.WuiPhone=v,e.WuiSelect=b,e.defineWeborityElements=C,e})({});
@@ -0,0 +1,862 @@
1
+ //#region src/WuiAutocomplete.js
2
+ var e = class extends HTMLElement {
3
+ static formAssociated = !0;
4
+ static get observedAttributes() {
5
+ return [
6
+ "value",
7
+ "placeholder",
8
+ "disabled",
9
+ "min-chars",
10
+ "debounce",
11
+ "remote"
12
+ ];
13
+ }
14
+ constructor() {
15
+ super(), this._internals = this.attachInternals ? this.attachInternals() : null, this._value = "", this._label = "", this._optionsProp = null, this._loading = !1, this._active = -1, this._timer = null;
16
+ }
17
+ connectedCallback() {
18
+ this._rendered || this.render();
19
+ }
20
+ attributeChangedCallback(e, t, n) {
21
+ this._rendered && (e === "value" ? this.value = n : this.render());
22
+ }
23
+ get value() {
24
+ return this._value;
25
+ }
26
+ set value(e) {
27
+ this._value = e == null ? "" : String(e), this._internals?.setFormValue(this._value);
28
+ let t = this._readOptions().find((e) => String(e.value) === this._value);
29
+ t && (this._label = n(t.label)), this._syncInput();
30
+ }
31
+ set options(e) {
32
+ this._optionsProp = Array.isArray(e) ? e : [], this._renderOptions();
33
+ }
34
+ get options() {
35
+ return this._readOptions();
36
+ }
37
+ set loading(e) {
38
+ this._loading = !!e, this._renderLoading();
39
+ }
40
+ get loading() {
41
+ return this._loading;
42
+ }
43
+ get _remote() {
44
+ return this.hasAttribute("remote");
45
+ }
46
+ get _minChars() {
47
+ return Math.max(0, Number(this.getAttribute("min-chars")) || +!!this._remote);
48
+ }
49
+ get _debounceMs() {
50
+ let e = Number(this.getAttribute("debounce"));
51
+ return Number.isFinite(e) && e >= 0 ? e : 250;
52
+ }
53
+ _readOptions() {
54
+ return this._optionsProp ? this._optionsProp : [...this.querySelectorAll(":scope > wui-option")].map((e) => ({
55
+ value: e.getAttribute("value") ?? e.textContent.trim(),
56
+ label: e.innerHTML
57
+ }));
58
+ }
59
+ render() {
60
+ let e = this.getAttribute("placeholder") || "Search…";
61
+ this.innerHTML = `
62
+ <div class="search-select">
63
+ <div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false">
64
+ <input class="search-select-input search-select-ac-input" placeholder="${t(e)}" aria-autocomplete="list" autocomplete="off"${this.hasAttribute("disabled") ? " disabled" : ""} />
65
+ <span class="search-select-spinner spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
66
+ <button type="button" class="search-select-clear" aria-label="Clear" hidden><i class="bi bi-x" aria-hidden="true"></i></button>
67
+ </div>
68
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" tabindex="-1" hidden>
69
+ <div class="search-select-options"></div>
70
+ <div class="search-select-empty" hidden>No matches</div>
71
+ <div class="search-select-hint" hidden>Type to search…</div>
72
+ </div>
73
+ </div>`, this._rendered = !0, this._wire(), this._syncInput(), this._renderOptions();
74
+ }
75
+ _refs() {
76
+ return {
77
+ control: this.querySelector(".search-select-control"),
78
+ input: this.querySelector(".search-select-ac-input"),
79
+ menu: this.querySelector(".search-select-menu"),
80
+ spinner: this.querySelector(".search-select-spinner"),
81
+ clear: this.querySelector(".search-select-clear"),
82
+ optionsWrap: this.querySelector(".search-select-options"),
83
+ empty: this.querySelector(".search-select-empty"),
84
+ hint: this.querySelector(".search-select-hint")
85
+ };
86
+ }
87
+ _optionEls() {
88
+ return [...this.querySelectorAll(".search-select-option")];
89
+ }
90
+ _syncInput() {
91
+ let { input: e, clear: t } = this._refs();
92
+ e && document.activeElement !== e && (e.value = this._label), t && (t.hidden = !this._value && !(e && e.value));
93
+ }
94
+ _renderLoading() {
95
+ let { spinner: e } = this._refs();
96
+ e && (e.hidden = !this._loading);
97
+ }
98
+ _renderOptions(e) {
99
+ let r = this._refs();
100
+ if (!r.optionsWrap) return;
101
+ let i = (e ?? (r.input ? r.input.value : "")).trim().toLowerCase(), a = this._readOptions();
102
+ !this._remote && i && (a = a.filter((e) => n(e.label).toLowerCase().includes(i))), r.optionsWrap.innerHTML = a.map((e) => {
103
+ let n = String(e.value) === String(this._value);
104
+ return `<button type="button" role="option" class="search-select-option${n ? " selected" : ""}" data-value="${t(e.value)}" aria-selected="${n}">${e.label}</button>`;
105
+ }).join(""), this._active = -1;
106
+ let o = i.length < this._minChars;
107
+ r.hint && (r.hint.hidden = !(this._remote && o && !a.length)), r.empty && (r.empty.hidden = this._loading || a.length > 0 || this._remote && o);
108
+ }
109
+ _wire() {
110
+ let e = this._refs();
111
+ if (!e.control || !e.input) return;
112
+ let t = () => {
113
+ let t = e.control.getBoundingClientRect();
114
+ e.menu.style.position = "fixed", e.menu.style.top = `${t.bottom + 4}px`, e.menu.style.left = `${t.left}px`, e.menu.style.width = `${t.width}px`;
115
+ }, r = () => this._optionEls().filter((e) => !e.hidden), i = (e) => {
116
+ let t = r();
117
+ this._active = e;
118
+ for (let e of this._optionEls()) e.classList.remove("is-active");
119
+ e >= 0 && t[e] && (t[e].classList.add("is-active"), t[e].scrollIntoView({ block: "nearest" }));
120
+ }, a = () => !e.menu.hidden, o = () => {
121
+ e.menu.hidden = !1, e.control.setAttribute("aria-expanded", "true"), e.control.classList.add("open"), t(), this._renderOptions();
122
+ }, s = () => {
123
+ e.menu.hidden = !0, e.control.setAttribute("aria-expanded", "false"), e.control.classList.remove("open"), i(-1), this._syncInput();
124
+ }, c = (t) => {
125
+ this._value = t.dataset.value, this._label = n(t.innerHTML), this._internals?.setFormValue(this._value), e.input.value = this._label, this.dispatchEvent(new Event("change", { bubbles: !0 })), s(), e.input.focus();
126
+ };
127
+ e.input.addEventListener("focus", () => o()), e.input.addEventListener("input", () => {
128
+ let t = e.input.value;
129
+ if (e.clear && (e.clear.hidden = !t), a() || o(), this._remote) {
130
+ if (this._renderOptions(t), t.trim().length < this._minChars) return;
131
+ clearTimeout(this._timer), this._timer = setTimeout(() => {
132
+ this.dispatchEvent(new CustomEvent("search", {
133
+ bubbles: !0,
134
+ detail: { query: t }
135
+ }));
136
+ }, this._debounceMs);
137
+ } else this._renderOptions(t);
138
+ }), e.input.addEventListener("keydown", (e) => {
139
+ let t = r();
140
+ e.key === "ArrowDown" ? (e.preventDefault(), a() || o(), i(Math.min(this._active + 1, t.length - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), i(Math.max(this._active - 1, 0))) : e.key === "Enter" ? t[this._active] && (e.preventDefault(), c(t[this._active])) : e.key === "Escape" && s();
141
+ }), e.optionsWrap.addEventListener("click", (e) => {
142
+ let t = e.target.closest(".search-select-option");
143
+ t && c(t);
144
+ }), e.optionsWrap.addEventListener("mousemove", (e) => {
145
+ let t = e.target.closest(".search-select-option");
146
+ t && i(this._optionEls().indexOf(t));
147
+ }), e.clear?.addEventListener("click", () => {
148
+ this._value = "", this._label = "", this._internals?.setFormValue(""), e.input.value = "", e.clear.hidden = !0, this._renderOptions(""), this.dispatchEvent(new Event("change", { bubbles: !0 })), e.input.focus();
149
+ }), this._onDocClick = (e) => {
150
+ a() && !this.contains(e.target) && s();
151
+ }, document.addEventListener("click", this._onDocClick), window.addEventListener("resize", () => {
152
+ a() && t();
153
+ });
154
+ }
155
+ disconnectedCallback() {
156
+ this._onDocClick && document.removeEventListener("click", this._onDocClick), clearTimeout(this._timer);
157
+ }
158
+ }, t = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), n = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), r = [
159
+ "January",
160
+ "February",
161
+ "March",
162
+ "April",
163
+ "May",
164
+ "June",
165
+ "July",
166
+ "August",
167
+ "September",
168
+ "October",
169
+ "November",
170
+ "December"
171
+ ], i = [
172
+ "Su",
173
+ "Mo",
174
+ "Tu",
175
+ "We",
176
+ "Th",
177
+ "Fr",
178
+ "Sa"
179
+ ], a = (e) => String(e).padStart(2, "0"), o = (e, t, n) => `${e}-${a(t + 1)}-${a(n)}`, s = (e) => {
180
+ let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e || "");
181
+ return t ? {
182
+ y: +t[1],
183
+ m: t[2] - 1,
184
+ d: +t[3]
185
+ } : null;
186
+ }, c = (e) => {
187
+ let t = s(e);
188
+ return t ? `${a(t.d)} ${r[t.m].slice(0, 3)} ${t.y}` : "";
189
+ }, l = class extends HTMLElement {
190
+ static formAssociated = !0;
191
+ static get observedAttributes() {
192
+ return [
193
+ "value",
194
+ "min",
195
+ "max",
196
+ "placeholder",
197
+ "disabled"
198
+ ];
199
+ }
200
+ constructor() {
201
+ super(), this._internals = this.attachInternals ? this.attachInternals() : null, this._value = "";
202
+ let e = new Date(2e3, 0, 1);
203
+ this._viewY = e.getFullYear(), this._viewM = e.getMonth();
204
+ }
205
+ connectedCallback() {
206
+ this._rendered || this.render();
207
+ }
208
+ attributeChangedCallback(e, t, n) {
209
+ this._rendered && (e === "value" ? (this._value = n || "", this._syncTrigger()) : this.render());
210
+ }
211
+ get value() {
212
+ return this._value;
213
+ }
214
+ set value(e) {
215
+ this._value = e || "", this._internals?.setFormValue(this._value), this._syncTrigger(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
216
+ }
217
+ render() {
218
+ this._value = this.getAttribute("value") || this._value;
219
+ let e = this.getAttribute("placeholder") || "Enter Date", t = s(this._value);
220
+ t && (this._viewY = t.y, this._viewM = t.m), this.innerHTML = `
221
+ <div class="datepicker">
222
+ <button type="button" class="input datepicker-trigger" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
223
+ <span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ? c(this._value) : e}</span>
224
+ <i class="bi bi-calendar3" aria-hidden="true"></i>
225
+ </button>
226
+ <div class="datepicker-pop" role="dialog" hidden></div>
227
+ </div>`, this._rendered = !0, this._wire();
228
+ }
229
+ _internalsSet() {
230
+ this._internals?.setFormValue(this._value);
231
+ }
232
+ _syncTrigger() {
233
+ let e = this.querySelector("[data-trigger-label]");
234
+ if (!e) return;
235
+ let t = s(this._value);
236
+ e.textContent = t ? c(this._value) : this.getAttribute("placeholder") || "Enter Date", e.classList.toggle("search-select-placeholder", !t);
237
+ }
238
+ _renderMonth() {
239
+ let e = this.querySelector(".datepicker-pop"), t = new Date(this._viewY, this._viewM, 1).getDay(), n = new Date(this._viewY, this._viewM + 1, 0).getDate(), a = s(this._value), c = s(this.getAttribute("min")), l = s(this.getAttribute("max")), u = (e, t, n) => {
240
+ let r = new Date(e, t, n).getTime();
241
+ return !!(c && r < new Date(c.y, c.m, c.d).getTime() || l && r > new Date(l.y, l.m, l.d).getTime());
242
+ }, d = "";
243
+ for (let e = 0; e < t; e++) d += "<span class=\"datepicker-day is-outside\"></span>";
244
+ for (let e = 1; e <= n; e++) {
245
+ let t = o(this._viewY, this._viewM, e), n = a && a.y === this._viewY && a.m === this._viewM && a.d === e, r = u(this._viewY, this._viewM, e);
246
+ d += `<button type="button" class="datepicker-day${n ? " selected" : ""}" data-iso="${t}"${r ? " disabled" : ""}>${e}</button>`;
247
+ }
248
+ e.innerHTML = `
249
+ <div class="datepicker-head">
250
+ <button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="Previous month"><i class="bi bi-chevron-left" aria-hidden="true"></i></button>
251
+ <span class="datepicker-month">${r[this._viewM]} ${this._viewY}</span>
252
+ <button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="Next month"><i class="bi bi-chevron-right" aria-hidden="true"></i></button>
253
+ </div>
254
+ <div class="datepicker-weekdays">${i.map((e) => `<span>${e}</span>`).join("")}</div>
255
+ <div class="datepicker-grid">${d}</div>
256
+ <div class="datepicker-foot"><button type="button" class="datepicker-link" data-clear>Clear</button></div>`;
257
+ }
258
+ _wire() {
259
+ let e = this.querySelector(".datepicker-trigger"), t = this.querySelector(".datepicker-pop");
260
+ if (!e || !t) return;
261
+ let n = () => !t.hidden, r = () => {
262
+ this._renderMonth(), t.hidden = !1, e.setAttribute("aria-expanded", "true");
263
+ }, i = () => {
264
+ t.hidden = !0, e.setAttribute("aria-expanded", "false");
265
+ };
266
+ e.addEventListener("click", () => n() ? i() : r()), t.addEventListener("click", (e) => {
267
+ let t = e.target.closest("[data-nav]");
268
+ if (t) {
269
+ this._viewM += Number(t.dataset.nav), this._viewM < 0 ? (this._viewM = 11, --this._viewY) : this._viewM > 11 && (this._viewM = 0, this._viewY += 1), this._renderMonth();
270
+ return;
271
+ }
272
+ if (e.target.closest("[data-clear]")) {
273
+ this.value = "", i();
274
+ return;
275
+ }
276
+ let n = e.target.closest(".datepicker-day[data-iso]");
277
+ n && !n.disabled && (this.value = n.dataset.iso, i());
278
+ }), this._onDocClick = (e) => {
279
+ n() && !this.contains(e.target) && i();
280
+ }, document.addEventListener("click", this._onDocClick), document.addEventListener("keydown", (e) => {
281
+ n() && e.key === "Escape" && i();
282
+ }), this._internalsSet();
283
+ }
284
+ disconnectedCallback() {
285
+ this._onDocClick && document.removeEventListener("click", this._onDocClick);
286
+ }
287
+ }, u = class extends HTMLElement {
288
+ static formAssociated = !0;
289
+ static get observedAttributes() {
290
+ return [
291
+ "placeholder",
292
+ "search-placeholder",
293
+ "searchable",
294
+ "disabled"
295
+ ];
296
+ }
297
+ constructor() {
298
+ super(), this._internals = this.attachInternals ? this.attachInternals() : null, this._values = [], this._optionsProp = null, this._active = -1;
299
+ }
300
+ connectedCallback() {
301
+ if (!this._rendered) {
302
+ if (!this._valuesInit && !this._optionsProp && !this._values.length) {
303
+ let e = [...this.querySelectorAll(":scope > wui-option[selected]")].map((e) => e.getAttribute("value") ?? e.textContent.trim());
304
+ e.length && (this._values = e.map(String));
305
+ }
306
+ this._valuesInit = !0, this.render();
307
+ }
308
+ }
309
+ attributeChangedCallback() {
310
+ this._rendered && this.render();
311
+ }
312
+ get values() {
313
+ return this._values.slice();
314
+ }
315
+ set values(e) {
316
+ this._values = Array.isArray(e) ? e.map(String) : [], this._internals?.setFormValue(this._values.join(",")), this._rendered && this._renderControl();
317
+ }
318
+ set options(e) {
319
+ this._optionsProp = Array.isArray(e) ? e : null, this.isConnected && this.render();
320
+ }
321
+ get options() {
322
+ return this._readOptions();
323
+ }
324
+ _readOptions() {
325
+ return this._optionsProp ? this._optionsProp : [...this.querySelectorAll(":scope > wui-option")].map((e) => ({
326
+ value: e.getAttribute("value") ?? e.textContent.trim(),
327
+ label: e.innerHTML
328
+ }));
329
+ }
330
+ _labelFor(e) {
331
+ let t = this._readOptions().find((t) => String(t.value) === String(e));
332
+ return t ? t.label : e;
333
+ }
334
+ render() {
335
+ let e = this.hasAttribute("searchable"), t = this.getAttribute("search-placeholder") || "Search…";
336
+ this._internals?.setFormValue(this._values.join(",")), this.innerHTML = `
337
+ <div class="search-select">
338
+ <div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : ""}>
339
+ <div class="ms-chips" data-chips></div>
340
+ <i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
341
+ </div>
342
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" aria-multiselectable="true" tabindex="-1" hidden>
343
+ ${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${d(t)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden><i class="bi bi-x" aria-hidden="true"></i></button></div>` : ""}
344
+ <div class="search-select-options"></div>
345
+ <div class="search-select-empty" hidden>No matches</div>
346
+ </div>
347
+ </div>`, this._rendered = !0, this._renderControl(), this._renderOptions(), this._wire();
348
+ }
349
+ _renderControl() {
350
+ let e = this.querySelector("[data-chips]");
351
+ if (!e) return;
352
+ let t = this.getAttribute("placeholder") || "Select…";
353
+ if (!this._values.length) {
354
+ e.innerHTML = `<span class="search-select-placeholder">${f(t)}</span>`;
355
+ return;
356
+ }
357
+ e.innerHTML = this._values.map((e) => `<span class="chip chip-sm"><span class="chip-label">${this._labelFor(e)}</span><button type="button" class="chip-remove" data-remove="${d(e)}" aria-label="Remove"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join("");
358
+ }
359
+ _renderOptions(e) {
360
+ let t = this.querySelector(".search-select-options"), n = this.querySelector(".search-select-empty");
361
+ if (!t) return;
362
+ let r = (e || "").trim().toLowerCase(), i = this._readOptions();
363
+ r && (i = i.filter((e) => p(e.label).toLowerCase().includes(r))), t.innerHTML = i.map((e) => {
364
+ let t = this._values.includes(String(e.value));
365
+ return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${d(e.value)}" aria-selected="${t}"><span class="ms-check"><i class="bi bi-check" aria-hidden="true"></i></span><span class="ms-opt-label">${e.label}</span></button>`;
366
+ }).join(""), n && (n.hidden = i.length > 0), this._active = -1;
367
+ }
368
+ _wire() {
369
+ let e = this.querySelector(".search-select-control"), t = this.querySelector(".search-select-menu"), n = this.querySelector(".search-select-input"), r = this.querySelector(".search-select-clear"), i = this.querySelector(".search-select-options");
370
+ if (this.querySelector("[data-chips]"), !e || !t) return;
371
+ let a = () => this.hasAttribute("disabled"), o = () => {
372
+ let n = e.getBoundingClientRect();
373
+ t.style.position = "fixed", t.style.top = `${n.bottom + 4}px`, t.style.left = `${n.left}px`, t.style.width = `${n.width}px`;
374
+ }, s = () => [...this.querySelectorAll(".search-select-option")], c = () => s().filter((e) => !e.hidden), l = (e) => {
375
+ let t = c();
376
+ this._active = e;
377
+ for (let e of s()) e.classList.remove("is-active");
378
+ e >= 0 && t[e] && (t[e].classList.add("is-active"), t[e].scrollIntoView({ block: "nearest" }));
379
+ }, u = () => !t.hidden, d = () => {
380
+ a() || (t.hidden = !1, e.setAttribute("aria-expanded", "true"), e.classList.add("open"), o(), n && (n.value = "", this._renderOptions(""), n.focus()));
381
+ }, f = () => {
382
+ t.hidden = !0, e.setAttribute("aria-expanded", "false"), e.classList.remove("open"), l(-1);
383
+ }, p = () => {
384
+ this._internals?.setFormValue(this._values.join(",")), this.dispatchEvent(new Event("change", { bubbles: !0 }));
385
+ }, m = (e) => {
386
+ let t = String(e);
387
+ this._values.includes(t) ? this._values = this._values.filter((e) => e !== t) : this._values = [...this._values, t], this._renderControl(), this._renderOptions(n ? n.value : ""), p();
388
+ }, h = (e) => {
389
+ this._values = this._values.filter((t) => t !== String(e)), this._renderControl(), this._renderOptions(n ? n.value : ""), p();
390
+ };
391
+ e.addEventListener("click", (e) => {
392
+ let t = e.target.closest("[data-remove]");
393
+ if (t) {
394
+ e.stopPropagation(), h(t.dataset.remove);
395
+ return;
396
+ }
397
+ u() ? f() : d();
398
+ }), i.addEventListener("click", (e) => {
399
+ let t = e.target.closest(".search-select-option");
400
+ t && (m(t.dataset.value), n?.focus());
401
+ }), i.addEventListener("mousemove", (e) => {
402
+ let t = e.target.closest(".search-select-option");
403
+ t && l(c().indexOf(t));
404
+ }), n?.addEventListener("input", () => {
405
+ this._renderOptions(n.value), r && (r.hidden = !n.value), l(-1);
406
+ }), n?.addEventListener("keydown", (t) => {
407
+ let r = c();
408
+ t.key === "ArrowDown" ? (t.preventDefault(), l(Math.min(this._active + 1, r.length - 1))) : t.key === "ArrowUp" ? (t.preventDefault(), l(Math.max(this._active - 1, 0))) : t.key === "Enter" ? (t.preventDefault(), r[this._active] && m(r[this._active].dataset.value)) : t.key === "Escape" ? (f(), e.focus()) : t.key === "Backspace" && !n.value && this._values.length && h(this._values[this._values.length - 1]);
409
+ }), r?.addEventListener("click", () => {
410
+ n.value = "", this._renderOptions(""), r.hidden = !0, n.focus();
411
+ }), e.addEventListener("keydown", (e) => {
412
+ !u() && (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), d());
413
+ }), this._onDocClick = (e) => {
414
+ u() && !this.contains(e.target) && f();
415
+ }, document.addEventListener("click", this._onDocClick), window.addEventListener("resize", () => {
416
+ u() && o();
417
+ });
418
+ }
419
+ disconnectedCallback() {
420
+ this._onDocClick && document.removeEventListener("click", this._onDocClick);
421
+ }
422
+ }, d = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), f = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;"), p = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), m = [
423
+ [
424
+ "IN",
425
+ "India",
426
+ "91"
427
+ ],
428
+ [
429
+ "US",
430
+ "United States",
431
+ "1"
432
+ ],
433
+ [
434
+ "GB",
435
+ "United Kingdom",
436
+ "44"
437
+ ],
438
+ [
439
+ "AE",
440
+ "United Arab Emirates",
441
+ "971"
442
+ ],
443
+ [
444
+ "SG",
445
+ "Singapore",
446
+ "65"
447
+ ],
448
+ [
449
+ "AU",
450
+ "Australia",
451
+ "61"
452
+ ],
453
+ [
454
+ "CA",
455
+ "Canada",
456
+ "1"
457
+ ],
458
+ [
459
+ "DE",
460
+ "Germany",
461
+ "49"
462
+ ],
463
+ [
464
+ "FR",
465
+ "France",
466
+ "33"
467
+ ],
468
+ [
469
+ "IT",
470
+ "Italy",
471
+ "39"
472
+ ],
473
+ [
474
+ "ES",
475
+ "Spain",
476
+ "34"
477
+ ],
478
+ [
479
+ "NL",
480
+ "Netherlands",
481
+ "31"
482
+ ],
483
+ [
484
+ "CH",
485
+ "Switzerland",
486
+ "41"
487
+ ],
488
+ [
489
+ "SE",
490
+ "Sweden",
491
+ "46"
492
+ ],
493
+ [
494
+ "NO",
495
+ "Norway",
496
+ "47"
497
+ ],
498
+ [
499
+ "DK",
500
+ "Denmark",
501
+ "45"
502
+ ],
503
+ [
504
+ "IE",
505
+ "Ireland",
506
+ "353"
507
+ ],
508
+ [
509
+ "NZ",
510
+ "New Zealand",
511
+ "64"
512
+ ],
513
+ [
514
+ "JP",
515
+ "Japan",
516
+ "81"
517
+ ],
518
+ [
519
+ "CN",
520
+ "China",
521
+ "86"
522
+ ],
523
+ [
524
+ "HK",
525
+ "Hong Kong",
526
+ "852"
527
+ ],
528
+ [
529
+ "MY",
530
+ "Malaysia",
531
+ "60"
532
+ ],
533
+ [
534
+ "ID",
535
+ "Indonesia",
536
+ "62"
537
+ ],
538
+ [
539
+ "TH",
540
+ "Thailand",
541
+ "66"
542
+ ],
543
+ [
544
+ "PH",
545
+ "Philippines",
546
+ "63"
547
+ ],
548
+ [
549
+ "VN",
550
+ "Vietnam",
551
+ "84"
552
+ ],
553
+ [
554
+ "KR",
555
+ "South Korea",
556
+ "82"
557
+ ],
558
+ [
559
+ "SA",
560
+ "Saudi Arabia",
561
+ "966"
562
+ ],
563
+ [
564
+ "QA",
565
+ "Qatar",
566
+ "974"
567
+ ],
568
+ [
569
+ "KW",
570
+ "Kuwait",
571
+ "965"
572
+ ],
573
+ [
574
+ "BH",
575
+ "Bahrain",
576
+ "973"
577
+ ],
578
+ [
579
+ "OM",
580
+ "Oman",
581
+ "968"
582
+ ],
583
+ [
584
+ "ZA",
585
+ "South Africa",
586
+ "27"
587
+ ],
588
+ [
589
+ "NG",
590
+ "Nigeria",
591
+ "234"
592
+ ],
593
+ [
594
+ "KE",
595
+ "Kenya",
596
+ "254"
597
+ ],
598
+ [
599
+ "EG",
600
+ "Egypt",
601
+ "20"
602
+ ],
603
+ [
604
+ "BR",
605
+ "Brazil",
606
+ "55"
607
+ ],
608
+ [
609
+ "MX",
610
+ "Mexico",
611
+ "52"
612
+ ],
613
+ [
614
+ "AR",
615
+ "Argentina",
616
+ "54"
617
+ ],
618
+ [
619
+ "BD",
620
+ "Bangladesh",
621
+ "880"
622
+ ],
623
+ [
624
+ "PK",
625
+ "Pakistan",
626
+ "92"
627
+ ],
628
+ [
629
+ "LK",
630
+ "Sri Lanka",
631
+ "94"
632
+ ],
633
+ [
634
+ "NP",
635
+ "Nepal",
636
+ "977"
637
+ ]
638
+ ], h = (e) => e.toUpperCase().replace(/./g, (e) => String.fromCodePoint(127397 + e.charCodeAt(0))), g = (e) => (m.find((t) => t[0] === e) || [
639
+ "",
640
+ "",
641
+ ""
642
+ ])[2], _ = class extends HTMLElement {
643
+ static formAssociated = !0;
644
+ static get observedAttributes() {
645
+ return [
646
+ "value",
647
+ "country",
648
+ "placeholder",
649
+ "disabled"
650
+ ];
651
+ }
652
+ constructor() {
653
+ super(), this._internals = this.attachInternals ? this.attachInternals() : null, this._country = "IN", this._national = "";
654
+ }
655
+ connectedCallback() {
656
+ this._rendered || this.render();
657
+ }
658
+ attributeChangedCallback(e, t, n) {
659
+ this._rendered && (e === "country" && (this._country = n || "IN"), this.render());
660
+ }
661
+ get value() {
662
+ return `+${g(this._country)}${this._national}`;
663
+ }
664
+ set value(e) {
665
+ this._national = String(e ?? "").replace(/[^0-9]/g, ""), this._commit();
666
+ }
667
+ _commit() {
668
+ this._internals?.setFormValue(this.value), this.dispatchEvent(new Event("change", { bubbles: !0 }));
669
+ }
670
+ render() {
671
+ let e = this.getAttribute("placeholder") || "Enter phone number";
672
+ this._country = this.getAttribute("country") || this._country;
673
+ let t = m.map(([e, t, n]) => `<button type="button" role="option" class="country-dropdown-item${e === this._country ? " selected" : ""}" data-iso="${e}"><span class="phone-flag-lg">${h(e)}</span><span class="country-name-text">${t}<span class="country-code-text">+${n}</span></span></button>`).join("");
674
+ this.innerHTML = `
675
+ <div class="phone-input-wrap">
676
+ <div class="phone-country-adornment">
677
+ <button type="button" class="country-toggle" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
678
+ <span class="phone-flag" data-flag>${h(this._country)}</span>
679
+ <i class="bi bi-chevron-down phone-chevron" aria-hidden="true"></i>
680
+ <span class="phone-dial" data-dial>+${g(this._country)}</span>
681
+ </button>
682
+ <div class="country-dropdown-menu" role="listbox" hidden>
683
+ <div class="dropdown-search-wrapper"><span class="dropdown-search-icon"><i class="bi bi-search" aria-hidden="true"></i></span><input type="text" class="dropdown-search-input" placeholder="Search country or code" aria-label="Search countries" /></div>
684
+ <div class="country-list-scroll">${t}<div class="country-empty" hidden>No countries found</div></div>
685
+ </div>
686
+ </div>
687
+ <input type="tel" class="input" placeholder="${v(e)}" value="${v(this._national)}"${this.hasAttribute("disabled") ? " disabled" : ""} />
688
+ </div>`, this._rendered = !0, this._wire();
689
+ }
690
+ _wire() {
691
+ let e = this.querySelector(".country-toggle"), t = this.querySelector(".country-dropdown-menu"), n = this.querySelector(".dropdown-search-input"), r = this.querySelector(".country-list-scroll"), i = this.querySelector(".country-empty"), a = this.querySelector("input[type=tel]"), o = this.querySelector("[data-flag]"), s = this.querySelector("[data-dial]");
692
+ if (!e || !t) return;
693
+ let c = () => !t.hidden, l = () => {
694
+ t.hidden = !1, e.setAttribute("aria-expanded", "true"), n.value = "", d(""), n.focus();
695
+ }, u = () => {
696
+ t.hidden = !0, e.setAttribute("aria-expanded", "false");
697
+ }, d = (e) => {
698
+ let t = e.trim().toLowerCase(), n = 0;
699
+ for (let e of r.querySelectorAll(".country-dropdown-item")) {
700
+ let r = !t || e.textContent.toLowerCase().includes(t);
701
+ e.hidden = !r, r && (n += 1);
702
+ }
703
+ i && (i.hidden = n > 0);
704
+ }, f = (e) => {
705
+ this._country = e, this.setAttribute("country", e), o && (o.textContent = h(e)), s && (s.textContent = `+${g(e)}`);
706
+ for (let t of r.querySelectorAll(".country-dropdown-item")) t.classList.toggle("selected", t.dataset.iso === e);
707
+ u(), this._commit();
708
+ };
709
+ e.addEventListener("click", () => c() ? u() : l()), n.addEventListener("input", () => d(n.value)), r.addEventListener("click", (e) => {
710
+ let t = e.target.closest(".country-dropdown-item");
711
+ t && f(t.dataset.iso);
712
+ }), a.addEventListener("input", () => {
713
+ this._national = a.value.replace(/[^0-9]/g, ""), this._commit();
714
+ }), this._onDocClick = (e) => {
715
+ c() && !this.contains(e.target) && u();
716
+ }, document.addEventListener("click", this._onDocClick), this._internals?.setFormValue(this.value);
717
+ }
718
+ disconnectedCallback() {
719
+ this._onDocClick && document.removeEventListener("click", this._onDocClick);
720
+ }
721
+ }, v = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), y = class extends HTMLElement {
722
+ static formAssociated = !0;
723
+ static get observedAttributes() {
724
+ return [
725
+ "value",
726
+ "placeholder",
727
+ "search-placeholder",
728
+ "searchable",
729
+ "disabled",
730
+ "compact"
731
+ ];
732
+ }
733
+ constructor() {
734
+ super(), this._internals = this.attachInternals ? this.attachInternals() : null, this._value = "", this._optionsProp = null, this._active = -1;
735
+ }
736
+ connectedCallback() {
737
+ this._rendered || this.render();
738
+ }
739
+ attributeChangedCallback(e, t, n) {
740
+ this._rendered && (e === "value" ? this.value = n : this.render());
741
+ }
742
+ get value() {
743
+ return this._value;
744
+ }
745
+ set value(e) {
746
+ this._value = e == null ? "" : String(e), this._internals?.setFormValue(this._value), this._syncSelected();
747
+ }
748
+ set options(e) {
749
+ this._optionsProp = Array.isArray(e) ? e : null, this.isConnected && this.render();
750
+ }
751
+ get options() {
752
+ return this._readOptions();
753
+ }
754
+ _readOptions() {
755
+ return this._optionsProp ? this._optionsProp : [...this.querySelectorAll(":scope > wui-option")].map((e) => ({
756
+ value: e.getAttribute("value") ?? e.textContent.trim(),
757
+ label: e.innerHTML,
758
+ selected: e.hasAttribute("selected")
759
+ }));
760
+ }
761
+ render() {
762
+ let e = this._readOptions(), t = this.hasAttribute("searchable"), n = this.getAttribute("placeholder") || "Select...", r = this.getAttribute("search-placeholder") || "Search...", i = e.find((e) => String(e.value) === String(this._value)) || e.find((e) => e.selected);
763
+ i && (this._value = String(i.value)), this._internals?.setFormValue(this._value);
764
+ let a = e.map((e) => {
765
+ let t = String(e.value) === String(this._value);
766
+ return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${b(e.value)}" aria-selected="${t}">${e.label}</button>`;
767
+ }).join("");
768
+ this.innerHTML = `
769
+ <div class="search-select${this.hasAttribute("compact") ? " search-select-compact" : ""}">
770
+ <button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
771
+ <span class="${i ? "" : "search-select-placeholder"}" data-label>${i ? i.label : n}</span>
772
+ <i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
773
+ </button>
774
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" tabindex="-1" hidden>
775
+ ${t ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${b(r)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden><i class="bi bi-x" aria-hidden="true"></i></button></div>` : ""}
776
+ <div class="search-select-options">${a}<div class="search-select-empty" hidden>No matches</div></div>
777
+ </div>
778
+ </div>`, this._rendered = !0, this._wire();
779
+ }
780
+ _refs() {
781
+ return {
782
+ control: this.querySelector(".search-select-control"),
783
+ menu: this.querySelector(".search-select-menu"),
784
+ label: this.querySelector("[data-label]"),
785
+ search: this.querySelector(".search-select-input"),
786
+ clear: this.querySelector(".search-select-clear"),
787
+ empty: this.querySelector(".search-select-empty"),
788
+ optionsWrap: this.querySelector(".search-select-options")
789
+ };
790
+ }
791
+ _optionEls() {
792
+ return [...this.querySelectorAll(".search-select-option")];
793
+ }
794
+ _visible() {
795
+ return this._optionEls().filter((e) => !e.hidden);
796
+ }
797
+ _syncSelected() {
798
+ let { label: e } = this._refs(), t = this._readOptions().find((e) => String(e.value) === String(this._value));
799
+ for (let e of this._optionEls()) {
800
+ let t = e.dataset.value === String(this._value);
801
+ e.classList.toggle("selected", t), e.setAttribute("aria-selected", String(t));
802
+ }
803
+ e && (e.innerHTML = t ? t.label : e.innerHTML, e.classList.toggle("search-select-placeholder", !t));
804
+ }
805
+ _wire() {
806
+ let e = this._refs();
807
+ if (!e.control || !e.menu) return;
808
+ let t = () => {
809
+ let t = e.control.getBoundingClientRect();
810
+ e.menu.style.position = "fixed", e.menu.style.top = `${t.bottom + 4}px`, e.menu.style.left = `${t.left}px`, e.menu.style.width = `${t.width}px`;
811
+ }, n = (e) => {
812
+ let t = this._visible();
813
+ this._active = e;
814
+ for (let e of this._optionEls()) e.classList.remove("is-active");
815
+ e >= 0 && t[e] && (t[e].classList.add("is-active"), t[e].scrollIntoView({ block: "nearest" }));
816
+ }, r = (t) => {
817
+ let n = t.trim().toLowerCase(), r = 0;
818
+ for (let e of this._optionEls()) {
819
+ let t = !n || e.textContent.toLowerCase().includes(n);
820
+ e.hidden = !t, t && (r += 1);
821
+ }
822
+ e.empty && (e.empty.hidden = r > 0), e.clear && (e.clear.hidden = !n);
823
+ }, i = () => !e.menu.hidden, a = () => {
824
+ e.menu.hidden = !1, e.control.setAttribute("aria-expanded", "true"), e.control.classList.add("open"), t(), e.search && (e.search.value = "", r(""), e.search.focus()), n(this._optionEls().findIndex((e) => e.classList.contains("selected")));
825
+ }, o = () => {
826
+ e.menu.hidden = !0, e.control.setAttribute("aria-expanded", "false"), e.control.classList.remove("open"), n(-1);
827
+ }, s = (t) => {
828
+ this.value = t.dataset.value, this.dispatchEvent(new Event("change", { bubbles: !0 })), o(), e.control.focus();
829
+ }, c = (t) => {
830
+ let r = this._visible();
831
+ t.key === "ArrowDown" ? (t.preventDefault(), n(Math.min(this._active + 1, r.length - 1))) : t.key === "ArrowUp" ? (t.preventDefault(), n(Math.max(this._active - 1, 0))) : t.key === "Enter" ? (t.preventDefault(), r[this._active] && s(r[this._active])) : t.key === "Escape" && (o(), e.control.focus());
832
+ };
833
+ e.control.addEventListener("click", () => i() ? o() : a()), e.control.addEventListener("keydown", (e) => {
834
+ !i() && (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), a());
835
+ }), e.optionsWrap.addEventListener("click", (e) => {
836
+ let t = e.target.closest(".search-select-option");
837
+ t && s(t);
838
+ }), e.optionsWrap.addEventListener("mousemove", (e) => {
839
+ let t = e.target.closest(".search-select-option");
840
+ t && n(this._visible().indexOf(t));
841
+ }), e.search?.addEventListener("input", () => {
842
+ r(e.search.value), n(-1);
843
+ }), e.search?.addEventListener("keydown", c), e.clear?.addEventListener("click", () => {
844
+ e.search.value = "", r(""), e.search.focus();
845
+ }), e.menu.addEventListener("keydown", c), this._onDocClick = (e) => {
846
+ i() && !this.contains(e.target) && o();
847
+ }, document.addEventListener("click", this._onDocClick), window.addEventListener("resize", () => {
848
+ i() && t();
849
+ });
850
+ }
851
+ disconnectedCallback() {
852
+ this._onDocClick && document.removeEventListener("click", this._onDocClick);
853
+ }
854
+ }, b = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), x = (e, t) => {
855
+ typeof customElements < "u" && !customElements.get(e) && customElements.define(e, t);
856
+ };
857
+ function S() {
858
+ x("wui-select", y), x("wui-phone", _), x("wui-datepicker", l), x("wui-autocomplete", e), x("wui-multiselect", u);
859
+ }
860
+ S();
861
+ //#endregion
862
+ export { e as WuiAutocomplete, l as WuiDatePicker, u as WuiMultiSelect, _ as WuiPhone, y as WuiSelect, S as defineWeborityElements };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@webority/ui-elements",
3
+ "version": "0.0.9",
4
+ "description": "Webority framework-agnostic UI custom elements (<wui-*>) — the single implementation of the interactive components, styled by @webority/theme. Used natively in Razor and wrapped by @webority/ui-react.",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "type": "module",
7
+ "publishConfig": {
8
+ "access": "public",
9
+ "registry": "https://registry.npmjs.org/"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/Webority/webority-ui.git",
14
+ "directory": "packages/elements"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "main": "./dist/ui-elements.js",
20
+ "module": "./dist/ui-elements.js",
21
+ "exports": {
22
+ ".": "./dist/ui-elements.js",
23
+ "./global": "./dist/ui-elements.global.js",
24
+ "./package.json": "./package.json"
25
+ },
26
+ "sideEffects": [
27
+ "./dist/*"
28
+ ],
29
+ "devDependencies": {
30
+ "vite": "^8.0.12"
31
+ },
32
+ "scripts": {
33
+ "build": "vite build"
34
+ }
35
+ }