@webority/ui-elements 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui-elements.global.js +8 -7
- package/dist/ui-elements.js +14 -12
- package/package.json +1 -1
|
@@ -19,7 +19,8 @@ var WeborityUiElements=(function(e){Object.defineProperty(e,Symbol.toStringTag,{
|
|
|
19
19
|
<div class="search-select-empty" hidden>No matches</div>
|
|
20
20
|
<div class="search-select-hint" hidden>Type to search…</div>
|
|
21
21
|
</div>
|
|
22
|
-
</div>`,this._rendered=!0,g(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=>ae(e.label).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 “${b(e.value)}”`;return`<button type="button" role="option" id="${S(n)}" class="search-select-option search-select-option-custom" data-value="${S(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="${S(n)}" class="search-select-option${r?` selected`:``}" data-value="${S(e.value)}" aria-selected="${r}">${x(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 t=()=>f(e.control,e.menu,{matchWidth:!0}),n=()=>this._optionEls().filter(e=>!e.hidden),r=t=>{let r=n();this._active=t;for(let e of this._optionEls())e.classList.remove(`is-active`);t>=0&&r[t]?(r[t].classList.add(`is-active`),r[t].scrollIntoView({block:`nearest`}),e.control.setAttribute(`aria-activedescendant`,r[t].id)):e.control.removeAttribute(`aria-activedescendant`)},i=()=>!e.menu.hidden,a=()=>{e.menu.hidden=!1,e.control.setAttribute(`aria-expanded`,`true`),e.control.classList.add(`open`),t(),this._renderOptions()},o=()=>{e.menu.hidden=!0,e.control.setAttribute(`aria-expanded`,`false`),e.control.classList.remove(`open`),r(-1),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,this._syncInput()},s=t=>{let n=t.dataset.custom===`true`;this._value=t.dataset.value,this._label=n?t.dataset.value:ae(t.innerHTML),g(this,this._value),e.input.value=this._label,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:n}})),o(),e.input.focus()},c=t=>{this._value=t,this._label=t,g(this,t),e.input.value=t,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!0}})),o()},l=()=>{let t=e.input.value;if(e.clear&&(e.clear.hidden=!t),i()||a(),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=ee({getVisibleOptions:n,getActive:()=>this._active,setActive:e=>r(e),onEnter:(t,n)=>{if(n[this._active])s(n[this._active]);else if(this._allowCustom){let t=e.input.value.trim();t&&!this._matchesKnownOption(t)&&c(t)}},onEscape:()=>{this._navHandler.clearTypeahead(),o()}});let u=e=>{let t=e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`;if(e.key===`ArrowDown`){e.preventDefault(),i()||a();let t=n();r(Math.min(this._active+1,t.length-1));return}else if(e.key===`ArrowUp`){e.preventDefault(),r(Math.max(this._active-1,0));return}else if((e.key===`Home`||e.key===`End`||e.key===`PageDown`||e.key===`PageUp`)&&(!i()||t))return;else if(e.key.length===1&&(e.ctrlKey||e.metaKey||e.altKey||!i()||e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`)&&(!i()||e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`))return;this._navHandler.handler(e)};e.input.addEventListener(`focus`,()=>a()),e.input.addEventListener(`input`,l),e.input.addEventListener(`keydown`,u),e.menu.addEventListener(`keydown`,u),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)||c(n)}),e.optionsWrap.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&s(t)}),e.optionsWrap.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&r(this._optionEls().indexOf(t))}),e.optionsWrap.addEventListener(`mouseleave`,()=>r(-1)),e.clear?.addEventListener(`click`,()=>{this._value=``,this._label=``,g(this,``),e.input.value=``,e.clear.hidden=!0,this._renderOptions(``),this.dispatchEvent(new Event(`change`,{bubbles:!0})),e.input.focus()}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{i()&&!this.contains(e.target)&&o()},document.addEventListener(`click`,this._onDocClick),p(this,()=>{i()&&t()})},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),m(this),clearTimeout(this._timer),this._navHandler?.teardown()}disconnectedCallback(){this._teardown()}},S=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`),ae=e=>String(e??``).replace(/<[^>]*>/g,``);function oe(e,t){let n=String(e??``),r=String(t??``).trim();if(!r||!n)return[{text:n,match:!1}];let i=n.toLowerCase(),a=r.toLowerCase();if(i.length!==n.length)return[{text:n,match:!1}];let o=[],s=0,c=i.indexOf(a,s);for(;c!==-1;)c>s&&o.push({text:n.slice(s,c),match:!1}),o.push({text:n.slice(c,c+a.length),match:!0}),s=c+a.length,c=i.indexOf(a,s);return s<n.length&&o.push({text:n.slice(s),match:!1}),o}var se=`[role="option"]`,ce=`No results`,le=class extends i{static get observedAttributes(){return[`filter`,`highlight`,`empty-text`]}constructor(){super(),this._activeId=null,this._lastQuery=null,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=this._optionFrom(e.target);t&&this._select(t)},this._onMouseDown=e=>{this._optionFrom(e.target)&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&this._setActive(t,!1)},this._onInput=e=>{!this.hasAttribute(`filter`)||e.target!==this._input()||(this._applyFilter(),this.refresh())}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousedown`,this._onMouseDown),this.addEventListener(`mousemove`,this._onMouseMove),this.addEventListener(`input`,this._onInput),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}disconnectedCallback(){this._teardown()}attributeChangedCallback(){this.isConnected&&(this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh())}get filter(){return this.hasAttribute(`filter`)}set filter(e){this.toggleAttribute(`filter`,!!e)}get highlight(){return this.getAttribute(`highlight`)!==`false`}set highlight(e){this.setAttribute(`highlight`,e?`true`:`false`)}get emptyText(){return this.getAttribute(`empty-text`)??ce}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){let e=this._input(),t=e?e.value:``,n=t!==this._lastQuery;this._lastQuery=t;let r=this._visibleOptions(),i=n?null:r.find(e=>e.id===this._activeId);this._setActive(i??r[0]??null,n)}_input(){return this.querySelector(`[role="combobox"]`)}_optionFrom(e){let t=e?.closest?.(se);return t&&this.contains(t)&&!this._isHidden(t)?t:null}_isHidden(e){return e.hidden||!!e.closest(`[role="group"]`)?.hidden}_visibleOptions(){return[...this.querySelectorAll(se)].filter(e=>!this._isHidden(e))}_setActive(e,t){this._activeId=e?e.id:null;for(let t of this.querySelectorAll(se))t.setAttribute(`aria-selected`,t===e?`true`:`false`);let n=this._input();n&&(e?n.setAttribute(`aria-activedescendant`,e.id):n.removeAttribute(`aria-activedescendant`)),e&&t&&e.scrollIntoView({block:`nearest`})}_move(e){let t=this._visibleOptions();if(!t.length)return;let n=t.findIndex(e=>e.id===this._activeId),r=n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;this._setActive(t[r],!0)}_handleKeyDown(e){if(e.target===this._input()){if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._move(e.key===`ArrowDown`?1:-1);else if(e.key===`Enter`&&!e.isComposing){let t=this._visibleOptions().find(e=>e.id===this._activeId);if(!t)return;e.preventDefault(),this._select(t)}}}_select(e){this.dispatchEvent(new CustomEvent(`wui-command-palette:select`,{bubbles:!0,cancelable:!0,detail:{key:e.dataset.key??null,groupKey:e.dataset.groupKey??null,id:e.id}}))&&e.dataset.href&&this._navigate(e.dataset.href)}_navigate(e){window.location.assign(e)}_applyFilter(){let e=this._input(),t=(e?e.value:``).trim(),n=t.toLowerCase(),r=this.highlight,i=0;for(let e of this.querySelectorAll(se)){let a=e.querySelector(`.wui-cmd-item-label`),o=e.dataset.label??a?.textContent??``,s=!n||o.toLowerCase().includes(n);e.hidden=!s,s&&i++,a&&(a.innerHTML=oe(o,r?t:``).map(e=>e.match?`<mark class="wui-cmd-mark">${b(e.text)}</mark>`:b(e.text)).join(``))}for(let e of this.querySelectorAll(`[role="group"]`))e.hidden=![...e.querySelectorAll(se)].some(e=>!e.hidden);let a=this.querySelector(`[role="listbox"]`);a&&(a.hidden=i===0);let o=this.querySelector(`.wui-cmd-empty`);o&&(o.textContent=n&&i===0?this.emptyText:``)}_teardown(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousedown`,this._onMouseDown),this.removeEventListener(`mousemove`,this._onMouseMove),this.removeEventListener(`input`,this._onInput)}},ue={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-surface":`#FFFFFF`,"--wui-radius-lg":`14px`,"--wui-shadow-overlay-lg":`0 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-fixed":`1030`},C=e=>`var(${e}, ${ue[e]})`,de=`
|
|
22
|
+
</div>`,this._rendered=!0,g(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=>ae(e.label).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 “${b(e.value)}”`;return`<button type="button" role="option" id="${S(n)}" class="search-select-option search-select-option-custom" data-value="${S(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="${S(n)}" class="search-select-option${r?` selected`:``}" data-value="${S(e.value)}" aria-selected="${r}">${x(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 t=()=>f(e.control,e.menu,{matchWidth:!0}),n=()=>this._optionEls().filter(e=>!e.hidden),r=t=>{let r=n();this._active=t;for(let e of this._optionEls())e.classList.remove(`is-active`);t>=0&&r[t]?(r[t].classList.add(`is-active`),r[t].scrollIntoView({block:`nearest`}),e.control.setAttribute(`aria-activedescendant`,r[t].id)):e.control.removeAttribute(`aria-activedescendant`)},i=()=>!e.menu.hidden,a=()=>{e.menu.hidden=!1,e.control.setAttribute(`aria-expanded`,`true`),e.control.classList.add(`open`),t(),this._renderOptions()},o=()=>{e.menu.hidden=!0,e.control.setAttribute(`aria-expanded`,`false`),e.control.classList.remove(`open`),r(-1),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,this._syncInput()},s=t=>{let n=t.dataset.custom===`true`;this._value=t.dataset.value,this._label=n?t.dataset.value:ae(t.innerHTML),g(this,this._value),e.input.value=this._label,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:n}})),o(),e.input.focus()},c=t=>{this._value=t,this._label=t,g(this,t),e.input.value=t,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!0}})),o()},l=()=>{let t=e.input.value;if(e.clear&&(e.clear.hidden=!t),i()||a(),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=ee({getVisibleOptions:n,getActive:()=>this._active,setActive:e=>r(e),onEnter:(t,n)=>{if(n[this._active])s(n[this._active]);else if(this._allowCustom){let t=e.input.value.trim();t&&!this._matchesKnownOption(t)&&c(t)}},onEscape:()=>{this._navHandler.clearTypeahead(),o()}});let u=e=>{let t=e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`;if(e.key===`ArrowDown`){e.preventDefault(),i()||a();let t=n();r(Math.min(this._active+1,t.length-1));return}else if(e.key===`ArrowUp`){e.preventDefault(),r(Math.max(this._active-1,0));return}else if((e.key===`Home`||e.key===`End`||e.key===`PageDown`||e.key===`PageUp`)&&(!i()||t))return;else if(e.key.length===1&&(e.ctrlKey||e.metaKey||e.altKey||!i()||e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`)&&(!i()||e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`))return;this._navHandler.handler(e)};e.input.addEventListener(`focus`,()=>a()),e.input.addEventListener(`input`,l),e.input.addEventListener(`keydown`,u),e.menu.addEventListener(`keydown`,u),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)||c(n)}),e.optionsWrap.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&s(t)}),e.optionsWrap.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&r(this._optionEls().indexOf(t))}),e.optionsWrap.addEventListener(`mouseleave`,()=>r(-1)),e.clear?.addEventListener(`click`,()=>{this._value=``,this._label=``,g(this,``),e.input.value=``,e.clear.hidden=!0,this._renderOptions(``),this.dispatchEvent(new Event(`change`,{bubbles:!0})),e.input.focus()}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{i()&&!this.contains(e.target)&&o()},document.addEventListener(`click`,this._onDocClick),p(this,()=>{i()&&t()})},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),m(this),clearTimeout(this._timer),this._navHandler?.teardown()}disconnectedCallback(){this._teardown()}},S=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`),ae=e=>String(e??``).replace(/<[^>]*>/g,``);function oe(e,t){let n=String(e??``),r=String(t??``).trim();if(!r||!n)return[{text:n,match:!1}];let i=n.toLowerCase(),a=r.toLowerCase();if(i.length!==n.length)return[{text:n,match:!1}];let o=[],s=0,c=i.indexOf(a,s);for(;c!==-1;)c>s&&o.push({text:n.slice(s,c),match:!1}),o.push({text:n.slice(c,c+a.length),match:!0}),s=c+a.length,c=i.indexOf(a,s);return s<n.length&&o.push({text:n.slice(s),match:!1}),o}var se=`[role="option"]`,ce=`No results`,le=class extends i{static get observedAttributes(){return[`filter`,`highlight`,`empty-text`]}constructor(){super(),this._activeId=null,this._lastQuery=null,this._lastIds=null,this._userChose=!1,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=this._optionFrom(e.target);t&&this._select(t)},this._onMouseDown=e=>{this._optionFrom(e.target)&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&(this._userChose=!0,this._setActive(t,!1))},this._onInput=e=>{!this.hasAttribute(`filter`)||e.target!==this._input()||(this._applyFilter(),this.refresh())}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousedown`,this._onMouseDown),this.addEventListener(`mousemove`,this._onMouseMove),this.addEventListener(`input`,this._onInput),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}disconnectedCallback(){this._teardown()}attributeChangedCallback(){this.isConnected&&(this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh())}get filter(){return this.hasAttribute(`filter`)}set filter(e){this.toggleAttribute(`filter`,!!e)}get highlight(){return this.getAttribute(`highlight`)!==`false`}set highlight(e){this.setAttribute(`highlight`,e?`true`:`false`)}get emptyText(){return this.getAttribute(`empty-text`)??ce}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){let e=this._input(),t=e?e.value:``,n=t!==this._lastQuery;this._lastQuery=t;let r=this._visibleOptions(),i=r.map(e=>e.id).join(`
|
|
23
|
+
`),a=i!==this._lastIds;this._lastIds=i;let o=!n&&(this._userChose||!a)?r.find(e=>e.id===this._activeId):null;o||(this._userChose=!1),this._setActive(o??r[0]??null,n)}_input(){return this.querySelector(`[role="combobox"]`)}_optionFrom(e){let t=e?.closest?.(se);return t&&this.contains(t)&&!this._isHidden(t)?t:null}_isHidden(e){return e.hidden||!!e.closest(`[role="group"]`)?.hidden}_visibleOptions(){return[...this.querySelectorAll(se)].filter(e=>!this._isHidden(e))}_setActive(e,t){this._activeId=e?e.id:null;for(let t of this.querySelectorAll(se))t.setAttribute(`aria-selected`,t===e?`true`:`false`);let n=this._input();n&&(e?n.setAttribute(`aria-activedescendant`,e.id):n.removeAttribute(`aria-activedescendant`)),e&&t&&e.scrollIntoView({block:`nearest`})}_move(e){let t=this._visibleOptions();if(!t.length)return;let n=t.findIndex(e=>e.id===this._activeId),r=n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;this._userChose=!0,this._setActive(t[r],!0)}_handleKeyDown(e){if(e.target===this._input()){if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._move(e.key===`ArrowDown`?1:-1);else if(e.key===`Enter`&&!e.isComposing){let t=this._visibleOptions().find(e=>e.id===this._activeId);if(!t)return;e.preventDefault(),this._select(t)}}}_select(e){this.dispatchEvent(new CustomEvent(`wui-command-palette:select`,{bubbles:!0,cancelable:!0,detail:{key:e.dataset.key??null,groupKey:e.dataset.groupKey??null,id:e.id}}))&&e.dataset.href&&this._navigate(e.dataset.href)}_navigate(e){window.location.assign(e)}_applyFilter(){let e=this._input(),t=(e?e.value:``).trim(),n=t.toLowerCase(),r=this.highlight,i=0;for(let e of this.querySelectorAll(se)){let a=e.querySelector(`.wui-cmd-item-label`),o=e.dataset.label??a?.textContent??``,s=!n||o.toLowerCase().includes(n);e.hidden=!s,s&&i++,a&&(a.innerHTML=oe(o,r?t:``).map(e=>e.match?`<mark class="wui-cmd-mark">${b(e.text)}</mark>`:b(e.text)).join(``))}for(let e of this.querySelectorAll(`[role="group"]`))e.hidden=![...e.querySelectorAll(se)].some(e=>!e.hidden);let a=this.querySelector(`[role="listbox"]`);a&&(a.hidden=i===0);let o=this.querySelector(`.wui-cmd-empty`);o&&(o.textContent=n&&i===0?this.emptyText:``)}_teardown(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousedown`,this._onMouseDown),this.removeEventListener(`mousemove`,this._onMouseMove),this.removeEventListener(`input`,this._onInput)}},ue={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-surface":`#FFFFFF`,"--wui-radius-lg":`14px`,"--wui-shadow-overlay-lg":`0 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-fixed":`1030`},C=e=>`var(${e}, ${ue[e]})`,de=`
|
|
23
24
|
:host {
|
|
24
25
|
all: initial;
|
|
25
26
|
position: fixed;
|
|
@@ -259,10 +260,10 @@ var WeborityUiElements=(function(e){Object.defineProperty(e,Symbol.toStringTag,{
|
|
|
259
260
|
<div class="datepicker-cells">${r}</div>`}_yearsHtml(){let e=T(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`
|
|
260
261
|
<div class="datepicker-head">
|
|
261
262
|
<button type="button" class="datepicker-nav-btn" data-nav-decade="-1" aria-label="Previous decade">${v(`chevron-left`)}</button>
|
|
262
|
-
<span class="datepicker-month">${r+1}
|
|
263
|
+
<span class="datepicker-month">${r+1} to ${r+10}</span>
|
|
263
264
|
<button type="button" class="datepicker-nav-btn" data-nav-decade="1" aria-label="Next decade">${v(`chevron-right`)}</button>
|
|
264
265
|
</div>
|
|
265
|
-
<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){f(e,t,{clampHeight:!0})}_setFocus(e,t,n,r){let{y:i,m:a}=D(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="${Ae(i,a,n)}"]`)?.focus()}_onKey(e){if(this._mode!==`days`){e.key===`Escape`&&this._close();return}let t=this._focus||T(this._value)||{y:this._viewY,m:this._viewM,d:1},n=(n,r)=>{e.preventDefault();let i=new Date(t.y,t.m,t.d+n);this._setFocus(i.getFullYear(),i.getMonth(),i.getDate(),r)};switch(e.key){case`ArrowLeft`:return n(-1,`slide-prev`);case`ArrowRight`:return n(1,`slide-next`);case`ArrowUp`:return n(-7,`slide-prev`);case`ArrowDown`:return n(7,`slide-next`);case`Home`:return n(-((new Date(t.y,t.m,t.d).getDay()-this._firstDay()+7)%7),`slide-prev`);case`End`:return n(6-(new Date(t.y,t.m,t.d).getDay()-this._firstDay()+7)%7,`slide-next`);case`PageUp`:{e.preventDefault();let n=D(t.y,t.m-(e.shiftKey?12:1));return this._setFocus(n.y,n.m,Math.min(t.d,E(n.y,n.m)),`slide-prev`)}case`PageDown`:{e.preventDefault();let n=D(t.y,t.m+(e.shiftKey?12:1));return this._setFocus(n.y,n.m,Math.min(t.d,E(n.y,n.m)),`slide-next`)}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(t.y,t.m,t.d)||(this.value=Ae(t.y,t.m,t.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return;case`Escape`:return this._close();default:}}_wire(){this._teardown();let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`.datepicker-pop`),n=this.querySelector(`.datepicker`);if(!e||!t)return;let r=()=>!t.hidden;this._open=()=>{let r=new Date,i=T(this._value);(i||!this._viewNavigated)&&(this._viewY=r.getFullYear(),this._viewM=r.getMonth()),this._mode=`days`;let a=r.getFullYear()===this._viewY&&r.getMonth()===this._viewM,o=i&&i.y===this._viewY&&i.m===this._viewM;this._focus=o?i:{y:this._viewY,m:this._viewM,d:a?r.getDate():1},this._renderView(),t.hidden=!1,n?.classList.add(`open`),this._position(e,t),e.setAttribute(`aria-expanded`,`true`),t.querySelector(`[tabindex="0"]`)?.focus()},this._close=()=>{t.hidden=!0,n?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),e.focus()},e.addEventListener(`click`,()=>r()?this._close():this._open()),t.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=D(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=Ae(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=>{r()&&this._onKey(e)},t.addEventListener(`keydown`,this._onKeyBound),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,r()&&!t&&!this.contains(e.target)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{r()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),p(this,()=>{r()&&this._position(e,t)})},this._bindGlobal(),this._syncFormValue()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),m(this)}disconnectedCallback(){this._teardown()}},Ne=class extends i{static formAssociated=!0;static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){let e=Number.parseInt(this.getAttribute(`first-day`)??``,10);return Number.isInteger(e)&&e>=0&&e<=6?e:0}_label(){let e=this.getAttribute(`placeholder`)||`Start
|
|
266
|
+
<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){f(e,t,{clampHeight:!0})}_setFocus(e,t,n,r){let{y:i,m:a}=D(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="${Ae(i,a,n)}"]`)?.focus()}_onKey(e){if(this._mode!==`days`){e.key===`Escape`&&this._close();return}let t=this._focus||T(this._value)||{y:this._viewY,m:this._viewM,d:1},n=(n,r)=>{e.preventDefault();let i=new Date(t.y,t.m,t.d+n);this._setFocus(i.getFullYear(),i.getMonth(),i.getDate(),r)};switch(e.key){case`ArrowLeft`:return n(-1,`slide-prev`);case`ArrowRight`:return n(1,`slide-next`);case`ArrowUp`:return n(-7,`slide-prev`);case`ArrowDown`:return n(7,`slide-next`);case`Home`:return n(-((new Date(t.y,t.m,t.d).getDay()-this._firstDay()+7)%7),`slide-prev`);case`End`:return n(6-(new Date(t.y,t.m,t.d).getDay()-this._firstDay()+7)%7,`slide-next`);case`PageUp`:{e.preventDefault();let n=D(t.y,t.m-(e.shiftKey?12:1));return this._setFocus(n.y,n.m,Math.min(t.d,E(n.y,n.m)),`slide-prev`)}case`PageDown`:{e.preventDefault();let n=D(t.y,t.m+(e.shiftKey?12:1));return this._setFocus(n.y,n.m,Math.min(t.d,E(n.y,n.m)),`slide-next`)}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(t.y,t.m,t.d)||(this.value=Ae(t.y,t.m,t.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return;case`Escape`:return this._close();default:}}_wire(){this._teardown();let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`.datepicker-pop`),n=this.querySelector(`.datepicker`);if(!e||!t)return;let r=()=>!t.hidden;this._open=()=>{let r=new Date,i=T(this._value);(i||!this._viewNavigated)&&(this._viewY=r.getFullYear(),this._viewM=r.getMonth()),this._mode=`days`;let a=r.getFullYear()===this._viewY&&r.getMonth()===this._viewM,o=i&&i.y===this._viewY&&i.m===this._viewM;this._focus=o?i:{y:this._viewY,m:this._viewM,d:a?r.getDate():1},this._renderView(),t.hidden=!1,n?.classList.add(`open`),this._position(e,t),e.setAttribute(`aria-expanded`,`true`),t.querySelector(`[tabindex="0"]`)?.focus()},this._close=()=>{t.hidden=!0,n?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),e.focus()},e.addEventListener(`click`,()=>r()?this._close():this._open()),t.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=D(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=Ae(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=>{r()&&this._onKey(e)},t.addEventListener(`keydown`,this._onKeyBound),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,r()&&!t&&!this.contains(e.target)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{r()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),p(this,()=>{r()&&this._position(e,t)})},this._bindGlobal(),this._syncFormValue()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),m(this)}disconnectedCallback(){this._teardown()}},Ne=class extends i{static formAssociated=!0;static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){let e=Number.parseInt(this.getAttribute(`first-day`)??``,10);return Number.isInteger(e)&&e>=0&&e<=6?e:0}_label(){let e=this.getAttribute(`placeholder`)||`Start to End`;return!this._start&&!this._end?{text:e,empty:!0}:{text:`${je(this._start)||`Start`} to ${je(this._end)||`End`}`,empty:!1}}render(){this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=T(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` input-sm`:t===`lg`?` input-lg`:``,{text:r,empty:i}=this._label(),a=this.getAttribute(`aria-label`),o=this.getAttribute(`aria-describedby`);this.innerHTML=`
|
|
266
267
|
<div class="daterange">
|
|
267
268
|
<button type="button" class="input daterange-trigger${n}${i?``:` has-value`}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${a?` aria-label="${b(a)}"`:``}${o?` aria-describedby="${b(o)}"`:``}>
|
|
268
269
|
<span data-range-label class="${i?`search-select-placeholder`:``}">${b(r)}</span>
|
|
@@ -286,7 +287,7 @@ var WeborityUiElements=(function(e){Object.defineProperty(e,Symbol.toStringTag,{
|
|
|
286
287
|
<div class="datepicker-foot">
|
|
287
288
|
<span class="daterange-hint" data-range-hint></span>
|
|
288
289
|
<button type="button" class="datepicker-link" data-clear>Clear</button>
|
|
289
|
-
</div>`,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)}let i=e.querySelector(`[data-range-hint]`);i&&(i.textContent=this._start?this._end?`${je(this._start)}
|
|
290
|
+
</div>`,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)}let i=e.querySelector(`[data-range-hint]`);i&&(i.textContent=this._start?this._end?`${je(this._start)} to ${je(this._end)}`:`Pick an end date`:`Pick a start date`)}_position(e,t){f(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()}_wire(){this._teardown();let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`.daterange-pop`),n=this.querySelector(`.daterange`);if(!e||!t)return;let r=()=>!t.hidden;this._open=()=>{let r=T(this._start);if(r)this._viewY=r.y,this._viewM=r.m;else{let e=new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._renderView(),t.hidden=!1,n?.classList.add(`open`),this._position(e,t),e.setAttribute(`aria-expanded`,`true`)},this._close=()=>{t.hidden=!0,this._hover=``,n?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`)},e.addEventListener(`click`,()=>r()?this._close():this._open()),t.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(`.datepicker-day[data-iso]`);n&&!n.disabled&&this._pick(n.dataset.iso)}),t.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,r()&&!t&&!this.contains(e.target)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{r()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),p(this,()=>{r()&&this._position(e,t)})},this._bindGlobal(),this._syncMirrors()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),m(this)}disconnectedCallback(){this._teardown()}},Pe=class extends i{static get observedAttributes(){return[`static`,`max-scale`,`radius`]}constructor(){super(),this._pointerMoveListener=null,this._pointerLeaveListener=null,this._frame=0,this._pointerX=0}connectedCallback(){this._wire()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){e===`static`&&this.isConnected&&this._wire()}_maxScale(){return Fe(this.getAttribute(`max-scale`),1.6)}_radius(){return Fe(this.getAttribute(`radius`),100)}_magnifyEnabled(){return!(this.hasAttribute(`static`)||typeof matchMedia==`function`&&(matchMedia(`(pointer: coarse)`).matches||matchMedia(`(prefers-reduced-motion: reduce)`).matches))}_applyMagnification(){this._frame=0;let e=this._maxScale(),t=this._radius();for(let n of this.querySelectorAll(`.dock-item`)){let r=n.getBoundingClientRect(),i=Math.abs(this._pointerX-(r.left+r.width/2)),a=Math.max(0,1-i/t),o=1+(e-1)*a;n.style.setProperty(`--wui-dock-mag`,o.toFixed(3))}}_resetMagnification(){this._frame&&=(cancelAnimationFrame(this._frame),0);for(let e of this.querySelectorAll(`.dock-item`))e.style.removeProperty(`--wui-dock-mag`)}_wire(){this._teardown(),this._magnifyEnabled()&&(this._pointerMoveListener=e=>{this._pointerX=e.clientX,this._frame||=requestAnimationFrame(()=>this._applyMagnification())},this._pointerLeaveListener=()=>this._resetMagnification(),this.addEventListener(`pointermove`,this._pointerMoveListener),this.addEventListener(`pointerleave`,this._pointerLeaveListener))}_teardown(){this._pointerMoveListener&&=(this.removeEventListener(`pointermove`,this._pointerMoveListener),null),this._pointerLeaveListener&&=(this.removeEventListener(`pointerleave`,this._pointerLeaveListener),null),this._resetMagnification()}},Fe=(e,t)=>{let n=Number.parseFloat(e);return Number.isFinite(n)?n:t},Ie={enter:`Enter`,comma:`,`,space:` `,tab:`Tab`},Le={enter:`
|
|
290
291
|
`,comma:`,`,space:` `,tab:` `},Re=e=>Ie[e],ze=e=>Le[e];function Be(e,t){let n=[String(e??``)];for(let e of t)n=n.flatMap(t=>t.split(e));return n.map(e=>e.trim()).filter(Boolean)}var Ve=(e,t)=>t.some(t=>String(e??``).includes(t)),He=class extends i{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`placeholder`,`search-placeholder`,`searchable`,`disabled`,`icon`,`size`,`collapse-chips`,`aria-label`,`aria-invalid`,`allow-custom`,`custom-pattern`,`custom-invalid-message`]}constructor(){super(),this._values=[],this._optionsProp=null,this._active=-1,this._typeahead=``,this._typeaheadTimer=null,this._customError=``;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){if(!this._valuesInit&&!this._optionsProp&&!this._values.length){let e=this.getAttribute(`value`);if(e!=null&&e!==``)this._values=e.split(`,`).map(e=>e.trim()).filter(Boolean);else{let e=[...this.querySelectorAll(`:scope > wui-option[selected]`)].map(e=>e.getAttribute(`value`)??e.textContent.trim());e.length&&(this._values=e.map(String))}}this._valuesInit=!0,this._defaultCaptured||=(this._defaultValues=this._values.slice(),!0),this.render();return}this._bindGlobal?.()}formResetCallback(){this.values=(this._defaultValues||[]).slice();let e=this.querySelector(`[data-input]`);e&&(e.value=``),this._setCustomError(``)}attributeChangedCallback(e){if(e===`aria-invalid`){this._syncInvalid();return}e===`custom-pattern`||e===`custom-invalid-message`||this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._customError?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get values(){return this._values.slice()}set values(e){this._values=Array.isArray(e)?e.map(String):[],g(this,this._values.join(`,`)),this._rendered&&(this._renderControl(),this._renderOptions(this._query()))}set options(e){if(this._optionsProp=Array.isArray(e)?e:null,this._rendered&&this._allowCustom){this._renderControl(),this._renderOptions(this._query());return}this.isConnected&&this.render()}get options(){return this._readOptions()}get validateCustom(){return this._validateCustom??null}set validateCustom(e){this._validateCustom=typeof e==`function`?e:null}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_query(){let e=this.querySelector(this._allowCustom?`[data-input]`:`.search-select-input`);return e?e.value:``}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t={value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[y]:!0,selected:e.hasAttribute(`selected`)};for(let[n,r]of We){let i=e.getAttribute(n);i&&(t[r]=i)}return e.hasAttribute(`disabled`)&&(t.disabled=!0),t}))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_labelFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?t.label:e}_labelHtmlFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?x(t):b(e)}render(){this._snapshotDeclared();let e=this._allowCustom,t=this.hasAttribute(`searchable`)&&!e,n=this.getAttribute(`search-placeholder`)||`Search…`,r=this.getAttribute(`icon`),i=this.getAttribute(`size`),a=i===`sm`?` search-select-sm`:i===`lg`?` search-select-lg`:``;g(this,this._values.join(`,`)),this.id||=`wui-multiselect-${Math.random().toString(36).slice(2,9)}`;let o=`${this.id}-listbox`;this._listboxId=o;let s=this.hasAttribute(`disabled`);if(e){let e=`${this.id}-custom-error`;this.innerHTML=`
|
|
291
292
|
<div class="search-select${a}">
|
|
292
293
|
<div class="input search-select-control search-select-multi"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${s?` aria-disabled="true"`:``}>
|
|
@@ -401,9 +402,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
401
402
|
aria-label="${Xu(this.getAttribute(`aria-label`)||`Value`)}"
|
|
402
403
|
></button>
|
|
403
404
|
`}
|
|
404
|
-
${this.hasAttribute(`show-value`)?n?`<span class="slider-value">${this._formatValue(this._start)}
|
|
405
|
+
${this.hasAttribute(`show-value`)?n?`<span class="slider-value">${this._formatValue(this._start)} to ${this._formatValue(this._end)}</span>`:`<span class="slider-value">${this._formatValue(this._value)}</span>`:``}
|
|
405
406
|
</div>
|
|
406
|
-
`,this._rendered=!0,this._placeParts(),this._syncMirrors(),this._wire()}_formatValue(e){return`${e}${this.getAttribute(`unit`)||``}`}_placeParts(){let e=this._min(),t=this._max(),n=n=>t===e?0:(n-e)/(t-e),r=this._isRange(),i=r?n(this._start):0,a=n(r?this._end:this._value),o=this.querySelector(`.slider-fill`);o&&(o.style.left=`${i*100}%`,o.style.right=`${100-a*100}%`,r&&o.style.setProperty(`--wui-fill-start`,String(i)),o.style.setProperty(`--wui-fill-end`,String(a)));let s=(e,t)=>{e&&(e.style.left=`${t*100}%`,e.style.setProperty(`--wui-t`,String(t)))};r?(s(this.querySelector(`[data-thumb="start"]`),i),s(this.querySelector(`[data-thumb="end"]`),a)):s(this.querySelector(`.slider-thumb`),a)}_syncValue(){if(this._rendered)if(this._placeParts(),this._isRange()){let e=this.querySelector(`[data-thumb="start"]`),t=this.querySelector(`[data-thumb="end"]`);e&&(e.setAttribute(`aria-valuenow`,String(this._start)),e.setAttribute(`aria-valuetext`,this._formatValue(this._start))),t&&(t.setAttribute(`aria-valuenow`,String(this._end)),t.setAttribute(`aria-valuetext`,this._formatValue(this._end)));let n=this.querySelector(`.slider-value`);n&&(n.textContent=`${this._formatValue(this._start)}
|
|
407
|
+
`,this._rendered=!0,this._placeParts(),this._syncMirrors(),this._wire()}_formatValue(e){return`${e}${this.getAttribute(`unit`)||``}`}_placeParts(){let e=this._min(),t=this._max(),n=n=>t===e?0:(n-e)/(t-e),r=this._isRange(),i=r?n(this._start):0,a=n(r?this._end:this._value),o=this.querySelector(`.slider-fill`);o&&(o.style.left=`${i*100}%`,o.style.right=`${100-a*100}%`,r&&o.style.setProperty(`--wui-fill-start`,String(i)),o.style.setProperty(`--wui-fill-end`,String(a)));let s=(e,t)=>{e&&(e.style.left=`${t*100}%`,e.style.setProperty(`--wui-t`,String(t)))};r?(s(this.querySelector(`[data-thumb="start"]`),i),s(this.querySelector(`[data-thumb="end"]`),a)):s(this.querySelector(`.slider-thumb`),a)}_syncValue(){if(this._rendered)if(this._placeParts(),this._isRange()){let e=this.querySelector(`[data-thumb="start"]`),t=this.querySelector(`[data-thumb="end"]`);e&&(e.setAttribute(`aria-valuenow`,String(this._start)),e.setAttribute(`aria-valuetext`,this._formatValue(this._start))),t&&(t.setAttribute(`aria-valuenow`,String(this._end)),t.setAttribute(`aria-valuetext`,this._formatValue(this._end)));let n=this.querySelector(`.slider-value`);n&&(n.textContent=`${this._formatValue(this._start)} to ${this._formatValue(this._end)}`)}else{let e=this.querySelector(`.slider-thumb`);e&&(e.setAttribute(`aria-valuenow`,String(this._value)),e.setAttribute(`aria-valuetext`,this._formatValue(this._value)));let t=this.querySelector(`.slider-value`);t&&(t.textContent=this._formatValue(this._value))}}_syncMirrors(){this._isRange()?this._syncRangeMirrors():this._syncSingleMirror()}_syncSingleMirror(){this.getAttribute(`name`)&&g(this,String(this._value))}_syncRangeMirrors(){let e=this.getAttribute(`start-name`)||this.getAttribute(`name`),t=this.getAttribute(`end-name`);this._mirrorRange(`start`,e,this._start),this._mirrorRange(`end`,t,this._end)}_mirrorRange(e,t,n){if(!t)return;let r=this.querySelector(`input[type="hidden"][data-slider-mirror="${e}"]`);r||(r=document.createElement(`input`),r.type=`hidden`,r.setAttribute(`data-slider-mirror`,e),this.appendChild(r)),r.name=t,r.value=String(n),r.disabled=this.hasAttribute(`disabled`)}_valueAtPosition(e){let t=this.querySelector(`.slider-track`);if(!t)return this._min();let n=t.getBoundingClientRect(),r=this.querySelector(`.slider-thumb`),i=r?r.offsetWidth/2:0,a=n.width-i*2,o=a>0?Math.max(0,Math.min(1,(e-n.left-i)/a)):0,s=this._min()+o*(this._max()-this._min());return this._snapToStep(s)}_nearestThumb(e){return Math.abs(e-this._start)<=Math.abs(e-this._end)?`start`:`end`}_wire(){if(this._teardown(),this.hasAttribute(`disabled`))return;let e=this.querySelectorAll(`.slider-thumb`),t=this.querySelector(`.slider-track`),n=this._isRange();this._pointerDownListener=e=>{if(this.hasAttribute(`disabled`))return;let t=e.target.closest(`.slider-thumb`);t&&(e.preventDefault(),this._isDragging=!0,this._dragThumb=t.getAttribute(`data-thumb`),document.addEventListener(`pointermove`,this._pointerMoveListener),document.addEventListener(`pointerup`,this._pointerUpListener),document.addEventListener(`pointercancel`,this._pointerUpListener))},this._pointerMoveListener=e=>{if(!this._isDragging)return;e.preventDefault();let t=this._valueAtPosition(e.clientX);if(this._dragThumb===`single`)this._value=this._clamp(t),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{value:this._value}}));else if(this._dragThumb===`start`){let e=Math.min(t,this._end);this._start=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}else if(this._dragThumb===`end`){let e=Math.max(t,this._start);this._end=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}},this._pointerUpListener=()=>{this._isDragging&&(this._isDragging=!1,this._dragThumb=null,document.removeEventListener(`pointermove`,this._pointerMoveListener),document.removeEventListener(`pointerup`,this._pointerUpListener),document.removeEventListener(`pointercancel`,this._pointerUpListener),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},this._thumbKeyListener=e=>{let t=e.currentTarget;if(this.hasAttribute(`disabled`))return;let n=this._step(),r=n*10,i=null,a=t.getAttribute(`data-thumb`),o=a===`end`?this._end:a===`start`?this._start:this._value;e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),i=o-n):e.key===`ArrowRight`||e.key===`ArrowUp`?(e.preventDefault(),i=o+n):e.key===`PageDown`?(e.preventDefault(),i=o-r):e.key===`PageUp`?(e.preventDefault(),i=o+r):e.key===`Home`?(e.preventDefault(),i=this._min()):e.key===`End`&&(e.preventDefault(),i=this._max()),i!=null&&(i=this._clamp(i),a===`single`?this._value=i:a===`start`?this._start=Math.min(i,this._end):a===`end`&&(this._end=Math.max(i,this._start)),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},this._trackClickListener=e=>{if(this.hasAttribute(`disabled`))return;let t=this._valueAtPosition(e.clientX);n?this._nearestThumb(t)===`start`?this._start=Math.min(this._clamp(t),this._end):this._end=Math.max(this._clamp(t),this._start):this._value=this._clamp(t),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))},e.forEach(e=>{e.addEventListener(`pointerdown`,this._pointerDownListener),e.addEventListener(`keydown`,this._thumbKeyListener)}),t?.addEventListener(`click`,this._trackClickListener)}_teardown(){for(let e of this.querySelectorAll(`.slider-thumb`))e.removeEventListener(`pointerdown`,this._pointerDownListener),e.removeEventListener(`keydown`,this._thumbKeyListener);document.removeEventListener(`pointermove`,this._pointerMoveListener),document.removeEventListener(`pointerup`,this._pointerUpListener),document.removeEventListener(`pointercancel`,this._pointerUpListener),this._isDragging=!1,this._dragThumb=null,this.querySelector(`.slider-track`)?.removeEventListener(`click`,this._trackClickListener)}disconnectedCallback(){this._teardown()}},Y=(e,t)=>{let n=Number.parseFloat(e);return Number.isFinite(n)?n:t},Xu=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`),Zu=class extends i{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Add tags`}static get observedAttributes(){return[`placeholder`,`disabled`,`size`,`max-tags`,`aria-label`,`separators`,`allow-duplicates`,`aria-invalid`]}constructor(){super(),this._values=[],this._draftText=``;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){if(!this._valuesInit&&!this._values.length){let e=this.getAttribute(`value`);if(e!=null&&e!==``)this._values=e.split(`,`).map(e=>e.trim()).filter(Boolean);else{let e=[...this.querySelectorAll(`:scope > wui-tag`)].map(e=>e.textContent.trim());e.length&&(this._values=e.map(String))}}this._valuesInit=!0,this._defaultCaptured||=(this._defaultValues=this._values.slice(),!0),this.render();return}this._wire()}formResetCallback(){this.values=(this._defaultValues||[]).slice(),this._draftText=``;let e=this.querySelector(`[data-input]`);e&&(e.value=``)}attributeChangedCallback(e){if(e===`aria-invalid`){this._syncInvalid();return}if(this._rendered){if(e===`separators`||e===`allow-duplicates`){this._wire();return}this.render()}}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get values(){return this._values.slice()}set values(e){this._values=Array.isArray(e)?e.map(String):[],g(this,this._values.join(`,`)),this._rendered&&this._renderControl()}render(){let e=this.getAttribute(`size`),t=e===`sm`?` search-select-sm`:e===`lg`?` search-select-lg`:``;g(this,this._values.join(`,`)),this.innerHTML=`
|
|
407
408
|
<div class="search-select${t}">
|
|
408
409
|
<div class="input search-select-control search-select-multi"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` aria-disabled="true"`:``}>
|
|
409
410
|
<div class="ms-chips" data-chips><input type="text" class="ms-input" data-input aria-label="${$u(this._accessibleName())}" placeholder="${$u(this.getAttribute(`placeholder`)||`Add…`)}" autocomplete="off"${this.hasAttribute(`disabled`)?` disabled`:``}/></div>
|
|
@@ -415,4 +416,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
415
416
|
${v(`clock`)}
|
|
416
417
|
</button>
|
|
417
418
|
<div class="timepicker-pop" role="listbox" tabindex="-1" hidden></div>
|
|
418
|
-
</div>`,this._rendered=!0,g(this,this._value),this._wire()}_syncFormValue(){g(this,this._value)}_syncTrigger(){let e=this.querySelector(`.timepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!t)return;let n=nd(this._value),r=this.getAttribute(`format`)||`24`;t.textContent=n?rd(n,r):this.getAttribute(`placeholder`)||`Select time`,t.classList.toggle(`timepicker-placeholder`,!n),e?.classList.toggle(`has-value`,!!n)}_buildTimes(){let e=Math.max(1,parseInt(this.getAttribute(`step`)||`30`,10)),t=this.getAttribute(`min`)||`00:00`,n=this.getAttribute(`max`)||`23:59`,r=nd(t)||{h:0,m:0},i=nd(n)||{h:23,m:59},a=[],o=r.h,s=r.m;for(s=Math.ceil(s/e)*e,s>=60&&(o+=1,s-=60);o<i.h||o===i.h&&s<=i.m;)a.push({h:o,m:s}),s+=e,s>=60&&(o+=1,s-=60);return a}_renderOptions(){let e=this.querySelector(`.timepicker-pop`);if(!e)return;let t=this.getAttribute(`format`)||`24`,n=this._buildTimes(),r=nd(this._value),i=this._focus,a=``;for(let e=0;e<n.length;e++){let o=n[e],s=td(o.h,o.m),c=r&&r.h===o.h&&r.m===o.m;a+=`<button type="button" class="timepicker-option${c?` is-selected`:``}" data-hm="${s}" role="option" tabindex="${i===e?`0`:`-1`}"${c?` aria-selected="true"`:``}>${rd(o,t)}</button>`}e.innerHTML=a,this._focusActive()}_focusActive(){let e=this.querySelector(`.timepicker-pop`),t=e?.querySelector(`[tabindex="0"]`)||e?.querySelector(`.is-selected`);t&&!e.hidden&&t.focus()}_position(e,t){f(e,t)}_onKey(e){let t=[...this.querySelector(`.timepicker-pop`).querySelectorAll(`.timepicker-option`)];switch(e.key){case`ArrowUp`:{e.preventDefault();let t=Math.max((this._focus??0)-1,0);this._focus=t,this._renderOptions();break}case`ArrowDown`:{e.preventDefault();let n=Math.min((this._focus??-1)+1,t.length-1);this._focus=n,this._renderOptions();break}case`Home`:if(e.preventDefault(),!t.length)return;this._focus=0,this._renderOptions();break;case`End`:if(e.preventDefault(),!t.length)return;this._focus=t.length-1,this._renderOptions();break;case`PageUp`:{if(e.preventDefault(),!t.length)return;let n=this._focus==null||this._focus<0?0:this._focus;this._focus=Math.max(n-8,0),this._renderOptions();break}case`PageDown`:{if(e.preventDefault(),!t.length)return;let n=this._focus==null||this._focus<0?0:this._focus;this._focus=Math.min(n+8,t.length-1),this._renderOptions();break}case`Enter`:case` `:e.preventDefault(),t[this._focus]&&(this.value=t[this._focus].dataset.hm,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());break;case`Escape`:this._close();break;default:if(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);let n=t.findIndex(e=>e.textContent.trim().toLowerCase().startsWith(this._typeahead));n>=0&&(this._focus=n,this._renderOptions())}}}_wire(){this._teardown();let e=this.querySelector(`.timepicker-trigger`),t=this.querySelector(`.timepicker-pop`),n=this.querySelector(`.timepicker`);if(!e||!t)return;let r=()=>!t.hidden;this._open=()=>{this._focus=null,this._renderOptions(),t.hidden=!1,n?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),this._position(e,t);let r=t.querySelector(`.is-selected`);r?this._focus=[...t.querySelectorAll(`.timepicker-option`)].indexOf(r):this._focus=0,this._renderOptions(),t.querySelector(`[tabindex="0"]`)?.focus()},this._close=()=>{t.hidden=!0,n?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,e.focus()},e.addEventListener(`click`,()=>r()?this._close():this._open()),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`)&&(e.preventDefault(),r()||this._open())}),t.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`.timepicker-option`);t&&!t.disabled&&(this.value=t.dataset.hm,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{r()&&this._onKey(e)},t.addEventListener(`keydown`,this._onKeyBound),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,r()&&!t&&!this.contains(e.target)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{r()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),p(this,()=>{r()&&this._position(e,t)})},this._bindGlobal(),this._syncFormValue()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),m(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``}disconnectedCallback(){this._teardown()}},ad=`wui-wizard-step`,od=class extends i{static get observedAttributes(){return[`active`,`variant`,`orientation`,`non-linear`,`hide-stepper`,`disabled`,`skippable`,`label`,`back-label`,`next-label`,`skip-label`,`finish-label`]}constructor(){super(),this._active=0,this._skipped=new Set,this._invalid=new Set,this._finished=!1,this._rendered=!1,this._reflecting=!1,this._beforeNext=null,this._header=null,this._footer=null,this._known=[],this._observer=null}get active(){return this._active}set active(e){let t=Number.parseInt(e,10);Number.isFinite(t)&&this._go(t,`set`)}get beforeNext(){return this._beforeNext}set beforeNext(e){this._beforeNext=typeof e==`function`?e:null}get _steps(){return[...this.querySelectorAll(`:scope > ${ad}`)]}refresh(){this._rendered&&this._renderChrome()}connectedCallback(){if(this._rendered)this._wire(),this._onStepsMutated();else{let e=Number.parseInt(this.getAttribute(`active`),10);this._active=Number.isFinite(e)&&e>=0?e:0,this.render()}}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){if(!(!this._rendered||this._reflecting)){if(e===`active`){let e=Number.parseInt(n,10);Number.isFinite(e)&&this._go(e,`set`);return}this._renderChrome()}}render(){let e=this._steps;this._header||(this._header=document.createElement(`nav`),this._header.className=`stepper wizard-stepper`,this._footer=document.createElement(`div`),this._footer.className=`form-actions wizard-footer form-actions-between`,e.length?(this.insertBefore(this._header,e[0]),e[e.length-1].after(this._footer)):(this.prepend(this._header),this.append(this._footer))),this._known=e,this._renderChrome(),this._rendered=!0,this._wire()}_renderChrome(){let e=this._reconcileSteps();this._placeChrome(e),this._clampActive(e),this._syncPanels(e),this._header.innerHTML=this._headerHtml(e),this._footer.innerHTML=this._footerHtml(e),this._header.hidden=this.hasAttribute(`hide-stepper`)}_clampActive(e){let t=Math.max(0,e.length-1);this._active>t&&(this._active=t),this._active<0&&(this._active=0)}_reconcileSteps(){let e=this._steps,t=this._known;if(this._known=e,sd(e,t))return e;let n=n=>new Set([...n].map(n=>e.indexOf(t[n])).filter(e=>e>=0));this._skipped=n(this._skipped),this._invalid=n(this._invalid);let r=t[this._active];if(!r)return e;let i=e.indexOf(r);if(i<0){let n=t=>e.includes(t),r=t.slice(this._active+1).find(n)??t.slice(0,this._active).reverse().find(n);i=r?e.indexOf(r):this._active}return i=Math.min(i,Math.max(0,e.length-1)),i!==this._active&&(this._active=i,this._reflectActive(i)),e}_placeChrome(e){if(!e.length)return;let t=e[e.length-1];this._header.nextElementSibling!==e[0]&&this.insertBefore(this._header,e[0]),this._footer.previousElementSibling!==t&&t.after(this._footer)}_onStepsMutated(){if(!this._rendered)return;let e=this._steps;(!e.length||this._header.nextElementSibling===e[0]&&this._footer.previousElementSibling===e[e.length-1])&&sd(e,this._known)||(this._renderChrome(),this._observer?.takeRecords())}_syncPanels(e){e.forEach((e,t)=>{let n=t===this._active;e.classList.add(`wizard-panel`),e.hidden=!n,e.setAttribute(`role`,`tabpanel`),e.setAttribute(`aria-hidden`,n?`false`:`true`)})}_stepStatus(e,t){return e.getAttribute(`status`)||(this._invalid.has(t)?`error`:this._finished?`done`:t===this._active?`active`:t<this._active?this._skipped.has(t)?`skipped`:`done`:`pending`)}_headerHtml(e){let t=this.getAttribute(`variant`)===`journey`,n=this.getAttribute(`variant`)===`icons`,r=this.getAttribute(`orientation`)===`vertical`;this._header.className=[`stepper`,`wizard-stepper`,t&&`stepper-journey`,n&&`stepper-icons`,r&&`stepper-vertical`].filter(Boolean).join(` `),this._header.setAttribute(`aria-label`,this.getAttribute(`label`)||`Progress`);let i=this.hasAttribute(`non-linear`);return e.map((e,r)=>{let a=this._stepStatus(e,r),o=e.getAttribute(`label`)||``,s=e.getAttribute(`description`)||``,c=e.getAttribute(`icon`)||``,l=r+1,u;u=a===`done`?v(`check`):a===`error`?v(`alert-triangle`):a===`skipped`?v(`minus`):c?v(c):String(l);let d=a===`pending`?`step`:`step ${a}`,f=a===`active`?` aria-current="step"`:``,p=i||r<this._active,m=s?`<span class="step-desc">${X(s)}</span>`:``,h;return h=t?`<span class="step-circle">${u}</span><span class="step-text"><span class="step-index">Step ${l}</span><span class="step-label">${X(o)}</span>${m}</span>`:n?`<span class="step-circle">${u}</span><span class="step-index">Step ${l}</span><span class="step-label">${X(o)}</span>${m}`:`<span class="step-circle">${u}</span><span class="step-label">${X(o)}</span>${m}`,p?`<button type="button" class="${d}" data-step="${r}"${f}>${h}</button>`:`<div class="${d}"${f}>${h}</div>`}).join(``)}_footerHtml(e){let t=this._active,n=e.length-1,r=this.hasAttribute(`disabled`)?` disabled`:``,i=e[t]?.hasAttribute(`optional`)||this.hasAttribute(`skippable`),a=this.getAttribute(`back-label`)||`Back`,o=this.getAttribute(`next-label`)||`Next`,s=this.getAttribute(`skip-label`)||`Skip`,c=this.getAttribute(`finish-label`)||`Finish`;return`${t>0?`<button type="button" class="btn btn-secondary" data-nav="back"${r}>${v(`arrow-left`,{className:`me-2`})}${X(a)}</button>`:`<span></span>`}<span class="wizard-footer-actions">${i&&t<n?`<button type="button" class="btn btn-subtle" data-nav="skip"${r}>${X(s)}</button>`:``}${t<n?`<button type="button" class="btn btn-primary" data-nav="next"${r}>${X(o)}${v(`arrow-right`,{className:`ms-2`})}</button>`:`<button type="button" class="btn btn-primary" data-nav="finish"${r}>${X(c)}</button>`}</span>`}_wire(){this._teardown(),this._onHeaderClick=e=>{let t=e.target.closest(`[data-step]`);t&&this.contains(t)&&this._stepTo(Number.parseInt(t.dataset.step,10))},this._onFooterClick=e=>{let t=e.target.closest(`[data-nav]`);if(!t||!this.contains(t)||this.hasAttribute(`disabled`))return;let n=t.dataset.nav;n===`back`?this._back():n===`skip`?this._skip():(n===`next`||n===`finish`)&&this._next()},this._header.addEventListener(`click`,this._onHeaderClick),this._footer.addEventListener(`click`,this._onFooterClick),this._observer=new MutationObserver(()=>this._onStepsMutated()),this._observer.observe(this,{childList:!0})}_teardown(){this._header&&this._onHeaderClick&&this._header.removeEventListener(`click`,this._onHeaderClick),this._footer&&this._onFooterClick&&this._footer.removeEventListener(`click`,this._onFooterClick),this._observer?.disconnect(),this._observer=null}_stepTo(e){this.hasAttribute(`disabled`)||!this.hasAttribute(`non-linear`)&&e>=this._active||this._go(e,`step`)}_back(){this._active>0&&this._go(this._active-1,`back`)}async _next(){this._reconcileSteps();let e=this._active,t=this._steps,n=e>=t.length-1,r=t[e];if(!this.dispatchEvent(new CustomEvent(`wui-wizard:beforechange`,{detail:n?{index:e,next:e,reason:`finish`}:{index:e,next:e+1,reason:`next`},cancelable:!0})))return this._flagInvalid(e);if(this._beforeNext){let i;try{i=await this._beforeNext(e)}catch{i=!1}if(this._reconcileSteps(),t=this._steps,e=t.indexOf(r),e<0)return;if(n=e>=t.length-1,i===!1)return this._flagInvalid(e)}if(this._invalid.delete(e),this._skipped.delete(e),n)return this._finish();this._go(e+1,`next`)}_skip(){let e=this._active,t=this._steps;if(!(!t[e]?.hasAttribute(`optional`)&&!this.hasAttribute(`skippable`))){if(this._invalid.delete(e),this._skipped.add(e),this.dispatchEvent(new CustomEvent(`wui-wizard:skip`,{detail:{index:e}})),e>=t.length-1)return this._finish();this._go(e+1,`skip`)}}_flagInvalid(e){this._invalid.add(e),this._renderChrome(),this.dispatchEvent(new CustomEvent(`wui-wizard:invalid`,{detail:{index:e}}))}_finish(){this._invalid.delete(this._active),this._finished=!0,this._renderChrome(),this.dispatchEvent(new CustomEvent(`wui-wizard:finish`,{detail:{index:this._active}}))}_go(e,t){let n=this._reconcileSteps(),r=Math.max(0,n.length-1),i=Math.min(Math.max(e,0),r),a=this._active;this._finished=!1,this._invalid.delete(a),this._active=i,this._reflectActive(i),this._renderChrome(),t!==`silent`&&i!==a&&this.dispatchEvent(new CustomEvent(`wui-wizard:change`,{detail:{index:i,previous:a,reason:t}}))}_reflectActive(e){this._reflecting=!0,this.setAttribute(`active`,String(e)),this._reflecting=!1}},sd=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),X=e=>String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),cd=class extends i{static get observedAttributes(){return[`label`,`description`,`optional`,`icon`,`status`]}attributeChangedCallback(){let e=this.closest(`wui-wizard`);e&&typeof e.refresh==`function`&&e.refresh()}},ld=2e3;async function ud(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.top=`0`,t.style.left=`0`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),!!n}catch{return!1}}var dd=`image/png,image/jpeg,image/webp`,fd=5,pd={"image/png":[`.png`],"image/jpeg":[`.jpg`,`.jpeg`],"image/webp":[`.webp`],"image/gif":[`.gif`],"image/svg+xml":[`.svg`],"application/pdf":[`.pdf`]},md={"image/png":`PNG`,"image/jpeg":`JPG`,"image/webp":`WEBP`,"image/gif":`GIF`,"image/svg+xml":`SVG`,"application/pdf":`PDF`,".png":`PNG`,".jpg":`JPG`,".jpeg":`JPG`,".webp":`WEBP`,".gif":`GIF`,".svg":`SVG`,".pdf":`PDF`},hd=e=>String(e||``).split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean),gd=[`.png`,`.jpg`,`.jpeg`,`.webp`,`.gif`,`.svg`,`.bmp`,`.avif`,`.heic`];function _d(e){if(!e)return!1;let t=typeof e==`object`&&e.type?String(e.type).toLowerCase():``;if(t)return t.startsWith(`image/`);let n=typeof e==`string`?e:e.name||e.url||``,r=String(n).toLowerCase();return gd.some(e=>r.endsWith(e))}function vd(e){let t=hd(e);return t.length?t.every(e=>e.startsWith(`.`)?gd.includes(e):e===`image/*`||e.startsWith(`image/`)):!1}function yd(e){let t=[];for(let n of hd(e)){let e=md[n]||(n.startsWith(`.`)?n.slice(1).toUpperCase():n.toUpperCase());t.includes(e)||t.push(e)}return t.length<=1?t[0]||`supported`:`${t.slice(0,-1).join(`, `)} or ${t[t.length-1]}`}function bd(e,t){let n=hd(t);if(!n.length)return!0;let r=(e.type||``).toLowerCase(),i=(e.name||``).toLowerCase();return n.some(e=>e.startsWith(`.`)?i.endsWith(e):e.endsWith(`/*`)?r.startsWith(e.slice(0,-1)):r&&r===e?!0:!r&&(pd[e]||[]).some(e=>i.endsWith(e)))}function xd(e,t={}){if(!e)return null;let n=t.accept===void 0?dd:t.accept,r=t.maxSizeMb===void 0?5:t.maxSizeMb;return bd(e,n)?r>0&&e.size>r*1024*1024?`Keep the file under ${r} MB.`:null:`Choose a ${yd(n)} file.`}var Sd={minLength:8,uppercase:!0,lowercase:!0,digit:!0,special:!0,uniqueChars:0},Cd=`Password Requirements`;function wd(e){return e===!0||e==null?{...Sd}:{...Sd,...e}}function Td(e){let t=wd(e),n=[];if(t.minLength>0&&n.push({key:`length`,label:`At least ${t.minLength} characters long`,test:e=>e.length>=t.minLength}),t.uppercase&&n.push({key:`uppercase`,label:`At least one uppercase letter`,test:e=>/[A-Z]/.test(e)}),t.lowercase&&n.push({key:`lowercase`,label:`At least one lowercase letter`,test:e=>/[a-z]/.test(e)}),t.digit&&n.push({key:`digit`,label:`At least one digit`,test:e=>/[0-9]/.test(e)}),t.special&&n.push({key:`special`,label:`At least one special character`,test:e=>/[^A-Za-z0-9]/.test(e)}),t.uniqueChars>0){let e=t.uniqueChars;n.push({key:`unique`,label:`At least ${e} unique character${e>1?`s`:``}`,test:t=>new Set(t).size>=e})}return n}function Ed(e,t){let n=e==null?``:String(e);return Td(t).map(e=>({key:e.key,label:e.label,met:e.test(n)}))}function Dd(e,t){return Ed(e,t).every(e=>e.met)}var Od=[`light`,`dark`,`auto`],kd=[`wave`,`circle`,`slide`,`blinds`,`fade`,`none`],Ad=`wave`,jd=`theme`,Md={wave:1100,circle:700,slide:600,blinds:900,fade:350,none:0},Nd=`wui-theme-switching`,Pd=`wui-theme-change`,Fd=`wui-theme-toggle`,Id=`(prefers-color-scheme: dark)`,Ld=e=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(e).matches,Rd=e=>Od.includes(e);function zd(e){return e===`dark`||e===`auto`&&Ld(Id)?`dark`:`light`}function Bd(e=jd,{includeAuto:t=!1}={}){let n=null;try{n=window.localStorage.getItem(e)}catch{}return!Rd(n)||n===`auto`&&!t?`light`:n}function Vd(e,t=jd){try{window.localStorage.setItem(t,e)}catch{}}function Hd(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.setAttribute(`data-bs-theme`,zd(e)),document.dispatchEvent(new CustomEvent(Pd,{detail:{mode:e}}))}function Ud(e,{includeAuto:t=!1}={}){return e===`light`?`dark`:e===`dark`&&t?`auto`:`light`}function Wd(e){if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>{};let t=window.matchMedia(Id),n=()=>e(t.matches?`dark`:`light`);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)}var Gd=60,Kd=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,Z=e=>e.toFixed(1),Q=(e,t)=>`${Z(e)}px ${Z(t)}px`,qd={amplitude:22,segments:36,cycles:1.5,ripples:2},Jd=6,Yd=(e,t,n,r,i)=>{let{amplitude:a,segments:o,cycles:s}=qd,c=n*(t+2*a),l=i?t+a-c:c-a,u=i?t+2*a:-2*a,d=[Q(0,u)];for(let t=0;t<=o;t++){let n=e*t/o,i=l+a*Math.sin(2*Math.PI*s*t/o+r);d.push(Q(n,i))}return d.push(Q(e,u)),`polygon(${d.join(`, `)})`},Xd=(e,t,n,r)=>{let i=t/Jd,a=[];for(let t=0;t<Jd;t++){let o=t*i,s=i*n,c=r?o+i-s:o,l=r?o+i:o+s;a.push(Q(0,c),Q(e,c),Q(e,l),Q(0,l))}return`polygon(${a.join(`, `)})`};function Zd(e,{width:t,height:n,to:r=`dark`,origin:i}={}){let a=r===`dark`,o=[];for(let r=0;r<=Gd;r++){let s=r/Gd,c=Kd(s);switch(e){case`circle`:{let e=i?.x??t/2,r=i?.y??n/2,a=Math.hypot(Math.max(e,t-e),Math.max(r,n-r));o.push({clipPath:`circle(${Z(a*c)}px at ${Z(e)}px ${Z(r)}px)`});break}case`slide`:{let e=n*(1-c);o.push({clipPath:a?`inset(${Z(e)}px 0px 0px 0px)`:`inset(0px 0px ${Z(e)}px 0px)`});break}case`blinds`:o.push({clipPath:Xd(t,n,c,a)});break;case`fade`:o.push({clipPath:`none`,opacity:c});break;case`none`:return[];default:o.push({clipPath:Yd(t,n,c,s*qd.ripples*2*Math.PI,a)})}}return o}function Qd(e,{effect:t=Ad,to:n,origin:r,duration:i,live:a}={}){let o=document.documentElement,s=n!==void 0&&o.getAttribute(`data-bs-theme`)===n;if(t===`none`||s||Ld(`(prefers-reduced-motion: reduce)`)||typeof document.startViewTransition!=`function`||typeof o.animate!=`function`)return e(),Promise.resolve(!1);o.classList.add(Nd);let c=a instanceof Element?a:null;c&&(c.style.viewTransitionName=Fd);let l=document.startViewTransition(e),u=i??Md[t]??Md.wave;return l.ready.then(()=>{let e=Zd(t,{width:window.innerWidth,height:window.innerHeight,to:n,origin:r});o.animate(e,{duration:u,easing:`linear`,fill:`both`,pseudoElement:`::view-transition-new(root)`})}).catch(()=>{}),l.finished.catch(()=>{}).then(()=>(o.classList.remove(Nd),c&&(c.style.viewTransitionName=``),!0))}var $=(e,t)=>{typeof customElements<`u`&&!customElements.get(e)&&customElements.define(e,t)};function $d(){$(`wui-select`,Se),$(`wui-country-select`,Ee),$(`wui-phone`,Ju),$(`wui-datepicker`,Me),$(`wui-date-range`,Ne),$(`wui-dock`,Pe),$(`wui-consent-banner`,ge),$(`wui-slider`,Yu),$(`wui-timepicker`,id),$(`wui-autocomplete`,ie),$(`wui-command-palette`,le),$(`wui-multiselect`,He),$(`wui-taginput`,Zu),$(`wui-otp`,et),$(`wui-status-icon`,c),$(`wui-wizard-step`,cd),$(`wui-wizard`,od)}return $d(),e.COPY_FEEDBACK_MS=ld,e.DEFAULT_IMAGE_ACCEPT=dd,e.DEFAULT_MAX_SIZE_MB=fd,e.DEFAULT_PASSWORD_RULES=Sd,e.DEFAULT_REQUIREMENTS_TITLE=Cd,e.DEFAULT_THEME_EFFECT=Ad,e.DEFAULT_THEME_STORAGE_KEY=jd,e.STATUS_TONES=s,e.THEME_CHANGE_EVENT=Pd,e.THEME_EFFECTS=kd,e.THEME_EFFECT_DURATION=Md,e.THEME_LIVE_NAME=Fd,e.THEME_MODES=Od,e.THEME_SWITCHING_CLASS=Nd,e.WuiAutocomplete=ie,e.WuiCommandPalette=le,e.WuiConsentBanner=ge,e.WuiCountrySelect=Ee,e.WuiDatePicker=Me,e.WuiDateRange=Ne,e.WuiDock=Pe,e.WuiMultiSelect=He,e.WuiOtp=et,e.WuiPhone=Ju,e.WuiSelect=Se,e.WuiSlider=Yu,e.WuiStatusIcon=c,e.WuiTagInput=Zu,e.WuiTimePicker=id,e.WuiWizard=od,e.WuiWizardStep=cd,e.acceptLabel=yd,e.applyTheme=Hd,e.buildPasswordRules=Td,e.copyTextToClipboard=ud,e.defineWeborityElements=$d,e.evaluatePassword=Ed,e.glyphSvg=v,e.isImageFile=_d,e.isImageOnlyAccept=vd,e.matchSegments=oe,e.matchesAccept=bd,e.nextTheme=Ud,e.passwordSatisfies=Dd,e.readStoredTheme=Bd,e.resolveTheme=zd,e.storeTheme=Vd,e.themeKeyframes=Zd,e.transitionTheme=Qd,e.validateFile=xd,e.watchSystemTheme=Wd,e})({});
|
|
419
|
+
</div>`,this._rendered=!0,g(this,this._value),this._wire()}_syncFormValue(){g(this,this._value)}_syncTrigger(){let e=this.querySelector(`.timepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!t)return;let n=nd(this._value),r=this.getAttribute(`format`)||`24`;t.textContent=n?rd(n,r):this.getAttribute(`placeholder`)||`Select time`,t.classList.toggle(`timepicker-placeholder`,!n),e?.classList.toggle(`has-value`,!!n)}_buildTimes(){let e=Math.max(1,parseInt(this.getAttribute(`step`)||`30`,10)),t=this.getAttribute(`min`)||`00:00`,n=this.getAttribute(`max`)||`23:59`,r=nd(t)||{h:0,m:0},i=nd(n)||{h:23,m:59},a=[],o=r.h,s=r.m;for(s=Math.ceil(s/e)*e,s>=60&&(o+=1,s-=60);o<i.h||o===i.h&&s<=i.m;)a.push({h:o,m:s}),s+=e,s>=60&&(o+=1,s-=60);return a}_renderOptions(){let e=this.querySelector(`.timepicker-pop`);if(!e)return;let t=this.getAttribute(`format`)||`24`,n=this._buildTimes(),r=nd(this._value),i=this._focus,a=``;for(let e=0;e<n.length;e++){let o=n[e],s=td(o.h,o.m),c=r&&r.h===o.h&&r.m===o.m;a+=`<button type="button" class="timepicker-option${c?` is-selected`:``}" data-hm="${s}" role="option" tabindex="${i===e?`0`:`-1`}"${c?` aria-selected="true"`:``}>${rd(o,t)}</button>`}e.innerHTML=a,this._focusActive()}_focusActive(){let e=this.querySelector(`.timepicker-pop`),t=e?.querySelector(`[tabindex="0"]`)||e?.querySelector(`.is-selected`);t&&!e.hidden&&t.focus()}_position(e,t){f(e,t)}_onKey(e){let t=[...this.querySelector(`.timepicker-pop`).querySelectorAll(`.timepicker-option`)];switch(e.key){case`ArrowUp`:{e.preventDefault();let t=Math.max((this._focus??0)-1,0);this._focus=t,this._renderOptions();break}case`ArrowDown`:{e.preventDefault();let n=Math.min((this._focus??-1)+1,t.length-1);this._focus=n,this._renderOptions();break}case`Home`:if(e.preventDefault(),!t.length)return;this._focus=0,this._renderOptions();break;case`End`:if(e.preventDefault(),!t.length)return;this._focus=t.length-1,this._renderOptions();break;case`PageUp`:{if(e.preventDefault(),!t.length)return;let n=this._focus==null||this._focus<0?0:this._focus;this._focus=Math.max(n-8,0),this._renderOptions();break}case`PageDown`:{if(e.preventDefault(),!t.length)return;let n=this._focus==null||this._focus<0?0:this._focus;this._focus=Math.min(n+8,t.length-1),this._renderOptions();break}case`Enter`:case` `:e.preventDefault(),t[this._focus]&&(this.value=t[this._focus].dataset.hm,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());break;case`Escape`:this._close();break;default:if(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);let n=t.findIndex(e=>e.textContent.trim().toLowerCase().startsWith(this._typeahead));n>=0&&(this._focus=n,this._renderOptions())}}}_wire(){this._teardown();let e=this.querySelector(`.timepicker-trigger`),t=this.querySelector(`.timepicker-pop`),n=this.querySelector(`.timepicker`);if(!e||!t)return;let r=()=>!t.hidden;this._open=()=>{this._focus=null,this._renderOptions(),t.hidden=!1,n?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),this._position(e,t);let r=t.querySelector(`.is-selected`);r?this._focus=[...t.querySelectorAll(`.timepicker-option`)].indexOf(r):this._focus=0,this._renderOptions(),t.querySelector(`[tabindex="0"]`)?.focus()},this._close=()=>{t.hidden=!0,n?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,e.focus()},e.addEventListener(`click`,()=>r()?this._close():this._open()),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`)&&(e.preventDefault(),r()||this._open())}),t.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`.timepicker-option`);t&&!t.disabled&&(this.value=t.dataset.hm,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{r()&&this._onKey(e)},t.addEventListener(`keydown`,this._onKeyBound),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,r()&&!t&&!this.contains(e.target)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{r()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),p(this,()=>{r()&&this._position(e,t)})},this._bindGlobal(),this._syncFormValue()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),m(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``}disconnectedCallback(){this._teardown()}},ad=`wui-wizard-step`,od=class extends i{static get observedAttributes(){return[`active`,`variant`,`orientation`,`non-linear`,`hide-stepper`,`disabled`,`skippable`,`label`,`back-label`,`next-label`,`skip-label`,`finish-label`]}constructor(){super(),this._active=0,this._skipped=new Set,this._invalid=new Set,this._finished=!1,this._rendered=!1,this._reflecting=!1,this._beforeNext=null,this._header=null,this._footer=null,this._known=[],this._observer=null}get active(){return this._active}set active(e){let t=Number.parseInt(e,10);Number.isFinite(t)&&this._go(t,`set`)}get beforeNext(){return this._beforeNext}set beforeNext(e){this._beforeNext=typeof e==`function`?e:null}get _steps(){return[...this.querySelectorAll(`:scope > ${ad}`)]}refresh(){this._rendered&&this._renderChrome()}connectedCallback(){if(this._rendered)this._wire(),this._onStepsMutated();else{let e=Number.parseInt(this.getAttribute(`active`),10);this._active=Number.isFinite(e)&&e>=0?e:0,this.render()}}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){if(!(!this._rendered||this._reflecting)){if(e===`active`){let e=Number.parseInt(n,10);Number.isFinite(e)&&this._go(e,`set`);return}this._renderChrome()}}render(){let e=this._steps;this._header||(this._header=document.createElement(`nav`),this._header.className=`stepper wizard-stepper`,this._footer=document.createElement(`div`),this._footer.className=`form-actions wizard-footer form-actions-between`,e.length?(this.insertBefore(this._header,e[0]),e[e.length-1].after(this._footer)):(this.prepend(this._header),this.append(this._footer))),this._known=e,this._renderChrome(),this._rendered=!0,this._wire()}_renderChrome(){let e=this._reconcileSteps();this._placeChrome(e),this._clampActive(e),this._syncPanels(e),this._header.innerHTML=this._headerHtml(e),this._footer.innerHTML=this._footerHtml(e),this._header.hidden=this.hasAttribute(`hide-stepper`)}_clampActive(e){let t=Math.max(0,e.length-1);this._active>t&&(this._active=t),this._active<0&&(this._active=0)}_reconcileSteps(){let e=this._steps,t=this._known;if(this._known=e,sd(e,t))return e;let n=n=>new Set([...n].map(n=>e.indexOf(t[n])).filter(e=>e>=0));this._skipped=n(this._skipped),this._invalid=n(this._invalid);let r=t[this._active];if(!r)return e;let i=e.indexOf(r);if(i<0){let n=t=>e.includes(t),r=t.slice(this._active+1).find(n)??t.slice(0,this._active).reverse().find(n);i=r?e.indexOf(r):this._active}return i=Math.min(i,Math.max(0,e.length-1)),i!==this._active&&(this._active=i,this._reflectActive(i)),e}_placeChrome(e){if(!e.length)return;let t=e[e.length-1];this._header.nextElementSibling!==e[0]&&this.insertBefore(this._header,e[0]),this._footer.previousElementSibling!==t&&t.after(this._footer)}_onStepsMutated(){if(!this._rendered)return;let e=this._steps;(!e.length||this._header.nextElementSibling===e[0]&&this._footer.previousElementSibling===e[e.length-1])&&sd(e,this._known)||(this._renderChrome(),this._observer?.takeRecords())}_syncPanels(e){e.forEach((e,t)=>{let n=t===this._active;e.classList.add(`wizard-panel`),e.hidden=!n,e.setAttribute(`role`,`tabpanel`),e.setAttribute(`aria-hidden`,n?`false`:`true`)})}_stepStatus(e,t){return e.getAttribute(`status`)||(this._invalid.has(t)?`error`:this._finished?`done`:t===this._active?`active`:t<this._active?this._skipped.has(t)?`skipped`:`done`:`pending`)}_headerHtml(e){let t=this.getAttribute(`variant`)===`journey`,n=this.getAttribute(`variant`)===`icons`,r=this.getAttribute(`orientation`)===`vertical`;this._header.className=[`stepper`,`wizard-stepper`,t&&`stepper-journey`,n&&`stepper-icons`,r&&`stepper-vertical`].filter(Boolean).join(` `),this._header.setAttribute(`aria-label`,this.getAttribute(`label`)||`Progress`);let i=this.hasAttribute(`non-linear`);return e.map((e,r)=>{let a=this._stepStatus(e,r),o=e.getAttribute(`label`)||``,s=e.getAttribute(`description`)||``,c=e.getAttribute(`icon`)||``,l=r+1,u;u=a===`done`?v(`check`):a===`error`?v(`alert-triangle`):a===`skipped`?v(`minus`):c?v(c):String(l);let d=a===`pending`?`step`:`step ${a}`,f=a===`active`?` aria-current="step"`:``,p=i||r<this._active,m=s?`<span class="step-desc">${X(s)}</span>`:``,h;return h=t?`<span class="step-circle">${u}</span><span class="step-text"><span class="step-index">Step ${l}</span><span class="step-label">${X(o)}</span>${m}</span>`:n?`<span class="step-circle">${u}</span><span class="step-index">Step ${l}</span><span class="step-label">${X(o)}</span>${m}`:`<span class="step-circle">${u}</span><span class="step-label">${X(o)}</span>${m}`,p?`<button type="button" class="${d}" data-step="${r}"${f}>${h}</button>`:`<div class="${d}"${f}>${h}</div>`}).join(``)}_footerHtml(e){let t=this._active,n=e.length-1,r=this.hasAttribute(`disabled`)?` disabled`:``,i=e[t]?.hasAttribute(`optional`)||this.hasAttribute(`skippable`),a=this.getAttribute(`back-label`)||`Back`,o=this.getAttribute(`next-label`)||`Next`,s=this.getAttribute(`skip-label`)||`Skip`,c=this.getAttribute(`finish-label`)||`Finish`;return`${t>0?`<button type="button" class="btn btn-secondary" data-nav="back"${r}>${v(`arrow-left`,{className:`me-2`})}${X(a)}</button>`:`<span></span>`}<span class="wizard-footer-actions">${i&&t<n?`<button type="button" class="btn btn-subtle" data-nav="skip"${r}>${X(s)}</button>`:``}${t<n?`<button type="button" class="btn btn-primary" data-nav="next"${r}>${X(o)}${v(`arrow-right`,{className:`ms-2`})}</button>`:`<button type="button" class="btn btn-primary" data-nav="finish"${r}>${X(c)}</button>`}</span>`}_wire(){this._teardown(),this._onHeaderClick=e=>{let t=e.target.closest(`[data-step]`);t&&this.contains(t)&&this._stepTo(Number.parseInt(t.dataset.step,10))},this._onFooterClick=e=>{let t=e.target.closest(`[data-nav]`);if(!t||!this.contains(t)||this.hasAttribute(`disabled`))return;let n=t.dataset.nav;n===`back`?this._back():n===`skip`?this._skip():(n===`next`||n===`finish`)&&this._next()},this._header.addEventListener(`click`,this._onHeaderClick),this._footer.addEventListener(`click`,this._onFooterClick),this._observer=new MutationObserver(()=>this._onStepsMutated()),this._observer.observe(this,{childList:!0})}_teardown(){this._header&&this._onHeaderClick&&this._header.removeEventListener(`click`,this._onHeaderClick),this._footer&&this._onFooterClick&&this._footer.removeEventListener(`click`,this._onFooterClick),this._observer?.disconnect(),this._observer=null}_stepTo(e){this.hasAttribute(`disabled`)||!this.hasAttribute(`non-linear`)&&e>=this._active||this._go(e,`step`)}_back(){this._active>0&&this._go(this._active-1,`back`)}async _next(){this._reconcileSteps();let e=this._active,t=this._steps,n=e>=t.length-1,r=t[e];if(!this.dispatchEvent(new CustomEvent(`wui-wizard:beforechange`,{detail:n?{index:e,next:e,reason:`finish`}:{index:e,next:e+1,reason:`next`},cancelable:!0})))return this._flagInvalid(e);if(this._beforeNext){let i;try{i=await this._beforeNext(e)}catch{i=!1}if(this._reconcileSteps(),t=this._steps,e=t.indexOf(r),e<0)return;if(n=e>=t.length-1,i===!1)return this._flagInvalid(e)}if(this._invalid.delete(e),this._skipped.delete(e),n)return this._finish();this._go(e+1,`next`)}_skip(){let e=this._active,t=this._steps;if(!(!t[e]?.hasAttribute(`optional`)&&!this.hasAttribute(`skippable`))){if(this._invalid.delete(e),this._skipped.add(e),this.dispatchEvent(new CustomEvent(`wui-wizard:skip`,{detail:{index:e}})),e>=t.length-1)return this._finish();this._go(e+1,`skip`)}}_flagInvalid(e){this._invalid.add(e),this._renderChrome(),this.dispatchEvent(new CustomEvent(`wui-wizard:invalid`,{detail:{index:e}}))}_finish(){this._invalid.delete(this._active),this._finished=!0,this._renderChrome(),this.dispatchEvent(new CustomEvent(`wui-wizard:finish`,{detail:{index:this._active}}))}_go(e,t){let n=this._reconcileSteps(),r=Math.max(0,n.length-1),i=Math.min(Math.max(e,0),r),a=this._active;this._finished=!1,this._invalid.delete(a),this._active=i,this._reflectActive(i),this._renderChrome(),t!==`silent`&&i!==a&&this.dispatchEvent(new CustomEvent(`wui-wizard:change`,{detail:{index:i,previous:a,reason:t}}))}_reflectActive(e){this._reflecting=!0,this.setAttribute(`active`,String(e)),this._reflecting=!1}},sd=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),X=e=>String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),cd=class extends i{static get observedAttributes(){return[`label`,`description`,`optional`,`icon`,`status`]}attributeChangedCallback(){let e=this.closest(`wui-wizard`);e&&typeof e.refresh==`function`&&e.refresh()}},ld=2e3;async function ud(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.top=`0`,t.style.left=`0`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),!!n}catch{return!1}}var dd=`image/png,image/jpeg,image/webp`,fd=5,pd={"image/png":[`.png`],"image/jpeg":[`.jpg`,`.jpeg`],"image/webp":[`.webp`],"image/gif":[`.gif`],"image/svg+xml":[`.svg`],"application/pdf":[`.pdf`]},md={"image/png":`PNG`,"image/jpeg":`JPG`,"image/webp":`WEBP`,"image/gif":`GIF`,"image/svg+xml":`SVG`,"application/pdf":`PDF`,".png":`PNG`,".jpg":`JPG`,".jpeg":`JPG`,".webp":`WEBP`,".gif":`GIF`,".svg":`SVG`,".pdf":`PDF`},hd=e=>String(e||``).split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean),gd=[`.png`,`.jpg`,`.jpeg`,`.webp`,`.gif`,`.svg`,`.bmp`,`.avif`,`.heic`];function _d(e){if(!e)return!1;let t=typeof e==`object`&&e.type?String(e.type).toLowerCase():``;if(t)return t.startsWith(`image/`);let n=typeof e==`string`?e:e.name||e.url||``,r=String(n).toLowerCase();return gd.some(e=>r.endsWith(e))}function vd(e){let t=hd(e);return t.length?t.every(e=>e.startsWith(`.`)?gd.includes(e):e===`image/*`||e.startsWith(`image/`)):!1}function yd(e){let t=[];for(let n of hd(e)){let e=md[n]||(n.startsWith(`.`)?n.slice(1).toUpperCase():n.toUpperCase());t.includes(e)||t.push(e)}return t.length<=1?t[0]||`supported`:`${t.slice(0,-1).join(`, `)} or ${t[t.length-1]}`}function bd(e,t){let n=hd(t);if(!n.length)return!0;let r=(e.type||``).toLowerCase(),i=(e.name||``).toLowerCase();return n.some(e=>e.startsWith(`.`)?i.endsWith(e):e.endsWith(`/*`)?r.startsWith(e.slice(0,-1)):r&&r===e?!0:!r&&(pd[e]||[]).some(e=>i.endsWith(e)))}function xd(e,t={}){if(!e)return null;let n=t.accept===void 0?dd:t.accept,r=t.maxSizeMb===void 0?5:t.maxSizeMb;return bd(e,n)?r>0&&e.size>r*1024*1024?`Keep the file under ${r} MB.`:null:`Choose a ${yd(n)} file.`}var Sd={minLength:8,uppercase:!0,lowercase:!0,digit:!0,special:!0,uniqueChars:0},Cd=`Password requirements`;function wd(e){return e===!0||e==null?{...Sd}:{...Sd,...e}}function Td(e){let t=wd(e),n=[];if(t.minLength>0&&n.push({key:`length`,label:`At least ${t.minLength} characters long`,test:e=>e.length>=t.minLength}),t.uppercase&&n.push({key:`uppercase`,label:`At least one uppercase letter`,test:e=>/[A-Z]/.test(e)}),t.lowercase&&n.push({key:`lowercase`,label:`At least one lowercase letter`,test:e=>/[a-z]/.test(e)}),t.digit&&n.push({key:`digit`,label:`At least one digit`,test:e=>/[0-9]/.test(e)}),t.special&&n.push({key:`special`,label:`At least one special character`,test:e=>/[^A-Za-z0-9]/.test(e)}),t.uniqueChars>0){let e=t.uniqueChars;n.push({key:`unique`,label:`At least ${e} unique character${e>1?`s`:``}`,test:t=>new Set(t).size>=e})}return n}function Ed(e,t){let n=e==null?``:String(e);return Td(t).map(e=>({key:e.key,label:e.label,met:e.test(n)}))}function Dd(e,t){return Ed(e,t).every(e=>e.met)}var Od=[`light`,`dark`,`auto`],kd=[`wave`,`circle`,`slide`,`blinds`,`fade`,`none`],Ad=`wave`,jd=`theme`,Md={wave:1100,circle:700,slide:600,blinds:900,fade:350,none:0},Nd=`wui-theme-switching`,Pd=`wui-theme-change`,Fd=`wui-theme-toggle`,Id=`(prefers-color-scheme: dark)`,Ld=e=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(e).matches,Rd=e=>Od.includes(e);function zd(e){return e===`dark`||e===`auto`&&Ld(Id)?`dark`:`light`}function Bd(e=jd,{includeAuto:t=!1}={}){let n=null;try{n=window.localStorage.getItem(e)}catch{}return!Rd(n)||n===`auto`&&!t?`light`:n}function Vd(e,t=jd){try{window.localStorage.setItem(t,e)}catch{}}function Hd(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.setAttribute(`data-bs-theme`,zd(e)),document.dispatchEvent(new CustomEvent(Pd,{detail:{mode:e}}))}function Ud(e,{includeAuto:t=!1}={}){return e===`light`?`dark`:e===`dark`&&t?`auto`:`light`}function Wd(e){if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>{};let t=window.matchMedia(Id),n=()=>e(t.matches?`dark`:`light`);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)}var Gd=60,Kd=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,Z=e=>e.toFixed(1),Q=(e,t)=>`${Z(e)}px ${Z(t)}px`,qd={amplitude:22,segments:36,cycles:1.5,ripples:2},Jd=6,Yd=(e,t,n,r,i)=>{let{amplitude:a,segments:o,cycles:s}=qd,c=n*(t+2*a),l=i?t+a-c:c-a,u=i?t+2*a:-2*a,d=[Q(0,u)];for(let t=0;t<=o;t++){let n=e*t/o,i=l+a*Math.sin(2*Math.PI*s*t/o+r);d.push(Q(n,i))}return d.push(Q(e,u)),`polygon(${d.join(`, `)})`},Xd=(e,t,n,r)=>{let i=t/Jd,a=[];for(let t=0;t<Jd;t++){let o=t*i,s=i*n,c=r?o+i-s:o,l=r?o+i:o+s;a.push(Q(0,c),Q(e,c),Q(e,l),Q(0,l))}return`polygon(${a.join(`, `)})`};function Zd(e,{width:t,height:n,to:r=`dark`,origin:i}={}){let a=r===`dark`,o=[];for(let r=0;r<=Gd;r++){let s=r/Gd,c=Kd(s);switch(e){case`circle`:{let e=i?.x??t/2,r=i?.y??n/2,a=Math.hypot(Math.max(e,t-e),Math.max(r,n-r));o.push({clipPath:`circle(${Z(a*c)}px at ${Z(e)}px ${Z(r)}px)`});break}case`slide`:{let e=n*(1-c);o.push({clipPath:a?`inset(${Z(e)}px 0px 0px 0px)`:`inset(0px 0px ${Z(e)}px 0px)`});break}case`blinds`:o.push({clipPath:Xd(t,n,c,a)});break;case`fade`:o.push({clipPath:`none`,opacity:c});break;case`none`:return[];default:o.push({clipPath:Yd(t,n,c,s*qd.ripples*2*Math.PI,a)})}}return o}function Qd(e,{effect:t=Ad,to:n,origin:r,duration:i,live:a}={}){let o=document.documentElement,s=n!==void 0&&o.getAttribute(`data-bs-theme`)===n;if(t===`none`||s||Ld(`(prefers-reduced-motion: reduce)`)||typeof document.startViewTransition!=`function`||typeof o.animate!=`function`)return e(),Promise.resolve(!1);o.classList.add(Nd);let c=a instanceof Element?a:null;c&&(c.style.viewTransitionName=Fd);let l=document.startViewTransition(e),u=i??Md[t]??Md.wave;return l.ready.then(()=>{let e=Zd(t,{width:window.innerWidth,height:window.innerHeight,to:n,origin:r});o.animate(e,{duration:u,easing:`linear`,fill:`both`,pseudoElement:`::view-transition-new(root)`})}).catch(()=>{}),l.finished.catch(()=>{}).then(()=>(o.classList.remove(Nd),c&&(c.style.viewTransitionName=``),!0))}var $=(e,t)=>{typeof customElements<`u`&&!customElements.get(e)&&customElements.define(e,t)};function $d(){$(`wui-select`,Se),$(`wui-country-select`,Ee),$(`wui-phone`,Ju),$(`wui-datepicker`,Me),$(`wui-date-range`,Ne),$(`wui-dock`,Pe),$(`wui-consent-banner`,ge),$(`wui-slider`,Yu),$(`wui-timepicker`,id),$(`wui-autocomplete`,ie),$(`wui-command-palette`,le),$(`wui-multiselect`,He),$(`wui-taginput`,Zu),$(`wui-otp`,et),$(`wui-status-icon`,c),$(`wui-wizard-step`,cd),$(`wui-wizard`,od)}return $d(),e.COPY_FEEDBACK_MS=ld,e.DEFAULT_IMAGE_ACCEPT=dd,e.DEFAULT_MAX_SIZE_MB=fd,e.DEFAULT_PASSWORD_RULES=Sd,e.DEFAULT_REQUIREMENTS_TITLE=Cd,e.DEFAULT_THEME_EFFECT=Ad,e.DEFAULT_THEME_STORAGE_KEY=jd,e.STATUS_TONES=s,e.THEME_CHANGE_EVENT=Pd,e.THEME_EFFECTS=kd,e.THEME_EFFECT_DURATION=Md,e.THEME_LIVE_NAME=Fd,e.THEME_MODES=Od,e.THEME_SWITCHING_CLASS=Nd,e.WuiAutocomplete=ie,e.WuiCommandPalette=le,e.WuiConsentBanner=ge,e.WuiCountrySelect=Ee,e.WuiDatePicker=Me,e.WuiDateRange=Ne,e.WuiDock=Pe,e.WuiMultiSelect=He,e.WuiOtp=et,e.WuiPhone=Ju,e.WuiSelect=Se,e.WuiSlider=Yu,e.WuiStatusIcon=c,e.WuiTagInput=Zu,e.WuiTimePicker=id,e.WuiWizard=od,e.WuiWizardStep=cd,e.acceptLabel=yd,e.applyTheme=Hd,e.buildPasswordRules=Td,e.copyTextToClipboard=ud,e.defineWeborityElements=$d,e.evaluatePassword=Ed,e.glyphSvg=v,e.isImageFile=_d,e.isImageOnlyAccept=vd,e.matchSegments=oe,e.matchesAccept=bd,e.nextTheme=Ud,e.passwordSatisfies=Dd,e.readStoredTheme=Bd,e.resolveTheme=zd,e.storeTheme=Vd,e.themeKeyframes=Zd,e.transitionTheme=Qd,e.validateFile=xd,e.watchSystemTheme=Wd,e})({});
|
package/dist/ui-elements.js
CHANGED
|
@@ -580,14 +580,14 @@ var E = "[role=\"option\"]", D = "No results", ee = class extends e {
|
|
|
580
580
|
];
|
|
581
581
|
}
|
|
582
582
|
constructor() {
|
|
583
|
-
super(), this._activeId = null, this._lastQuery = null, this._onKeyDown = (e) => this._handleKeyDown(e), this._onClick = (e) => {
|
|
583
|
+
super(), this._activeId = null, this._lastQuery = null, this._lastIds = null, this._userChose = !1, this._onKeyDown = (e) => this._handleKeyDown(e), this._onClick = (e) => {
|
|
584
584
|
let t = this._optionFrom(e.target);
|
|
585
585
|
t && this._select(t);
|
|
586
586
|
}, this._onMouseDown = (e) => {
|
|
587
587
|
this._optionFrom(e.target) && e.preventDefault();
|
|
588
588
|
}, this._onMouseMove = (e) => {
|
|
589
589
|
let t = this._optionFrom(e.target);
|
|
590
|
-
t && t.id !== this._activeId && this._setActive(t, !1);
|
|
590
|
+
t && t.id !== this._activeId && (this._userChose = !0, this._setActive(t, !1));
|
|
591
591
|
}, this._onInput = (e) => {
|
|
592
592
|
!this.hasAttribute("filter") || e.target !== this._input() || (this._applyFilter(), this.refresh());
|
|
593
593
|
};
|
|
@@ -622,8 +622,10 @@ var E = "[role=\"option\"]", D = "No results", ee = class extends e {
|
|
|
622
622
|
refresh() {
|
|
623
623
|
let e = this._input(), t = e ? e.value : "", n = t !== this._lastQuery;
|
|
624
624
|
this._lastQuery = t;
|
|
625
|
-
let r = this._visibleOptions(), i =
|
|
626
|
-
this.
|
|
625
|
+
let r = this._visibleOptions(), i = r.map((e) => e.id).join("\n"), a = i !== this._lastIds;
|
|
626
|
+
this._lastIds = i;
|
|
627
|
+
let o = !n && (this._userChose || !a) ? r.find((e) => e.id === this._activeId) : null;
|
|
628
|
+
o || (this._userChose = !1), this._setActive(o ?? r[0] ?? null, n);
|
|
627
629
|
}
|
|
628
630
|
_input() {
|
|
629
631
|
return this.querySelector("[role=\"combobox\"]");
|
|
@@ -648,7 +650,7 @@ var E = "[role=\"option\"]", D = "No results", ee = class extends e {
|
|
|
648
650
|
let t = this._visibleOptions();
|
|
649
651
|
if (!t.length) return;
|
|
650
652
|
let n = t.findIndex((e) => e.id === this._activeId), r = n < 0 ? e > 0 ? 0 : t.length - 1 : (n + e + t.length) % t.length;
|
|
651
|
-
this._setActive(t[r], !0);
|
|
653
|
+
this._userChose = !0, this._setActive(t[r], !0);
|
|
652
654
|
}
|
|
653
655
|
_handleKeyDown(e) {
|
|
654
656
|
if (e.target === this._input()) {
|
|
@@ -2744,7 +2746,7 @@ var j = (e) => String(e ?? "").replace(/&/g, "&").replace(/</g, "<").repl
|
|
|
2744
2746
|
return `
|
|
2745
2747
|
<div class="datepicker-head">
|
|
2746
2748
|
<button type="button" class="datepicker-nav-btn" data-nav-decade="-1" aria-label="Previous decade">${m("chevron-left")}</button>
|
|
2747
|
-
<span class="datepicker-month">${r + 1}
|
|
2749
|
+
<span class="datepicker-month">${r + 1} to ${r + 10}</span>
|
|
2748
2750
|
<button type="button" class="datepicker-nav-btn" data-nav-decade="1" aria-label="Next decade">${m("chevron-right")}</button>
|
|
2749
2751
|
</div>
|
|
2750
2752
|
<div class="datepicker-cells">${i}</div>`;
|
|
@@ -2957,12 +2959,12 @@ var j = (e) => String(e ?? "").replace(/&/g, "&").replace(/</g, "<").repl
|
|
|
2957
2959
|
return Number.isInteger(e) && e >= 0 && e <= 6 ? e : 0;
|
|
2958
2960
|
}
|
|
2959
2961
|
_label() {
|
|
2960
|
-
let e = this.getAttribute("placeholder") || "Start
|
|
2962
|
+
let e = this.getAttribute("placeholder") || "Start to End";
|
|
2961
2963
|
return !this._start && !this._end ? {
|
|
2962
2964
|
text: e,
|
|
2963
2965
|
empty: !0
|
|
2964
2966
|
} : {
|
|
2965
|
-
text: `${z(this._start) || "Start"}
|
|
2967
|
+
text: `${z(this._start) || "Start"} to ${z(this._end) || "End"}`,
|
|
2966
2968
|
empty: !1
|
|
2967
2969
|
};
|
|
2968
2970
|
}
|
|
@@ -3053,7 +3055,7 @@ var j = (e) => String(e ?? "").replace(/&/g, "&").replace(/</g, "<").repl
|
|
|
3053
3055
|
n.classList.toggle("is-range-start", i), n.classList.toggle("is-range-end", a), n.classList.toggle("in-range", o);
|
|
3054
3056
|
}
|
|
3055
3057
|
let i = e.querySelector("[data-range-hint]");
|
|
3056
|
-
i && (i.textContent = this._start ? this._end ? `${z(this._start)}
|
|
3058
|
+
i && (i.textContent = this._start ? this._end ? `${z(this._start)} to ${z(this._end)}` : "Pick an end date" : "Pick a start date");
|
|
3057
3059
|
}
|
|
3058
3060
|
_position(e, t) {
|
|
3059
3061
|
c(e, t, { clampHeight: !0 });
|
|
@@ -4574,7 +4576,7 @@ var Qe = class extends e {
|
|
|
4574
4576
|
aria-label="${et(this.getAttribute("aria-label") || "Value")}"
|
|
4575
4577
|
></button>
|
|
4576
4578
|
`}
|
|
4577
|
-
${this.hasAttribute("show-value") ? n ? `<span class="slider-value">${this._formatValue(this._start)}
|
|
4579
|
+
${this.hasAttribute("show-value") ? n ? `<span class="slider-value">${this._formatValue(this._start)} to ${this._formatValue(this._end)}</span>` : `<span class="slider-value">${this._formatValue(this._value)}</span>` : ""}
|
|
4578
4580
|
</div>
|
|
4579
4581
|
`, this._rendered = !0, this._placeParts(), this._syncMirrors(), this._wire();
|
|
4580
4582
|
}
|
|
@@ -4594,7 +4596,7 @@ var Qe = class extends e {
|
|
|
4594
4596
|
let e = this.querySelector("[data-thumb=\"start\"]"), t = this.querySelector("[data-thumb=\"end\"]");
|
|
4595
4597
|
e && (e.setAttribute("aria-valuenow", String(this._start)), e.setAttribute("aria-valuetext", this._formatValue(this._start))), t && (t.setAttribute("aria-valuenow", String(this._end)), t.setAttribute("aria-valuetext", this._formatValue(this._end)));
|
|
4596
4598
|
let n = this.querySelector(".slider-value");
|
|
4597
|
-
n && (n.textContent = `${this._formatValue(this._start)}
|
|
4599
|
+
n && (n.textContent = `${this._formatValue(this._start)} to ${this._formatValue(this._end)}`);
|
|
4598
4600
|
} else {
|
|
4599
4601
|
let e = this.querySelector(".slider-thumb");
|
|
4600
4602
|
e && (e.setAttribute("aria-valuenow", String(this._value)), e.setAttribute("aria-valuetext", this._formatValue(this._value)));
|
|
@@ -5328,7 +5330,7 @@ var wt = {
|
|
|
5328
5330
|
digit: !0,
|
|
5329
5331
|
special: !0,
|
|
5330
5332
|
uniqueChars: 0
|
|
5331
|
-
}, Tt = "Password
|
|
5333
|
+
}, Tt = "Password requirements";
|
|
5332
5334
|
function Et(e) {
|
|
5333
5335
|
return e === !0 || e == null ? { ...wt } : {
|
|
5334
5336
|
...wt,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/ui-elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Webority framework-agnostic UI custom elements (<wui-*>) — the single implementation of the interactive components, styled by @webority/theme. Used natively in Razor and wrapped by @webority/ui-react.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|