@webority/ui-elements 0.58.1 → 0.59.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/{WuiAutocomplete-CE7wT-Vc.js → WuiAutocomplete-B2SKLPOV.js} +1 -1
  2. package/dist/{WuiCountrySelect-D92rrSvW.js → WuiCountrySelect-D-K0dm77.js} +1 -1
  3. package/dist/WuiDatePicker-B4E_NvAh.js +31 -0
  4. package/dist/{WuiDateRange-CrVodISl.js → WuiDateRange-BuVA1MK5.js} +1 -1
  5. package/dist/WuiDrawer-D6K2eRlW.js +1 -0
  6. package/dist/WuiHoverCard-BsYAwmbA.js +1 -0
  7. package/dist/{WuiMultiSelect-WUNCdkzW.js → WuiMultiSelect-BGZOG93I.js} +1 -1
  8. package/dist/{WuiNotificationCenter-DKdvaSbm.js → WuiNotificationCenter-BZwVMUSV.js} +1 -1
  9. package/dist/{WuiPhone-DtuXp6o2.js → WuiPhone-Dbb_9J8q.js} +1 -1
  10. package/dist/{WuiSelect-CT8tgsxL.js → WuiSelect-U5Owq3wT.js} +1 -1
  11. package/dist/{WuiTimePicker-Bolpp93P.js → WuiTimePicker-UjvUcDrS.js} +1 -1
  12. package/dist/WuiTour-DW3kPaR9.js +1 -488
  13. package/dist/elements/autocomplete.js +1 -1
  14. package/dist/elements/country-select.js +1 -1
  15. package/dist/elements/date-range.js +1 -1
  16. package/dist/elements/datepicker.js +1 -1
  17. package/dist/elements/drawer.js +1 -1
  18. package/dist/elements/hover-card.js +1 -1
  19. package/dist/elements/kanban.js +1 -1
  20. package/dist/elements/multiselect.js +1 -1
  21. package/dist/elements/notification-center.js +1 -1
  22. package/dist/elements/phone.js +1 -1
  23. package/dist/elements/select.js +1 -1
  24. package/dist/elements/timepicker.js +1 -1
  25. package/dist/{fileViewerImage-Bis2gnyc.js → fileViewerImage-DEhhKbIU.js} +1 -1
  26. package/dist/{fileViewerMedia-CaJaVnjE.js → fileViewerMedia-B12HzBnN.js} +1 -1
  27. package/dist/{fileViewerPdf-DGU_-iub.js → fileViewerPdf-L8OJZRPO.js} +2 -2
  28. package/dist/{fileViewerUi-DasgDsU-.js → fileViewerUi-KPTQsM_Y.js} +1 -1
  29. package/dist/kanban-29Pv2HU9.js +1 -0
  30. package/dist/ui-chat.global.js +1 -1
  31. package/dist/ui-chat.js +1 -1
  32. package/dist/ui-elements.global.js +112 -112
  33. package/dist/ui-elements.js +1 -1
  34. package/dist/ui-file-viewer.global.js +2 -2
  35. package/dist/ui-file-viewer.js +1 -1
  36. package/dist/ui-rich-text.global.js +1 -1
  37. package/dist/ui-rich-text.js +1 -1
  38. package/package.json +1 -1
  39. package/dist/WuiDatePicker-_BzQ2m1e.js +0 -31
  40. package/dist/WuiDrawer-BuvDLR6M.js +0 -1
  41. package/dist/WuiHoverCard-CNEawHmO.js +0 -1
  42. package/dist/kanban-CdELdS3U.js +0 -1
@@ -10,4 +10,4 @@ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from".
10
10
  <div class="search-select-empty" hidden>No matches</div>
11
11
  <div class="search-select-hint" hidden>Type to search…</div>
12
12
  </div>
