@webority/ui-elements 0.173.0 → 0.173.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +1 -1
- package/dist/ui-elements/comment-thread.global.js +1 -1
- package/dist/ui-elements/consent-banner.global.js +1 -1
- package/dist/ui-elements/context-menu.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +1 -1
- package/dist/ui-elements/date-time.global.js +1 -1
- package/dist/ui-elements/datepicker.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/dropdown.global.js +1 -1
- package/dist/ui-elements/entry-grid.global.js +1 -1
- package/dist/ui-elements/gantt.global.js +1 -1
- package/dist/ui-elements/glyphs.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -1
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lead-popup.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +1 -1
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/popover.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +1 -1
- package/dist/ui-elements/select-recents.global.js +1 -1
- package/dist/ui-elements/select-search.global.js +1 -1
- package/dist/ui-elements/select-window.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/table-export.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree-picker.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=globalThis.WeborityUiElementsInternal?.version;if(l!==`0.173.0`)throw Error(`[webority-ui] kanban expects ui-elements 0.173.0 but the page loaded `+l+`.`);var u={ariaLabel:`Board`,busyMessage:`This card is still saving. Try again in a moment.`,cancelledText:`{card} was not moved.`,cardLabel:`Card`,clientMessage:`This card could not be moved. Refresh the board and try again.`,collapseLabel:`Collapse {title}`,columnsLabel:`Board columns`,dropHereText:`Drop here to move {card} to {column}.`,emptyText:`Nothing here`,expandLabel:`Expand {title}`,fewerLabel:`Show fewer`,forbiddenMessage:`You do not have permission to move this card.`,helpText:`Press Space to pick up the card. Use the Left and Right arrow keys to choose a column, then Space to drop it, or Escape to cancel.`,liftedText:`Picked up {card} in {column}. Use the Left and Right arrow keys to choose a column.`,loadFailedMessage:`More cards could not be loaded. Try again.`,loadMoreText:`Show more ({n})`,loadingLabel:`Loading…`,lockedText:`{card} cannot be moved.`,moreText:`Show {count} more`,movedText:`Moved {card} to {column}.`,movingText:`Moving {card} to {column}.`,networkMessage:`Could not reach the server, so the card went back. Check your connection and try again.`,overRefusedText:`{column}. {reason}`,overSourceText:`{column}, where the card started.`,overTextOne:`{column}, 1 card. Drop allowed.`,overTextOther:`{column}, {count} cards. Drop allowed.`,refusedText:`Cards in {from} cannot move to {to}.`,rolledBackText:`{card} went back to {column}.`,serverMessage:`Something went wrong on our side, so the card went back. Try again in a moment.`,swipeHintText:`Swipe sideways or tap a column`},d=Object.freeze([`neutral`,`primary`,`info`,`success`,`warning`,`danger`]),f=Object.freeze([`number`,`currency`,`compact`]),p=`wui-kanban:`,m=`(max-width: 767.98px)`,h=400,g=6,_=()=>(0,a.readText)(`kanban`,u),v=e=>typeof e==`object`&&!!e,y=e=>{let t=v(e)?e.collapsed:void 0;return v(t)?Object.fromEntries(Object.entries(t).map(([e,t])=>[e,!!t])):{}};function b(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);if(!Number.isInteger(t)||t<1)throw TypeError(`Unsupported kanban visible limit "${String(e)}". Use a whole number of 1 or more.`);return t}function x(e,t,n,r){let i=new Set;if(t==null||n)return i;let a=0;for(let n of e)r.has(n)||(a<t?a++:i.add(n));return i}function S(e){let t=(e.getAttribute(`aria-label`)||e.textContent||``).replace(/\s+/g,` `).trim();return t.length>80?`${t.slice(0,79)}…`:t||e.getAttribute(`data-wui-card`)||_().cardLabel}function C(e){return e?`${p}${e}`:null}function w(e,t=globalThis.localStorage){let n=C(e);if(!n||!t)return{};try{return y(JSON.parse(t.getItem(n)||`null`))}catch{return{}}}function T(e,t,n,r=globalThis.localStorage){let i=C(e);if(!i||!r)return;let a={...w(e,r),[String(t)]:!!n};try{r.setItem(i,JSON.stringify({collapsed:a}))}catch(e){if(!(e instanceof DOMException))throw e}}function E(e,t){if(!f.includes(e))throw TypeError(`Unsupported kanban summary format "${String(e)}". Use ${f.join(`, `)}.`);if(t!=null&&t!==``&&!(0,i.isMoneyUnit)(t))throw TypeError(`Unsupported kanban summary unit "${String(t)}". Use ${i.MONEY_UNITS.join(`, `)}.`);return e===`currency`?{style:`currency`,currency:`INR`,unit:t||`rupees`}:e===`compact`?{style:`compact`,currency:`INR`,unit:t||`rupees`}:{style:`number`,decimals:0}}function D(e){let t=0;for(let n of e){if(n==null||n===``)continue;let e=typeof n==`number`?n:Number(n);Number.isFinite(e)&&(t+=e)}return t}var O=()=>(0,a.readText)(`kanban`,u),ee=()=>({forbidden:O().forbiddenMessage,client:O().clientMessage,validation:O().clientMessage,server:O().serverMessage,network:O().networkMessage}),k=`[data-wui-column]`,A=`[data-wui-body]`,j=`[data-wui-card]`,M=`[data-wui-count]`,N=`[data-wui-summary]`,te=`[data-wui-empty]`,P=`[data-wui-drop-note]`,ne=`[data-wui-live]`,re=`[data-wui-help]`,F=`[data-wui-switch]`,ie=`[data-wui-scroller]`,I=`[data-wui-collapse]`,L=`[data-wui-more]`,R=`data-wui-visible-limit`,z=`data-wui-overflow`,ae=`input, select, textarea, [contenteditable=""], [contenteditable="true"], [data-wui-no-drag]`,B=`[data-wui-load-more]`,V=`data-wui-more-url`,oe=`data-wui-total`,H=`data-wui-unloaded`,U=48,W=16,se=160,G=e=>e.getAttribute(`data-wui-column`),K=e=>e.getAttribute(`data-wui-card`),q=e=>e instanceof HTMLElement&&!!e.hidden||e.hasAttribute(`hidden`),ce=e=>q(e)||e.hasAttribute(z),J=e=>e instanceof Element?e:null,le=e=>typeof e==`object`&&e&&`name`in e?e.name:void 0,ue=e=>typeof e==`object`&&e&&`message`in e?e.message:void 0,Y=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},X=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),Z=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Q=()=>window.WUI??null,$=(e,t)=>{e&&Q()?.toast(e,{variant:t})},de=class extends r.ElementBase{constructor(){super(),this._wired=!1,this._filter=null,this._expanded=new Set,this._revealed=new Set,this._press=null,this._drag=null,this._kbd=null,this._suppressClick=!1,this._observer=null,this._refreshQueued=!1,this._scrollTimer=0,this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onPointerCancel=()=>this._endPointer(!1),this._onDocKeyDown=e=>{e.key===`Escape`&&this._drag&&(e.preventDefault(),this._endPointer(!1))},this._onScroll=()=>{clearTimeout(this._scrollTimer),this._scrollTimer=setTimeout(()=>this._syncSwitcherFromScroll(),80)},this.addEventListener(`pointerdown`,e=>this._pointerDown(e)),this.addEventListener(`keydown`,e=>this._keyDown(e)),this.addEventListener(`click`,e=>this._click(e),!0),this.addEventListener(`scroll`,e=>{e.target instanceof Element&&this._loadOnScroll(e.target)},!0),this.addEventListener(`dragstart`,e=>{J(e.target)?.closest(j)&&e.preventDefault()}),this.addEventListener(`touchmove`,e=>{this._drag&&e.preventDefault()},{passive:!1})}_controlled(){return this.hasAttribute(`controlled`)}connectedCallback(){if(!this._wired){this._wired=!0,this._scroller()?.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._restoreCollapsed();for(let e of this._allCards())this._prepareCard(e);if(typeof MutationObserver==`function`){this._observer=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e instanceof HTMLElement&&e.matches(j)&&this._prepareCard(e);this._queueRefresh()});for(let e of this.querySelectorAll(A))this._observer.observe(e,{childList:!0})}this.refresh()}}disconnectedCallback(){this._endPointer(!1),this._observer?.disconnect(),this._observer=null,this._scroller()?.removeEventListener(`scroll`,this._onScroll),clearTimeout(this._scrollTimer),this._wired=!1}setFilter(e){if(e!=null&&typeof e!=`function`)throw TypeError(`wui-kanban setFilter: pass a function or null.`);if(this._filter=e,!e)for(let e of this._allCards())e.hidden=!1;this.refresh()}refresh(){if(this._controlled())return;this._refreshQueued=!1;let e=this._summaryFormat();for(let t of this._columns()){let n=G(t),r=b(t.getAttribute(R)),o=[],s=[];for(let e of this._cardsIn(t))this._filter&&(e.hidden=this._filter(e)===!1),q(e)?e.removeAttribute(z):(o.push(e),s.push(e.getAttribute(`data-wui-value`)));let c=this._expanded.has(n),l=x(o.map(K),r,c,this._revealed);for(let e of o)e.toggleAttribute(z,l.has(K(e)));let u=this._unloadedIn(t),d=String(o.length+u);for(let e of this._countsOf(t))e.textContent!==d&&(e.textContent=d);let f=Y(t,te,HTMLElement);if(f&&(f.hidden=o.length>0),e){let n=t.querySelector(N);n&&(n.textContent=(0,i.formatValue)(D(s),e))}let p=Y(t,L,HTMLElement);if(p){p.hidden=r==null||(c?o.length<=r:l.size===0),p.setAttribute(`aria-expanded`,c?`true`:`false`);let e=c?O().fewerLabel:(0,a.fillText)(O().moreText,{count:l.size});p.textContent!==e&&(p.textContent=e)}let m=Y(t,B,HTMLButtonElement);if(m&&(m.hidden=u<=0,!t.hasAttribute(`data-wui-loading`))){m.disabled=!1;let e=(0,a.fillText)(O().loadMoreText,{n:u});m.textContent!==e&&(m.textContent=e)}}}moveCard(e,t,n){let r=this._cardByKey(e);if(!r)throw Error(`wui-kanban moveCard: no card "${String(e)}" on this board.`);if(!this._columnByKey(t))throw Error(`wui-kanban moveCard: no column "${String(t)}" on this board.`);return this._commit(r,t,n)}_columns(){return X(this,k,HTMLElement)}_columnByKey(e){return this._columns().find(t=>G(t)===e)||null}_columnOf(e){return Z(e,k,HTMLElement)}_titleOf(e){return(e.querySelector(`.wui-kanban-title`)?.textContent||G(e)||``).replace(/\s+/g,` `).trim()}_bodyOf(e){return Y(e,A,HTMLElement)}_cardsIn(e){let t=this._bodyOf(e);return t?[...t.children].filter(e=>e instanceof HTMLElement&&e.matches(j)):[]}_visibleCardsIn(e){return this._cardsIn(e).filter(e=>!ce(e))}_allCards(){return X(this,`${A} > ${j}`,HTMLElement)}_cardByKey(e){return this._allCards().find(t=>K(t)===e)||null}_countsOf(e){let t=G(e),n=[...this.querySelectorAll(F)].filter(e=>e.getAttribute(`data-wui-switch`)===t);return[...e.querySelectorAll(M),...n.flatMap(e=>[...e.querySelectorAll(M)])]}_scroller(){return Y(this,ie,HTMLElement)}_summaryFormat(){let e=this.getAttribute(`summary-format`);return e?E(e,this.getAttribute(`summary-unit`)):null}_queueRefresh(){this._refreshQueued||(this._refreshQueued=!0,queueMicrotask(()=>{this._refreshQueued&&this.refresh()}))}_prepareCard(e){let t=this.querySelector(re);t?.id&&!e.hasAttribute(`aria-describedby`)&&e.setAttribute(`aria-describedby`,t.id),e.hasAttribute(`tabindex`)||(e.tabIndex=0)}_announce(e){let t=Y(this,ne,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t,n=!1){return this.dispatchEvent(new CustomEvent(e,{bubbles:!0,cancelable:n,detail:t}))}_canLift(e){let t=S(e),n=this.hasAttribute(`readonly`);return n||e.hasAttribute(`data-wui-locked`)?(this._announce((0,a.fillText)(O().lockedText,{card:t})),this._fire(`wui:kanban:locked`,{key:K(e),card:e,reason:n?`readonly`:`locked`},!0),!1):e.getAttribute(`aria-busy`)!==`true`||(this._announce(O().busyMessage),$(O().busyMessage,`info`),!1)}_check(e,t,n){if(t===n)return{ok:!1,source:!0,reason:null};let r=this._columnByKey(t),i=this._columnByKey(n),o=(0,a.fillText)(O().refusedText,{from:r?this._titleOf(r):String(t),to:i?this._titleOf(i):String(n)}),s=i?.getAttribute(`data-accept-from`),c=s?.split(/\s+/).filter(Boolean)??[];if(s!=null&&!c.includes(t))return{ok:!1,reason:o};if(typeof this.accept==`function`){let r=this.accept(e,t,n);if(r===!1)return{ok:!1,reason:o};if(typeof r==`string`&&r)return{ok:!1,reason:r}}return{ok:!0,reason:null}}_markTargets(e,t){let n=S(e),r=new Map;for(let i of this._columns()){let o=G(i),s=this._check(e,t,o);r.set(o,s),i.setAttribute(`data-wui-drop`,s.source?`source`:s.ok?`ok`:`refused`);let c=Y(i,P,HTMLElement);c&&!s.source&&(c.textContent=s.ok?(0,a.fillText)(O().dropHereText,{card:n,column:this._titleOf(i)}):s.reason,c.hidden=!1)}return r}_clearTargets(){for(let e of this._columns()){e.removeAttribute(`data-wui-drop`),e.removeAttribute(`data-wui-over`),e.removeAttribute(`data-wui-target`);let t=Y(e,P,HTMLElement);t&&(t.hidden=!0,t.textContent=``)}}async _commit(e,t,n){let r=this._columnOf(e);if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let i=G(r),o=this._columnByKey(t),s=S(e);if(i===t||!this._canLift(e))return!1;let l=this._check(e,i,t);if(!l.ok)return this._announce(l.reason),$(l.reason,`info`),!1;if(!o)throw Error(`wui-kanban: no column "${String(t)}" on this board.`);let u=this._cardsIn(o),d=Number.isInteger(n)?Math.max(0,Math.min(n??0,u.length)):u.length,f={key:K(e),card:e,from:i,to:t,index:d},p=e.contains(document.activeElement);if(this._controlled())return this._fire(`wui:kanban:move`,f),this._announce((0,a.fillText)(O().movedText,{card:s,column:this._titleOf(o)})),p&&this._refocusSoon(f.key),!0;if(!this._fire(`wui:kanban:move`,f,!0))return!1;let m=o.hasAttribute(R)&&!this._revealed.has(f.key);m&&this._revealed.add(f.key);let h={parent:e.parentNode,next:e.nextSibling,column:r,revealed:m},g=this._bodyOf(o);if(!g)throw Error(`wui-kanban: the target column has no body.`);g.insertBefore(e,u[d]||null),p&&this._focusMoved(e),this.refresh();let _=o.getAttribute(`data-wui-step`);if(_)return this._runStep(e,f,h,_,o.getAttribute(`data-wui-step-size`));let v=this.getAttribute(`move-url`);if(!v)return this._announce((0,a.fillText)(O().movedText,{card:s,column:this._titleOf(o)})),this._fire(`wui:kanban:moved`,{...f,result:null}),!0;this._lock(e,!0),this._announce((0,a.fillText)(O().movingText,{card:s,column:this._titleOf(o)}));let y=new URLSearchParams({card:String(f.key),from:String(i),to:String(t),index:String(d)}),b=await(0,c.wuiFetch)(v,{method:`POST`,body:y});if(this._lock(e,!1),b.kind===`session`)return!1;if(b.ok){let t=this._applyFragment(b.html)||e;return $(b.message,`success`),this._announce((0,a.fillText)(O().movedText,{card:S(t),column:this._titleOf(o)})),this._fire(`wui:kanban:moved`,{...f,card:t,result:b}),!0}return this._rollback(e,h),b.kind!==`aborted`&&$(b.message||ee()[b.kind]||O().serverMessage,`danger`),this._fire(`wui:kanban:failed`,{...f,kind:b.kind,status:b.status,message:b.message}),!1}async _runStep(e,t,n,r,i){let o=S(e),s=this._columnByKey(t.to),l=new URLSearchParams({card:String(t.key),from:String(t.from),to:String(t.to)}).toString(),u=r+(r.includes(`?`)?`&`:`?`)+l;this._lock(e,!0);let d;try{let t=window.WUI?.modal?.load;if(typeof t!=`function`)throw Error(`<wui-kanban> data-wui-step needs the Razor script webority-ui.js (WUI.modal.load).`);d=await(await t(u,{trigger:e,size:i||void 0})).closed}catch(r){return this._lock(e,!1),this._rollback(e,n),le(r)!==`AbortError`&&$(O().serverMessage,`danger`),this._fire(`wui:kanban:failed`,{...t,kind:`step`,status:0,message:ue(r)??null}),!1}if(d?.status!==`success`)return this._lock(e,!1),this._rollback(e,n),this._announce((0,a.fillText)(O().cancelledText,{card:o})),this._fire(`wui:kanban:failed`,{...t,kind:`dismissed`,status:0,message:null}),!1;let f=e,p=this.getAttribute(`card-url`);if(p){let n=await(0,c.wuiFetch)(`${p}${p.includes(`?`)?`&`:`?`}${new URLSearchParams({card:String(t.key)})}`);n.ok&&(f=this._applyFragment(n.html)||e)}if(this._lock(f,!1),!s)throw Error(`wui-kanban: no column "${String(t.to)}" on this board.`);return this._announce((0,a.fillText)(O().movedText,{card:S(f),column:this._titleOf(s)})),this._fire(`wui:kanban:moved`,{...t,card:f,result:d}),!0}_lock(e,t){t?(e.setAttribute(`aria-busy`,`true`),e.setAttribute(`data-wui-saving`,``)):(e.removeAttribute(`aria-busy`),e.removeAttribute(`data-wui-saving`))}_rollback(e,t){let n=e.contains(document.activeElement),r=t.next&&t.next.parentNode===t.parent?t.next:null;if(t.revealed&&this._revealed.delete(K(e)),!t.parent)throw Error(`wui-kanban: the card had no parent to go back to.`);t.parent.insertBefore(e,r),n&&e.focus(),this.refresh(),this._announce((0,a.fillText)(O().rolledBackText,{card:S(e),column:this._titleOf(t.column)}))}_applyFragment(e){if(!e)return null;let t=(0,s.parseServerHtml)(e);for(let e of t.querySelectorAll(`script`))(0,n.devWarn)(`[@webority/ui-elements] A kanban fragment carried a script tag; it was removed, not run.`),e.remove();let r=null;for(let e of X(t,j,HTMLElement)){if(e.closest(`template`))continue;let t=this._cardByKey(K(e));if(!t)continue;let n=t.contains(document.activeElement);t.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),t.hidden&&(e.hidden=!0),t.replaceWith(e),this._prepareCard(e),n&&e.focus(),r??=e}for(let e of X(t,`template[data-wui-kanban-summary]`,HTMLTemplateElement))this._columnByKey(e.getAttribute(`data-wui-kanban-summary`))?.querySelector(N)?.replaceChildren(e.content.cloneNode(!0));return this.refresh(),Q()?.refresh(),r}_refocusSoon(e){let t=()=>{let t=this._cardByKey(e);t&&this._focusMoved(t)};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}_focusMoved(e){e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`nearest`})}_pointerDown(e){if(e.button!==0||e.isPrimary===!1||this._drag||this._kbd)return;let t=J(e.target),n=t?Z(t,j,HTMLElement):null;if(!n||!this.contains(n)||t?.closest(ae))return;let r={card:n,id:e.pointerId,x:e.clientX,y:e.clientY,type:e.pointerType,timer:0};this._press=r,e.pointerType===`touch`&&(r.timer=setTimeout(()=>{this._press===r&&this._startDrag(r,r.x,r.y)},400)),window.addEventListener(`pointermove`,this._onPointerMove),window.addEventListener(`pointerup`,this._onPointerUp),window.addEventListener(`pointercancel`,this._onPointerCancel)}_pointerMove(e){let t=this._press;if(t&&e.pointerId===t.id){if(!this._drag){if(!(Math.hypot(e.clientX-t.x,e.clientY-t.y)>6))return;if(t.type===`touch`){this._endPointer(!1);return}if(this._startDrag(t,e.clientX,e.clientY),!this._drag)return}this._dragTo(e.clientX,e.clientY)}}_pointerUp(e){this._press&&e.pointerId===this._press.id&&this._endPointer(!!this._drag)}_startDrag(e,t,n){let r=e.card;if(!this._canLift(r)){this._endPointer(!1);return}let i=this._columnOf(r);if(!i)throw Error(`wui-kanban: the card is not inside a column.`);let o=G(i),s=r.getBoundingClientRect(),c=r.cloneNode(!0);if(!(c instanceof HTMLElement))return;let l=c;for(let e of[l,...l.querySelectorAll(`[id]`)])e.removeAttribute(`id`);l.removeAttribute(`data-wui-card`),l.removeAttribute(`tabindex`),l.setAttribute(`aria-hidden`,`true`),l.classList.add(`wui-kanban-ghost`),l.style.width=`${s.width}px`,this.appendChild(l),r.setAttribute(`data-wui-dragging`,``),this.setAttribute(`data-wui-dragging`,``),this._drag={card:r,from:o,ghost:l,dx:t-s.left,dy:n-s.top,x:t,y:n,over:null,verdicts:this._markTargets(r,o)},this._announce((0,a.fillText)(O().liftedText,{card:S(r),column:this._titleOf(i)})),document.addEventListener(`keydown`,this._onDocKeyDown),this._dragTo(t,n)}_dragTo(e,t){let n=this._drag;if(!n)throw Error(`wui-kanban: no drag in progress.`);n.x=e,n.y=t,n.ghost.style.transform=`translate(${e-n.dx}px, ${t-n.dy}px)`;let r=this._columnAt(e,t);r!==n.over&&(n.over?.removeAttribute(`data-wui-over`),r?.setAttribute(`data-wui-over`,``),n.over=r),this._autoScroll(e,t,r)}_columnAt(e,t){for(let n of this._columns()){let r=n.getBoundingClientRect();if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom)return n}return null}_indexAt(e,t){let n=this._visibleCardsIn(e).filter(e=>e!==this._drag?.card).find(e=>{let n=e.getBoundingClientRect();return t<n.top+n.height/2}),r=this._cardsIn(e).filter(e=>e!==this._drag?.card);return n?r.indexOf(n):r.length}_autoScroll(e,t,n){let r=this._scroller();if(r){let t=r.getBoundingClientRect();t.width>0&&(e<t.left+U?r.scrollBy?.({left:-16}):e>t.right-U&&r.scrollBy?.({left:W}))}if(n&&this._scrollColumn(n,t))return;let i=window.innerHeight||0;i>0&&(t<U?window.scrollBy?.({top:-16}):t>i-U&&window.scrollBy?.({top:W}))}_scrollColumn(e,t){let n=this._bodyOf(e);if(!n||e.hasAttribute(`data-collapsed`)||n.scrollHeight<=n.clientHeight)return!1;let r=n.getBoundingClientRect();return t<r.top+U&&n.scrollTop>0?(n.scrollBy?.({top:-16}),!0):t>r.bottom-U&&n.scrollTop+n.clientHeight<n.scrollHeight-1&&(n.scrollBy?.({top:W}),!0)}_endPointer(e){let t=this._press,n=this._drag;if(t&&clearTimeout(t.timer||void 0),this._press=null,this._drag=null,window.removeEventListener(`pointermove`,this._onPointerMove),window.removeEventListener(`pointerup`,this._onPointerUp),window.removeEventListener(`pointercancel`,this._onPointerCancel),document.removeEventListener(`keydown`,this._onDocKeyDown),!n)return;n.ghost.remove(),n.card.removeAttribute(`data-wui-dragging`),this.removeAttribute(`data-wui-dragging`),this._suppressClick=!0,setTimeout(()=>{this._suppressClick=!1},0);let r=n.over;if(this._clearTargets(),!e||!r){this._announce((0,a.fillText)(O().cancelledText,{card:S(n.card)}));return}let i=G(r),o=n.verdicts.get(i);o?.source?this._announce((0,a.fillText)(O().cancelledText,{card:S(n.card)})):o?.ok?this._commit(n.card,i,this._indexAt(r,n.y)):(this._announce(o?.reason),$(o?.reason,`info`))}_click(e){let t=J(e.target);if(this._suppressClick&&t?.closest(j)){e.preventDefault(),e.stopPropagation(),this._suppressClick=!1;return}let n=t?.closest(I);if(n&&this.contains(n)){let e=Z(n,k,HTMLElement);e&&this._setCollapsed(e,!e.hasAttribute(`data-collapsed`),!0);return}let r=t?.closest(B);if(r&&this.contains(r)){this._controlled()||this._loadMore(Z(r,k,HTMLElement));return}let i=t?.closest(L);if(i&&this.contains(i)){this._controlled()||this._toggleMore(Z(i,k,HTMLElement));return}let a=t?.closest(F);a&&this.contains(a)&&this._showColumn(a.getAttribute(`data-wui-switch`))}_keyDown(e){let t=this._kbd;if(t){this._liftedKey(e,t);return}let n=e.target instanceof HTMLElement?e.target:null;if(!n?.matches(j)||!this.contains(n))return;let r=this._columnOf(n),i=(0,o.mirrorKey)(e.key,(0,o.isRtl)(this));switch(i){case` `:case`Spacebar`:{if(e.preventDefault(),!this._canLift(n))return;if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let t=G(r),i=this._columns();this._kbd={card:n,from:t,target:i.indexOf(r),verdicts:this._markTargets(n,t)},n.setAttribute(`data-wui-lifted`,``),this.setAttribute(`data-wui-dragging`,``),r.setAttribute(`data-wui-target`,``),this._announce((0,a.fillText)(O().liftedText,{card:S(n),column:this._titleOf(r)}));return}case`ArrowDown`:case`ArrowUp`:{if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let t=this._visibleCardsIn(r),i=t[t.indexOf(n)+(e.key===`ArrowDown`?1:-1)];i&&(e.preventDefault(),i.focus());return}case`ArrowLeft`:case`ArrowRight`:{let t=this._columns(),n=i===`ArrowRight`?1:-1;for(let i=(r?t.indexOf(r):-1)+n;i>=0&&i<t.length;i+=n){let n=t[i],r=n?this._visibleCardsIn(n)[0]:void 0;if(r&&n&&!n.hasAttribute(`data-collapsed`)){e.preventDefault(),r.focus();return}}return}}}_liftedKey(e,t){let n=this._columns(),r=(0,o.mirrorKey)(e.key,(0,o.isRtl)(this));switch(r){case`ArrowLeft`:case`ArrowRight`:{e.preventDefault();let i=t.target+(r===`ArrowRight`?1:-1);if(i<0||i>=n.length)return;n[t.target]?.removeAttribute(`data-wui-target`),t.target=i;let o=n[i];if(!o)return;o.setAttribute(`data-wui-target`,``),this._showColumn(G(o),!1);let s=t.verdicts.get(G(o));if(!s)throw Error(`wui-kanban: no verdict for the column.`);let c=this._titleOf(o);this._announce(s.source?(0,a.fillText)(O().overSourceText,{column:c}):s.ok?(0,a.pluralText)(O(),`overText`,this._cardsIn(o).filter(e=>!q(e)).length,{column:c}):(0,a.fillText)(O().overRefusedText,{column:c,reason:s.reason??``}));return}case` `:case`Spacebar`:case`Enter`:{e.preventDefault();let r=n[t.target];if(!r)throw Error(`wui-kanban: the lifted card has no target column.`);let i=G(r),o=t.verdicts.get(i);if(!o)throw Error(`wui-kanban: no verdict for the column.`);if(!o.source&&!o.ok){this._announce(o.reason);return}this._endKeyboard(),o.source?this._announce((0,a.fillText)(O().cancelledText,{card:S(t.card)})):this._commit(t.card,i);return}case`Escape`:case`Tab`:e.key===`Escape`&&e.preventDefault(),this._endKeyboard(),this._showColumn(t.from,!1),this._announce((0,a.fillText)(O().cancelledText,{card:S(t.card)}));return}}_endKeyboard(){let e=this._kbd;this._kbd=null,e&&(e.card.removeAttribute(`data-wui-lifted`),this.removeAttribute(`data-wui-dragging`),this._clearTargets())}_restoreCollapsed(){let e=w(this.getAttribute(`board-id`));for(let t of this._columns()){let n=G(t);t.hasAttribute(`data-collapsible`)&&Object.hasOwn(e,String(n))&&this._setCollapsed(t,e[String(n)],!1)}}_setCollapsed(e,t,n){let r=G(e);e.toggleAttribute(`data-collapsed`,t);let i=this._titleOf(e);for(let n of e.querySelectorAll(I))n.setAttribute(`aria-expanded`,t?`false`:`true`),n.setAttribute(`aria-label`,t?(0,a.fillText)(O().expandLabel,{title:i}):(0,a.fillText)(O().collapseLabel,{title:i}));n&&(T(this.getAttribute(`board-id`),r,t),this._fire(`wui:kanban:collapse`,{column:r,collapsed:t}))}_toggleMore(e){if(!e)return;let t=G(e);if(this._expanded.delete(t))for(let t of this._cardsIn(e))this._revealed.delete(K(t));else this._expanded.add(t);this.refresh()}_unloadedIn(e){return e.hasAttribute(V)?(e.hasAttribute(H)||e.setAttribute(H,String(Math.max(0,Number(e.getAttribute(oe))-this._cardsIn(e).length))),Number(e.getAttribute(H))):0}async _loadMore(e){if(!e)throw Error(`wui-kanban: the load-more button is outside a column.`);let t=Number(e.getAttribute(H));if(e.hasAttribute(`data-wui-loading`)||!(t>0))return;e.setAttribute(`data-wui-loading`,``);let r=Y(e,B,HTMLButtonElement);r&&(r.disabled=!0,r.textContent=O().loadingLabel);let i=new URL(String(e.getAttribute(V)),document.baseURI);i.searchParams.set(`skip`,String(this._cardsIn(e).length));let a=0,o=!1;try{let n=await(0,c.wuiFetch)(i.toString());if(n.ok){let r=(0,s.parseServerHtml)(n.html),i=this._bodyOf(e);for(let e of[...r.children])if(e.matches(j)&&!this._cardByKey(K(e))){if(!i)throw Error(`wui-kanban: the column has no body.`);i.append(e),a++}let c=n.response?.headers.get(`Wui-Kanban-Remaining`)??``;e.setAttribute(H,String(/^\d+$/.test(c)?Number(c):Math.max(0,t-a))),o=!0}}catch(e){(0,n.devError)(`[@webority/ui-elements] A kanban column could not load its next cards.`,e)}e.removeAttribute(`data-wui-loading`),this.refresh(),o?this._fire(`wui:kanban:loaded`,{key:G(e),added:a}):$(O().loadFailedMessage,`danger`)}_loadOnScroll(e){if(this._controlled()||!e.matches(A))return;let t=Z(e,k,HTMLElement);t?.hasAttribute(V)&&e.scrollTop+e.clientHeight>=e.scrollHeight-se&&this._loadMore(t)}_isPhone(){return typeof matchMedia==`function`&&matchMedia(`(max-width: 767.98px)`).matches}_showColumn(e,t=!0){for(let t of this.querySelectorAll(F))t.getAttribute(`data-wui-switch`)===e?t.setAttribute(`aria-current`,`true`):t.removeAttribute(`aria-current`);let n=this._columnByKey(e),r=this._scroller();if(!n||!r||!t&&!this._isPhone())return;let i=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollTo?.({left:n.offsetLeft-r.offsetLeft,behavior:i?`auto`:`smooth`})}_syncSwitcherFromScroll(){let e=this._scroller();if(!e||!this._isPhone())return;let t=e.clientWidth||1,n=this._columns()[Math.round(e.scrollLeft/t)];if(n)for(let e of this.querySelectorAll(F))e.getAttribute(`data-wui-switch`)===G(n)?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`)}};(0,t.defineElement)(`wui-kanban`,de),e.KANBAN_DRAG_THRESHOLD_PX=g,e.KANBAN_LONG_PRESS_MS=h,e.KANBAN_PHONE_QUERY=m,e.KANBAN_STORAGE_PREFIX=p,e.KANBAN_SUMMARY_FORMATS=f,e.KANBAN_TONES=d,e.WuiKanban=de,e.kanbanCardLabel=S,e.kanbanOverflow=x,e.kanbanStorageKey=C,e.kanbanSummaryFormat=E,e.kanbanVisibleLimit=b,e.readKanbanCollapsed=w,e.sumKanbanValues=D,e.writeKanbanCollapsed=T})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.wuiHttp);
|
|
1
|
+
(function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=globalThis.WeborityUiElementsInternal?.version;if(l!==`0.173.1`)throw Error(`[webority-ui] kanban expects ui-elements 0.173.1 but the page loaded `+l+`.`);var u={ariaLabel:`Board`,busyMessage:`This card is still saving. Try again in a moment.`,cancelledText:`{card} was not moved.`,cardLabel:`Card`,clientMessage:`This card could not be moved. Refresh the board and try again.`,collapseLabel:`Collapse {title}`,columnsLabel:`Board columns`,dropHereText:`Drop here to move {card} to {column}.`,emptyText:`Nothing here`,expandLabel:`Expand {title}`,fewerLabel:`Show fewer`,forbiddenMessage:`You do not have permission to move this card.`,helpText:`Press Space to pick up the card. Use the Left and Right arrow keys to choose a column, then Space to drop it, or Escape to cancel.`,liftedText:`Picked up {card} in {column}. Use the Left and Right arrow keys to choose a column.`,loadFailedMessage:`More cards could not be loaded. Try again.`,loadMoreText:`Show more ({n})`,loadingLabel:`Loading…`,lockedText:`{card} cannot be moved.`,moreText:`Show {count} more`,movedText:`Moved {card} to {column}.`,movingText:`Moving {card} to {column}.`,networkMessage:`Could not reach the server, so the card went back. Check your connection and try again.`,overRefusedText:`{column}. {reason}`,overSourceText:`{column}, where the card started.`,overTextOne:`{column}, 1 card. Drop allowed.`,overTextOther:`{column}, {count} cards. Drop allowed.`,refusedText:`Cards in {from} cannot move to {to}.`,rolledBackText:`{card} went back to {column}.`,serverMessage:`Something went wrong on our side, so the card went back. Try again in a moment.`,swipeHintText:`Swipe sideways or tap a column`},d=Object.freeze([`neutral`,`primary`,`info`,`success`,`warning`,`danger`]),f=Object.freeze([`number`,`currency`,`compact`]),p=`wui-kanban:`,m=`(max-width: 767.98px)`,h=400,g=6,_=()=>(0,a.readText)(`kanban`,u),v=e=>typeof e==`object`&&!!e,y=e=>{let t=v(e)?e.collapsed:void 0;return v(t)?Object.fromEntries(Object.entries(t).map(([e,t])=>[e,!!t])):{}};function b(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);if(!Number.isInteger(t)||t<1)throw TypeError(`Unsupported kanban visible limit "${String(e)}". Use a whole number of 1 or more.`);return t}function x(e,t,n,r){let i=new Set;if(t==null||n)return i;let a=0;for(let n of e)r.has(n)||(a<t?a++:i.add(n));return i}function S(e){let t=(e.getAttribute(`aria-label`)||e.textContent||``).replace(/\s+/g,` `).trim();return t.length>80?`${t.slice(0,79)}…`:t||e.getAttribute(`data-wui-card`)||_().cardLabel}function C(e){return e?`${p}${e}`:null}function w(e,t=globalThis.localStorage){let n=C(e);if(!n||!t)return{};try{return y(JSON.parse(t.getItem(n)||`null`))}catch{return{}}}function T(e,t,n,r=globalThis.localStorage){let i=C(e);if(!i||!r)return;let a={...w(e,r),[String(t)]:!!n};try{r.setItem(i,JSON.stringify({collapsed:a}))}catch(e){if(!(e instanceof DOMException))throw e}}function E(e,t){if(!f.includes(e))throw TypeError(`Unsupported kanban summary format "${String(e)}". Use ${f.join(`, `)}.`);if(t!=null&&t!==``&&!(0,i.isMoneyUnit)(t))throw TypeError(`Unsupported kanban summary unit "${String(t)}". Use ${i.MONEY_UNITS.join(`, `)}.`);return e===`currency`?{style:`currency`,currency:`INR`,unit:t||`rupees`}:e===`compact`?{style:`compact`,currency:`INR`,unit:t||`rupees`}:{style:`number`,decimals:0}}function D(e){let t=0;for(let n of e){if(n==null||n===``)continue;let e=typeof n==`number`?n:Number(n);Number.isFinite(e)&&(t+=e)}return t}var O=()=>(0,a.readText)(`kanban`,u),ee=()=>({forbidden:O().forbiddenMessage,client:O().clientMessage,validation:O().clientMessage,server:O().serverMessage,network:O().networkMessage}),k=`[data-wui-column]`,A=`[data-wui-body]`,j=`[data-wui-card]`,M=`[data-wui-count]`,N=`[data-wui-summary]`,te=`[data-wui-empty]`,P=`[data-wui-drop-note]`,ne=`[data-wui-live]`,re=`[data-wui-help]`,F=`[data-wui-switch]`,ie=`[data-wui-scroller]`,I=`[data-wui-collapse]`,L=`[data-wui-more]`,R=`data-wui-visible-limit`,z=`data-wui-overflow`,ae=`input, select, textarea, [contenteditable=""], [contenteditable="true"], [data-wui-no-drag]`,B=`[data-wui-load-more]`,V=`data-wui-more-url`,oe=`data-wui-total`,H=`data-wui-unloaded`,U=48,W=16,se=160,G=e=>e.getAttribute(`data-wui-column`),K=e=>e.getAttribute(`data-wui-card`),q=e=>e instanceof HTMLElement&&!!e.hidden||e.hasAttribute(`hidden`),ce=e=>q(e)||e.hasAttribute(z),J=e=>e instanceof Element?e:null,le=e=>typeof e==`object`&&e&&`name`in e?e.name:void 0,ue=e=>typeof e==`object`&&e&&`message`in e?e.message:void 0,Y=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},X=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),Z=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Q=()=>window.WUI??null,$=(e,t)=>{e&&Q()?.toast(e,{variant:t})},de=class extends r.ElementBase{constructor(){super(),this._wired=!1,this._filter=null,this._expanded=new Set,this._revealed=new Set,this._press=null,this._drag=null,this._kbd=null,this._suppressClick=!1,this._observer=null,this._refreshQueued=!1,this._scrollTimer=0,this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onPointerCancel=()=>this._endPointer(!1),this._onDocKeyDown=e=>{e.key===`Escape`&&this._drag&&(e.preventDefault(),this._endPointer(!1))},this._onScroll=()=>{clearTimeout(this._scrollTimer),this._scrollTimer=setTimeout(()=>this._syncSwitcherFromScroll(),80)},this.addEventListener(`pointerdown`,e=>this._pointerDown(e)),this.addEventListener(`keydown`,e=>this._keyDown(e)),this.addEventListener(`click`,e=>this._click(e),!0),this.addEventListener(`scroll`,e=>{e.target instanceof Element&&this._loadOnScroll(e.target)},!0),this.addEventListener(`dragstart`,e=>{J(e.target)?.closest(j)&&e.preventDefault()}),this.addEventListener(`touchmove`,e=>{this._drag&&e.preventDefault()},{passive:!1})}_controlled(){return this.hasAttribute(`controlled`)}connectedCallback(){if(!this._wired){this._wired=!0,this._scroller()?.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._restoreCollapsed();for(let e of this._allCards())this._prepareCard(e);if(typeof MutationObserver==`function`){this._observer=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e instanceof HTMLElement&&e.matches(j)&&this._prepareCard(e);this._queueRefresh()});for(let e of this.querySelectorAll(A))this._observer.observe(e,{childList:!0})}this.refresh()}}disconnectedCallback(){this._endPointer(!1),this._observer?.disconnect(),this._observer=null,this._scroller()?.removeEventListener(`scroll`,this._onScroll),clearTimeout(this._scrollTimer),this._wired=!1}setFilter(e){if(e!=null&&typeof e!=`function`)throw TypeError(`wui-kanban setFilter: pass a function or null.`);if(this._filter=e,!e)for(let e of this._allCards())e.hidden=!1;this.refresh()}refresh(){if(this._controlled())return;this._refreshQueued=!1;let e=this._summaryFormat();for(let t of this._columns()){let n=G(t),r=b(t.getAttribute(R)),o=[],s=[];for(let e of this._cardsIn(t))this._filter&&(e.hidden=this._filter(e)===!1),q(e)?e.removeAttribute(z):(o.push(e),s.push(e.getAttribute(`data-wui-value`)));let c=this._expanded.has(n),l=x(o.map(K),r,c,this._revealed);for(let e of o)e.toggleAttribute(z,l.has(K(e)));let u=this._unloadedIn(t),d=String(o.length+u);for(let e of this._countsOf(t))e.textContent!==d&&(e.textContent=d);let f=Y(t,te,HTMLElement);if(f&&(f.hidden=o.length>0),e){let n=t.querySelector(N);n&&(n.textContent=(0,i.formatValue)(D(s),e))}let p=Y(t,L,HTMLElement);if(p){p.hidden=r==null||(c?o.length<=r:l.size===0),p.setAttribute(`aria-expanded`,c?`true`:`false`);let e=c?O().fewerLabel:(0,a.fillText)(O().moreText,{count:l.size});p.textContent!==e&&(p.textContent=e)}let m=Y(t,B,HTMLButtonElement);if(m&&(m.hidden=u<=0,!t.hasAttribute(`data-wui-loading`))){m.disabled=!1;let e=(0,a.fillText)(O().loadMoreText,{n:u});m.textContent!==e&&(m.textContent=e)}}}moveCard(e,t,n){let r=this._cardByKey(e);if(!r)throw Error(`wui-kanban moveCard: no card "${String(e)}" on this board.`);if(!this._columnByKey(t))throw Error(`wui-kanban moveCard: no column "${String(t)}" on this board.`);return this._commit(r,t,n)}_columns(){return X(this,k,HTMLElement)}_columnByKey(e){return this._columns().find(t=>G(t)===e)||null}_columnOf(e){return Z(e,k,HTMLElement)}_titleOf(e){return(e.querySelector(`.wui-kanban-title`)?.textContent||G(e)||``).replace(/\s+/g,` `).trim()}_bodyOf(e){return Y(e,A,HTMLElement)}_cardsIn(e){let t=this._bodyOf(e);return t?[...t.children].filter(e=>e instanceof HTMLElement&&e.matches(j)):[]}_visibleCardsIn(e){return this._cardsIn(e).filter(e=>!ce(e))}_allCards(){return X(this,`${A} > ${j}`,HTMLElement)}_cardByKey(e){return this._allCards().find(t=>K(t)===e)||null}_countsOf(e){let t=G(e),n=[...this.querySelectorAll(F)].filter(e=>e.getAttribute(`data-wui-switch`)===t);return[...e.querySelectorAll(M),...n.flatMap(e=>[...e.querySelectorAll(M)])]}_scroller(){return Y(this,ie,HTMLElement)}_summaryFormat(){let e=this.getAttribute(`summary-format`);return e?E(e,this.getAttribute(`summary-unit`)):null}_queueRefresh(){this._refreshQueued||(this._refreshQueued=!0,queueMicrotask(()=>{this._refreshQueued&&this.refresh()}))}_prepareCard(e){let t=this.querySelector(re);t?.id&&!e.hasAttribute(`aria-describedby`)&&e.setAttribute(`aria-describedby`,t.id),e.hasAttribute(`tabindex`)||(e.tabIndex=0)}_announce(e){let t=Y(this,ne,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t,n=!1){return this.dispatchEvent(new CustomEvent(e,{bubbles:!0,cancelable:n,detail:t}))}_canLift(e){let t=S(e),n=this.hasAttribute(`readonly`);return n||e.hasAttribute(`data-wui-locked`)?(this._announce((0,a.fillText)(O().lockedText,{card:t})),this._fire(`wui:kanban:locked`,{key:K(e),card:e,reason:n?`readonly`:`locked`},!0),!1):e.getAttribute(`aria-busy`)!==`true`||(this._announce(O().busyMessage),$(O().busyMessage,`info`),!1)}_check(e,t,n){if(t===n)return{ok:!1,source:!0,reason:null};let r=this._columnByKey(t),i=this._columnByKey(n),o=(0,a.fillText)(O().refusedText,{from:r?this._titleOf(r):String(t),to:i?this._titleOf(i):String(n)}),s=i?.getAttribute(`data-accept-from`),c=s?.split(/\s+/).filter(Boolean)??[];if(s!=null&&!c.includes(t))return{ok:!1,reason:o};if(typeof this.accept==`function`){let r=this.accept(e,t,n);if(r===!1)return{ok:!1,reason:o};if(typeof r==`string`&&r)return{ok:!1,reason:r}}return{ok:!0,reason:null}}_markTargets(e,t){let n=S(e),r=new Map;for(let i of this._columns()){let o=G(i),s=this._check(e,t,o);r.set(o,s),i.setAttribute(`data-wui-drop`,s.source?`source`:s.ok?`ok`:`refused`);let c=Y(i,P,HTMLElement);c&&!s.source&&(c.textContent=s.ok?(0,a.fillText)(O().dropHereText,{card:n,column:this._titleOf(i)}):s.reason,c.hidden=!1)}return r}_clearTargets(){for(let e of this._columns()){e.removeAttribute(`data-wui-drop`),e.removeAttribute(`data-wui-over`),e.removeAttribute(`data-wui-target`);let t=Y(e,P,HTMLElement);t&&(t.hidden=!0,t.textContent=``)}}async _commit(e,t,n){let r=this._columnOf(e);if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let i=G(r),o=this._columnByKey(t),s=S(e);if(i===t||!this._canLift(e))return!1;let l=this._check(e,i,t);if(!l.ok)return this._announce(l.reason),$(l.reason,`info`),!1;if(!o)throw Error(`wui-kanban: no column "${String(t)}" on this board.`);let u=this._cardsIn(o),d=Number.isInteger(n)?Math.max(0,Math.min(n??0,u.length)):u.length,f={key:K(e),card:e,from:i,to:t,index:d},p=e.contains(document.activeElement);if(this._controlled())return this._fire(`wui:kanban:move`,f),this._announce((0,a.fillText)(O().movedText,{card:s,column:this._titleOf(o)})),p&&this._refocusSoon(f.key),!0;if(!this._fire(`wui:kanban:move`,f,!0))return!1;let m=o.hasAttribute(R)&&!this._revealed.has(f.key);m&&this._revealed.add(f.key);let h={parent:e.parentNode,next:e.nextSibling,column:r,revealed:m},g=this._bodyOf(o);if(!g)throw Error(`wui-kanban: the target column has no body.`);g.insertBefore(e,u[d]||null),p&&this._focusMoved(e),this.refresh();let _=o.getAttribute(`data-wui-step`);if(_)return this._runStep(e,f,h,_,o.getAttribute(`data-wui-step-size`));let v=this.getAttribute(`move-url`);if(!v)return this._announce((0,a.fillText)(O().movedText,{card:s,column:this._titleOf(o)})),this._fire(`wui:kanban:moved`,{...f,result:null}),!0;this._lock(e,!0),this._announce((0,a.fillText)(O().movingText,{card:s,column:this._titleOf(o)}));let y=new URLSearchParams({card:String(f.key),from:String(i),to:String(t),index:String(d)}),b=await(0,c.wuiFetch)(v,{method:`POST`,body:y});if(this._lock(e,!1),b.kind===`session`)return!1;if(b.ok){let t=this._applyFragment(b.html)||e;return $(b.message,`success`),this._announce((0,a.fillText)(O().movedText,{card:S(t),column:this._titleOf(o)})),this._fire(`wui:kanban:moved`,{...f,card:t,result:b}),!0}return this._rollback(e,h),b.kind!==`aborted`&&$(b.message||ee()[b.kind]||O().serverMessage,`danger`),this._fire(`wui:kanban:failed`,{...f,kind:b.kind,status:b.status,message:b.message}),!1}async _runStep(e,t,n,r,i){let o=S(e),s=this._columnByKey(t.to),l=new URLSearchParams({card:String(t.key),from:String(t.from),to:String(t.to)}).toString(),u=r+(r.includes(`?`)?`&`:`?`)+l;this._lock(e,!0);let d;try{let t=window.WUI?.modal?.load;if(typeof t!=`function`)throw Error(`<wui-kanban> data-wui-step needs the Razor script webority-ui.js (WUI.modal.load).`);d=await(await t(u,{trigger:e,size:i||void 0})).closed}catch(r){return this._lock(e,!1),this._rollback(e,n),le(r)!==`AbortError`&&$(O().serverMessage,`danger`),this._fire(`wui:kanban:failed`,{...t,kind:`step`,status:0,message:ue(r)??null}),!1}if(d?.status!==`success`)return this._lock(e,!1),this._rollback(e,n),this._announce((0,a.fillText)(O().cancelledText,{card:o})),this._fire(`wui:kanban:failed`,{...t,kind:`dismissed`,status:0,message:null}),!1;let f=e,p=this.getAttribute(`card-url`);if(p){let n=await(0,c.wuiFetch)(`${p}${p.includes(`?`)?`&`:`?`}${new URLSearchParams({card:String(t.key)})}`);n.ok&&(f=this._applyFragment(n.html)||e)}if(this._lock(f,!1),!s)throw Error(`wui-kanban: no column "${String(t.to)}" on this board.`);return this._announce((0,a.fillText)(O().movedText,{card:S(f),column:this._titleOf(s)})),this._fire(`wui:kanban:moved`,{...t,card:f,result:d}),!0}_lock(e,t){t?(e.setAttribute(`aria-busy`,`true`),e.setAttribute(`data-wui-saving`,``)):(e.removeAttribute(`aria-busy`),e.removeAttribute(`data-wui-saving`))}_rollback(e,t){let n=e.contains(document.activeElement),r=t.next&&t.next.parentNode===t.parent?t.next:null;if(t.revealed&&this._revealed.delete(K(e)),!t.parent)throw Error(`wui-kanban: the card had no parent to go back to.`);t.parent.insertBefore(e,r),n&&e.focus(),this.refresh(),this._announce((0,a.fillText)(O().rolledBackText,{card:S(e),column:this._titleOf(t.column)}))}_applyFragment(e){if(!e)return null;let t=(0,s.parseServerHtml)(e);for(let e of t.querySelectorAll(`script`))(0,n.devWarn)(`[@webority/ui-elements] A kanban fragment carried a script tag; it was removed, not run.`),e.remove();let r=null;for(let e of X(t,j,HTMLElement)){if(e.closest(`template`))continue;let t=this._cardByKey(K(e));if(!t)continue;let n=t.contains(document.activeElement);t.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),t.hidden&&(e.hidden=!0),t.replaceWith(e),this._prepareCard(e),n&&e.focus(),r??=e}for(let e of X(t,`template[data-wui-kanban-summary]`,HTMLTemplateElement))this._columnByKey(e.getAttribute(`data-wui-kanban-summary`))?.querySelector(N)?.replaceChildren(e.content.cloneNode(!0));return this.refresh(),Q()?.refresh(),r}_refocusSoon(e){let t=()=>{let t=this._cardByKey(e);t&&this._focusMoved(t)};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}_focusMoved(e){e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`nearest`})}_pointerDown(e){if(e.button!==0||e.isPrimary===!1||this._drag||this._kbd)return;let t=J(e.target),n=t?Z(t,j,HTMLElement):null;if(!n||!this.contains(n)||t?.closest(ae))return;let r={card:n,id:e.pointerId,x:e.clientX,y:e.clientY,type:e.pointerType,timer:0};this._press=r,e.pointerType===`touch`&&(r.timer=setTimeout(()=>{this._press===r&&this._startDrag(r,r.x,r.y)},400)),window.addEventListener(`pointermove`,this._onPointerMove),window.addEventListener(`pointerup`,this._onPointerUp),window.addEventListener(`pointercancel`,this._onPointerCancel)}_pointerMove(e){let t=this._press;if(t&&e.pointerId===t.id){if(!this._drag){if(!(Math.hypot(e.clientX-t.x,e.clientY-t.y)>6))return;if(t.type===`touch`){this._endPointer(!1);return}if(this._startDrag(t,e.clientX,e.clientY),!this._drag)return}this._dragTo(e.clientX,e.clientY)}}_pointerUp(e){this._press&&e.pointerId===this._press.id&&this._endPointer(!!this._drag)}_startDrag(e,t,n){let r=e.card;if(!this._canLift(r)){this._endPointer(!1);return}let i=this._columnOf(r);if(!i)throw Error(`wui-kanban: the card is not inside a column.`);let o=G(i),s=r.getBoundingClientRect(),c=r.cloneNode(!0);if(!(c instanceof HTMLElement))return;let l=c;for(let e of[l,...l.querySelectorAll(`[id]`)])e.removeAttribute(`id`);l.removeAttribute(`data-wui-card`),l.removeAttribute(`tabindex`),l.setAttribute(`aria-hidden`,`true`),l.classList.add(`wui-kanban-ghost`),l.style.width=`${s.width}px`,this.appendChild(l),r.setAttribute(`data-wui-dragging`,``),this.setAttribute(`data-wui-dragging`,``),this._drag={card:r,from:o,ghost:l,dx:t-s.left,dy:n-s.top,x:t,y:n,over:null,verdicts:this._markTargets(r,o)},this._announce((0,a.fillText)(O().liftedText,{card:S(r),column:this._titleOf(i)})),document.addEventListener(`keydown`,this._onDocKeyDown),this._dragTo(t,n)}_dragTo(e,t){let n=this._drag;if(!n)throw Error(`wui-kanban: no drag in progress.`);n.x=e,n.y=t,n.ghost.style.transform=`translate(${e-n.dx}px, ${t-n.dy}px)`;let r=this._columnAt(e,t);r!==n.over&&(n.over?.removeAttribute(`data-wui-over`),r?.setAttribute(`data-wui-over`,``),n.over=r),this._autoScroll(e,t,r)}_columnAt(e,t){for(let n of this._columns()){let r=n.getBoundingClientRect();if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom)return n}return null}_indexAt(e,t){let n=this._visibleCardsIn(e).filter(e=>e!==this._drag?.card).find(e=>{let n=e.getBoundingClientRect();return t<n.top+n.height/2}),r=this._cardsIn(e).filter(e=>e!==this._drag?.card);return n?r.indexOf(n):r.length}_autoScroll(e,t,n){let r=this._scroller();if(r){let t=r.getBoundingClientRect();t.width>0&&(e<t.left+U?r.scrollBy?.({left:-16}):e>t.right-U&&r.scrollBy?.({left:W}))}if(n&&this._scrollColumn(n,t))return;let i=window.innerHeight||0;i>0&&(t<U?window.scrollBy?.({top:-16}):t>i-U&&window.scrollBy?.({top:W}))}_scrollColumn(e,t){let n=this._bodyOf(e);if(!n||e.hasAttribute(`data-collapsed`)||n.scrollHeight<=n.clientHeight)return!1;let r=n.getBoundingClientRect();return t<r.top+U&&n.scrollTop>0?(n.scrollBy?.({top:-16}),!0):t>r.bottom-U&&n.scrollTop+n.clientHeight<n.scrollHeight-1&&(n.scrollBy?.({top:W}),!0)}_endPointer(e){let t=this._press,n=this._drag;if(t&&clearTimeout(t.timer||void 0),this._press=null,this._drag=null,window.removeEventListener(`pointermove`,this._onPointerMove),window.removeEventListener(`pointerup`,this._onPointerUp),window.removeEventListener(`pointercancel`,this._onPointerCancel),document.removeEventListener(`keydown`,this._onDocKeyDown),!n)return;n.ghost.remove(),n.card.removeAttribute(`data-wui-dragging`),this.removeAttribute(`data-wui-dragging`),this._suppressClick=!0,setTimeout(()=>{this._suppressClick=!1},0);let r=n.over;if(this._clearTargets(),!e||!r){this._announce((0,a.fillText)(O().cancelledText,{card:S(n.card)}));return}let i=G(r),o=n.verdicts.get(i);o?.source?this._announce((0,a.fillText)(O().cancelledText,{card:S(n.card)})):o?.ok?this._commit(n.card,i,this._indexAt(r,n.y)):(this._announce(o?.reason),$(o?.reason,`info`))}_click(e){let t=J(e.target);if(this._suppressClick&&t?.closest(j)){e.preventDefault(),e.stopPropagation(),this._suppressClick=!1;return}let n=t?.closest(I);if(n&&this.contains(n)){let e=Z(n,k,HTMLElement);e&&this._setCollapsed(e,!e.hasAttribute(`data-collapsed`),!0);return}let r=t?.closest(B);if(r&&this.contains(r)){this._controlled()||this._loadMore(Z(r,k,HTMLElement));return}let i=t?.closest(L);if(i&&this.contains(i)){this._controlled()||this._toggleMore(Z(i,k,HTMLElement));return}let a=t?.closest(F);a&&this.contains(a)&&this._showColumn(a.getAttribute(`data-wui-switch`))}_keyDown(e){let t=this._kbd;if(t){this._liftedKey(e,t);return}let n=e.target instanceof HTMLElement?e.target:null;if(!n?.matches(j)||!this.contains(n))return;let r=this._columnOf(n),i=(0,o.mirrorKey)(e.key,(0,o.isRtl)(this));switch(i){case` `:case`Spacebar`:{if(e.preventDefault(),!this._canLift(n))return;if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let t=G(r),i=this._columns();this._kbd={card:n,from:t,target:i.indexOf(r),verdicts:this._markTargets(n,t)},n.setAttribute(`data-wui-lifted`,``),this.setAttribute(`data-wui-dragging`,``),r.setAttribute(`data-wui-target`,``),this._announce((0,a.fillText)(O().liftedText,{card:S(n),column:this._titleOf(r)}));return}case`ArrowDown`:case`ArrowUp`:{if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let t=this._visibleCardsIn(r),i=t[t.indexOf(n)+(e.key===`ArrowDown`?1:-1)];i&&(e.preventDefault(),i.focus());return}case`ArrowLeft`:case`ArrowRight`:{let t=this._columns(),n=i===`ArrowRight`?1:-1;for(let i=(r?t.indexOf(r):-1)+n;i>=0&&i<t.length;i+=n){let n=t[i],r=n?this._visibleCardsIn(n)[0]:void 0;if(r&&n&&!n.hasAttribute(`data-collapsed`)){e.preventDefault(),r.focus();return}}return}}}_liftedKey(e,t){let n=this._columns(),r=(0,o.mirrorKey)(e.key,(0,o.isRtl)(this));switch(r){case`ArrowLeft`:case`ArrowRight`:{e.preventDefault();let i=t.target+(r===`ArrowRight`?1:-1);if(i<0||i>=n.length)return;n[t.target]?.removeAttribute(`data-wui-target`),t.target=i;let o=n[i];if(!o)return;o.setAttribute(`data-wui-target`,``),this._showColumn(G(o),!1);let s=t.verdicts.get(G(o));if(!s)throw Error(`wui-kanban: no verdict for the column.`);let c=this._titleOf(o);this._announce(s.source?(0,a.fillText)(O().overSourceText,{column:c}):s.ok?(0,a.pluralText)(O(),`overText`,this._cardsIn(o).filter(e=>!q(e)).length,{column:c}):(0,a.fillText)(O().overRefusedText,{column:c,reason:s.reason??``}));return}case` `:case`Spacebar`:case`Enter`:{e.preventDefault();let r=n[t.target];if(!r)throw Error(`wui-kanban: the lifted card has no target column.`);let i=G(r),o=t.verdicts.get(i);if(!o)throw Error(`wui-kanban: no verdict for the column.`);if(!o.source&&!o.ok){this._announce(o.reason);return}this._endKeyboard(),o.source?this._announce((0,a.fillText)(O().cancelledText,{card:S(t.card)})):this._commit(t.card,i);return}case`Escape`:case`Tab`:e.key===`Escape`&&e.preventDefault(),this._endKeyboard(),this._showColumn(t.from,!1),this._announce((0,a.fillText)(O().cancelledText,{card:S(t.card)}));return}}_endKeyboard(){let e=this._kbd;this._kbd=null,e&&(e.card.removeAttribute(`data-wui-lifted`),this.removeAttribute(`data-wui-dragging`),this._clearTargets())}_restoreCollapsed(){let e=w(this.getAttribute(`board-id`));for(let t of this._columns()){let n=G(t);t.hasAttribute(`data-collapsible`)&&Object.hasOwn(e,String(n))&&this._setCollapsed(t,e[String(n)],!1)}}_setCollapsed(e,t,n){let r=G(e);e.toggleAttribute(`data-collapsed`,t);let i=this._titleOf(e);for(let n of e.querySelectorAll(I))n.setAttribute(`aria-expanded`,t?`false`:`true`),n.setAttribute(`aria-label`,t?(0,a.fillText)(O().expandLabel,{title:i}):(0,a.fillText)(O().collapseLabel,{title:i}));n&&(T(this.getAttribute(`board-id`),r,t),this._fire(`wui:kanban:collapse`,{column:r,collapsed:t}))}_toggleMore(e){if(!e)return;let t=G(e);if(this._expanded.delete(t))for(let t of this._cardsIn(e))this._revealed.delete(K(t));else this._expanded.add(t);this.refresh()}_unloadedIn(e){return e.hasAttribute(V)?(e.hasAttribute(H)||e.setAttribute(H,String(Math.max(0,Number(e.getAttribute(oe))-this._cardsIn(e).length))),Number(e.getAttribute(H))):0}async _loadMore(e){if(!e)throw Error(`wui-kanban: the load-more button is outside a column.`);let t=Number(e.getAttribute(H));if(e.hasAttribute(`data-wui-loading`)||!(t>0))return;e.setAttribute(`data-wui-loading`,``);let r=Y(e,B,HTMLButtonElement);r&&(r.disabled=!0,r.textContent=O().loadingLabel);let i=new URL(String(e.getAttribute(V)),document.baseURI);i.searchParams.set(`skip`,String(this._cardsIn(e).length));let a=0,o=!1;try{let n=await(0,c.wuiFetch)(i.toString());if(n.ok){let r=(0,s.parseServerHtml)(n.html),i=this._bodyOf(e);for(let e of[...r.children])if(e.matches(j)&&!this._cardByKey(K(e))){if(!i)throw Error(`wui-kanban: the column has no body.`);i.append(e),a++}let c=n.response?.headers.get(`Wui-Kanban-Remaining`)??``;e.setAttribute(H,String(/^\d+$/.test(c)?Number(c):Math.max(0,t-a))),o=!0}}catch(e){(0,n.devError)(`[@webority/ui-elements] A kanban column could not load its next cards.`,e)}e.removeAttribute(`data-wui-loading`),this.refresh(),o?this._fire(`wui:kanban:loaded`,{key:G(e),added:a}):$(O().loadFailedMessage,`danger`)}_loadOnScroll(e){if(this._controlled()||!e.matches(A))return;let t=Z(e,k,HTMLElement);t?.hasAttribute(V)&&e.scrollTop+e.clientHeight>=e.scrollHeight-se&&this._loadMore(t)}_isPhone(){return typeof matchMedia==`function`&&matchMedia(`(max-width: 767.98px)`).matches}_showColumn(e,t=!0){for(let t of this.querySelectorAll(F))t.getAttribute(`data-wui-switch`)===e?t.setAttribute(`aria-current`,`true`):t.removeAttribute(`aria-current`);let n=this._columnByKey(e),r=this._scroller();if(!n||!r||!t&&!this._isPhone())return;let i=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollTo?.({left:n.offsetLeft-r.offsetLeft,behavior:i?`auto`:`smooth`})}_syncSwitcherFromScroll(){let e=this._scroller();if(!e||!this._isPhone())return;let t=e.clientWidth||1,n=this._columns()[Math.round(e.scrollLeft/t)];if(n)for(let e of this.querySelectorAll(F))e.getAttribute(`data-wui-switch`)===G(n)?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`)}};(0,t.defineElement)(`wui-kanban`,de),e.KANBAN_DRAG_THRESHOLD_PX=g,e.KANBAN_LONG_PRESS_MS=h,e.KANBAN_PHONE_QUERY=m,e.KANBAN_STORAGE_PREFIX=p,e.KANBAN_SUMMARY_FORMATS=f,e.KANBAN_TONES=d,e.WuiKanban=de,e.kanbanCardLabel=S,e.kanbanOverflow=x,e.kanbanStorageKey=C,e.kanbanSummaryFormat=E,e.kanbanVisibleLimit=b,e.readKanbanCollapsed=w,e.sumKanbanValues=D,e.writeKanbanCollapsed=T})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.wuiHttp);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.173.
|
|
1
|
+
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.173.1`)throw Error(`[webority-ui] lead-popup expects ui-elements 0.173.1 but the page loaded `+o+`.`);var s={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-soft":`#E0E7FF`,"--color-primary-text":`#4F46E5`,"--color-on-primary":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-border-strong":`#C4CADA`,"--color-surface":`#FFFFFF`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-modal":`0px 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-modal":`1505`},c=e=>`var(${e}, ${s[e]})`,l=`
|
|
2
2
|
:host {
|
|
3
3
|
all: initial;
|
|
4
4
|
display: contents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=globalThis.WeborityUiElementsInternal?.version;if(l!==`0.173.0`)throw Error(`[webority-ui] lightbox expects ui-elements 0.173.0 but the page loaded `+l+`.`);var u={closeLabel:`Close`,countText:`{position} of {total}`,downloadLabel:`Download`,imageFailedMessage:`This image can't be shown.`,label:`Image viewer`,nextImageLabel:`Next image`,previousImageLabel:`Previous image`,zoomInLabel:`Zoom in`,zoomOutLabel:`Zoom out`},d=`a.wui-lightbox-item`,f=1,p=4,m=.5,h=2,g=50,_=6,v=300,y=300;function b(e){return Number.isFinite(e)?Math.min(p,Math.max(f,e)):f}function x(e,t,n,r){let i=(e,n)=>Math.max(0,(e*t-n)/2),a=i(r.width,n.width),o=i(r.height,n.height);return{x:Math.min(a,Math.max(-a,e.x)),y:Math.min(o,Math.max(-o,e.y))}}function S(e,t){return Math.abs(e)<g||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function C(e){let t=(String(e??``).split(/[?#]/)[0]??``).split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var w=()=>(0,c.readText)(`lightbox`,u);function T(e,t,r){let i=(0,n.make)(`button`,{class:`u-action wui-lightbox-btn ${r}`,type:`button`,"aria-label":t,title:t});i.style.setProperty(`--wui-action-size`,`40px`);let o=(0,a.glyphNode)(e,{size:20});return i.replaceChildren(...o?[o]:[]),i}var E=class extends r.ElementBase{_ui;_index;_zoom;_pan;_pointers;_gesture;_lastTap;_returnTo;_release;_onClick;static get observedAttributes(){return[`open-index`]}constructor(){super(),this._ui=null,this._index=0,this._zoom=f,this._pan={x:0,y:0},this._pointers=new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._release=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target,n=t instanceof Element?t.closest(d):null;if(!(n instanceof HTMLAnchorElement)||!this.contains(n))return;let r=this._links().indexOf(n);r<0||(e.preventDefault(),this.open(r))}}get _view(){if(!this._ui)throw Error(`<wui-lightbox> viewer is not open.`);return this._ui}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||w().label}set label(e){this.setAttribute(`label`,String(e??``))}get layout(){return this.getAttribute(`layout`)===`single`?`single`:`gallery`}set layout(e){if(e===`single`)this.setAttribute(`layout`,`single`);else if(e===`gallery`||e===``)this.removeAttribute(`layout`);else throw Error(`<wui-lightbox> layout must be "gallery" or "single", received "${e}".`)}get isOpen(){return this._ui!==null}connectedCallback(){this.addEventListener(`click`,this._onClick),this._syncOpenIndex()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this._teardown()}attributeChangedCallback(){this.isConnected&&this._syncOpenIndex()}_syncOpenIndex(){let e=this.getAttribute(`open-index`);e===null?this.close():this.open(Number(e))}_links(){return[...this.querySelectorAll(d)].filter(e=>e instanceof HTMLAnchorElement)}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||C(t)}})}open(e=0){let t=this._items();if(!t.length)return!1;if(!this._ui){let t=document.activeElement;this._returnTo=t instanceof HTMLElement||t instanceof SVGElement?t:null,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))}return this._show(e,t),!0}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._release?.(),this._release=null,this._ui.root.open&&this._ui.root.close(),this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null)}_build(){let e=(0,n.make)(`dialog`,{class:`wui-lightbox-overlay`,role:`dialog`,"aria-label":this.label,tabindex:`-1`}),t=(0,n.make)(`div`,{class:`wui-lightbox-bar`}),r=(0,n.make)(`span`,{class:`wui-lightbox-count`,"aria-live":`polite`}),i=(0,n.make)(`div`,{class:`wui-lightbox-tools`}),s=T(`zoom-out`,w().zoomOutLabel,`wui-lightbox-zoom-out`),c=T(`zoom-in`,w().zoomInLabel,`wui-lightbox-zoom-in`),l=(0,n.make)(`a`,{class:`u-action wui-lightbox-btn wui-lightbox-download`,"aria-label":w().downloadLabel,title:w().downloadLabel});l.style.setProperty(`--wui-action-size`,`40px`);let u=(0,a.glyphNode)(`download`,{size:20});l.replaceChildren(...u?[u]:[]),l.hidden=!this.download;let d=T(`x`,w().closeLabel,`wui-lightbox-close`);i.append(s,c,l,d),t.append(r,i);let f=(0,n.make)(`div`,{class:`wui-lightbox-stage`}),p=T(`chevron-left`,w().previousImageLabel,`wui-lightbox-nav wui-lightbox-prev`),h=T(`chevron-right`,w().nextImageLabel,`wui-lightbox-nav wui-lightbox-next`),g=(0,n.make)(`img`,{class:`wui-lightbox-image`,decoding:`async`,draggable:`false`,alt:``}),_=(0,n.make)(`p`,{class:`wui-lightbox-status`,role:`status`});f.append(g,_,p,h);let v=(0,n.make)(`p`,{class:`wui-lightbox-caption`});e.append(t,f,v);let y={root:e,count:r,zoomOut:s,zoomIn:c,download:l,close:d,stage:f,prev:p,next:h,image:g,status:_,caption:v};this._ui=y,d.addEventListener(`click`,()=>this.close()),p.addEventListener(`click`,()=>this.step(-1)),h.addEventListener(`click`,()=>this.step(1)),s.addEventListener(`click`,()=>this._setZoom(this._zoom-m)),c.addEventListener(`click`,()=>this._setZoom(this._zoom+m)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),f.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),f.addEventListener(`pointermove`,e=>this._onPointerMove(e)),f.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),f.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),f.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),g.addEventListener(`load`,()=>{this._ui===y&&(_.textContent=``,f.removeAttribute(`aria-busy`),g.hidden=!1,this._applyTransform())}),g.addEventListener(`error`,()=>{this._ui===y&&(f.removeAttribute(`aria-busy`),g.hidden=!0,_.textContent=w().imageFailedMessage)}),this.append(e),this._release=(0,o.openModalDialog)(e,{escape:!0,backdrop:!1,focus:`panel`,onRequestClose:()=>this.close()})}step(e){if(!this._ui||!e)return;let t=this._items();t.length<2||this._show((this._index+e+t.length)%t.length,t)}_show(e,t){let n=this._view,r=Math.min(t.length-1,Math.max(0,Math.trunc(Number(e))||0)),a=t[r];if(!a)throw Error(`<wui-lightbox> image missing.`);let o=r!==this._index||!n.image.getAttribute(`src`);if(this._index=r,this._zoom=f,this._pan={x:0,y:0},n.count.textContent=(0,c.fillText)(w().countText,{position:(0,i.formatNumber)(r+1,{decimals:0}),total:(0,i.formatNumber)(t.length,{decimals:0})}),n.caption.textContent=a.caption,n.caption.hidden=!a.caption,n.download.href=a.src,n.download.setAttribute(`download`,a.name),n.prev.hidden=n.next.hidden=t.length<2,n.stage.setAttribute(`aria-busy`,`true`),n.status.textContent=``,n.image.hidden=!1,n.image.alt=a.alt||a.caption,n.image.src=a.src,this._applyTransform(),this._syncZoomButtons(),t.length>1){let e=t[(r+1)%t.length],n=t[(r-1+t.length)%t.length];if(!e||!n)throw Error(`<wui-lightbox> neighbour image missing.`);for(let t of[e,n])new Image().src=t.src}o&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:r}}))}_syncZoomButtons(){let e=this._view;e.zoomOut.disabled=this._zoom<=f,e.zoomIn.disabled=this._zoom>=p;let t=document.activeElement;(t===e.zoomOut||t===e.zoomIn)&&t instanceof HTMLButtonElement&&t.disabled&&e.close.focus()}_setZoom(e){this._ui&&(this._zoom=b(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._view;return x(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._view;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>f)}_onKeyDown(e){let t=(0,s.mirrorKey)(e.key,(0,s.isRtl)(this));if(t===`ArrowLeft`||t===`ArrowRight`)e.preventDefault(),this.step(t===`ArrowRight`?1:-1);else if(e.key===`Home`||e.key===`End`){e.preventDefault();let t=this._items();this._show(e.key===`Home`?0:t.length-1,t)}else e.key===`+`||e.key===`=`?(e.preventDefault(),this._setZoom(this._zoom+m)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-m)):e.key===`0`&&(e.preventDefault(),this._setZoom(f))}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){let t=e.target;if(t instanceof Element&&t.closest(`.wui-lightbox-nav`))return;let n=this._view;if(n.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let e=[...this._pointers.values()],t=e[0],n=e[1];if(!t||!n)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._gesture={kind:`pinch`,distance:Math.hypot(t.x-n.x,t.y-n.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===n.image,moved:!1})}_onPointerMove(e){let t=this._gesture;if(t&&this._pointers.has(e.pointerId)){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let e=[...this._pointers.values()],n=e[0],r=e[1];if(!n||!r)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._setZoom(t.zoom*Math.hypot(n.x-r.x,n.y-r.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>_&&(t.moved=!0),this._zoom>f&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._view.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,i=e.clientY-n.startY;n.moved?this._zoom===f&&this.step(S(r,i)):e.timeStamp-n.startTime>v||(n.onImage?e.timeStamp-this._lastTap<y?(this._lastTap=-1/0,this._setZoom(this._zoom>f?f:h)):this._lastTap=e.timeStamp:this.close())}};(0,t.defineElement)(`wui-lightbox`,E),e.WuiLightbox=E})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore);
|
|
1
|
+
(function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=globalThis.WeborityUiElementsInternal?.version;if(l!==`0.173.1`)throw Error(`[webority-ui] lightbox expects ui-elements 0.173.1 but the page loaded `+l+`.`);var u={closeLabel:`Close`,countText:`{position} of {total}`,downloadLabel:`Download`,imageFailedMessage:`This image can't be shown.`,label:`Image viewer`,nextImageLabel:`Next image`,previousImageLabel:`Previous image`,zoomInLabel:`Zoom in`,zoomOutLabel:`Zoom out`},d=`a.wui-lightbox-item`,f=1,p=4,m=.5,h=2,g=50,_=6,v=300,y=300;function b(e){return Number.isFinite(e)?Math.min(p,Math.max(f,e)):f}function x(e,t,n,r){let i=(e,n)=>Math.max(0,(e*t-n)/2),a=i(r.width,n.width),o=i(r.height,n.height);return{x:Math.min(a,Math.max(-a,e.x)),y:Math.min(o,Math.max(-o,e.y))}}function S(e,t){return Math.abs(e)<g||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function C(e){let t=(String(e??``).split(/[?#]/)[0]??``).split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var w=()=>(0,c.readText)(`lightbox`,u);function T(e,t,r){let i=(0,n.make)(`button`,{class:`u-action wui-lightbox-btn ${r}`,type:`button`,"aria-label":t,title:t});i.style.setProperty(`--wui-action-size`,`40px`);let o=(0,a.glyphNode)(e,{size:20});return i.replaceChildren(...o?[o]:[]),i}var E=class extends r.ElementBase{_ui;_index;_zoom;_pan;_pointers;_gesture;_lastTap;_returnTo;_release;_onClick;static get observedAttributes(){return[`open-index`]}constructor(){super(),this._ui=null,this._index=0,this._zoom=f,this._pan={x:0,y:0},this._pointers=new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._release=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target,n=t instanceof Element?t.closest(d):null;if(!(n instanceof HTMLAnchorElement)||!this.contains(n))return;let r=this._links().indexOf(n);r<0||(e.preventDefault(),this.open(r))}}get _view(){if(!this._ui)throw Error(`<wui-lightbox> viewer is not open.`);return this._ui}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||w().label}set label(e){this.setAttribute(`label`,String(e??``))}get layout(){return this.getAttribute(`layout`)===`single`?`single`:`gallery`}set layout(e){if(e===`single`)this.setAttribute(`layout`,`single`);else if(e===`gallery`||e===``)this.removeAttribute(`layout`);else throw Error(`<wui-lightbox> layout must be "gallery" or "single", received "${e}".`)}get isOpen(){return this._ui!==null}connectedCallback(){this.addEventListener(`click`,this._onClick),this._syncOpenIndex()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this._teardown()}attributeChangedCallback(){this.isConnected&&this._syncOpenIndex()}_syncOpenIndex(){let e=this.getAttribute(`open-index`);e===null?this.close():this.open(Number(e))}_links(){return[...this.querySelectorAll(d)].filter(e=>e instanceof HTMLAnchorElement)}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||C(t)}})}open(e=0){let t=this._items();if(!t.length)return!1;if(!this._ui){let t=document.activeElement;this._returnTo=t instanceof HTMLElement||t instanceof SVGElement?t:null,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))}return this._show(e,t),!0}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._release?.(),this._release=null,this._ui.root.open&&this._ui.root.close(),this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null)}_build(){let e=(0,n.make)(`dialog`,{class:`wui-lightbox-overlay`,role:`dialog`,"aria-label":this.label,tabindex:`-1`}),t=(0,n.make)(`div`,{class:`wui-lightbox-bar`}),r=(0,n.make)(`span`,{class:`wui-lightbox-count`,"aria-live":`polite`}),i=(0,n.make)(`div`,{class:`wui-lightbox-tools`}),s=T(`zoom-out`,w().zoomOutLabel,`wui-lightbox-zoom-out`),c=T(`zoom-in`,w().zoomInLabel,`wui-lightbox-zoom-in`),l=(0,n.make)(`a`,{class:`u-action wui-lightbox-btn wui-lightbox-download`,"aria-label":w().downloadLabel,title:w().downloadLabel});l.style.setProperty(`--wui-action-size`,`40px`);let u=(0,a.glyphNode)(`download`,{size:20});l.replaceChildren(...u?[u]:[]),l.hidden=!this.download;let d=T(`x`,w().closeLabel,`wui-lightbox-close`);i.append(s,c,l,d),t.append(r,i);let f=(0,n.make)(`div`,{class:`wui-lightbox-stage`}),p=T(`chevron-left`,w().previousImageLabel,`wui-lightbox-nav wui-lightbox-prev`),h=T(`chevron-right`,w().nextImageLabel,`wui-lightbox-nav wui-lightbox-next`),g=(0,n.make)(`img`,{class:`wui-lightbox-image`,decoding:`async`,draggable:`false`,alt:``}),_=(0,n.make)(`p`,{class:`wui-lightbox-status`,role:`status`});f.append(g,_,p,h);let v=(0,n.make)(`p`,{class:`wui-lightbox-caption`});e.append(t,f,v);let y={root:e,count:r,zoomOut:s,zoomIn:c,download:l,close:d,stage:f,prev:p,next:h,image:g,status:_,caption:v};this._ui=y,d.addEventListener(`click`,()=>this.close()),p.addEventListener(`click`,()=>this.step(-1)),h.addEventListener(`click`,()=>this.step(1)),s.addEventListener(`click`,()=>this._setZoom(this._zoom-m)),c.addEventListener(`click`,()=>this._setZoom(this._zoom+m)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),f.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),f.addEventListener(`pointermove`,e=>this._onPointerMove(e)),f.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),f.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),f.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),g.addEventListener(`load`,()=>{this._ui===y&&(_.textContent=``,f.removeAttribute(`aria-busy`),g.hidden=!1,this._applyTransform())}),g.addEventListener(`error`,()=>{this._ui===y&&(f.removeAttribute(`aria-busy`),g.hidden=!0,_.textContent=w().imageFailedMessage)}),this.append(e),this._release=(0,o.openModalDialog)(e,{escape:!0,backdrop:!1,focus:`panel`,onRequestClose:()=>this.close()})}step(e){if(!this._ui||!e)return;let t=this._items();t.length<2||this._show((this._index+e+t.length)%t.length,t)}_show(e,t){let n=this._view,r=Math.min(t.length-1,Math.max(0,Math.trunc(Number(e))||0)),a=t[r];if(!a)throw Error(`<wui-lightbox> image missing.`);let o=r!==this._index||!n.image.getAttribute(`src`);if(this._index=r,this._zoom=f,this._pan={x:0,y:0},n.count.textContent=(0,c.fillText)(w().countText,{position:(0,i.formatNumber)(r+1,{decimals:0}),total:(0,i.formatNumber)(t.length,{decimals:0})}),n.caption.textContent=a.caption,n.caption.hidden=!a.caption,n.download.href=a.src,n.download.setAttribute(`download`,a.name),n.prev.hidden=n.next.hidden=t.length<2,n.stage.setAttribute(`aria-busy`,`true`),n.status.textContent=``,n.image.hidden=!1,n.image.alt=a.alt||a.caption,n.image.src=a.src,this._applyTransform(),this._syncZoomButtons(),t.length>1){let e=t[(r+1)%t.length],n=t[(r-1+t.length)%t.length];if(!e||!n)throw Error(`<wui-lightbox> neighbour image missing.`);for(let t of[e,n])new Image().src=t.src}o&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:r}}))}_syncZoomButtons(){let e=this._view;e.zoomOut.disabled=this._zoom<=f,e.zoomIn.disabled=this._zoom>=p;let t=document.activeElement;(t===e.zoomOut||t===e.zoomIn)&&t instanceof HTMLButtonElement&&t.disabled&&e.close.focus()}_setZoom(e){this._ui&&(this._zoom=b(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._view;return x(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._view;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>f)}_onKeyDown(e){let t=(0,s.mirrorKey)(e.key,(0,s.isRtl)(this));if(t===`ArrowLeft`||t===`ArrowRight`)e.preventDefault(),this.step(t===`ArrowRight`?1:-1);else if(e.key===`Home`||e.key===`End`){e.preventDefault();let t=this._items();this._show(e.key===`Home`?0:t.length-1,t)}else e.key===`+`||e.key===`=`?(e.preventDefault(),this._setZoom(this._zoom+m)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-m)):e.key===`0`&&(e.preventDefault(),this._setZoom(f))}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){let t=e.target;if(t instanceof Element&&t.closest(`.wui-lightbox-nav`))return;let n=this._view;if(n.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let e=[...this._pointers.values()],t=e[0],n=e[1];if(!t||!n)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._gesture={kind:`pinch`,distance:Math.hypot(t.x-n.x,t.y-n.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===n.image,moved:!1})}_onPointerMove(e){let t=this._gesture;if(t&&this._pointers.has(e.pointerId)){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let e=[...this._pointers.values()],n=e[0],r=e[1];if(!n||!r)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._setZoom(t.zoom*Math.hypot(n.x-r.x,n.y-r.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>_&&(t.moved=!0),this._zoom>f&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._view.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,i=e.clientY-n.startY;n.moved?this._zoom===f&&this.step(S(r,i)):e.timeStamp-n.startTime>v||(n.onImage?e.timeStamp-this._lastTap<y?(this._lastTap=-1/0,this._setZoom(this._zoom>f?f:h)):this._lastTap=e.timeStamp:this.close())}};(0,t.defineElement)(`wui-lightbox`,E),e.WuiLightbox=E})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.173.
|
|
1
|
+
(function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.173.1`)throw Error(`[webority-ui] markdown expects ui-elements 0.173.1 but the page loaded `+i+`.`);var a=/\[([^[\]\n]+)\](?!\()/g,o=new Set(`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`),s=/\[([^\]\n]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,c=/!\[([^\]\n]*)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,l=new RegExp(a.source,`y`),u=e=>/[\p{L}\p{N}]/u.test(e);function d(e,t){let n=0;for(let r=t-1;r>=0&&e.charAt(r)===`\\`;--r)n+=1;return n%2==1}function f(e,t,n){let r=n.length===1;for(let i=e.indexOf(n,t);i!==-1;i=e.indexOf(n,i+1)){let a=i>t&&!/\s/.test(e.charAt(t))&&!/\s/.test(e.charAt(i-1)),o=r&&(e.charAt(i+1)===n||e.charAt(i-1)===n),s=n===`_`&&u(e.charAt(i+n.length));if(a&&!o&&!s&&!d(e,i))return i}return-1}function p(e,t){let n=t?.isCitation,r=[],i=``,a=()=>{i&&=(r.push({type:`text`,text:i}),``)},d=0;for(;d<e.length;){let m=e.charAt(d),h=e.charAt(d+1);if(m===`\\`&&o.has(h)){i+=h,d+=2;continue}if(m==="`"){let t=e.indexOf("`",d+1);if(t>d+1){a(),r.push({type:`code`,text:e.slice(d+1,t)}),d=t+1;continue}}let g=m+h;if(g===`**`||g===`__`||g===`~~`){let n=f(e,d+2,g);if(n!==-1&&!(g===`__`&&u(e.charAt(d-1)))){a();let i=p(e.slice(d+2,n),t);g===`~~`?r.push({type:`strike`,children:i}):r.push({type:`strong`,children:i}),d=n+2;continue}i+=g,d+=2}else{if(m===`*`||m===`_`){let n=f(e,d+1,m);if(n!==-1&&!(m===`_`&&u(e.charAt(d-1)))){a(),r.push({type:`em`,children:p(e.slice(d+1,n),t)}),d=n+1;continue}}if(m===`[`){s.lastIndex=d;let t=s.exec(e);if(t){let e=t[1],n=t[2];if(e===void 0||n===void 0)throw Error(`The link pattern always captures its label and href`);a(),r.push({type:`link`,href:n,children:p(e)}),d+=t[0].length;continue}if(n){l.lastIndex=d;let t=l.exec(e);if(t){let e=t[1];if(e===void 0)throw Error(`The citation pattern always captures its inner text`);if(n(e)){a(),r.push({type:`citation`,text:e}),d+=t[0].length;continue}}}}if(m===`!`){c.lastIndex=d;let t=c.exec(e);if(t){let e=t[1];if(e===void 0)throw Error(`The image pattern always captures its alt text`);a(),r.push({type:`image`,children:p(e)}),d+=t[0].length;continue}}i+=m,d+=1}}return a(),r.map((e,t)=>({...e,key:t}))}var m=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,h=/^https?:/i,g=/^(mailto|tel):/i,_=/^(?:\/(?![/\\])|#|\?|\.{1,2}\/)/,v=/^https:\/\/[^/?#@\\\s]+$/i,ee=/^[a-z][a-z0-9+.-]*:/i;function te(e){if(typeof e!=`string`)return null;let t=e.endsWith(`/`)?e.slice(0,-1):e;return v.test(t)?t:null}function y(e,t,n,r,i){if(n&&(t===`page`||m.test(e))){let t=n(e);if(t!=null)return{kind:`app`,target:t}}if(t===`app`)return null;let a=i==null?null:te(i),o=a===null?e:b(e,a);return o===null?null:_.test(o)?{kind:`page`,href:o}:t===`page`&&!(h.test(o)&&r&&S(o,r))?null:h.test(o)?{kind:r&&S(o,r)?`page`:`web`,href:o}:g.test(o)?{kind:`contact`,href:o}:null}function b(e,t){if(ee.test(e))return e;if(e.startsWith(`//`))return`https:${e}`;if(e===``)return null;let n=e.indexOf(`#`),r=n<0?``:e.slice(n),i=n<0?e:e.slice(0,n),a=i.indexOf(`?`),o=a<0?i:i.slice(0,a),s=a<0?``:i.slice(a);return o===``?`${t}${s}${r}`:`${t}${x(o.startsWith(`/`)?o:`/${o}`)}${s}${r}`}function x(e){let t=e.split(`/`),n=[];return t.forEach((e,r)=>{let i=r===t.length-1;e===`.`?i&&n.push(``):e===`..`?(n.length>1&&n.pop(),i&&n.push(``)):n.push(e)}),n.join(`/`)}function S(e,t){if(e.slice(0,t.length).toLowerCase()!==t.toLowerCase())return!1;let n=e[t.length];return n===void 0||n===`/`||n===`?`||n===`#`}function ne(e){return typeof e!=`string`||!e.startsWith(`/`)||e[1]===`/`||e[1]===`\\`?null:e}var C=/^\s*```/,w=/^\s*```\s*(\S*)/,T=/^\s{0,3}(#{1,6})\s+(.*?)(?:\s+#+)?\s*$/,E=/^\s*([-*_])(\s*\1){2,}\s*$/,D=/^(\s*)[-*+]\s+(.*)$/,O=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,k=/^\s*>\s?(.*)$/,A=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,j=[1,2,3,4,5,6],M=e=>e.includes(`|`);function N(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function P(e,t){let n=e[t];if(n===void 0)throw Error(`startsTable was called past the last source line`);let r=e[t+1];return r!==void 0&&M(n)&&r.includes(`|`)&&A.test(r)}function F(e,t){let n=e[t];if(n===void 0)throw Error(`startsBlock was called past the last source line`);return C.test(n)||k.test(n)||D.test(n)||O.test(n)||T.test(n)||E.test(n)||P(e,t)}function I(e){let t=e.replace(/\t/g,` `).length;return Math.min(Math.floor(t/2),4)}function L(e){let t=O.exec(e);if(t){let e=t[1],n=t[2],r=t[3];if(e===void 0||n===void 0||r===void 0)throw Error(`The ordered list pattern always captures its indent, number and text`);return{text:r,depth:I(e),ordered:!0,number:Number(n)}}let n=D.exec(e);if(n){let e=n[1],t=n[2];if(e===void 0||t===void 0)throw Error(`The bullet list pattern always captures its indent and text`);return{text:t,depth:I(e),ordered:!1,number:0}}return null}function R(e){let t=(e??``).replace(/\r\n?/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()){r+=1;continue}if(C.test(e)){let i=w.exec(e)?.[1]||null,a=[];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(C.test(e))break;a.push(e),r+=1}r+=1,n.push({type:`code`,text:a.join(`
|
|
4
4
|
`),language:i});continue}if(P(t,r)){let i=N(e),a=[];for(r+=2;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||!M(e))break;a.push(N(e)),r+=1}n.push({type:`table`,header:i,rows:a});continue}if(E.test(e)){n.push({type:`rule`}),r+=1;continue}let i=T.exec(e);if(i){let e=i[1],t=i[2];if(e===void 0||t===void 0)throw Error(`The heading pattern always captures its hashes and text`);let a=j[e.length-1];if(a===void 0)throw Error(`The heading pattern always captures one to six hashes`);n.push({type:`heading`,level:a,text:t}),r+=1;continue}if(k.test(e)){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);let i=k.exec(n);if(!i)break;let a=i[1];if(a===void 0)throw Error(`The quote pattern always captures its text`);e.push(a),r+=1}n.push({type:`quote`,lines:e});continue}let a=L(e);if(a){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);if(!n.trim())break;let i=L(n);if(i){if(i.depth===0&&i.ordered!==a.ordered)break;e.push(i)}else if(F(t,r))break;else{let t=e[e.length-1];if(t===void 0)throw Error(`A list continuation line follows a list with no item`);t.text+=` ${n.trim()}`}r+=1}n.push({type:`list`,ordered:a.ordered,start:a.ordered?a.number:1,items:e});continue}let o=[e];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||F(t,r))break;o.push(e),r+=1}n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var z=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`],B=[`razor`,`cshtml`],V=[`app`,`web`,`page`],H=e=>e!==void 0&&V.includes(e);function U(e,t,n,r,i=null){let a=W(n,r).map((e,n)=>{let r=t[n],i=r?.sig===e.sig?r.nodes:null;return{sig:e.sig,nodes:i??e.build()}}),o=new Set(a.flatMap(e=>e.nodes));for(let e of t)for(let t of e.nodes)o.has(t)||t.parentNode?.removeChild(t);let s=i;for(let t of a.flatMap(e=>e.nodes))(t.parentNode!==e||t.previousSibling!==s)&&e.insertBefore(t,s?s.nextSibling:e.firstChild),s=t;return a}function W(e,t){let n={links:H(t.links)?t.links:`web`,headings:t.headings===`text`?`text`:`outline`,resolveLink:t.resolveLink,isCitation:t.isCitation,figureText:typeof t.figureText==`function`?t.figureText:void 0,base:typeof t.base==`string`?t.base:void 0},r=t.resolverGeneration??0;return R(e).map(e=>({sig:`${JSON.stringify(e)}|${n.links}|${n.headings}|${n.base??``}|${r}`,build:()=>K(n,e)}))}var G=class extends r.ElementBase{_drawn;_blocks;_observer;_connected;_resolveLink;_isCitation;_resolverGeneration;_figureText;static get observedAttributes(){return[`links`,`headings`,`base`]}constructor(){super(),this._drawn=[],this._blocks=[],this._observer=null,this._connected=!1,this._resolveLink=void 0,this._isCitation=void 0,this._resolverGeneration=0,this._figureText=void 0}connectedCallback(){this._connected=!0,this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._drawn.some(t=>t.contains(e.target)))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._connected=!1,this._observer?.disconnect(),this._observer=null}get resolveLink(){return this._resolveLink}set resolveLink(e){this._resolveLink=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get base(){return this.getAttribute(`base`)??void 0}set base(e){e==null?this.removeAttribute(`base`):this.setAttribute(`base`,String(e))}get isCitation(){return this._isCitation}set isCitation(e){this._isCitation=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get figureText(){return this._figureText}set figureText(e){this._figureText=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}attributeChangedCallback(e,t,n){t!==n&&this._connected&&this._render()}_source(){return Array.from(this.children).find(e=>e instanceof HTMLPreElement&&e.classList.contains(`wui-markdown-source`))}_render(){let e=this._source();e&&(this._blocks=U(this,this._blocks,e.textContent??``,{links:this.getAttribute(`links`)??void 0,headings:this.getAttribute(`headings`)??void 0,base:this.getAttribute(`base`)??void 0,resolveLink:this._resolveLink,isCitation:this._isCitation,figureText:this._figureText,resolverGeneration:this._resolverGeneration},e),this._drawn=this._blocks.flatMap(e=>e.nodes),e.hidden=!0,this._observer?.takeRecords())}};function K(e,t){switch(t.type){case`paragraph`:return[(0,n.make)(`p`,null,...q(e,t.lines))];case`heading`:return[J(e,t)];case`list`:return Y(e,t.items);case`table`:return[re(e,t)];case`code`:return[ae(t)];case`quote`:return[(0,n.make)(`blockquote`,null,...q(e,t.lines))];case`rule`:return[(0,n.make)(`hr`)];default:return[]}}function q(e,t){let r=[];return t.forEach((t,i)=>{i>0&&r.push((0,n.make)(`br`)),r.push(...Z(e,t))}),r}function J(e,t){let r=Z(e,t.text);return e.headings===`text`?(0,n.make)(`p`,{class:`fw-semibold`},...r):(0,n.make)(`h2`,null,...r)}function Y(e,t){let n=[];for(let r=0;r<t.length;){let i=X(e,t,r);n.push(i.list),r=i.next}return n}function X(e,t,r){let i=t[r];if(!i)throw Error(`List run starts past its items.`);let{depth:a,ordered:o,number:s}=i,c=(0,n.make)(o?`ol`:`ul`,o&&s!==1?{start:s}:null),l=null,u=r,d=t[u];for(;d&&d.depth>=a;){if(d.depth===a)l=(0,n.make)(`li`,null,...Z(e,d.text)),c.append(l),u+=1;else{let n=X(e,t,u);if(!l)throw Error(`Nested list has no item before it.`);l.append(n.list),u=n.next}d=t[u]}return{list:c,next:u}}function re(e,t){let r=t.header.map(t=>(0,n.make)(`th`,{scope:`col`},...Z(e,t))),i=t.rows.map(r=>(0,n.make)(`tr`,null,...t.header.map((t,i)=>(0,n.make)(`td`,null,...Z(e,r[i]??``))))),a=(0,n.make)(`table`,{class:`table`},(0,n.make)(`thead`,null,(0,n.make)(`tr`,null,...r)),(0,n.make)(`tbody`,null,...i));return(0,n.make)(`div`,{class:`table-responsive`},a)}function ie(e){return e===null?`text`:B.includes(e.toLowerCase())?`razor`:z.includes(e)?e:`text`}function ae(e){let t=(0,n.make)(`code`,null,e.text),r=(0,n.make)(`pre`,{class:`wui-code-source`},t);return(0,n.make)(`wui-code-block`,{class:`wui-code-block`,language:ie(e.language)},r)}function Z(e,t){return Q(e,p(t,{isCitation:e.isCitation}))}function Q(e,t){return t.flatMap(t=>oe(e,t))}function oe(e,t){switch(t.type){case`code`:return[(0,n.make)(`code`,null,t.text)];case`strong`:return[(0,n.make)(`strong`,null,...Q(e,t.children))];case`em`:return[(0,n.make)(`em`,null,...Q(e,t.children))];case`strike`:return[(0,n.make)(`del`,null,...Q(e,t.children))];case`image`:return[document.createTextNode(`[`),...Q(e,t.children),document.createTextNode(`]`)];case`link`:return se(e,t);case`citation`:return[le(t.text)];case`text`:return e.figureText?ce(e.figureText,t.text):[document.createTextNode(t.text)];default:throw Error(`wui-markdown: unknown inline token ${JSON.stringify(t)}`)}}function se(e,t){let n=Q(e,t.children),r=y(t.href,e.links,e.resolveLink,globalThis.location?.origin,e.base);if(!r)return n;if(r.kind===`app`){let e=ne(r.target);return e?[$(e,n,!1)]:n}return[$(r.href,n,r.kind===`web`)]}function ce(e,t){return e(t).map(e=>e.kind===`sub`||e.kind===`sup`?(0,n.make)(e.kind,null,e.text):document.createTextNode(e.text))}function le(e){let t=(0,n.make)(`span`,{class:`chip-label`},e),r=(0,n.make)(`button`,{type:`button`,class:`chip-body`,"aria-label":e},t);return r.addEventListener(`click`,()=>{r.dispatchEvent(new CustomEvent(`wui-markdown-citation`,{bubbles:!0,detail:{citation:e}}))}),(0,n.make)(`span`,{class:`chip primary chip-outline chip-sm chip-clickable wui-markdown-citation`,"data-wui":`AppChip`},r)}function $(e,t,r){let i=(0,n.make)(`span`,{class:`wui-link__label`},...t);return(0,n.make)(`a`,{class:`wui-link wui-link--static`,"data-wui":`AppLink`,href:e,target:r?`_blank`:void 0,rel:r?`noopener noreferrer`:void 0},i)}(0,t.defineElement)(`wui-markdown`,G),e.WuiMarkdown=G})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.173.
|
|
1
|
+
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.173.1`)throw Error(`[webority-ui] org-tree expects ui-elements 0.173.1 but the page loaded `+o+`.`);var s={ariaLabel:`Organisation`,collapseLabel:`Hide {name}'s team`,expandLabel:`Show {name}'s team`,helpText:`Arrow Down goes to a person's first report, Arrow Up to their manager, Arrow Left and Right to colleagues. Plus opens a team and minus closes it. Enter chooses a person.`,noResultsText:`No one found`,resultsText:`{count} found`,searchLabel:`Search by name`},c=`li[data-wui-org-node]`,l=`:scope > .wui-org-tree-node`,u=`:scope > .wui-org-tree-node > .wui-org-tree-text > .wui-org-tree-name`,d=`:scope > .wui-org-tree-children`,f=`:scope > .wui-org-tree-node > [data-wui-org-toggle]`,p=`[data-wui-org-toggle]`,m=`a, button, input, select, textarea`,h=`.wui-org-tree-overlay`,g=`[data-wui-org-search]`,_=`[data-wui-org-canvas]`,v=`[data-wui-org-live]`,y=`--wui-org-tree-print-scale`,b=718,x=1e3,S=150,C=()=>(0,a.readText)(`orgTree`,s),w=e=>[...e.querySelectorAll(c)].filter(e=>e instanceof HTMLElement),T=e=>e.querySelector(u)?.textContent?.trim()??``,E=e=>e.getAttribute(`data-wui-org-node`),D=e=>e.getAttribute(`aria-expanded`)===`true`,O=class extends r.ElementBase{static get observedAttributes(){return[`selected`,`selectable`,`expand-label`,`collapse-label`,`search-results-text`,`search-empty-text`]}constructor(){super(),this._query=``,this._snapshot=null,this._observer=null,this._announceTimer=void 0,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>this._handleClick(e),this._onFocusIn=e=>this._handleFocusIn(e),this._onInput=e=>this._handleInput(e),this._onBeforePrint=()=>this._scaleForPrint(),this._onAfterPrint=()=>this.style.removeProperty(y)}connectedCallback(){this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`input`,this._onInput),window.addEventListener(`beforeprint`,this._onBeforePrint),window.addEventListener(`afterprint`,this._onAfterPrint);let e=this.querySelector(_);e?(this._observer=new MutationObserver(()=>{this._query&&this._applySearch(this._query)}),this._observer.observe(e,{childList:!0,subtree:!0})):(0,n.devError)(`[@webority/ui-elements] <wui-org-tree> has no [data-wui-org-canvas]; render the tree markup inside it.`)}disconnectedCallback(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`input`,this._onInput),window.removeEventListener(`beforeprint`,this._onBeforePrint),window.removeEventListener(`afterprint`,this._onAfterPrint),this._observer?.disconnect(),this._observer=null,clearTimeout(this._announceTimer)}attributeChangedCallback(e){e===`selected`||e===`selectable`?this._applySelected():(e===`expand-label`||e===`collapse-label`)&&this._syncToggles()}get selected(){return this.getAttribute(`selected`)}set selected(e){e==null?this.removeAttribute(`selected`):this.setAttribute(`selected`,String(e))}get selectable(){return this.hasAttribute(`selectable`)}set selectable(e){this.toggleAttribute(`selectable`,!!e)}_items(){return w(this)}_hasChildren(e){return!!e.querySelector(d)}_isVisible(e){for(let t=e;t&&t!==this;t=t.parentElement)if(t.hasAttribute(`hidden`))return!1;return!0}_visibleItems(){return this._items().filter(e=>this._isVisible(e))}_parentItem(e){let t=e.parentElement?.closest(c);return t instanceof HTMLElement&&this.contains(t)?t:null}_visibleChildren(e){let t=e.querySelector(d);return t?[...t.children].filter(e=>e.matches(c)&&this._isVisible(e)):[]}_isVisibleItem(e){return e instanceof HTMLElement&&e.matches(c)&&this._isVisible(e)}_siblingItem(e,t){let n=e[t];for(;n&&!this._isVisibleItem(n);)n=n[t];return this._isVisibleItem(n)?n:null}_setRoving(e){for(let t of this._items())t.setAttribute(`tabindex`,t===e?`0`:`-1`)}_focusItem(e){e&&(this._setRoving(e),e.focus())}_toggleLabel(e,t){return(t?this.getAttribute(`collapse-label`)??C().collapseLabel:this.getAttribute(`expand-label`)??C().expandLabel).split(`{name}`).join(T(e))}_setExpanded(e,t){let n=e.querySelector(d);n instanceof HTMLElement&&(e.setAttribute(`aria-expanded`,String(t)),n.hidden=!t,e.querySelector(f)?.setAttribute(`aria-label`,this._toggleLabel(e,t)),!t&&n.contains(document.activeElement)&&this._focusItem(e))}_toggle(e){this._setExpanded(e,!D(e))}_syncToggles(){for(let e of this._items())this._hasChildren(e)&&this._setExpanded(e,D(e))}_applySelected(){for(let e of this._items())this.selectable?e.setAttribute(`aria-selected`,String(E(e)===this.selected)):e.removeAttribute(`aria-selected`)}_select(e){this.selectable&&(this.selected=E(e),this.dispatchEvent(new CustomEvent(`wui-org-tree:select`,{detail:{id:this.selected},bubbles:!0,composed:!0})))}_activate(e){this.selectable?this._select(e):this._hasChildren(e)&&this._toggle(e)}_handleFocusIn(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(c);n instanceof HTMLElement&&this.contains(n)&&this._setRoving(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(c);n instanceof HTMLElement&&this.contains(n)&&(this._setRoving(n),t.closest(p)?this._hasChildren(n)&&this._toggle(n):n.querySelector(l)?.contains(t)&&(t.closest(m)?.closest(h)||this._select(n)))}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=e.target;if(t instanceof HTMLElement&&t.matches(c)&&this.contains(t))switch((0,i.mirrorKey)(e.key,(0,i.isRtl)(this))){case`ArrowDown`:if(e.preventDefault(),!this._hasChildren(t))return;D(t)||this._setExpanded(t,!0),this._focusItem(this._visibleChildren(t)[0]);return;case`ArrowUp`:e.preventDefault(),this._focusItem(this._parentItem(t));return;case`ArrowRight`:e.preventDefault(),this._focusItem(this._siblingItem(t,`nextElementSibling`));return;case`ArrowLeft`:e.preventDefault(),this._focusItem(this._siblingItem(t,`previousElementSibling`));return;case`Home`:e.preventDefault(),this._focusItem(this._visibleItems()[0]);return;case`End`:e.preventDefault(),this._focusItem(this._visibleItems().at(-1));return;case`+`:case`=`:if(!this._hasChildren(t))return;e.preventDefault(),this._setExpanded(t,!0);return;case`-`:if(!this._hasChildren(t))return;e.preventDefault(),this._setExpanded(t,!1);return;case`Enter`:case` `:e.preventDefault(),this._activate(t);return}}_handleInput(e){let t=e.target;t instanceof HTMLInputElement&&t.matches(g)&&this._search(t.value.trim().toLocaleLowerCase())}_search(e){clearTimeout(this._announceTimer),e?(this._snapshot||=this._captureExpanded(),this._query=e,this._applySearch(e),this._announceTimer=window.setTimeout(()=>this._announce(this._resultText()),S)):(this._snapshot&&this._restore(this._snapshot),this._snapshot=null,this._query=``,this._announce(``))}_captureExpanded(){return new Map(this._items().filter(e=>this._hasChildren(e)).map(e=>[E(e),D(e)]))}_restore(e){for(let t of this._items()){t.hidden=!1,t.classList.remove(`wui-org-tree-match`);let n=E(t);e.has(n)&&this._setExpanded(t,e.get(n)??!1)}}_applySearch(e){let t=this._items(),n=new Set(t.filter(t=>T(t).toLocaleLowerCase().includes(e))),r=new Set(n);for(let e of n)for(let t=this._parentItem(e);t;t=this._parentItem(t))r.add(t),D(t)||this._setExpanded(t,!0);for(let e of t)e.classList.toggle(`wui-org-tree-match`,n.has(e)),e.hidden=!r.has(e);let i=t.filter(e=>r.has(e)),a=i[0];a&&!i.some(e=>e.getAttribute(`tabindex`)===`0`)&&this._setRoving(a)}_resultText(){let e=this._items().filter(e=>e.classList.contains(`wui-org-tree-match`)).length;return e===0?this.getAttribute(`search-empty-text`)??C().noResultsText:(this.getAttribute(`search-results-text`)??C().resultsText).split(`{count}`).join(String(e))}_announce(e){let t=this.querySelector(v);t&&(t.textContent=e)}_scaleForPrint(){let e=this.querySelector(_);if(!(e instanceof HTMLElement))return;let t=Math.min(1,b/e.scrollWidth,x/e.scrollHeight);this.style.setProperty(y,String(t))}};(0,t.defineElement)(`wui-org-tree`,O),e.WuiOrgTree=O})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var h=Object.defineProperty,g=(e,t)=>{let n={};for(var r in e)h(n,r,{get:e[r],enumerable:!0});return t||h(n,Symbol.toStringTag,{value:`Module`}),n},_=globalThis.WeborityUiElementsInternal?.version;if(_!==`0.173.0`)throw Error(`[webority-ui] phone expects ui-elements 0.173.0 but the page loaded `+_+`.`);var v=[[`AF`,`Afghanistan`,`93`],[`AX`,`Åland Islands`,`358`],[`AL`,`Albania`,`355`],[`DZ`,`Algeria`,`213`],[`AS`,`American Samoa`,`1`],[`AD`,`Andorra`,`376`],[`AO`,`Angola`,`244`],[`AI`,`Anguilla`,`1`],[`AG`,`Antigua & Barbuda`,`1`],[`AR`,`Argentina`,`54`],[`AM`,`Armenia`,`374`],[`AW`,`Aruba`,`297`],[`AC`,`Ascension Island`,`247`],[`AU`,`Australia`,`61`],[`AT`,`Austria`,`43`],[`AZ`,`Azerbaijan`,`994`],[`BS`,`Bahamas`,`1`],[`BH`,`Bahrain`,`973`],[`BD`,`Bangladesh`,`880`],[`BB`,`Barbados`,`1`],[`BY`,`Belarus`,`375`],[`BE`,`Belgium`,`32`],[`BZ`,`Belize`,`501`],[`BJ`,`Benin`,`229`],[`BM`,`Bermuda`,`1`],[`BT`,`Bhutan`,`975`],[`BO`,`Bolivia`,`591`],[`BA`,`Bosnia & Herzegovina`,`387`],[`BW`,`Botswana`,`267`],[`BR`,`Brazil`,`55`],[`IO`,`British Indian Ocean Territory`,`246`],[`VG`,`British Virgin Islands`,`1`],[`BN`,`Brunei`,`673`],[`BG`,`Bulgaria`,`359`],[`BF`,`Burkina Faso`,`226`],[`BI`,`Burundi`,`257`],[`KH`,`Cambodia`,`855`],[`CM`,`Cameroon`,`237`],[`CA`,`Canada`,`1`],[`CV`,`Cape Verde`,`238`],[`BQ`,`Caribbean Netherlands`,`599`],[`KY`,`Cayman Islands`,`1`],[`CF`,`Central African Republic`,`236`],[`TD`,`Chad`,`235`],[`CL`,`Chile`,`56`],[`CN`,`China`,`86`],[`CX`,`Christmas Island`,`61`],[`CC`,`Cocos (Keeling) Islands`,`61`],[`CO`,`Colombia`,`57`],[`KM`,`Comoros`,`269`],[`CG`,`Congo - Brazzaville`,`242`],[`CD`,`Congo - Kinshasa`,`243`],[`CK`,`Cook Islands`,`682`],[`CR`,`Costa Rica`,`506`],[`CI`,`Côte d’Ivoire`,`225`],[`HR`,`Croatia`,`385`],[`CU`,`Cuba`,`53`],[`CW`,`Curaçao`,`599`],[`CY`,`Cyprus`,`357`],[`CZ`,`Czechia`,`420`],[`DK`,`Denmark`,`45`],[`DJ`,`Djibouti`,`253`],[`DM`,`Dominica`,`1`],[`DO`,`Dominican Republic`,`1`],[`EC`,`Ecuador`,`593`],[`EG`,`Egypt`,`20`],[`SV`,`El Salvador`,`503`],[`GQ`,`Equatorial Guinea`,`240`],[`ER`,`Eritrea`,`291`],[`EE`,`Estonia`,`372`],[`SZ`,`Eswatini`,`268`],[`ET`,`Ethiopia`,`251`],[`FK`,`Falkland Islands`,`500`],[`FO`,`Faroe Islands`,`298`],[`FJ`,`Fiji`,`679`],[`FI`,`Finland`,`358`],[`FR`,`France`,`33`],[`GF`,`French Guiana`,`594`],[`PF`,`French Polynesia`,`689`],[`GA`,`Gabon`,`241`],[`GM`,`Gambia`,`220`],[`GE`,`Georgia`,`995`],[`DE`,`Germany`,`49`],[`GH`,`Ghana`,`233`],[`GI`,`Gibraltar`,`350`],[`GR`,`Greece`,`30`],[`GL`,`Greenland`,`299`],[`GD`,`Grenada`,`1`],[`GP`,`Guadeloupe`,`590`],[`GU`,`Guam`,`1`],[`GT`,`Guatemala`,`502`],[`GG`,`Guernsey`,`44`],[`GN`,`Guinea`,`224`],[`GW`,`Guinea-Bissau`,`245`],[`GY`,`Guyana`,`592`],[`HT`,`Haiti`,`509`],[`HN`,`Honduras`,`504`],[`HK`,`Hong Kong SAR China`,`852`],[`HU`,`Hungary`,`36`],[`IS`,`Iceland`,`354`],[`IN`,`India`,`91`],[`ID`,`Indonesia`,`62`],[`IR`,`Iran`,`98`],[`IQ`,`Iraq`,`964`],[`IE`,`Ireland`,`353`],[`IM`,`Isle of Man`,`44`],[`IL`,`Israel`,`972`],[`IT`,`Italy`,`39`],[`JM`,`Jamaica`,`1`],[`JP`,`Japan`,`81`],[`JE`,`Jersey`,`44`],[`JO`,`Jordan`,`962`],[`KZ`,`Kazakhstan`,`7`],[`KE`,`Kenya`,`254`],[`KI`,`Kiribati`,`686`],[`XK`,`Kosovo`,`383`],[`KW`,`Kuwait`,`965`],[`KG`,`Kyrgyzstan`,`996`],[`LA`,`Laos`,`856`],[`LV`,`Latvia`,`371`],[`LB`,`Lebanon`,`961`],[`LS`,`Lesotho`,`266`],[`LR`,`Liberia`,`231`],[`LY`,`Libya`,`218`],[`LI`,`Liechtenstein`,`423`],[`LT`,`Lithuania`,`370`],[`LU`,`Luxembourg`,`352`],[`MO`,`Macao SAR China`,`853`],[`MG`,`Madagascar`,`261`],[`MW`,`Malawi`,`265`],[`MY`,`Malaysia`,`60`],[`MV`,`Maldives`,`960`],[`ML`,`Mali`,`223`],[`MT`,`Malta`,`356`],[`MH`,`Marshall Islands`,`692`],[`MQ`,`Martinique`,`596`],[`MR`,`Mauritania`,`222`],[`MU`,`Mauritius`,`230`],[`YT`,`Mayotte`,`262`],[`MX`,`Mexico`,`52`],[`FM`,`Micronesia`,`691`],[`MD`,`Moldova`,`373`],[`MC`,`Monaco`,`377`],[`MN`,`Mongolia`,`976`],[`ME`,`Montenegro`,`382`],[`MS`,`Montserrat`,`1`],[`MA`,`Morocco`,`212`],[`MZ`,`Mozambique`,`258`],[`MM`,`Myanmar (Burma)`,`95`],[`NA`,`Namibia`,`264`],[`NR`,`Nauru`,`674`],[`NP`,`Nepal`,`977`],[`NL`,`Netherlands`,`31`],[`NC`,`New Caledonia`,`687`],[`NZ`,`New Zealand`,`64`],[`NI`,`Nicaragua`,`505`],[`NE`,`Niger`,`227`],[`NG`,`Nigeria`,`234`],[`NU`,`Niue`,`683`],[`NF`,`Norfolk Island`,`672`],[`KP`,`North Korea`,`850`],[`MK`,`North Macedonia`,`389`],[`MP`,`Northern Mariana Islands`,`1`],[`NO`,`Norway`,`47`],[`OM`,`Oman`,`968`],[`PK`,`Pakistan`,`92`],[`PW`,`Palau`,`680`],[`PS`,`Palestinian Territories`,`970`],[`PA`,`Panama`,`507`],[`PG`,`Papua New Guinea`,`675`],[`PY`,`Paraguay`,`595`],[`PE`,`Peru`,`51`],[`PH`,`Philippines`,`63`],[`PL`,`Poland`,`48`],[`PT`,`Portugal`,`351`],[`PR`,`Puerto Rico`,`1`],[`QA`,`Qatar`,`974`],[`RE`,`Réunion`,`262`],[`RO`,`Romania`,`40`],[`RU`,`Russia`,`7`],[`RW`,`Rwanda`,`250`],[`WS`,`Samoa`,`685`],[`SM`,`San Marino`,`378`],[`ST`,`São Tomé & Príncipe`,`239`],[`SA`,`Saudi Arabia`,`966`],[`SN`,`Senegal`,`221`],[`RS`,`Serbia`,`381`],[`SC`,`Seychelles`,`248`],[`SL`,`Sierra Leone`,`232`],[`SG`,`Singapore`,`65`],[`SX`,`Sint Maarten`,`1`],[`SK`,`Slovakia`,`421`],[`SI`,`Slovenia`,`386`],[`SB`,`Solomon Islands`,`677`],[`SO`,`Somalia`,`252`],[`ZA`,`South Africa`,`27`],[`KR`,`South Korea`,`82`],[`SS`,`South Sudan`,`211`],[`ES`,`Spain`,`34`],[`LK`,`Sri Lanka`,`94`],[`BL`,`St. Barthélemy`,`590`],[`SH`,`St. Helena, Ascension & Tristan da Cunha`,`290`],[`KN`,`St. Kitts & Nevis`,`1`],[`LC`,`St. Lucia`,`1`],[`MF`,`St. Martin`,`590`],[`PM`,`St. Pierre & Miquelon`,`508`],[`VC`,`St. Vincent & Grenadines`,`1`],[`SD`,`Sudan`,`249`],[`SR`,`Suriname`,`597`],[`SJ`,`Svalbard & Jan Mayen`,`47`],[`SE`,`Sweden`,`46`],[`CH`,`Switzerland`,`41`],[`SY`,`Syria`,`963`],[`TW`,`Taiwan`,`886`],[`TJ`,`Tajikistan`,`992`],[`TZ`,`Tanzania`,`255`],[`TH`,`Thailand`,`66`],[`TL`,`Timor-Leste`,`670`],[`TG`,`Togo`,`228`],[`TK`,`Tokelau`,`690`],[`TO`,`Tonga`,`676`],[`TT`,`Trinidad & Tobago`,`1`],[`TA`,`Tristan da Cunha`,`290`],[`TN`,`Tunisia`,`216`],[`TR`,`Türkiye`,`90`],[`TM`,`Turkmenistan`,`993`],[`TC`,`Turks & Caicos Islands`,`1`],[`TV`,`Tuvalu`,`688`],[`VI`,`U.S. Virgin Islands`,`1`],[`UG`,`Uganda`,`256`],[`UA`,`Ukraine`,`380`],[`AE`,`United Arab Emirates`,`971`],[`GB`,`United Kingdom`,`44`],[`US`,`United States`,`1`],[`UY`,`Uruguay`,`598`],[`UZ`,`Uzbekistan`,`998`],[`VU`,`Vanuatu`,`678`],[`VA`,`Vatican City`,`39`],[`VE`,`Venezuela`,`58`],[`VN`,`Vietnam`,`84`],[`WF`,`Wallis & Futuna`,`681`],[`EH`,`Western Sahara`,`212`],[`YE`,`Yemen`,`967`],[`ZM`,`Zambia`,`260`],[`ZW`,`Zimbabwe`,`263`]],y=e=>v.find(t=>t[0]===e)?.[2]??``,b={AD:[`Europe/Andorra`],AE:[`Asia/Dubai`],AF:[`Asia/Kabul`],AG:[`America/Antigua`],AI:[`America/Anguilla`],AL:[`Europe/Tirane`],AM:[`Asia/Yerevan`],AO:[`Africa/Luanda`],AR:[`America/Argentina/Buenos_Aires`,`America/Argentina/Catamarca`,`America/Argentina/ComodRivadavia`,`America/Argentina/Cordoba`,`America/Argentina/Jujuy`,`America/Argentina/La_Rioja`,`America/Argentina/Mendoza`,`America/Argentina/Rio_Gallegos`,`America/Argentina/Salta`,`America/Argentina/San_Juan`,`America/Argentina/San_Luis`,`America/Argentina/Tucuman`,`America/Argentina/Ushuaia`,`America/Buenos_Aires`,`America/Catamarca`,`America/Cordoba`,`America/Jujuy`,`America/Mendoza`,`America/Rosario`],AS:[`Pacific/Pago_Pago`,`Pacific/Samoa`,`US/Samoa`],AT:[`Europe/Vienna`],AU:[`Antarctica/Macquarie`,`Australia/Adelaide`,`Australia/Brisbane`,`Australia/Broken_Hill`,`Australia/Canberra`,`Australia/Currie`,`Australia/Darwin`,`Australia/Eucla`,`Australia/Hobart`,`Australia/LHI`,`Australia/Lindeman`,`Australia/Lord_Howe`,`Australia/Melbourne`,`Australia/NSW`,`Australia/North`,`Australia/Perth`,`Australia/Queensland`,`Australia/South`,`Australia/Sydney`,`Australia/Tasmania`,`Australia/Victoria`,`Australia/West`,`Australia/Yancowinna`],AW:[`America/Aruba`],AX:[`Europe/Mariehamn`],AZ:[`Asia/Baku`],BA:[`Europe/Sarajevo`],BB:[`America/Barbados`],BD:[`Asia/Dacca`,`Asia/Dhaka`],BE:[`Europe/Brussels`],BF:[`Africa/Ouagadougou`],BG:[`Europe/Sofia`],BH:[`Asia/Bahrain`],BI:[`Africa/Bujumbura`],BJ:[`Africa/Porto-Novo`],BL:[`America/St_Barthelemy`],BM:[`Atlantic/Bermuda`],BN:[`Asia/Brunei`],BO:[`America/La_Paz`],BQ:[`America/Kralendijk`],BR:[`America/Araguaina`,`America/Bahia`,`America/Belem`,`America/Boa_Vista`,`America/Campo_Grande`,`America/Cuiaba`,`America/Eirunepe`,`America/Fortaleza`,`America/Maceio`,`America/Manaus`,`America/Noronha`,`America/Porto_Acre`,`America/Porto_Velho`,`America/Recife`,`America/Rio_Branco`,`America/Santarem`,`America/Sao_Paulo`,`Brazil/DeNoronha`,`Brazil/East`,`Brazil/West`],BS:[`America/Nassau`],BT:[`Asia/Thimbu`,`Asia/Thimphu`],BW:[`Africa/Gaborone`],BY:[`Europe/Minsk`],BZ:[`America/Belize`],CA:`America/Atikokan.America/Blanc-Sablon.America/Cambridge_Bay.America/Coral_Harbour.America/Creston.America/Dawson.America/Dawson_Creek.America/Edmonton.America/Fort_Nelson.America/Glace_Bay.America/Goose_Bay.America/Halifax.America/Inuvik.America/Iqaluit.America/Moncton.America/Montreal.America/Nipigon.America/Pangnirtung.America/Rainy_River.America/Rankin_Inlet.America/Regina.America/Resolute.America/St_Johns.America/Swift_Current.America/Thunder_Bay.America/Toronto.America/Vancouver.America/Whitehorse.America/Winnipeg.America/Yellowknife.Canada/Atlantic.Canada/Central.Canada/Eastern.Canada/Mountain.Canada/Newfoundland.Canada/Pacific.Canada/Saskatchewan.Canada/Yukon`.split(`.`),CC:[`Indian/Cocos`],CD:[`Africa/Kinshasa`,`Africa/Lubumbashi`],CF:[`Africa/Bangui`],CG:[`Africa/Brazzaville`],CH:[`Europe/Zurich`],CI:[`Africa/Abidjan`],CK:[`Pacific/Rarotonga`],CL:[`America/Coyhaique`,`America/Punta_Arenas`,`America/Santiago`,`Chile/Continental`,`Chile/EasterIsland`,`Pacific/Easter`],CM:[`Africa/Douala`],CN:[`Asia/Chongqing`,`Asia/Harbin`,`Asia/Kashgar`,`Asia/Shanghai`,`Asia/Urumqi`],CO:[`America/Bogota`],CR:[`America/Costa_Rica`],CU:[`America/Havana`],CV:[`Atlantic/Cape_Verde`],CW:[`America/Curacao`],CX:[`Indian/Christmas`],CY:[`Asia/Famagusta`,`Asia/Nicosia`,`Europe/Nicosia`],CZ:[`Europe/Prague`],DE:[`Europe/Berlin`,`Europe/Busingen`],DJ:[`Africa/Djibouti`],DK:[`Europe/Copenhagen`],DM:[`America/Dominica`],DO:[`America/Santo_Domingo`],DZ:[`Africa/Algiers`],EC:[`America/Guayaquil`,`Pacific/Galapagos`],EE:[`Europe/Tallinn`],EG:[`Africa/Cairo`],EH:[`Africa/El_Aaiun`],ER:[`Africa/Asmara`,`Africa/Asmera`],ES:[`Africa/Ceuta`,`Atlantic/Canary`,`Europe/Madrid`],ET:[`Africa/Addis_Ababa`],FI:[`Europe/Helsinki`],FJ:[`Pacific/Fiji`],FK:[`Atlantic/Stanley`],FM:[`Pacific/Chuuk`,`Pacific/Kosrae`,`Pacific/Pohnpei`,`Pacific/Ponape`,`Pacific/Truk`,`Pacific/Yap`],FO:[`Atlantic/Faeroe`,`Atlantic/Faroe`],FR:[`Europe/Paris`],GA:[`Africa/Libreville`],GB:[`Europe/Belfast`,`Europe/London`],GD:[`America/Grenada`],GE:[`Asia/Tbilisi`],GF:[`America/Cayenne`],GG:[`Europe/Guernsey`],GH:[`Africa/Accra`],GI:[`Europe/Gibraltar`],GL:[`America/Danmarkshavn`,`America/Godthab`,`America/Nuuk`,`America/Scoresbysund`,`America/Thule`],GM:[`Africa/Banjul`],GN:[`Africa/Conakry`],GP:[`America/Guadeloupe`],GQ:[`Africa/Malabo`],GR:[`Europe/Athens`],GT:[`America/Guatemala`],GU:[`Pacific/Guam`],GW:[`Africa/Bissau`],GY:[`America/Guyana`],HK:[`Asia/Hong_Kong`],HN:[`America/Tegucigalpa`],HR:[`Europe/Zagreb`],HT:[`America/Port-au-Prince`],HU:[`Europe/Budapest`],ID:[`Asia/Jakarta`,`Asia/Jayapura`,`Asia/Makassar`,`Asia/Pontianak`,`Asia/Ujung_Pandang`],IE:[`Europe/Dublin`],IL:[`Asia/Jerusalem`,`Asia/Tel_Aviv`],IM:[`Europe/Isle_of_Man`],IN:[`Asia/Calcutta`,`Asia/Kolkata`],IO:[`Indian/Chagos`],IQ:[`Asia/Baghdad`],IR:[`Asia/Tehran`],IS:[`Atlantic/Reykjavik`],IT:[`Europe/Rome`],JE:[`Europe/Jersey`],JM:[`America/Jamaica`],JO:[`Asia/Amman`],JP:[`Asia/Tokyo`],KE:[`Africa/Nairobi`],KG:[`Asia/Bishkek`],KH:[`Asia/Phnom_Penh`],KI:[`Pacific/Enderbury`,`Pacific/Kanton`,`Pacific/Kiritimati`,`Pacific/Tarawa`],KM:[`Indian/Comoro`],KN:[`America/St_Kitts`],KP:[`Asia/Pyongyang`],KR:[`Asia/Seoul`],KW:[`Asia/Kuwait`],KY:[`America/Cayman`],KZ:[`Asia/Almaty`,`Asia/Aqtau`,`Asia/Aqtobe`,`Asia/Atyrau`,`Asia/Oral`,`Asia/Qostanay`,`Asia/Qyzylorda`],LA:[`Asia/Vientiane`],LB:[`Asia/Beirut`],LC:[`America/St_Lucia`],LI:[`Europe/Vaduz`],LK:[`Asia/Colombo`],LR:[`Africa/Monrovia`],LS:[`Africa/Maseru`],LT:[`Europe/Vilnius`],LU:[`Europe/Luxembourg`],LV:[`Europe/Riga`],LY:[`Africa/Tripoli`],MA:[`Africa/Casablanca`],MC:[`Europe/Monaco`],MD:[`Europe/Chisinau`,`Europe/Tiraspol`],ME:[`Europe/Podgorica`],MF:[`America/Marigot`],MG:[`Indian/Antananarivo`],MH:[`Pacific/Kwajalein`,`Pacific/Majuro`],MK:[`Europe/Skopje`],ML:[`Africa/Bamako`,`Africa/Timbuktu`],MM:[`Asia/Rangoon`,`Asia/Yangon`],MN:[`Asia/Choibalsan`,`Asia/Hovd`,`Asia/Ulaanbaatar`,`Asia/Ulan_Bator`],MO:[`Asia/Macao`,`Asia/Macau`],MP:[`Pacific/Saipan`],MQ:[`America/Martinique`],MR:[`Africa/Nouakchott`],MS:[`America/Montserrat`],MT:[`Europe/Malta`],MU:[`Indian/Mauritius`],MV:[`Indian/Maldives`],MW:[`Africa/Blantyre`],MX:[`America/Bahia_Banderas`,`America/Cancun`,`America/Chihuahua`,`America/Ciudad_Juarez`,`America/Ensenada`,`America/Hermosillo`,`America/Matamoros`,`America/Mazatlan`,`America/Merida`,`America/Mexico_City`,`America/Monterrey`,`America/Ojinaga`,`America/Santa_Isabel`,`America/Tijuana`,`Mexico/BajaNorte`,`Mexico/BajaSur`,`Mexico/General`],MY:[`Asia/Kuala_Lumpur`,`Asia/Kuching`],MZ:[`Africa/Maputo`],NA:[`Africa/Windhoek`],NC:[`Pacific/Noumea`],NE:[`Africa/Niamey`],NF:[`Pacific/Norfolk`],NG:[`Africa/Lagos`],NI:[`America/Managua`],NL:[`Europe/Amsterdam`],NO:[`Europe/Oslo`],NP:[`Asia/Kathmandu`,`Asia/Katmandu`],NR:[`Pacific/Nauru`],NU:[`Pacific/Niue`],NZ:[`Pacific/Auckland`,`Pacific/Chatham`],OM:[`Asia/Muscat`],PA:[`America/Panama`],PE:[`America/Lima`],PF:[`Pacific/Gambier`,`Pacific/Marquesas`,`Pacific/Tahiti`],PG:[`Pacific/Bougainville`,`Pacific/Port_Moresby`],PH:[`Asia/Manila`],PK:[`Asia/Karachi`],PL:[`Europe/Warsaw`],PM:[`America/Miquelon`],PR:[`America/Puerto_Rico`],PS:[`Asia/Gaza`,`Asia/Hebron`],PT:[`Atlantic/Azores`,`Atlantic/Madeira`,`Europe/Lisbon`],PW:[`Pacific/Palau`],PY:[`America/Asuncion`],QA:[`Asia/Qatar`],RE:[`Indian/Reunion`],RO:[`Europe/Bucharest`],RS:[`Europe/Belgrade`],RU:`Asia/Anadyr.Asia/Barnaul.Asia/Chita.Asia/Irkutsk.Asia/Kamchatka.Asia/Khandyga.Asia/Krasnoyarsk.Asia/Magadan.Asia/Novokuznetsk.Asia/Novosibirsk.Asia/Omsk.Asia/Sakhalin.Asia/Srednekolymsk.Asia/Tomsk.Asia/Ust-Nera.Asia/Vladivostok.Asia/Yakutsk.Asia/Yekaterinburg.Europe/Astrakhan.Europe/Kaliningrad.Europe/Kirov.Europe/Moscow.Europe/Samara.Europe/Saratov.Europe/Ulyanovsk.Europe/Volgograd`.split(`.`),RW:[`Africa/Kigali`],SA:[`Asia/Riyadh`],SB:[`Pacific/Guadalcanal`],SC:[`Indian/Mahe`],SD:[`Africa/Khartoum`],SE:[`Europe/Stockholm`],SG:[`Asia/Singapore`],SH:[`Atlantic/St_Helena`],SI:[`Europe/Ljubljana`],SJ:[`Arctic/Longyearbyen`,`Atlantic/Jan_Mayen`],SK:[`Europe/Bratislava`],SL:[`Africa/Freetown`],SM:[`Europe/San_Marino`],SN:[`Africa/Dakar`],SO:[`Africa/Mogadishu`],SR:[`America/Paramaribo`],SS:[`Africa/Juba`],ST:[`Africa/Sao_Tome`],SV:[`America/El_Salvador`],SX:[`America/Lower_Princes`],SY:[`Asia/Damascus`],SZ:[`Africa/Mbabane`],TC:[`America/Grand_Turk`],TD:[`Africa/Ndjamena`],TG:[`Africa/Lome`],TH:[`Asia/Bangkok`],TJ:[`Asia/Dushanbe`],TK:[`Pacific/Fakaofo`],TL:[`Asia/Dili`],TM:[`Asia/Ashgabat`,`Asia/Ashkhabad`],TN:[`Africa/Tunis`],TO:[`Pacific/Tongatapu`],TR:[`Asia/Istanbul`,`Europe/Istanbul`],TT:[`America/Port_of_Spain`],TV:[`Pacific/Funafuti`],TW:[`Asia/Taipei`],TZ:[`Africa/Dar_es_Salaam`],UA:[`Europe/Kiev`,`Europe/Kyiv`,`Europe/Simferopol`,`Europe/Uzhgorod`,`Europe/Zaporozhye`],UG:[`Africa/Kampala`],US:`America/Adak.America/Anchorage.America/Atka.America/Boise.America/Chicago.America/Denver.America/Detroit.America/Fort_Wayne.America/Indiana/Indianapolis.America/Indiana/Knox.America/Indiana/Marengo.America/Indiana/Petersburg.America/Indiana/Tell_City.America/Indiana/Vevay.America/Indiana/Vincennes.America/Indiana/Winamac.America/Indianapolis.America/Juneau.America/Kentucky/Louisville.America/Kentucky/Monticello.America/Knox_IN.America/Los_Angeles.America/Louisville.America/Menominee.America/Metlakatla.America/New_York.America/Nome.America/North_Dakota/Beulah.America/North_Dakota/Center.America/North_Dakota/New_Salem.America/Phoenix.America/Shiprock.America/Sitka.America/Yakutat.Pacific/Honolulu.US/Alaska.US/Aleutian.US/Arizona.US/Central.US/East-Indiana.US/Eastern.US/Hawaii.US/Indiana-Starke.US/Michigan.US/Mountain.US/Pacific`.split(`.`),UY:[`America/Montevideo`],UZ:[`Asia/Samarkand`,`Asia/Tashkent`],VA:[`Europe/Vatican`],VC:[`America/St_Vincent`],VE:[`America/Caracas`],VG:[`America/Tortola`],VI:[`America/St_Thomas`,`America/Virgin`],VN:[`Asia/Ho_Chi_Minh`,`Asia/Saigon`],VU:[`Pacific/Efate`],WF:[`Pacific/Wallis`],WS:[`Pacific/Apia`],YE:[`Asia/Aden`],YT:[`Indian/Mayotte`],ZA:[`Africa/Johannesburg`],ZM:[`Africa/Lusaka`],ZW:[`Africa/Harare`]},x=new Set(v.map(([e])=>e)),S=new Map;for(let[e,t]of Object.entries(b))for(let n of t)S.set(n,e);function C(e){let t=e===void 0?void 0:S.get(e);return t&&x.has(t)?t:null}function w(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&x.has(t)?t:null}function T(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return C(e)||w(t)||null}var E=`ui-phone.global.js`;function D(){return window.WeborityPhone?Promise.resolve(window.WeborityPhone):new Promise((e,t)=>{let n=document.querySelector(`script[src*="${E}"]`);if(!n){let e=document.createElement(`script`);try{e.src=(0,d.assetUrl)(E)}catch(e){t(e);return}document.head.append(e),n=e}n.addEventListener(`load`,()=>window.WeborityPhone?e(window.WeborityPhone):t(Error(`The phone metadata script did not load.`))),n.addEventListener(`error`,()=>t(Error(`The phone metadata script failed to load.`)))})}var O={chooseCountryLabel:`Choose country`,chooseCountryMessage:`Choose a country`,examplePlaceholder:`For example {example}`,invalidNumberExampleMessage:`Enter a valid phone number, e.g. {example}`,invalidNumberMessage:`Enter a valid phone number`,noCountriesFoundLabel:`No countries found`,placeholder:`Enter phone number`,searchCountriesLabel:`Search countries`,searchCountryPlaceholder:`Search country or code`},k=()=>(0,f.readText)(`phone`,O);function A(e,t){return e.isSupportedCountry(t)}var j=e=>e?`wui-flag wui-flag-${String(e).toLowerCase()}`:`wui-flag`,M=e=>e?`+${y(e)}`:``,N=null,P=null;function F(){return N?Promise.resolve(N):(P||=D().then(e=>(N=e,N)).catch(e=>((0,n.devError)(`[@webority/ui-elements] <wui-phone> could not load its phone number metadata.`,e),null)),P)}function I(e,t){let n=`+${y(e)}`;return t?.startsWith(n)?t.slice(n.length).trimStart():null}function L(e,t){if(!N||!t||!e||!A(N,e))return t;try{return I(e,new N.AsYouType(e).input(`+${y(e)}${t}`))||t}catch{return t}}function R(e,t){if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r++)if(/[0-9]/.test(e[r]??``)&&(n+=1,n===t))return r+1;return e.length}function z(e){if(!N||!e||!A(N,e))return null;try{return I(e,N.getExampleNumber(e,N.examples)?.formatInternational())||null}catch{return null}}function B(e){let t=z(e);return t?(0,f.fillText)(k().examplePlaceholder,{example:t}):null}function V(e){if(!N||!e)return null;try{if(!N.isValidPhoneNumber(e))return!1;let t=N.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function H(e){if(!N||!e||!A(N,e))return null;try{let t=N.getExampleNumber(e,N.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function U(e,t,n){if(!N||!A(N,e))return null;try{let r=N.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function W(e){if(!N||!e?.trim().startsWith(`+`))return null;try{let t=new N.AsYouType;t.input(e.trim());let n=t.getCountry();return!n||!X(t)?null:{country:n,national:t.getNationalNumber()||``}}catch{return null}}function G(e,t){let n=String(t??``).trim();if(!n.startsWith(`+`))return null;let r=n.replace(/[^0-9]/g,``),i=String(y(e));return{country:e,national:r.startsWith(i)?r.slice(i.length):r}}var K=class extends i.ElementBase{static formAssociated=!0;static whenFormatted(){return F().then(()=>void 0)}static get observedAttributes(){return[`value`,`country`,`locked-country`,`placeholder`,`disabled`,`readonly`,`loading`,`required`,`aria-label`,`aria-describedby`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._defaultCountry=T()||``,this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``,this._validateOnInput=!1}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){let e=J(this.querySelector(`.country-dropdown-menu`),HTMLElement);e&&(0,u.closeAnchoredPopover)(e)}attributeChangedCallback(e,t,n){if(e===`value`)this.value=n;else if(this._rendered){if(e===`aria-label`){let t=this.querySelector(`input[type=tel]`);t&&(n==null?t.removeAttribute(e):t.setAttribute(e,n))}else if(e===`aria-describedby`)this._syncDescribedBy();else if(e===`country`){if(this._locked)return;let e=this.value;if(this._country=n||this._defaultCountry,this._suppressCountryRender)return;this.render(),this.value!==e&&(this._emitInput(),this._emitChange())}else this.render()}}formResetCallback(){this._validateOnInput=!1,this.value=this._defaultValue||``}get _locked(){return(this.getAttribute(`locked-country`)||``).toUpperCase()||null}get value(){return this._national&&this._country?`+${y(this._country)}${this._national}`:``}set value(e){let t=String(e??``).trim();this._locked&&(this._country=this._locked);let n=this._locked?null:W(t);if(n)this._country=n.country,this._national=n.national.replace(/[^0-9]/g,``);else if(t.startsWith(`+`)){let e=t.replace(/[^0-9]/g,``),n=String(y(this._locked||this.getAttribute(`country`)||this._country));n&&e.startsWith(n)&&(e=e.slice(n.length)),this._national=e}else this._national=t.replace(/[^0-9]/g,``);n&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){(0,o.syncFormMirror)(this,this.value)}_syncDescribedBy(){let e=this.querySelector(`input[type=tel]`);if(!e)return;let t=[this.getAttribute(`aria-describedby`),this.querySelector(`[data-phone-error]`)?.id].filter(Boolean);t.length?e.setAttribute(`aria-describedby`,t.join(` `)):e.removeAttribute(`aria-describedby`)}_emitInput(){this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_emitChange(){this._committedValue=this.value,this.dispatchEvent(new Event(`change`,{bubbles:!0}))}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``),this._country=this._locked||this.getAttribute(`country`)||this._country;let e=this.getAttribute(`placeholder`)||B(this._country)||k().placeholder;this.id||=`wui-phone-${Math.random().toString(36).slice(2,9)}`;let t=`${this.id}-listbox`;this._listboxId=t;let n=this._locked?(0,r.make)(`div`,{class:`phone-country-adornment`},(0,r.make)(`span`,{class:`wui-phone-prefix`},(0,r.make)(`span`,{class:j(this._country),"data-flag":!0,"aria-hidden":`true`}),(0,r.make)(`span`,{class:`phone-dial`,"data-dial":!0},M(this._country)))):(0,r.make)(`div`,{class:`phone-country-adornment`},(0,r.make)(`button`,{type:`button`,class:`country-toggle`,"aria-label":k().chooseCountryLabel,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":t,disabled:this.hasAttribute(`disabled`)||void 0},(0,r.make)(`span`,{class:j(this._country),"data-flag":!0,"aria-hidden":`true`}),(0,s.glyphNode)(`chevron-down`,{className:`phone-chevron`}),(0,r.make)(`span`,{class:`phone-dial`,"data-dial":!0},M(this._country))),(0,r.make)(`div`,{class:`country-dropdown-menu`,popover:`auto`},(0,r.make)(`div`,{class:`dropdown-search-wrapper`},(0,r.make)(`span`,{class:`dropdown-search-icon`},(0,s.glyphNode)(`search`)),(0,r.make)(`input`,{type:`text`,class:`dropdown-search-input`,placeholder:k().searchCountryPlaceholder,"aria-label":k().searchCountriesLabel,"aria-controls":t,"aria-autocomplete":`list`})),(0,r.make)(`div`,{class:`country-list-scroll`,role:`listbox`,id:t,tabindex:`-1`}),(0,r.make)(`div`,{class:`country-empty`,hidden:!0},k().noCountriesFoundLabel))),i=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`),l=(0,r.make)(`input`,{type:`tel`,class:`input`,placeholder:e,value:L(this._country,this._national),"aria-label":i||void 0,"aria-describedby":c||void 0,required:this.hasAttribute(`required`)||void 0,"aria-required":this.hasAttribute(`required`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)||void 0,readonly:(0,a.isInert)(this)||void 0});this.replaceChildren((0,r.make)(`div`,{class:`phone-input-wrap`},n,l)),this._rendered=!0,(0,a.syncFieldState)(this,this.querySelector(`input.input`)),(0,o.syncFormMirror)(this,this.value),this._wire()}_ensureItems(){let e=J(this.querySelector(`.country-list-scroll`),HTMLElement);if(!e||e.querySelector(`.country-dropdown-item`))return;let t=this._listboxId,n=v.map(([e,n,i],a)=>(0,r.make)(`button`,{type:`button`,role:`option`,id:`${t}-opt-${a}`,class:`country-dropdown-item${e===this._country?` selected`:``}`,"data-iso":e,"aria-selected":String(e===this._country)},(0,r.make)(`span`,{class:j(e),"aria-hidden":`true`}),(0,r.make)(`span`,{class:`country-name-text`},n,(0,r.make)(`span`,{class:`country-code-text`},`+${i}`))));e.prepend(...n)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)].filter(e=>e instanceof HTMLElement)}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){let e=J(this.querySelector(`.country-toggle`),HTMLButtonElement),t=q(J(this.querySelector(`.phone-input-wrap`),HTMLElement),`phone input wrapper`),n=J(this.querySelector(`.country-dropdown-menu`),HTMLElement),r=J(this.querySelector(`.dropdown-search-input`),HTMLInputElement),i=J(this.querySelector(`.country-list-scroll`),HTMLElement),o=J(this.querySelector(`.country-empty`),HTMLElement),s=q(J(this.querySelector(`input[type=tel]`),HTMLInputElement),`phone input`),d=J(this.querySelector(`[data-flag]`),HTMLElement),p=J(this.querySelector(`[data-dial]`),HTMLElement),m=()=>n!==null&&(0,u.isPopoverOpen)(n),h=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,(0,l.moveActiveRow)(q(i,`country list`),e>=0&&n[e]||null);let a=e>=0?n[e]:void 0;a?(t&&a.scrollIntoView({block:`nearest`}),r?.setAttribute(`aria-activedescendant`,a.id)):r?.removeAttribute(`aria-activedescendant`)},g=()=>{m()||(q(e,`country toggle`).setAttribute(`aria-expanded`,`false`),h(-1))},_=()=>{if((0,a.isInert)(this)||(this._ensureItems(),(0,u.openAnchoredPopover)(t,q(n,`country menu`),{mode:`auto`,onClosed:g}),!m()))return;q(e,`country toggle`).setAttribute(`aria-expanded`,`true`);let i=q(r,`country search`);i.value=``,b(``),i.focus(),h(this._visibleItems().findIndex(e=>e.classList.contains(`selected`)))},v=()=>{(0,u.closeAnchoredPopover)(q(n,`country menu`))},b=e=>{let t=e.trim().toLowerCase(),n=0;for(let e of this._itemEls()){let r=!t||(e.textContent??``).toLowerCase().includes(t);e.hidden=!r,r&&(n+=1)}o&&(o.hidden=n>0)},x=e=>{this._country=e,this.getAttribute(`country`)!==e&&(this._suppressCountryRender=!0,this.setAttribute(`country`,e),this._suppressCountryRender=!1),d&&(d.className=j(e)),p&&(p.textContent=`+${y(e)}`);for(let t of this._itemEls()){let n=t.dataset.iso===e;t.classList.toggle(`selected`,n),t.setAttribute(`aria-selected`,String(n))}this.getAttribute(`placeholder`)||(s.placeholder=B(e)||k().placeholder),this._national&&(s.value=L(e,this._national)),v(),this._syncMirror(),this._emitChange(),this._validateOnInput&&C(w()),s.focus()},S=t=>{let n=this._visibleItems();if(t.key===`ArrowDown`){if(t.preventDefault(),!m()){_();return}h(Math.min(this._active+1,n.length-1))}else if(t.key===`ArrowUp`){if(t.preventDefault(),!m())return;h(Math.max(this._active-1,0))}else if((0,c.isImeSafeEnter)(t)){t.preventDefault();let e=n[this._active];m()&&e?.dataset.iso&&x(e.dataset.iso)}else t.key===`Escape`&&m()&&(t.preventDefault(),t.stopPropagation(),v(),q(e,`country toggle`).focus())};e?.addEventListener(`click`,()=>m()?v():_()),e?.addEventListener(`keydown`,e=>{m()?S(e):(e.key===`ArrowDown`||(0,c.isImeSafeEnter)(e)||e.key===` `)&&(e.preventDefault(),_())}),r&&r.addEventListener(`input`,()=>{b(r.value);let e=this._visibleItems();h(e.length?0:-1)}),i?.addEventListener(`click`,e=>{let t=J(Y(e).closest(`.country-dropdown-item`),HTMLElement);t?.dataset.iso&&x(t.dataset.iso)}),i?.addEventListener(`mousemove`,e=>{let t=J(Y(e).closest(`.country-dropdown-item`),HTMLElement);t&&!t.classList.contains(`is-active`)&&h(this._visibleItems().indexOf(t),{reveal:!1})}),i?.addEventListener(`mouseleave`,()=>h(-1)),n?.addEventListener(`keydown`,S);let C=e=>{s.classList.toggle(`is-invalid`,e),e?s.setAttribute(`aria-invalid`,`true`):s.removeAttribute(`aria-invalid`);let n=J(this.querySelector(`[data-phone-error]`),HTMLElement);if(e&&!this.hasAttribute(`external-error`)){n||(n=document.createElement(`div`),n.className=`field-error`,n.id=`${this.id}-phone-error`,n.setAttribute(`data-phone-error`,``),t.after(n));let e=z(this._country);n.textContent=this._country?e?(0,f.fillText)(k().invalidNumberExampleMessage,{example:e}):k().invalidNumberMessage:k().chooseCountryMessage}else n?.remove();this._syncDescribedBy()},w=()=>this._national.length>0&&(!this._country||V(this.value)===!1);s.addEventListener(`input`,e=>{e.stopPropagation();let t=s.selectionStart??s.value.length,n=s.value.slice(0,t).replace(/[^0-9]/g,``).length,r=s.value.replace(/[^0-9]/g,``),i=H(this._country);if(i&&r.length>i){let e=U(this._country,r,i);e?(n=Math.max(0,n-(r.length-e.length)),r=e):r=r.slice(0,i)}this._national=r;let a=L(this._country,this._national);if(s.value!==a){s.value=a;let e=R(a,Math.min(n,r.length));s.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),this._validateOnInput&&C(w())}),s.addEventListener(`change`,e=>e.stopPropagation()),s.addEventListener(`blur`,()=>{let e=w();C(e),e&&(this._validateOnInput=!0),this.value!==this._committedValue&&this._emitChange()}),s.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text`),n=this._locked?G(this._locked,t):W(t);n&&(e.preventDefault(),this._national=n.national.replace(/[^0-9]/g,``),n.country===this._country?s.value=L(this._country,this._national):(this._country=n.country,this.setAttribute(`country`,n.country)),this._syncMirror(),this._emitInput(),this._emitChange(),this._validateOnInput&&s.isConnected&&C(w()),J(this.querySelector(`input[type=tel]`),HTMLInputElement)?.focus())}),this._validateOnInput&&C(w()),F().then(e=>{if(e&&s.isConnected){if(this._national){let e=L(this._country,this._national);s.defaultValue=e,s.value=e}if(!this.getAttribute(`placeholder`)){let e=B(this._country);e&&(s.placeholder=e)}}}),this._syncMirror()}};function q(e,t){if(e==null)throw Error(`${t} missing`);return e}function J(e,t){return e instanceof t?e:null}function Y(e){if(!(e.target instanceof Element))throw Error(`Event target is not an element`);return e.target}function X(e){return`getNationalNumber`in e&&typeof e.getNationalNumber==`function`}(0,t.defineElement)(`wui-phone`,K);var ee=g({default:()=>ie}),Z=()=>(0,f.readText)(`select`,p.SELECT_TEXT),te=/^\+?\d+$/,Q=e=>String(e??``).split(`,`).map(e=>e.trim().toUpperCase()).filter(Boolean),ne=e=>{let t=Q(e.getAttribute(`countries`)),n=t.length?new Set(t):null,r=v.filter(([e])=>!n||n.has(e)),i=new Map(r.map(e=>[e[0],e])),a=[...new Set(Q(e.getAttribute(`suggested`)))].map(e=>i.get(e)).filter(e=>e!==void 0);if(!a.length)return r.map(e=>({tuple:e,group:null}));let o=new Set(a.map(e=>e[0])),s=e.getAttribute(`suggested-label`)||Z().suggestedLabel,c=e.getAttribute(`all-countries-label`)||Z().allCountriesLabel;return[...a.map(e=>({tuple:e,group:s})),...r.filter(e=>!o.has(e[0])).map(e=>({tuple:e,group:c}))]},$=({tuple:[e,t,n],group:r})=>({value:e,label:t,flag:e,meta:`+${n}`,...r?{group:r}:{}}),re=([,e,t],n)=>n?te.test(n)?t.startsWith(n.replace(`+`,``)):e.toLowerCase().includes(n):!0;function ie(){let e,t=[];return{mount(n){e=n,t=ne(n),n.setPartOptions(t.map($))},onQuery(n){let r=n.trim().toLowerCase();return e.setPartOptions(t.filter(e=>re(e.tuple,r)).map($)),!0},teardown(){}}}(0,m.registerSelectPart)(`country`,ee),e.WuiPhone=K})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.listboxKeyNav,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.loader,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.selectText,WeborityUiElementsInternal.modules.partRegistry);
|
|
1
|
+
(function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var h=Object.defineProperty,g=(e,t)=>{let n={};for(var r in e)h(n,r,{get:e[r],enumerable:!0});return t||h(n,Symbol.toStringTag,{value:`Module`}),n},_=globalThis.WeborityUiElementsInternal?.version;if(_!==`0.173.1`)throw Error(`[webority-ui] phone expects ui-elements 0.173.1 but the page loaded `+_+`.`);var v=[[`AF`,`Afghanistan`,`93`],[`AX`,`Åland Islands`,`358`],[`AL`,`Albania`,`355`],[`DZ`,`Algeria`,`213`],[`AS`,`American Samoa`,`1`],[`AD`,`Andorra`,`376`],[`AO`,`Angola`,`244`],[`AI`,`Anguilla`,`1`],[`AG`,`Antigua & Barbuda`,`1`],[`AR`,`Argentina`,`54`],[`AM`,`Armenia`,`374`],[`AW`,`Aruba`,`297`],[`AC`,`Ascension Island`,`247`],[`AU`,`Australia`,`61`],[`AT`,`Austria`,`43`],[`AZ`,`Azerbaijan`,`994`],[`BS`,`Bahamas`,`1`],[`BH`,`Bahrain`,`973`],[`BD`,`Bangladesh`,`880`],[`BB`,`Barbados`,`1`],[`BY`,`Belarus`,`375`],[`BE`,`Belgium`,`32`],[`BZ`,`Belize`,`501`],[`BJ`,`Benin`,`229`],[`BM`,`Bermuda`,`1`],[`BT`,`Bhutan`,`975`],[`BO`,`Bolivia`,`591`],[`BA`,`Bosnia & Herzegovina`,`387`],[`BW`,`Botswana`,`267`],[`BR`,`Brazil`,`55`],[`IO`,`British Indian Ocean Territory`,`246`],[`VG`,`British Virgin Islands`,`1`],[`BN`,`Brunei`,`673`],[`BG`,`Bulgaria`,`359`],[`BF`,`Burkina Faso`,`226`],[`BI`,`Burundi`,`257`],[`KH`,`Cambodia`,`855`],[`CM`,`Cameroon`,`237`],[`CA`,`Canada`,`1`],[`CV`,`Cape Verde`,`238`],[`BQ`,`Caribbean Netherlands`,`599`],[`KY`,`Cayman Islands`,`1`],[`CF`,`Central African Republic`,`236`],[`TD`,`Chad`,`235`],[`CL`,`Chile`,`56`],[`CN`,`China`,`86`],[`CX`,`Christmas Island`,`61`],[`CC`,`Cocos (Keeling) Islands`,`61`],[`CO`,`Colombia`,`57`],[`KM`,`Comoros`,`269`],[`CG`,`Congo - Brazzaville`,`242`],[`CD`,`Congo - Kinshasa`,`243`],[`CK`,`Cook Islands`,`682`],[`CR`,`Costa Rica`,`506`],[`CI`,`Côte d’Ivoire`,`225`],[`HR`,`Croatia`,`385`],[`CU`,`Cuba`,`53`],[`CW`,`Curaçao`,`599`],[`CY`,`Cyprus`,`357`],[`CZ`,`Czechia`,`420`],[`DK`,`Denmark`,`45`],[`DJ`,`Djibouti`,`253`],[`DM`,`Dominica`,`1`],[`DO`,`Dominican Republic`,`1`],[`EC`,`Ecuador`,`593`],[`EG`,`Egypt`,`20`],[`SV`,`El Salvador`,`503`],[`GQ`,`Equatorial Guinea`,`240`],[`ER`,`Eritrea`,`291`],[`EE`,`Estonia`,`372`],[`SZ`,`Eswatini`,`268`],[`ET`,`Ethiopia`,`251`],[`FK`,`Falkland Islands`,`500`],[`FO`,`Faroe Islands`,`298`],[`FJ`,`Fiji`,`679`],[`FI`,`Finland`,`358`],[`FR`,`France`,`33`],[`GF`,`French Guiana`,`594`],[`PF`,`French Polynesia`,`689`],[`GA`,`Gabon`,`241`],[`GM`,`Gambia`,`220`],[`GE`,`Georgia`,`995`],[`DE`,`Germany`,`49`],[`GH`,`Ghana`,`233`],[`GI`,`Gibraltar`,`350`],[`GR`,`Greece`,`30`],[`GL`,`Greenland`,`299`],[`GD`,`Grenada`,`1`],[`GP`,`Guadeloupe`,`590`],[`GU`,`Guam`,`1`],[`GT`,`Guatemala`,`502`],[`GG`,`Guernsey`,`44`],[`GN`,`Guinea`,`224`],[`GW`,`Guinea-Bissau`,`245`],[`GY`,`Guyana`,`592`],[`HT`,`Haiti`,`509`],[`HN`,`Honduras`,`504`],[`HK`,`Hong Kong SAR China`,`852`],[`HU`,`Hungary`,`36`],[`IS`,`Iceland`,`354`],[`IN`,`India`,`91`],[`ID`,`Indonesia`,`62`],[`IR`,`Iran`,`98`],[`IQ`,`Iraq`,`964`],[`IE`,`Ireland`,`353`],[`IM`,`Isle of Man`,`44`],[`IL`,`Israel`,`972`],[`IT`,`Italy`,`39`],[`JM`,`Jamaica`,`1`],[`JP`,`Japan`,`81`],[`JE`,`Jersey`,`44`],[`JO`,`Jordan`,`962`],[`KZ`,`Kazakhstan`,`7`],[`KE`,`Kenya`,`254`],[`KI`,`Kiribati`,`686`],[`XK`,`Kosovo`,`383`],[`KW`,`Kuwait`,`965`],[`KG`,`Kyrgyzstan`,`996`],[`LA`,`Laos`,`856`],[`LV`,`Latvia`,`371`],[`LB`,`Lebanon`,`961`],[`LS`,`Lesotho`,`266`],[`LR`,`Liberia`,`231`],[`LY`,`Libya`,`218`],[`LI`,`Liechtenstein`,`423`],[`LT`,`Lithuania`,`370`],[`LU`,`Luxembourg`,`352`],[`MO`,`Macao SAR China`,`853`],[`MG`,`Madagascar`,`261`],[`MW`,`Malawi`,`265`],[`MY`,`Malaysia`,`60`],[`MV`,`Maldives`,`960`],[`ML`,`Mali`,`223`],[`MT`,`Malta`,`356`],[`MH`,`Marshall Islands`,`692`],[`MQ`,`Martinique`,`596`],[`MR`,`Mauritania`,`222`],[`MU`,`Mauritius`,`230`],[`YT`,`Mayotte`,`262`],[`MX`,`Mexico`,`52`],[`FM`,`Micronesia`,`691`],[`MD`,`Moldova`,`373`],[`MC`,`Monaco`,`377`],[`MN`,`Mongolia`,`976`],[`ME`,`Montenegro`,`382`],[`MS`,`Montserrat`,`1`],[`MA`,`Morocco`,`212`],[`MZ`,`Mozambique`,`258`],[`MM`,`Myanmar (Burma)`,`95`],[`NA`,`Namibia`,`264`],[`NR`,`Nauru`,`674`],[`NP`,`Nepal`,`977`],[`NL`,`Netherlands`,`31`],[`NC`,`New Caledonia`,`687`],[`NZ`,`New Zealand`,`64`],[`NI`,`Nicaragua`,`505`],[`NE`,`Niger`,`227`],[`NG`,`Nigeria`,`234`],[`NU`,`Niue`,`683`],[`NF`,`Norfolk Island`,`672`],[`KP`,`North Korea`,`850`],[`MK`,`North Macedonia`,`389`],[`MP`,`Northern Mariana Islands`,`1`],[`NO`,`Norway`,`47`],[`OM`,`Oman`,`968`],[`PK`,`Pakistan`,`92`],[`PW`,`Palau`,`680`],[`PS`,`Palestinian Territories`,`970`],[`PA`,`Panama`,`507`],[`PG`,`Papua New Guinea`,`675`],[`PY`,`Paraguay`,`595`],[`PE`,`Peru`,`51`],[`PH`,`Philippines`,`63`],[`PL`,`Poland`,`48`],[`PT`,`Portugal`,`351`],[`PR`,`Puerto Rico`,`1`],[`QA`,`Qatar`,`974`],[`RE`,`Réunion`,`262`],[`RO`,`Romania`,`40`],[`RU`,`Russia`,`7`],[`RW`,`Rwanda`,`250`],[`WS`,`Samoa`,`685`],[`SM`,`San Marino`,`378`],[`ST`,`São Tomé & Príncipe`,`239`],[`SA`,`Saudi Arabia`,`966`],[`SN`,`Senegal`,`221`],[`RS`,`Serbia`,`381`],[`SC`,`Seychelles`,`248`],[`SL`,`Sierra Leone`,`232`],[`SG`,`Singapore`,`65`],[`SX`,`Sint Maarten`,`1`],[`SK`,`Slovakia`,`421`],[`SI`,`Slovenia`,`386`],[`SB`,`Solomon Islands`,`677`],[`SO`,`Somalia`,`252`],[`ZA`,`South Africa`,`27`],[`KR`,`South Korea`,`82`],[`SS`,`South Sudan`,`211`],[`ES`,`Spain`,`34`],[`LK`,`Sri Lanka`,`94`],[`BL`,`St. Barthélemy`,`590`],[`SH`,`St. Helena, Ascension & Tristan da Cunha`,`290`],[`KN`,`St. Kitts & Nevis`,`1`],[`LC`,`St. Lucia`,`1`],[`MF`,`St. Martin`,`590`],[`PM`,`St. Pierre & Miquelon`,`508`],[`VC`,`St. Vincent & Grenadines`,`1`],[`SD`,`Sudan`,`249`],[`SR`,`Suriname`,`597`],[`SJ`,`Svalbard & Jan Mayen`,`47`],[`SE`,`Sweden`,`46`],[`CH`,`Switzerland`,`41`],[`SY`,`Syria`,`963`],[`TW`,`Taiwan`,`886`],[`TJ`,`Tajikistan`,`992`],[`TZ`,`Tanzania`,`255`],[`TH`,`Thailand`,`66`],[`TL`,`Timor-Leste`,`670`],[`TG`,`Togo`,`228`],[`TK`,`Tokelau`,`690`],[`TO`,`Tonga`,`676`],[`TT`,`Trinidad & Tobago`,`1`],[`TA`,`Tristan da Cunha`,`290`],[`TN`,`Tunisia`,`216`],[`TR`,`Türkiye`,`90`],[`TM`,`Turkmenistan`,`993`],[`TC`,`Turks & Caicos Islands`,`1`],[`TV`,`Tuvalu`,`688`],[`VI`,`U.S. Virgin Islands`,`1`],[`UG`,`Uganda`,`256`],[`UA`,`Ukraine`,`380`],[`AE`,`United Arab Emirates`,`971`],[`GB`,`United Kingdom`,`44`],[`US`,`United States`,`1`],[`UY`,`Uruguay`,`598`],[`UZ`,`Uzbekistan`,`998`],[`VU`,`Vanuatu`,`678`],[`VA`,`Vatican City`,`39`],[`VE`,`Venezuela`,`58`],[`VN`,`Vietnam`,`84`],[`WF`,`Wallis & Futuna`,`681`],[`EH`,`Western Sahara`,`212`],[`YE`,`Yemen`,`967`],[`ZM`,`Zambia`,`260`],[`ZW`,`Zimbabwe`,`263`]],y=e=>v.find(t=>t[0]===e)?.[2]??``,b={AD:[`Europe/Andorra`],AE:[`Asia/Dubai`],AF:[`Asia/Kabul`],AG:[`America/Antigua`],AI:[`America/Anguilla`],AL:[`Europe/Tirane`],AM:[`Asia/Yerevan`],AO:[`Africa/Luanda`],AR:[`America/Argentina/Buenos_Aires`,`America/Argentina/Catamarca`,`America/Argentina/ComodRivadavia`,`America/Argentina/Cordoba`,`America/Argentina/Jujuy`,`America/Argentina/La_Rioja`,`America/Argentina/Mendoza`,`America/Argentina/Rio_Gallegos`,`America/Argentina/Salta`,`America/Argentina/San_Juan`,`America/Argentina/San_Luis`,`America/Argentina/Tucuman`,`America/Argentina/Ushuaia`,`America/Buenos_Aires`,`America/Catamarca`,`America/Cordoba`,`America/Jujuy`,`America/Mendoza`,`America/Rosario`],AS:[`Pacific/Pago_Pago`,`Pacific/Samoa`,`US/Samoa`],AT:[`Europe/Vienna`],AU:[`Antarctica/Macquarie`,`Australia/Adelaide`,`Australia/Brisbane`,`Australia/Broken_Hill`,`Australia/Canberra`,`Australia/Currie`,`Australia/Darwin`,`Australia/Eucla`,`Australia/Hobart`,`Australia/LHI`,`Australia/Lindeman`,`Australia/Lord_Howe`,`Australia/Melbourne`,`Australia/NSW`,`Australia/North`,`Australia/Perth`,`Australia/Queensland`,`Australia/South`,`Australia/Sydney`,`Australia/Tasmania`,`Australia/Victoria`,`Australia/West`,`Australia/Yancowinna`],AW:[`America/Aruba`],AX:[`Europe/Mariehamn`],AZ:[`Asia/Baku`],BA:[`Europe/Sarajevo`],BB:[`America/Barbados`],BD:[`Asia/Dacca`,`Asia/Dhaka`],BE:[`Europe/Brussels`],BF:[`Africa/Ouagadougou`],BG:[`Europe/Sofia`],BH:[`Asia/Bahrain`],BI:[`Africa/Bujumbura`],BJ:[`Africa/Porto-Novo`],BL:[`America/St_Barthelemy`],BM:[`Atlantic/Bermuda`],BN:[`Asia/Brunei`],BO:[`America/La_Paz`],BQ:[`America/Kralendijk`],BR:[`America/Araguaina`,`America/Bahia`,`America/Belem`,`America/Boa_Vista`,`America/Campo_Grande`,`America/Cuiaba`,`America/Eirunepe`,`America/Fortaleza`,`America/Maceio`,`America/Manaus`,`America/Noronha`,`America/Porto_Acre`,`America/Porto_Velho`,`America/Recife`,`America/Rio_Branco`,`America/Santarem`,`America/Sao_Paulo`,`Brazil/DeNoronha`,`Brazil/East`,`Brazil/West`],BS:[`America/Nassau`],BT:[`Asia/Thimbu`,`Asia/Thimphu`],BW:[`Africa/Gaborone`],BY:[`Europe/Minsk`],BZ:[`America/Belize`],CA:`America/Atikokan.America/Blanc-Sablon.America/Cambridge_Bay.America/Coral_Harbour.America/Creston.America/Dawson.America/Dawson_Creek.America/Edmonton.America/Fort_Nelson.America/Glace_Bay.America/Goose_Bay.America/Halifax.America/Inuvik.America/Iqaluit.America/Moncton.America/Montreal.America/Nipigon.America/Pangnirtung.America/Rainy_River.America/Rankin_Inlet.America/Regina.America/Resolute.America/St_Johns.America/Swift_Current.America/Thunder_Bay.America/Toronto.America/Vancouver.America/Whitehorse.America/Winnipeg.America/Yellowknife.Canada/Atlantic.Canada/Central.Canada/Eastern.Canada/Mountain.Canada/Newfoundland.Canada/Pacific.Canada/Saskatchewan.Canada/Yukon`.split(`.`),CC:[`Indian/Cocos`],CD:[`Africa/Kinshasa`,`Africa/Lubumbashi`],CF:[`Africa/Bangui`],CG:[`Africa/Brazzaville`],CH:[`Europe/Zurich`],CI:[`Africa/Abidjan`],CK:[`Pacific/Rarotonga`],CL:[`America/Coyhaique`,`America/Punta_Arenas`,`America/Santiago`,`Chile/Continental`,`Chile/EasterIsland`,`Pacific/Easter`],CM:[`Africa/Douala`],CN:[`Asia/Chongqing`,`Asia/Harbin`,`Asia/Kashgar`,`Asia/Shanghai`,`Asia/Urumqi`],CO:[`America/Bogota`],CR:[`America/Costa_Rica`],CU:[`America/Havana`],CV:[`Atlantic/Cape_Verde`],CW:[`America/Curacao`],CX:[`Indian/Christmas`],CY:[`Asia/Famagusta`,`Asia/Nicosia`,`Europe/Nicosia`],CZ:[`Europe/Prague`],DE:[`Europe/Berlin`,`Europe/Busingen`],DJ:[`Africa/Djibouti`],DK:[`Europe/Copenhagen`],DM:[`America/Dominica`],DO:[`America/Santo_Domingo`],DZ:[`Africa/Algiers`],EC:[`America/Guayaquil`,`Pacific/Galapagos`],EE:[`Europe/Tallinn`],EG:[`Africa/Cairo`],EH:[`Africa/El_Aaiun`],ER:[`Africa/Asmara`,`Africa/Asmera`],ES:[`Africa/Ceuta`,`Atlantic/Canary`,`Europe/Madrid`],ET:[`Africa/Addis_Ababa`],FI:[`Europe/Helsinki`],FJ:[`Pacific/Fiji`],FK:[`Atlantic/Stanley`],FM:[`Pacific/Chuuk`,`Pacific/Kosrae`,`Pacific/Pohnpei`,`Pacific/Ponape`,`Pacific/Truk`,`Pacific/Yap`],FO:[`Atlantic/Faeroe`,`Atlantic/Faroe`],FR:[`Europe/Paris`],GA:[`Africa/Libreville`],GB:[`Europe/Belfast`,`Europe/London`],GD:[`America/Grenada`],GE:[`Asia/Tbilisi`],GF:[`America/Cayenne`],GG:[`Europe/Guernsey`],GH:[`Africa/Accra`],GI:[`Europe/Gibraltar`],GL:[`America/Danmarkshavn`,`America/Godthab`,`America/Nuuk`,`America/Scoresbysund`,`America/Thule`],GM:[`Africa/Banjul`],GN:[`Africa/Conakry`],GP:[`America/Guadeloupe`],GQ:[`Africa/Malabo`],GR:[`Europe/Athens`],GT:[`America/Guatemala`],GU:[`Pacific/Guam`],GW:[`Africa/Bissau`],GY:[`America/Guyana`],HK:[`Asia/Hong_Kong`],HN:[`America/Tegucigalpa`],HR:[`Europe/Zagreb`],HT:[`America/Port-au-Prince`],HU:[`Europe/Budapest`],ID:[`Asia/Jakarta`,`Asia/Jayapura`,`Asia/Makassar`,`Asia/Pontianak`,`Asia/Ujung_Pandang`],IE:[`Europe/Dublin`],IL:[`Asia/Jerusalem`,`Asia/Tel_Aviv`],IM:[`Europe/Isle_of_Man`],IN:[`Asia/Calcutta`,`Asia/Kolkata`],IO:[`Indian/Chagos`],IQ:[`Asia/Baghdad`],IR:[`Asia/Tehran`],IS:[`Atlantic/Reykjavik`],IT:[`Europe/Rome`],JE:[`Europe/Jersey`],JM:[`America/Jamaica`],JO:[`Asia/Amman`],JP:[`Asia/Tokyo`],KE:[`Africa/Nairobi`],KG:[`Asia/Bishkek`],KH:[`Asia/Phnom_Penh`],KI:[`Pacific/Enderbury`,`Pacific/Kanton`,`Pacific/Kiritimati`,`Pacific/Tarawa`],KM:[`Indian/Comoro`],KN:[`America/St_Kitts`],KP:[`Asia/Pyongyang`],KR:[`Asia/Seoul`],KW:[`Asia/Kuwait`],KY:[`America/Cayman`],KZ:[`Asia/Almaty`,`Asia/Aqtau`,`Asia/Aqtobe`,`Asia/Atyrau`,`Asia/Oral`,`Asia/Qostanay`,`Asia/Qyzylorda`],LA:[`Asia/Vientiane`],LB:[`Asia/Beirut`],LC:[`America/St_Lucia`],LI:[`Europe/Vaduz`],LK:[`Asia/Colombo`],LR:[`Africa/Monrovia`],LS:[`Africa/Maseru`],LT:[`Europe/Vilnius`],LU:[`Europe/Luxembourg`],LV:[`Europe/Riga`],LY:[`Africa/Tripoli`],MA:[`Africa/Casablanca`],MC:[`Europe/Monaco`],MD:[`Europe/Chisinau`,`Europe/Tiraspol`],ME:[`Europe/Podgorica`],MF:[`America/Marigot`],MG:[`Indian/Antananarivo`],MH:[`Pacific/Kwajalein`,`Pacific/Majuro`],MK:[`Europe/Skopje`],ML:[`Africa/Bamako`,`Africa/Timbuktu`],MM:[`Asia/Rangoon`,`Asia/Yangon`],MN:[`Asia/Choibalsan`,`Asia/Hovd`,`Asia/Ulaanbaatar`,`Asia/Ulan_Bator`],MO:[`Asia/Macao`,`Asia/Macau`],MP:[`Pacific/Saipan`],MQ:[`America/Martinique`],MR:[`Africa/Nouakchott`],MS:[`America/Montserrat`],MT:[`Europe/Malta`],MU:[`Indian/Mauritius`],MV:[`Indian/Maldives`],MW:[`Africa/Blantyre`],MX:[`America/Bahia_Banderas`,`America/Cancun`,`America/Chihuahua`,`America/Ciudad_Juarez`,`America/Ensenada`,`America/Hermosillo`,`America/Matamoros`,`America/Mazatlan`,`America/Merida`,`America/Mexico_City`,`America/Monterrey`,`America/Ojinaga`,`America/Santa_Isabel`,`America/Tijuana`,`Mexico/BajaNorte`,`Mexico/BajaSur`,`Mexico/General`],MY:[`Asia/Kuala_Lumpur`,`Asia/Kuching`],MZ:[`Africa/Maputo`],NA:[`Africa/Windhoek`],NC:[`Pacific/Noumea`],NE:[`Africa/Niamey`],NF:[`Pacific/Norfolk`],NG:[`Africa/Lagos`],NI:[`America/Managua`],NL:[`Europe/Amsterdam`],NO:[`Europe/Oslo`],NP:[`Asia/Kathmandu`,`Asia/Katmandu`],NR:[`Pacific/Nauru`],NU:[`Pacific/Niue`],NZ:[`Pacific/Auckland`,`Pacific/Chatham`],OM:[`Asia/Muscat`],PA:[`America/Panama`],PE:[`America/Lima`],PF:[`Pacific/Gambier`,`Pacific/Marquesas`,`Pacific/Tahiti`],PG:[`Pacific/Bougainville`,`Pacific/Port_Moresby`],PH:[`Asia/Manila`],PK:[`Asia/Karachi`],PL:[`Europe/Warsaw`],PM:[`America/Miquelon`],PR:[`America/Puerto_Rico`],PS:[`Asia/Gaza`,`Asia/Hebron`],PT:[`Atlantic/Azores`,`Atlantic/Madeira`,`Europe/Lisbon`],PW:[`Pacific/Palau`],PY:[`America/Asuncion`],QA:[`Asia/Qatar`],RE:[`Indian/Reunion`],RO:[`Europe/Bucharest`],RS:[`Europe/Belgrade`],RU:`Asia/Anadyr.Asia/Barnaul.Asia/Chita.Asia/Irkutsk.Asia/Kamchatka.Asia/Khandyga.Asia/Krasnoyarsk.Asia/Magadan.Asia/Novokuznetsk.Asia/Novosibirsk.Asia/Omsk.Asia/Sakhalin.Asia/Srednekolymsk.Asia/Tomsk.Asia/Ust-Nera.Asia/Vladivostok.Asia/Yakutsk.Asia/Yekaterinburg.Europe/Astrakhan.Europe/Kaliningrad.Europe/Kirov.Europe/Moscow.Europe/Samara.Europe/Saratov.Europe/Ulyanovsk.Europe/Volgograd`.split(`.`),RW:[`Africa/Kigali`],SA:[`Asia/Riyadh`],SB:[`Pacific/Guadalcanal`],SC:[`Indian/Mahe`],SD:[`Africa/Khartoum`],SE:[`Europe/Stockholm`],SG:[`Asia/Singapore`],SH:[`Atlantic/St_Helena`],SI:[`Europe/Ljubljana`],SJ:[`Arctic/Longyearbyen`,`Atlantic/Jan_Mayen`],SK:[`Europe/Bratislava`],SL:[`Africa/Freetown`],SM:[`Europe/San_Marino`],SN:[`Africa/Dakar`],SO:[`Africa/Mogadishu`],SR:[`America/Paramaribo`],SS:[`Africa/Juba`],ST:[`Africa/Sao_Tome`],SV:[`America/El_Salvador`],SX:[`America/Lower_Princes`],SY:[`Asia/Damascus`],SZ:[`Africa/Mbabane`],TC:[`America/Grand_Turk`],TD:[`Africa/Ndjamena`],TG:[`Africa/Lome`],TH:[`Asia/Bangkok`],TJ:[`Asia/Dushanbe`],TK:[`Pacific/Fakaofo`],TL:[`Asia/Dili`],TM:[`Asia/Ashgabat`,`Asia/Ashkhabad`],TN:[`Africa/Tunis`],TO:[`Pacific/Tongatapu`],TR:[`Asia/Istanbul`,`Europe/Istanbul`],TT:[`America/Port_of_Spain`],TV:[`Pacific/Funafuti`],TW:[`Asia/Taipei`],TZ:[`Africa/Dar_es_Salaam`],UA:[`Europe/Kiev`,`Europe/Kyiv`,`Europe/Simferopol`,`Europe/Uzhgorod`,`Europe/Zaporozhye`],UG:[`Africa/Kampala`],US:`America/Adak.America/Anchorage.America/Atka.America/Boise.America/Chicago.America/Denver.America/Detroit.America/Fort_Wayne.America/Indiana/Indianapolis.America/Indiana/Knox.America/Indiana/Marengo.America/Indiana/Petersburg.America/Indiana/Tell_City.America/Indiana/Vevay.America/Indiana/Vincennes.America/Indiana/Winamac.America/Indianapolis.America/Juneau.America/Kentucky/Louisville.America/Kentucky/Monticello.America/Knox_IN.America/Los_Angeles.America/Louisville.America/Menominee.America/Metlakatla.America/New_York.America/Nome.America/North_Dakota/Beulah.America/North_Dakota/Center.America/North_Dakota/New_Salem.America/Phoenix.America/Shiprock.America/Sitka.America/Yakutat.Pacific/Honolulu.US/Alaska.US/Aleutian.US/Arizona.US/Central.US/East-Indiana.US/Eastern.US/Hawaii.US/Indiana-Starke.US/Michigan.US/Mountain.US/Pacific`.split(`.`),UY:[`America/Montevideo`],UZ:[`Asia/Samarkand`,`Asia/Tashkent`],VA:[`Europe/Vatican`],VC:[`America/St_Vincent`],VE:[`America/Caracas`],VG:[`America/Tortola`],VI:[`America/St_Thomas`,`America/Virgin`],VN:[`Asia/Ho_Chi_Minh`,`Asia/Saigon`],VU:[`Pacific/Efate`],WF:[`Pacific/Wallis`],WS:[`Pacific/Apia`],YE:[`Asia/Aden`],YT:[`Indian/Mayotte`],ZA:[`Africa/Johannesburg`],ZM:[`Africa/Lusaka`],ZW:[`Africa/Harare`]},x=new Set(v.map(([e])=>e)),S=new Map;for(let[e,t]of Object.entries(b))for(let n of t)S.set(n,e);function C(e){let t=e===void 0?void 0:S.get(e);return t&&x.has(t)?t:null}function w(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&x.has(t)?t:null}function T(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return C(e)||w(t)||null}var E=`ui-phone.global.js`;function D(){return window.WeborityPhone?Promise.resolve(window.WeborityPhone):new Promise((e,t)=>{let n=document.querySelector(`script[src*="${E}"]`);if(!n){let e=document.createElement(`script`);try{e.src=(0,d.assetUrl)(E)}catch(e){t(e);return}document.head.append(e),n=e}n.addEventListener(`load`,()=>window.WeborityPhone?e(window.WeborityPhone):t(Error(`The phone metadata script did not load.`))),n.addEventListener(`error`,()=>t(Error(`The phone metadata script failed to load.`)))})}var O={chooseCountryLabel:`Choose country`,chooseCountryMessage:`Choose a country`,examplePlaceholder:`For example {example}`,invalidNumberExampleMessage:`Enter a valid phone number, e.g. {example}`,invalidNumberMessage:`Enter a valid phone number`,noCountriesFoundLabel:`No countries found`,placeholder:`Enter phone number`,searchCountriesLabel:`Search countries`,searchCountryPlaceholder:`Search country or code`},k=()=>(0,f.readText)(`phone`,O);function A(e,t){return e.isSupportedCountry(t)}var j=e=>e?`wui-flag wui-flag-${String(e).toLowerCase()}`:`wui-flag`,M=e=>e?`+${y(e)}`:``,N=null,P=null;function F(){return N?Promise.resolve(N):(P||=D().then(e=>(N=e,N)).catch(e=>((0,n.devError)(`[@webority/ui-elements] <wui-phone> could not load its phone number metadata.`,e),null)),P)}function I(e,t){let n=`+${y(e)}`;return t?.startsWith(n)?t.slice(n.length).trimStart():null}function L(e,t){if(!N||!t||!e||!A(N,e))return t;try{return I(e,new N.AsYouType(e).input(`+${y(e)}${t}`))||t}catch{return t}}function R(e,t){if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r++)if(/[0-9]/.test(e[r]??``)&&(n+=1,n===t))return r+1;return e.length}function z(e){if(!N||!e||!A(N,e))return null;try{return I(e,N.getExampleNumber(e,N.examples)?.formatInternational())||null}catch{return null}}function B(e){let t=z(e);return t?(0,f.fillText)(k().examplePlaceholder,{example:t}):null}function V(e){if(!N||!e)return null;try{if(!N.isValidPhoneNumber(e))return!1;let t=N.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function H(e){if(!N||!e||!A(N,e))return null;try{let t=N.getExampleNumber(e,N.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function U(e,t,n){if(!N||!A(N,e))return null;try{let r=N.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function W(e){if(!N||!e?.trim().startsWith(`+`))return null;try{let t=new N.AsYouType;t.input(e.trim());let n=t.getCountry();return!n||!X(t)?null:{country:n,national:t.getNationalNumber()||``}}catch{return null}}function G(e,t){let n=String(t??``).trim();if(!n.startsWith(`+`))return null;let r=n.replace(/[^0-9]/g,``),i=String(y(e));return{country:e,national:r.startsWith(i)?r.slice(i.length):r}}var K=class extends i.ElementBase{static formAssociated=!0;static whenFormatted(){return F().then(()=>void 0)}static get observedAttributes(){return[`value`,`country`,`locked-country`,`placeholder`,`disabled`,`readonly`,`loading`,`required`,`aria-label`,`aria-describedby`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._defaultCountry=T()||``,this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``,this._validateOnInput=!1}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){let e=J(this.querySelector(`.country-dropdown-menu`),HTMLElement);e&&(0,u.closeAnchoredPopover)(e)}attributeChangedCallback(e,t,n){if(e===`value`)this.value=n;else if(this._rendered){if(e===`aria-label`){let t=this.querySelector(`input[type=tel]`);t&&(n==null?t.removeAttribute(e):t.setAttribute(e,n))}else if(e===`aria-describedby`)this._syncDescribedBy();else if(e===`country`){if(this._locked)return;let e=this.value;if(this._country=n||this._defaultCountry,this._suppressCountryRender)return;this.render(),this.value!==e&&(this._emitInput(),this._emitChange())}else this.render()}}formResetCallback(){this._validateOnInput=!1,this.value=this._defaultValue||``}get _locked(){return(this.getAttribute(`locked-country`)||``).toUpperCase()||null}get value(){return this._national&&this._country?`+${y(this._country)}${this._national}`:``}set value(e){let t=String(e??``).trim();this._locked&&(this._country=this._locked);let n=this._locked?null:W(t);if(n)this._country=n.country,this._national=n.national.replace(/[^0-9]/g,``);else if(t.startsWith(`+`)){let e=t.replace(/[^0-9]/g,``),n=String(y(this._locked||this.getAttribute(`country`)||this._country));n&&e.startsWith(n)&&(e=e.slice(n.length)),this._national=e}else this._national=t.replace(/[^0-9]/g,``);n&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){(0,o.syncFormMirror)(this,this.value)}_syncDescribedBy(){let e=this.querySelector(`input[type=tel]`);if(!e)return;let t=[this.getAttribute(`aria-describedby`),this.querySelector(`[data-phone-error]`)?.id].filter(Boolean);t.length?e.setAttribute(`aria-describedby`,t.join(` `)):e.removeAttribute(`aria-describedby`)}_emitInput(){this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_emitChange(){this._committedValue=this.value,this.dispatchEvent(new Event(`change`,{bubbles:!0}))}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``),this._country=this._locked||this.getAttribute(`country`)||this._country;let e=this.getAttribute(`placeholder`)||B(this._country)||k().placeholder;this.id||=`wui-phone-${Math.random().toString(36).slice(2,9)}`;let t=`${this.id}-listbox`;this._listboxId=t;let n=this._locked?(0,r.make)(`div`,{class:`phone-country-adornment`},(0,r.make)(`span`,{class:`wui-phone-prefix`},(0,r.make)(`span`,{class:j(this._country),"data-flag":!0,"aria-hidden":`true`}),(0,r.make)(`span`,{class:`phone-dial`,"data-dial":!0},M(this._country)))):(0,r.make)(`div`,{class:`phone-country-adornment`},(0,r.make)(`button`,{type:`button`,class:`country-toggle`,"aria-label":k().chooseCountryLabel,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":t,disabled:this.hasAttribute(`disabled`)||void 0},(0,r.make)(`span`,{class:j(this._country),"data-flag":!0,"aria-hidden":`true`}),(0,s.glyphNode)(`chevron-down`,{className:`phone-chevron`}),(0,r.make)(`span`,{class:`phone-dial`,"data-dial":!0},M(this._country))),(0,r.make)(`div`,{class:`country-dropdown-menu`,popover:`auto`},(0,r.make)(`div`,{class:`dropdown-search-wrapper`},(0,r.make)(`span`,{class:`dropdown-search-icon`},(0,s.glyphNode)(`search`)),(0,r.make)(`input`,{type:`text`,class:`dropdown-search-input`,placeholder:k().searchCountryPlaceholder,"aria-label":k().searchCountriesLabel,"aria-controls":t,"aria-autocomplete":`list`})),(0,r.make)(`div`,{class:`country-list-scroll`,role:`listbox`,id:t,tabindex:`-1`}),(0,r.make)(`div`,{class:`country-empty`,hidden:!0},k().noCountriesFoundLabel))),i=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`),l=(0,r.make)(`input`,{type:`tel`,class:`input`,placeholder:e,value:L(this._country,this._national),"aria-label":i||void 0,"aria-describedby":c||void 0,required:this.hasAttribute(`required`)||void 0,"aria-required":this.hasAttribute(`required`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)||void 0,readonly:(0,a.isInert)(this)||void 0});this.replaceChildren((0,r.make)(`div`,{class:`phone-input-wrap`},n,l)),this._rendered=!0,(0,a.syncFieldState)(this,this.querySelector(`input.input`)),(0,o.syncFormMirror)(this,this.value),this._wire()}_ensureItems(){let e=J(this.querySelector(`.country-list-scroll`),HTMLElement);if(!e||e.querySelector(`.country-dropdown-item`))return;let t=this._listboxId,n=v.map(([e,n,i],a)=>(0,r.make)(`button`,{type:`button`,role:`option`,id:`${t}-opt-${a}`,class:`country-dropdown-item${e===this._country?` selected`:``}`,"data-iso":e,"aria-selected":String(e===this._country)},(0,r.make)(`span`,{class:j(e),"aria-hidden":`true`}),(0,r.make)(`span`,{class:`country-name-text`},n,(0,r.make)(`span`,{class:`country-code-text`},`+${i}`))));e.prepend(...n)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)].filter(e=>e instanceof HTMLElement)}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){let e=J(this.querySelector(`.country-toggle`),HTMLButtonElement),t=q(J(this.querySelector(`.phone-input-wrap`),HTMLElement),`phone input wrapper`),n=J(this.querySelector(`.country-dropdown-menu`),HTMLElement),r=J(this.querySelector(`.dropdown-search-input`),HTMLInputElement),i=J(this.querySelector(`.country-list-scroll`),HTMLElement),o=J(this.querySelector(`.country-empty`),HTMLElement),s=q(J(this.querySelector(`input[type=tel]`),HTMLInputElement),`phone input`),d=J(this.querySelector(`[data-flag]`),HTMLElement),p=J(this.querySelector(`[data-dial]`),HTMLElement),m=()=>n!==null&&(0,u.isPopoverOpen)(n),h=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,(0,l.moveActiveRow)(q(i,`country list`),e>=0&&n[e]||null);let a=e>=0?n[e]:void 0;a?(t&&a.scrollIntoView({block:`nearest`}),r?.setAttribute(`aria-activedescendant`,a.id)):r?.removeAttribute(`aria-activedescendant`)},g=()=>{m()||(q(e,`country toggle`).setAttribute(`aria-expanded`,`false`),h(-1))},_=()=>{if((0,a.isInert)(this)||(this._ensureItems(),(0,u.openAnchoredPopover)(t,q(n,`country menu`),{mode:`auto`,onClosed:g}),!m()))return;q(e,`country toggle`).setAttribute(`aria-expanded`,`true`);let i=q(r,`country search`);i.value=``,b(``),i.focus(),h(this._visibleItems().findIndex(e=>e.classList.contains(`selected`)))},v=()=>{(0,u.closeAnchoredPopover)(q(n,`country menu`))},b=e=>{let t=e.trim().toLowerCase(),n=0;for(let e of this._itemEls()){let r=!t||(e.textContent??``).toLowerCase().includes(t);e.hidden=!r,r&&(n+=1)}o&&(o.hidden=n>0)},x=e=>{this._country=e,this.getAttribute(`country`)!==e&&(this._suppressCountryRender=!0,this.setAttribute(`country`,e),this._suppressCountryRender=!1),d&&(d.className=j(e)),p&&(p.textContent=`+${y(e)}`);for(let t of this._itemEls()){let n=t.dataset.iso===e;t.classList.toggle(`selected`,n),t.setAttribute(`aria-selected`,String(n))}this.getAttribute(`placeholder`)||(s.placeholder=B(e)||k().placeholder),this._national&&(s.value=L(e,this._national)),v(),this._syncMirror(),this._emitChange(),this._validateOnInput&&C(w()),s.focus()},S=t=>{let n=this._visibleItems();if(t.key===`ArrowDown`){if(t.preventDefault(),!m()){_();return}h(Math.min(this._active+1,n.length-1))}else if(t.key===`ArrowUp`){if(t.preventDefault(),!m())return;h(Math.max(this._active-1,0))}else if((0,c.isImeSafeEnter)(t)){t.preventDefault();let e=n[this._active];m()&&e?.dataset.iso&&x(e.dataset.iso)}else t.key===`Escape`&&m()&&(t.preventDefault(),t.stopPropagation(),v(),q(e,`country toggle`).focus())};e?.addEventListener(`click`,()=>m()?v():_()),e?.addEventListener(`keydown`,e=>{m()?S(e):(e.key===`ArrowDown`||(0,c.isImeSafeEnter)(e)||e.key===` `)&&(e.preventDefault(),_())}),r&&r.addEventListener(`input`,()=>{b(r.value);let e=this._visibleItems();h(e.length?0:-1)}),i?.addEventListener(`click`,e=>{let t=J(Y(e).closest(`.country-dropdown-item`),HTMLElement);t?.dataset.iso&&x(t.dataset.iso)}),i?.addEventListener(`mousemove`,e=>{let t=J(Y(e).closest(`.country-dropdown-item`),HTMLElement);t&&!t.classList.contains(`is-active`)&&h(this._visibleItems().indexOf(t),{reveal:!1})}),i?.addEventListener(`mouseleave`,()=>h(-1)),n?.addEventListener(`keydown`,S);let C=e=>{s.classList.toggle(`is-invalid`,e),e?s.setAttribute(`aria-invalid`,`true`):s.removeAttribute(`aria-invalid`);let n=J(this.querySelector(`[data-phone-error]`),HTMLElement);if(e&&!this.hasAttribute(`external-error`)){n||(n=document.createElement(`div`),n.className=`field-error`,n.id=`${this.id}-phone-error`,n.setAttribute(`data-phone-error`,``),t.after(n));let e=z(this._country);n.textContent=this._country?e?(0,f.fillText)(k().invalidNumberExampleMessage,{example:e}):k().invalidNumberMessage:k().chooseCountryMessage}else n?.remove();this._syncDescribedBy()},w=()=>this._national.length>0&&(!this._country||V(this.value)===!1);s.addEventListener(`input`,e=>{e.stopPropagation();let t=s.selectionStart??s.value.length,n=s.value.slice(0,t).replace(/[^0-9]/g,``).length,r=s.value.replace(/[^0-9]/g,``),i=H(this._country);if(i&&r.length>i){let e=U(this._country,r,i);e?(n=Math.max(0,n-(r.length-e.length)),r=e):r=r.slice(0,i)}this._national=r;let a=L(this._country,this._national);if(s.value!==a){s.value=a;let e=R(a,Math.min(n,r.length));s.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),this._validateOnInput&&C(w())}),s.addEventListener(`change`,e=>e.stopPropagation()),s.addEventListener(`blur`,()=>{let e=w();C(e),e&&(this._validateOnInput=!0),this.value!==this._committedValue&&this._emitChange()}),s.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text`),n=this._locked?G(this._locked,t):W(t);n&&(e.preventDefault(),this._national=n.national.replace(/[^0-9]/g,``),n.country===this._country?s.value=L(this._country,this._national):(this._country=n.country,this.setAttribute(`country`,n.country)),this._syncMirror(),this._emitInput(),this._emitChange(),this._validateOnInput&&s.isConnected&&C(w()),J(this.querySelector(`input[type=tel]`),HTMLInputElement)?.focus())}),this._validateOnInput&&C(w()),F().then(e=>{if(e&&s.isConnected){if(this._national){let e=L(this._country,this._national);s.defaultValue=e,s.value=e}if(!this.getAttribute(`placeholder`)){let e=B(this._country);e&&(s.placeholder=e)}}}),this._syncMirror()}};function q(e,t){if(e==null)throw Error(`${t} missing`);return e}function J(e,t){return e instanceof t?e:null}function Y(e){if(!(e.target instanceof Element))throw Error(`Event target is not an element`);return e.target}function X(e){return`getNationalNumber`in e&&typeof e.getNationalNumber==`function`}(0,t.defineElement)(`wui-phone`,K);var ee=g({default:()=>ie}),Z=()=>(0,f.readText)(`select`,p.SELECT_TEXT),te=/^\+?\d+$/,Q=e=>String(e??``).split(`,`).map(e=>e.trim().toUpperCase()).filter(Boolean),ne=e=>{let t=Q(e.getAttribute(`countries`)),n=t.length?new Set(t):null,r=v.filter(([e])=>!n||n.has(e)),i=new Map(r.map(e=>[e[0],e])),a=[...new Set(Q(e.getAttribute(`suggested`)))].map(e=>i.get(e)).filter(e=>e!==void 0);if(!a.length)return r.map(e=>({tuple:e,group:null}));let o=new Set(a.map(e=>e[0])),s=e.getAttribute(`suggested-label`)||Z().suggestedLabel,c=e.getAttribute(`all-countries-label`)||Z().allCountriesLabel;return[...a.map(e=>({tuple:e,group:s})),...r.filter(e=>!o.has(e[0])).map(e=>({tuple:e,group:c}))]},$=({tuple:[e,t,n],group:r})=>({value:e,label:t,flag:e,meta:`+${n}`,...r?{group:r}:{}}),re=([,e,t],n)=>n?te.test(n)?t.startsWith(n.replace(`+`,``)):e.toLowerCase().includes(n):!0;function ie(){let e,t=[];return{mount(n){e=n,t=ne(n),n.setPartOptions(t.map($))},onQuery(n){let r=n.trim().toLowerCase();return e.setPartOptions(t.filter(e=>re(e.tuple,r)).map($)),!0},teardown(){}}}(0,m.registerSelectPart)(`country`,ee),e.WuiPhone=K})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.listboxKeyNav,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.loader,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.selectText,WeborityUiElementsInternal.modules.partRegistry);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.173.
|
|
1
|
+
(function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.173.1`)throw Error(`[webority-ui] popover expects ui-elements 0.173.1 but the page loaded `+i+`.`);var a=80,o=220,s=`:scope > [data-wui-popover-trigger]`,c=`:scope > [data-wui-popover-panel]`,l=`.popover-arrow`,u=`.popover-header`,d=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,f=[`click`,`hover`,`focus`],p=[`top`,`bottom`,`start`,`end`,`auto`],m=0;function h(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}function g(e){return e.pointerType===`touch`||e.pointerType===`pen`}var _=class extends n.ElementBase{_open;_timer;_pressOpen;_refocusing;_awaitChildren;_onPress;_onClick;_onOver;_onOut;_onFocusIn;_onFocusOut;_onKeyDown;static get observedAttributes(){return[`open`,`trigger`,`placement`,`open-delay`,`close-delay`,`role-dialog`,`auto-focus`,`labelled-by`]}constructor(){super(),this._open=!1,this._timer=null,this._pressOpen=null,this._refocusing=!1,this._awaitChildren=null,this._onPress=e=>{this._pressOpen=this._zone(e.target)===`trigger`?this._open:null},this._onClick=e=>{if(this._zone(e.target)!==`trigger`||!this._kinds().includes(`click`))return;let t=this._pressOpen??this._open;this._pressOpen=null,this._requestOpen(!t)},this._onOver=e=>{if(g(e))return;let t=this._zone(e.target);t===`panel`?this._clear():t===`trigger`&&this._kinds().includes(`hover`)&&this._schedule(!0)},this._onOut=e=>{!g(e)&&this._kinds().includes(`hover`)&&this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onFocusIn=e=>{if(this._refocusing)return;let t=this._zone(e.target);t===`trigger`&&this._kinds().includes(`focus`)?this._requestOpen(!0):t===`panel`&&this._clear()},this._onFocusOut=e=>{this._kinds().includes(`focus`)&&this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._requestOpen(!1)},this._onKeyDown=e=>{if(e.key!==`Escape`||!this._open)return;e.preventDefault();let t=this._zone(this.ownerDocument.activeElement)===`panel`;this._clear(),this._requestOpen(!1),t&&!this._open&&this._trigger?.focus()}}get isOpen(){return this._open}show(){this._open||(this._applyOpen(!0),this._notify(!0,!1))}hide(){this._open&&(this._applyOpen(!1),this._notify(!1,!1))}connectedCallback(){this.addEventListener(`pointerdown`,this._onPress),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerover`,this._onOver),this.addEventListener(`pointerout`,this._onOut),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._stampTrigger(),this._openOrAwaitChildren()}attributeChangedCallback(e){e===`open`&&this._awaitChildren?this.hasAttribute(`open`)||this._disarmAwait():e===`open`&&this.isConnected&&this._openOrAwaitChildren()}disconnectedCallback(){this._disarmAwait(),this._clear(),this.removeEventListener(`pointerdown`,this._onPress),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerover`,this._onOver),this.removeEventListener(`pointerout`,this._onOut),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this.ownerDocument.removeEventListener(`keydown`,this._onKeyDown),this._open=!1;let e=this._panel;e&&(0,r.closeAnchoredPopover)(e)}get _panel(){return h(this,c)}get _trigger(){let e=h(this,s);if(e)return e;for(let e of this.children)if(e instanceof HTMLElement&&!e.hasAttribute(`data-wui-popover-panel`))return e;return null}_stampTrigger(){let e=this._trigger;e&&(e.setAttribute(`data-wui-popover-trigger`,``),(this.getAttribute(`trigger`)??`click`).split(/\s+/).includes(`click`)&&!e.hasAttribute(`aria-expanded`)&&e.setAttribute(`aria-expanded`,`false`))}_zone(e){if(!(e instanceof Node)||!this.contains(e))return null;let t=e instanceof Element?e:e.parentElement;return this._panel?.contains(t)?`panel`:this._trigger?.contains(t)?`trigger`:null}_kinds(){let e=(this.getAttribute(`trigger`)??`click`).split(/\s+/).filter(Boolean),t=[];for(let n of e){let e=f.find(e=>e===n);if(!e)throw RangeError(`<wui-popover>: trigger="${n}" is not click, hover or focus.`);t.push(e)}if(t.length===0)throw RangeError(`<wui-popover>: trigger is empty; name click, hover or focus.`);return t}_side(){let e=this.getAttribute(`placement`)??`bottom`,t=p.find(t=>t===e);if(!t)throw RangeError(`<wui-popover>: placement="${e}" is not top, bottom, start, end or auto.`);return t}_delay(e,t){if(!this.hasAttribute(e))return t;let n=this.getAttribute(e)??``,r=Number(n);if(n.trim()===``||!Number.isFinite(r)||r<0)throw RangeError(`<wui-popover>: ${e}="${n}" is not zero or more milliseconds.`);return r}_clear(){this._timer!==null&&clearTimeout(this._timer),this._timer=null}_schedule(e){if(this._clear(),this._open===e)return;let t=e?this._delay(`open-delay`,a):this._delay(`close-delay`,o);this._timer=setTimeout(()=>{this._timer=null,this._requestOpen(e)},t)}_requestOpen(e){e!==this._open&&(e&&this._ready(),this._notify(e,!0)&&this._applyOpen(e))}_notify(e,t){return this.dispatchEvent(new CustomEvent(`wui-popover-toggle`,{bubbles:!0,cancelable:t,detail:{open:e}}))}_mode(){return this._kinds().includes(`click`)?`auto`:`manual`}_ready(){let e=this._panel;if(!e)throw Error(`<wui-popover> has no panel: a child with data-wui-popover-panel is required to open.`);let t=this._trigger;if(!t)throw Error(`<wui-popover> has no trigger: a child element is required to open.`);return{panel:e,trigger:t,side:this._side(),mode:this._mode()}}_applyOpen(e){if(this._stampTrigger(),e===this._open)return;if(e){let{panel:e,trigger:t,side:n,mode:i}=this._ready();this._open=!0,this._name(e);try{(0,r.openAnchoredPopover)(t,e,{mode:i,side:n,align:`center`,clampHeight:!0,arrow:h(e,l),onClosed:()=>this._onNativeClose()})}catch(t){throw this._open=!1,(0,r.closeAnchoredPopover)(e),t}this.setAttribute(`open`,``),i===`manual`&&this.ownerDocument.addEventListener(`keydown`,this._onKeyDown),this.hasAttribute(`auto-focus`)&&queueMicrotask(()=>{this._open&&(0,r.isPopoverOpen)(e)&&h(e,d)?.focus()}),t.hasAttribute(`aria-expanded`)&&t.setAttribute(`aria-expanded`,`true`);return}let t=this._panel;if(!t)throw Error(`<wui-popover> has no panel: a child with data-wui-popover-panel is required to close.`);let n=this._trigger;if(!n)throw Error(`<wui-popover> has no trigger: a child element is required to close.`);this._open=!1,this.ownerDocument.removeEventListener(`keydown`,this._onKeyDown),this.hasAttribute(`auto-focus`)&&this._mode()===`manual`&&t.contains(this.ownerDocument.activeElement)&&this._refocus(),(0,r.closeAnchoredPopover)(t),this.removeAttribute(`open`),n.hasAttribute(`aria-expanded`)&&n.setAttribute(`aria-expanded`,`false`)}_openOrAwaitChildren(){if(this.hasAttribute(`open`)&&(this._panel===null||this._trigger===null)){if(this._awaitChildren)return;this._awaitChildren=new MutationObserver(()=>this._finishAwaitedOpen()),this._awaitChildren.observe(this,{childList:!0})}else this._applyOpen(this.hasAttribute(`open`))}_finishAwaitedOpen(){this._panel!==null&&this._trigger!==null&&(this._disarmAwait(),this._applyOpen(this.hasAttribute(`open`)))}_disarmAwait(){this._awaitChildren?.disconnect(),this._awaitChildren=null}_onNativeClose(){let e=this._panel;if(!this._open||!e||(0,r.isPopoverOpen)(e))return;let t=e.contains(this.ownerDocument.activeElement);this._applyOpen(!1),t&&this._refocus(),this._notify(!1,!1)}_refocus(){let e=this._trigger;e&&(this._refocusing=!0,e.focus(),this._refocusing=!1)}_name(e){if(!this.hasAttribute(`role-dialog`))return;e.setAttribute(`role`,`dialog`);let t=this.getAttribute(`labelled-by`);if(t){e.setAttribute(`aria-labelledby`,t);return}let n=h(e,u);n&&(n.id||=`wui-popover-title-${++m}`,e.setAttribute(`aria-labelledby`,n.id))}};(0,t.defineElement)(`wui-popover`,_),e.WuiPopover=_})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.nativeOverlay);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.173.
|
|
1
|
+
(function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.173.1`)throw Error(`[webority-ui] saved-views expects ui-elements 0.173.1 but the page loaded `+s+`.`);var c={cannotShareViewsMessage:`You cannot share views.`,deleteLabel:`Delete`,deleteText:`Delete {name}`,giveViewNameMessage:`Give the view a name.`,listNotFoundMessage:`That list could not be found.`,nameViewPlaceholder:`Name this view`,requestNotSupportedMessage:`That request is not supported.`,saveViewLabel:`Save this view`,shareTeamLabel:`Share with the team`,sharedLabel:`Shared`,viewNameLabel:`View name`,viewNameTooLongMessage:`The view name is too long.`,viewNotFoundMessage:`That view could not be found.`,viewNotSavedMessage:`That view could not be saved.`,viewsLabel:`Views`,viewsNotUpdatedMessage:`The views could not be updated. Try again.`},l=`wui-saved-views:`,u=20,d=0,f=()=>(0,o.readText)(`savedViews`,c),p=e=>typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`query`in e&&typeof e.query==`string`,m=class extends r.ElementBase{static get observedAttributes(){return[`key`,`mode`,`action`,`can-share`]}_doc=null;_dom=null;_views;_open;_busy;_error;_trigger;_onTriggerClick;_onKeyDown;_onPointerDown;_onSubmit;constructor(){super(),this._views=[],this._open=!1,this._busy=!1,this._error=null,this._onTriggerClick=()=>this._setOpen(!this._open),this._onKeyDown=e=>{this._open&&e.target instanceof Node&&this.contains(e.target)&&(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._setOpen(!1),this._trigger?.focus()):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&this._ui.menu.contains(e.target)&&!(e.target instanceof Element&&/input|textarea/i.test(e.target.tagName))&&(e.preventDefault(),e.stopPropagation()))},this._onPointerDown=e=>{this._open&&!e.composedPath().includes(this)&&this._setOpen(!1)},this._onSubmit=async e=>{e.preventDefault();let t=this._ui.input.value.trim();if(!t)return;if(this._server()){if(this._busy)return;let e={name:t,query:this._ownerDoc.location.search};this._canShare()&&(e.shared=String(this._ui.share.checked)),await this._request(`save`,e)&&(this._ui.input.value=``,this._ui.share.checked=!1);return}let n=this._ownerDoc.location.search;this._commit([{name:t,query:n},...this._views.filter(e=>e.name!==t)].slice(0,u)),this._ui.input.value=``}}get _ownerDoc(){if(!this._doc)throw Error(`wui-saved-views is not connected`);return this._doc}get _ui(){if(!this._dom)throw Error(`wui-saved-views is not built`);return this._dom}connectedCallback(){this._doc=this.ownerDocument,this._trigger||this._build(),window.addEventListener(`keydown`,this._onKeyDown,!0),this._reload()}disconnectedCallback(){this._setOpen(!1),window.removeEventListener(`keydown`,this._onKeyDown,!0),this._doc=null}attributeChangedCallback(){this._doc&&this._trigger&&this._reload()}_reload(){this._server()?(this._views=[],this._render(),this._request(`list`)):(this._views=this._load(),this._render())}_server(){return this.getAttribute(`mode`)===`server`&&!!this.getAttribute(`action`)&&!!this.getAttribute(`key`)}_canShare(){return this._server()&&this.getAttribute(`can-share`)===`true`}async _request(e,t={}){let n=this.getAttribute(`action`)??``,r=this.getAttribute(`key`)??``,o=n,s;e===`list`?o+=(n.includes(`?`)?`&`:`?`)+new URLSearchParams({intent:`list`,key:r}):s={method:`POST`,body:new URLSearchParams({intent:e,key:r,...t})},this._busy=!0,this._render();let c=await(0,a.wuiFetch)(o,s);if(this._busy=!1,this._doc===null)return!1;if(c.ok){let e=(0,i.parseServerHtml)(c.html);return this._views=[...e.querySelectorAll(`[data-wui-saved-views-items] > li`)].filter(e=>e instanceof HTMLLIElement).map(e=>({name:e.dataset.name,query:e.dataset.query,shared:e.dataset.shared===`true`})).filter(p),this._error=null,this._render(),!0}return this._error=c.message||f().viewsNotUpdatedMessage,this._render(),!1}_build(){let e=this._ownerDoc;this.classList.add(`dropdown`),this._trigger=e.createElement(`button`),this._trigger.type=`button`,this._trigger.className=(0,n.buttonClass)(`neutral`,`outline`,`sm`),this._trigger.dataset.wui=n.APP_BUTTON_MARKER,this._trigger.textContent=f().viewsLabel,this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,`false`),this._trigger.addEventListener(`click`,this._onTriggerClick);let t=e.createElement(`div`);t.className=`dropdown-menu`;let r=e.createElement(`div`);r.className=`dropdown-divider`;let i=e.createElement(`input`);i.type=`text`,i.className=`form-control form-control-sm`,i.setAttribute(`aria-label`,f().viewNameLabel),i.placeholder=f().nameViewPlaceholder;let a=e.createElement(`button`);a.type=`submit`,a.className=(0,n.buttonClass)(`primary`,`solid`,`sm`),a.dataset.wui=n.APP_BUTTON_MARKER,a.textContent=f().saveViewLabel;let o=e.createElement(`form`);o.className=`d-flex gap-2 px-3 py-2`,o.append(i,a),o.addEventListener(`submit`,this._onSubmit);let s=e.createElement(`input`);s.type=`checkbox`,s.className=`form-check-input`,s.setAttribute(`role`,`switch`),s.id=`wui-saved-views-share-${d++}`;let c=e.createElement(`label`);c.className=`form-check-label`,c.htmlFor=s.id,c.textContent=f().shareTeamLabel;let l=e.createElement(`div`);l.className=`form-check form-switch mb-0`,l.append(s,c);let u=e.createElement(`div`);u.className=`px-3 pb-2`,u.hidden=!0,u.append(l),this._dom={menu:t,divider:r,form:o,input:i,save:a,shareRow:u,share:s},this.append(this._trigger,t)}_render(){let e=this._ownerDoc,t=this._ui,n=[];for(let t of this._views){let r=e.createElement(`a`);if(r.className=`dropdown-item`,r.setAttribute(`href`,e.location.pathname+t.query),r.textContent=t.name,t.shared){let t=e.createElement(`span`);t.className=`badge text-bg-secondary ms-2`,t.textContent=f().sharedLabel,r.append(t)}let i=e.createElement(`button`);i.type=`button`,i.className=`btn btn-link btn-sm`,i.textContent=f().deleteLabel,i.setAttribute(`aria-label`,(0,o.fillText)(f().deleteText,{name:t.name})),i.disabled=this._busy,i.addEventListener(`click`,()=>this._server()?this._request(`delete`,{name:t.name}):this._commit(this._views.filter(e=>e.name!==t.name))),n.push(r,i)}if(this._error){let t=e.createElement(`div`);t.className=`dropdown-item-text text-danger small`,t.setAttribute(`role`,`alert`),t.textContent=this._error,n.push(t)}t.save.disabled=this._busy,t.share.disabled=this._busy,t.shareRow.hidden=!this._canShare(),t.menu.replaceChildren(...n,t.divider,t.form,t.shareRow)}_commit(e){this._views=e,this._write(e),this._render()}_setOpen(e){e!==this._open&&(this._open=e,this._ui.menu.classList.toggle(`show`,e),this._trigger?.setAttribute(`aria-expanded`,String(e)),e?this._ownerDoc.addEventListener(`pointerdown`,this._onPointerDown,!0):this._ownerDoc.removeEventListener(`pointerdown`,this._onPointerDown,!0))}_storage(){let e=this.getAttribute(`key`);if(!e)return null;try{let t=this._ownerDoc.defaultView;return t?{store:t.localStorage,key:l+e}:null}catch{return null}}_load(){let e=this._storage();if(!e)return[];try{let t=JSON.parse(e.store.getItem(e.key)??`[]`);return Array.isArray(t)?t.filter(p).slice(0,u):[]}catch{return[]}}_write(e){let t=this._storage();if(t)try{t.store.setItem(t.key,JSON.stringify(e))}catch(e){if(!(e instanceof DOMException))throw e}}};(0,t.defineElement)(`wui-saved-views`,m),e.WuiSavedViews=m})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.textStore);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o,s,c,l,u){var d=Object.defineProperty,f=(e,t)=>{let n={};for(var r in e)d(n,r,{get:e[r],enumerable:!0});return t||d(n,Symbol.toStringTag,{value:`Module`}),n},p=globalThis.WeborityUiElementsInternal?.version;if(p!==`0.173.
|
|
1
|
+
(function(e,t,n,r,i,a,o,s,c,l,u){var d=Object.defineProperty,f=(e,t)=>{let n={};for(var r in e)d(n,r,{get:e[r],enumerable:!0});return t||d(n,Symbol.toStringTag,{value:`Module`}),n},p=globalThis.WeborityUiElementsInternal?.version;if(p!==`0.173.1`)throw Error(`[webority-ui] select-chips expects ui-elements 0.173.1 but the page loaded `+p+`.`);var m={enter:`Enter`,comma:`,`,space:` `,tab:`Tab`},h={enter:`
|
|
2
2
|
`,comma:`,`,space:` `,tab:` `},ee=e=>m[e],g=e=>h[e];function te(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 ne=(e,t)=>t.some(t=>String(e??``).includes(t)),_={invalidMessage:`Enter a valid value.`},v=new Map,y=e=>{if(v.has(e))return v.get(e)??null;let t=null;try{t=RegExp(`^(?:${e})$`,`u`)}catch{(0,c.devWarn)(`<wui-select> pattern is not a valid regular expression and is ignored: ${e}`)}return v.set(e,t),t},b=(e,t)=>{let n=e.getAttribute(`invalid-message`)||(0,o.readText)(`customRule`,_).invalidMessage,r=e.getAttribute(`pattern`);if(r){let e=y(r);if(e&&!e.test(t))return n}let i=e.validate;if(typeof i!=`function`)return``;let a=i(t);return a===!0?``:typeof a==`string`&&a?a:n},x=f({default:()=>T}),S=()=>(0,o.readText)(`select`,s.SELECT_TEXT),C=new WeakMap;function w(e,t){if(e===null)throw TypeError(`The chip row needs ${t}, and it is not mounted.`);return e}function T(){let s,c,u=null,d=null,f=null,p=null,m=null,h=null,_=null,v=!1,y=()=>w(d,`the draft input`),x=()=>s.mode===`tag`,T=()=>Array.isArray(s.value)?s.value.slice():[],E=()=>(s.getAttribute(`separators`)||`enter,comma`).split(`,`).map(e=>e.trim()).filter(Boolean),D=()=>new Set(E().map(ee).filter(Boolean)),O=()=>{let e=parseInt(s.getAttribute(`max-tags`)??``,10)||0;return Math.max(e,0)},k=()=>{let e=O();return e>0&&T().length>=e},A=(e,t)=>!s.hasAttribute(`allow-duplicates`)&&e.some(e=>e.toLowerCase()===t.toLowerCase()),j=()=>{let e=C.get(s);return e||(e=new Map,C.set(s,e)),e},M=e=>(s.options||[]).find(t=>String(t.value)===String(e))??j().get(String(e)),re=e=>{let t=j();for(let n of s.options||[])e.includes(String(n.value))&&t.set(String(n.value),n);for(let n of t.keys())e.includes(n)||t.delete(n)},N=e=>{let t=e.trim().toLowerCase();return(s.options||[]).find(e=>String(e.value??``).toLowerCase()===t||(0,a.optionText)(e).trim().toLowerCase()===t)},P=e=>{for(let t of E()){let n=g(t)??t;if(ne(e,[n]))return te(e,[n])}return[e.trim()]},F=()=>d?d.value:s._query||``,ie=()=>x()||s.hasAttribute(`allow-custom`),ae=()=>s.getAttribute(`placeholder`)||(x()?S().tagPlaceholder:S().placeholder),oe=()=>{let e=s.getAttribute(`aria-label`);if(e)return e;let t=s.closest(`label`)?.textContent?.trim();if(t)return t;let n=s.id;return(n?[...document.querySelectorAll(`label[for]`)].find(e=>e instanceof HTMLLabelElement&&e.htmlFor===n):void 0)?.textContent?.trim()||(x()?S().addTagsLabel:S().fallbackName)},I=()=>{d&&(d.setAttribute(`aria-expanded`,String((0,i.isPopoverOpen)(c.menu))),c.list.id&&d.setAttribute(`aria-controls`,c.list.id),d.setAttribute(`aria-label`,oe()))},se=()=>!(0,t.isReadOnly)(s)&&!s.hasAttribute(`loading`),ce=e=>{v=!0,y().setAttribute(`aria-invalid`,`true`),s.setError(e)},L=()=>{v&&(v=!1,y().removeAttribute(`aria-invalid`),s.setError(null))},R=(e,{quiet:t=!1,strip:n=!1}={})=>{let r=T(),i=r.slice(),a=O(),o=[],c=``,l=!1;for(let t of e){let e=(n?t.trim().replace(/,+$/,``):t).trim();if(!e)continue;if(a&&i.length>=a)break;let r=N(e);if(r){if(r.disabled){o.push(e),c||=r.disabledHint||s.getAttribute(`invalid-message`)||S().invalidMessage;continue}A(i,String(r.value))||i.push(String(r.value));continue}let u=b(s,e);u?(o.push(e),c||=u):A(i,e)||(i.push(e),l=!0)}i.length!==r.length&&(l?s.commit(i,{isCustom:!0}):s.commit(i)),y().value=o.join(`, `),c?t||ce(c):L()},z=e=>{(0,t.isInert)(s)||R([y().value],e)},B=e=>s.commit(T().filter(t=>t!==e)),V=()=>(0,e.make)(`span`,{class:`wui-select-placeholder`},s.getAttribute(`placeholder`)||S().placeholder),H=t=>{let r=M(t),i=(0,e.make)(`span`,{class:`chip chip-sm`}),s=(0,e.make)(`span`,{class:`chip-label`});if(s.replaceChildren(...r?(0,a.optionLabelNodes)(r):[t]),i.append(s),se()){let s=r?(0,a.optionText)(r):(0,a.stripTags)(t),c=(0,e.make)(`button`,{class:`chip-remove`,type:`button`,"data-remove":t,"aria-label":(0,o.fillText)(S().removeText,{text:s})}),l=(0,n.glyphNode)(`x`);l&&c.replaceChildren(l),i.append(c)}return i};function U(){if(!u)return;u.querySelector(`:scope > .chip-more`)?.remove();let t=[...u.querySelectorAll(`:scope > .chip`)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`The chip row holds a node that is not an element.`);return e});for(let e of t)e.style.display=``;let n=t.at(-1);if(!s.hasAttribute(`collapse-chips`)||!n)return;let r=u.clientWidth,i=e=>e.offsetLeft+e.offsetWidth;if(i(n)<=r)return;let a=(0,e.make)(`span`,{class:`chip chip-sm chip-more`});a.textContent=`+${t.length}`,n.after(a);let o=a.offsetWidth+6,c=0;for(let e of t)if(i(e)<=r-o)c+=1;else break;c<1&&(c=1);for(let e of t.slice(c))e.style.display=`none`;a.textContent=`+${t.length-c}`}function W(){if(!u)return!1;u.parentNode!==c.value&&c.value.append(u);for(let e of u.querySelectorAll(`:scope > .chip, :scope > .wui-select-placeholder`))e.remove();let e=T();re(e);let n=u,r=e=>{d?n.insertBefore(e,d):n.append(e)};x()||d||e.length||r(V());for(let t of e)r(H(t));return d&&(d.placeholder=x()||!e.length?ae():``,d.disabled=s.hasAttribute(`disabled`),d.readOnly=(0,t.isInert)(s),I()),x()||(w(p,`the footer text`).textContent=(()=>{let t=s.getAttribute(`selected-text`);return t?t.replace(`{n}`,()=>String(e.length)):(0,o.fillText)(S().selectedText,{count:e.length})})(),w(m,`the clear-all button`).textContent=s.getAttribute(`clear-all-label`)||S().clearAllLabel),U(),!0}function le(e){if(e.key===`Backspace`){let t=d?!F():!F()&&(0,i.isPopoverOpen)(c.menu),n=T().at(-1);return!t||n===void 0?!1:(e.preventDefault(),B(n),!0)}if(!d)return!1;let t=d.value;if(e.key===`Escape`){if(!x())return!1;let n=(0,i.isPopoverOpen)(c.menu);return!n&&!t?!1:(e.preventDefault(),n&&e.stopPropagation(),d.value=``,L(),s.closeMenu({focusControl:!1}),!0)}let n=!x()&&!t.trim(),a=D();return(0,r.isImeSafeEnter)(e)&&a.has(`Enter`)?n||c.list.querySelector(`.is-active`)?!1:(e.preventDefault(),z(),!0):e.key===`,`&&a.has(`,`)?!n&&(e.preventDefault(),z({strip:!0}),!0):e.key===` `&&a.has(` `)&&t.trim()||e.key===`Tab`&&a.has(`Tab`)&&!n?(e.preventDefault(),z(),!0):!1}function ue(e){let t=String(e.value);if(x()||d&&!M(t))return R([t]),!0;let n=T();return n.includes(t)?s.commit(n.filter(e=>e!==t)):d?R([t]):s.commit([...n,t]),d?.value&&(d.value=``,L()),!0}function G(e){if(!d)return null;let t=String(e??``).trim().replace(/,+$/,``).trim();if(!t||k()||N(t)||A(T(),t))return null;let n=s.getAttribute(`create-label`)||S().createLabel;return{position:x()?`top`:`bottom`,label:n.replace(`{text}`,()=>t),value:t}}function K(e){let n=e.target,r=n instanceof Element?n.closest(`[data-remove]`):null;if(r instanceof HTMLElement){if((0,t.isInert)(s))return;e.stopPropagation(),B(r.dataset.remove??``),d?.focus()}else d&&!(0,t.isInert)(s)&&d.focus()}function q(){L();let e=y().value.trim();x()||!e||(0,i.isPopoverOpen)(c.menu)||(G(e)||(0,l.filterOptions)(s.options||[],e).length)&&s.openMenu()}function J(e){e.preventDefault(),(0,t.isInert)(s)||R(P(e.clipboardData?.getData(`text/plain`)??``))}function Y(){y().value.trim()&&z({quiet:!0,strip:!0}),s.closeMenu({focusControl:!1})}function X(e){e.relatedTarget instanceof Node&&s.contains(e.relatedTarget)||Y()}function de(){return d?(Y(),!0):!1}function Z(){y().value.trim()&&z({strip:!0})}function Q(){(0,t.isInert)(s)||s.commit([])}function $(e){e.target!==d&&e.preventDefault()}function fe(t,n,r={}){s=t,c=n,u=(0,e.make)(`div`,{class:`wui-select-chips`}),u.addEventListener(`click`,K),c.value.append(u),ie()&&(d=(0,e.make)(`input`,{class:`wui-select-draft`,type:`text`,autocomplete:`off`,role:`combobox`,"aria-autocomplete":`list`}),s.hasAttribute(`required`)&&d.setAttribute(`aria-required`,`true`),c.menu.addEventListener(`toggle`,I),u.append(d),d.value=r.carry?.draft??``,c.input=d,d.addEventListener(`input`,q),d.addEventListener(`paste`,J),d.addEventListener(`blur`,X),u.addEventListener(`mousedown`,$),h=s.closest(`form`),h?.addEventListener(`submit`,Z,!0)),x()||(f=(0,e.make)(`div`,{class:`wui-select-footer`}),p=document.createElement(`span`),m=(0,e.make)(`button`,{class:`wui-select-clear-all`,type:`button`}),m.addEventListener(`click`,Q),f.append(p,m),c.menu.append(f)),typeof ResizeObserver<`u`&&(_=new ResizeObserver(U),_.observe(u)),W()}function pe(){u?.removeEventListener(`click`,K),u?.removeEventListener(`mousedown`,$),d&&(d.removeEventListener(`input`,q),d.removeEventListener(`paste`,J),d.removeEventListener(`blur`,X),c.input=null),m&&m.removeEventListener(`click`,Q),h?.removeEventListener(`submit`,Z,!0),h=null,_?.disconnect(),_=null,c.menu.removeEventListener(`toggle`,I),f?.remove(),u?.remove(),u=null,d=null,f=null,v=!1}return{mount:fe,onKey:le,onPick:ue,renderValue:W,actionRow:G,onQuery:()=>!1,onBlur:de,teardown:pe}}(0,u.registerSelectPart)(`chips`,x)})(WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.optionLabel,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.selectText,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.selectList,WeborityUiElementsInternal.modules.partRegistry);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r){var i=Object.defineProperty,a=(e,t)=>{let n={};for(var r in e)i(n,r,{get:e[r],enumerable:!0});return t||i(n,Symbol.toStringTag,{value:`Module`}),n},o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.173.
|
|
1
|
+
(function(e,t,n,r){var i=Object.defineProperty,a=(e,t)=>{let n={};for(var r in e)i(n,r,{get:e[r],enumerable:!0});return t||i(n,Symbol.toStringTag,{value:`Module`}),n},o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.173.1`)throw Error(`[webority-ui] select-recents expects ui-elements 0.173.1 but the page loaded `+o+`.`);var s=a({default:()=>d}),c=()=>(0,n.readText)(`select`,r.SELECT_TEXT),l=5,u=20;function d(){let e,n=null,r=()=>e.getAttribute(`recents-key`)??``,i=()=>e.mode!==`tag`&&r()!==``,a=(e,r)=>{e!==n&&(n=e,(0,t.devWarn)(`<wui-select> recents-limit "${e}" ${r}.`))},o=()=>{let t=e.getAttribute(`recents-limit`);if(t===null)return l;let n=Number(t);return!Number.isInteger(n)||n<1?(a(t,`is not a whole number from 1 to 20; 5 is used`),l):n>u?(a(t,`is over 20; 20 is used`),u):n},s=()=>{let e;try{e=JSON.parse(globalThis.localStorage?.getItem(r())??`[]`)}catch{return[]}return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]},d=e=>{try{globalThis.localStorage?.setItem(r(),JSON.stringify(e))}catch(e){if(!(e instanceof DOMException))throw e}};return{mount(n){e=n,e.mode===`tag`?(0,t.devWarn)(`<wui-select> recents-key is not used in mode "tag"; it is ignored.`):r()===``&&(0,t.devWarn)(`<wui-select> recents-key is empty; no recents are kept.`)},onPick(t,n){if(!i()||n?.isCustom)return!1;let r=String(t.value);return r===``||Array.isArray(e.value)&&e.value.includes(r)||d([r,...s().filter(e=>e!==r)].slice(0,o())),!1},recents(t){if(!i())return null;let n=o(),r=[];for(let e of s()){let i=t.find(t=>String(t.value)===e);if(i&&!i.disabled&&r.push(i),r.length===n)break}return r.length?{label:e.getAttribute(`recents-label`)||c().recentsLabel,options:r}:null},teardown(){}}}(0,e.registerSelectPart)(`recents`,s)})(WeborityUiElementsInternal.modules.partRegistry,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.selectText);
|