13
- </div>`,this._rendered=!0,o(this,this._value),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?.value)}_renderLoading(){let{spinner:e}=this._refs();e&&(e.hidden=!this._loading)}_renderOptions(e){let t=this._refs();if(!t.optionsWrap)return;let n=e??(t.input?t.input.value:``),r=n.trim().toLowerCase(),i=this._readOptions();!this._remote&&r&&(i=i.filter(e=>d(e).toLowerCase().includes(r)));let a=n.trim(),o=this._allowCustom&&a&&!this._matchesKnownOption(a)?[...i,{value:a,custom:!0}]:i,s=this._listboxId||`${this.id||`wui-autocomplete`}-listbox`;t.optionsWrap.innerHTML=o.map((e,t)=>{let n=`${s}-opt-${t}`;if(e.custom){let t=`Add “${f(e.value)}”`;return`<button type="button" role="option" id="${g(n)}" class="search-select-option search-select-option-custom" data-value="${g(e.value)}" data-custom="true" aria-selected="false">${t}</button>`}let r=String(e.value)===String(this._value);return`<button type="button" role="option" id="${g(n)}" class="search-select-option${r?` selected`:``}" data-value="${g(e.value)}" aria-selected="${r}">${p(e)}</button>`}).join(``),this._active=-1,t.control?.removeAttribute(`aria-activedescendant`);let c=r.length<this._minChars;t.hint&&(t.hint.hidden=!(this._remote&&c&&!i.length)),t.empty&&(t.empty.hidden=this._loading||o.length>0||this._remote&&c),this._reanchor?.()}_wire(){this._teardown();let e=this._refs();if(!e.control||!e.input)return;let s=()=>r(e.control,e.menu,{matchWidth:!0}),f=()=>this._optionEls().filter(e=>!e.hidden),p=(t,{reveal:n=!0}={})=>{let r=f();this._active=t,c(e.optionsWrap,t>=0&&r[t]||null),t>=0&&r[t]?(n&&r[t].scrollIntoView({block:`nearest`}),e.control.setAttribute(`aria-activedescendant`,r[t].id)):e.control.removeAttribute(`aria-activedescendant`)},m=()=>!e.menu.hidden,h=()=>{m()&&s()},g=()=>{!this._remote||this._minChars!==0||e.input.value.trim()||(clearTimeout(this._timer),this._fireSearch(``,++this._reqSeq))},_=({load:n=!0}={})=>{e.menu.hidden=!1,e.control.setAttribute(`aria-expanded`,`true`),e.control.classList.add(`open`),s(),t(this,h),n&&g(),this._renderOptions()},v=()=>{e.menu.hidden=!0,e.control.setAttribute(`aria-expanded`,`false`),e.control.classList.remove(`open`),p(-1),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,this._syncInput(),n(this)},y=t=>{let n=t.dataset.custom===`true`;this._value=t.dataset.value;let r=n?null:this._readOptions().find(e=>String(e.value)===t.dataset.value);this._label=n?t.dataset.value:r?d(r):u(t.innerHTML),o(this,this._value),e.input.value=this._label,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:n}})),v(),e.input.focus()},b=t=>{this._value=t,this._label=t,o(this,t),e.input.value=t,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!0}})),v()},x=()=>{let t=e.input.value;if(e.clear&&(e.clear.hidden=!t),m()||_({load:!1}),this._remote){if(this._renderOptions(t),clearTimeout(this._timer),t.trim().length<this._minChars){this._pendingSearch=null;return}let e=++this._reqSeq;this._pendingSearch={query:t,seq:e},this._timer=setTimeout(()=>this._fireSearch(t,e),this._debounceMs)}else this._renderOptions(t)};this._navHandler=l({getVisibleOptions:f,getActive:()=>this._active,setActive:e=>p(e),onEnter:(t,n)=>{if(n[this._active])y(n[this._active]);else if(this._allowCustom){let t=e.input.value.trim();t&&!this._matchesKnownOption(t)&&b(t)}},onEscape:()=>{this._navHandler.clearTypeahead(),v()}});let S=e=>{let t=e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`;if(e.key===`ArrowDown`){e.preventDefault(),m()||_();let t=f();p(Math.min(this._active+1,t.length-1));return}else if(e.key===`ArrowUp`){e.preventDefault(),p(Math.max(this._active-1,0));return}else if((e.key===`Home`||e.key===`End`||e.key===`PageDown`||e.key===`PageUp`)&&(!m()||t))return;else if(e.key.length===1&&(e.ctrlKey||e.metaKey||e.altKey||!m()||e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`)&&(!m()||e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`))return;this._navHandler.handler(e)};i(),e.input.addEventListener(`focus`,()=>{a()&&!m()&&_()}),e.control.addEventListener(`click`,t=>{e.input.disabled||t.target.closest(`.search-select-clear`)||(t.target!==e.input&&e.input.focus(),m()||_())}),e.input.addEventListener(`input`,x),e.input.addEventListener(`keydown`,S),e.menu.addEventListener(`keydown`,S),e.input.addEventListener(`blur`,t=>{if(!this._allowCustom||t.relatedTarget&&this.contains(t.relatedTarget))return;let n=e.input.value.trim();!n||n===this._label||this._matchesKnownOption(n)||b(n)}),e.optionsWrap.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&y(t)}),e.optionsWrap.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&!t.classList.contains(`is-active`)&&p(this._optionEls().indexOf(t),{reveal:!1})}),e.optionsWrap.addEventListener(`mouseleave`,()=>p(-1)),e.clear?.addEventListener(`click`,()=>{this._value=``,this._label=``,o(this,``),e.input.value=``,e.clear.hidden=!0,this._renderOptions(``),this.dispatchEvent(new Event(`change`,{bubbles:!0})),e.input.focus(),m()?g():_()}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{m()&&!this.contains(e.target)&&v()},document.addEventListener(`click`,this._onDocClick),m()&&t(this,h)},this._bindGlobal()}_fireSearch(e,t){this._pendingSearch=null,this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this),clearTimeout(this._timer),this._navHandler?.teardown()}disconnectedCallback(){this._teardown()}},g=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{h as t};
13
+ </div>`,this._rendered=!0,o(this,this._value),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?.value)}_renderLoading(){let{spinner:e}=this._refs();e&&(e.hidden=!this._loading)}_renderOptions(e){let t=this._refs();if(!t.optionsWrap)return;let n=e??(t.input?t.input.value:``),r=n.trim().toLowerCase(),i=this._readOptions();!this._remote&&r&&(i=i.filter(e=>d(e).toLowerCase().includes(r)));let a=n.trim(),o=this._allowCustom&&a&&!this._matchesKnownOption(a)?[...i,{value:a,custom:!0}]:i,s=this._listboxId||`${this.id||`wui-autocomplete`}-listbox`;t.optionsWrap.innerHTML=o.map((e,t)=>{let n=`${s}-opt-${t}`;if(e.custom){let t=`Add “${f(e.value)}”`;return`<button type="button" role="option" id="${g(n)}" class="search-select-option search-select-option-custom" data-value="${g(e.value)}" data-custom="true" aria-selected="false">${t}</button>`}let r=String(e.value)===String(this._value);return`<button type="button" role="option" id="${g(n)}" class="search-select-option${r?` selected`:``}" data-value="${g(e.value)}" aria-selected="${r}">${p(e)}</button>`}).join(``),this._active=-1,t.control?.removeAttribute(`aria-activedescendant`);let c=r.length<this._minChars;t.hint&&(t.hint.hidden=!(this._remote&&c&&!i.length)),t.empty&&(t.empty.hidden=this._loading||o.length>0||this._remote&&c),this._reanchor?.()}_wire(){this._teardown();let e=this._refs();if(!e.control||!e.input)return;let s=()=>r(e.control,e.menu,{matchWidth:!0}),f=()=>this._optionEls().filter(e=>!e.hidden),p=(t,{reveal:n=!0}={})=>{let r=f();this._active=t,c(e.optionsWrap,t>=0&&r[t]||null),t>=0&&r[t]?(n&&r[t].scrollIntoView({block:`nearest`}),e.control.setAttribute(`aria-activedescendant`,r[t].id)):e.control.removeAttribute(`aria-activedescendant`)},m=()=>!e.menu.hidden,h=()=>{m()&&s()},g=()=>{!this._remote||this._minChars!==0||e.input.value.trim()||(clearTimeout(this._timer),this._fireSearch(``,++this._reqSeq))},_=({load:n=!0}={})=>{e.menu.hidden=!1,e.control.setAttribute(`aria-expanded`,`true`),e.control.classList.add(`open`),s(),t(this,h),n&&g(),this._renderOptions()},v=()=>{e.menu.hidden=!0,e.control.setAttribute(`aria-expanded`,`false`),e.control.classList.remove(`open`),p(-1),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,this._syncInput(),n(this)},y=t=>{let n=t.dataset.custom===`true`;this._value=t.dataset.value;let r=n?null:this._readOptions().find(e=>String(e.value)===t.dataset.value);this._label=n?t.dataset.value:r?d(r):u(t.innerHTML),o(this,this._value),e.input.value=this._label,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:n}})),v(),e.input.focus()},b=t=>{this._value=t,this._label=t,o(this,t),e.input.value=t,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!0}})),v()},x=()=>{let t=e.input.value;if(e.clear&&(e.clear.hidden=!t),m()||_({load:!1}),this._remote){if(this._renderOptions(t),clearTimeout(this._timer),t.trim().length<this._minChars){this._pendingSearch=null;return}let e=++this._reqSeq;this._pendingSearch={query:t,seq:e},this._timer=setTimeout(()=>this._fireSearch(t,e),this._debounceMs)}else this._renderOptions(t)};this._navHandler=l({getVisibleOptions:f,getActive:()=>this._active,setActive:e=>p(e),onEnter:(t,n)=>{if(n[this._active])y(n[this._active]);else if(this._allowCustom){let t=e.input.value.trim();t&&!this._matchesKnownOption(t)&&b(t)}},onEscape:()=>{this._navHandler.clearTypeahead(),v()}});let S=e=>{let t=e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`;if(e.key===`ArrowDown`){e.preventDefault(),m()||_();let t=f();p(Math.min(this._active+1,t.length-1));return}else if(e.key===`ArrowUp`){e.preventDefault(),p(Math.max(this._active-1,0));return}else if((e.key===`Home`||e.key===`End`||e.key===`PageDown`||e.key===`PageUp`)&&(!m()||t))return;else if(e.key.length===1&&(e.ctrlKey||e.metaKey||e.altKey||!m()||e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`)&&(!m()||e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`))return;e.key===`Escape`&&m()&&(e.preventDefault(),e.stopPropagation()),this._navHandler.handler(e)};i(),e.input.addEventListener(`focus`,()=>{a()&&!m()&&_()}),e.control.addEventListener(`click`,t=>{e.input.disabled||t.target.closest(`.search-select-clear`)||(t.target!==e.input&&e.input.focus(),m()||_())}),e.input.addEventListener(`input`,x),e.input.addEventListener(`keydown`,S),e.menu.addEventListener(`keydown`,S),e.input.addEventListener(`blur`,t=>{if(!this._allowCustom||t.relatedTarget&&this.contains(t.relatedTarget))return;let n=e.input.value.trim();!n||n===this._label||this._matchesKnownOption(n)||b(n)}),e.optionsWrap.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&y(t)}),e.optionsWrap.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&!t.classList.contains(`is-active`)&&p(this._optionEls().indexOf(t),{reveal:!1})}),e.optionsWrap.addEventListener(`mouseleave`,()=>p(-1)),e.clear?.addEventListener(`click`,()=>{this._value=``,this._label=``,o(this,``),e.input.value=``,e.clear.hidden=!0,this._renderOptions(``),this.dispatchEvent(new Event(`change`,{bubbles:!0})),e.input.focus(),m()?g():_()}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{m()&&!this.contains(e.target)&&v()},document.addEventListener(`click`,this._onDocClick),m()&&t(this,h)},this._bindGlobal()}_fireSearch(e,t){this._pendingSearch=null,this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this),clearTimeout(this._timer),this._navHandler?.teardown()}disconnectedCallback(){this._teardown()}},g=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{h as t};
@@ -1 +1 @@
1
- import{t as e}from"./countries-CvmZ2xpG.js";import{t}from"./WuiSelect-CT8tgsxL.js";var n=e=>{if(e==null)return null;let t=String(e).split(`,`).map(e=>e.trim().toUpperCase()).filter(Boolean);return t.length?new Set(t):null},r=t=>{let r=n(t);return e.filter(([e])=>!r||r.has(e)).map(([e,t])=>({value:e,label:t,flag:e}))},i=class extends t{static get observedAttributes(){return[...t.observedAttributes,`countries`]}_readOptions(){let e=this.getAttribute(`countries`);return this._countryCache?.attr!==e&&(this._countryCache={attr:e,options:r(e)}),this._countryCache.options}};export{i as t};
1
+ import{t as e}from"./countries-CvmZ2xpG.js";import{t}from"./WuiSelect-U5Owq3wT.js";var n=e=>{if(e==null)return null;let t=String(e).split(`,`).map(e=>e.trim().toUpperCase()).filter(Boolean);return t.length?new Set(t):null},r=t=>{let r=n(t);return e.filter(([e])=>!r||r.has(e)).map(([e,t])=>({value:e,label:t,flag:e}))},i=class extends t{static get observedAttributes(){return[...t.observedAttributes,`countries`]}_readOptions(){let e=this.getAttribute(`countries`);return this._countryCache?.attr!==e&&(this._countryCache={attr:e,options:r(e)}),this._countryCache.options}};export{i as t};
@@ -0,0 +1,31 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-WcDeH46q.js";import{t as i}from"./formMirror-BgY7zkC3.js";import{t as a}from"./iconGlyphs.g-CUm_mfze.js";import{n as o}from"./optionLabel-BBaur8Bs.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p,t as m}from"./calendarMath-BC2wGCD-.js";var h=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`disabled-weekdays`,`display-format`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._slide=``}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&(e===`value`?(this._value=n||``,this._syncFormValue(),this._syncTrigger()):e===`display-format`?this._syncTrigger():e===`first-day`?this.querySelector(`.datepicker-pop`)?.hidden||this._renderView():this.render())}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,i(this,this._value),this._syncTrigger()}_firstDay(){return s(this)}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this.getAttribute(`placeholder`)||`Enter Date`,t=p(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),r=n===`sm`?` input-sm`:n===`lg`?` input-lg`:``,s=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
2
+ <div class="datepicker">
3
+ <button type="button" class="input datepicker-trigger${r}${t?` has-value`:``}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${s?` aria-label="${o(s)}"`:``}${c?` aria-describedby="${o(c)}"`:``}>
4
+ <span data-trigger-label class="${t?``:`search-select-placeholder`}">${o(t?d(this._value,this.getAttribute(`display-format`)):e)}</span>
5
+ ${a(`calendar-dots`)}
6
+ </button>
7
+ <div class="datepicker-pop" role="dialog" aria-modal="false" hidden></div>
8
+ </div>`,this._rendered=!0,i(this,this._value),this._wire()}_syncFormValue(){i(this,this._value)}_syncTrigger(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!t)return;let n=p(this._value);t.textContent=n?d(this._value,this.getAttribute(`display-format`)):this.getAttribute(`placeholder`)||`Enter Date`,t.classList.toggle(`search-select-placeholder`,!n),e?.classList.toggle(`has-value`,!!n)}_limits(){let e=p(this.getAttribute(`min`)),t=p(this.getAttribute(`max`)),n=e?new Date(e.y,e.m,e.d).getTime():-1/0,r=t?new Date(t.y,t.m,t.d).getTime():1/0,i=new Set;for(let e of(this.getAttribute(`disabled-weekdays`)||``).split(`,`)){let t=e.trim();/^[0-6]$/.test(t)&&i.add(Number(t))}return{dayDisabled:(e,t,a)=>{let o=new Date(e,t,a),s=o.getTime();return s<n||s>r||i.has(o.getDay())},monthDisabled:(e,t)=>{let i=new Date(e,t,1).getTime();return new Date(e,t,l(e,t)).getTime()<n||i>r},yearDisabled:e=>{let t=new Date(e,0,1).getTime();return new Date(e,11,31).getTime()<n||t>r}}}_renderView(){let e=this.querySelector(`.datepicker-pop`);e&&(this._mode===`months`?e.innerHTML=this._monthsHtml():this._mode===`years`?e.innerHTML=this._yearsHtml():e.innerHTML=this._daysHtml(),this._focusActive())}_daysHtml(){let e=this._firstDay(),t=(new Date(this._viewY,this._viewM,1).getDay()-e+7)%7,n=l(this._viewY,this._viewM),r=p(this._value),i=new Date,{dayDisabled:o}=this._limits(),s=this._focus||r||{y:this._viewY,m:this._viewM,d:1},d=(e,t,n,a)=>{let l=c(e,t,n),u=r&&r.y===e&&r.m===t&&r.d===n,d=i.getFullYear()===e&&i.getMonth()===t&&i.getDate()===n,f=s.y===e&&s.m===t&&s.d===n,p=o(e,t,n);return`<button type="button" class="${[`datepicker-day`,a?`is-outside`:``,d?`is-today`:``,u?`is-selected`:``].filter(Boolean).join(` `)}" data-iso="${l}" role="gridcell" tabindex="${f&&!p?`0`:`-1`}"${u?` aria-selected="true"`:``}${p?` disabled aria-disabled="true"`:``}>${n}</button>`},h=``,g=f(this._viewY,this._viewM-1),_=l(g.y,g.m);for(let e=t-1;e>=0;e--)h+=d(g.y,g.m,_-e,!0);for(let e=1;e<=n;e++)h+=d(this._viewY,this._viewM,e,!1);let v=f(this._viewY,this._viewM+1),y=(7-(t+n)%7)%7;for(let e=1;e<=y;e++)h+=d(v.y,v.m,e,!0);let b=o(i.getFullYear(),i.getMonth(),i.getDate()),x=u.map((t,n)=>u[(n+e)%7]).map(e=>`<span>${e}</span>`).join(``);return`
9
+ <div class="datepicker-head">
10
+ <button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="Previous month">${a(`chevron-left`)}</button>
11
+ <button type="button" class="datepicker-month" data-view="months" aria-label="Choose month and year">${m[this._viewM]} ${this._viewY}</button>
12
+ <button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="Next month">${a(`chevron-right`)}</button>
13
+ </div>
14
+ <div class="datepicker-weekdays">${x}</div>
15
+ <div class="datepicker-grid${this._slide?` ${this._slide}`:``}" role="grid">${h}</div>
16
+ <div class="datepicker-foot">
17
+ <button type="button" class="datepicker-link" data-today${b?` disabled`:``}>Today</button>
18
+ <button type="button" class="datepicker-link" data-clear>Clear</button>
19
+ </div>`}_monthsHtml(){let e=p(this._value),t=new Date,{monthDisabled:n}=this._limits(),r=``;for(let i=0;i<12;i++){let a=e&&e.y===this._viewY&&e.m===i,o=t.getFullYear()===this._viewY&&t.getMonth()===i,s=n(this._viewY,i),c=[`datepicker-cell`,o?`is-today`:``,a?`is-selected`:``].filter(Boolean).join(` `);r+=`<button type="button" class="${c}" data-month="${i}"${s?` disabled`:``}>${m[i].slice(0,3)}</button>`}return`
20
+ <div class="datepicker-head">
21
+ <button type="button" class="datepicker-nav-btn" data-nav-year="-1" aria-label="Previous year">${a(`chevron-left`)}</button>
22
+ <button type="button" class="datepicker-month" data-view="years" aria-label="Choose year">${this._viewY}</button>
23
+ <button type="button" class="datepicker-nav-btn" data-nav-year="1" aria-label="Next year">${a(`chevron-right`)}</button>
24
+ </div>
25
+ <div class="datepicker-cells">${r}</div>`}_yearsHtml(){let e=p(this._value),t=new Date().getFullYear(),{yearDisabled:n}=this._limits(),r=this._viewY-(this._viewY%10+10)%10-1,i=``;for(let a=0;a<12;a++){let o=r+a,s=e&&e.y===o,c=t===o,l=n(o),u=[`datepicker-cell`,c?`is-today`:``,s?`is-selected`:``].filter(Boolean).join(` `);i+=`<button type="button" class="${u}" data-year="${o}"${l?` disabled`:``}>${o}</button>`}return`
26
+ <div class="datepicker-head">
27
+ <button type="button" class="datepicker-nav-btn" data-nav-decade="-1" aria-label="Previous decade">${a(`chevron-left`)}</button>
28
+ <span class="datepicker-month">${r+1} to ${r+10}</span>
29
+ <button type="button" class="datepicker-nav-btn" data-nav-decade="1" aria-label="Next decade">${a(`chevron-right`)}</button>
30
+ </div>
31
+ <div class="datepicker-cells">${i}</div>`}_focusActive(){let e=this.querySelector(`.datepicker-pop`),t=e?.querySelector(`[tabindex="0"]`)||e?.querySelector(`.is-selected`)||e?.querySelector(`.datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)`);t&&e.contains(document.activeElement)&&t.focus()}_position(e,t){r(e,t,{clampHeight:!0})}_setFocus(e,t,n,r){let{y:i,m:a}=f(e,t);this._focus={y:i,m:a,d:n};let o=i!==this._viewY||a!==this._viewM;this._viewY=i,this._viewM=a,this._slide=o&&r||``,this._renderView(),this._slide=``,this.querySelector(`.datepicker-day[data-iso="${c(i,a,n)}"]`)?.focus()}_seek(e,t,n,r){let{dayDisabled:i}=this._limits(),a=new Date(e,t,n);for(let e=0;e<400;e++,a.setDate(a.getDate()+r))if(!i(a.getFullYear(),a.getMonth(),a.getDate()))return new Date(a);return null}_onKey(e){if(this._mode!==`days`)return;let t=this._focus||p(this._value)||{y:this._viewY,m:this._viewM,d:1},n=(e,t,n,r,i)=>{let a=this._seek(e,t,n,r);a&&this._setFocus(a.getFullYear(),a.getMonth(),a.getDate(),i)},r=(r,i,a=r<0?-1:1)=>{e.preventDefault(),n(t.y,t.m,t.d+r,a,i)};switch(e.key){case`ArrowLeft`:return r(-1,`slide-prev`);case`ArrowRight`:return r(1,`slide-next`);case`ArrowUp`:return r(-7,`slide-prev`);case`ArrowDown`:return r(7,`slide-next`);case`Home`:return r(-((new Date(t.y,t.m,t.d).getDay()-this._firstDay()+7)%7),`slide-prev`,1);case`End`:return r(6-(new Date(t.y,t.m,t.d).getDay()-this._firstDay()+7)%7,`slide-next`,-1);case`PageUp`:{e.preventDefault();let r=f(t.y,t.m-(e.shiftKey?12:1));return n(r.y,r.m,Math.min(t.d,l(r.y,r.m)),-1,`slide-prev`)}case`PageDown`:{e.preventDefault();let r=f(t.y,t.m+(e.shiftKey?12:1));return n(r.y,r.m,Math.min(t.d,l(r.y,r.m)),1,`slide-next`)}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(t.y,t.m,t.d)||(this.value=c(t.y,t.m,t.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return;default:}}_wire(){this._teardown();let e=this.querySelector(`.datepicker-trigger`),r=this.querySelector(`.datepicker-pop`),i=this.querySelector(`.datepicker`);if(!e||!r)return;let a=()=>!r.hidden,o=()=>{a()&&this._position(e,r)};this._open=()=>{let n=new Date,a=p(this._value);(a||!this._viewNavigated)&&(this._viewY=n.getFullYear(),this._viewM=n.getMonth()),this._mode=`days`;let s=n.getFullYear()===this._viewY&&n.getMonth()===this._viewM,c=a&&a.y===this._viewY&&a.m===this._viewM;if(this._focus=c?a:{y:this._viewY,m:this._viewM,d:s?n.getDate():1},this._limits().dayDisabled(this._focus.y,this._focus.m,this._focus.d)){let e=this._focus,t=[1,-1].map(t=>this._seek(e.y,e.m,e.d,t)).find(t=>t&&t.getMonth()===e.m);t&&(this._focus={y:t.getFullYear(),m:t.getMonth(),d:t.getDate()})}this._renderView(),r.hidden=!1,i?.classList.add(`open`),this._position(e,r),t(this,o),e.setAttribute(`aria-expanded`,`true`),r.querySelector(`[tabindex="0"]`)?.focus()},this._close=()=>{r.hidden=!0,i?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),n(this),e.focus()},e.addEventListener(`click`,()=>a()?this._close():this._open()),r.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`[data-nav]`);if(t){this._viewNavigated=!0,this._slide=Number(t.dataset.nav)<0?`slide-prev`:`slide-next`;let e=f(this._viewY,this._viewM+Number(t.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._focus={y:e.y,m:e.m,d:1},this._renderView(),this._slide=``;return}let n=e.target.closest(`[data-nav-year]`);if(n){this._viewY+=Number(n.dataset.navYear),this._renderView();return}let r=e.target.closest(`[data-nav-decade]`);if(r){this._viewY+=Number(r.dataset.navDecade)*10,this._renderView();return}let i=e.target.closest(`[data-view]`);if(i){this._mode=i.dataset.view,this._renderView();return}let a=e.target.closest(`[data-month]`);if(a&&!a.disabled){this._viewNavigated=!0,this._viewM=Number(a.dataset.month),this._mode=`days`,this._focus={y:this._viewY,m:this._viewM,d:1},this._renderView();return}let o=e.target.closest(`[data-year]`);if(o&&!o.disabled){this._viewNavigated=!0,this._viewY=Number(o.dataset.year),this._mode=`months`,this._renderView();return}if(e.target.closest(`[data-today]`)){let e=new Date;if(this._limits().dayDisabled(e.getFullYear(),e.getMonth(),e.getDate()))return;this.value=c(e.getFullYear(),e.getMonth(),e.getDate()),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}if(e.target.closest(`[data-clear]`)){this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}let s=e.target.closest(`.datepicker-day[data-iso]`);s&&!s.disabled&&(this.value=s.dataset.iso,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{a()&&this._onKey(e)},r.addEventListener(`keydown`,this._onKeyBound),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,a()&&!t&&!this.contains(e.target)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{a()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),this._onHostKey=e=>{!a()||e.key!==`Escape`||(e.preventDefault(),e.stopPropagation(),this._close())},this.addEventListener(`keydown`,this._onHostKey),a()&&t(this,o)},this._bindGlobal(),this._syncFormValue()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),this._onHostKey&&=(this.removeEventListener(`keydown`,this._onHostKey),null),n(this)}disconnectedCallback(){this._teardown()}};export{h as t};
@@ -22,4 +22,4 @@ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from".
22
22
  <div class="datepicker-foot">
23
23
  <span class="daterange-hint" data-range-hint></span>
24
24
  <button type="button" class="datepicker-link" data-clear>Clear</button>
25
- </div>`;e.classList.toggle(`wui-daterange-pop--presets`,n!==``),e.innerHTML=n?`${n}<div class="wui-daterange-main">${r}</div>`:r,this._paint()}_paint(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=this._start?new Date(this._start).getTime():null,n=this._end;t&&!this._end&&this._hover&&new Date(this._hover).getTime()>=t&&(n=this._hover);let r=n?new Date(n).getTime():null;for(let n of e.querySelectorAll(`.datepicker-day[data-iso]`)){let e=new Date(n.dataset.iso).getTime(),i=t!=null&&e===t,a=r!=null&&e===r,o=t!=null&&r!=null&&e>t&&e<r;n.classList.toggle(`is-range-start`,i),n.classList.toggle(`is-range-end`,a),n.classList.toggle(`in-range`,o)}e.querySelectorAll(`[data-preset]`).forEach(e=>{let t=this._presetList?.[Number(e.dataset.preset)],n=!!t&&t.start===this._start&&t.end===this._end;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-pressed`,String(n))});let i=e.querySelector(`[data-range-hint]`);i&&(i.textContent=this._start?this._end?`${u(this._start)} to ${u(this._end)}`:`Pick an end date`:`Pick a start date`)}_position(e,t){r(e,t,{clampHeight:!0})}_pick(e){if(!this._start||this._start&&this._end){this._start=e,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint();return}if(new Date(e).getTime()<new Date(this._start).getTime()){this._start=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}this._end=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close()}_applyPreset({start:e,end:t}){this._start=e,this._end=t,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close()}_wire(){this._teardown();let e=this.querySelector(`.daterange-trigger`),r=this.querySelector(`.daterange-pop`),i=this.querySelector(`.daterange`);if(!e||!r)return;let a=()=>!r.hidden,o=()=>{a()&&this._position(e,r)};this._open=()=>{let n=f(this._start);if(n)this._viewY=n.y,this._viewM=n.m;else{let e=new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._presetList=C(this.getAttribute(`presets`)),this._renderView(),r.hidden=!1,i?.classList.add(`open`),this._position(e,r),t(this,o),e.setAttribute(`aria-expanded`,`true`)},this._close=()=>{r.hidden=!0,this._hover=``,i?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),n(this)},e.addEventListener(`click`,()=>a()?this._close():this._open()),r.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`[data-nav]`);if(t){let e=d(this._viewY,this._viewM+Number(t.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._renderView();return}if(e.target.closest(`[data-clear]`)){this._start=``,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._renderView(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let n=e.target.closest(`[data-preset]`);if(n&&!n.disabled){let e=this._presetList?.[Number(n.dataset.preset)];e&&this._applyPreset(e);return}let r=e.target.closest(`.datepicker-day[data-iso]`);r&&!r.disabled&&this._pick(r.dataset.iso)}),r.addEventListener(`mouseover`,e=>{let t=e.target.closest(`.datepicker-day[data-iso]`);t&&this._start&&!this._end&&(this._hover=t.dataset.iso,this._paint())}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,a()&&!t&&!this.contains(e.target)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{a()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),a()&&t(this,o)},this._bindGlobal(),this._syncMirrors()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),n(this)}disconnectedCallback(){this._teardown()}};export{w as t};
25
+ </div>`;e.classList.toggle(`wui-daterange-pop--presets`,n!==``),e.innerHTML=n?`${n}<div class="wui-daterange-main">${r}</div>`:r,this._paint()}_paint(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=this._start?new Date(this._start).getTime():null,n=this._end;t&&!this._end&&this._hover&&new Date(this._hover).getTime()>=t&&(n=this._hover);let r=n?new Date(n).getTime():null;for(let n of e.querySelectorAll(`.datepicker-day[data-iso]`)){let e=new Date(n.dataset.iso).getTime(),i=t!=null&&e===t,a=r!=null&&e===r,o=t!=null&&r!=null&&e>t&&e<r;n.classList.toggle(`is-range-start`,i),n.classList.toggle(`is-range-end`,a),n.classList.toggle(`in-range`,o)}e.querySelectorAll(`[data-preset]`).forEach(e=>{let t=this._presetList?.[Number(e.dataset.preset)],n=!!t&&t.start===this._start&&t.end===this._end;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-pressed`,String(n))});let i=e.querySelector(`[data-range-hint]`);i&&(i.textContent=this._start?this._end?`${u(this._start)} to ${u(this._end)}`:`Pick an end date`:`Pick a start date`)}_position(e,t){r(e,t,{clampHeight:!0})}_pick(e){if(!this._start||this._start&&this._end){this._start=e,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint();return}if(new Date(e).getTime()<new Date(this._start).getTime()){this._start=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}this._end=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close()}_applyPreset({start:e,end:t}){this._start=e,this._end=t,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close()}_wire(){this._teardown();let e=this.querySelector(`.daterange-trigger`),r=this.querySelector(`.daterange-pop`),i=this.querySelector(`.daterange`);if(!e||!r)return;let a=()=>!r.hidden,o=()=>{a()&&this._position(e,r)};this._open=()=>{let n=f(this._start);if(n)this._viewY=n.y,this._viewM=n.m;else{let e=new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._presetList=C(this.getAttribute(`presets`)),this._renderView(),r.hidden=!1,i?.classList.add(`open`),this._position(e,r),t(this,o),e.setAttribute(`aria-expanded`,`true`)},this._close=()=>{r.hidden=!0,this._hover=``,i?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),n(this)},e.addEventListener(`click`,()=>a()?this._close():this._open()),r.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`[data-nav]`);if(t){let e=d(this._viewY,this._viewM+Number(t.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._renderView();return}if(e.target.closest(`[data-clear]`)){this._start=``,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._renderView(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let n=e.target.closest(`[data-preset]`);if(n&&!n.disabled){let e=this._presetList?.[Number(n.dataset.preset)];e&&this._applyPreset(e);return}let r=e.target.closest(`.datepicker-day[data-iso]`);r&&!r.disabled&&this._pick(r.dataset.iso)}),r.addEventListener(`mouseover`,e=>{let t=e.target.closest(`.datepicker-day[data-iso]`);t&&this._start&&!this._end&&(this._hover=t.dataset.iso,this._paint())}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,a()&&!t&&!this.contains(e.target)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{a()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),this._onHostKey=e=>{!a()||e.key!==`Escape`||(e.preventDefault(),e.stopPropagation(),this._close())},this.addEventListener(`keydown`,this._onHostKey),a()&&t(this,o)},this._bindGlobal(),this._syncMirrors()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),this._onHostKey&&=(this.removeEventListener(`keydown`,this._onHostKey),null),n(this)}disconnectedCallback(){this._teardown()}};export{w as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";var t=[50,90],n=10,r=100;function i(e,i=t){let a=Array.isArray(e)?e:String(e??``).split(`,`),o=[];for(let e of a){if(typeof e==`string`&&e.trim()===``)return i;let t=Number(e);if(!Number.isFinite(t)||t<n||t>r)return i;o.includes(t)||o.push(t)}return o.length?o.sort((e,t)=>e-t):i}function a({points:e,index:t,visible:n,velocity:r,canDismiss:i}){let a=i?-1:0;if(Math.abs(r)>=.5)return r>0?Math.max(t-1,a):Math.min(t+1,e.length-1);if(i&&n<e[0]/2)return-1;let o=0;for(let t=1;t<e.length;t++)Math.abs(e[t]-n)<Math.abs(e[o]-n)&&(o=t);return o}var o=`(max-width: 767.98px)`,s=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,c=4,l=0,u=new WeakSet;function d(e){u.has(e)||(u.add(e),e.addEventListener(`click`,t=>{let n=t.target?.closest?.(`[data-wui-drawer-open]`);if(!n)return;let r=n.getAttribute(`data-wui-drawer-open`).replace(/^#/,``),i=e.getElementById(r);typeof i?.show==`function`&&(t.preventDefault(),i.show(n))}))}var f=class extends e{static get observedAttributes(){return[`open`,`snap-points`]}constructor(){super(),this._doc=null,this._media=null,this._shown=!1,this._locked=!1,this._opener=null,this._snap=0,this._drag=null,this._onMedia=()=>this._syncMode(),this._onClick=e=>this._click(e),this._onPointerDown=e=>this._pointerDown(e),this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onKeyDown=e=>this._keyDown(e),this._onHostKey=e=>{e.key===`Escape`&&this._keyDown(e)}}connectedCallback(){this._doc=this.ownerDocument,d(this._doc),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown),this._media=typeof matchMedia==`function`?matchMedia(o):null,this._media?.addEventListener?.(`change`,this._onMedia),this._syncMode(),this._applyPoints(),this.hasAttribute(`open`)?this._open():this.setAttribute(`inert`,``)}disconnectedCallback(){this._endDrag(),this._shown&&this._release(),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown),this._media?.removeEventListener?.(`change`,this._onMedia),this._media=null,this._doc=null}attributeChangedCallback(e){this._doc&&(e===`open`?this.hasAttribute(`open`)?this._open():this._close():(this._snap=Math.min(this._snap,this._points().length-1),this._applyPoints()))}get isOpen(){return this.hasAttribute(`open`)}show(e){e&&(this._opener=e),this.setAttribute(`open`,``)}hide(){this.removeAttribute(`open`)}_points(){return i(this.getAttribute(`snap-points`),t)}_sheet(){return!!this._media?.matches}_syncMode(){this.setAttribute(`data-mode`,this._sheet()?`sheet`:`side`)}_applyPoints(){let e=this._points();this._snap=Math.min(Math.max(this._snap,0),e.length-1),this.style.setProperty(`--wui-drawer-max`,String(e[e.length-1])),this.style.setProperty(`--wui-drawer-snap`,String(e[this._snap])),this.setAttribute(`data-snap`,String(this._snap));let t=this.querySelector(`.wui-drawer-handle`);if(!t)return;let n=e[this._snap];t.setAttribute(`aria-valuemin`,String(e[0])),t.setAttribute(`aria-valuemax`,String(e[e.length-1])),t.setAttribute(`aria-valuenow`,String(n)),t.setAttribute(`aria-valuetext`,`${n}% of the screen`)}_setSnap(e){let t=this._points(),n=Math.min(Math.max(e,0),t.length-1),r=n!==this._snap;this._snap=n,this._applyPoints(),r&&this.dispatchEvent(new CustomEvent(`wui-drawer-snap`,{bubbles:!0,detail:{index:n,percent:t[n]}}))}_open(){if(this._shown)return;this._shown=!0;let e=this._doc;this._opener??=e.activeElement;let t=Number.parseInt(this.getAttribute(`default-snap`)??`0`,10);this._snap=Number.isFinite(t)?t:0,this._syncMode(),this._applyPoints(),this.removeAttribute(`inert`),this._locked||(this._locked=!0,l++,e.body.classList.add(`wui-drawer-locked`)),e.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`keydown`,this._onHostKey),this._focusIn()}_close(){if(!this._shown)return;this._endDrag(),this.setAttribute(`inert`,``);let e=this._doc,t=this._opener,n=e.activeElement;this._release(),this._opener=null,t?.isConnected&&(n===e.body||this.contains(n))&&t.focus?.()}_release(){this._shown=!1,this._doc?.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`keydown`,this._onHostKey),this._locked&&(this._locked=!1,l--,l<=0&&(l=0,this._doc?.body.classList.remove(`wui-drawer-locked`)))}_panel(){return this.querySelector(`.wui-drawer-panel`)}_focusables(){let e=this._panel();return e?Array.from(e.querySelectorAll(s)).filter(e=>!e.closest(`[hidden],[inert]`)):[]}_focusIn(){let e=this._panel();if(!e)return;let t=e.querySelector(`[data-autofocus]`),n=this._sheet()?null:this._focusables().find(e=>e.closest(`.wui-drawer-body`));(t||n||e).focus?.()}_requestClose(){let e=this.dispatchEvent(new CustomEvent(`wui-drawer-close`,{bubbles:!0,cancelable:!0}));return e&&this.hide(),e}_click(e){if(!this.isOpen)return;let t=e.target;(t.closest?.(`[data-wui-drawer-close]`)||t.closest?.(`[data-wui-drawer-backdrop]`)&&!this.hasAttribute(`static`))&&this._requestClose()}_keyDown(e){if(e.key===`Escape`){if(e.defaultPrevented||this.hasAttribute(`static`))return;e.preventDefault(),e.stopPropagation(),this._requestClose();return}if(e.key===`Tab`){this._trapTab(e);return}e.target?.closest?.(`.wui-drawer-handle`)&&this._sheet()&&this._handleKey(e)}_trapTab(e){let t=this._focusables(),n=this._panel();if(!t.length){e.preventDefault(),n?.focus?.();return}let r=t[0],i=t[t.length-1],a=this._doc.activeElement;!n?.contains(a)||a===n?(e.preventDefault(),(e.shiftKey?i:r).focus()):e.shiftKey&&a===r?(e.preventDefault(),i.focus()):!e.shiftKey&&a===i&&(e.preventDefault(),r.focus())}_handleKey(e){let t=this._points().length-1,n={ArrowUp:this._snap+1,ArrowDown:this._snap-1,Home:0,End:t};e.key in n&&(e.preventDefault(),this._setSnap(n[e.key]))}_pointerDown(e){if(!this.isOpen||!this._sheet()||(e.button??0)!==0)return;let t=e.target?.closest?.(`[data-wui-drawer-grip]`);!t||e.target.closest(`button`)||(this._drag={grip:t,id:e.pointerId,startY:e.clientY,lastY:e.clientY,lastT:e.timeStamp,velocity:0,moved:!1},t.setPointerCapture?.(e.pointerId),t.addEventListener(`pointermove`,this._onPointerMove),t.addEventListener(`pointerup`,this._onPointerUp),t.addEventListener(`pointercancel`,this._onPointerUp))}_viewport(){return this._doc.defaultView.innerHeight}_pointerMove(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let n=e.clientY-t.startY;if(!t.moved&&Math.abs(n)<c)return;t.moved=!0,this.classList.add(`is-dragging`);let r=e.timeStamp-t.lastT;r>0&&(t.velocity=(e.clientY-t.lastY)/r),t.lastY=e.clientY,t.lastT=e.timeStamp;let i=this._points(),a=(i[i.length-1]-i[this._snap])/100*this._viewport();t.offset=Math.max(n,-a),this.style.setProperty(`--wui-drawer-drag`,`${t.offset}px`)}_pointerUp(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let{moved:n,velocity:r,offset:i=0}=t;if(this._endDrag(),!n)return;let o=this._points(),s=this._viewport(),c=(o[this._snap]/100*s-i)/(s/100),l=!this.hasAttribute(`static`),u=a({points:o,index:this._snap,visible:c,velocity:r,canDismiss:l});u>=0?this._setSnap(u):this._requestClose()}_endDrag(){let e=this._drag;e&&(this._drag=null,e.grip.releasePointerCapture?.(e.id),e.grip.removeEventListener(`pointermove`,this._onPointerMove),e.grip.removeEventListener(`pointerup`,this._onPointerUp),e.grip.removeEventListener(`pointercancel`,this._onPointerUp),this.classList.remove(`is-dragging`),this.style.removeProperty(`--wui-drawer-drag`))}};export{f as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-WcDeH46q.js";var i=300,a=150,o=`.wui-hover-card-trigger`,s=`.wui-hover-card-panel`,c=`a[href],button,input,select,textarea,[tabindex]`,l=0,u=class extends e{constructor(){super(),this._doc=null,this._timer=null,this._described=null,this._refocusing=!1,this._onOver=e=>{if(e.pointerType===`touch`||e.pointerType===`pen`)return;let t=this._zone(e.target);t===`panel`?this._clear():t===`trigger`&&this._schedule(!0)},this._onOut=e=>{e.pointerType===`touch`||e.pointerType===`pen`||this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onFocusIn=e=>{this._refocusing||(this._zone(e.target)===`trigger`?this._schedule(!0):this._zone(e.target)===`panel`&&this._clear())},this._onFocusOut=e=>{this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onKeyDown=e=>{if(e.key!==`Escape`||!this.isOpen)return;e.stopPropagation();let t=this._panel?.contains(this.ownerDocument.activeElement);this._clear(),this._setOpen(!1),t&&(this._refocusing=!0,this._anchor?.focus(),this._refocusing=!1)}}get isOpen(){return this._panel?.hasAttribute(`data-open`)??!1}connectedCallback(){this._doc=this.ownerDocument,this.addEventListener(`pointerover`,this._onOver),this.addEventListener(`pointerout`,this._onOut),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut)}disconnectedCallback(){this._clear(),this.removeEventListener(`pointerover`,this._onOver),this.removeEventListener(`pointerout`,this._onOut),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`keydown`,this._onKeyDown),n(this),this._doc=null}get _trigger(){return this.querySelector(o)}get _panel(){return this.querySelector(s)}get _anchor(){let e=this._trigger;return e?.querySelector(c)??e}_zone(e){if(!(e instanceof Node)||!this.contains(e))return null;let t=e instanceof Element?e:e.parentElement;return this._panel?.contains(t)?`panel`:this._trigger?.contains(t)?`trigger`:null}_delay(e,t){let n=Number(this.getAttribute(e));return this.hasAttribute(e)&&Number.isFinite(n)&&n>=0?n:t}_clear(){this._timer!==null&&clearTimeout(this._timer),this._timer=null}_schedule(e){if(this._clear(),this.isOpen===e)return;let t=e?this._delay(`open-delay`,i):this._delay(`close-delay`,a);this._timer=setTimeout(()=>{this._timer=null,this._setOpen(e)},t)}_setOpen(e){let r=this._panel;!r||this.isOpen===e||(e?(r.setAttribute(`data-open`,``),this._reposition(),t(this,()=>this._reposition()),this._doc?.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`keydown`,this._onKeyDown),this._describe(r)):(r.removeAttribute(`data-open`),n(this),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`keydown`,this._onKeyDown),this._described?.removeAttribute(`aria-describedby`),this._described=null),this.dispatchEvent(new CustomEvent(e?`wui:hover-card:open`:`wui:hover-card:close`,{bubbles:!0})))}_reposition(){this.isOpen&&r(this._trigger,this._panel,{clampHeight:!0})}_describe(e){let t=this._anchor;t&&(e.id||=`wui-hover-card-${++l}`,t.setAttribute(`aria-describedby`,e.id),this._described=t)}};export{u as t};
@@ -21,5 +21,5 @@ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from".
21
21
  <div class="search-select-options"></div>
22
22
  <div class="search-select-empty" hidden>No matches</div>
23
23
  </div>
24
- </div>`;this._rendered=!0,this._customError=``,o(this,this._values),this._renderControl(),this._renderOptions(),this._wire()}_renderControl(){let e=this.querySelector(`[data-chips]`);if(!e)return;let t=this.getAttribute(`placeholder`)||`Select…`,n=this._allowCustom?e.querySelector(`[data-input]`):null,r=this._values.map(e=>`<span class="chip chip-sm"><span class="chip-label">${this._labelHtmlFor(e)}</span><button type="button" class="chip-remove" data-remove="${E(e)}" aria-label="Remove ${E(this._labelFor(e))}">${s(`x`)}</button></span>`).join(``);if(n){for(let t of[...e.querySelectorAll(`:scope > .chip`)])t.remove();n.insertAdjacentHTML(`beforebegin`,r),n.placeholder=this._values.length?``:t,this._collapseChips();return}if(!this._values.length){e.innerHTML=`<span class="search-select-placeholder">${f(t)}</span>`;return}e.innerHTML=r,this._collapseChips()}_collapseChips(){let e=this.querySelector(`[data-chips]`);if(!e||!this.hasAttribute(`collapse-chips`)||!this._values.length)return;e.querySelector(`.chip-more`)?.remove();let t=[...e.querySelectorAll(`:scope > .chip:not(.chip-more)`)];for(let e of t)e.style.display=``;if(!t.length)return;let n=e.clientWidth,r=e=>e.offsetLeft+e.offsetWidth;if(r(t[t.length-1])<=n)return;let i=document.createElement(`span`);i.className=`chip chip-sm chip-more`,i.textContent=`+${t.length}`,t[t.length-1].after(i);let a=i.offsetWidth+6,o=0;for(let e of t)if(r(e)<=n-a)o+=1;else break;o<1&&(o=1);for(let e=o;e<t.length;e+=1)t[e].style.display=`none`;i.textContent=`+${t.length-o}`}_matches(e,t){return d(e).toLowerCase().includes(t)||String(e.description??``).toLowerCase().includes(t)}_optionNamed(e){let t=e.trim().toLowerCase();return this._readOptions().find(e=>String(e.value??``).toLowerCase()===t||d(e).trim().toLowerCase()===t)}_renderOptions(e){let t=this.querySelector(`.search-select-options`),n=this.querySelector(`.search-select-empty`);if(!t)return;let r=(e||``).trim(),i=r.toLowerCase(),a=this._readOptions();i&&(a=a.filter(e=>this._matches(e,i)));let o=this._listboxId||`${this.id||`wui-multiselect`}-listbox`,c=this._allowCustom&&r&&!this._optionNamed(r),l=a.map((e,t)=>{let n=this._values.includes(String(e.value)),r=`${o}-opt-${t}`;return b(e)?C(e,r,n):`<button type="button" role="option" id="${E(r)}" class="search-select-option${n?` selected`:``}" data-value="${E(e.value)}" aria-selected="${n}"><span class="ms-opt-label">${p(e)}</span><span class="ms-check">${s(`check`)}</span></button>`});c&&l.push(`<button type="button" role="option" id="${E(`${o}-opt-${a.length}`)}" class="search-select-option search-select-option-custom" data-value="${E(r)}" data-custom="true" aria-selected="false">Add “${f(r)}”</button>`),t.innerHTML=l.join(``),n&&(n.hidden=a.length>0),this._active=-1,this._combobox()?.removeAttribute(`aria-activedescendant`),this._allowCustom&&this._syncCustomMenu?.(),this._reanchor?.()}_combobox(){return this._allowCustom?this.querySelector(`[data-input]`):this.querySelector(`.search-select-control`)}_setCustomError(e){this._customError=e||``;let t=this.querySelector(`.wui-ms-custom-error`),n=this.querySelector(`[data-input]`);t&&(t.textContent=this._customError,t.hidden=!this._customError),n&&(this._customError?n.setAttribute(`aria-invalid`,`true`):n.removeAttribute(`aria-invalid`)),this._syncInvalid()}_customRefusal(e){let t=this.getAttribute(`custom-invalid-message`)||`Enter a valid value.`,n=this.getAttribute(`custom-pattern`);if(n){let r=T(n);if(r&&!r.test(e))return t}let r=this._validateCustom;if(r){let n=r(e);return n===!0?``:typeof n==`string`&&n?n:t}return``}_commitTyped(e){let t=e.trim().replace(/,+$/,``).trim();if(!t)return``;let n=this._optionNamed(t),r;if(n){if(n.disabled)return n.disabledHint||this.getAttribute(`custom-invalid-message`)||`That option is not available.`;r=String(n.value)}else{let e=this._customRefusal(t);if(e)return e;r=t}let i=r.toLowerCase();return this._values.some(e=>e.toLowerCase()===i)||(this._values=[...this._values,r]),``}_wire(){this._teardown();let e=this.querySelector(`.search-select-control`),s=this.querySelector(`.search-select-menu`),u=this.querySelector(`.search-select-input`),d=this.querySelector(`.search-select-clear`),f=this.querySelector(`.search-select-options`),p=this._allowCustom,m=p?this.querySelector(`[data-input]`):null,_=m||e;if(!e||!s)return;let y=()=>this.hasAttribute(`disabled`),b=()=>r(e,s,{matchWidth:!0}),x=()=>[...this.querySelectorAll(`.search-select-option`)],S=()=>x().filter(e=>!e.hidden),C=(e,{reveal:t=!0}={})=>{let n=S();this._active=e,c(f,e>=0&&n[e]||null),e>=0&&n[e]?(t&&n[e].scrollIntoView({block:`nearest`}),_.setAttribute(`aria-activedescendant`,n[e].id)):_.removeAttribute(`aria-activedescendant`)},w=!1,T=()=>p?w:!s.hidden,E=()=>{let t=w&&x().length>0,n=s.hidden;s.hidden=!t,_.setAttribute(`aria-expanded`,String(t)),e.classList.toggle(`open`,t),t&&n&&b()};this._syncCustomMenu=p?E:null;let D=()=>{T()&&b()},O=()=>{if(!y()){if(t(this,D),p){w=!0,E();return}s.hidden=!1,e.setAttribute(`aria-expanded`,`true`),e.classList.add(`open`),b(),u&&(u.value=``,this._renderOptions(``),u.focus())}},k=()=>{p?(w=!1,E()):(s.hidden=!0,e.setAttribute(`aria-expanded`,`false`),e.classList.remove(`open`)),C(-1),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,n(this)},A=()=>{o(this,this._values),this.dispatchEvent(new Event(`change`,{bubbles:!0}))},j=e=>{let t=String(e);if(this._values.includes(t))this._values=this._values.filter(e=>e!==t);else if(p&&this._values.some(e=>e.toLowerCase()===t.toLowerCase()))return;else this._values=[...this._values,t];this._renderControl(),this._renderOptions(this._query()),A()},M=e=>{this._values=this._values.filter(t=>t!==String(e)),this._renderControl(),this._renderOptions(this._query()),A()},N=(e,{quiet:t=!1}={})=>{let n=this._values.length,r=g(e,v)?h(e,v):[e],i=[],a=``;for(let e of r){let t=this._commitTyped(e);t&&(i.push(e.trim()),a||=t)}t&&i.length||(m.value=i.join(`, `),this._setCustomError(a),this._values.length!==n&&(this._renderControl(),A()),this._renderOptions(m.value))},P=e=>{if(!(!e||e.getAttribute(`aria-disabled`)===`true`)){if(e.dataset.custom===`true`){N(e.dataset.value);return}j(e.dataset.value),m?.value&&(m.value=``,this._setCustomError(``),this._renderOptions(``))}};e.addEventListener(`click`,e=>{if(y())return;let t=e.target.closest(`[data-remove]`);if(t){e.stopPropagation(),M(t.dataset.remove),m?.focus();return}if(m){let t=T();e.target!==m&&m.focus(),e.target===m||!t?O():k();return}T()?k():O()}),f.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&(P(t),(m||u)?.focus())}),f.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&!t.classList.contains(`is-active`)&&C(S().indexOf(t),{reveal:!1})}),f.addEventListener(`mouseleave`,()=>C(-1)),f.addEventListener(`error`,e=>{e.target?.classList?.contains(`avatar-img`)&&e.target.remove()},!0),u?.addEventListener(`input`,()=>{this._renderOptions(u.value),d&&(d.hidden=!u.value),C(-1)}),this._navHandler=l({getVisibleOptions:S,getActive:()=>this._active,setActive:e=>C(e),onEnter:e=>{e?P(e):m?.value.trim()&&N(m.value)},onEscape:()=>{this._navHandler.clearTypeahead(),k(),m||e.focus()}});let F=e=>{let t=m||u;if(e.key===`Backspace`&&!t?.value&&this._values.length){M(this._values[this._values.length-1]);return}this._navHandler.handler(e)};if(u?.addEventListener(`keydown`,F),d?.addEventListener(`click`,()=>{u.value=``,this._renderOptions(``),d.hidden=!0,u.focus()}),m){let t=e=>{e.target!==m&&e.preventDefault()};f.addEventListener(`mousedown`,t),e.addEventListener(`mousedown`,t),i(),m.addEventListener(`focus`,()=>{a()&&O()}),m.addEventListener(`input`,()=>{this._customError&&this._setCustomError(``),this._renderOptions(m.value),O()}),m.addEventListener(`keydown`,e=>{if(e.key===`,`&&m.value.trim()){e.preventDefault(),N(m.value);return}if(e.key===`Enter`){if(this._active<0&&!m.value.trim())return;this._navHandler.handler(e);return}(e.key===`ArrowDown`||e.key===`ArrowUp`)&&!T()&&O(),F(e)}),m.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text/plain`)??``;g(t,v)&&(e.preventDefault(),N(`${m.value}${t}`))}),m.addEventListener(`blur`,e=>{e.relatedTarget&&this.contains(e.relatedTarget)||(m.value.trim()&&N(m.value,{quiet:!0}),k())})}else e.addEventListener(`keydown`,e=>{if(T()){F(e);return}(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),O())});this._bindGlobal=()=>{this._teardown(),!this._ro&&typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._collapseChips()),this._ro.observe(this)),this._onDocClick=e=>{T()&&!this.contains(e.target)&&k()},document.addEventListener(`click`,this._onDocClick),T()&&t(this,D)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this),this._navHandler?.teardown()}disconnectedCallback(){this._teardown(),this._ro?.disconnect(),this._ro=null}},v=[`,`,`;`,`
24
+ </div>`;this._rendered=!0,this._customError=``,o(this,this._values),this._renderControl(),this._renderOptions(),this._wire()}_renderControl(){let e=this.querySelector(`[data-chips]`);if(!e)return;let t=this.getAttribute(`placeholder`)||`Select…`,n=this._allowCustom?e.querySelector(`[data-input]`):null,r=this._values.map(e=>`<span class="chip chip-sm"><span class="chip-label">${this._labelHtmlFor(e)}</span><button type="button" class="chip-remove" data-remove="${E(e)}" aria-label="Remove ${E(this._labelFor(e))}">${s(`x`)}</button></span>`).join(``);if(n){for(let t of[...e.querySelectorAll(`:scope > .chip`)])t.remove();n.insertAdjacentHTML(`beforebegin`,r),n.placeholder=this._values.length?``:t,this._collapseChips();return}if(!this._values.length){e.innerHTML=`<span class="search-select-placeholder">${f(t)}</span>`;return}e.innerHTML=r,this._collapseChips()}_collapseChips(){let e=this.querySelector(`[data-chips]`);if(!e||!this.hasAttribute(`collapse-chips`)||!this._values.length)return;e.querySelector(`.chip-more`)?.remove();let t=[...e.querySelectorAll(`:scope > .chip:not(.chip-more)`)];for(let e of t)e.style.display=``;if(!t.length)return;let n=e.clientWidth,r=e=>e.offsetLeft+e.offsetWidth;if(r(t[t.length-1])<=n)return;let i=document.createElement(`span`);i.className=`chip chip-sm chip-more`,i.textContent=`+${t.length}`,t[t.length-1].after(i);let a=i.offsetWidth+6,o=0;for(let e of t)if(r(e)<=n-a)o+=1;else break;o<1&&(o=1);for(let e=o;e<t.length;e+=1)t[e].style.display=`none`;i.textContent=`+${t.length-o}`}_matches(e,t){return d(e).toLowerCase().includes(t)||String(e.description??``).toLowerCase().includes(t)}_optionNamed(e){let t=e.trim().toLowerCase();return this._readOptions().find(e=>String(e.value??``).toLowerCase()===t||d(e).trim().toLowerCase()===t)}_renderOptions(e){let t=this.querySelector(`.search-select-options`),n=this.querySelector(`.search-select-empty`);if(!t)return;let r=(e||``).trim(),i=r.toLowerCase(),a=this._readOptions();i&&(a=a.filter(e=>this._matches(e,i)));let o=this._listboxId||`${this.id||`wui-multiselect`}-listbox`,c=this._allowCustom&&r&&!this._optionNamed(r),l=a.map((e,t)=>{let n=this._values.includes(String(e.value)),r=`${o}-opt-${t}`;return b(e)?C(e,r,n):`<button type="button" role="option" id="${E(r)}" class="search-select-option${n?` selected`:``}" data-value="${E(e.value)}" aria-selected="${n}"><span class="ms-opt-label">${p(e)}</span><span class="ms-check">${s(`check`)}</span></button>`});c&&l.push(`<button type="button" role="option" id="${E(`${o}-opt-${a.length}`)}" class="search-select-option search-select-option-custom" data-value="${E(r)}" data-custom="true" aria-selected="false">Add “${f(r)}”</button>`),t.innerHTML=l.join(``),n&&(n.hidden=a.length>0),this._active=-1,this._combobox()?.removeAttribute(`aria-activedescendant`),this._allowCustom&&this._syncCustomMenu?.(),this._reanchor?.()}_combobox(){return this._allowCustom?this.querySelector(`[data-input]`):this.querySelector(`.search-select-control`)}_setCustomError(e){this._customError=e||``;let t=this.querySelector(`.wui-ms-custom-error`),n=this.querySelector(`[data-input]`);t&&(t.textContent=this._customError,t.hidden=!this._customError),n&&(this._customError?n.setAttribute(`aria-invalid`,`true`):n.removeAttribute(`aria-invalid`)),this._syncInvalid()}_customRefusal(e){let t=this.getAttribute(`custom-invalid-message`)||`Enter a valid value.`,n=this.getAttribute(`custom-pattern`);if(n){let r=T(n);if(r&&!r.test(e))return t}let r=this._validateCustom;if(r){let n=r(e);return n===!0?``:typeof n==`string`&&n?n:t}return``}_commitTyped(e){let t=e.trim().replace(/,+$/,``).trim();if(!t)return``;let n=this._optionNamed(t),r;if(n){if(n.disabled)return n.disabledHint||this.getAttribute(`custom-invalid-message`)||`That option is not available.`;r=String(n.value)}else{let e=this._customRefusal(t);if(e)return e;r=t}let i=r.toLowerCase();return this._values.some(e=>e.toLowerCase()===i)||(this._values=[...this._values,r]),``}_wire(){this._teardown();let e=this.querySelector(`.search-select-control`),s=this.querySelector(`.search-select-menu`),u=this.querySelector(`.search-select-input`),d=this.querySelector(`.search-select-clear`),f=this.querySelector(`.search-select-options`),p=this._allowCustom,m=p?this.querySelector(`[data-input]`):null,_=m||e;if(!e||!s)return;let y=()=>this.hasAttribute(`disabled`),b=()=>r(e,s,{matchWidth:!0}),x=()=>[...this.querySelectorAll(`.search-select-option`)],S=()=>x().filter(e=>!e.hidden),C=(e,{reveal:t=!0}={})=>{let n=S();this._active=e,c(f,e>=0&&n[e]||null),e>=0&&n[e]?(t&&n[e].scrollIntoView({block:`nearest`}),_.setAttribute(`aria-activedescendant`,n[e].id)):_.removeAttribute(`aria-activedescendant`)},w=!1,T=()=>p?w:!s.hidden,E=()=>{let t=w&&x().length>0,n=s.hidden;s.hidden=!t,_.setAttribute(`aria-expanded`,String(t)),e.classList.toggle(`open`,t),t&&n&&b()};this._syncCustomMenu=p?E:null;let D=()=>{T()&&b()},O=()=>{if(!y()){if(t(this,D),p){w=!0,E();return}s.hidden=!1,e.setAttribute(`aria-expanded`,`true`),e.classList.add(`open`),b(),u&&(u.value=``,this._renderOptions(``),u.focus())}},k=()=>{p?(w=!1,E()):(s.hidden=!0,e.setAttribute(`aria-expanded`,`false`),e.classList.remove(`open`)),C(-1),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,n(this)},A=()=>{o(this,this._values),this.dispatchEvent(new Event(`change`,{bubbles:!0}))},j=e=>{let t=String(e);if(this._values.includes(t))this._values=this._values.filter(e=>e!==t);else if(p&&this._values.some(e=>e.toLowerCase()===t.toLowerCase()))return;else this._values=[...this._values,t];this._renderControl(),this._renderOptions(this._query()),A()},M=e=>{this._values=this._values.filter(t=>t!==String(e)),this._renderControl(),this._renderOptions(this._query()),A()},N=(e,{quiet:t=!1}={})=>{let n=this._values.length,r=g(e,v)?h(e,v):[e],i=[],a=``;for(let e of r){let t=this._commitTyped(e);t&&(i.push(e.trim()),a||=t)}t&&i.length||(m.value=i.join(`, `),this._setCustomError(a),this._values.length!==n&&(this._renderControl(),A()),this._renderOptions(m.value))},P=e=>{if(!(!e||e.getAttribute(`aria-disabled`)===`true`)){if(e.dataset.custom===`true`){N(e.dataset.value);return}j(e.dataset.value),m?.value&&(m.value=``,this._setCustomError(``),this._renderOptions(``))}};e.addEventListener(`click`,e=>{if(y())return;let t=e.target.closest(`[data-remove]`);if(t){e.stopPropagation(),M(t.dataset.remove),m?.focus();return}if(m){let t=T();e.target!==m&&m.focus(),e.target===m||!t?O():k();return}T()?k():O()}),f.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&(P(t),(m||u)?.focus())}),f.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&!t.classList.contains(`is-active`)&&C(S().indexOf(t),{reveal:!1})}),f.addEventListener(`mouseleave`,()=>C(-1)),f.addEventListener(`error`,e=>{e.target?.classList?.contains(`avatar-img`)&&e.target.remove()},!0),u?.addEventListener(`input`,()=>{this._renderOptions(u.value),d&&(d.hidden=!u.value),C(-1)}),this._navHandler=l({getVisibleOptions:S,getActive:()=>this._active,setActive:e=>C(e),onEnter:e=>{e?P(e):m?.value.trim()&&N(m.value)},onEscape:()=>{this._navHandler.clearTypeahead(),k(),m||e.focus()}});let F=e=>{let t=m||u;if(e.key===`Backspace`&&!t?.value&&this._values.length){M(this._values[this._values.length-1]);return}e.key===`Escape`&&T()&&(e.preventDefault(),e.stopPropagation()),this._navHandler.handler(e)};if(u?.addEventListener(`keydown`,F),d?.addEventListener(`click`,()=>{u.value=``,this._renderOptions(``),d.hidden=!0,u.focus()}),m){let t=e=>{e.target!==m&&e.preventDefault()};f.addEventListener(`mousedown`,t),e.addEventListener(`mousedown`,t),i(),m.addEventListener(`focus`,()=>{a()&&O()}),m.addEventListener(`input`,()=>{this._customError&&this._setCustomError(``),this._renderOptions(m.value),O()}),m.addEventListener(`keydown`,e=>{if(e.key===`,`&&m.value.trim()){e.preventDefault(),N(m.value);return}if(e.key===`Enter`){if(this._active<0&&!m.value.trim())return;this._navHandler.handler(e);return}(e.key===`ArrowDown`||e.key===`ArrowUp`)&&!T()&&O(),F(e)}),m.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text/plain`)??``;g(t,v)&&(e.preventDefault(),N(`${m.value}${t}`))}),m.addEventListener(`blur`,e=>{e.relatedTarget&&this.contains(e.relatedTarget)||(m.value.trim()&&N(m.value,{quiet:!0}),k())})}else e.addEventListener(`keydown`,e=>{if(T()){F(e);return}(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),O())});this._bindGlobal=()=>{this._teardown(),!this._ro&&typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._collapseChips()),this._ro.observe(this)),this._onDocClick=e=>{T()&&!this.contains(e.target)&&k()},document.addEventListener(`click`,this._onDocClick),T()&&t(this,D)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this),this._navHandler?.teardown()}disconnectedCallback(){this._teardown(),this._ro?.disconnect(),this._ro=null}},v=[`,`,`;`,`
25
25
  `,` `],y=[[`description`,`description`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],b=e=>!!(e.description||e.avatar||e.initials||e.disabled||e.disabledHint),x=e=>{let t=String(e??``).trim();return/^(https?:)?\/\//i.test(t)||/^\/(?!\/)/.test(t)||/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(t)?t:``},S=e=>{let t=x(e.avatar);return!t&&!e.initials?``:`<span class="avatar wui-opt-avatar" aria-hidden="true"><span class="avatar-face">${f(e.initials??``)}</span>${t?`<img class="avatar-img" src="${E(t)}" alt="" />`:``}</span>`},C=(e,t,n)=>{let r=!!e.disabled,i=e.description?`<span class="wui-opt-desc">${f(e.description)}</span>`:``,a=e.disabledHint&&r?`<span class="wui-opt-hint">${f(e.disabledHint)}</span>`:``;return`<button type="button" role="option" id="${E(t)}" class="search-select-option wui-opt-rich${n?` selected`:``}" data-value="${E(e.value)}" aria-selected="${n}"${r?` aria-disabled="true"`:``}><span class="ms-opt-label"><span class="wui-opt-name">${p(e)}</span>${i}</span>${a}${S(e)}<span class="ms-check">${s(`check`)}</span></button>`},w=new Map,T=e=>{if(w.has(e))return w.get(e);let t=null;try{t=RegExp(`^(?:${e})$`,`u`)}catch{console.warn(`<wui-multiselect> custom-pattern is not a valid regular expression and is ignored: ${e}`)}return w.set(e,t),t},E=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{_ as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{c as t}from"./wuiHttp-BC8co934.js";import{c as n,i as r,n as i,s as a}from"./notificationDays-pYmoU0g6.js";var o=`.wui-notification-center-trigger`,s=`.wui-notification-center-panel`,c=`.wui-notification-center-count`,l=`.wui-notification-center-live`,u=`.wui-notification-center-markall`,d=`.wui-notification-center-item`,f=`wui-notification-center-item-read`,p=`.wui-notification-center-unread-label`,m=class extends e{constructor(){super(),this._doc=null,this._unread=0,this._busy=!1,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onOutside=e=>{this.contains(e.target)||this.close()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}connectedCallback(){this._doc=this.ownerDocument,this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`mousedown`,this._onOutside),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`mousedown`,this._onOutside),this.removeEventListener(`focusout`,this._onFocusOut),this._doc=null}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(this.setAttribute(`open`,``),this._syncOpen(),this.querySelector(s)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&this.querySelector(o)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(o)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${d}:not(.${f})`).length}_click(e){let t=e.target.closest?.(`${o}, ${u}, ${d}`);if(!(!t||!this.contains(t))){if(t.matches(o)){this.toggle();return}this.hasAttribute(`controlled`)||(t.matches(u)?this._markAll():this._markItem(t))}}_key(e){if(e.key===`Escape`&&this.isOpen){e.preventDefault(),this.close({restoreFocus:!0});return}if(!this.isOpen||!this.querySelector(s)?.contains(e.target))return;let t={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`}[e.key];if(t===void 0)return;let n=[...this.querySelectorAll(d)];if(n.length===0)return;let r=n.indexOf(e.target.closest(d)),i;i=t===`first`?0:t===`last`?n.length-1:r===-1?t===1?0:n.length-1:Math.min(n.length-1,Math.max(0,r+t)),e.preventDefault(),n[i].focus()}_markItem(e){e.classList.contains(f)||(this._applyRead(e),this._unread=Math.max(0,this._unread-1),this._render(),this._say(n(this._unread)),this._emitRead([e.dataset.id].filter(Boolean),!1))}async _markAll(){if(this._busy)return;let e=[...this.querySelectorAll(`${d}:not(.${f})`)];if(e.length===0&&this._unread===0)return;let n=e.map(e=>e.dataset.id).filter(Boolean),r=this.getAttribute(`read-action`);if(r){this._setBusy(!0);let e=new URLSearchParams;for(let t of n)e.append(`ids`,t);let a=await t(r,{method:`POST`,body:e});if(this._setBusy(!1),!a.ok){if(a.kind===`session`||a.kind===`aborted`)return;let e=a.message||i.failed[a.kind]||i.failed.server;this._say(e),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:a.kind,message:e}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(i.allRead),this._emitRead(n,!0)}_applyRead(e){e.classList.add(f),e.querySelector(p)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(u);t&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=this.querySelector(c);e&&(e.textContent=r(this._unread),e.hidden=this._unread===0),this.querySelector(o)?.setAttribute(`aria-label`,a(this.getAttribute(`label`)||i.label,this._unread));let t=this.querySelector(u);t&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(l);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{m as t};
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{c as t}from"./wuiHttp-BC8co934.js";import{c as n,i as r,n as i,s as a}from"./notificationDays-pYmoU0g6.js";var o=`.wui-notification-center-trigger`,s=`.wui-notification-center-panel`,c=`.wui-notification-center-count`,l=`.wui-notification-center-live`,u=`.wui-notification-center-markall`,d=`.wui-notification-center-item`,f=`wui-notification-center-item-read`,p=`.wui-notification-center-unread-label`,m=class extends e{constructor(){super(),this._doc=null,this._unread=0,this._busy=!1,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onOutside=e=>{this.contains(e.target)||this.close()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}connectedCallback(){this._doc=this.ownerDocument,this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`mousedown`,this._onOutside),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`mousedown`,this._onOutside),this.removeEventListener(`focusout`,this._onFocusOut),this._doc=null}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(this.setAttribute(`open`,``),this._syncOpen(),this.querySelector(s)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&this.querySelector(o)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(o)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${d}:not(.${f})`).length}_click(e){let t=e.target.closest?.(`${o}, ${u}, ${d}`);if(!(!t||!this.contains(t))){if(t.matches(o)){this.toggle();return}this.hasAttribute(`controlled`)||(t.matches(u)?this._markAll():this._markItem(t))}}_key(e){if(e.key===`Escape`&&this.isOpen){e.preventDefault(),e.stopPropagation(),this.close({restoreFocus:!0});return}if(!this.isOpen||!this.querySelector(s)?.contains(e.target))return;let t={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`}[e.key];if(t===void 0)return;let n=[...this.querySelectorAll(d)];if(n.length===0)return;let r=n.indexOf(e.target.closest(d)),i;i=t===`first`?0:t===`last`?n.length-1:r===-1?t===1?0:n.length-1:Math.min(n.length-1,Math.max(0,r+t)),e.preventDefault(),n[i].focus()}_markItem(e){e.classList.contains(f)||(this._applyRead(e),this._unread=Math.max(0,this._unread-1),this._render(),this._say(n(this._unread)),this._emitRead([e.dataset.id].filter(Boolean),!1))}async _markAll(){if(this._busy)return;let e=[...this.querySelectorAll(`${d}:not(.${f})`)];if(e.length===0&&this._unread===0)return;let n=e.map(e=>e.dataset.id).filter(Boolean),r=this.getAttribute(`read-action`);if(r){this._setBusy(!0);let e=new URLSearchParams;for(let t of n)e.append(`ids`,t);let a=await t(r,{method:`POST`,body:e});if(this._setBusy(!1),!a.ok){if(a.kind===`session`||a.kind===`aborted`)return;let e=a.message||i.failed[a.kind]||i.failed.server;this._say(e),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:a.kind,message:e}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(i.allRead),this._emitRead(n,!0)}_applyRead(e){e.classList.add(f),e.querySelector(p)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(u);t&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=this.querySelector(c);e&&(e.textContent=r(this._unread),e.hidden=this._unread===0),this.querySelector(o)?.setAttribute(`aria-label`,a(this.getAttribute(`label`)||i.label,this._unread));let t=this.querySelector(u);t&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(l);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{m as t};
@@ -12,4 +12,4 @@ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from".
12
12
  </div>
13
13
  </div>
14
14
  <input type="tel" class="input" placeholder="${j(e)}" value="${j(C(this._country,this._national))}"${this.getAttribute(`aria-label`)?` aria-label="${j(this.getAttribute(`aria-label`))}"`:``}${this.getAttribute(`aria-describedby`)?` aria-describedby="${j(this.getAttribute(`aria-describedby`))}"`:``}${this.hasAttribute(`required`)?` required aria-required="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``} />
15
- </div>`,this._rendered=!0,i(this,this.value),this._wire()}_ensureItems(){let e=this.querySelector(`.country-list-scroll`);if(!e||e.querySelector(`.country-dropdown-item`))return;let t=this._listboxId,n=c.map(([e,n,r],i)=>`<button type="button" role="option" id="${j(`${t}-opt-${i}`)}" class="country-dropdown-item${e===this._country?` selected`:``}" data-iso="${e}" aria-selected="${e===this._country}"><span class="${_(e)}" aria-hidden="true"></span><span class="country-name-text">${n}<span class="country-code-text">+${r}</span></span></button>`).join(``);e.insertAdjacentHTML(`afterbegin`,n)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)]}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){this._teardown();let e=this.querySelector(`.country-toggle`),i=this.querySelector(`.phone-input-wrap`),a=this.querySelector(`.country-dropdown-menu`),c=this.querySelector(`.dropdown-search-input`),l=this.querySelector(`.country-list-scroll`),u=this.querySelector(`.country-empty`),d=this.querySelector(`input[type=tel]`),f=this.querySelector(`[data-flag]`),p=this.querySelector(`[data-dial]`);if(!e||!a)return;let m=()=>!a.hidden,h=()=>r(i||e,a),g=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,o(l,e>=0&&n[e]||null),e>=0&&n[e]?(t&&n[e].scrollIntoView({block:`nearest`}),c?.setAttribute(`aria-activedescendant`,n[e].id)):c?.removeAttribute(`aria-activedescendant`)},v=()=>{m()&&h()},y=()=>{this._ensureItems(),a.hidden=!1,e.setAttribute(`aria-expanded`,`true`),c.value=``,S(``),h(),t(this,v),c.focus(),g(this._visibleItems().findIndex(e=>e.classList.contains(`selected`)))},b=()=>{a.hidden=!0,e.setAttribute(`aria-expanded`,`false`),g(-1),n(this)},S=e=>{let t=e.trim().toLowerCase(),n=0;for(let e of this._itemEls()){let r=!t||e.textContent.toLowerCase().includes(t);e.hidden=!r,r&&(n+=1)}u&&(u.hidden=n>0)},A=e=>{this._country=e,this.getAttribute(`country`)!==e&&(this._suppressCountryRender=!0,this.setAttribute(`country`,e),this._suppressCountryRender=!1),f&&(f.className=_(e)),p&&(p.textContent=`+${s(e)}`);for(let t of this._itemEls()){let n=t.dataset.iso===e;t.classList.toggle(`selected`,n),t.setAttribute(`aria-selected`,String(n))}!this.getAttribute(`placeholder`)&&d&&(d.placeholder=T(e)||`Enter phone number`),d&&this._national&&(d.value=C(e,this._national)),b(),this._syncMirror(),this._emitChange(),this._validateOnInput&&M(N()),d?.focus()},j=t=>{let n=this._visibleItems();if(t.key===`ArrowDown`){if(t.preventDefault(),!m()){y();return}g(Math.min(this._active+1,n.length-1))}else if(t.key===`ArrowUp`){if(t.preventDefault(),!m())return;g(Math.max(this._active-1,0))}else t.key===`Enter`?(t.preventDefault(),m()&&n[this._active]&&A(n[this._active].dataset.iso)):t.key===`Escape`&&m()&&(t.preventDefault(),b(),e.focus())};e.addEventListener(`click`,()=>m()?b():y()),e.addEventListener(`keydown`,e=>{if(m()){j(e);return}(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),y())}),c.addEventListener(`input`,()=>{S(c.value);let e=this._visibleItems();g(e.length?0:-1)}),l.addEventListener(`click`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&A(t.dataset.iso)}),l.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&!t.classList.contains(`is-active`)&&g(this._visibleItems().indexOf(t),{reveal:!1})}),l.addEventListener(`mouseleave`,()=>g(-1)),a.addEventListener(`keydown`,j);let M=e=>{d.classList.toggle(`is-invalid`,e),e?d.setAttribute(`aria-invalid`,`true`):d.removeAttribute(`aria-invalid`);let t=this.querySelector(`[data-phone-error]`);if(e){t||(t=document.createElement(`div`),t.className=`field-error`,t.id=`${this.id}-phone-error`,t.setAttribute(`data-phone-error`,``),i.after(t));let e=T(this._country);t.textContent=this._country?e?`Enter a valid phone number, e.g. ${e}`:`Enter a valid phone number`:`Choose a country`}else t?.remove();this._syncDescribedBy()},N=()=>this._national.length>0&&(!this._country||E(this.value)===!1);d.addEventListener(`input`,e=>{e.stopPropagation();let t=d.selectionStart??d.value.length,n=d.value.slice(0,t).replace(/[^0-9]/g,``).length,r=d.value.replace(/[^0-9]/g,``),i=D(this._country);if(i&&r.length>i){let e=O(this._country,r,i);e?(n=Math.max(0,n-(r.length-e.length)),r=e):r=r.slice(0,i)}this._national=r;let a=C(this._country,this._national);if(d.value!==a){d.value=a;let e=w(a,Math.min(n,r.length));d.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),this._validateOnInput&&M(N())}),d.addEventListener(`change`,e=>e.stopPropagation()),d.addEventListener(`blur`,()=>{let e=N();M(e),e&&(this._validateOnInput=!0),this.value!==this._committedValue&&this._emitChange()}),d.addEventListener(`paste`,e=>{let t=k(e.clipboardData?.getData(`text`));t&&(e.preventDefault(),this._national=t.national.replace(/[^0-9]/g,``),t.country===this._country?d.value=C(this._country,this._national):this.setAttribute(`country`,t.country),this._syncMirror(),this._emitInput(),this._emitChange(),this._validateOnInput&&d.isConnected&&M(N()),this.querySelector(`input[type=tel]`)?.focus())}),this._bindGlobal=()=>{this._teardownGlobals?.(),this._onDocClick=e=>{m()&&!this.contains(e.target)&&b()},document.addEventListener(`click`,this._onDocClick),m()&&t(this,v)},this._teardownGlobals=()=>{this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this)},this._bindGlobal(),this._validateOnInput&&M(N()),x().then(e=>{if(!(!e||!d.isConnected)&&(this._national&&(d.value=C(this._country,this._national)),!this.getAttribute(`placeholder`))){let e=T(this._country);e&&(d.placeholder=e)}}),this._syncMirror()}_teardown(){this._teardownGlobals?.()}disconnectedCallback(){this._teardown()}},j=e=>String(e??``).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{A as t};
15
+ </div>`,this._rendered=!0,i(this,this.value),this._wire()}_ensureItems(){let e=this.querySelector(`.country-list-scroll`);if(!e||e.querySelector(`.country-dropdown-item`))return;let t=this._listboxId,n=c.map(([e,n,r],i)=>`<button type="button" role="option" id="${j(`${t}-opt-${i}`)}" class="country-dropdown-item${e===this._country?` selected`:``}" data-iso="${e}" aria-selected="${e===this._country}"><span class="${_(e)}" aria-hidden="true"></span><span class="country-name-text">${n}<span class="country-code-text">+${r}</span></span></button>`).join(``);e.insertAdjacentHTML(`afterbegin`,n)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)]}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){this._teardown();let e=this.querySelector(`.country-toggle`),i=this.querySelector(`.phone-input-wrap`),a=this.querySelector(`.country-dropdown-menu`),c=this.querySelector(`.dropdown-search-input`),l=this.querySelector(`.country-list-scroll`),u=this.querySelector(`.country-empty`),d=this.querySelector(`input[type=tel]`),f=this.querySelector(`[data-flag]`),p=this.querySelector(`[data-dial]`);if(!e||!a)return;let m=()=>!a.hidden,h=()=>r(i||e,a),g=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,o(l,e>=0&&n[e]||null),e>=0&&n[e]?(t&&n[e].scrollIntoView({block:`nearest`}),c?.setAttribute(`aria-activedescendant`,n[e].id)):c?.removeAttribute(`aria-activedescendant`)},v=()=>{m()&&h()},y=()=>{this._ensureItems(),a.hidden=!1,e.setAttribute(`aria-expanded`,`true`),c.value=``,S(``),h(),t(this,v),c.focus(),g(this._visibleItems().findIndex(e=>e.classList.contains(`selected`)))},b=()=>{a.hidden=!0,e.setAttribute(`aria-expanded`,`false`),g(-1),n(this)},S=e=>{let t=e.trim().toLowerCase(),n=0;for(let e of this._itemEls()){let r=!t||e.textContent.toLowerCase().includes(t);e.hidden=!r,r&&(n+=1)}u&&(u.hidden=n>0)},A=e=>{this._country=e,this.getAttribute(`country`)!==e&&(this._suppressCountryRender=!0,this.setAttribute(`country`,e),this._suppressCountryRender=!1),f&&(f.className=_(e)),p&&(p.textContent=`+${s(e)}`);for(let t of this._itemEls()){let n=t.dataset.iso===e;t.classList.toggle(`selected`,n),t.setAttribute(`aria-selected`,String(n))}!this.getAttribute(`placeholder`)&&d&&(d.placeholder=T(e)||`Enter phone number`),d&&this._national&&(d.value=C(e,this._national)),b(),this._syncMirror(),this._emitChange(),this._validateOnInput&&M(N()),d?.focus()},j=t=>{let n=this._visibleItems();if(t.key===`ArrowDown`){if(t.preventDefault(),!m()){y();return}g(Math.min(this._active+1,n.length-1))}else if(t.key===`ArrowUp`){if(t.preventDefault(),!m())return;g(Math.max(this._active-1,0))}else t.key===`Enter`?(t.preventDefault(),m()&&n[this._active]&&A(n[this._active].dataset.iso)):t.key===`Escape`&&m()&&(t.preventDefault(),t.stopPropagation(),b(),e.focus())};e.addEventListener(`click`,()=>m()?b():y()),e.addEventListener(`keydown`,e=>{if(m()){j(e);return}(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),y())}),c.addEventListener(`input`,()=>{S(c.value);let e=this._visibleItems();g(e.length?0:-1)}),l.addEventListener(`click`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&A(t.dataset.iso)}),l.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&!t.classList.contains(`is-active`)&&g(this._visibleItems().indexOf(t),{reveal:!1})}),l.addEventListener(`mouseleave`,()=>g(-1)),a.addEventListener(`keydown`,j);let M=e=>{d.classList.toggle(`is-invalid`,e),e?d.setAttribute(`aria-invalid`,`true`):d.removeAttribute(`aria-invalid`);let t=this.querySelector(`[data-phone-error]`);if(e){t||(t=document.createElement(`div`),t.className=`field-error`,t.id=`${this.id}-phone-error`,t.setAttribute(`data-phone-error`,``),i.after(t));let e=T(this._country);t.textContent=this._country?e?`Enter a valid phone number, e.g. ${e}`:`Enter a valid phone number`:`Choose a country`}else t?.remove();this._syncDescribedBy()},N=()=>this._national.length>0&&(!this._country||E(this.value)===!1);d.addEventListener(`input`,e=>{e.stopPropagation();let t=d.selectionStart??d.value.length,n=d.value.slice(0,t).replace(/[^0-9]/g,``).length,r=d.value.replace(/[^0-9]/g,``),i=D(this._country);if(i&&r.length>i){let e=O(this._country,r,i);e?(n=Math.max(0,n-(r.length-e.length)),r=e):r=r.slice(0,i)}this._national=r;let a=C(this._country,this._national);if(d.value!==a){d.value=a;let e=w(a,Math.min(n,r.length));d.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),this._validateOnInput&&M(N())}),d.addEventListener(`change`,e=>e.stopPropagation()),d.addEventListener(`blur`,()=>{let e=N();M(e),e&&(this._validateOnInput=!0),this.value!==this._committedValue&&this._emitChange()}),d.addEventListener(`paste`,e=>{let t=k(e.clipboardData?.getData(`text`));t&&(e.preventDefault(),this._national=t.national.replace(/[^0-9]/g,``),t.country===this._country?d.value=C(this._country,this._national):this.setAttribute(`country`,t.country),this._syncMirror(),this._emitInput(),this._emitChange(),this._validateOnInput&&d.isConnected&&M(N()),this.querySelector(`input[type=tel]`)?.focus())}),this._bindGlobal=()=>{this._teardownGlobals?.(),this._onDocClick=e=>{m()&&!this.contains(e.target)&&b()},document.addEventListener(`click`,this._onDocClick),m()&&t(this,v)},this._teardownGlobals=()=>{this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this)},this._bindGlobal(),this._validateOnInput&&M(N()),x().then(e=>{if(!(!e||!d.isConnected)&&(this._national&&(d.value=C(this._country,this._national)),!this.getAttribute(`placeholder`))){let e=T(this._country);e&&(d.placeholder=e)}}),this._syncMirror()}_teardown(){this._teardownGlobals?.()}disconnectedCallback(){this._teardown()}},j=e=>String(e??``).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{A as t};
@@ -11,4 +11,4 @@ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from".
11
11
  ${t?`<div class="search-select-search">${a(`search`)}<input class="search-select-input" placeholder="${f(p)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden>${a(`x`)}</button></div>`:``}
12
12
  <div class="search-select-options">${g}<div class="search-select-empty" hidden>No matches</div></div>
13
13
  </div>
14
- </div>`,this._rendered=!0,i(this,this._value),this._wire(),this._syncReset()}_refs(){return{control:this.querySelector(`.search-select-control`),menu:this.querySelector(`.search-select-menu`),label:this.querySelector(`[data-label]`),reset:this.querySelector(`.search-select-reset`),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?l(t):c(this.getAttribute(`placeholder`)||`Select...`),e.classList.toggle(`search-select-placeholder`,!t))}_syncReset(){let{reset:e}=this._refs();e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._value!==``&&!this.hasAttribute(`disabled`)))}_wire(){this._teardown();let e=this._refs();if(!e.control||!e.menu)return;let i=()=>{if(this.hasAttribute(`compact`)){let t=e.control.getBoundingClientRect();e.menu.style.width=`max-content`,e.menu.style.minWidth=`${t.width}px`,e.menu.style.maxWidth=`280px`,r(e.control,e.menu)}else r(e.control,e.menu,{matchWidth:!0})},a=(t,{reveal:n=!0}={})=>{let r=this._visible();this._active=t,o(e.optionsWrap,t>=0&&r[t]||null),t>=0&&r[t]?(n&&r[t].scrollIntoView({block:`nearest`}),e.control.setAttribute(`aria-activedescendant`,r[t].id)):e.control.removeAttribute(`aria-activedescendant`)},c=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),e.menu.hidden||i()},l=()=>!e.menu.hidden,u=()=>{l()&&i()},d=()=>{e.menu.hidden=!1,e.control.setAttribute(`aria-expanded`,`true`),e.control.classList.add(`open`),i(),t(this,u),e.search&&(e.search.value=``,c(``),e.search.focus()),a(this._optionEls().findIndex(e=>e.classList.contains(`selected`)))},f=()=>{e.menu.hidden=!0,e.control.setAttribute(`aria-expanded`,`false`),e.control.classList.remove(`open`),a(-1),n(this)},p=t=>{this.value=t.dataset.value,this.dispatchEvent(new Event(`change`,{bubbles:!0})),f(),e.control.focus()};this._navHandler=s({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>a(e),onEnter:e=>{e&&p(e)},onEscape:()=>{this._navHandler.clearTypeahead(),f(),e.control.focus()}}),e.reset?.addEventListener(`click`,t=>{t.stopPropagation(),this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),e.control.focus()}),e.control.addEventListener(`click`,()=>l()?f():d()),e.control.addEventListener(`keydown`,e=>{if(l()){this._navHandler.handler(e);return}(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d())}),e.optionsWrap.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&p(t)}),e.optionsWrap.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&!t.classList.contains(`is-active`)&&a(this._visible().indexOf(t),{reveal:!1})}),e.optionsWrap.addEventListener(`mouseleave`,()=>a(-1)),e.search?.addEventListener(`input`,()=>{c(e.search.value),a(-1)}),e.clear?.addEventListener(`click`,()=>{e.search.value=``,c(``),e.search.focus()}),e.menu.addEventListener(`keydown`,this._navHandler.handler),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{l()&&!this.contains(e.target)&&f()},document.addEventListener(`click`,this._onDocClick),l()&&t(this,u)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this),this._navHandler?.teardown()}disconnectedCallback(){this._teardown()}},f=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{d as t};
14
+ </div>`,this._rendered=!0,i(this,this._value),this._wire(),this._syncReset()}_refs(){return{control:this.querySelector(`.search-select-control`),menu:this.querySelector(`.search-select-menu`),label:this.querySelector(`[data-label]`),reset:this.querySelector(`.search-select-reset`),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?l(t):c(this.getAttribute(`placeholder`)||`Select...`),e.classList.toggle(`search-select-placeholder`,!t))}_syncReset(){let{reset:e}=this._refs();e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._value!==``&&!this.hasAttribute(`disabled`)))}_wire(){this._teardown();let e=this._refs();if(!e.control||!e.menu)return;let i=()=>{if(this.hasAttribute(`compact`)){let t=e.control.getBoundingClientRect();e.menu.style.width=`max-content`,e.menu.style.minWidth=`${t.width}px`,e.menu.style.maxWidth=`280px`,r(e.control,e.menu)}else r(e.control,e.menu,{matchWidth:!0})},a=(t,{reveal:n=!0}={})=>{let r=this._visible();this._active=t,o(e.optionsWrap,t>=0&&r[t]||null),t>=0&&r[t]?(n&&r[t].scrollIntoView({block:`nearest`}),e.control.setAttribute(`aria-activedescendant`,r[t].id)):e.control.removeAttribute(`aria-activedescendant`)},c=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),e.menu.hidden||i()},l=()=>!e.menu.hidden,u=()=>{l()&&i()},d=()=>{e.menu.hidden=!1,e.control.setAttribute(`aria-expanded`,`true`),e.control.classList.add(`open`),i(),t(this,u),e.search&&(e.search.value=``,c(``),e.search.focus()),a(this._optionEls().findIndex(e=>e.classList.contains(`selected`)))},f=()=>{e.menu.hidden=!0,e.control.setAttribute(`aria-expanded`,`false`),e.control.classList.remove(`open`),a(-1),n(this)},p=t=>{this.value=t.dataset.value,this.dispatchEvent(new Event(`change`,{bubbles:!0})),f(),e.control.focus()};this._navHandler=s({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>a(e),onEnter:e=>{e&&p(e)},onEscape:()=>{this._navHandler.clearTypeahead(),f(),e.control.focus()}});let m=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation()),this._navHandler.handler(e)};e.reset?.addEventListener(`click`,t=>{t.stopPropagation(),this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),e.control.focus()}),e.control.addEventListener(`click`,()=>l()?f():d()),e.control.addEventListener(`keydown`,e=>{if(l()){m(e);return}(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d())}),e.optionsWrap.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&p(t)}),e.optionsWrap.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&!t.classList.contains(`is-active`)&&a(this._visible().indexOf(t),{reveal:!1})}),e.optionsWrap.addEventListener(`mouseleave`,()=>a(-1)),e.search?.addEventListener(`input`,()=>{c(e.search.value),a(-1)}),e.clear?.addEventListener(`click`,()=>{e.search.value=``,c(``),e.search.focus()}),e.menu.addEventListener(`keydown`,m),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{l()&&!this.contains(e.target)&&f()},document.addEventListener(`click`,this._onDocClick),l()&&t(this,u)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this),this._navHandler?.teardown()}disconnectedCallback(){this._teardown()}},f=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{d as t};
@@ -6,4 +6,4 @@ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from".
6
6
  </div>
7
7
  <div class="timepicker-pop" id="${n}-pop" role="dialog" aria-label="Choose time" hidden></div>
8
8
  <div class="field-error wui-timepicker-error" id="${n}-error" hidden></div>
9
- </div>`,this._rendered=!0,this._syncAttrs(),this._syncText(),this._syncInvalid(),i(this,this._value),this._wire()}_input(){return this.querySelector(`.timepicker-trigger`)}_pop(){return this.querySelector(`.timepicker-pop`)}_syncFormValue(){i(this,this._value)}_syncAttrs(){let e=this._input(),t=this.querySelector(`.wui-timepicker-toggle`);if(!e)return;let n=this.hasAttribute(`disabled`);e.disabled=n,t&&(t.disabled=n),e.placeholder=this.getAttribute(`placeholder`)||`Select time`,this.hasAttribute(`required`)?e.setAttribute(`aria-required`,`true`):e.removeAttribute(`aria-required`);let r=this.getAttribute(`aria-label`);r?e.setAttribute(`aria-label`,r):e.removeAttribute(`aria-label`),i(this,this._value),n&&this._isOpen?.()&&this._close({commit:!1})}_syncText(){let e=this._input();e&&(e.value=l(c(this._value),this._format()),this._isOpen?.()&&this._syncColumns())}_syncInvalid(){let e=this._input(),t=this.querySelector(`.wui-timepicker-error`);if(!e||!t)return;let n=this._typedError;t.textContent=n,t.hidden=!n,this.hasAttribute(`aria-invalid`)||n?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`);let r=[this.getAttribute(`aria-describedby`),n?t.id:null].filter(Boolean).join(` `);r?e.setAttribute(`aria-describedby`,r):e.removeAttribute(`aria-describedby`),e.setCustomValidity?.(n)}_commitText(){let e=this._input();if(!e||e.value===l(c(this._value),this._format()))return!0;let t=e.value.trim(),n=``;if(t){let e=u(t),r=e?this._refusal(e):`Enter a time like ${this._format()===`12`?`7:45 PM`:`19:45`}.`;if(r)return this._typedError=r,this._syncInvalid(),!1;n=s(e.h,e.m)}let r=n!==this._value;return this.value=n,r&&this.dispatchEvent(new Event(`change`,{bubbles:!0})),!0}_pending(){let e=u(this._input()?.value);return e&&this._allowed(e.h,e.m)?e:null}_columnsHtml(){let e=this._format(),t=this._times(),n=(e,t,n)=>`<div class="wui-timepicker-col" role="listbox" aria-label="${t}" data-col="${e}">${n.map(e=>`<button type="button" class="timepicker-option" role="option" tabindex="-1" aria-selected="false" data-v="${e.v}">${e.text}</button>`).join(``)}</div>`,r=[...new Set(t.map(e=>e.h))],i=[...new Set(t.map(e=>e.m))].sort((e,t)=>e-t),a;if(e===`12`){let e=[...new Set(r.map(e=>e%12))].sort((e,t)=>e-t),t=[...new Set(r.map(e=>e>=12?`pm`:`am`))].sort();a=n(`hour`,`Hour`,e.map(e=>({v:e,text:String(e||12)})))+n(`minute`,`Minute`,i.map(e=>({v:e,text:o(e)})))+n(`period`,`AM or PM`,t.map(e=>({v:e,text:e.toUpperCase()})))}else a=n(`hour`,`Hour`,r.map(e=>({v:e,text:o(e)})))+n(`minute`,`Minute`,i.map(e=>({v:e,text:o(e)})));return`<div class="wui-timepicker-cols">${a}</div>`}_selectedIn(e,t){return t?e===`minute`?String(t.m):e===`period`?t.h>=12?`pm`:`am`:String(this._format()===`12`?t.h%12:t.h):null}_optionEnabled(e,t,n){if(!n)return!0;let r=this._format()===`12`,i=n.h>=12,a=e=>r?[e+(i?12:0)]:[e],o=Array.from({length:60},(e,t)=>t);if(e===`hour`)return a(+t).some(e=>o.some(t=>this._allowed(e,t)));if(e===`minute`)return this._allowed(n.h,+t);let s=t===`pm`?12:0;return Array.from({length:12},(e,t)=>s+t).some(e=>o.some(t=>this._allowed(e,t)))}_syncColumns({scroll:e=!1}={}){let t=this._pop();if(!t)return;let n=this._pending();for(let r of t.querySelectorAll(`.wui-timepicker-col`)){let t=r.dataset.col,i=this._selectedIn(t,n),a=[...r.querySelectorAll(`.timepicker-option`)],o=null;for(let e of a){let r=e.dataset.v===i;e.classList.toggle(`is-selected`,r),e.setAttribute(`aria-selected`,r?`true`:`false`),e.disabled=!r&&!this._optionEnabled(t,e.dataset.v,n),r&&(o=e)}o=o||a.find(e=>!e.disabled)||null;for(let e of a)e.tabIndex=e===o?0:-1;e&&o&&(r.scrollTop=o.offsetTop-(r.clientHeight-o.offsetHeight)/2)}}_pick(e,t){let n=this._times();if(!n.length)return;let r=this._pending()||n[0],i=this._format()===`12`,a=r.h,o=r.m;if(e===`minute`?o=+t:a=e===`period`?a%12+(t===`pm`?12:0):i?+t+(r.h>=12?12:0):+t,!this._allowed(a,o)){let t=a*60+o,r=n.filter(t=>e===`minute`?t.m===o:e===`period`?t.h>=12==a>=12:i?t.h%12==a%12&&t.h>=12==a>=12:t.h===a).sort((e,n)=>Math.abs(e.h*60+e.m-t)-Math.abs(n.h*60+n.m-t))[0];if(!r)return;a=r.h,o=r.m}let s=this._input();s.value=l({h:a,m:o},this._format()),this._typedError=``,this._syncInvalid(),this._syncColumns()}_position(){r(this.querySelector(`.wui-timepicker-field`),this._pop())}_onColumnKey(e){let t=e.target.closest?.(`.timepicker-option`),n=t?.closest(`.wui-timepicker-col`);if(!t||!n)return;let r=[...n.querySelectorAll(`.timepicker-option`)].filter(e=>!e.disabled),i=r.indexOf(t),a=[...this._pop().querySelectorAll(`.wui-timepicker-col`)],o=e=>{e&&(this._pick(n.dataset.col,e.dataset.v),(n.querySelector(`.timepicker-option.is-selected`)||e).focus())};switch(e.key){case`ArrowDown`:e.preventDefault(),o(r[Math.min(i+1,r.length-1)]);return;case`ArrowUp`:e.preventDefault(),o(r[Math.max(i-1,0)]);return;case`Home`:e.preventDefault(),o(r[0]);return;case`End`:e.preventDefault(),o(r[r.length-1]);return;case`PageDown`:e.preventDefault(),o(r[Math.min(i+8,r.length-1)]);return;case`PageUp`:e.preventDefault(),o(r[Math.max(i-8,0)]);return;case`ArrowRight`:case`ArrowLeft`:e.preventDefault(),a[a.indexOf(n)+(e.key===`ArrowRight`?1:-1)]?.querySelector(`.timepicker-option[tabindex="0"]`)?.focus();return;case`Enter`:e.preventDefault(),this._close({commit:!0,refocus:!0});return;case` `:e.preventDefault(),o(t);return;case`Escape`:e.preventDefault(),this._close({commit:!1,refocus:!0});return;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),clearTimeout(this._typeaheadTimer),this._typeahead+=e.key.toLowerCase(),this._typeaheadTimer=setTimeout(()=>{this._typeahead=``,this._typeaheadTimer=null},500),o(r.find(e=>e.textContent.trim().toLowerCase().startsWith(this._typeahead))))}}_wire(){this._teardown();let e=this._input(),r=this.querySelector(`.wui-timepicker-toggle`),i=this._pop(),a=this.querySelector(`.timepicker`);if(!e||!i)return;let o=()=>!i.hidden;this._isOpen=o;let s=()=>{o()&&this._position()},c=()=>i.querySelector(`.wui-timepicker-col .timepicker-option[tabindex="0"]`)?.focus();this._open=({focus:n=!1}={})=>{this.hasAttribute(`disabled`)||(o()||(i.innerHTML=this._columnsHtml(),i.hidden=!1,a?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),r?.setAttribute(`aria-expanded`,`true`),this._position(),t(this,s),this._syncColumns({scroll:!0})),n&&c())},this._close=({commit:t=!0,refocus:s=!1}={})=>{if(!o())return;let c=i.contains(document.activeElement);i.hidden=!0,i.innerHTML=``,a?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),r?.setAttribute(`aria-expanded`,`false`),n(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,t?this._commitText():(this._typedError=``,this._syncText(),this._syncInvalid()),(s||c)&&e.focus()},e.addEventListener(`pointerdown`,e=>{this._lastPointer=e.pointerType}),e.addEventListener(`click`,()=>{this._lastPointer!==`touch`&&!o()&&this._open(),this._lastPointer=null}),r?.addEventListener(`click`,()=>{o()?this._close({commit:!0,refocus:!0}):this._open({focus:!0})}),e.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._open({focus:!0});else if(e.key===`Enter`){let t=o(),n=this._commitText();t&&n&&this._close({commit:!1}),(!n||t)&&e.preventDefault()}else e.key===`Escape`&&o()?(e.preventDefault(),this._close({commit:!1})):e.key===`Tab`&&o()&&this._close({commit:!0})}),e.addEventListener(`input`,e=>{e.stopPropagation(),this._typedError&&(this._typedError=``,this._syncInvalid()),o()&&this._syncColumns({scroll:!0})}),e.addEventListener(`change`,e=>{e.stopPropagation(),o()||this._commitText()}),i.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`.timepicker-option`),n=t?.closest(`.wui-timepicker-col`);t&&n&&!t.disabled&&this._pick(n.dataset.col,t.dataset.v)}),i.addEventListener(`keydown`,e=>{o()&&this._onColumnKey(e)}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,o()&&!t&&!this.contains(e.target)&&this._close({commit:!0})},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{o()&&e.key===`Escape`&&this._close({commit:!1})},document.addEventListener(`keydown`,this._onDocKey),o()&&t(this,s)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),n(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``}disconnectedCallback(){this._teardown()}};export{f as t};
9
+ </div>`,this._rendered=!0,this._syncAttrs(),this._syncText(),this._syncInvalid(),i(this,this._value),this._wire()}_input(){return this.querySelector(`.timepicker-trigger`)}_pop(){return this.querySelector(`.timepicker-pop`)}_syncFormValue(){i(this,this._value)}_syncAttrs(){let e=this._input(),t=this.querySelector(`.wui-timepicker-toggle`);if(!e)return;let n=this.hasAttribute(`disabled`);e.disabled=n,t&&(t.disabled=n),e.placeholder=this.getAttribute(`placeholder`)||`Select time`,this.hasAttribute(`required`)?e.setAttribute(`aria-required`,`true`):e.removeAttribute(`aria-required`);let r=this.getAttribute(`aria-label`);r?e.setAttribute(`aria-label`,r):e.removeAttribute(`aria-label`),i(this,this._value),n&&this._isOpen?.()&&this._close({commit:!1})}_syncText(){let e=this._input();e&&(e.value=l(c(this._value),this._format()),this._isOpen?.()&&this._syncColumns())}_syncInvalid(){let e=this._input(),t=this.querySelector(`.wui-timepicker-error`);if(!e||!t)return;let n=this._typedError;t.textContent=n,t.hidden=!n,this.hasAttribute(`aria-invalid`)||n?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`);let r=[this.getAttribute(`aria-describedby`),n?t.id:null].filter(Boolean).join(` `);r?e.setAttribute(`aria-describedby`,r):e.removeAttribute(`aria-describedby`),e.setCustomValidity?.(n)}_commitText(){let e=this._input();if(!e||e.value===l(c(this._value),this._format()))return!0;let t=e.value.trim(),n=``;if(t){let e=u(t),r=e?this._refusal(e):`Enter a time like ${this._format()===`12`?`7:45 PM`:`19:45`}.`;if(r)return this._typedError=r,this._syncInvalid(),!1;n=s(e.h,e.m)}let r=n!==this._value;return this.value=n,r&&this.dispatchEvent(new Event(`change`,{bubbles:!0})),!0}_pending(){let e=u(this._input()?.value);return e&&this._allowed(e.h,e.m)?e:null}_columnsHtml(){let e=this._format(),t=this._times(),n=(e,t,n)=>`<div class="wui-timepicker-col" role="listbox" aria-label="${t}" data-col="${e}">${n.map(e=>`<button type="button" class="timepicker-option" role="option" tabindex="-1" aria-selected="false" data-v="${e.v}">${e.text}</button>`).join(``)}</div>`,r=[...new Set(t.map(e=>e.h))],i=[...new Set(t.map(e=>e.m))].sort((e,t)=>e-t),a;if(e===`12`){let e=[...new Set(r.map(e=>e%12))].sort((e,t)=>e-t),t=[...new Set(r.map(e=>e>=12?`pm`:`am`))].sort();a=n(`hour`,`Hour`,e.map(e=>({v:e,text:String(e||12)})))+n(`minute`,`Minute`,i.map(e=>({v:e,text:o(e)})))+n(`period`,`AM or PM`,t.map(e=>({v:e,text:e.toUpperCase()})))}else a=n(`hour`,`Hour`,r.map(e=>({v:e,text:o(e)})))+n(`minute`,`Minute`,i.map(e=>({v:e,text:o(e)})));return`<div class="wui-timepicker-cols">${a}</div>`}_selectedIn(e,t){return t?e===`minute`?String(t.m):e===`period`?t.h>=12?`pm`:`am`:String(this._format()===`12`?t.h%12:t.h):null}_optionEnabled(e,t,n){if(!n)return!0;let r=this._format()===`12`,i=n.h>=12,a=e=>r?[e+(i?12:0)]:[e],o=Array.from({length:60},(e,t)=>t);if(e===`hour`)return a(+t).some(e=>o.some(t=>this._allowed(e,t)));if(e===`minute`)return this._allowed(n.h,+t);let s=t===`pm`?12:0;return Array.from({length:12},(e,t)=>s+t).some(e=>o.some(t=>this._allowed(e,t)))}_syncColumns({scroll:e=!1}={}){let t=this._pop();if(!t)return;let n=this._pending();for(let r of t.querySelectorAll(`.wui-timepicker-col`)){let t=r.dataset.col,i=this._selectedIn(t,n),a=[...r.querySelectorAll(`.timepicker-option`)],o=null;for(let e of a){let r=e.dataset.v===i;e.classList.toggle(`is-selected`,r),e.setAttribute(`aria-selected`,r?`true`:`false`),e.disabled=!r&&!this._optionEnabled(t,e.dataset.v,n),r&&(o=e)}o=o||a.find(e=>!e.disabled)||null;for(let e of a)e.tabIndex=e===o?0:-1;e&&o&&(r.scrollTop=o.offsetTop-(r.clientHeight-o.offsetHeight)/2)}}_pick(e,t){let n=this._times();if(!n.length)return;let r=this._pending()||n[0],i=this._format()===`12`,a=r.h,o=r.m;if(e===`minute`?o=+t:a=e===`period`?a%12+(t===`pm`?12:0):i?+t+(r.h>=12?12:0):+t,!this._allowed(a,o)){let t=a*60+o,r=n.filter(t=>e===`minute`?t.m===o:e===`period`?t.h>=12==a>=12:i?t.h%12==a%12&&t.h>=12==a>=12:t.h===a).sort((e,n)=>Math.abs(e.h*60+e.m-t)-Math.abs(n.h*60+n.m-t))[0];if(!r)return;a=r.h,o=r.m}let s=this._input();s.value=l({h:a,m:o},this._format()),this._typedError=``,this._syncInvalid(),this._syncColumns()}_position(){r(this.querySelector(`.wui-timepicker-field`),this._pop())}_onColumnKey(e){let t=e.target.closest?.(`.timepicker-option`),n=t?.closest(`.wui-timepicker-col`);if(!t||!n)return;let r=[...n.querySelectorAll(`.timepicker-option`)].filter(e=>!e.disabled),i=r.indexOf(t),a=[...this._pop().querySelectorAll(`.wui-timepicker-col`)],o=e=>{e&&(this._pick(n.dataset.col,e.dataset.v),(n.querySelector(`.timepicker-option.is-selected`)||e).focus())};switch(e.key){case`ArrowDown`:e.preventDefault(),o(r[Math.min(i+1,r.length-1)]);return;case`ArrowUp`:e.preventDefault(),o(r[Math.max(i-1,0)]);return;case`Home`:e.preventDefault(),o(r[0]);return;case`End`:e.preventDefault(),o(r[r.length-1]);return;case`PageDown`:e.preventDefault(),o(r[Math.min(i+8,r.length-1)]);return;case`PageUp`:e.preventDefault(),o(r[Math.max(i-8,0)]);return;case`ArrowRight`:case`ArrowLeft`:e.preventDefault(),a[a.indexOf(n)+(e.key===`ArrowRight`?1:-1)]?.querySelector(`.timepicker-option[tabindex="0"]`)?.focus();return;case`Enter`:e.preventDefault(),this._close({commit:!0,refocus:!0});return;case` `:e.preventDefault(),o(t);return;case`Escape`:e.preventDefault(),e.stopPropagation(),this._close({commit:!1,refocus:!0});return;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),clearTimeout(this._typeaheadTimer),this._typeahead+=e.key.toLowerCase(),this._typeaheadTimer=setTimeout(()=>{this._typeahead=``,this._typeaheadTimer=null},500),o(r.find(e=>e.textContent.trim().toLowerCase().startsWith(this._typeahead))))}}_wire(){this._teardown();let e=this._input(),r=this.querySelector(`.wui-timepicker-toggle`),i=this._pop(),a=this.querySelector(`.timepicker`);if(!e||!i)return;let o=()=>!i.hidden;this._isOpen=o;let s=()=>{o()&&this._position()},c=()=>i.querySelector(`.wui-timepicker-col .timepicker-option[tabindex="0"]`)?.focus();this._open=({focus:n=!1}={})=>{this.hasAttribute(`disabled`)||(o()||(i.innerHTML=this._columnsHtml(),i.hidden=!1,a?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),r?.setAttribute(`aria-expanded`,`true`),this._position(),t(this,s),this._syncColumns({scroll:!0})),n&&c())},this._close=({commit:t=!0,refocus:s=!1}={})=>{if(!o())return;let c=i.contains(document.activeElement);i.hidden=!0,i.innerHTML=``,a?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),r?.setAttribute(`aria-expanded`,`false`),n(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,t?this._commitText():(this._typedError=``,this._syncText(),this._syncInvalid()),(s||c)&&e.focus()},e.addEventListener(`pointerdown`,e=>{this._lastPointer=e.pointerType}),e.addEventListener(`click`,()=>{this._lastPointer!==`touch`&&!o()&&this._open(),this._lastPointer=null}),r?.addEventListener(`click`,()=>{o()?this._close({commit:!0,refocus:!0}):this._open({focus:!0})}),e.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._open({focus:!0});else if(e.key===`Enter`){let t=o(),n=this._commitText();t&&n&&this._close({commit:!1}),(!n||t)&&e.preventDefault()}else e.key===`Escape`&&o()?(e.preventDefault(),e.stopPropagation(),this._close({commit:!1})):e.key===`Tab`&&o()&&this._close({commit:!0})}),e.addEventListener(`input`,e=>{e.stopPropagation(),this._typedError&&(this._typedError=``,this._syncInvalid()),o()&&this._syncColumns({scroll:!0})}),e.addEventListener(`change`,e=>{e.stopPropagation(),o()||this._commitText()}),i.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`.timepicker-option`),n=t?.closest(`.wui-timepicker-col`);t&&n&&!t.disabled&&this._pick(n.dataset.col,t.dataset.v)}),i.addEventListener(`keydown`,e=>{o()&&this._onColumnKey(e)}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,o()&&!t&&!this.contains(e.target)&&this._close({commit:!0})},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{o()&&e.key===`Escape`&&this._close({commit:!1})},document.addEventListener(`keydown`,this._onDocKey),this._onHostKey=e=>{!o()||e.key!==`Escape`||(e.preventDefault(),e.stopPropagation(),this._close({commit:!1,refocus:!0}))},this.addEventListener(`keydown`,this._onHostKey),o()&&t(this,s)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),this._onHostKey&&=(this.removeEventListener(`keydown`,this._onHostKey),null),n(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``}disconnectedCallback(){this._teardown()}};export{f as t};