@webority/ui-elements 0.182.0 → 0.184.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{WuiSelect-DIW_WXH7.js → WuiSelect-B0CT2utp.js} +1 -1
- package/dist/{chips-paLEDoxn.js → chips-DxSWAJDI.js} +1 -1
- package/dist/drawerDiscard-CBUOklnA.js +1 -0
- package/dist/elements/select.js +1 -1
- package/dist/{loader-DUCcKxjq.js → loader-X2uBXCDm.js} +1 -1
- package/dist/{search-C46tnoPd.js → search-DLRWJomU.js} +1 -1
- package/dist/server.js +1 -1
- package/dist/ui-elements/calendar-views.global.js +1 -1
- 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/dashboard-grid.global.js +1 -1
- package/dist/ui-elements/data-table.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/dock.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/hover-card.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/mini-calendar.global.js +1 -1
- package/dist/ui-elements/navigation-menu.global.js +1 -1
- package/dist/ui-elements/notification-center.global.js +1 -1
- package/dist/ui-elements/offline-banner.global.js +1 -1
- package/dist/ui-elements/onboarding-checklist.global.js +1 -1
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/otp.global.js +1 -1
- package/dist/ui-elements/overflow.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/rating.global.js +1 -1
- package/dist/ui-elements/record-pager.global.js +1 -1
- package/dist/ui-elements/relative-time.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/server.global.js +1 -1
- package/dist/ui-elements/shell.global.js +1 -1
- package/dist/ui-elements/shortcuts.global.js +1 -1
- package/dist/ui-elements/show-more.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/truncate.global.js +1 -1
- package/dist/ui-elements/whats-new.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +1 -1
- package/dist/ui-elements.js +1 -1
- package/package.json +5 -5
- package/types/global/shared.d.ts +2 -0
- package/types/server/serverActions.d.ts +3 -0
- package/types/server/wuiUpload.d.ts +6 -4
- package/dist/drawerDiscard-D_LMpaFv.js +0 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ element classes. Any other helper is imported from the module that owns it.
|
|
|
29
29
|
|
|
30
30
|
## Server entry
|
|
31
31
|
|
|
32
|
-
`@webority/ui-elements/server` carries the server-driven layer for an ASP.NET host: `wuiFetch` and `createRequestQueue` (HTML fragments fetched with the antiforgery token and classified results), server-paged tables, server-loaded modals and drawers, confirm/post/flash actions, the shell parts and the unsaved-changes guard. The Razor script reaches all of it through `window.WeborityUiElements`. The token is read from the meta tag named `wui-csrf` (rendered by the app-csrf-meta tag helper) and sent in the header named by the tag attribute `data-header`; a host that uses another meta name or default header calls `configureCsrf({ metaName, header })` once before the first request. Use `wuiUpload` for a file upload that needs progress: it sends a POST with XMLHttpRequest, the one request the library makes that way, because fetch cannot report upload progress.
|
|
32
|
+
`@webority/ui-elements/server` carries the server-driven layer for an ASP.NET host: `wuiFetch` and `createRequestQueue` (HTML fragments fetched with the antiforgery token and classified results), server-paged tables, server-loaded modals and drawers, confirm/post/flash actions, the shell parts and the unsaved-changes guard. The Razor script reaches all of it through `window.WeborityUiElements`. The token is read from the meta tag named `wui-csrf` (rendered by the app-csrf-meta tag helper) and sent in the header named by the tag attribute `data-header`; a host that uses another meta name or default header calls `configureCsrf({ metaName, header })` once before the first request. Use `wuiUpload` for a file upload that needs progress: it sends a POST with XMLHttpRequest, the one request the library makes that way, because fetch cannot report upload progress. A Razor page posts an upload with a progress bar through `WUI.post(url, { body: formData, onUploadProgress })`, which uses wuiUpload and settles the answer like any other post.
|
|
33
33
|
|
|
34
34
|
Component catalogue: <https://ui-react.webority.dev>
|
|
35
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./anchorOverlay-daGdh_91.js";import{t}from"./avatarNode-BaEvz5Xr.js";import{n}from"./devWarn-DXdRWZs3.js";import{i as r,r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{r as o,t as s}from"./fieldState-D-zQcXUS.js";import{n as c,t as l}from"./formMirror-9IpSgeZb.js";import{n as u}from"./loader-DUCcKxjq.js";import{t as d}from"./iconGlyphs.g-a9FtjPXh.js";import{n as f}from"./imeSafeEnter-DeO_3lXy.js";import{n as p,t as m}from"./listboxKeyNav-CNso9shL.js";import{a as h,l as g,s as _}from"./nativeOverlay-BHD2QV02.js";import{i as v,n as y,t as b}from"./optionLabel-wbpl8OTJ.js";import{r as x}from"./textStore-DBplASiZ.js";import{n as S,r as C,t as w}from"./search.g-B5d1s59A.js";import{t as T}from"./hasOwn-CJsplJ62.js";import{n as E,r as D,t as O}from"./window-BZWK3rQk.js";var k=()=>x(`select`,C);function A(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[y(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var j=/* @__PURE__ */ new WeakMap,M=e=>e?{"data-index":String(e.index),"aria-setsize":String(e.size),"aria-posinset":String(e.index+1)}:{},N=e=>e.map(e=>e instanceof Element?e.outerHTML:e.textContent??``).join(``),P;function F(e){P=e}function I(e){P?.clear(e),j.delete(e),e.replaceChildren()}function L(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=k().emptyText,searchingText:c=k().searchingText,hintText:l=k().hintText,actionRow:u=[],recents:d=null}=n,f=new Set(r.map(String)),p=A(t,a),m=e.id,h=u.filter(e=>e.position===`top`),g=u.filter(e=>e.position===`bottom`),_=d?.options.length?d.options:[],v=h.length+_.length+p.length+g.length,y=p.length>300,b=P,x=y&&b!==void 0,S=e=>x?{index:e,size:v}:void 0,C=0,w=e=>{let t=C++;return i(`button`,{type:`button`,role:`option`,id:R(m,t),class:`wui-select-option wui-select-add`,"data-value":String(e.value??``),"data-custom":`true`,"aria-selected":`false`,...M(S(t))},e.label)},T=e=>{let t=C++;return V(e,R(m,t),f.has(String(e.value)),S(t))},E=h.map(w),D=_.length&&d?[i(`div`,{class:`wui-select-group`},d.label),..._.map(T),i(`div`,{class:`wui-select-sep`,"aria-hidden":`true`})]:[],O=C,F=[];if(x)C+=p.length;else{let e=``;for(let t of p)t.group&&t.group!==e&&F.push(i(`div`,{class:`wui-select-group`},t.group)),e=t.group??``,F.push(T(t))}let I=g.map(w),L=[];if(o===`loading`?L=[i(`div`,{class:`wui-select-loading`},i(`span`,{class:`wui-select-spinner spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`}),c)]:o===`hint`?L=[i(`div`,{class:`wui-select-hint`},l)]:(o===`empty`||p.length===0&&u.length===0)&&(L=[i(`div`,{class:`wui-select-empty`},s)]),x&&b){let n=[...E,...D],r=[...I,...L];return b.render(e,{options:t,query:a,rows:p,pre:n,post:r,preSig:N(n),postSig:N(r),picked:f,top:h,recent:_,bottom:g,bodyBase:O,total:v}),{rows:v,windowed:!0,long:y}}b?.clear(e);let z=[...E,...D,...F,...I,...L],B=N(z);return j.get(e)===B||(j.set(e,B),e.replaceChildren(...z)),{rows:C,windowed:!1,long:y}}var R=(e,t)=>`${e}-opt-${t}`,z=e=>[...e.querySelectorAll(`.wui-select-option`)];function B(e){return P?P.refresh(e):!1}function ee(e,t){return P?P.reveal(e,t):z(e)[t]??null}function te(e,t){if(P)return P.indexOfValue(e,t);let n=new Set(t.map(String));return z(e).findIndex(e=>n.has(e.dataset.value??``))}function ne(e,t){return P?P.indexByPrefix(e,t):z(e).findIndex(e=>(e.textContent??``).trim().toLowerCase().startsWith(t))}function V(e,n,r,a){let o=!!e.disabled,s={id:n,role:`option`,"data-value":String(e.value??``),"aria-selected":String(r),"aria-disabled":o?`true`:void 0,title:o&&e.disabledHint?e.disabledHint:void 0,...M(a)},c=i(`span`,{class:`wui-select-check`,"aria-hidden":`true`},d(`check`));if(!e.description&&!e.meta)return i(`button`,{type:`button`,class:`wui-select-option${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-opt-name`},...b(e)),c);let l=e.description?i(`span`,{class:`wui-select-opt-desc`},e.description):null,u=e.meta?i(`span`,{class:`wui-select-opt-meta`},e.meta):null;return i(`div`,{class:`wui-select-option wui-select-option-rich${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-option-text`},i(`span`,{class:`wui-opt-label`},...b(e)),l),u,c)}var re=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),H=e=>e===`multiple`||e===`tag`,ie={recents:()=>import(`./recents-B9efQ1Au.js`),chips:()=>import(`./chips-paLEDoxn.js`),search:()=>import(`./search-C46tnoPd.js`),country:()=>import(`./country-T7AfpJpN.js`)};function ae(e){let t=T(ie,e)?ie[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var U=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),oe=300,W=`<div class="wui-select-spacer" aria-hidden="true"></div>`,G=()=>i(`div`,{class:`wui-select-spacer`,"aria-hidden":`true`}),K=/* @__PURE__ */ new WeakMap;function se(e,t,n,r){let i=K.get(e);if(i&&i.options===t&&i.query===n&&i.count===r.length)return i;let a=[],o=new Int32Array(r.length),s=``;r.forEach((e,t)=>{e.group&&e.group!==s&&a.push({kind:`group`,label:e.group}),s=e.group??``,o[t]=a.length,a.push({kind:`option`,option:e,ord:t})});let c={options:t,query:n,count:r.length,entries:a,optionEntry:o,heights:O(a.length),estimated:!1,bodyTop:0,start:0,end:0,pre:[],post:[],preSig:``,postSig:``,picked:/* @__PURE__ */ new Set,top:[],recent:[],bottom:[],bodyBase:0,total:0};return K.set(e,c),e.scrollTop=0,c}var q=e=>e.clientHeight||oe,J=(e,t)=>D(t.heights,{scrollTop:Math.max(0,e.scrollTop-t.bodyTop),viewport:q(e)});function ce(e,t,n,r){let a=[];for(let o=n;o<r;o++){let n=e.entries[o];if(n){if(n.kind===`group`)a.push(i(`div`,{class:`wui-select-group`,"data-entry":o},n.label));else{let r=e.bodyBase+n.ord;a.push(V(n.option,R(t,r),e.picked.has(String(n.option.value)),{index:r,size:e.total}))}}}return a}function le(e,t){let[n,r]=e.querySelectorAll(`.wui-select-spacer`);n&&r&&(n.style.flex=r.style.flex=`none`,n.style.height=`${t.heights.offsetOf(t.start)}px`,r.style.height=`${t.heights.total()-t.heights.offsetOf(t.end)}px`)}function ue(e,t){let{start:n,end:r}=J(e,t);t.start=n,t.end=r;let i=ce(t,e.id,n,r),a=t.preSig+W+N(i)+W+t.postSig,o=e.scrollTop;j.get(e)!==a&&(j.set(e,a),e.replaceChildren(...t.pre,G(),...i,G(),...t.post)),le(e,t),e.scrollTop!==o&&(e.scrollTop=o)}function de(e,t){let n={changed:!1,delta:0};if(!e.clientHeight)return n;let{heights:r}=t,i=e.querySelector(`.wui-select-spacer`),a=[],o=!0,s=!1;if(i){let n=i.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;Math.abs(n-t.bodyTop)>.5&&(t.bodyTop=n,s=!0)}let c=r.indexAt(Math.max(0,e.scrollTop-t.bodyTop)),l=r.offsetOf(c),u=0;for(let n of e.querySelectorAll(`.wui-select-option[data-index], .wui-select-group[data-entry]`)){let e=n.getBoundingClientRect().height;if(n.dataset.entry!==void 0)a.push([Number(n.dataset.entry),e]);else{let r=Number(n.dataset.index)-t.bodyBase,i=r>=0?t.optionEntry[r]:void 0;if(i===void 0)continue;o&&(u=e),o=!1,a.push([i,e])}}if(!t.estimated&&u>0){let e=r.estimate;r.setEstimate(u),t.estimated=!0,r.estimate!==e&&(s=!0)}for(let[e,t]of a)r.set(e,t)&&(s=!0);return s?{changed:s,delta:r.offsetOf(c)-l}:n}function Y(e,t){ue(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=de(e,t);if(!n)return;le(e,t),r&&(e.scrollTop+=r),ue(e,t)}}function fe(e,t){let n=se(e,t.options,t.query,t.rows);Object.assign(n,{pre:t.pre,post:t.post,preSig:t.preSig,postSig:t.postSig,picked:t.picked,top:t.top,recent:t.recent,bottom:t.bottom,bodyBase:t.bodyBase,total:t.total}),Y(e,n)}function pe(e){let t=K.get(e);if(!t)return!1;let{start:n,end:r}=J(e,t);return n===t.start&&r===t.end?!1:(Y(e,t),!0)}function me(e,t){let n=K.get(e);if(!n||t<0||t>=n.total)return null;let r=t-n.bodyBase,i=r>=0?n.optionEntry[r]:void 0,a=()=>e.querySelector(`[data-index="${t}"]`);if(i===void 0)return a();for(let t=0;t<2;t++){let t={scrollTop:e.scrollTop-n.bodyTop,viewport:q(e)},r=n.bodyTop+E(n.heights,i,t);if(Math.abs(r-e.scrollTop)>.5)e.scrollTop=r;else if(a())break;Y(e,n)}return a()}function he(e,t){if(t<0||t>=e.total)return;if(t<e.top.length)return e.top[t];let n=t-e.top.length;if(n<e.recent.length)return e.recent[n];let r=t-e.bodyBase;if(r<e.count){let t=e.entries[e.optionEntry[r]??-1];return t?.kind===`option`?t.option:void 0}return e.bottom[r-e.count]}var ge=e=>e&&!(`position`in e)?e:void 0;function _e(e,t){let n=K.get(e);if(!n||t.length===0)return-1;let r=new Set(t.map(String));for(let e=0;e<n.total;e++){let t=ge(he(n,e));if(t&&r.has(String(t.value)))return e}return-1}var ve=e=>`position`in e?e.label:`${e.initials??``}${y(e)}${e.description??``}${e.meta??``}`;function ye(e,t){let n=K.get(e);if(!n)return-1;for(let e=0;e<n.total;e++){let r=he(n,e);if(r&&ve(r).trim().toLowerCase().startsWith(t))return e}return-1}F({render:fe,refresh:pe,reveal:me,indexOfValue:_e,indexByPrefix:ye,clear(e){K.delete(e)}});function be(){return Promise.resolve()}var X=()=>x(`select`,C),xe=()=>x(`search`,w),Se=()=>x(`field`,S),Ce=class extends a{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_rows;_windowed;_windowLoad;_windowFailed;_scrollFrame;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_panelShown;_pressOpen;static get observedAttributes(){return/* @__PURE__ */ `class.mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.open-on-hover.lazy-options.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._rows=0,this._windowed=!1,this._windowLoad=null,this._windowFailed=!1,this._scrollFrame=null,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._searchShown=!1,this._defaultValue=void 0,this._warnedMode=null,this._hoverTimer=null,this._hoverOpened=!1,this._panelShown=!1,this._pressOpen=null,this._onHoverOver=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&(this._clearHover(),!this._menuOpen()&&this._hoverEligible()&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,!this._menuOpen()&&this._hoverEligible()&&(this._open({focus:!1}),this._hoverOpened=!0)},De)))},this._onHoverOut=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&!this._hoverZone(e.relatedTarget)&&(this._clearHover(),this._menuOpen()&&this.hasAttribute(`open-on-hover`)&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._close()},Oe)))}}connectedCallback(){this.addEventListener(`pointerover`,this._onHoverOver),this.addEventListener(`pointerout`,this._onHoverOut),this._rendered||this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this.removeEventListener(`pointerover`,this._onHoverOver),this.removeEventListener(`pointerout`,this._onHoverOut),this._clearHover(),this._dropMenu(),this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`class`?this._syncUnderline():e===`value`?(this._value=Z(n,H(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):e===`open-on-hover`?this.hasAttribute(`open-on-hover`)||this._clearHover():e!==`lazy-options`&&(e===`mode`&&(this._value=Z(this._value,H(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),Me.has(e)?this._rendered&&(this._drawValue(),this.renderList()):je.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null?`single`:Te(e)?e:(e!==this._warnedMode&&(this._warnedMode=e,n(`<wui-select> mode "${e}" is not one of ${re.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||Ee.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,n(`<wui-select> density "${e}" is not one of ${Ee.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=Z(e,H(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();if(this._rendered){if(this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._autoSearch()!==this._searchShown){this.render();return}this._drawValue(),this.renderList()}}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){s(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();if(!e.list)return;let t=this._ownsFilter?``:this._query,n=this._actionRows(),r=this._recents();if(this.hasAttribute(`lazy-options`)&&!this._menuOpen()){this._rows=A(this._listOptions(),t).length+n.length+(r?.options.length??0),this._windowed=!1,I(e.list),this._anchorMenu();return}let i=L(e.list,this._listOptions(),{selected:this._selectedValues(),query:t,status:this._status,emptyText:this.getAttribute(`empty-text`)||X().emptyText,searchingText:this.getAttribute(`searching-text`)||X().searchingText,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:n,recents:r});this._rows=i.rows,this._windowed=i.windowed,i.long&&!i.windowed&&!this._windowFailed&&this._loadWindow(),this._active>=this._rowCount()&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._anchorMenu()}render(){this._dropMenu();let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=H(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=Z(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=Z(this._value,n));let s=this.getAttribute(`size`),c=s===`sm`?` wui-select-sm`:s===`lg`?` wui-select-lg`:s===`xl`?` wui-select-xl`:``,l=this.getAttribute(`icon`),u=this.getAttribute(`prefix`),f=this.hasAttribute(`clearable`),p=this.hasAttribute(`disabled`);if(!this.id){let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(8));this.id=`wui-select-${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`}let m=`${this.id}-listbox`,h=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${h}`:h,v=this.hasAttribute(`aria-invalid`)||!!this._error,y=this.hasAttribute(`required`)&&!a,b=this._accessibleName(),x=a?{}:{role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":m},S={"aria-label":b,"aria-describedby":_,"aria-invalid":v?`true`:void 0,"aria-required":y?`true`:void 0},C=n?i(`div`,{class:`input wui-select-control wui-select-multi`,...x,...S,"aria-disabled":p?`true`:void 0,tabindex:!p&&!r?`0`:void 0}):i(`button`,{type:`button`,class:`input wui-select-control`,...x,...S,disabled:p||void 0}),w=[l?d(l,{className:`wui-select-icon`}):null,u?i(`span`,{class:`wui-select-prefix`},u):null,i(`span`,{class:`wui-select-value`,"data-label":!0}),f?i(`span`,{class:`wui-select-reset`,role:`button`,"aria-label":X().clearSelectionLabel,hidden:!0},d(`x`)):null,d(`chevron-down`,{className:`wui-select-caret`})];C.append(...w.filter(e=>e!==null));let T=this.getAttribute(`searchable`),E=T===null?t===`multiple`||t===`country`||this._autoSearch():T!==`false`,D=t===`search`||E&&!a;this._searchShown=D;let O=this.getAttribute(`search-placeholder`)||(t===`country`?X().countrySearchPlaceholder:xe().placeholder),k=D?i(`div`,{class:`wui-select-search`},d(`search`),i(`input`,{class:`wui-select-input`,placeholder:O,"aria-label":O,"aria-autocomplete":`list`}),i(`button`,{type:`button`,class:`wui-select-clear`,"aria-label":xe().clearLabel,hidden:!0},d(`x`))):null,A=i(`div`,{class:`wui-select-options`,role:`listbox`,id:m,tabindex:`-1`,"aria-multiselectable":n?`true`:void 0}),j=i(`div`,{class:`wui-select-menu wui-select-menu-fixed`,popover:`auto`},k,A),M=i(`div`,{class:`field-error wui-select-error`,id:h,"aria-live":`polite`,hidden:!this._error||void 0},this._error||null);this.replaceChildren(i(`div`,{class:`wui-select${c}`},C,j),M),this._rendered=!0,this._syncMirror(),this._syncValidity(),this._drawValue(),this._syncReset(),this.renderList(),this._wire(),o(this,this.querySelector(`.wui-select-control`)),this._syncUnderline(),this._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||X().fallbackName}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t=document.createDocumentFragment();for(let n of e.childNodes)t.append(n.cloneNode(!0));let n={value:e.getAttribute(`value`)??$(e).trim(),label:t.textContent??``,selected:e.hasAttribute(`selected`)};for(let[t,r]of Ne){let i=e.getAttribute(t);i&&(n[r]=i)}return e.hasAttribute(`disabled`)&&(n.disabled=!0),v(n,t)}))}_readOptions(){return this.mode===`country`?this._partOptions||[]:this._partOptions?this._partOptions:this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_listOptions(){let e=this._readOptions(),t=this.getAttribute(`value-label`);if(this.mode!==`search`||!t||this._value===``)return e;let n=String(this._value);return e.some(e=>String(e.value)===n)?e:[...e,{value:n,label:t}]}_declaredSelected(){return this._optionsProp?[]:(this._declared??[]).filter(e=>e.selected).map(e=>String(e.value))}_preselect(){let e=this._readOptions(),t=this._value!==``&&e.find(e=>String(e.value)===this._value)||e.find(e=>`selected`in e&&!!e.selected);t&&(this._value=String(t.value))}_optionFor(e){let t=String(e),n=this._readOptions().find(e=>String(e.value)===t);return n?(this._known.set(t,n),n):this._known.get(t)}_placeholder(){return this.getAttribute(`placeholder`)||Ae()[this.mode]}_hasValue(){return Array.isArray(this._value)?this._value.length>0:this._value!==``}_selectedValues(){return Array.isArray(this._value)?this._value:this._value===``?this._listOptions().some(e=>String(e.value)===``)?[``]:[]:[this._value]}_applyValue(){this._syncMirror(),this._syncValidity(),this._rendered&&(this._drawValue(),this._syncReset(),this.renderList())}_syncMirror(){H(this.mode)?c(this,this._selectedValues()):l(this,this._value)}_drawValue(){let e=this._refs();if(!e.value)return;let t=H(this.mode),n=t?void 0:this._optionFor(this._value);if(this._syncTitle(n),this._syncValueAvatar(),this._activePartsList().some(e=>e.renderValue?.()===!0))return;if(t){e.value.classList.remove(`wui-select-placeholder`),e.value.textContent=``;return}e.value.classList.toggle(`wui-select-placeholder`,!n);let r=this._placeholder();e.value.replaceChildren(...n?b(n):r?[r]:[])}_syncTitle(e){let t=this.querySelector(`.wui-select-control`);if(!t)return;let n=e&&!this.hasAttribute(`title`)?y(e).trim():``;n?t.setAttribute(`title`,n):t.removeAttribute(`title`)}_syncValueAvatar(){let e=this.querySelector(`.wui-select-control`);if(!e)return;e.querySelector(`:scope > .wui-select-value-avatar`)?.remove();let n=!H(this.mode)&&this._hasValue()?t({avatar:this.getAttribute(`value-avatar`),initials:this.getAttribute(`value-initials`)},`avatar-xs`):null;e.classList.toggle(`wui-has-value-avatar`,!!n),n&&e.prepend(i(`span`,{class:`wui-select-value-avatar`,"aria-hidden":`true`},n))}_syncValidity(){let e=this._internals;if(typeof e?.setValidity==`function`){if(this.hasAttribute(`required`)&&!this._hasValue()){let t=this.querySelector(`.wui-select-control`);e.setValidity({valueMissing:!0},Se().requiredFieldMessage,t instanceof HTMLElement?t:void 0)}else e.setValidity({})}}_syncReset(){let e=Q(this,`.wui-select-reset`,HTMLElement);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!s(this)))}_syncUnderline(){this.querySelector(`.wui-select-control`)?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`))}_syncInvalid(){let e=this.querySelector(`.wui-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._error?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}_syncError(){let e=Q(this,`.wui-select-error`,HTMLElement);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:Q(this,`.wui-select-control`,HTMLElement),value:Q(this,`.wui-select-value`,HTMLElement),menu:Q(this,`.wui-select-menu`,HTMLElement),list:Q(this,`.wui-select-options`,HTMLElement),search:Q(this,`.wui-select-search input`,HTMLInputElement),input:Q(this,`.wui-select-draft`,HTMLInputElement)}}_menuOpen(){let e=Q(this,`.wui-select-menu`,HTMLElement);return e!==null&&_(e)}_hoverZone(e){if(!(e instanceof Element))return!1;let t=e.closest(`.wui-select-control, .wui-select-menu`);return t!==null&&this.contains(t)}_hoverEligible(){if(!this.hasAttribute(`open-on-hover`)||s(this)||this.mode===`tag`)return!1;let e=this._refs();return e.search===null&&e.input===null}_clearHover(){this._hoverTimer!==null&&clearTimeout(this._hoverTimer),this._hoverTimer=null}_autoSearch(){return this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._readOptions().length>ke}_visible(){let e=this._refs();return e.list?Re(e.list,`.wui-select-option`):[]}_rowCount(){return this._windowed?this._rows:this._visible().length}_rowEl(e){if(!this._windowed)return this._visible()[e];let t=this._refs().list?.querySelector(`[data-index="${e}"]`);return t instanceof HTMLElement?t:void 0}_setActive(e,{reveal:t=!0}={}){let n=this._refs();if(!n.list||!n.control)return;this._active=e;let r=null;e>=0&&e<this._rowCount()&&(r=this._rowEl(e)??(this._windowed&&t?ee(n.list,e):null)),p(n.list,r),r?(t&&r.scrollIntoView({block:`nearest`}),n.control.setAttribute(`aria-activedescendant`,r.id)):n.control.removeAttribute(`aria-activedescendant`)}_onListScroll(){this._scrollFrame=null;let e=this._refs().list;e&&B(e)&&this._active>=0&&this._setActive(this._active,{reveal:!1})}_actionRows(){let e=[];for(let t of this._activePartsList()){let n=t.actionRow?.(this._query);n&&e.push(n)}return e}_recents(){if(this._query.trim()!==``)return null;for(let e of this._activePartsList()){let t=e.recents?.(this._listOptions());if(t)return t}return null}_menuPlacement(e,t){let n=this.hasAttribute(`open`)?{below:!0}:{};if(this.getAttribute(`density`)!==`compact`)return{matchWidth:!0,...n};let r=e.getBoundingClientRect();return t.style.width=`max-content`,t.style.minWidth=`${r.width}px`,t.style.maxWidth=`280px`,n}_anchorMenu(){let t=this._refs();t.control&&t.menu&&this._menuOpen()&&e(t.control,t.menu,this._menuPlacement(t.control,t.menu))}_showMenu(e,t){g(e,t,{...this._menuPlacement(e,t),mode:`auto`,keepOffscreen:this.hasAttribute(`open`),onClosed:()=>this._onPanelClosed()}),this._panelShown=!0}_onPanelClosed(){if(!this._panelShown)return;this._panelShown=!1;let e=this._refs();e.control&&(e.control.setAttribute(`aria-expanded`,`false`),this._setActive(-1),this._nav?.clearTypeahead(),this.dispatchEvent(new CustomEvent(`wui-select:close`,{bubbles:!0})))}_open({focus:e=!0}={}){let t=this._refs();if(!t.menu||!t.control)return;let n=this._menuOpen();this._hoverOpened=!1,t.control.setAttribute(`aria-expanded`,`true`),this._query=t.input?t.input.value:``,this._ownsFilter=this._ownsFilter&&this._query!==``;let r=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement);if(r&&(r.hidden=!0),t.search&&(t.search.value=``),n||this._showMenu(t.control,t.menu),this.renderList(),e&&(t.search?.focus(),this._setActive(this._windowed&&t.list?te(t.list,this._selectedValues()):this._visible().findIndex(e=>e.classList.contains(`selected`)))),!n){this.dispatchEvent(new CustomEvent(`wui-select:open`,{bubbles:!0}));for(let e of this._activePartsList())e.onOpen?.()}}_close({force:e=!1}={}){if(!e&&this.hasAttribute(`open`))return;let t=this._refs();if(!t.menu||!t.control)return;this._hoverOpened=!1;let n=t.menu.contains(document.activeElement);_(t.menu)&&h(t.menu),this._onPanelClosed(),n&&t.control.focus()}_onQueryChange(e){this._query=e,this._setActive(-1);let t=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement);t&&(t.hidden=!e);let n=!1;for(let t of this._activePartsList())t.onQuery?.(e)===!0&&(n=!0);this._ownsFilter=n,this.renderList()}_pick(e){if(e.getAttribute(`aria-disabled`)===`true`)return;let t=e.dataset.custom===`true`,n=e.dataset.value??``,r=t?{value:n,label:$(e).trim()}:this._listOptions().find(e=>String(e.value)===n)??{value:n,label:n},i=this._activePartsList().some(e=>e.onPick?.(r,{isCustom:t})===!0);H(this.mode)||(i||this.commit(n,{isCustom:t}),this._close(),this._refs().control?.focus())}_draftOpens(){return this.mode===`multiple`?this.hasAttribute(`allow-custom`):this.mode===`tag`&&U(this)}_onKeyDown(e){if(!s(this)){for(let t of this._activePartsList())if(t.onKey?.(e)===!0)return;if(!this._menuOpen()){if(e.target instanceof HTMLInputElement){if(e.key!==`ArrowDown`||!this._draftOpens())return;this._open({focus:!1})}else{(e.key===`ArrowDown`||f(e)||e.key===` `)&&(e.preventDefault(),this._open({focus:!0}));return}}r(this._nav,`Listbox keys are not wired.`).handler(e)}}_wire(){this._teardown();let e=this._refs(),t=e.control,n=e.list;if(!t||!e.menu||!n)return;let i=r(Q(this,`.wui-select`,HTMLElement),`The select wrapper is missing.`),a=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement),o=Q(this,`.wui-select-reset`,HTMLElement);this._nav=m({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>this._setActive(e),getCount:()=>this._rowCount(),getOptionAt:e=>this._rowEl(e),findByPrefix:e=>this._windowed?ne(n,e):this._visible().findIndex(t=>t.textContent.trim().toLowerCase().startsWith(e)),onEnter:(e,t)=>{if(e)this._pick(e);else if(this._query.trim()!==``){let e=t.find(e=>e.dataset.custom===`true`);if(e)this._pick(e);else if(t.length===1){let e=t[0];e&&this._pick(e)}}},onEscape:e=>{e.preventDefault(),this._nav?.clearTypeahead(),this._close(),t.focus()}}),i.addEventListener(`keydown`,e=>this._onKeyDown(e)),i.addEventListener(`input`,e=>{let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-select-input, .wui-select-draft`))return;this._onQueryChange(t.value);let n=t.matches(`.wui-select-draft`),r=this._rows>0||this._actionRows().length>0;n&&r&&!this._menuOpen()&&!s(this)&&this._draftOpens()&&this._open({focus:!1})}),i.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||!this._activePartsList().some(e=>e.onBlur?.()===!0)&&t&&this._close()}),a?.addEventListener(`click`,()=>{let t=r(e.search,`The search input is missing.`);t.value=``,this._onQueryChange(``),t.focus()}),t.addEventListener(`pointerdown`,()=>{this._pressOpen=this._menuOpen()}),t.addEventListener(`click`,e=>{if(e.target instanceof Element&&e.target.closest(`[data-remove]`))return;if(this.mode===`tag`){if(s(this))return;this._refs().input?.focus(),!this._menuOpen()&&this._draftOpens()&&this._open({focus:!1});return}if(e.target instanceof HTMLInputElement){!this._menuOpen()&&!s(this)&&this._open({focus:!1});return}let t=e.detail>0&&this._pressOpen!==null?this._pressOpen:this._menuOpen();this._pressOpen=null,this._clearHover(),this._hoverOpened&&t?(this._hoverOpened=!1,this._open({focus:!0})):t?this._close():s(this)||this._open({focus:!0})}),o?.addEventListener(`click`,e=>{e.stopPropagation(),this.commit(H(this.mode)?[]:``),this._close(),t.focus()}),n.addEventListener(`click`,n=>{let r=Le(n).closest(`.wui-select-option`);if(r instanceof HTMLElement&&(this._pick(r),H(this.mode))){let n=this.querySelector(`.wui-select-draft`);(e.search??(n instanceof HTMLElement?n:t)).focus()}}),n.addEventListener(`mousedown`,e=>{H(this.mode)&&e.target instanceof Element&&e.target.closest(`.wui-select-option`)&&e.preventDefault()}),n.addEventListener(`mousemove`,e=>{let t=Le(e).closest(`.wui-select-option`);t instanceof HTMLElement&&!t.classList.contains(`is-active`)&&this._setActive(this._windowed?Number(t.dataset.index):this._visible().indexOf(t),{reveal:!1})}),n.addEventListener(`scroll`,()=>{this._windowed&&this._scrollFrame===null&&(this._scrollFrame=requestAnimationFrame(()=>this._onListScroll()))},{passive:!0}),n.addEventListener(`mouseleave`,()=>this._setActive(-1)),n.addEventListener(`error`,e=>{let t=e.target;t instanceof Element&&t.classList.contains(`avatar-img`)&&t.remove()},!0),this.hasAttribute(`open`)&&this._open({focus:!1})}_teardown(){this._nav?.clearTypeahead(),this._scrollFrame!==null&&cancelAnimationFrame(this._scrollFrame),this._scrollFrame=null}_dropMenu(){let e=Q(this,`.wui-select-menu`,HTMLElement);e&&h(e)}_activePartsList(){return this._partsMounted?r(this._parts,`The mounted parts are missing.`):[]}_ensureParts(){if(!this.isConnected)return;(this.hasAttribute(`source`)||this.hasAttribute(`remote`)||this.hasAttribute(`recents-key`)||this._loadOptionsFn!==null)&&this._loadWindow();let e=Fe(this,this.mode),t=e.join(`,`);if(t===this._partSig)return;this._teardownParts(),this._parts=null,this._partSig=t;let n=++this._partToken;Promise.all(e.map(e=>ze(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(e=>e!==null),this._mountParts())})}_loadWindow(){this._windowLoad===null&&(this._windowLoad=be().then(()=>this.renderList(),()=>{this._windowFailed=!0,document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:`select-window`}})),this.setError(X().partLoadMessage)}))}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=we(this._refs());for(let n of this._parts)n.mount(this,t,{carry:e});this._drawValue(),this.renderList()}_teardownParts(){let e=this._activePartsList();this._partsMounted=!1;for(let t of e)t.teardown()}_remountParts(){if(!this._partsMounted)return;let e=this._carry();this._teardownParts(),this._mountParts(e)}_carry(){let e=this._refs();return{draft:e.input?.value??``,query:e.search?.value??``}}},we=e=>{let{control:t,value:n,menu:i,list:a}=e;return{control:r(t,`control missing`),value:r(n,`value missing`),menu:r(i,`menu missing`),list:r(a,`list missing`),search:e.search,input:e.input}},Te=e=>re.includes(e),Ee=[`comfortable`,`compact`],De=150,Oe=250,ke=10,Ae=()=>{let e=X();return{single:e.placeholder,search:e.placeholder,multiple:e.placeholder,tag:e.tagPlaceholder,country:e.countryPlaceholder}},je=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),Me=/* @__PURE__ */ new Set([`separators`,`allow-duplicates`,`invalid-message`,`create-label`,`add-label`,`selected-text`,`clear-all-label`,`value-label`,`value-avatar`,`value-initials`,`hint-text`,`recents-key`,`recents-limit`,`recents-label`]),Ne=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],Z=(e,t)=>t?Array.isArray(e)?e.map(String):e==null||e===``?[]:String(e).split(`,`).map(e=>e.trim()).filter(Boolean):Array.isArray(e)?e.length?String(e[0]):``:e==null?``:String(e),Pe=(e,t)=>t===`multiple`?U(e)?[`chips`,`search`]:[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?U(e)?[`chips`,`search`]:[`chips`]:[],Fe=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...Pe(e,t)]:Pe(e,t),Ie=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,Le=e=>{if(e.target instanceof Element)return e.target;throw Error(`The event target is not an element.`)},Q=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Re=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),$=e=>{let t=e.textContent;if(t===null)throw Error(`The element has no text.`);return t},ze=(e,t)=>ae(t).then(e=>{if(!Ie(e))throw Error(`The part ${t} has no default export.`);return e.default()}).catch(()=>(document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:t}})),e.setError(X().partLoadMessage),null));export{U as n,A as r,Ce as t};
|
|
1
|
+
import{t as e}from"./anchorOverlay-daGdh_91.js";import{t}from"./avatarNode-BaEvz5Xr.js";import{n}from"./devWarn-DXdRWZs3.js";import{i as r,r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{r as o,t as s}from"./fieldState-D-zQcXUS.js";import{n as c,t as l}from"./formMirror-9IpSgeZb.js";import{n as u}from"./loader-X2uBXCDm.js";import{t as d}from"./iconGlyphs.g-a9FtjPXh.js";import{n as f}from"./imeSafeEnter-DeO_3lXy.js";import{n as p,t as m}from"./listboxKeyNav-CNso9shL.js";import{a as h,l as g,s as _}from"./nativeOverlay-BHD2QV02.js";import{i as v,n as y,t as b}from"./optionLabel-wbpl8OTJ.js";import{r as x}from"./textStore-DBplASiZ.js";import{n as S,r as C,t as w}from"./search.g-B5d1s59A.js";import{t as T}from"./hasOwn-CJsplJ62.js";import{n as E,r as D,t as O}from"./window-BZWK3rQk.js";var k=()=>x(`select`,C);function A(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[y(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var j=/* @__PURE__ */ new WeakMap,M=e=>e?{"data-index":String(e.index),"aria-setsize":String(e.size),"aria-posinset":String(e.index+1)}:{},N=e=>e.map(e=>e instanceof Element?e.outerHTML:e.textContent??``).join(``),P;function F(e){P=e}function I(e){P?.clear(e),j.delete(e),e.replaceChildren()}function L(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=k().emptyText,searchingText:c=k().searchingText,hintText:l=k().hintText,actionRow:u=[],recents:d=null}=n,f=new Set(r.map(String)),p=A(t,a),m=e.id,h=u.filter(e=>e.position===`top`),g=u.filter(e=>e.position===`bottom`),_=d?.options.length?d.options:[],v=h.length+_.length+p.length+g.length,y=p.length>300,b=P,x=y&&b!==void 0,S=e=>x?{index:e,size:v}:void 0,C=0,w=e=>{let t=C++;return i(`button`,{type:`button`,role:`option`,id:R(m,t),class:`wui-select-option wui-select-add`,"data-value":String(e.value??``),"data-custom":`true`,"aria-selected":`false`,...M(S(t))},e.label)},T=e=>{let t=C++;return V(e,R(m,t),f.has(String(e.value)),S(t))},E=h.map(w),D=_.length&&d?[i(`div`,{class:`wui-select-group`},d.label),..._.map(T),i(`div`,{class:`wui-select-sep`,"aria-hidden":`true`})]:[],O=C,F=[];if(x)C+=p.length;else{let e=``;for(let t of p)t.group&&t.group!==e&&F.push(i(`div`,{class:`wui-select-group`},t.group)),e=t.group??``,F.push(T(t))}let I=g.map(w),L=[];if(o===`loading`?L=[i(`div`,{class:`wui-select-loading`},i(`span`,{class:`wui-select-spinner spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`}),c)]:o===`hint`?L=[i(`div`,{class:`wui-select-hint`},l)]:(o===`empty`||p.length===0&&u.length===0)&&(L=[i(`div`,{class:`wui-select-empty`},s)]),x&&b){let n=[...E,...D],r=[...I,...L];return b.render(e,{options:t,query:a,rows:p,pre:n,post:r,preSig:N(n),postSig:N(r),picked:f,top:h,recent:_,bottom:g,bodyBase:O,total:v}),{rows:v,windowed:!0,long:y}}b?.clear(e);let z=[...E,...D,...F,...I,...L],B=N(z);return j.get(e)===B||(j.set(e,B),e.replaceChildren(...z)),{rows:C,windowed:!1,long:y}}var R=(e,t)=>`${e}-opt-${t}`,z=e=>[...e.querySelectorAll(`.wui-select-option`)];function B(e){return P?P.refresh(e):!1}function ee(e,t){return P?P.reveal(e,t):z(e)[t]??null}function te(e,t){if(P)return P.indexOfValue(e,t);let n=new Set(t.map(String));return z(e).findIndex(e=>n.has(e.dataset.value??``))}function ne(e,t){return P?P.indexByPrefix(e,t):z(e).findIndex(e=>(e.textContent??``).trim().toLowerCase().startsWith(t))}function V(e,n,r,a){let o=!!e.disabled,s={id:n,role:`option`,"data-value":String(e.value??``),"aria-selected":String(r),"aria-disabled":o?`true`:void 0,title:o&&e.disabledHint?e.disabledHint:void 0,...M(a)},c=i(`span`,{class:`wui-select-check`,"aria-hidden":`true`},d(`check`));if(!e.description&&!e.meta)return i(`button`,{type:`button`,class:`wui-select-option${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-opt-name`},...b(e)),c);let l=e.description?i(`span`,{class:`wui-select-opt-desc`},e.description):null,u=e.meta?i(`span`,{class:`wui-select-opt-meta`},e.meta):null;return i(`div`,{class:`wui-select-option wui-select-option-rich${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-option-text`},i(`span`,{class:`wui-opt-label`},...b(e)),l),u,c)}var re=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),H=e=>e===`multiple`||e===`tag`,ie={recents:()=>import(`./recents-B9efQ1Au.js`),chips:()=>import(`./chips-DxSWAJDI.js`),search:()=>import(`./search-DLRWJomU.js`),country:()=>import(`./country-T7AfpJpN.js`)};function ae(e){let t=T(ie,e)?ie[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var U=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),oe=300,W=`<div class="wui-select-spacer" aria-hidden="true"></div>`,G=()=>i(`div`,{class:`wui-select-spacer`,"aria-hidden":`true`}),K=/* @__PURE__ */ new WeakMap;function se(e,t,n,r){let i=K.get(e);if(i&&i.options===t&&i.query===n&&i.count===r.length)return i;let a=[],o=new Int32Array(r.length),s=``;r.forEach((e,t)=>{e.group&&e.group!==s&&a.push({kind:`group`,label:e.group}),s=e.group??``,o[t]=a.length,a.push({kind:`option`,option:e,ord:t})});let c={options:t,query:n,count:r.length,entries:a,optionEntry:o,heights:O(a.length),estimated:!1,bodyTop:0,start:0,end:0,pre:[],post:[],preSig:``,postSig:``,picked:/* @__PURE__ */ new Set,top:[],recent:[],bottom:[],bodyBase:0,total:0};return K.set(e,c),e.scrollTop=0,c}var q=e=>e.clientHeight||oe,J=(e,t)=>D(t.heights,{scrollTop:Math.max(0,e.scrollTop-t.bodyTop),viewport:q(e)});function ce(e,t,n,r){let a=[];for(let o=n;o<r;o++){let n=e.entries[o];if(n){if(n.kind===`group`)a.push(i(`div`,{class:`wui-select-group`,"data-entry":o},n.label));else{let r=e.bodyBase+n.ord;a.push(V(n.option,R(t,r),e.picked.has(String(n.option.value)),{index:r,size:e.total}))}}}return a}function le(e,t){let[n,r]=e.querySelectorAll(`.wui-select-spacer`);n&&r&&(n.style.flex=r.style.flex=`none`,n.style.height=`${t.heights.offsetOf(t.start)}px`,r.style.height=`${t.heights.total()-t.heights.offsetOf(t.end)}px`)}function ue(e,t){let{start:n,end:r}=J(e,t);t.start=n,t.end=r;let i=ce(t,e.id,n,r),a=t.preSig+W+N(i)+W+t.postSig,o=e.scrollTop;j.get(e)!==a&&(j.set(e,a),e.replaceChildren(...t.pre,G(),...i,G(),...t.post)),le(e,t),e.scrollTop!==o&&(e.scrollTop=o)}function de(e,t){let n={changed:!1,delta:0};if(!e.clientHeight)return n;let{heights:r}=t,i=e.querySelector(`.wui-select-spacer`),a=[],o=!0,s=!1;if(i){let n=i.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;Math.abs(n-t.bodyTop)>.5&&(t.bodyTop=n,s=!0)}let c=r.indexAt(Math.max(0,e.scrollTop-t.bodyTop)),l=r.offsetOf(c),u=0;for(let n of e.querySelectorAll(`.wui-select-option[data-index], .wui-select-group[data-entry]`)){let e=n.getBoundingClientRect().height;if(n.dataset.entry!==void 0)a.push([Number(n.dataset.entry),e]);else{let r=Number(n.dataset.index)-t.bodyBase,i=r>=0?t.optionEntry[r]:void 0;if(i===void 0)continue;o&&(u=e),o=!1,a.push([i,e])}}if(!t.estimated&&u>0){let e=r.estimate;r.setEstimate(u),t.estimated=!0,r.estimate!==e&&(s=!0)}for(let[e,t]of a)r.set(e,t)&&(s=!0);return s?{changed:s,delta:r.offsetOf(c)-l}:n}function Y(e,t){ue(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=de(e,t);if(!n)return;le(e,t),r&&(e.scrollTop+=r),ue(e,t)}}function fe(e,t){let n=se(e,t.options,t.query,t.rows);Object.assign(n,{pre:t.pre,post:t.post,preSig:t.preSig,postSig:t.postSig,picked:t.picked,top:t.top,recent:t.recent,bottom:t.bottom,bodyBase:t.bodyBase,total:t.total}),Y(e,n)}function pe(e){let t=K.get(e);if(!t)return!1;let{start:n,end:r}=J(e,t);return n===t.start&&r===t.end?!1:(Y(e,t),!0)}function me(e,t){let n=K.get(e);if(!n||t<0||t>=n.total)return null;let r=t-n.bodyBase,i=r>=0?n.optionEntry[r]:void 0,a=()=>e.querySelector(`[data-index="${t}"]`);if(i===void 0)return a();for(let t=0;t<2;t++){let t={scrollTop:e.scrollTop-n.bodyTop,viewport:q(e)},r=n.bodyTop+E(n.heights,i,t);if(Math.abs(r-e.scrollTop)>.5)e.scrollTop=r;else if(a())break;Y(e,n)}return a()}function he(e,t){if(t<0||t>=e.total)return;if(t<e.top.length)return e.top[t];let n=t-e.top.length;if(n<e.recent.length)return e.recent[n];let r=t-e.bodyBase;if(r<e.count){let t=e.entries[e.optionEntry[r]??-1];return t?.kind===`option`?t.option:void 0}return e.bottom[r-e.count]}var ge=e=>e&&!(`position`in e)?e:void 0;function _e(e,t){let n=K.get(e);if(!n||t.length===0)return-1;let r=new Set(t.map(String));for(let e=0;e<n.total;e++){let t=ge(he(n,e));if(t&&r.has(String(t.value)))return e}return-1}var ve=e=>`position`in e?e.label:`${e.initials??``}${y(e)}${e.description??``}${e.meta??``}`;function ye(e,t){let n=K.get(e);if(!n)return-1;for(let e=0;e<n.total;e++){let r=he(n,e);if(r&&ve(r).trim().toLowerCase().startsWith(t))return e}return-1}F({render:fe,refresh:pe,reveal:me,indexOfValue:_e,indexByPrefix:ye,clear(e){K.delete(e)}});function be(){return Promise.resolve()}var X=()=>x(`select`,C),xe=()=>x(`search`,w),Se=()=>x(`field`,S),Ce=class extends a{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_rows;_windowed;_windowLoad;_windowFailed;_scrollFrame;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_panelShown;_pressOpen;static get observedAttributes(){return/* @__PURE__ */ `class.mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.open-on-hover.lazy-options.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._rows=0,this._windowed=!1,this._windowLoad=null,this._windowFailed=!1,this._scrollFrame=null,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._searchShown=!1,this._defaultValue=void 0,this._warnedMode=null,this._hoverTimer=null,this._hoverOpened=!1,this._panelShown=!1,this._pressOpen=null,this._onHoverOver=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&(this._clearHover(),!this._menuOpen()&&this._hoverEligible()&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,!this._menuOpen()&&this._hoverEligible()&&(this._open({focus:!1}),this._hoverOpened=!0)},De)))},this._onHoverOut=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&!this._hoverZone(e.relatedTarget)&&(this._clearHover(),this._menuOpen()&&this.hasAttribute(`open-on-hover`)&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._close()},Oe)))}}connectedCallback(){this.addEventListener(`pointerover`,this._onHoverOver),this.addEventListener(`pointerout`,this._onHoverOut),this._rendered||this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this.removeEventListener(`pointerover`,this._onHoverOver),this.removeEventListener(`pointerout`,this._onHoverOut),this._clearHover(),this._dropMenu(),this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`class`?this._syncUnderline():e===`value`?(this._value=Z(n,H(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):e===`open-on-hover`?this.hasAttribute(`open-on-hover`)||this._clearHover():e!==`lazy-options`&&(e===`mode`&&(this._value=Z(this._value,H(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),Me.has(e)?this._rendered&&(this._drawValue(),this.renderList()):je.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null?`single`:Te(e)?e:(e!==this._warnedMode&&(this._warnedMode=e,n(`<wui-select> mode "${e}" is not one of ${re.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||Ee.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,n(`<wui-select> density "${e}" is not one of ${Ee.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=Z(e,H(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();if(this._rendered){if(this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._autoSearch()!==this._searchShown){this.render();return}this._drawValue(),this.renderList()}}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){s(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();if(!e.list)return;let t=this._ownsFilter?``:this._query,n=this._actionRows(),r=this._recents();if(this.hasAttribute(`lazy-options`)&&!this._menuOpen()){this._rows=A(this._listOptions(),t).length+n.length+(r?.options.length??0),this._windowed=!1,I(e.list),this._anchorMenu();return}let i=L(e.list,this._listOptions(),{selected:this._selectedValues(),query:t,status:this._status,emptyText:this.getAttribute(`empty-text`)||X().emptyText,searchingText:this.getAttribute(`searching-text`)||X().searchingText,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:n,recents:r});this._rows=i.rows,this._windowed=i.windowed,i.long&&!i.windowed&&!this._windowFailed&&this._loadWindow(),this._active>=this._rowCount()&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._anchorMenu()}render(){this._dropMenu();let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=H(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=Z(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=Z(this._value,n));let s=this.getAttribute(`size`),c=s===`sm`?` wui-select-sm`:s===`lg`?` wui-select-lg`:s===`xl`?` wui-select-xl`:``,l=this.getAttribute(`icon`),u=this.getAttribute(`prefix`),f=this.hasAttribute(`clearable`),p=this.hasAttribute(`disabled`);if(!this.id){let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(8));this.id=`wui-select-${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`}let m=`${this.id}-listbox`,h=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${h}`:h,v=this.hasAttribute(`aria-invalid`)||!!this._error,y=this.hasAttribute(`required`)&&!a,b=this._accessibleName(),x=a?{}:{role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":m},S={"aria-label":b,"aria-describedby":_,"aria-invalid":v?`true`:void 0,"aria-required":y?`true`:void 0},C=n?i(`div`,{class:`input wui-select-control wui-select-multi`,...x,...S,"aria-disabled":p?`true`:void 0,tabindex:!p&&!r?`0`:void 0}):i(`button`,{type:`button`,class:`input wui-select-control`,...x,...S,disabled:p||void 0}),w=[l?d(l,{className:`wui-select-icon`}):null,u?i(`span`,{class:`wui-select-prefix`},u):null,i(`span`,{class:`wui-select-value`,"data-label":!0}),f?i(`span`,{class:`wui-select-reset`,role:`button`,"aria-label":X().clearSelectionLabel,hidden:!0},d(`x`)):null,d(`chevron-down`,{className:`wui-select-caret`})];C.append(...w.filter(e=>e!==null));let T=this.getAttribute(`searchable`),E=T===null?t===`multiple`||t===`country`||this._autoSearch():T!==`false`,D=t===`search`||E&&!a;this._searchShown=D;let O=this.getAttribute(`search-placeholder`)||(t===`country`?X().countrySearchPlaceholder:xe().placeholder),k=D?i(`div`,{class:`wui-select-search`},d(`search`),i(`input`,{class:`wui-select-input`,placeholder:O,"aria-label":O,"aria-autocomplete":`list`}),i(`button`,{type:`button`,class:`wui-select-clear`,"aria-label":xe().clearLabel,hidden:!0},d(`x`))):null,A=i(`div`,{class:`wui-select-options`,role:`listbox`,id:m,tabindex:`-1`,"aria-multiselectable":n?`true`:void 0}),j=i(`div`,{class:`wui-select-menu wui-select-menu-fixed`,popover:`auto`},k,A),M=i(`div`,{class:`field-error wui-select-error`,id:h,"aria-live":`polite`,hidden:!this._error||void 0},this._error||null);this.replaceChildren(i(`div`,{class:`wui-select${c}`},C,j),M),this._rendered=!0,this._syncMirror(),this._syncValidity(),this._drawValue(),this._syncReset(),this.renderList(),this._wire(),o(this,this.querySelector(`.wui-select-control`)),this._syncUnderline(),this._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||X().fallbackName}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t=document.createDocumentFragment();for(let n of e.childNodes)t.append(n.cloneNode(!0));let n={value:e.getAttribute(`value`)??$(e).trim(),label:t.textContent??``,selected:e.hasAttribute(`selected`)};for(let[t,r]of Ne){let i=e.getAttribute(t);i&&(n[r]=i)}return e.hasAttribute(`disabled`)&&(n.disabled=!0),v(n,t)}))}_readOptions(){return this.mode===`country`?this._partOptions||[]:this._partOptions?this._partOptions:this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_listOptions(){let e=this._readOptions(),t=this.getAttribute(`value-label`);if(this.mode!==`search`||!t||this._value===``)return e;let n=String(this._value);return e.some(e=>String(e.value)===n)?e:[...e,{value:n,label:t}]}_declaredSelected(){return this._optionsProp?[]:(this._declared??[]).filter(e=>e.selected).map(e=>String(e.value))}_preselect(){let e=this._readOptions(),t=this._value!==``&&e.find(e=>String(e.value)===this._value)||e.find(e=>`selected`in e&&!!e.selected);t&&(this._value=String(t.value))}_optionFor(e){let t=String(e),n=this._readOptions().find(e=>String(e.value)===t);return n?(this._known.set(t,n),n):this._known.get(t)}_placeholder(){return this.getAttribute(`placeholder`)||Ae()[this.mode]}_hasValue(){return Array.isArray(this._value)?this._value.length>0:this._value!==``}_selectedValues(){return Array.isArray(this._value)?this._value:this._value===``?this._listOptions().some(e=>String(e.value)===``)?[``]:[]:[this._value]}_applyValue(){this._syncMirror(),this._syncValidity(),this._rendered&&(this._drawValue(),this._syncReset(),this.renderList())}_syncMirror(){H(this.mode)?c(this,this._selectedValues()):l(this,this._value)}_drawValue(){let e=this._refs();if(!e.value)return;let t=H(this.mode),n=t?void 0:this._optionFor(this._value);if(this._syncTitle(n),this._syncValueAvatar(),this._activePartsList().some(e=>e.renderValue?.()===!0))return;if(t){e.value.classList.remove(`wui-select-placeholder`),e.value.textContent=``;return}e.value.classList.toggle(`wui-select-placeholder`,!n);let r=this._placeholder();e.value.replaceChildren(...n?b(n):r?[r]:[])}_syncTitle(e){let t=this.querySelector(`.wui-select-control`);if(!t)return;let n=e&&!this.hasAttribute(`title`)?y(e).trim():``;n?t.setAttribute(`title`,n):t.removeAttribute(`title`)}_syncValueAvatar(){let e=this.querySelector(`.wui-select-control`);if(!e)return;e.querySelector(`:scope > .wui-select-value-avatar`)?.remove();let n=!H(this.mode)&&this._hasValue()?t({avatar:this.getAttribute(`value-avatar`),initials:this.getAttribute(`value-initials`)},`avatar-xs`):null;e.classList.toggle(`wui-has-value-avatar`,!!n),n&&e.prepend(i(`span`,{class:`wui-select-value-avatar`,"aria-hidden":`true`},n))}_syncValidity(){let e=this._internals;if(typeof e?.setValidity==`function`){if(this.hasAttribute(`required`)&&!this._hasValue()){let t=this.querySelector(`.wui-select-control`);e.setValidity({valueMissing:!0},Se().requiredFieldMessage,t instanceof HTMLElement?t:void 0)}else e.setValidity({})}}_syncReset(){let e=Q(this,`.wui-select-reset`,HTMLElement);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!s(this)))}_syncUnderline(){this.querySelector(`.wui-select-control`)?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`))}_syncInvalid(){let e=this.querySelector(`.wui-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._error?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}_syncError(){let e=Q(this,`.wui-select-error`,HTMLElement);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:Q(this,`.wui-select-control`,HTMLElement),value:Q(this,`.wui-select-value`,HTMLElement),menu:Q(this,`.wui-select-menu`,HTMLElement),list:Q(this,`.wui-select-options`,HTMLElement),search:Q(this,`.wui-select-search input`,HTMLInputElement),input:Q(this,`.wui-select-draft`,HTMLInputElement)}}_menuOpen(){let e=Q(this,`.wui-select-menu`,HTMLElement);return e!==null&&_(e)}_hoverZone(e){if(!(e instanceof Element))return!1;let t=e.closest(`.wui-select-control, .wui-select-menu`);return t!==null&&this.contains(t)}_hoverEligible(){if(!this.hasAttribute(`open-on-hover`)||s(this)||this.mode===`tag`)return!1;let e=this._refs();return e.search===null&&e.input===null}_clearHover(){this._hoverTimer!==null&&clearTimeout(this._hoverTimer),this._hoverTimer=null}_autoSearch(){return this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._readOptions().length>ke}_visible(){let e=this._refs();return e.list?Re(e.list,`.wui-select-option`):[]}_rowCount(){return this._windowed?this._rows:this._visible().length}_rowEl(e){if(!this._windowed)return this._visible()[e];let t=this._refs().list?.querySelector(`[data-index="${e}"]`);return t instanceof HTMLElement?t:void 0}_setActive(e,{reveal:t=!0}={}){let n=this._refs();if(!n.list||!n.control)return;this._active=e;let r=null;e>=0&&e<this._rowCount()&&(r=this._rowEl(e)??(this._windowed&&t?ee(n.list,e):null)),p(n.list,r),r?(t&&r.scrollIntoView({block:`nearest`}),n.control.setAttribute(`aria-activedescendant`,r.id)):n.control.removeAttribute(`aria-activedescendant`)}_onListScroll(){this._scrollFrame=null;let e=this._refs().list;e&&B(e)&&this._active>=0&&this._setActive(this._active,{reveal:!1})}_actionRows(){let e=[];for(let t of this._activePartsList()){let n=t.actionRow?.(this._query);n&&e.push(n)}return e}_recents(){if(this._query.trim()!==``)return null;for(let e of this._activePartsList()){let t=e.recents?.(this._listOptions());if(t)return t}return null}_menuPlacement(e,t){let n=this.hasAttribute(`open`)?{below:!0}:{};if(this.getAttribute(`density`)!==`compact`)return{matchWidth:!0,...n};let r=e.getBoundingClientRect();return t.style.width=`max-content`,t.style.minWidth=`${r.width}px`,t.style.maxWidth=`280px`,n}_anchorMenu(){let t=this._refs();t.control&&t.menu&&this._menuOpen()&&e(t.control,t.menu,this._menuPlacement(t.control,t.menu))}_showMenu(e,t){g(e,t,{...this._menuPlacement(e,t),mode:`auto`,keepOffscreen:this.hasAttribute(`open`),onClosed:()=>this._onPanelClosed()}),this._panelShown=!0}_onPanelClosed(){if(!this._panelShown)return;this._panelShown=!1;let e=this._refs();e.control&&(e.control.setAttribute(`aria-expanded`,`false`),this._setActive(-1),this._nav?.clearTypeahead(),this.dispatchEvent(new CustomEvent(`wui-select:close`,{bubbles:!0})))}_open({focus:e=!0}={}){let t=this._refs();if(!t.menu||!t.control)return;let n=this._menuOpen();this._hoverOpened=!1,t.control.setAttribute(`aria-expanded`,`true`),this._query=t.input?t.input.value:``,this._ownsFilter=this._ownsFilter&&this._query!==``;let r=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement);if(r&&(r.hidden=!0),t.search&&(t.search.value=``),n||this._showMenu(t.control,t.menu),this.renderList(),e&&(t.search?.focus(),this._setActive(this._windowed&&t.list?te(t.list,this._selectedValues()):this._visible().findIndex(e=>e.classList.contains(`selected`)))),!n){this.dispatchEvent(new CustomEvent(`wui-select:open`,{bubbles:!0}));for(let e of this._activePartsList())e.onOpen?.()}}_close({force:e=!1}={}){if(!e&&this.hasAttribute(`open`))return;let t=this._refs();if(!t.menu||!t.control)return;this._hoverOpened=!1;let n=t.menu.contains(document.activeElement);_(t.menu)&&h(t.menu),this._onPanelClosed(),n&&t.control.focus()}_onQueryChange(e){this._query=e,this._setActive(-1);let t=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement);t&&(t.hidden=!e);let n=!1;for(let t of this._activePartsList())t.onQuery?.(e)===!0&&(n=!0);this._ownsFilter=n,this.renderList()}_pick(e){if(e.getAttribute(`aria-disabled`)===`true`)return;let t=e.dataset.custom===`true`,n=e.dataset.value??``,r=t?{value:n,label:$(e).trim()}:this._listOptions().find(e=>String(e.value)===n)??{value:n,label:n},i=this._activePartsList().some(e=>e.onPick?.(r,{isCustom:t})===!0);H(this.mode)||(i||this.commit(n,{isCustom:t}),this._close(),this._refs().control?.focus())}_draftOpens(){return this.mode===`multiple`?this.hasAttribute(`allow-custom`):this.mode===`tag`&&U(this)}_onKeyDown(e){if(!s(this)){for(let t of this._activePartsList())if(t.onKey?.(e)===!0)return;if(!this._menuOpen()){if(e.target instanceof HTMLInputElement){if(e.key!==`ArrowDown`||!this._draftOpens())return;this._open({focus:!1})}else{(e.key===`ArrowDown`||f(e)||e.key===` `)&&(e.preventDefault(),this._open({focus:!0}));return}}r(this._nav,`Listbox keys are not wired.`).handler(e)}}_wire(){this._teardown();let e=this._refs(),t=e.control,n=e.list;if(!t||!e.menu||!n)return;let i=r(Q(this,`.wui-select`,HTMLElement),`The select wrapper is missing.`),a=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement),o=Q(this,`.wui-select-reset`,HTMLElement);this._nav=m({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>this._setActive(e),getCount:()=>this._rowCount(),getOptionAt:e=>this._rowEl(e),findByPrefix:e=>this._windowed?ne(n,e):this._visible().findIndex(t=>t.textContent.trim().toLowerCase().startsWith(e)),onEnter:(e,t)=>{if(e)this._pick(e);else if(this._query.trim()!==``){let e=t.find(e=>e.dataset.custom===`true`);if(e)this._pick(e);else if(t.length===1){let e=t[0];e&&this._pick(e)}}},onEscape:e=>{e.preventDefault(),this._nav?.clearTypeahead(),this._close(),t.focus()}}),i.addEventListener(`keydown`,e=>this._onKeyDown(e)),i.addEventListener(`input`,e=>{let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-select-input, .wui-select-draft`))return;this._onQueryChange(t.value);let n=t.matches(`.wui-select-draft`),r=this._rows>0||this._actionRows().length>0;n&&r&&!this._menuOpen()&&!s(this)&&this._draftOpens()&&this._open({focus:!1})}),i.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||!this._activePartsList().some(e=>e.onBlur?.()===!0)&&t&&this._close()}),a?.addEventListener(`click`,()=>{let t=r(e.search,`The search input is missing.`);t.value=``,this._onQueryChange(``),t.focus()}),t.addEventListener(`pointerdown`,()=>{this._pressOpen=this._menuOpen()}),t.addEventListener(`click`,e=>{if(e.target instanceof Element&&e.target.closest(`[data-remove]`))return;if(this.mode===`tag`){if(s(this))return;this._refs().input?.focus(),!this._menuOpen()&&this._draftOpens()&&this._open({focus:!1});return}if(e.target instanceof HTMLInputElement){!this._menuOpen()&&!s(this)&&this._open({focus:!1});return}let t=e.detail>0&&this._pressOpen!==null?this._pressOpen:this._menuOpen();this._pressOpen=null,this._clearHover(),this._hoverOpened&&t?(this._hoverOpened=!1,this._open({focus:!0})):t?this._close():s(this)||this._open({focus:!0})}),o?.addEventListener(`click`,e=>{e.stopPropagation(),this.commit(H(this.mode)?[]:``),this._close(),t.focus()}),n.addEventListener(`click`,n=>{let r=Le(n).closest(`.wui-select-option`);if(r instanceof HTMLElement&&(this._pick(r),H(this.mode))){let n=this.querySelector(`.wui-select-draft`);(e.search??(n instanceof HTMLElement?n:t)).focus()}}),n.addEventListener(`mousedown`,e=>{H(this.mode)&&e.target instanceof Element&&e.target.closest(`.wui-select-option`)&&e.preventDefault()}),n.addEventListener(`mousemove`,e=>{let t=Le(e).closest(`.wui-select-option`);t instanceof HTMLElement&&!t.classList.contains(`is-active`)&&this._setActive(this._windowed?Number(t.dataset.index):this._visible().indexOf(t),{reveal:!1})}),n.addEventListener(`scroll`,()=>{this._windowed&&this._scrollFrame===null&&(this._scrollFrame=requestAnimationFrame(()=>this._onListScroll()))},{passive:!0}),n.addEventListener(`mouseleave`,()=>this._setActive(-1)),n.addEventListener(`error`,e=>{let t=e.target;t instanceof Element&&t.classList.contains(`avatar-img`)&&t.remove()},!0),this.hasAttribute(`open`)&&this._open({focus:!1})}_teardown(){this._nav?.clearTypeahead(),this._scrollFrame!==null&&cancelAnimationFrame(this._scrollFrame),this._scrollFrame=null}_dropMenu(){let e=Q(this,`.wui-select-menu`,HTMLElement);e&&h(e)}_activePartsList(){return this._partsMounted?r(this._parts,`The mounted parts are missing.`):[]}_ensureParts(){if(!this.isConnected)return;(this.hasAttribute(`source`)||this.hasAttribute(`remote`)||this.hasAttribute(`recents-key`)||this._loadOptionsFn!==null)&&this._loadWindow();let e=Fe(this,this.mode),t=e.join(`,`);if(t===this._partSig)return;this._teardownParts(),this._parts=null,this._partSig=t;let n=++this._partToken;Promise.all(e.map(e=>ze(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(e=>e!==null),this._mountParts())})}_loadWindow(){this._windowLoad===null&&(this._windowLoad=be().then(()=>this.renderList(),()=>{this._windowFailed=!0,document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:`select-window`}})),this.setError(X().partLoadMessage)}))}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=we(this._refs());for(let n of this._parts)n.mount(this,t,{carry:e});this._drawValue(),this.renderList()}_teardownParts(){let e=this._activePartsList();this._partsMounted=!1;for(let t of e)t.teardown()}_remountParts(){if(!this._partsMounted)return;let e=this._carry();this._teardownParts(),this._mountParts(e)}_carry(){let e=this._refs();return{draft:e.input?.value??``,query:e.search?.value??``}}},we=e=>{let{control:t,value:n,menu:i,list:a}=e;return{control:r(t,`control missing`),value:r(n,`value missing`),menu:r(i,`menu missing`),list:r(a,`list missing`),search:e.search,input:e.input}},Te=e=>re.includes(e),Ee=[`comfortable`,`compact`],De=150,Oe=250,ke=10,Ae=()=>{let e=X();return{single:e.placeholder,search:e.placeholder,multiple:e.placeholder,tag:e.tagPlaceholder,country:e.countryPlaceholder}},je=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),Me=/* @__PURE__ */ new Set([`separators`,`allow-duplicates`,`invalid-message`,`create-label`,`add-label`,`selected-text`,`clear-all-label`,`value-label`,`value-avatar`,`value-initials`,`hint-text`,`recents-key`,`recents-limit`,`recents-label`]),Ne=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],Z=(e,t)=>t?Array.isArray(e)?e.map(String):e==null||e===``?[]:String(e).split(`,`).map(e=>e.trim()).filter(Boolean):Array.isArray(e)?e.length?String(e[0]):``:e==null?``:String(e),Pe=(e,t)=>t===`multiple`?U(e)?[`chips`,`search`]:[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?U(e)?[`chips`,`search`]:[`chips`]:[],Fe=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...Pe(e,t)]:Pe(e,t),Ie=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,Le=e=>{if(e.target instanceof Element)return e.target;throw Error(`The event target is not an element.`)},Q=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Re=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),$=e=>{let t=e.textContent;if(t===null)throw Error(`The element has no text.`);return t},ze=(e,t)=>ae(t).then(e=>{if(!Ie(e))throw Error(`The part ${t} has no default export.`);return e.default()}).catch(()=>(document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:t}})),e.setError(X().partLoadMessage),null));export{U as n,A as r,Ce as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./dom-DMQu--xV.js";import{n as t,t as n}from"./fieldState-D-zQcXUS.js";import{t as r}from"./iconGlyphs.g-a9FtjPXh.js";import{n as i}from"./imeSafeEnter-DeO_3lXy.js";import{s as a}from"./nativeOverlay-BHD2QV02.js";import{n as o,r as s,t as c}from"./optionLabel-wbpl8OTJ.js";import{r as l,t as u}from"./textStore-DBplASiZ.js";import{r as d}from"./search.g-B5d1s59A.js";import{t as ee}from"./customRule-BpwcjVLb.js";import{r as f}from"./WuiSelect-
|
|
1
|
+
import{r as e}from"./dom-DMQu--xV.js";import{n as t,t as n}from"./fieldState-D-zQcXUS.js";import{t as r}from"./iconGlyphs.g-a9FtjPXh.js";import{n as i}from"./imeSafeEnter-DeO_3lXy.js";import{s as a}from"./nativeOverlay-BHD2QV02.js";import{n as o,r as s,t as c}from"./optionLabel-wbpl8OTJ.js";import{r as l,t as u}from"./textStore-DBplASiZ.js";import{r as d}from"./search.g-B5d1s59A.js";import{t as ee}from"./customRule-BpwcjVLb.js";import{r as f}from"./WuiSelect-B0CT2utp.js";var p={enter:`Enter`,comma:`,`,space:` `,tab:`Tab`},m={enter:`
|
|
2
2
|
`,comma:`,`,space:` `,tab:` `},te=e=>p[e],h=e=>m[e];function ne(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 re=(e,t)=>t.some(t=>String(e??``).includes(t)),g=()=>l(`select`,d),_=/* @__PURE__ */ new WeakMap;function v(e,t){if(e===null)throw TypeError(`The chip row needs ${t}, and it is not mounted.`);return e}function y(){let l,d,p=null,m=null,y=null,b=null,x=null,S=null,C=null,w=!1,T=()=>v(m,`the draft input`),E=()=>l.mode===`tag`,D=()=>Array.isArray(l.value)?l.value.slice():[],O=()=>(l.getAttribute(`separators`)||`enter,comma`).split(`,`).map(e=>e.trim()).filter(Boolean),ie=()=>new Set(O().map(te).filter(Boolean)),k=()=>{let e=parseInt(l.getAttribute(`max-tags`)??``,10)||0;return Math.max(e,0)},A=()=>{let e=k();return e>0&&D().length>=e},j=(e,t)=>!l.hasAttribute(`allow-duplicates`)&&e.some(e=>e.toLowerCase()===t.toLowerCase()),M=()=>{let e=_.get(l);return e||(e=/* @__PURE__ */ new Map,_.set(l,e)),e},N=e=>(l.options||[]).find(t=>String(t.value)===String(e))??M().get(String(e)),P=e=>{let t=M();for(let n of l.options||[])e.includes(String(n.value))&&t.set(String(n.value),n);for(let n of t.keys())e.includes(n)||t.delete(n)},F=e=>{let t=e.trim().toLowerCase();return(l.options||[]).find(e=>String(e.value??``).toLowerCase()===t||o(e).trim().toLowerCase()===t)},ae=e=>{for(let t of O()){let n=h(t)??t;if(re(e,[n]))return ne(e,[n])}return[e.trim()]},I=()=>m?m.value:l._query||``,oe=()=>E()||l.hasAttribute(`allow-custom`),se=()=>l.getAttribute(`placeholder`)||(E()?g().tagPlaceholder:g().placeholder),ce=()=>{let e=l.getAttribute(`aria-label`);if(e)return e;let t=l.closest(`label`)?.textContent?.trim();if(t)return t;let n=l.id;return(n?[...document.querySelectorAll(`label[for]`)].find(e=>e instanceof HTMLLabelElement&&e.htmlFor===n):void 0)?.textContent?.trim()||(E()?g().addTagsLabel:g().fallbackName)},L=()=>{m&&(m.setAttribute(`aria-expanded`,String(a(d.menu))),d.list.id&&m.setAttribute(`aria-controls`,d.list.id),m.setAttribute(`aria-label`,ce()))},le=()=>!t(l)&&!l.hasAttribute(`loading`),ue=e=>{w=!0,T().setAttribute(`aria-invalid`,`true`),l.setError(e)},R=()=>{w&&(w=!1,T().removeAttribute(`aria-invalid`),l.setError(null))},z=(e,{quiet:t=!1,strip:n=!1}={})=>{let r=D(),i=r.slice(),a=k(),o=[],s=``,c=!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=F(e);if(r){if(r.disabled){o.push(e),s||=r.disabledHint||l.getAttribute(`invalid-message`)||g().invalidMessage;continue}j(i,String(r.value))||i.push(String(r.value));continue}let u=ee(l,e);u?(o.push(e),s||=u):j(i,e)||(i.push(e),c=!0)}i.length!==r.length&&(c?l.commit(i,{isCustom:!0}):l.commit(i)),T().value=o.join(`, `),s?t||ue(s):R()},B=e=>{n(l)||z([T().value],e)},V=e=>l.commit(D().filter(t=>t!==e)),H=()=>e(`span`,{class:`wui-select-placeholder`},l.getAttribute(`placeholder`)||g().placeholder),de=t=>{let n=N(t),i=e(`span`,{class:`chip chip-sm`}),a=e(`span`,{class:`chip-label`});if(a.replaceChildren(...n?c(n):[t]),i.append(a),le()){let a=n?o(n):s(t),c=e(`button`,{class:`chip-remove`,type:`button`,"data-remove":t,"aria-label":u(g().removeText,{text:a})}),l=r(`x`);l&&c.replaceChildren(l),i.append(c)}return i};function U(){if(!p)return;p.querySelector(`:scope > .chip-more`)?.remove();let t=[...p.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[t.length-1];if(!l.hasAttribute(`collapse-chips`)||!n)return;let r=p.clientWidth,i=e=>e.offsetLeft+e.offsetWidth;if(i(n)<=r)return;let a=e(`span`,{class:`chip chip-sm chip-more`});a.textContent=`+${t.length}`,n.after(a);let o=a.offsetWidth+6,s=0;for(let e of t)if(i(e)<=r-o)s+=1;else break;s<1&&(s=1);for(let e of t.slice(s))e.style.display=`none`;a.textContent=`+${t.length-s}`}function W(){if(!p)return!1;p.parentNode!==d.value&&d.value.append(p);for(let e of p.querySelectorAll(`:scope > .chip, :scope > .wui-select-placeholder`))e.remove();let e=D();P(e);let t=p,r=e=>{m?t.insertBefore(e,m):t.append(e)};E()||m||e.length||r(H());for(let t of e)r(de(t));return m&&(m.placeholder=E()||!e.length?se():``,m.disabled=l.hasAttribute(`disabled`),m.readOnly=n(l),L()),E()||(v(b,`the footer text`).textContent=(()=>{let t=l.getAttribute(`selected-text`);return t?t.replace(`{n}`,()=>String(e.length)):u(g().selectedText,{count:e.length})})(),v(x,`the clear-all button`).textContent=l.getAttribute(`clear-all-label`)||g().clearAllLabel),U(),!0}function fe(e){if(e.key===`Backspace`){let t=m?!I():!I()&&a(d.menu),n=D(),r=n[n.length-1];return!t||r===void 0?!1:(e.preventDefault(),V(r),!0)}if(!m)return!1;let t=m.value;if(e.key===`Escape`){if(!E())return!1;let n=a(d.menu);return!n&&!t?!1:(e.preventDefault(),n&&e.stopPropagation(),m.value=``,R(),l.closeMenu({focusControl:!1}),!0)}let n=!E()&&!t.trim(),r=ie();return i(e)&&r.has(`Enter`)?n||d.list.querySelector(`.is-active`)?!1:(e.preventDefault(),B(),!0):e.key===`,`&&r.has(`,`)?!n&&(e.preventDefault(),B({strip:!0}),!0):e.key===` `&&r.has(` `)&&t.trim()||e.key===`Tab`&&r.has(`Tab`)&&!n?(e.preventDefault(),B(),!0):!1}function pe(e){let t=String(e.value);if(E()||m&&!N(t))return z([t]),!0;let n=D();return n.includes(t)?l.commit(n.filter(e=>e!==t)):m?z([t]):l.commit([...n,t]),m?.value&&(m.value=``,R()),!0}function G(e){if(!m)return null;let t=String(e??``).trim().replace(/,+$/,``).trim();if(!t||A()||F(t)||j(D(),t))return null;let n=l.getAttribute(`create-label`)||g().createLabel;return{position:E()?`top`:`bottom`,label:n.replace(`{text}`,()=>t),value:t}}function K(e){let t=e.target,r=t instanceof Element?t.closest(`[data-remove]`):null;if(r instanceof HTMLElement){if(n(l))return;e.stopPropagation(),V(r.dataset.remove??``),m?.focus()}else m&&!n(l)&&m.focus()}function q(){R();let e=T().value.trim();E()||!e||a(d.menu)||(G(e)||f(l.options||[],e).length)&&l.openMenu()}function J(e){e.preventDefault(),n(l)||z(ae(e.clipboardData?.getData(`text/plain`)??``))}function Y(){T().value.trim()&&B({quiet:!0,strip:!0}),l.closeMenu({focusControl:!1})}function X(e){e.relatedTarget instanceof Node&&l.contains(e.relatedTarget)||Y()}function me(){return m?(Y(),!0):!1}function Z(){T().value.trim()&&B({strip:!0})}function Q(){n(l)||l.commit([])}function $(e){e.target!==m&&e.preventDefault()}function he(t,n,r={}){l=t,d=n,p=e(`div`,{class:`wui-select-chips`}),p.addEventListener(`click`,K),d.value.append(p),oe()&&(m=e(`input`,{class:`wui-select-draft`,type:`text`,autocomplete:`off`,role:`combobox`,"aria-autocomplete":`list`}),l.hasAttribute(`required`)&&m.setAttribute(`aria-required`,`true`),d.menu.addEventListener(`toggle`,L),p.append(m),m.value=r.carry?.draft??``,d.input=m,m.addEventListener(`input`,q),m.addEventListener(`paste`,J),m.addEventListener(`blur`,X),p.addEventListener(`mousedown`,$),S=l.closest(`form`),S?.addEventListener(`submit`,Z,!0)),E()||(y=e(`div`,{class:`wui-select-footer`}),b=document.createElement(`span`),x=e(`button`,{class:`wui-select-clear-all`,type:`button`}),x.addEventListener(`click`,Q),y.append(b,x),d.menu.append(y)),typeof ResizeObserver<`u`&&(C=new ResizeObserver(U),C.observe(p)),W()}function ge(){p?.removeEventListener(`click`,K),p?.removeEventListener(`mousedown`,$),m&&(m.removeEventListener(`input`,q),m.removeEventListener(`paste`,J),m.removeEventListener(`blur`,X),d.input=null),x&&x.removeEventListener(`click`,Q),S?.removeEventListener(`submit`,Z,!0),S=null,C?.disconnect(),C=null,d.menu.removeEventListener(`toggle`,L),y?.remove(),p?.remove(),p=null,m=null,y=null,w=!1}return{mount:he,onKey:fe,onPick:pe,renderValue:W,actionRow:G,onQuery:()=>!1,onBlur:me,teardown:ge}}export{y as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{i as n,n as r,r as i,t as a}from"./dom-DMQu--xV.js";import{t as o}from"./loader-X2uBXCDm.js";import{r as s}from"./textStore-DBplASiZ.js";import{t as c}from"./drawer.g-B-zYKBfQ.js";import{i as l,n as u,r as d,t as f}from"./toast.g-CJ8c0BNZ.js";import{N as p}from"./dataTable-C0q14bkP.js";import{n as ee,t as m}from"./devWarn-DXdRWZs3.js";import{t as te}from"./httpFailure.g-DjZzGxPj.js";import{_ as h,a as ne,b as re,c as ie,d as ae,f as oe,i as se,l as ce,o as le,r as ue,s as de,t as fe,u as pe,x as g,y as me}from"./refreshAfter-DhYgWXmQ.js";import{t as he}from"./hasOwn-CJsplJ62.js";import{t as ge}from"./svgNodes-CyPS2oFH.js";import{t as _e}from"./serverHtml-BC6tAyAl.js";import{a as ve,d as ye,f as be,h as xe,l as Se,m as _,o as Ce,p as we,s as Te,u as Ee}from"./wuiHttp-8CYWEbRz.js";var v=class extends Error{code;status;html;body;kind;constructor(e,t){super(e,t.cause===void 0?void 0:{cause:t.cause}),this.name=`WuiPostError`,this.code=t.code,this.status=t.status,this.html=t.html,this.body=t.body,this.kind=t.kind}},De=/* @__PURE__ */ new Set(/* @__PURE__ */ `bad request.unauthorized.payment required.forbidden.not found.method not allowed.not acceptable.proxy authentication required.request timeout.conflict.gone.length required.precondition failed.payload too large.uri too long.unsupported media type.range not satisfiable.expectation failed.misdirected request.unprocessable content.unprocessable entity.locked.failed dependency.too early.upgrade required.precondition required.too many requests.request header fields too large.unavailable for legal reasons`.split(`.`)),Oe=e=>typeof e!=`object`||!e?{message:void 0,detail:void 0,title:void 0}:{message:`message`in e?e.message:void 0,detail:`detail`in e?e.detail:void 0,title:`title`in e?e.title:void 0};async function ke(e){return e.html===``?e.response===null?``:e.response.text():e.html}function Ae(e,t){let n=e=>typeof e==`string`?e.trim():``,r=Oe(e),i=n(r.message);if(i)return i;let a=n(r.detail);if(a)return a;let o=n(r.title);if(!o)return null;let s=o.toLowerCase();return De.has(s)||s===t.trim().toLowerCase()?null:o}var je=`wui-remote-modal`,Me=`wui-remote-drawer`,Ne=Object.freeze({sm:360,md:480,lg:640,xl:720}),Pe=`wui-modal-fullscreen`,Fe=`wui-modal-wide`,y=Object.freeze({sm:380,md:440,lg:640,xl:880,wide:1080}),b=()=>s(`modal`,u),Ie=e=>we(e?.getAttribute(`data-wui-timeout`)??null)??3e4,Le=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,Re=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,ze=`[aria-invalid="true"], .is-invalid, .input-validation-error`,Be=`invalid`,Ve=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,He=`[data-wui-modal-content]`,Ue=`[data-wui-pane-close], [data-wui-dismiss]`,We=()=>i(`button`,{type:`button`,class:`wui-modal-close`,"data-wui-dismiss":!0,"aria-label":b().closeLabel},ge({width:18,height:18,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},[[`path`,{d:`M18 6 6 18M6 6l12 12`}]])),x=/* @__PURE__ */ new WeakMap,Ge=/* @__PURE__ */ new WeakSet;function S(e,t){if(e==null)throw TypeError(`The remote modal needs ${t}, and the page does not have it.`);return e}var C=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},w=(e,t,n)=>S(C(e,t),n),Ke=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),T=()=>Object.assign(/* @__PURE__ */ Error(`The remote modal load was aborted.`),{name:`AbortError`}),qe=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,E=(e,t)=>{let n=e instanceof Element?e.closest(t):null;return n instanceof HTMLElement?n:null},Je=e=>he(y,e),Ye=e=>he(Ne,e);function Xe(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(Je(e))return e===`wide`?{px:y.wide,wide:!0}:{px:y[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported modal size "${String(e)}". Use sm, md, lg, xl, wide, fullscreen or a px number.`)}var Ze=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};if(e.classList.contains(`wui-modal-wide`))return{px:y.wide,wide:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:y.md}},D=(e,t)=>{e.classList.toggle(Pe,!!t.fullscreen),e.classList.toggle(Fe,!t.fullscreen&&!!t.wide),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},Qe=[`center`,`top`];function $e(e){if(e==null||e===``)return null;if(Ye(e))return{px:Ne[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported drawer size "${String(e)}". Use sm, md, lg, xl or a px number.`)}var et=e=>e.container===`drawer`,O=e=>e.container===`pane`,tt=e=>e.container!==`modal`,nt=(e,t)=>et(e)?$e(t):Xe(t),rt=e=>{let t=typeof e==`string`?document.querySelector(e):e,n=t instanceof HTMLElement?t:null;return n?.matches(`[data-wui-pane-host]`)?n:null},it=e=>O(e)?e.shell:w(e.shell,`.modal-dialog`,`a dialog frame`);function at(e=`modal`){let t=e===`drawer`,n=t?Me:je,r=document.getElementById(n);if(r)return r;let a=document.createElement(`wui-modal`);a.id=n,a.setAttribute(`data-wui`,`AppModal`);let o=document.createElement(`dialog`);return o.className=t?`modal wui-modal-shell wui-remote-drawer`:`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${t?Ne.md:y.md}px`),o.replaceChildren(i(`div`,{class:t?`modal-dialog wui-remote-drawer-dialog`:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal`}))),a.append(o),document.body.appendChild(a),a}var ot=e=>i(`div`,{class:`wui-modal-header`},i(`div`,{class:`wui-modal-heading`},i(`div`,{class:`wui-modal-headtext`},i(`div`,{class:`wui-modal-title`},e))),We()),st=e=>i(`div`,{class:`modal-content wui-modal`,"aria-busy":`true`},ot(e),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-loading`,role:`status`},i(`span`,{class:`visually-hidden`},b().loadingLabel),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton wui-modal-skeleton--short`})))),ct=(n,r)=>{let a={forbidden:b().forbiddenMessage,networkCheck:s(`httpFailure`,te).networkCheckText,client:b().clientMessage,server:b().serverMessage,network:b().networkMessage,timeout:b().timeoutMessage};return i(`div`,{class:`modal-content wui-modal`,"data-wui-modal-error":r},ot(n),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-state`,role:`alert`},i(`p`,{class:`wui-modal-state-title`},b().errorTitle),i(`p`,{class:`wui-modal-state-text`},a[r]||b().serverMessage),i(`div`,{class:`wui-modal-state-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":!0,"data-wui":t},b().closeLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-wui-modal-retry":!0,"data-wui":t},b().retryLabel)))))},k=e=>C(e.shell,`.modal-content`),lt=e=>r(e.cloneNode(!0),HTMLElement,`a card copy is not an element`);function ut(e){e&&e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}))}function A(e,t){let n=k(e),r=n?ft(n):/* @__PURE__ */ new Map;ut(n),n?n.replaceWith(t):it(e).appendChild(t),pt(t,r),h().refresh()}var dt=`input[type="file"][name]`;function ft(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(dt)){if(!(n instanceof HTMLInputElement))continue;let e=n.files;e&&e.length>0&&t.set(n.name,[...e])}return t}function pt(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(dt)){if(!(n instanceof HTMLInputElement))continue;let e=t.get(n.name);if(!e)continue;let r=new DataTransfer;for(let t of e)r.items.add(t);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}var mt=e=>O(e)?!e.shell.hidden:e.host.hasAttribute(`open`);function ht(e,t,n=!1){let r=t?C(e,ze):null,i=r?r.matches(Le)?r:C(r,Le)||r:null;if(!i&&n)i=C(e,`[data-autofocus]`)||C(e,Re)||C(e,`.wui-modal-close`);else if(!i){let t=Ke(e,Le);i=C(e,`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}r?i?.focus?.():i?.focus?.({preventScroll:!0})}function gt(e,t){let n=C(e.shell,`[data-wui-modal-live]`);n||(n=document.createElement(`div`),n.className=`visually-hidden`,n.setAttribute(`aria-live`,`assertive`),n.setAttribute(`data-wui-modal-live`,``),it(e).appendChild(n)),n.textContent=``,n.textContent=t}var _t=e=>{let t=C(e.shell,`[data-wui-modal-live]`);t&&(t.textContent=``)},vt=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};function j(e,t,n,r){let i={...r,container:e.container};vt(t,`wui:modal:${n}`,i),et(e)&&vt(t,`wui:drawer:${n}`,i),O(e)&&vt(t,`wui:pane:${n}`,i)}var yt=e=>e.matches(`[data-wui-pane-host]`)?`pane`:w(e,`dialog`,`a dialog`).classList.contains(`wui-remote-drawer`)?`drawer`:`modal`,bt=e=>S(e.host.closest(`wui-modal`),`a wui-modal host`);function xt(e){let t=x.get(e);if(t)return t;let n=yt(e),r=n===`pane`?e:w(e,`dialog`,`a dialog`),a=k({shell:r}),o={host:e,shell:r,container:n,queue:Se(),defaultSize:Ze(r),defaultLabel:r.getAttribute(`aria-label`),placeholder:a?lt(a):i(`div`,{class:`modal-content wui-modal`}),remoteUrl:e.getAttribute(`data-wui-remote-url`),cache:e.getAttribute(`data-wui-remote-cache`)===`true`,loadedUrl:null,session:null};return x.set(e,o),e.addEventListener(`submit`,e=>Ht(o,e)),e.addEventListener(`click`,e=>{E(e.target,`[data-wui-modal-retry]`)&&o.session&&(e.preventDefault(),N(o,o.session))}),O(o)&&e.addEventListener(`click`,t=>{let n=E(t.target,Ue);n&&e.contains(n)&&o.session&&M(o,o.session,`dismissed`,null)}),e.addEventListener(`wui-modal-close`,t=>{t.target===e&&t instanceof CustomEvent&&Rt(t.detail,`reason`)===`escape`&&e.querySelector(`form[data-wui-submitting]`)&&t.preventDefault()}),e.addEventListener(`wui-modal-closed`,t=>{t.target===e&&Dt(o)}),e.addEventListener(`wui-modal-opened`,t=>{if(t.target!==e)return;let n=k(o);o.session&&n?.matches(He)&&!n.contains(document.activeElement)&&ht(n,!1,tt(o))}),o.remoteUrl&&e.addEventListener(`wui-modal-open`,t=>{t.target===e&&Ot(o,t)}),o}function St(e,t,n){let r=null;e.session&&(r=e.session.pendingRefresh,e.session.pendingRefresh=null,e.queue.abort(),e.session.resolveClosed({status:`dismissed`,detail:{replaced:!0}}));let i=()=>void 0,a=new Promise(e=>{i=e}),o={url:t,method:(n.method||`GET`).toUpperCase(),body:n.body,options:n,trigger:n.trigger||null,explicitSize:null,closing:null,resolveClosed:i,handle:{el:e.shell,closed:a,close:()=>M(e,o,`dismissed`,null),reload:()=>N(e,o)},pendingRefresh:r};return e.session=o,o}function M(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},O(e)?wt(e,t):Ct(e))}function Ct(e){let t=bt(e);t.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:`dismiss`}}))&&t.hide()}function wt(e,t){let n=e.shell,{status:r,detail:i}=S(t.closing,`the closing state`),a=n.contains(document.activeElement);e.queue.abort(),e.session=null,ut(k(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),j(e,n,`closed`,{status:r,url:t.url}),Tt(t),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function Tt(e){let t=e.pendingRefresh;e.pendingRefresh=null,t&&fe(t).catch(m)}function Et(e,t){for(let n=e;n!==null;n=n.parentElement){let e=n instanceof HTMLElement?x.get(n):void 0;if(e?.session){let n=de(t);return e.session.pendingRefresh=ne(e.session.pendingRefresh,{...t,message:n?t.message:null,action:n?t.action:null}),!0}}return!1}oe(Et);function Dt(e){let t=e.session;if(e.queue.abort(),e.session=null,_t(e),t){let n=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n.status,detail:n.detail}),j(e,e.shell,`closed`,{status:n.status,url:t.url}),Tt(t);let r=document.activeElement;t.trigger?.isConnected&&(!r||r===document.body||e.shell.contains(r))&&t.trigger.focus?.()}e.cache||(A(e,lt(e.placeholder)),e.loadedUrl=null,D(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function Ot(e,t){let n=Rt(t instanceof CustomEvent?t.detail:null,`trigger`),r=n instanceof HTMLElement?n:null,i=r?.getAttribute(`data-wui-url`)||e.remoteUrl||``,a=St(e,i,{trigger:r});a.explicitSize=kt(e,r?.getAttribute(`data-wui-size`)),a.explicitSize&&D(e.shell,a.explicitSize),e.cache&&e.loadedUrl===i||(e.loadedUrl&&A(e,lt(e.placeholder)),N(e,a,{keepPlaceholder:!0}))}function kt(e,t){try{return nt(e,t)}catch(e){return m(e),null}}async function N(e,t,{keepPlaceholder:n=!1}={}){n||A(e,st(t.options.title||At(e)));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate,timeoutMs:Ie(t.trigger)});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if(r.kind===`ok`&&Pt(e,t,r.html,!1))return e.loadedUrl=t.url,j(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return A(e,ct(t.options.title||At(e),i)),mt(e)&&ht(S(k(e),`a card`),!1,tt(e)),j(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var At=e=>k(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,jt=`/_content/Webority.Ui.Razor/js/`,Mt=e=>new URL(e,window.location.href).pathname.includes(jt);function Nt(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function Pt(e,t,n,r){let i=_e(n),a=!1;for(let e of i.querySelectorAll(`script`)){if(e.getAttribute(`type`)===`application/json`)continue;let t=e.getAttribute(`src`);e.remove(),t&&Mt(t)?Nt(t):a=!0}a&&ee(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let o=C(i,He);if(!o)return m(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(A(e,o),r||_t(e),!O(e)){D(e.shell,t.explicitSize||kt(e,o.getAttribute(`data-wui-size`))||e.defaultSize);let n=o.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return mt(e)&&ht(o,r,tt(e)),!0}var Ft=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function It(e,t,n){let r=[...e.elements].filter(e=>e.matches(Ft));if(n){e.setAttribute(`data-wui-submitting`,``);let n=t&&r.includes(t)?t:r[0];for(let e of r)e.toggleAttribute(`data-wui-was-disabled`,e.disabled),e.disabled=!0;n&&(n.classList.add(`is-loading`),n.setAttribute(`aria-busy`,`true`),n.tagName===`BUTTON`&&n.prepend(i(`span`,{class:`spinner-border spinner-border-sm me-2`,"aria-hidden":`true`,"data-wui-submit-spinner":!0})))}else{e.removeAttribute(`data-wui-submitting`);for(let e of r)e.disabled=e.hasAttribute(`data-wui-was-disabled`),e.removeAttribute(`data-wui-was-disabled`),e.classList.remove(`is-loading`),e.removeAttribute(`aria-busy`),e.querySelector(`[data-wui-submit-spinner]`)?.remove()}}function Lt(e){for(let t of e.querySelectorAll(Ve))t.remove();for(let t of e.querySelectorAll(ze))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var Rt=(e,t)=>{if(typeof e==`object`&&e&&t in e)return Reflect.get(e,t)};async function zt(e){if(e.status<400||e.status>499||!e.response?.headers.get(`content-type`)?.toLowerCase().includes(`json`))return null;let t;try{t=JSON.parse(await ke(e))}catch{return null}return Ae(t,e.response.statusText)}function Bt(e,t,n,r){let i={forbidden:b().forbiddenMessage,networkCheck:s(`httpFailure`,te).networkCheckText,client:b().clientMessage,server:b().serverMessage,network:b().networkMessage,timeout:b().timeoutMessage},a=t.closest(`.wui-modal-body`)||t;a.querySelector(`[data-wui-modal-submit-error]`)?.remove(),Lt(a);let o=document.createElement(`div`);o.className=`alert alert-danger wui-modal-submit-error`,o.setAttribute(`role`,`alert`),o.setAttribute(`data-wui-modal-submit-error`,``),o.textContent=`${b().submitFailedMessage} ${r||i[n]||b().serverMessage}`,a.prepend(o),gt(e,o.textContent)}var Vt=(e,t)=>{let n=new URL(e,window.location.href);for(let[e,r]of t)typeof r==`string`&&n.searchParams.append(e,r);return n.origin===window.location.origin?n.pathname+n.search:n.href};async function Ht(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(He)||(t.preventDefault(),n.hasAttribute(`data-wui-submitting`)))return;let i=`submitter`in t&&(t.submitter instanceof HTMLButtonElement||t.submitter instanceof HTMLInputElement)?t.submitter:null,a=i?.getAttribute(`formaction`)||n.getAttribute(`action`)||r.url,o=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),s=new FormData(n);i?.name&&!s.has(i.name)&&s.append(i.name,i.value);let c=o===`GET`;It(n,i,!0);let l;try{l=await e.queue.run(c?Vt(a,s):a,{method:o,body:c?void 0:s,navigate:r.options.navigate,timeoutMs:Ie(r.trigger)})}catch(t){m(t),e.session===r&&n.isConnected&&(It(n,i,!1),Bt(e,n,`server`,null));return}if(e.session!==r)return;if(n.isConnected&&It(n,i,!1),l.kind===`ok`&&l.result===`success`){Ut(e,r,l);return}if(l.kind===`aborted`||l.kind===`stale`||l.kind===`session`)return;if(l.kind===`ok`&&l.html){let t=l.result===Be;if(Pt(e,r,l.html,t)){if(t){let t=S(k(e),`a card`).querySelector(Ve)?.textContent?.replace(/\s+/g,` `).trim();gt(e,t||b().invalidMessage)}return}}let u=l.kind===`ok`||l.kind===`validation`?`server`:l.kind,d=await zt(l);e.session===r&&Bt(e,n,u,d)}function Ut(e,t,n){let r=n.message,i=n.redirect||null,a=n.toastVariant||`success`;if(!re(a))throw TypeError(`Unknown toast variant "${a}". Use ${me.join(`, `)}.`);let o={url:t.url,trigger:t.trigger,handle:t.handle,message:r,redirect:i,data:n.data??null,container:e.container},s=i||se(t.trigger)?null:le(n),c=!(n.next&&!i)&&!n.keepOpen,l=s!==null&&c&&de(s);i&&!t.options.navigate?g(r,a):r&&!l&&h().toast(r,{variant:a}),j(e,t.trigger?.isConnected?t.trigger:document,`success`,o),t.options.onSuccess?.(o,t.handle),i&&(t.options.navigate||(e=>window.location.assign(e)))(i),s&&(t.pendingRefresh=ne(t.pendingRefresh,{...s,action:null,message:l?s.message:null}));let u=n.next;u&&!i?(t.url=u,t.method=`GET`,t.body=void 0,N(e,t)):n.keepOpen?n.html&&n.data===null&&Pt(e,t,n.html,!1):M(e,t,`success`,o)}function Wt(e){let t=E(e.target,`[data-wui-modal], [data-wui-drawer], [data-wui-pane]`);t&&(t.matches(`a[href]`)&&(e.ctrlKey||e.metaKey||e.shiftKey||e.button!==0)||(e.preventDefault(),t.hasAttribute(`data-wui-pane`)?Zt(t.getAttribute(`data-wui-pane`)??``,{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{qe(e)||m(e)}):t.hasAttribute(`data-wui-modal`)?qt(t.getAttribute(`data-wui-modal`)??``,{size:t.getAttribute(`data-wui-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{qe(e)||m(e)}):Yt(t.getAttribute(`data-wui-drawer`)??``,{size:t.getAttribute(`data-wui-drawer-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{qe(e)||m(e)})))}function Gt(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=E(e.target,Xt);if(!t)return;let n=x.get(t),r=e.currentTarget;n?.session&&r instanceof Document&&!r.querySelector(`wui-modal[open]`)&&(t.querySelector(`form[data-wui-submitting]`)||(e.preventDefault(),M(n,n.session,`dismissed`,null)))}function Kt(e=document){let t=e instanceof Document?e:S(e.ownerDocument,`an owner document`);Ge.has(t)||(Ge.add(t),t.addEventListener(`click`,Wt),t.addEventListener(`keydown`,Gt));let n=Ke(e,`wui-modal[data-wui-remote-url]`);e instanceof HTMLElement&&e.matches(`wui-modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)xt(e)}function qt(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=t.container===`drawer`,r=n?$e(t.size):Xe(t.size),i=t.placement||`center`;if(!Qe.includes(i))throw TypeError(`WUI.modal.load: unsupported placement "${i}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(T());let a=at(n?`drawer`:`modal`);Kt(document);let o=xt(a),s=mt(o),c=St(o,e,t);c.explicitSize=r,D(o.shell,r||o.defaultSize),n||w(o.shell,`.modal-dialog`,`a dialog frame`).classList.toggle(`modal-dialog-centered`,i===`center`),t.title&&o.shell.setAttribute(`aria-label`,t.title),s||(a.toggleAttribute(`static`,t.staticBackdrop!==!1),a.toggleAttribute(`no-escape`,t.closeOnEscape===!1));let l=s?Promise.resolve():new Promise(e=>a.addEventListener(`wui-modal-opened`,()=>e(),{once:!0})),u=N(o,c);return s||bt(o).show(),Jt(o,c,t,l,u,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function Jt(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),M(e,t,`dismissed`,{aborted:!0})),i(T())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw T();if(e===`session`)throw Error(`${a}(${t.url}): the session expired; the browser is signing in again.`);return t.handle});return Promise.race([s,o])}function Yt(e,t={}){return qt(e,{...t,container:`drawer`,placement:void 0})}var Xt=`[data-wui-pane-host]`;function Zt(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=rt(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(T());Kt(document);let r=xt(n),i=St(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=N(r,i);return Jt(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function Qt(e){let t=rt(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=x.get(t);n?.session&&M(n,n.session,`dismissed`,null)}var $t=8e3,en=()=>s(`toast`,f);function tn(e){if(!re(e))throw RangeError(`Unknown toast variant "${e}".`);return e}function P(e,t=`success`){e?.message&&nn(e.message,t,e.toastAction)}function nn(e,t,n=null){n?h().toast(e,{variant:tn(t),duration:$t,action:{label:n.label,onClick:e=>void rn(n,e)}}):h().toast(e,{variant:tn(t)})}async function rn(e,t=null){let n=await _(e.url,{method:e.method});n.kind!==`session`&&n.kind!==`aborted`&&(n.ok?(ae(n)||P(n,n.toastVariant||`success`),await ie(n,{origin:t})):h().toast(n.message||en().failedText,{variant:`danger`}))}var an=/* @__PURE__ */ new Set([204,205,304]),on=e=>{let t=new Headers;for(let n of e.split(/\r?\n/)){let e=n.indexOf(`:`);e>0&&t.append(n.slice(0,e).trim(),n.slice(e+1).trim())}return t};async function sn(e,t,n={}){if(!(t instanceof FormData))throw TypeError(`wuiUpload: body must be FormData`);let r=n.timeoutMs;if(r!==void 0&&!(Number.isFinite(r)&&r>0))throw TypeError(`wuiUpload: timeoutMs must be a positive number`);let i={Accept:`text/html`,"X-Requested-With":`XMLHttpRequest`,[Ce]:`1`,...n.headers};if(Ee(e)){let e=ye();e&&(i[e.header]=e.token)}let a=n.signal,o=n.navigate||(e=>window.location.assign(e));return a?.aborted?be(`aborted`):new Promise(s=>{let c=new XMLHttpRequest,l=!1,u,d=()=>c.abort(),f=(e,t=null,n=``)=>{u!==void 0&&clearTimeout(u),a?.removeEventListener(`abort`,d),s(be(e,t,n))};c.upload.onprogress=e=>{n.onProgress?.(e.loaded,e.lengthComputable?e.total:0)},c.onload=()=>{let t=c.status;if(t===0){f(`network`);return}let n=on(c.getAllResponseHeaders()),r=Te(t,n),i=c.responseURL!==``&&c.responseURL!==new URL(e,window.location.href).href;r===`ok`&&i&&n.get(ve.fragment)!==`1`&&(r=`session`);let a=c.responseText,s=r===`ok`||r===`validation`?a:``;if(t<200||t>599){f(r,null,s);return}let l=new Response(an.has(t)?null:a,{status:t,headers:n});r===`session`?(o(t===401?n.get(`Location`)||window.location.href:c.responseURL),f(`session`,l)):f(r,l,s)},c.onerror=()=>f(`network`),c.onabort=()=>{f(a?.aborted?`aborted`:l?`timeout`:`aborted`)},r!==void 0&&(u=setTimeout(()=>{l=!0,c.abort()},r)),a?.addEventListener(`abort`,d,{once:!0}),c.open(`POST`,e,!0);for(let[e,t]of Object.entries(i))c.setRequestHeader(e,t);c.send(t)})}var F=`wuiConfirm`,cn=Object.freeze([`danger`]),ln=Object.freeze([`warning`,`info`,`delete`]),I=()=>s(`confirmDialog`,d),un=/* @__PURE__ */ new WeakSet,dn=/* @__PURE__ */ new WeakSet,L=null,R=null,z=!1,B=(e,t)=>{e&&h().toast(e,{variant:t})};function fn(){let r=document.getElementById(F);if(r)return n(r.closest(`wui-modal`),`#${F} must be a wui-modal.`);let a=document.createElement(`wui-modal`);a.id=F;let o=document.createElement(`dialog`);return o.className=`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${y.md}px`),o.replaceChildren(i(`div`,{class:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal wui-confirm`},i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-confirm-content`},i(`span`,{class:`wui-confirm-icon`},i(`wui-status-icon`,{tone:`info`,size:120})),i(`h3`,{class:`wui-confirm-title`,tabindex:-1,"data-autofocus":``}),i(`p`,{class:`wui-confirm-msg`}))),i(`div`,{class:`wui-modal-footer`},i(`div`,{class:`wui-confirm-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":``,"data-wui":t},I().cancelLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-app-confirm":``,"data-wui":t})))))),a.append(o),document.body.appendChild(a),a}function pn(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!cn.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);mn({title:e.getAttribute(`data-wui-confirm-title`),message:e.getAttribute(`data-wui-confirm`),label:e.getAttribute(`data-wui-confirm-label`),danger:n===`danger`,cancel:void 0,icon:void 0},t)}function mn({title:e,message:t,label:r,danger:i,cancel:a,icon:o},s){let c=fn(),l=c.querySelector(`.wui-confirm-title`),u=c.querySelector(`[data-app-confirm]`);if(!l||!u)throw Error(`#${F} is not a confirm dialog with a confirm button. Render <app-confirm-dialog id="${F}"> without confirm-href, or leave the dialog to the library.`);let d=c.querySelector(`.wui-confirm-msg`);d||(d=document.createElement(`p`),d.className=`wui-confirm-msg`,l.after(d));let f=e||I().confirmTitle;l.textContent=f,d.textContent=t,u.textContent=r||I().confirmLabel,u.classList.toggle(`btn-danger`,i),u.classList.toggle(`btn-primary`,!i),c.querySelector(`wui-status-icon`)?.setAttribute(`tone`,o??(i?`delete`:`info`));let p=c.querySelector(`[data-wui-dismiss]`);p&&(p.textContent=a||I().cancelLabel),n(c.querySelector(`dialog`),`#${F} has no <dialog>.`).setAttribute(`aria-label`,f),R=s,z=!1,c.show()}var V=(e,t)=>{L=e;try{t()}finally{L=null}},H=(e,t)=>{let n=Reflect.get(e,t);if(n===void 0||typeof n==`string`)return n;throw TypeError(`confirmAction: ${t} must be text.`)},hn=e=>{if(typeof e!=`object`||!e)throw TypeError(`confirmAction: options must be an object with a message.`);let t=`message`in e?e.message:void 0;if(typeof t!=`string`)throw TypeError(`confirmAction: message must be text.`);return{title:H(e,`title`),message:t,label:H(e,`label`),tone:H(e,`tone`),cancel:H(e,`cancel`),icon:H(e,`icon`)}};function gn(e,t,n){let{title:r,message:i,label:a,tone:o,cancel:s,icon:c}=hn(t);if(o!=null&&!cn.includes(o))throw TypeError(`confirmAction: tone "${o}" is not supported. Use danger, or leave it off.`);if(c!=null&&!ln.includes(c))throw TypeError(`confirmAction: icon "${c}" is not supported. Use warning, info or delete, or leave it off.`);Rn(e.ownerDocument),mn({title:r,message:i,label:a,danger:o===`danger`,cancel:s,icon:c},()=>V(e,n))}var _n=e=>`disabled`in e&&e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`,vn=e=>{r(e,HTMLElement,`data-wui-confirm needs an HTML element to click.`).click()};function yn(e){let t=a(e.target,`[data-wui-confirm]:not(form)`);t&&t!==L&&!_n(t)&&(e.preventDefault(),e.stopImmediatePropagation(),pn(t,()=>V(t,()=>vn(t))))}function bn(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===L||e.submitter&&e.submitter===L||t.querySelector(`input[data-app-repeater-hidden]`))return;e.preventDefault(),e.stopImmediatePropagation();let n=e.submitter instanceof HTMLButtonElement||e.submitter instanceof HTMLInputElement?e.submitter:null,r=n?.form===t?n:void 0;pn(t,()=>V(t,()=>t.requestSubmit(r)))}function xn(e){let t=a(e.target,`#${F} [data-app-confirm]`);t&&!t.hasAttribute(`disabled`)&&R&&(z=!0,n(t.closest(`wui-modal`),`#${F} is missing around its confirm button.`).hide())}function Sn(e){if(!(e.target instanceof Element)||e.target.id!==`wuiConfirm`)return;let t=z?R:null;R=null,z=!1,t?.()}var U=e=>e===`forbidden`?I().forbiddenMessage:e===`networkCheck`?s(`httpFailure`,te).networkCheckText:e===`network`?I().networkMessage:e===`timeout`?I().timeoutMessage:I().failedMessage,Cn=(e,t)=>{`disabled`in e&&(e.disabled=t)},wn=e=>{Cn(e,!1),e.removeAttribute(`aria-busy`)};async function Tn(e){let t=e.getAttribute(`data-wui-post`);if(!t)throw Error(`A data-wui-post button needs the URL the action posts to.`);return En(t,e)}async function En(e,t,n){Cn(t,!0),t.setAttribute(`aria-busy`,`true`);let r=we(t.getAttribute(`data-wui-timeout`))??3e4,i=await _(e,{method:`POST`,body:n,timeoutMs:r});if(i.kind===`session`||i.kind===`aborted`)return;let a=i.toastVariant||`success`;if(i.ok&&i.redirect)g(i.message,a,i.toastAction),window.location.assign(i.redirect);else if(i.ok){let e=se(t);if(!e&&ae(i)){await ie(i,{origin:t})===`held`&&wn(t);return}wn(t),P(i,a),e||await ie(i,{origin:t})}else wn(t),B(i.message||U(i.kind),`danger`)}var Dn=e=>typeof e!=`object`||!e||!(`code`in e)?null:typeof e.code==`string`?e.code:null,On=e=>(e.response?.headers.get(`Content-Type`)??``).toLowerCase().includes(`json`)?e.data:e.html===``?null:e.html;async function kn(e,t={}){if(t.body!==void 0&&t.json!==void 0)throw TypeError(`postAction takes a body or a json value, not both.`);let n=t.method??`POST`;if(!xe.includes(n))throw TypeError(`postAction method must be POST, PUT, PATCH or DELETE.`);let r=t.timeoutMs??3e4;if(!Number.isInteger(r)||r<0)throw TypeError(`postAction timeoutMs must be a whole number of milliseconds, 0 for no limit.`);if(t.onUploadProgress!==void 0){if(!(t.body instanceof FormData))throw TypeError(`postAction onUploadProgress needs a FormData body.`);if(n!==`POST`)throw TypeError(`postAction onUploadProgress needs the POST method.`)}let i={},a;t.json===void 0?t.body instanceof FormData||t.body instanceof URLSearchParams?a=t.body:t.body!==void 0&&(a=new URLSearchParams(t.body)):(i[`Content-Type`]=`application/json`,a=JSON.stringify(t.json));let o;try{o=t.onUploadProgress!==void 0&&t.body instanceof FormData?await sn(e,t.body,{onProgress:t.onUploadProgress,headers:i,timeoutMs:r===0?void 0:r}):await _(e,{method:n,body:a,headers:i,timeoutMs:r})}catch(e){throw m(e),e}if(o.kind===`session`||o.kind===`aborted`)throw new v(U(o.kind),{code:null,status:o.status,html:null,body:null,kind:o.kind});let s=t.toast!==!1,c=t.refresh!==!1,l=o.toastVariant||`success`;if(o.ok){if(o.redirect)g(s?o.message:null,l,s?o.toastAction:null),window.location.assign(o.redirect);else{let e=le(o);s&&!(c&&ae(o))&&P(o,l),e!==null&&c&&await fe({...e,message:s?e.message:null,action:s?e.action:null})}return On(o)}let u;try{u=await ke(o)}catch(e){m(e);let t=o.message||U(o.kind);throw B(t,`danger`),new v(t,{code:null,status:o.status,html:null,body:null,kind:o.kind,cause:e})}let d=(o.response?.headers.get(`Content-Type`)??``).toLowerCase(),f=null;if(d.includes(`json`))try{f=JSON.parse(u)}catch{f=null}let p=Ae(f,o.response?.statusText??``)||o.message||U(o.kind),ee=d.includes(`text/html`)?u:null;throw(o.kind!==`validation`||ee===null)&&B(p,`danger`),new v(p,{code:Dn(f),status:o.status,html:ee,body:f,kind:o.kind})}function An(e,t){Cn(e,!1),e.removeAttribute(`aria-busy`),m(t),B(I().failedMessage,`danger`)}function jn(e){let t=a(e.target,`[data-wui-post]`);t&&(e.preventDefault(),_n(t)||t.getAttribute(`aria-busy`)===`true`||Tn(t).catch(e=>An(t,e)))}function Mn(e){let t=a(e.target,`form[data-wui-post-form]`);if(!(t instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let r=n(e.submitter||t.querySelector(`button:not(.repeater-add):not(.repeater-remove)`),`A data-wui-post-form needs a submit button to report its result on.`);if(r.getAttribute(`aria-busy`)===`true`)return;let i=new URL(n(t.getAttribute(`action`),`A data-wui-post-form needs an action attribute to post to.`),document.baseURI).href;En(i,r,new FormData(t)).catch(e=>An(r,e)),t.closest(`wui-dropdown`)?.hide()}var W=(e,t)=>{e.disabled=!1,e.removeAttribute(`aria-busy`),t&&p(t,null)};async function Nn(e,t){let n=e.dataset.url;if(!n)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);e.disabled=!0,e.setAttribute(`aria-busy`,`true`),t&&p(t,`saving`);let r=we(e.getAttribute(`data-wui-timeout`))??3e4,i=await _(n,{method:(e.dataset.method||`post`).toUpperCase(),timeoutMs:r});if(i.kind===`session`)return;if(i.kind===`aborted`){W(e,t);return}let a=i.toastVariant||`success`;if(i.ok&&i.redirect){g(i.message,a,i.toastAction),window.location.assign(i.redirect);return}if(i.ok){let n=le(i);if(se(e)||n===null||ce(n)){W(e,t),P(i,a);return}if(ue({...n,reload:`page`},e)){W(e,t);return}g(i.message,a,i.toastAction),pe();return}let o=i.message||U(i.kind);e.disabled=!1,e.removeAttribute(`aria-busy`),t&&p(t,`error`,o),B(o,`danger`)}var Pn=/* @__PURE__ */ new WeakSet;function Fn(e){let t=a(e.target,`[data-wui-row-action]`);if(!t||t.closest(`[data-wui-server]`))return;if(!(t instanceof HTMLButtonElement)){if(Pn.has(t))return;Pn.add(t),m(/* @__PURE__ */ Error(`A [data-wui-row-action] element must be a button with data-url, so its click does nothing: ${t.getAttribute(`data-wui-row-action`)??``}`));return}if(e.preventDefault(),t.disabled||t.getAttribute(`aria-busy`)===`true`)return;let n=t.closest(`tr`);Nn(t,n).catch(e=>{W(t,n),m(e),B(I().failedMessage,`danger`)})}var In=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.form:null;function Ln(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-wui-auto-submit]`);if(!t)return;let n=In(e.target)||t.closest(`form`);n instanceof HTMLFormElement&&n.requestSubmit()}function Rn(e){dn.has(e)||(dn.add(e),e.addEventListener(`click`,xn),e.addEventListener(`wui-modal-closed`,Sn))}function zn(e=document){let t=e instanceof Element?e.ownerDocument:e;un.has(t)||(un.add(t),t.addEventListener(`click`,yn,!0),t.addEventListener(`submit`,bn,!0),Rn(t),t.addEventListener(`click`,jn),t.addEventListener(`click`,Fn),t.addEventListener(`submit`,Mn),t.addEventListener(`change`,Ln))}var G=()=>s(`unsavedChanges`,l),K=`form[data-wui-unsaved]`,Bn=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,Vn=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,Hn=/* @__PURE__ */ new Set([`submit`,`button`,`reset`,`image`]),Un=/* @__PURE__ */ new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),Wn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Gn=e=>Wn(e)?e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled:`disabled`in e&&!!e.disabled,Kn=e=>`name`in e&&typeof e.name==`string`&&e.name!==``,qn=e=>typeof e==`object`&&!!e,Jn=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&typeof e[0]==`string`);function Yn(e){let t=JSON.parse(e);if(!Jn(t))throw Error(`unsaved-changes snapshot is malformed`);return t}var q=/* @__PURE__ */ new WeakMap,Xn=/* @__PURE__ */ new WeakSet,Zn=e=>`${e.name}:${e.size}:${e.lastModified}`,J=e=>[...e.querySelectorAll(K)].filter(e=>e instanceof HTMLFormElement);function Y(e){let t=[];for(let n of e.elements)Kn(n)&&!Gn(n)&&(Wn(n)&&Hn.has(n.type)||(n instanceof HTMLInputElement&&(n.type===`checkbox`||n.type===`radio`)?t.push([n.name,n.value,n.checked]):n instanceof HTMLInputElement&&n.type===`file`?t.push([n.name,[...n.files||[]].map(Zn)]):n instanceof HTMLSelectElement&&n.type===`select-multiple`?t.push([n.name,[...n.selectedOptions].map(e=>e.value)]):n instanceof HTMLFieldSetElement||n instanceof HTMLObjectElement?t.push([n.name,null]):t.push([n.name,`value`in n?n.value:null])));return JSON.stringify(t)}function X(e){return Y(e)}function Qn(e,t){let n=/* @__PURE__ */ new Map,r=Yn(t);for(let e of r){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let i=Yn(Y(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())i.push(...e);return JSON.stringify(i)}function $n(e){for(let t of e.elements)if(Wn(t)&&t.name&&!Gn(t)){if(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!Un.has(t.type)){if(t.value.trim()!==``)return!0}else if(t instanceof HTMLInputElement&&t.type===`file`&&(t.files?.length??0)>0)return!0}return!1}var er=e=>({saved:e.querySelector(Bn)&&$n(e)?null:Y(e),engaged:!1,discarded:!1});function tr(e){let t=q.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&Y(e)!==t.saved}var nr=(e,t)=>J(e).filter(e=>e!==t&&tr(e));function rr(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||G().message;gn(e,{title:G().title,message:r,label:G().leaveLabel,cancel:G().keepLabel,icon:`warning`,tone:`danger`},()=>{for(let e of t){let t=q.get(e);t&&(t.discarded=!0)}n()})}function ir(e){if(e.matches(Vn))return!1;let t=e.getAttribute(`target`);if(t&&t.toLowerCase()!==`_self`)return!1;let n=e.getAttribute(`href`);if(n===null)return!1;let r=new URL(n,window.location.href);if(r.protocol!==`http:`&&r.protocol!==`https:`)return!1;let i=window.location;return!(r.hash&&r.origin===i.origin&&r.pathname===i.pathname&&r.search===i.search)}function ar(e,t){if((t?.getAttribute(`formmethod`)||e.getAttribute(`method`)||`get`).toLowerCase()===`dialog`)return!1;let n=t?.getAttribute(`formtarget`)||e.getAttribute(`target`);return!n||n.toLowerCase()===`_self`}function or(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target,n=a(t,`a[href]`);if(!(n instanceof HTMLAnchorElement)||!ir(n))return;let r=nr(n.ownerDocument,null);r.length&&(e.preventDefault(),rr(n,r,()=>n.click()))}function sr(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!ar(t,e.submitter))return;let n=nr(t.ownerDocument,t);if(n.length){e.preventDefault();let r=e.submitter,i=(r instanceof HTMLButtonElement||r instanceof HTMLInputElement)&&r.form===t?r:void 0;rr(t,n,()=>t.requestSubmit(i));return}let r=q.get(t);r&&(r.saved=Y(t),r.discarded=!1)}function cr(e){nr(document,null).length&&e.preventDefault()}function lr(e){let t=e.target,n=a(t,K);return n instanceof HTMLFormElement?n:null}function ur(e){let t=lr(e);if(!t)return;let n=q.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=Y(t)),n.engaged=!0)}function dr(e){let t=lr(e),n=t&&q.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function fr(e){for(let t of J(e)){let e=q.get(t);e?.saved&&(e.saved=Qn(t,e.saved))}}function pr(e){let t=qn(e)?e.handle:void 0;return qn(t)?t.el:void 0}function mr(e){if(!(e instanceof CustomEvent))return;let t=pr(e.detail);if(t instanceof Element)for(let e of J(t))gr(e)}function hr(e=document){let t=e instanceof Document?e:e.ownerDocument;if(!Xn.has(t)){Xn.add(t);for(let e of[`focusin`,`pointerdown`,`drop`])t.addEventListener(e,ur,!0);for(let e of[`input`,`change`])t.addEventListener(e,dr,!0);t.addEventListener(`click`,or),t.addEventListener(`submit`,sr),t.addEventListener(`wui:modal:success`,mr),t.addEventListener(o,()=>fr(t)),n(t.defaultView,`unsaved-changes guard needs a document with a window`).addEventListener(`beforeunload`,cr)}let r=J(e);e instanceof HTMLFormElement&&e.matches(K)&&r.unshift(e);for(let e of r)q.has(e)||q.set(e,er(e))}function gr(e){if(!(e instanceof HTMLFormElement)||!e.matches(K))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);q.set(e,{saved:Y(e),engaged:!1,discarded:!1})}var _r=()=>s(`drawer`,c),vr=`wui:drawer:discard`,Z=`wui-drawer[confirm-discard]`,yr=`wui-modal`,br=`data-wui-no-discard`,xr=`.wui-drawer-discard`,Sr=`input, select, textarea`,Cr=e=>typeof e==`object`&&!!e||typeof e==`function`;function wr(e){let t=e.currentTarget;if(!(t instanceof Document))throw Error(`The discard guard is not wired on a document.`);return t}function Tr(e,t){return a(e,t)}var Er=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,Q=/* @__PURE__ */ new WeakMap,Dr=/* @__PURE__ */ new WeakSet,Or=/* @__PURE__ */ new WeakSet;function kr(n,r,i,a,o){let s=n.createElement(`button`);return s.type=`button`,s.className=e(r,i,`sm`),s.dataset.wui=t,s.setAttribute(a,``),s.textContent=o,s}function Ar(e,t){let n=e.createElement(`div`);n.className=`wui-drawer-discard`,n.setAttribute(`role`,`alert`);let r=e.createElement(`span`);return r.className=`wui-drawer-discard-text`,r.textContent=t,n.append(r,kr(e,`danger`,`solid`,`data-wui-discard-confirm`,_r().discardLabel),kr(e,`primary`,`soft`,`data-wui-discard-keep`,_r().keepLabel)),n}function jr(e){if(!(e instanceof Element))return null;let t=e.closest(Z);if(t)return t;let n=e.closest(yr);return n&&$(n).length?n:null}function Mr(e){return e.closest(Z)??e.closest(yr)}function Nr(e,t){return t.hasAttribute(br)||e.hasAttribute(br)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function $(e){return e.matches(Z)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>Nr(t,e))}function Pr(e){let t=Q.get(e);return t!=null&&X(e)!==t}function Fr(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-drawer-footer`,n(e.querySelector(`.wui-drawer-panel`),`The drawer has no panel to hold its footer.`).append(t),Or.add(t),t}function Ir(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-modal-footer`,(e.querySelector(`.wui-modal-body`)?.parentElement??e.querySelector(`.modal-content`)??e).append(t),Or.add(t),t}function Lr(e){let t=e.querySelector(`[data-wui-discard-confirm]`);if(!(t instanceof HTMLElement))throw Error(`The discard prompt has no confirm button.`);t.focus()}function Rr(e,t,n){let r=e.querySelector(xr);if(r){Lr(r);return}let i=Ar(e.ownerDocument,t),a;if(e.matches(Z))a=e.querySelector(`.wui-drawer-footer`)??Fr(e),a.prepend(i);else if(e.hasAttribute(`confirm-discard`))a=e.querySelector(`.wui-modal-footer`)??Ir(e),a.prepend(i);else{if(!n)throw Error(`A discard prompt needs the form that is dirty.`);a=n.querySelector(`.modal-footer`)??e.querySelector(`.wui-modal-footer`)??Ir(e),a.prepend(i)}a.classList.add(`wui-drawer-discarding`),Lr(i)}function zr(e){let t=e.parentElement;if(e.remove(),!t)throw Error(`The discard prompt has no footer.`);t.classList.remove(`wui-drawer-discarding`),Or.has(t)&&t.remove()}function Br(e){for(let t of $(e))for(let e of t.querySelectorAll(Sr))if(Er(e)&&e.type!==`hidden`&&!e.disabled){e.focus({preventScroll:!0});return}}function Vr(e){let t=jr(e.target);if(t)for(let e of $(t))Q.get(e)??Q.set(e,X(e))}function Hr(e){for(let t of wr(e).querySelectorAll(`form`)){let e=Q.get(t);e!=null&&Q.set(t,Qn(t,e))}}function Ur(e){let t=e.target;t instanceof HTMLFormElement&&jr(t)&&Q.set(t,X(t))}function Wr(e){if(!Cr(e))return;let t=`handle`in e?e.handle:void 0;if(Cr(t))return`el`in t?t.el:void 0}function Gr(e){if(!(e instanceof CustomEvent))return;let t=e.detail,n=Wr(t);if(n instanceof Element)for(let e of n.querySelectorAll(`form`))Q.delete(e)}function Kr(e){let t=e.target;t instanceof Element&&t.matches(Z)&&[...$(t)].some(Pr)&&(e.preventDefault(),Rr(t,t.getAttribute(`confirm-discard`),null))}function qr(e){let t=e.target;if(!(t instanceof Element)||!t.matches(yr))return;let n=[...$(t)].find(Pr);n&&(e.preventDefault(),Rr(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??_r().confirmDiscard,n))}function Jr(e){let t=n(e.closest(xr),`The discard button is outside its prompt.`),r=Mr(t);if(zr(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);for(let e of $(r))Q.set(e,X(e));r.dispatchEvent(new CustomEvent(vr,{bubbles:!0})),r.matches(Z)?n(r.closest(`wui-drawer`),`The confirm-discard drawer is not a wui-drawer.`).hide():n(r.closest(`wui-modal`),`The discarded dialog is not a wui-modal.`).hide()}function Yr(e){let t=n(e.closest(xr),`The keep button is outside its prompt.`),r=Mr(t);if(zr(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);Br(r)}function Xr(e){let t=Tr(e.target,`[data-wui-discard-confirm]`);if(t){Jr(t);return}let n=Tr(e.target,`[data-wui-discard-keep]`);n&&Yr(n)}function Zr(e=document){let t=e instanceof Document?e:e.ownerDocument;Dr.has(t)||(Dr.add(t),t.addEventListener(`focusin`,Vr),t.addEventListener(`pointerdown`,Vr),t.addEventListener(`submit`,Ur),t.addEventListener(o,Hr),t.addEventListener(`wui:modal:success`,Gr),t.addEventListener(`wui:modal:loaded`,Gr),t.addEventListener(`wui-drawer-close`,Kr,!0),t.addEventListener(`wui-modal-close`,qr),t.addEventListener(`click`,Xr))}export{v as S,Qt as _,hr as a,qt as b,cn as c,kn as d,sn as f,nn as g,P as h,X as i,gn as l,rn as m,Ar as n,gr as o,$t as p,Zr as r,F as s,vr as t,zn as u,Kt as v,Zt as x,Yt as y};
|
package/dist/elements/select.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiSelect-
|
|
1
|
+
import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiSelect-B0CT2utp.js";e(`wui-select`,t);export{t as WuiSelect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.freeze({serverActions:`[data-wui-confirm], [data-wui-post], form[data-wui-post-form], [data-wui-row-action], [data-wui-auto-submit]`,unsavedChanges:`form[data-wui-unsaved]`,remoteModal:`[data-wui-modal], [data-wui-drawer], [data-wui-pane], wui-modal[data-wui-remote-url]`,serverTable:`[data-wui-server]`,drawerDiscard:`wui-drawer[confirm-discard], wui-modal form`}),t=Object.freeze({carousel:{entries:[`elements/carousel.ts`],tags:[`wui-carousel`]},"data-table":{entries:[`elements/data-table.ts`],tags:[`wui-data-table`]},dock:{entries:[`elements/dock.ts`],tags:[`wui-dock`]},"hover-card":{entries:[`elements/hover-card.ts`],tags:[`wui-hover-card`]},"navigation-menu":{entries:[`elements/navigation-menu.ts`],tags:[`wui-navigation-menu`]},"notification-center":{entries:[`elements/notification-center.ts`],tags:[`wui-notification-center`]},"onboarding-checklist":{entries:[`elements/onboarding-checklist.ts`],tags:[`wui-onboarding-checklist`]},otp:{entries:[`elements/otp.ts`],tags:[`wui-otp`]},overflow:{entries:[`elements/overflow.ts`],tags:[`wui-overflow`]},rating:{entries:[`elements/rating.ts`],tags:[`wui-rating`]},"record-pager":{entries:[`elements/record-pager.ts`],tags:[`wui-record-pager`]},"relative-time":{entries:[`elements/relative-time.ts`],tags:[`wui-relative-time`]},shortcuts:{entries:[`elements/shortcuts.ts`],tags:[`wui-shortcuts`]},"show-more":{entries:[`elements/show-more.ts`],tags:[`wui-show-more`]},"calendar-views":{entries:[`elements/calendar-views.ts`],tags:[`wui-calendar-views`]},truncate:{entries:[`elements/truncate.ts`],tags:[`wui-truncate`]},"whats-new":{entries:[`elements/whats-new.ts`],tags:[`wui-whats-new`]},"offline-banner":{entries:[`elements/offline-banner.ts`],tags:[`wui-offline-banner`]},"code-block":{entries:[`elements/code-block.ts`],tags:[`wui-code-block`]},"command-palette":{entries:[`elements/command-palette.ts`],tags:[`wui-command-palette`]},"comment-thread":{entries:[`elements/comment-thread.ts`],tags:[`wui-mention-input`,`wui-comment-thread`]},"consent-banner":{entries:[`elements/consent-banner.ts`],tags:[`wui-consent-banner`]},"context-menu":{entries:[`elements/context-menu.ts`],tags:[`wui-context-menu`]},"date-range":{entries:[`elements/date-range.ts`],tags:[`wui-date-range`]},"date-time":{entries:[`elements/date-time.ts`],tags:[`wui-date-time`]},datepicker:{entries:[`elements/datepicker.ts`],tags:[`wui-datepicker`]},"mini-calendar":{entries:[`elements/mini-calendar.ts`],tags:[`wui-mini-calendar`]},drawer:{entries:[`elements/drawer.ts`],tags:[`wui-drawer`]},dropdown:{entries:[`elements/dropdown.ts`],tags:[`wui-dropdown`]},"entry-grid":{entries:[`elements/entry-grid.ts`],tags:[`wui-entry-grid`]},gantt:{entries:[`elements/gantt.ts`],tags:[`wui-gantt`]},"image-crop":{entries:[`elements/image-crop.ts`],tags:[`wui-image-crop`]},"inline-edit":{entries:[`elements/inline-edit.ts`],tags:[`wui-inline-edit`]},kanban:{entries:[`elements/kanban.ts`],tags:[`wui-kanban`]},"dashboard-grid":{entries:[`elements/dashboard-grid.ts`],tags:[`wui-dashboard-grid`]},"lead-popup":{entries:[`elements/lead-popup.ts`],tags:[`wui-lead-popup`]},lightbox:{entries:[`elements/lightbox.ts`],tags:[`wui-lightbox`]},"org-tree":{entries:[`elements/org-tree.ts`],tags:[`wui-org-tree`]},markdown:{entries:[`elements/markdown.ts`],tags:[`wui-markdown`]},phone:{entries:[`elements/phone.ts`,`global/parts/select-country.ts`],tags:[`wui-phone`]},popover:{entries:[`elements/popover.ts`],tags:[`wui-popover`]},"saved-views":{entries:[`elements/saved-views.ts`],tags:[`wui-saved-views`]},glyphs:{entries:[`global/parts/glyphs.ts`],tags:[]},"select-chips":{entries:[`global/parts/select-chips.ts`],tags:[]},"select-recents":{entries:[`global/parts/select-recents.ts`],tags:[]},"select-search":{entries:[`global/parts/select-search.ts`],tags:[]},"select-window":{entries:[`global/parts/select-window.ts`],tags:[]},"table-export":{entries:[`global/parts/table-export.ts`],tags:[]},server:{entries:[`global/parts/server.ts`],tags:[],markers:Object.values(e).join(`, `)},shell:{entries:[`global/parts/shell.ts`],tags:[],markers:`[data-app-shell]`},slider:{entries:[`elements/slider.ts`],tags:[`wui-slider`]},sortable:{entries:[`elements/sortable.ts`],tags:[`wui-sortable`]},"status-icon":{entries:[`elements/status-icon.ts`],tags:[`wui-status-icon`]},timepicker:{entries:[`elements/timepicker.ts`],tags:[`wui-timepicker`]},tour:{entries:[`elements/tour.ts`],tags:[`wui-tour`]},tree:{entries:[`elements/tree.ts`],tags:[`wui-tree`]},"tree-picker":{entries:[`elements/tree-picker.ts`],tags:[`wui-tree-picker`]},wizard:{entries:[`elements/wizard.ts`],tags:[`wui-wizard-step`,`wui-wizard`]},chart:{file:`ui-chart.global.js`,tags:[`wui-chart`],selfContained:!0},calendar:{file:`ui-calendar.global.js`,tags:[`wui-calendar`],selfContained:!0},"rich-text":{file:`ui-rich-text.global.js`,tags:[`wui-rich-text`],selfContained:!0},"file-viewer":{file:`ui-file-viewer.global.js`,tags:[`wui-file-viewer`],selfContained:!0}});Object.freeze({anchorOverlay:`anchorOverlay.ts`,avatarNode:`avatarNode.ts`,buttonClass:`buttonClass.ts`,calendarMath:`calendarMath.ts`,copyText:`copyText.ts`,dataTable:`dataTable.ts`,dataTableText:`text/web/dataTable.g.ts`,datePickerText:`text/web/datePicker.g.ts`,defineElement:`defineElement.ts`,devWarn:`devWarn.ts`,dom:`dom.ts`,drawerText:`text/web/drawer.g.ts`,elementBase:`elementBase.ts`,fieldState:`fieldState.ts`,flash:`server/flash.ts`,formatters:`formatters.ts`,formMirror:`formMirror.ts`,glyphs:`global/glyphs.ts`,hasOwn:`hasOwn.ts`,httpFailureText:`text/web/httpFailure.g.ts`,iconGlyphs:`iconGlyphs.g.ts`,imeSafeEnter:`imeSafeEnter.ts`,isDrawn:`isDrawn.ts`,listboxKeyNav:`listboxKeyNav.ts`,loader:`global/loader.ts`,mentionText:`mentionText.ts`,menuKeyNav:`menuKeyNav.ts`,nativeOverlay:`nativeOverlay.ts`,notificationCentreText:`text/web/notificationCentre.g.ts`,notificationDays:`notificationDays.ts`,optionLabel:`optionLabel.ts`,partRegistry:`select/partRegistry.ts`,postError:`server/postError.ts`,refreshAfter:`server/refreshAfter.ts`,regions:`server/regions.ts`,relativeTime:`relativeTime.ts`,rtl:`rtl.ts`,selectList:`select/list.ts`,selectRemote:`select/remote.ts`,selectText:`text/web/select.g.ts`,selectWindow:`select/window.ts`,server:`global/server.ts`,serverHtml:`server/serverHtml.ts`,serverTableRegistry:`server/serverTableRegistry.ts`,shellRegistry:`server/shellRegistry.ts`,shortcutKeys:`shortcutKeys.ts`,stepperHeader:`stepperHeader.ts`,svgNodes:`svgNodes.ts`,tableExport:`global/tableExport.ts`,tableSelect:`tableSelect.ts`,textMatch:`textMatch.ts`,textStore:`text/textStore.ts`,toastAction:`server/toastAction.ts`,toastHeader:`server/toastHeader.ts`,tooltips:`tooltips.ts`,wuiHost:`server/wuiHost.ts`,wuiHttp:`server/wuiHttp.ts`,WuiSelect:`WuiSelect.ts`,zone:`zone.ts`});var n=`wui-elements:defined`,r=`wui-elements:load-error`,i=/* @__PURE__ */ new Map;for(let[e,n]of Object.entries(t))for(let t of n.tags)i.set(t,e);[...i.keys()].join(`,`);var a=[];for(let[e,n]of Object.entries(t))n.markers!==void 0&&a.push([e,n.markers]);[...new Set(a.flatMap(([,e])=>[...e.matchAll(/\[([a-z-]+)\]/g)]).flatMap(e=>e[1]===void 0?[]:[e[1]]))];export{r as n,n as t};
|
|
1
|
+
var e=Object.freeze({serverActions:`[data-wui-confirm], [data-wui-post], form[data-wui-post-form], [data-wui-row-action], [data-wui-auto-submit]`,unsavedChanges:`form[data-wui-unsaved]`,remoteModal:`[data-wui-modal], [data-wui-drawer], [data-wui-pane], wui-modal[data-wui-remote-url]`,serverTable:`[data-wui-server]`,drawerDiscard:`wui-drawer[confirm-discard], wui-modal form`}),t=Object.freeze({carousel:{entries:[`elements/carousel.ts`],tags:[`wui-carousel`]},"data-table":{entries:[`elements/data-table.ts`],tags:[`wui-data-table`]},dock:{entries:[`elements/dock.ts`],tags:[`wui-dock`]},"hover-card":{entries:[`elements/hover-card.ts`],tags:[`wui-hover-card`]},"navigation-menu":{entries:[`elements/navigation-menu.ts`],tags:[`wui-navigation-menu`]},"notification-center":{entries:[`elements/notification-center.ts`],tags:[`wui-notification-center`]},"onboarding-checklist":{entries:[`elements/onboarding-checklist.ts`],tags:[`wui-onboarding-checklist`]},otp:{entries:[`elements/otp.ts`],tags:[`wui-otp`]},overflow:{entries:[`elements/overflow.ts`],tags:[`wui-overflow`]},rating:{entries:[`elements/rating.ts`],tags:[`wui-rating`]},"record-pager":{entries:[`elements/record-pager.ts`],tags:[`wui-record-pager`]},"relative-time":{entries:[`elements/relative-time.ts`],tags:[`wui-relative-time`]},shortcuts:{entries:[`elements/shortcuts.ts`],tags:[`wui-shortcuts`]},"show-more":{entries:[`elements/show-more.ts`],tags:[`wui-show-more`]},"calendar-views":{entries:[`elements/calendar-views.ts`],tags:[`wui-calendar-views`]},truncate:{entries:[`elements/truncate.ts`],tags:[`wui-truncate`]},"whats-new":{entries:[`elements/whats-new.ts`],tags:[`wui-whats-new`]},"offline-banner":{entries:[`elements/offline-banner.ts`],tags:[`wui-offline-banner`]},"code-block":{entries:[`elements/code-block.ts`],tags:[`wui-code-block`]},"command-palette":{entries:[`elements/command-palette.ts`],tags:[`wui-command-palette`]},"comment-thread":{entries:[`elements/comment-thread.ts`],tags:[`wui-mention-input`,`wui-comment-thread`]},"consent-banner":{entries:[`elements/consent-banner.ts`],tags:[`wui-consent-banner`]},"context-menu":{entries:[`elements/context-menu.ts`],tags:[`wui-context-menu`]},"date-range":{entries:[`elements/date-range.ts`],tags:[`wui-date-range`]},"date-time":{entries:[`elements/date-time.ts`],tags:[`wui-date-time`]},datepicker:{entries:[`elements/datepicker.ts`],tags:[`wui-datepicker`]},"mini-calendar":{entries:[`elements/mini-calendar.ts`],tags:[`wui-mini-calendar`]},drawer:{entries:[`elements/drawer.ts`],tags:[`wui-drawer`]},dropdown:{entries:[`elements/dropdown.ts`],tags:[`wui-dropdown`]},"entry-grid":{entries:[`elements/entry-grid.ts`],tags:[`wui-entry-grid`]},gantt:{entries:[`elements/gantt.ts`],tags:[`wui-gantt`]},"image-crop":{entries:[`elements/image-crop.ts`],tags:[`wui-image-crop`]},"inline-edit":{entries:[`elements/inline-edit.ts`],tags:[`wui-inline-edit`]},kanban:{entries:[`elements/kanban.ts`],tags:[`wui-kanban`]},"dashboard-grid":{entries:[`elements/dashboard-grid.ts`],tags:[`wui-dashboard-grid`]},"lead-popup":{entries:[`elements/lead-popup.ts`],tags:[`wui-lead-popup`]},lightbox:{entries:[`elements/lightbox.ts`],tags:[`wui-lightbox`]},"org-tree":{entries:[`elements/org-tree.ts`],tags:[`wui-org-tree`]},markdown:{entries:[`elements/markdown.ts`],tags:[`wui-markdown`]},phone:{entries:[`elements/phone.ts`,`global/parts/select-country.ts`],tags:[`wui-phone`]},popover:{entries:[`elements/popover.ts`],tags:[`wui-popover`]},"saved-views":{entries:[`elements/saved-views.ts`],tags:[`wui-saved-views`]},glyphs:{entries:[`global/parts/glyphs.ts`],tags:[]},"select-chips":{entries:[`global/parts/select-chips.ts`],tags:[]},"select-recents":{entries:[`global/parts/select-recents.ts`],tags:[]},"select-search":{entries:[`global/parts/select-search.ts`],tags:[]},"select-window":{entries:[`global/parts/select-window.ts`],tags:[]},"table-export":{entries:[`global/parts/table-export.ts`],tags:[]},server:{entries:[`global/parts/server.ts`],tags:[],markers:Object.values(e).join(`, `)},shell:{entries:[`global/parts/shell.ts`],tags:[],markers:`[data-app-shell]`},slider:{entries:[`elements/slider.ts`],tags:[`wui-slider`]},sortable:{entries:[`elements/sortable.ts`],tags:[`wui-sortable`]},"status-icon":{entries:[`elements/status-icon.ts`],tags:[`wui-status-icon`]},timepicker:{entries:[`elements/timepicker.ts`],tags:[`wui-timepicker`]},tour:{entries:[`elements/tour.ts`],tags:[`wui-tour`]},tree:{entries:[`elements/tree.ts`],tags:[`wui-tree`]},"tree-picker":{entries:[`elements/tree-picker.ts`],tags:[`wui-tree-picker`]},wizard:{entries:[`elements/wizard.ts`],tags:[`wui-wizard-step`,`wui-wizard`]},chart:{file:`ui-chart.global.js`,tags:[`wui-chart`],selfContained:!0},calendar:{file:`ui-calendar.global.js`,tags:[`wui-calendar`],selfContained:!0},"rich-text":{file:`ui-rich-text.global.js`,tags:[`wui-rich-text`],selfContained:!0},"file-viewer":{file:`ui-file-viewer.global.js`,tags:[`wui-file-viewer`],selfContained:!0}});Object.freeze({anchorOverlay:`anchorOverlay.ts`,avatarNode:`avatarNode.ts`,buttonClass:`buttonClass.ts`,calendarMath:`calendarMath.ts`,copyText:`copyText.ts`,dataTable:`dataTable.ts`,dataTableText:`text/web/dataTable.g.ts`,datePickerText:`text/web/datePicker.g.ts`,defineElement:`defineElement.ts`,devWarn:`devWarn.ts`,dom:`dom.ts`,drawerText:`text/web/drawer.g.ts`,elementBase:`elementBase.ts`,fieldState:`fieldState.ts`,flash:`server/flash.ts`,formatters:`formatters.ts`,formMirror:`formMirror.ts`,glyphs:`global/glyphs.ts`,hasOwn:`hasOwn.ts`,httpFailureText:`text/web/httpFailure.g.ts`,iconGlyphs:`iconGlyphs.g.ts`,imeSafeEnter:`imeSafeEnter.ts`,isDrawn:`isDrawn.ts`,listboxKeyNav:`listboxKeyNav.ts`,loader:`global/loader.ts`,mentionText:`mentionText.ts`,menuKeyNav:`menuKeyNav.ts`,nativeOverlay:`nativeOverlay.ts`,notificationCentreText:`text/web/notificationCentre.g.ts`,notificationDays:`notificationDays.ts`,optionLabel:`optionLabel.ts`,partRegistry:`select/partRegistry.ts`,postError:`server/postError.ts`,refreshAfter:`server/refreshAfter.ts`,regions:`server/regions.ts`,relativeTime:`relativeTime.ts`,rtl:`rtl.ts`,selectList:`select/list.ts`,selectRemote:`select/remote.ts`,selectText:`text/web/select.g.ts`,selectWindow:`select/window.ts`,server:`global/server.ts`,serverHtml:`server/serverHtml.ts`,serverTableRegistry:`server/serverTableRegistry.ts`,shellRegistry:`server/shellRegistry.ts`,shortcutKeys:`shortcutKeys.ts`,stepperHeader:`stepperHeader.ts`,svgNodes:`svgNodes.ts`,tableExport:`global/tableExport.ts`,tableSelect:`tableSelect.ts`,textMatch:`textMatch.ts`,textStore:`text/textStore.ts`,toastAction:`server/toastAction.ts`,toastHeader:`server/toastHeader.ts`,tooltips:`tooltips.ts`,wuiHost:`server/wuiHost.ts`,wuiHttp:`server/wuiHttp.ts`,wuiUpload:`server/wuiUpload.ts`,WuiSelect:`WuiSelect.ts`,zone:`zone.ts`});var n=`wui-elements:defined`,r=`wui-elements:load-error`,i=/* @__PURE__ */ new Map;for(let[e,n]of Object.entries(t))for(let t of n.tags)i.set(t,e);[...i.keys()].join(`,`);var a=[];for(let[e,n]of Object.entries(t))n.markers!==void 0&&a.push([e,n.markers]);[...new Set(a.flatMap(([,e])=>[...e.matchAll(/\[([a-z-]+)\]/g)]).flatMap(e=>e[1]===void 0?[]:[e[1]]))];export{r as n,n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./devWarn-DXdRWZs3.js";import{n as t}from"./optionLabel-wbpl8OTJ.js";import{r as n}from"./textStore-DBplASiZ.js";import{r}from"./search.g-B5d1s59A.js";import{t as i}from"./customRule-BpwcjVLb.js";import{n as a}from"./WuiSelect-
|
|
1
|
+
import{n as e}from"./devWarn-DXdRWZs3.js";import{n as t}from"./optionLabel-wbpl8OTJ.js";import{r as n}from"./textStore-DBplASiZ.js";import{r}from"./search.g-B5d1s59A.js";import{t as i}from"./customRule-BpwcjVLb.js";import{n as a}from"./WuiSelect-B0CT2utp.js";var o=()=>n(`select`,r),s=(e,n)=>{let r=n.toLowerCase(),i=e.getAttribute(`value-label`);return i&&String(e.value??``)!==``&&i.toLowerCase()===r?!0:e.options.some(e=>t(e).toLowerCase()===r||String(e.value??``).toLowerCase()===r)},c=e=>{if(e.querySelector(`.wui-select-spacer`))return null;let t=[...e.querySelectorAll(`.wui-select-option`)].filter(e=>e.dataset.custom!==`true`&&e.getAttribute(`aria-disabled`)!==`true`);return t.length===1?t[0]?.dataset.value??null:null};function l(){let t,n,r=0,l,u=null,d=null,f=``,p=null,m=!1,h=()=>a(t),g=()=>typeof t.loadOptions!=`function`&&!t.getAttribute(`source`),_=(e,n,r)=>{let i=t.getAttribute(e);if(i==null||i.trim()===``)return n;let a=Number(i);return r(a)?a:n},v=()=>_(`min-chars`,1,e=>Number.isInteger(e)&&e>=0),y=()=>_(`debounce`,250,e=>Number.isFinite(e)&&e>=0),b=()=>{u?.abort(),u=null};function x(e,n){if(typeof t.loadOptions==`function`)return t.loadOptions(e,{signal:n});let r=t.getAttribute(`source`);if(r===null)throw Error(`search source attribute missing`);let i=`${r}${r.includes(`?`)?`&`:`?`}q=${encodeURIComponent(e)}`;return fetch(i,{signal:n,credentials:`same-origin`,headers:{Accept:`application/json`}}).then(e=>{if(!e.ok)throw Error(`search request failed with status ${e.status}`);return e.json()})}function S(n,r,i){r?(e(`wui-select: search failed`,i),t.setPartOptions([]),t.setStatus(`empty`)):(t.setPartOptions(n),t.setStatus(n.length?`idle`:`empty`))}async function C(e,t,n){let i=[],a=!1,o=null;try{if(i=await x(e,n),!Array.isArray(i))throw TypeError(`search results must be an array`)}catch(e){a=!0,o=e??/* @__PURE__ */ Error(`search failed`)}finally{t===r&&(u=null,S(i,a,o))}}function w(e){let n=r;b(),g()?(m=!0,t.setStatus(`loading`)):(u=new AbortController,t.setStatus(`loading`),C(e,n,u.signal))}let T=(e,n)=>t.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:n}}));function E(e){r+=1,b(),clearTimeout(l),l=void 0,e.trim().length<v()?(t.setPartOptions([]),t.setStatus(`hint`)):(T(e,r),w(e))}return{mount(e,r,i={}){t=e,n=r;let a=n.search?.value??``;n.search&&i.carry?.query&&a===``&&(n.search.value=i.carry.query),a.trim()!==``&&t._onQueryChange(a)},onQuery(e){if(r+=1,b(),clearTimeout(l),l=void 0,f=e,p=null,m=!1,!h())return!1;if(e.trim().length<v())return t.setPartOptions([]),t.setStatus(`hint`),!0;let n=r;return l=setTimeout(()=>{l=void 0,T(e,n),w(e)},y()),!0},onOpen(){if(h()){if(p!==null){let e=p;p=null,E(e)}else v()===0&&t._query.trim()===``&&E(``)}},onOptions(){m&&(m=!1,t.setStatus(t.options.length?`idle`:`empty`))},onBlur(){if(t.mode!==`search`)return!1;let e=(n.search?.value??``).trim();if(!e||e===String(t.value))return!1;if(t.hasAttribute(`allow-custom`)&&!s(t,e)){let n=i(t,e);return n?(t.setError(n),!1):(t.commit(e,{isCustom:!0}),!0)}let r=c(n.list);return r===null||r===String(t.value)?!1:(t.commit(r,{isCustom:!1}),t.closeMenu(),!0)},actionRow(e){if(d=null,t.mode!==`search`||!t.hasAttribute(`allow-custom`))return null;let n=e.trim();return!n||s(t,n)?null:(d={position:`bottom`,label:(t.getAttribute(`add-label`)??o().addLabel).replaceAll(`{query}`,n),value:n},d)},onPick(e){if(!d||e.value!==d.value||e.label!==d.label)return!1;let n=d.value;return d=null,t.commit(n,{isCustom:!0}),!0},renderValue(){let e=t.value;if(t.mode!==`search`||!e||t.options.some(t=>String(t.value)===String(e)))return!1;let r=t.getAttribute(`value-label`);return r?(n.value.classList.remove(`wui-select-placeholder`),n.value.textContent=r,!0):!1},teardown(){(l!==void 0||u!==null||m)&&(p=f),m=!1,r+=1,clearTimeout(l),l=void 0,b(),d=null}}}export{l as default};
|
package/dist/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./dom-DMQu--xV.js";import{n}from"./imeSafeEnter-DeO_3lXy.js";import{r,t as i}from"./textStore-DBplASiZ.js";import{t as a}from"./shell.g-BhC11Oe3.js";import{t as o}from"./serverHtml-BC6tAyAl.js";import{a as s,c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,n as g,o as _,p as ee,s as v,t as y,u as b}from"./wuiHttp-8CYWEbRz.js";import{n as x,t as te}from"./buttonClass-C8BRtTk8.js";import{E as ne,M as re,N as S,b as C,k as w,y as ie}from"./dataTable-C0q14bkP.js";import{n as T,t as ae}from"./devWarn-DXdRWZs3.js";import{t as oe}from"./iconGlyphs.g-a9FtjPXh.js";import{LIST_QUERY_RESERVED as se,SEARCH_PARAM as ce}from"./listQuery.js";import{a as le,c as ue,i as de,n as E,r as fe,s as pe}from"./tableSelect-juA3KcQh.js";import{t as D}from"./dataTable.g-1PsmN1Nj.js";import{t as me}from"./httpFailure.g-DjZzGxPj.js";import{S as he,_ as O,b as ge,c as k,d as _e,g as A,h as ve,i as j,m as M,n as N,p as P,v as ye,y as F}from"./refreshAfter-DhYgWXmQ.js";import{_ as be,a as I,b as xe,c as Se,d as Ce,f as L,g as R,h as z,i as we,l as B,m as Te,n as Ee,o as De,p as Oe,r as ke,s as Ae,t as V,u as je,v as Me,x as Ne,y as Pe}from"./drawerDiscard-D_LMpaFv.js";var H=()=>r(`dataTable`,D),Fe=5,Ie=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Le=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,Re=e=>Ie(e)&&`type`in e&&e.type===`hidden`,U=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),W=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},G=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},ze=e=>e.localName===`wui-select`,K=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},Be=e=>({total:K(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:K(e.dataset.page,1),pageSize:K(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`,pending:e.dataset.totalPending===`true`,rowCount:K(e.dataset.rowCount,0)}),Ve=(e,t)=>{e&&O().toast(e,{variant:t})},He=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!Re(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!se.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of U(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},Ue=new Intl.NumberFormat(`en-IN`),We=(e,t)=>t?`${Ue.format(e)}+`:Ue.format(e),Ge=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?W(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=We(t,n))};function Ke(e=document){let t=U(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if(M(e))continue;let t=qe(e);ve(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function qe(n){let a=W(n,`.table-wrap`,HTMLElement),s=a?W(a,`:scope > table`,HTMLTableElement):null,c=n.dataset.src;if(!a||!s||!c)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let l=W(a,`:scope > [data-wui-table-state]`,HTMLElement),u=W(n,`[data-wui-table-pager]`,HTMLElement),d=W(n,`[data-wui-table-status]`,HTMLElement),f={urlState:n.dataset.urlState!==`false`,filtersForm:n.dataset.filtersForm||null,filtersRegion:n.dataset.filtersRegion||null,searchInput:n.dataset.searchInput||null,loadingText:n.dataset.loadingText||H().loadingText,errorText:n.dataset.errorText||H().errorText,timeoutMs:ee(n.getAttribute(`data-wui-timeout`))??3e4},p=new URL(c,window.location.href),g=n.dataset.totalSrc||null,_=g===null?null:new URL(g,window.location.href),v=/* @__PURE__ */ new Set([...p.searchParams.keys(),..._?.searchParams.keys()??[]]),y=s.hasAttribute(`data-app-datatable-selectable`),b=/* @__PURE__ */ new Set,D=!1,he=m(),ge=new AbortController,A={signal:ge.signal},ve=W(s,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),M=e(ve,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),N=Be(M),P=null,ye=null,F=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))v.has(n)||t.append(n,r);return t},be=e=>F(new URL(e,window.location.href).search),I=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},xe=(e,t)=>{let n=new URL(e.href);for(let[e,r]of t)v.has(e)||n.searchParams.append(e,r);return n.origin===window.location.origin?`${n.pathname}${n.search}`:n.href},Se=e=>xe(p,e),Ce=(e,t)=>{let n=new URLSearchParams(e);return n.has(`page`)&&n.set(`page`,String(t.page)),n.has(`pageSize`)&&n.set(`pageSize`,String(t.pageSize)),n.has(`sortBy`)?t.sortBy?(n.set(`sortBy`,t.sortBy),n.set(`sortOrder`,t.sortOrder)):(n.delete(`sortBy`),n.delete(`sortOrder`)):n.delete(`sortOrder`),n},L=Ce(f.urlState?F(window.location.search):new URLSearchParams,N);f.urlState&&I(L)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,I(L));let R=(e,t)=>a.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),z=e=>{d&&(d.textContent=e)},we=e=>{if(e.pending)return e.rowCount===0?H().emptyLabel:i(H().pageTextPending,{page:e.page});if(e.total===0)return H().emptyLabel;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?We(e.total,!0):`${e.total}`;return i(e.total===1?H().pageTextOne:H().pageTextOther,{page:e.page,pages:t,total:n})},B=()=>U(s,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),Ee=e=>{if(y&&U(e,`:scope > tr:not(.wui-group-row, .wui-virtual-spacer)`,HTMLTableRowElement).some(e=>!e.dataset.rowKey))throw Error(`A selectable server-paged table needs data-row-key on every row, so a selection can span pages.`)},De=e=>{let t=n.dataset.activeRowKey;if(t!==void 0)for(let n of e){let e=n.classList.contains(`wui-row-active`),r=t!==``&&n.dataset.rowKey===t;n.classList.toggle(`wui-row-active`,r),r?n.setAttribute(`aria-current`,`true`):e&&n.removeAttribute(`aria-current`)}},Oe=e=>{if(y){fe(e);for(let t of e){let e=W(t,`.${E} .form-check-input:not(:disabled)`,HTMLInputElement);e&&(D&&b.add(t.dataset.rowKey),e.checked=b.has(t.dataset.rowKey))}ue(s)}De(e);let t=B();if(s.classList.contains(`wui-table-stack`))for(let n of e)[...n.cells].forEach((e,n)=>{let r=t[n]?.textContent?.trim();r&&!e.hasAttribute(`data-label`)&&e.setAttribute(`data-label`,r)});t.forEach((t,n)=>{if(t.classList.contains(`wui-col-hidden`))for(let t of e)t.cells[n]?.classList.add(`wui-col-hidden`)})},ke=e=>Oe(U(e,`:scope > tr`,HTMLTableRowElement)),Ae=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},V=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),je=(e,t)=>{if(!l)return;let n=W(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);V(l),(t.pending?t.rowCount:t.total)===0&&n?(l.replaceChildren(n.content.cloneNode(!0)),l.hidden=!1):(l.replaceChildren(),l.hidden=!0)},Me=e=>{u&&(V(u),u.replaceChildren(...e?[e.content.cloneNode(!0)]:[]),u.hidden=!1)},Ne=e=>{let t=f.filtersRegion&&e?W(document,f.filtersRegion,HTMLElement):null;return t&&e&&(V(t),t.replaceChildren(e.content.cloneNode(!0))),t},Pe=0,Ue=e=>{let t=Be(e);t.pending&&Object.assign(t,{total:N.total,totalCapped:N.totalCapped});let n=t.sortBy!==N.sortBy||t.sortOrder!==N.sortOrder?ie(M.rows):null;Me(W(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement)),je(e,t);let r=Ne(W(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement));Ae(e),V(M),s.replaceChild(e,M),M=e,Pe+=1;let i=D&&t.total!==N.total;return N=t,i&&(D=!1),a.removeAttribute(`data-wui-table-error`),ke(e),it(),ne(e.rows,n),i&&X(),r},Ke=e=>{let t=W(o(`<table>${e}</table>`),`tbody[data-wui-rows]`,HTMLTableSectionElement);return t&&Ee(t),t?document.importNode(t,!0):null},qe=(e,t=B())=>{let n=document.createElement(`tr`);for(let r=0;r<e;r++){let e=t[r],i=e?.classList.contains(`text-center`),a=!i&&(e?.classList.contains(`num`)||e?.classList.contains(`text-end`)||e?.classList.contains(`wui-cell-end`)),o=document.createElement(`td`);i?o.classList.add(`text-center`):a&&o.classList.add(e?.classList.contains(`num`)?`num`:`wui-cell-end`);let s=document.createElement(`span`);s.className=`skeleton`,s.setAttribute(`aria-hidden`,`true`);let c=i?44:a?56:60;s.style.cssText=`display:block;width:${c}%;height:12px;border-radius:6px`,o.append(s),n.append(o)}return n},Je=()=>{if(M.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,B().length);M.replaceChildren(...Array.from({length:Fe},()=>{let t=qe(e);return t.setAttribute(`data-wui-skeleton`,``),t})),a.removeAttribute(`data-wui-table-error`),l&&(l.hidden=!0)},Ye=e=>{e?(a.setAttribute(`aria-busy`,`true`),Je()):a.removeAttribute(`aria-busy`)},Xe=e=>e===`forbidden`?H().forbiddenMessage:e===`networkCheck`?r(`httpFailure`,me).networkCheckText:e===`network`?H().networkMessage:e===`timeout`?H().timeoutMessage:f.errorText,Ze=e=>{let t=Xe(e);if(a.setAttribute(`data-wui-table-error`,e),u&&(u.hidden=!0),l){let n=document.createElement(`div`);n.className=`empty-state wui-empty-state-table wui-table-error`,n.setAttribute(`role`,`alert`);let r=document.createElement(`span`);r.className=`empty-state-icon`;let i=oe(e===`forbidden`?`lock`:`alert-circle`,{size:24});i&&r.replaceChildren(i);let a=document.createElement(`div`);a.className=`empty-state-title`,a.textContent=t;let o=document.createElement(`div`);o.className=`empty-state-action`;let s=document.createElement(`button`);s.type=`button`,s.className=x(`primary`,`outline`,`sm`),s.dataset.wui=te,s.setAttribute(`data-wui-table-retry`,``),s.textContent=H().retryLabel,o.append(s),n.append(r,a,o),V(l),l.replaceChildren(n),l.hidden=!1}z(t)},Qe=()=>f.filtersForm?W(document,f.filtersForm,HTMLFormElement):null,$e=async(e,t=`none`,{quiet:r=!1}={})=>{let i=new URLSearchParams(e);r||(P={query:i,mode:t},Ye(!0),z(f.loadingText)),R(`wui:table:loading`,{query:i.toString()});let o=await he.run(Se(i),{timeoutMs:f.timeoutMs});if(o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return o;r||Ye(!1);let s=null;if(o.ok)try{s=Ke(o.html)}catch(e){ae(e)}if(!o.ok||!s){let e=o.ok?`server`:o.kind;return r?T(`A quiet server table refresh failed; the rows on screen are kept.`,e):Ze(e),R(`wui:table:error`,{status:o.status,kind:e,message:Xe(e)}),o}let c=Ue(s);return L=Ce(i,N),He(Qe(),L),f.urlState&&t===`push`?window.history.pushState(window.history.state,``,I(L)):f.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,I(L)),r||z(we(N)),O().refresh(a),c&&O().refresh(c),N.pending?nt():Ge(n,N.total,N.totalCapped),R(`wui:table:loaded`,{...N,query:L.toString()}),o},q=[],et=null,tt=()=>{if(q.length===0||a.getAttribute(`aria-busy`)===`true`)return;let e=q;q=[],$e(L,`none`,{quiet:!0}).then(t=>{for(let n of e)n.resolve(t)},t=>{for(let n of e)n.reject(t)})},J=async(e,t=`none`,n={})=>{let r;try{r=await $e(e,t,n)}catch(e){let t=q;q=[];for(let n of t)n.reject(e);throw e}r.kind===`session`&&(et=r);let i=r.kind===`aborted`&&a.getAttribute(`aria-busy`)===`true`;if(r.kind===`session`||r.kind===`aborted`&&!i){let e=q;q=[];for(let t of e)t.resolve(r)}return tt(),r},Y=e=>(e.delete(`page`),e),nt=()=>{if(!_||!N.pending)return;let e=Pe;h(xe(_,L),{timeoutMs:f.timeoutMs}).then(t=>{if(e!==Pe)return;if(!t.ok){T(`[@webority/ui-elements] A server table's total did not load; its pager keeps Previous and Next.`,t.kind);return}let r=W(o(t.html),`div[data-wui-total]`,HTMLElement);if(!r){T(`[@webority/ui-elements] A server table's count answer has no div[data-wui-total]; its pager keeps Previous and Next.`);return}if(K(r.dataset.page,-1)!==N.page||K(r.dataset.pageSize,-1)!==N.pageSize)return;let i=K(r.dataset.total,-1);if(i<0){T(`[@webority/ui-elements] A server table's count answer has no whole data-total; its pager keeps Previous and Next.`);return}let a=r.dataset.totalCapped===`true`,s=D&&i!==N.total;N={...N,total:i,totalCapped:a,pending:!1},s&&(D=!1);let c=W(r,`:scope > template[data-wui-pager]`,HTMLTemplateElement);c&&Me(c);let l=Ne(W(r,`:scope > template[data-wui-filters]`,HTMLTemplateElement));l&&O().refresh(l),Ge(n,N.total,N.totalCapped),z(we(N)),s&&X(),R(`wui:table:total`,{total:i,totalCapped:a})})},rt=()=>U(s,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),it=()=>{for(let e of rt()){let t=e.dataset.sortKey===N.sortBy;e.setAttribute(`aria-sort`,t?N.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of rt())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=e.classList.contains(`num`)||e.classList.contains(`text-end`),n=document.createElement(`span`);n.className=t?`sort-icon wui-sort-lead`:`sort-icon`;let r=oe(`chevrons-up-down`,{size:14});r&&n.replaceChildren(r),t?e.prepend(n):e.append(n)}let at=e=>{let t=Y(new URLSearchParams(L)),n=N.sortBy===e&&N.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),J(t,`push`)};s.addEventListener(`click`,e=>{let t=e.target instanceof Element?G(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&s.tHead?.contains(t)&&at(t.dataset.sortKey??``)}),s.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?G(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&s.tHead?.contains(t)&&(e.preventDefault(),at(t.dataset.sortKey??``))});let X=()=>{ue(s),pe(s);let e=D?{selected:N.total,total:N.total,allMatching:D}:{selected:b.size,total:N.total};s.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};y&&(le(s,(e,t)=>{for(let n of e){let e=G(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?b.add(e):b.delete(e))}t||(D=!1)}),s.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.wui-select-cell .form-check-input:not(:disabled)`)){if(t.checked||(D=!1),s.tHead?.contains(t))for(let e of U(M,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let n=W(e,`.${E} .form-check-input:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?b.add(e.dataset.rowKey):b.delete(e.dataset.rowKey))}else if(G(t,`tr`,HTMLTableRowElement)?.classList.contains(`wui-group-row`)){let e=G(t,`tr`,HTMLTableRowElement);for(let n=e?.nextElementSibling;n instanceof HTMLTableRowElement&&!n.matches(`tr.wui-group-row`);n=n.nextElementSibling){let e=W(n,`.${E} .form-check-input:not(:disabled)`,HTMLInputElement),r=n.dataset.rowKey;e&&r&&(e.checked=t.checked,t.checked?b.add(r):b.delete(r))}}else{let e=G(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?b.add(e):b.delete(e)}X()}})),u&&(u.addEventListener(`click`,e=>{let t=e.target instanceof Element?G(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),J(be(t.getAttribute(`href`)??``),`push`))}),u.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),J(be(t.value),`push`))}));let Z=()=>{if(!f.searchInput)return null;let e=W(document,f.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?W(e,`input`,HTMLInputElement):null},Q=()=>n.isConnected?!0:(ge.abort(),clearTimeout(ye??void 0),!1),ot=(e,t)=>{let n=[...e.elements].filter(Ie),r=/* @__PURE__ */ new Set;for(let e of n)e.name&&!Re(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!Le(e)){if(e instanceof HTMLInputElement&&e.matches(`input[type="hidden"][data-wui-carried]`))r.has(e.name)||i.push([e.name,e.value]);else if(e instanceof HTMLInputElement&&e.matches(`input[type=checkbox], input[type=radio]`))e.checked&&i.push([e.name,e.value]);else if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.matches(`[type=submit], [type=button], [type=reset], [type=image], [type=file]`)||i.push([e.name,e.value]);else if(e instanceof HTMLSelectElement)for(let t of e.selectedOptions)i.push([e.name,t.value])}return(t instanceof HTMLButtonElement||t instanceof HTMLInputElement)&&t.name&&!t.disabled&&i.push([t.name,t.value]),i},st=(e,t)=>{let n=new Set([...e.elements].filter(Ie).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&se.includes(e);for(let[e,t]of L)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of ot(e,t))a===``||i(n)||v.has(n)||r.append(n,a);let a=Z();if(a){r.delete(ce);let e=a.value.trim();e&&r.set(ce,e)}return J(r,`push`)},ct=e=>f.filtersForm&&e.closest?.(f.filtersForm)||f.filtersRegion&&e.closest?.(f.filtersRegion)||null;document.addEventListener(`submit`,e=>{Q()&&f.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(f.filtersForm)&&(e.preventDefault(),st(e.target,e.submitter))},A),document.addEventListener(`change`,e=>{if(!Q()||!f.filtersForm||!(e.target instanceof Element))return;let t=G(e.target,f.filtersForm,HTMLFormElement);!t||e.target===Z()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||st(t)},A);let lt=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of U(e,`input[name]:not([type=hidden])`,HTMLInputElement))if(r.type===`checkbox`)r.checked=t.getAll(r.name).includes(r.value);else if(r.type===`radio`){let e=n(r.name)===r.value;if(r.checked===e)continue;r.checked=e,e&&r.dispatchEvent(new Event(`change`))}else r.value!==n(r.name)&&(r.value=n(r.name),r.dispatchEvent(new Event(`input`,{bubbles:!0})));for(let r of U(e,`select[name]`,HTMLSelectElement))if(!r.multiple)r.value=n(r.name);else for(let e of r.options)e.selected=t.getAll(r.name).includes(e.value);for(let r of[...e.querySelectorAll(`wui-select[name]`)].filter(ze)){let e=r.getAttribute(`name`)??``;r.value=r.mode===`multiple`||r.mode===`tag`?t.getAll(e):n(e)}for(let t of e.querySelectorAll(`wui-date-range`)){let e=t.getAttribute(`start-name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!Q())return;let t=e.target instanceof Element?G(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!ct(t)||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let n=new URL(t.getAttribute(`href`)??``,window.location.href);if(n.origin!==window.location.origin||n.pathname!==window.location.pathname)return;e.preventDefault();let r=Y(be(n.href));lt(t.closest(`form`),r),He(t.closest(`form`),r),J(r,`push`)},A),document.addEventListener(`input`,e=>{if(!Q())return;let t=Z();t&&e.target===t&&(clearTimeout(ye??void 0),ye=setTimeout(()=>{if(!Q())return;let e=Y(new URLSearchParams(L)),n=t.value.trim();n?e.set(ce,n):e.delete(ce),e.toString()!==L.toString()&&J(e,`replace`)},300))},A),f.urlState&&window.addEventListener(`popstate`,()=>{if(!Q())return;let e=F(window.location.search),t=Z();t&&(t.value=e.get(`search`)??``),He(Qe(),e),J(e,`none`)},A),l?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&P&&J(P.query,P.mode)});let ut=e=>[...M.rows].find(t=>t.dataset.rowKey===e)??null,dt=e=>{if(!e?.trim())return null;let t=o(`<table><tbody>${e}</tbody></table>`);if(t.querySelector(`tbody[data-wui-rows]`))return null;let n=U(t,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},ft=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let i=[];for(let n of e){let e=n===r?t:ut(n.dataset.rowKey);e&&(V(e),e.replaceWith(n),i.push(n))}return Oe(i),O().refresh(a),r},pt=e=>e.message||(e.kind===`forbidden`?H().actionForbiddenMessage:H().actionFailedMessage),$=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&S(e,null)},mt=async({url:e,method:r=`POST`,body:i,key:o,row:s}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let c=o==null,u=c?null:ut(String(o));if(!c&&!u)throw Error(`saveRow found no row with data-row-key="${o}" on this page.`);let d=B().filter(e=>!e.classList.contains(E)),f=s===void 0?u??qe(Math.max(1,d.length),d):t(s,HTMLTableRowElement,"saveRow's `row` is required to be a row element: the <tr> as it will read, not its HTML.");u&&f!==u?u.replaceWith(f):u||M.insertBefore(f,M.firstChild),f!==u&&Oe([f]),l&&!a.hasAttribute(`data-wui-table-error`)&&(l.hidden=!0),S(f,`saving`);let p=w(f),m=await h(e,{method:r.toUpperCase(),body:i});if(m.kind===`session`)return!1;if(m.ok){if(!j(n)&&_e(m))return $(f),R(`wui:table:saved`,{key:c?null:String(o),added:c,status:m.status}),await k(m,{origin:n}),!0;let e=dt(m.html),t=e&&f.isConnected?ft(e,f,c):null;return t&&z(re(w(t)||p)),Te(m,m.toastVariant||`success`),j(n)||await k(m,{skip:t?n:null,origin:n}),$(f),R(`wui:table:saved`,{key:t?.dataset.rowKey??(c?null:String(o)),added:c,status:m.status}),!0}let g=pt(m),_=f;return u&&f!==u&&f.isConnected?(f.replaceWith(u),_=u):c&&!s&&(f.remove(),_=null,l?.childElementCount&&!M.querySelector(`:scope > tr`)&&(l.hidden=!1)),_?.isConnected&&S(_,`error`,g),m.kind!==`aborted`&&Ve(g,`danger`),z(C(p,g)),R(`wui:table:failed`,{key:c?null:String(o),added:c,status:m.status,kind:m.kind,message:g}),!1},ht=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let r=G(e,`tr`,HTMLTableRowElement),i=r?.dataset.rowKey??null,a=e.dataset.wuiRowAction||``,o=r?w(r):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),r&&S(r,`saving`);let s=await h(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),s.kind===`session`||s.kind===`aborted`)$(r);else if(s.ok&&!j(e)&&_e(s))$(r),R(`wui:table:action`,{action:a,key:i,ok:s.ok,status:s.status}),await k(s,{origin:e});else{if(s.ok){Te(s,s.toastVariant||`success`);let t=r?.isConnected?dt(s.html):null,i=t&&r?ft(t,r,!1):null;i&&z(re(w(i)||o)),j(e)||await k(s,{skip:i?n:null,origin:e}),$(r)}else{let e=pt(s);Ve(e,`danger`),r?.isConnected&&S(r,`error`,e),z(C(o,e))}R(`wui:table:action`,{action:a,key:i,ok:s.ok,status:s.status})}};return s.addEventListener(`click`,e=>{let t=e.target instanceof Element?G(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&M.contains(t)&&!t.disabled&&(e.preventDefault(),ht(t))}),Ee(M),Ae(M),y&&de(s),ke(M),it(),N.pending&&(z(we(N)),nt()),{el:n,reload:async e=>{if(et)return et;let t=e?.quiet===!0;return t&&a.getAttribute(`aria-busy`)===`true`?new Promise((e,t)=>{q.push({resolve:e,reject:t})}):J(L,`none`,{quiet:t})},query:()=>new URLSearchParams(L),setQuery:e=>{let t=new URLSearchParams(L);for(let[n,r]of Object.entries(e??{})){t.delete(n);for(let e of Array.isArray(r)?r:[r])e!=null&&e!==``&&t.append(n,String(e))}return e&&`page`in e||t.delete(`page`),J(t,`push`)},saveRow:mt,setActiveRow:e=>{n.dataset.activeRowKey=e==null?``:String(e),De(U(M,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...b],count:()=>D?N.total:b.size,allMatching:()=>D,selectAllMatching:()=>{if(N.pending)T(`[@webority/ui-elements] select all matching needs the total; the table is still waiting for its count.`);else{D=!0;for(let e of U(M,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let t=W(e,`.${E} .form-check-input`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&b.add(e.dataset.rowKey))}X()}},clear:()=>{D=!1,b.clear();for(let e of U(M,`:scope > tr > .${E} .form-check-input:not(:disabled)`,HTMLInputElement))e.checked=!1;X()}}}}var Je=/* @__PURE__ */ new WeakSet;function Ye(e){let t=e.querySelectorAll?[...e.querySelectorAll(`[data-wui-flash]`)]:[];e instanceof Element&&e.matches(`[data-wui-flash]`)&&t.unshift(e);for(let e of t){let t=e.getAttribute(`data-wui-flash-variant`)||`success`;if(!ge(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${F.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||(e.textContent??``).trim();e.remove(),n&&z(n,t)}}function Xe(e=document){let t=e instanceof Element?e.ownerDocument:e;if(!Je.has(t)){Je.add(t);let e=he();e&&z(e.message,e.variant,e.action)}Ye(e)}var Ze=/* @__PURE__ */ new Set([204,205,304]),Qe=e=>{let t=new Headers;for(let n of e.split(/\r?\n/)){let e=n.indexOf(`:`);e>0&&t.append(n.slice(0,e).trim(),n.slice(e+1).trim())}return t};async function $e(e,t,n={}){if(!(t instanceof FormData))throw TypeError(`wuiUpload: body must be FormData`);let r=n.timeoutMs;if(r!==void 0&&!(Number.isFinite(r)&&r>0))throw TypeError(`wuiUpload: timeoutMs must be a positive number`);let i={Accept:`text/html`,"X-Requested-With":`XMLHttpRequest`,[_]:`1`,...n.headers};if(b(e)){let e=l();e&&(i[e.header]=e.token)}let a=n.signal;return a?.aborted?u(`aborted`):new Promise(o=>{let s=new XMLHttpRequest,c=!1,l,d=()=>s.abort(),f=(e,t=null,n=``)=>{l!==void 0&&clearTimeout(l),a?.removeEventListener(`abort`,d),o(u(e,t,n))};s.upload.onprogress=e=>{n.onProgress?.(e.loaded,e.lengthComputable?e.total:0)},s.onload=()=>{let e=s.status;if(e===0){f(`network`);return}let t=Qe(s.getAllResponseHeaders()),n=v(e,t),r=s.responseText,i=n===`ok`||n===`validation`?r:``;if(e<200||e>599){f(n,null,i);return}let a=new Response(Ze.has(e)?null:r,{status:e,headers:t});f(n,a,i)},s.onerror=()=>f(`network`),s.onabort=()=>{f(a?.aborted?`aborted`:c?`timeout`:`aborted`)},r!==void 0&&(l=setTimeout(()=>{c=!0,s.abort()},r)),a?.addEventListener(`abort`,d,{once:!0}),s.open(`POST`,e,!0);for(let[e,t]of Object.entries(i))s.setRequestHeader(e,t);s.send(t)})}var q=/* @__PURE__ */ new WeakMap;function et(e,t){q.set(e,t)}function tt(e){q.delete(e)}function J(e){let t=e?.closest(`[data-app-shell]`);return(t&&q.get(t))??null}var Y=()=>r(`shell`,a),nt=31536e3;function rt(e,t,n,r){let i=[...e.querySelectorAll(`nav.wui-tabbar a.wui-tabbar-item`)].find(e=>e.getAttribute(`href`)===t);if(!i)throw Error(`setTabCount: no tab bar item links to ${t}.`);let a=i.querySelector(`:scope > .wui-tabbar-badge`);if(n===null||n===0){a?.remove();return}a||(a=document.createElement(`span`),i.append(a)),a.className=`wui-tabbar-badge${r?` tone-${r}`:``}`;let o=e.querySelector(`nav.wui-tabbar`)?.hasAttribute(`data-wui-cap-badges`)===!0;a.textContent=o?it(n):String(n)}var it=e=>e>99?`99+`:String(e),at=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,()=>String(n)),e);function X(e,t,n=document){try{n.cookie=`${e}=${t?`1`:`0`}; Path=/; Max-Age=${nt}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}function Z(e,t,n,r=document){try{let i=`${e}=`,a=r.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(i)),o=new Set(a?a.slice(i.length).split(`.`).filter(Boolean):[]);n?o.add(t):o.delete(t),r.cookie=`${e}=${[...o].join(`.`)}; Path=/; Max-Age=${nt}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}var Q=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},ot=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},st=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],ct=e=>{if(!(e.target instanceof Element))throw Error(`event target is not an element`);return e.target},lt=e=>{let t=e.getAttribute(`href`);if(t===null)throw Error(`search hit has no href`);return t},ut=(e,t)=>{let n=document.createElement(`div`);return n.className=e,n.textContent=t,n},dt=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),ft=(e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}${encodeURIComponent(t)}=${encodeURIComponent(n)}`;function pt(t,r){let i=e(Q(t,`input.search-input`,HTMLInputElement),`search input missing`),a=Q(t,`.wui-topsearch-results`,HTMLElement),s=()=>e(a,`search results missing`),c=Q(t,`.wui-topsearch-open`,HTMLElement),l=Q(t,`[data-wui-topsearch-live]`,HTMLElement),{src:u,param:d=`q`,resultsHref:f}=t.dataset,p=Number(t.dataset.minChars??2),h=Number(t.dataset.debounceMs??250),g=t.dataset.noResultsText??Y().noResultsText,_=t.dataset.resultsCountText??Y().resultsCountText,ee=t.dataset.resultCountText??Y().resultCountText,v=m(),y,b=-1,x=()=>st(s(),`.wui-topsearch-hit`,HTMLElement),te=e=>{let t=x();b=t.length===0?-1:(e+t.length)%t.length,t.forEach((e,t)=>{let n=t===b;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)});let n=b>=0?t[b]:void 0;n?(i.setAttribute(`aria-activedescendant`,n.id),n.scrollIntoView?.({block:`nearest`})):i.removeAttribute(`aria-activedescendant`)},ne=()=>{s().hidden=!0,i.setAttribute(`aria-expanded`,`false`),i.removeAttribute(`aria-activedescendant`),b=-1},re=()=>{s().hidden=!1,i.setAttribute(`aria-expanded`,`true`)},S=e=>{t.classList.toggle(`is-open`,e),c?.setAttribute(`aria-expanded`,e?`true`:`false`)},C=e=>{let n=new CustomEvent(`wui:search:select`,{bubbles:!0,cancelable:!0,detail:{href:e}});t.dispatchEvent(n)&&window.location.assign(e)},w=async e=>{if(t.classList.add(`is-loading`),u===void 0)throw Error(`search has no data-src`);let n=await v.run(ft(u,d,e));if(n.kind!==`aborted`&&n.kind!==`stale`&&n.kind!==`session`){if(t.classList.remove(`is-loading`),n.ok){let e=o(n.html),t=Q(e,`[data-wui-count]`,HTMLElement);s().replaceChildren(e),x().forEach((e,t)=>{e.id=`${s().id}-opt-${t}`});let r=t?Number(t.getAttribute(`data-wui-count`)):x().length;l&&(l.textContent=r===0?g:at(r===1?ee:_,{count:r}))}else s().replaceChildren(ut(`wui-topsearch-empty`,Y().searchUnavailableMessage));b=-1,re()}};i.addEventListener(`input`,()=>{clearTimeout(y);let e=i.value.trim();e.length<p?(v.abort(),t.classList.remove(`is-loading`),s().replaceChildren(),ne()):y=setTimeout(()=>w(e),h)}),i.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(s().hidden||x().length===0)return;e.preventDefault(),te(b+(e.key===`ArrowDown`?1:-1))}else if(n(e)){let t=x(),n=b>=0?t[b]:void 0;!s().hidden&&n?(e.preventDefault(),C(lt(n))):f&&i.value.trim()!==``&&(e.preventDefault(),C(ft(f,d,i.value.trim())))}else e.key===`Escape`&&(s().hidden?t.classList.contains(`is-open`)&&(e.preventDefault(),e.stopPropagation(),S(!1),c?.focus()):(e.preventDefault(),e.stopPropagation(),ne()))}),s().addEventListener(`click`,e=>{let t=ot(ct(e),`.wui-topsearch-hit`,HTMLElement);!t||e.ctrlKey||e.metaKey||e.shiftKey||e.button===1||(e.preventDefault(),C(lt(t)))}),c?.addEventListener(`click`,()=>{let e=!t.classList.contains(`is-open`);S(e),e&&i.focus()});let ie=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||dt(e.target)||(e.preventDefault(),S(!0),i.focus())},T=e=>{e.target instanceof Node&&t.contains(e.target)||(ne(),t.classList.contains(`is-open`)&&S(!1))};document.addEventListener(`keydown`,ie),document.addEventListener(`pointerdown`,T),r.push(()=>{clearTimeout(y),v.abort(),document.removeEventListener(`keydown`,ie),document.removeEventListener(`pointerdown`,T)})}function $(e){let t=[],n=e.dataset.wuiCollapsedCookie;n&&e.addEventListener(`wui:shell:collapse`,e=>{X(n,!!e.detail?.collapsed)});let r=e.dataset.wuiFoldedCookie;r&&e.addEventListener(`wui:shell:nav-fold`,e=>{Z(r,e.detail?.key,!!e.detail?.folded)}),e.addEventListener(`click`,t=>{ct(t).closest(`[data-wui-tabbar-more]`)&&Q(e,`[data-app-shell-menu]`,HTMLElement)?.click()});let i=Q(e,`[data-wui-topsearch]`,HTMLElement);i&&pt(i,t);let a={el:e,setTabCount(t,n,r){rt(e,t,n,r)},get collapsed(){return e.classList.contains(`collapsed`)},set collapsed(t){if(!!t===e.classList.contains(`collapsed`))return;let n=Q(e,`[data-app-shell-collapse]`,HTMLElement);n?n.click():e.classList.toggle(`collapsed`,!!t)}};et(e,a);let o=n=>{if(n.target===e||n.target instanceof Node&&n.target.contains(e)){for(let e of t)e();tt(e),delete e.dataset.wuiPartsWired,document.removeEventListener(`wui:teardown`,o)}};return document.addEventListener(`wui:teardown`,o),a}function mt(e=document){let t=[];e instanceof HTMLElement&&e.matches(`[data-app-shell]`)&&t.push(e),t.push(...st(e,`[data-app-shell]`,HTMLElement));for(let e of t)e.dataset.wuiPartsWired||(e.dataset.wuiPartsWired=`1`,$(e))}function ht(e){let t=ot(e,`[data-app-shell]`,HTMLElement);return t?(J(t)||mt(t),J(t)):null}export{Ae as CONFIRM_DIALOG_ID,Se as CONFIRM_TONES,y as CSRF_META_NAME,g as DEFAULT_CSRF_HEADER,V as DISCARD_EVENT,ye as FLASH_STORAGE_KEY,F as FLASH_VARIANTS,p as HTTP_KINDS,f as TOAST_ACTION_METHODS,L as TOAST_ACTION_MS,s as WUI_HEADERS,Ne as WuiPostError,N as applyRefresh,v as classifyStatus,R as closeRemotePane,c as configureCsrf,B as confirmAction,Ee as createDiscardPrompt,m as createRequestQueue,we as formValues,P as getServerTable,ht as getShell,ke as initDrawerDiscard,Xe as initFlashToasts,be as initRemoteModals,je as initServerActions,Ke as initServerTables,mt as initShellParts,I as initUnsavedChanges,Me as loadRemoteDrawer,Pe as loadRemoteModal,xe as loadRemotePane,o as parseServerHtml,d as parseToastAction,Ce as postAction,l as readCsrf,k as refreshAfter,A as refreshRegions,_e as reloadsPage,De as resetUnsavedChanges,Oe as runToastAction,Te as showResultToast,z as showToast,ee as timeoutFromAttribute,h as wuiFetch,$e as wuiUpload};
|
|
1
|
+
import{i as e,n as t}from"./dom-DMQu--xV.js";import{n}from"./imeSafeEnter-DeO_3lXy.js";import{r,t as i}from"./textStore-DBplASiZ.js";import{t as a}from"./shell.g-BhC11Oe3.js";import{t as o}from"./serverHtml-BC6tAyAl.js";import{a as s,c,d as l,g as u,h as d,i as f,l as p,m as ee,n as m,p as h,s as g,t as _}from"./wuiHttp-8CYWEbRz.js";import{n as te,t as ne}from"./buttonClass-C8BRtTk8.js";import{E as v,M as y,N as b,b as x,k as S,y as C}from"./dataTable-C0q14bkP.js";import{n as w,t as re}from"./devWarn-DXdRWZs3.js";import{t as ie}from"./iconGlyphs.g-a9FtjPXh.js";import{LIST_QUERY_RESERVED as ae,SEARCH_PARAM as oe}from"./listQuery.js";import{a as se,c as ce,i as le,n as T,r as ue,s as de}from"./tableSelect-juA3KcQh.js";import{t as fe}from"./dataTable.g-1PsmN1Nj.js";import{t as pe}from"./httpFailure.g-DjZzGxPj.js";import{S as E,_ as D,b as O,c as me,d as he,g as k,h as ge,i as _e,m as ve,n as A,p as ye,v as j,y as M}from"./refreshAfter-DhYgWXmQ.js";import{S as N,_ as be,a as xe,b as Se,c as P,d as Ce,f as we,g as F,h as Te,i as I,l as L,m as R,n as Ee,o as z,p as De,r as Oe,s as ke,t as Ae,u as je,v as B,x as Me,y as Ne}from"./drawerDiscard-CBUOklnA.js";var V=()=>r(`dataTable`,fe),Pe=5,Fe=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Ie=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,Le=e=>Fe(e)&&`type`in e&&e.type===`hidden`,H=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),U=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},W=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Re=e=>e.localName===`wui-select`,G=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},ze=e=>({total:G(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:G(e.dataset.page,1),pageSize:G(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`,pending:e.dataset.totalPending===`true`,rowCount:G(e.dataset.rowCount,0)}),Be=(e,t)=>{e&&D().toast(e,{variant:t})},Ve=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!Le(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!ae.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of H(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},He=new Intl.NumberFormat(`en-IN`),Ue=(e,t)=>t?`${He.format(e)}+`:He.format(e),We=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?U(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Ue(t,n))};function Ge(e=document){let t=H(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if(ve(e))continue;let t=Ke(e);ge(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function Ke(n){let a=U(n,`.table-wrap`,HTMLElement),s=a?U(a,`:scope > table`,HTMLTableElement):null,c=n.dataset.src;if(!a||!s||!c)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let l=U(a,`:scope > [data-wui-table-state]`,HTMLElement),u=U(n,`[data-wui-table-pager]`,HTMLElement),d=U(n,`[data-wui-table-status]`,HTMLElement),f={urlState:n.dataset.urlState!==`false`,filtersForm:n.dataset.filtersForm||null,filtersRegion:n.dataset.filtersRegion||null,searchInput:n.dataset.searchInput||null,loadingText:n.dataset.loadingText||V().loadingText,errorText:n.dataset.errorText||V().errorText,timeoutMs:h(n.getAttribute(`data-wui-timeout`))??3e4},m=new URL(c,window.location.href),g=n.dataset.totalSrc||null,_=g===null?null:new URL(g,window.location.href),fe=/* @__PURE__ */ new Set([...m.searchParams.keys(),..._?.searchParams.keys()??[]]),E=s.hasAttribute(`data-app-datatable-selectable`),O=/* @__PURE__ */ new Set,k=!1,ge=p(),ve=new AbortController,A={signal:ve.signal},ye=U(s,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),j=e(ye,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),M=ze(j),N=null,be=null,xe=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))fe.has(n)||t.append(n,r);return t},Se=e=>xe(new URL(e,window.location.href).search),P=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},Ce=(e,t)=>{let n=new URL(e.href);for(let[e,r]of t)fe.has(e)||n.searchParams.append(e,r);return n.origin===window.location.origin?`${n.pathname}${n.search}`:n.href},we=e=>Ce(m,e),F=(e,t)=>{let n=new URLSearchParams(e);return n.has(`page`)&&n.set(`page`,String(t.page)),n.has(`pageSize`)&&n.set(`pageSize`,String(t.pageSize)),n.has(`sortBy`)?t.sortBy?(n.set(`sortBy`,t.sortBy),n.set(`sortOrder`,t.sortOrder)):(n.delete(`sortBy`),n.delete(`sortOrder`)):n.delete(`sortOrder`),n},I=F(f.urlState?xe(window.location.search):new URLSearchParams,M);f.urlState&&P(I)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,P(I));let L=(e,t)=>a.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),R=e=>{d&&(d.textContent=e)},Ee=e=>{if(e.pending)return e.rowCount===0?V().emptyLabel:i(V().pageTextPending,{page:e.page});if(e.total===0)return V().emptyLabel;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Ue(e.total,!0):`${e.total}`;return i(e.total===1?V().pageTextOne:V().pageTextOther,{page:e.page,pages:t,total:n})},z=()=>H(s,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),De=e=>{if(E&&H(e,`:scope > tr:not(.wui-group-row, .wui-virtual-spacer)`,HTMLTableRowElement).some(e=>!e.dataset.rowKey))throw Error(`A selectable server-paged table needs data-row-key on every row, so a selection can span pages.`)},Oe=e=>{let t=n.dataset.activeRowKey;if(t!==void 0)for(let n of e){let e=n.classList.contains(`wui-row-active`),r=t!==``&&n.dataset.rowKey===t;n.classList.toggle(`wui-row-active`,r),r?n.setAttribute(`aria-current`,`true`):e&&n.removeAttribute(`aria-current`)}},ke=e=>{if(E){ue(e);for(let t of e){let e=U(t,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement);e&&(k&&O.add(t.dataset.rowKey),e.checked=O.has(t.dataset.rowKey))}ce(s)}Oe(e);let t=z();if(s.classList.contains(`wui-table-stack`))for(let n of e)[...n.cells].forEach((e,n)=>{let r=t[n]?.textContent?.trim();r&&!e.hasAttribute(`data-label`)&&e.setAttribute(`data-label`,r)});t.forEach((t,n)=>{if(t.classList.contains(`wui-col-hidden`))for(let t of e)t.cells[n]?.classList.add(`wui-col-hidden`)})},Ae=e=>ke(H(e,`:scope > tr`,HTMLTableRowElement)),je=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},B=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),Me=(e,t)=>{if(!l)return;let n=U(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);B(l),(t.pending?t.rowCount:t.total)===0&&n?(l.replaceChildren(n.content.cloneNode(!0)),l.hidden=!1):(l.replaceChildren(),l.hidden=!0)},Ne=e=>{u&&(B(u),u.replaceChildren(...e?[e.content.cloneNode(!0)]:[]),u.hidden=!1)},He=e=>{let t=f.filtersRegion&&e?U(document,f.filtersRegion,HTMLElement):null;return t&&e&&(B(t),t.replaceChildren(e.content.cloneNode(!0))),t},Ge=0,Ke=e=>{let t=ze(e);t.pending&&Object.assign(t,{total:M.total,totalCapped:M.totalCapped});let n=t.sortBy!==M.sortBy||t.sortOrder!==M.sortOrder?C(j.rows):null;Ne(U(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement)),Me(e,t);let r=He(U(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement));je(e),B(j),s.replaceChild(e,j),j=e,Ge+=1;let i=k&&t.total!==M.total;return M=t,i&&(k=!1),a.removeAttribute(`data-wui-table-error`),Ae(e),rt(),v(e.rows,n),i&&Z(),r},qe=e=>{let t=U(o(`<table>${e}</table>`),`tbody[data-wui-rows]`,HTMLTableSectionElement);return t&&De(t),t?document.importNode(t,!0):null},Je=(e,t=z())=>{let n=document.createElement(`tr`);for(let r=0;r<e;r++){let e=t[r],i=e?.classList.contains(`text-center`),a=!i&&(e?.classList.contains(`num`)||e?.classList.contains(`text-end`)||e?.classList.contains(`wui-cell-end`)),o=document.createElement(`td`);i?o.classList.add(`text-center`):a&&o.classList.add(e?.classList.contains(`num`)?`num`:`wui-cell-end`);let s=document.createElement(`span`);s.className=`skeleton`,s.setAttribute(`aria-hidden`,`true`);let c=i?44:a?56:60;s.style.cssText=`display:block;width:${c}%;height:12px;border-radius:6px`,o.append(s),n.append(o)}return n},Ye=()=>{if(j.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,z().length);j.replaceChildren(...Array.from({length:Pe},()=>{let t=Je(e);return t.setAttribute(`data-wui-skeleton`,``),t})),a.removeAttribute(`data-wui-table-error`),l&&(l.hidden=!0)},K=e=>{e?(a.setAttribute(`aria-busy`,`true`),Ye()):a.removeAttribute(`aria-busy`)},Xe=e=>e===`forbidden`?V().forbiddenMessage:e===`networkCheck`?r(`httpFailure`,pe).networkCheckText:e===`network`?V().networkMessage:e===`timeout`?V().timeoutMessage:f.errorText,Ze=e=>{let t=Xe(e);if(a.setAttribute(`data-wui-table-error`,e),u&&(u.hidden=!0),l){let n=document.createElement(`div`);n.className=`empty-state wui-empty-state-table wui-table-error`,n.setAttribute(`role`,`alert`);let r=document.createElement(`span`);r.className=`empty-state-icon`;let i=ie(e===`forbidden`?`lock`:`alert-circle`,{size:24});i&&r.replaceChildren(i);let a=document.createElement(`div`);a.className=`empty-state-title`,a.textContent=t;let o=document.createElement(`div`);o.className=`empty-state-action`;let s=document.createElement(`button`);s.type=`button`,s.className=te(`primary`,`outline`,`sm`),s.dataset.wui=ne,s.setAttribute(`data-wui-table-retry`,``),s.textContent=V().retryLabel,o.append(s),n.append(r,a,o),B(l),l.replaceChildren(n),l.hidden=!1}R(t)},Qe=()=>f.filtersForm?U(document,f.filtersForm,HTMLFormElement):null,q=async(e,t=`none`,{quiet:r=!1}={})=>{let i=new URLSearchParams(e);r||(N={query:i,mode:t},K(!0),R(f.loadingText)),L(`wui:table:loading`,{query:i.toString()});let o=await ge.run(we(i),{timeoutMs:f.timeoutMs});if(o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return o;r||K(!1);let s=null;if(o.ok)try{s=qe(o.html)}catch(e){re(e)}if(!o.ok||!s){let e=o.ok?`server`:o.kind;return r?w(`A quiet server table refresh failed; the rows on screen are kept.`,e):Ze(e),L(`wui:table:error`,{status:o.status,kind:e,message:Xe(e)}),o}let c=Ke(s);return I=F(i,M),Ve(Qe(),I),f.urlState&&t===`push`?window.history.pushState(window.history.state,``,P(I)):f.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,P(I)),r||R(Ee(M)),D().refresh(a),c&&D().refresh(c),M.pending?nt():We(n,M.total,M.totalCapped),L(`wui:table:loaded`,{...M,query:I.toString()}),o},J=[],$e=null,et=()=>{if(J.length===0||a.getAttribute(`aria-busy`)===`true`)return;let e=J;J=[],q(I,`none`,{quiet:!0}).then(t=>{for(let n of e)n.resolve(t)},t=>{for(let n of e)n.reject(t)})},Y=async(e,t=`none`,n={})=>{let r;try{r=await q(e,t,n)}catch(e){let t=J;J=[];for(let n of t)n.reject(e);throw e}r.kind===`session`&&($e=r);let i=r.kind===`aborted`&&a.getAttribute(`aria-busy`)===`true`;if(r.kind===`session`||r.kind===`aborted`&&!i){let e=J;J=[];for(let t of e)t.resolve(r)}return et(),r},tt=e=>(e.delete(`page`),e),nt=()=>{if(!_||!M.pending)return;let e=Ge;ee(Ce(_,I),{timeoutMs:f.timeoutMs}).then(t=>{if(e!==Ge)return;if(!t.ok){w(`[@webority/ui-elements] A server table's total did not load; its pager keeps Previous and Next.`,t.kind);return}let r=U(o(t.html),`div[data-wui-total]`,HTMLElement);if(!r){w(`[@webority/ui-elements] A server table's count answer has no div[data-wui-total]; its pager keeps Previous and Next.`);return}if(G(r.dataset.page,-1)!==M.page||G(r.dataset.pageSize,-1)!==M.pageSize)return;let i=G(r.dataset.total,-1);if(i<0){w(`[@webority/ui-elements] A server table's count answer has no whole data-total; its pager keeps Previous and Next.`);return}let a=r.dataset.totalCapped===`true`,s=k&&i!==M.total;M={...M,total:i,totalCapped:a,pending:!1},s&&(k=!1);let c=U(r,`:scope > template[data-wui-pager]`,HTMLTemplateElement);c&&Ne(c);let l=He(U(r,`:scope > template[data-wui-filters]`,HTMLTemplateElement));l&&D().refresh(l),We(n,M.total,M.totalCapped),R(Ee(M)),s&&Z(),L(`wui:table:total`,{total:i,totalCapped:a})})},X=()=>H(s,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),rt=()=>{for(let e of X()){let t=e.dataset.sortKey===M.sortBy;e.setAttribute(`aria-sort`,t?M.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of X())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=e.classList.contains(`num`)||e.classList.contains(`text-end`),n=document.createElement(`span`);n.className=t?`sort-icon wui-sort-lead`:`sort-icon`;let r=ie(`chevrons-up-down`,{size:14});r&&n.replaceChildren(r),t?e.prepend(n):e.append(n)}let it=e=>{let t=tt(new URLSearchParams(I)),n=M.sortBy===e&&M.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),Y(t,`push`)};s.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&s.tHead?.contains(t)&&it(t.dataset.sortKey??``)}),s.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?W(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&s.tHead?.contains(t)&&(e.preventDefault(),it(t.dataset.sortKey??``))});let Z=()=>{ce(s),de(s);let e=k?{selected:M.total,total:M.total,allMatching:k}:{selected:O.size,total:M.total};s.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};E&&(se(s,(e,t)=>{for(let n of e){let e=W(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?O.add(e):O.delete(e))}t||(k=!1)}),s.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.wui-select-cell .form-check-input:not(:disabled)`)){if(t.checked||(k=!1),s.tHead?.contains(t))for(let e of H(j,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let n=U(e,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?O.add(e.dataset.rowKey):O.delete(e.dataset.rowKey))}else if(W(t,`tr`,HTMLTableRowElement)?.classList.contains(`wui-group-row`)){let e=W(t,`tr`,HTMLTableRowElement);for(let n=e?.nextElementSibling;n instanceof HTMLTableRowElement&&!n.matches(`tr.wui-group-row`);n=n.nextElementSibling){let e=U(n,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement),r=n.dataset.rowKey;e&&r&&(e.checked=t.checked,t.checked?O.add(r):O.delete(r))}}else{let e=W(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?O.add(e):O.delete(e)}Z()}})),u&&(u.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),Y(Se(t.getAttribute(`href`)??``),`push`))}),u.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),Y(Se(t.value),`push`))}));let Q=()=>{if(!f.searchInput)return null;let e=U(document,f.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?U(e,`input`,HTMLInputElement):null},$=()=>n.isConnected?!0:(ve.abort(),clearTimeout(be??void 0),!1),at=(e,t)=>{let n=[...e.elements].filter(Fe),r=/* @__PURE__ */ new Set;for(let e of n)e.name&&!Le(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!Ie(e)){if(e instanceof HTMLInputElement&&e.matches(`input[type="hidden"][data-wui-carried]`))r.has(e.name)||i.push([e.name,e.value]);else if(e instanceof HTMLInputElement&&e.matches(`input[type=checkbox], input[type=radio]`))e.checked&&i.push([e.name,e.value]);else if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.matches(`[type=submit], [type=button], [type=reset], [type=image], [type=file]`)||i.push([e.name,e.value]);else if(e instanceof HTMLSelectElement)for(let t of e.selectedOptions)i.push([e.name,t.value])}return(t instanceof HTMLButtonElement||t instanceof HTMLInputElement)&&t.name&&!t.disabled&&i.push([t.name,t.value]),i},ot=(e,t)=>{let n=new Set([...e.elements].filter(Fe).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&ae.includes(e);for(let[e,t]of I)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of at(e,t))a===``||i(n)||fe.has(n)||r.append(n,a);let a=Q();if(a){r.delete(oe);let e=a.value.trim();e&&r.set(oe,e)}return Y(r,`push`)},st=e=>f.filtersForm&&e.closest?.(f.filtersForm)||f.filtersRegion&&e.closest?.(f.filtersRegion)||null;document.addEventListener(`submit`,e=>{$()&&f.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(f.filtersForm)&&(e.preventDefault(),ot(e.target,e.submitter))},A),document.addEventListener(`change`,e=>{if(!$()||!f.filtersForm||!(e.target instanceof Element))return;let t=W(e.target,f.filtersForm,HTMLFormElement);!t||e.target===Q()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||ot(t)},A);let ct=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of H(e,`input[name]:not([type=hidden])`,HTMLInputElement))if(r.type===`checkbox`)r.checked=t.getAll(r.name).includes(r.value);else if(r.type===`radio`){let e=n(r.name)===r.value;if(r.checked===e)continue;r.checked=e,e&&r.dispatchEvent(new Event(`change`))}else r.value!==n(r.name)&&(r.value=n(r.name),r.dispatchEvent(new Event(`input`,{bubbles:!0})));for(let r of H(e,`select[name]`,HTMLSelectElement))if(!r.multiple)r.value=n(r.name);else for(let e of r.options)e.selected=t.getAll(r.name).includes(e.value);for(let r of[...e.querySelectorAll(`wui-select[name]`)].filter(Re)){let e=r.getAttribute(`name`)??``;r.value=r.mode===`multiple`||r.mode===`tag`?t.getAll(e):n(e)}for(let t of e.querySelectorAll(`wui-date-range`)){let e=t.getAttribute(`start-name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!$())return;let t=e.target instanceof Element?W(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!st(t)||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let n=new URL(t.getAttribute(`href`)??``,window.location.href);if(n.origin!==window.location.origin||n.pathname!==window.location.pathname)return;e.preventDefault();let r=tt(Se(n.href));ct(t.closest(`form`),r),Ve(t.closest(`form`),r),Y(r,`push`)},A),document.addEventListener(`input`,e=>{if(!$())return;let t=Q();t&&e.target===t&&(clearTimeout(be??void 0),be=setTimeout(()=>{if(!$())return;let e=tt(new URLSearchParams(I)),n=t.value.trim();n?e.set(oe,n):e.delete(oe),e.toString()!==I.toString()&&Y(e,`replace`)},300))},A),f.urlState&&window.addEventListener(`popstate`,()=>{if(!$())return;let e=xe(window.location.search),t=Q();t&&(t.value=e.get(`search`)??``),Ve(Qe(),e),Y(e,`none`)},A),l?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&N&&Y(N.query,N.mode)});let lt=e=>[...j.rows].find(t=>t.dataset.rowKey===e)??null,ut=e=>{if(!e?.trim())return null;let t=o(`<table><tbody>${e}</tbody></table>`);if(t.querySelector(`tbody[data-wui-rows]`))return null;let n=H(t,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},dt=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let i=[];for(let n of e){let e=n===r?t:lt(n.dataset.rowKey);e&&(B(e),e.replaceWith(n),i.push(n))}return ke(i),D().refresh(a),r},ft=e=>e.message||(e.kind===`forbidden`?V().actionForbiddenMessage:V().actionFailedMessage),pt=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&b(e,null)},mt=async({url:e,method:r=`POST`,body:i,key:o,row:s}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let c=o==null,u=c?null:lt(String(o));if(!c&&!u)throw Error(`saveRow found no row with data-row-key="${o}" on this page.`);let d=z().filter(e=>!e.classList.contains(T)),f=s===void 0?u??Je(Math.max(1,d.length),d):t(s,HTMLTableRowElement,"saveRow's `row` is required to be a row element: the <tr> as it will read, not its HTML.");u&&f!==u?u.replaceWith(f):u||j.insertBefore(f,j.firstChild),f!==u&&ke([f]),l&&!a.hasAttribute(`data-wui-table-error`)&&(l.hidden=!0),b(f,`saving`);let p=S(f),m=await ee(e,{method:r.toUpperCase(),body:i});if(m.kind===`session`)return!1;if(m.ok){if(!_e(n)&&he(m))return pt(f),L(`wui:table:saved`,{key:c?null:String(o),added:c,status:m.status}),await me(m,{origin:n}),!0;let e=ut(m.html),t=e&&f.isConnected?dt(e,f,c):null;return t&&R(y(S(t)||p)),Te(m,m.toastVariant||`success`),_e(n)||await me(m,{skip:t?n:null,origin:n}),pt(f),L(`wui:table:saved`,{key:t?.dataset.rowKey??(c?null:String(o)),added:c,status:m.status}),!0}let h=ft(m),g=f;return u&&f!==u&&f.isConnected?(f.replaceWith(u),g=u):c&&!s&&(f.remove(),g=null,l?.childElementCount&&!j.querySelector(`:scope > tr`)&&(l.hidden=!1)),g?.isConnected&&b(g,`error`,h),m.kind!==`aborted`&&Be(h,`danger`),R(x(p,h)),L(`wui:table:failed`,{key:c?null:String(o),added:c,status:m.status,kind:m.kind,message:h}),!1},ht=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let r=W(e,`tr`,HTMLTableRowElement),i=r?.dataset.rowKey??null,a=e.dataset.wuiRowAction||``,o=r?S(r):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),r&&b(r,`saving`);let s=await ee(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),s.kind===`session`||s.kind===`aborted`)pt(r);else if(s.ok&&!_e(e)&&he(s))pt(r),L(`wui:table:action`,{action:a,key:i,ok:s.ok,status:s.status}),await me(s,{origin:e});else{if(s.ok){Te(s,s.toastVariant||`success`);let t=r?.isConnected?ut(s.html):null,i=t&&r?dt(t,r,!1):null;i&&R(y(S(i)||o)),_e(e)||await me(s,{skip:i?n:null,origin:e}),pt(r)}else{let e=ft(s);Be(e,`danger`),r?.isConnected&&b(r,`error`,e),R(x(o,e))}L(`wui:table:action`,{action:a,key:i,ok:s.ok,status:s.status})}};return s.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&j.contains(t)&&!t.disabled&&(e.preventDefault(),ht(t))}),De(j),je(j),E&&le(s),Ae(j),rt(),M.pending&&(R(Ee(M)),nt()),{el:n,reload:async e=>{if($e)return $e;let t=e?.quiet===!0;return t&&a.getAttribute(`aria-busy`)===`true`?new Promise((e,t)=>{J.push({resolve:e,reject:t})}):Y(I,`none`,{quiet:t})},query:()=>new URLSearchParams(I),setQuery:e=>{let t=new URLSearchParams(I);for(let[n,r]of Object.entries(e??{})){t.delete(n);for(let e of Array.isArray(r)?r:[r])e!=null&&e!==``&&t.append(n,String(e))}return e&&`page`in e||t.delete(`page`),Y(t,`push`)},saveRow:mt,setActiveRow:e=>{n.dataset.activeRowKey=e==null?``:String(e),Oe(H(j,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...O],count:()=>k?M.total:O.size,allMatching:()=>k,selectAllMatching:()=>{if(M.pending)w(`[@webority/ui-elements] select all matching needs the total; the table is still waiting for its count.`);else{k=!0;for(let e of H(j,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let t=U(e,`.${T} .form-check-input`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&O.add(e.dataset.rowKey))}Z()}},clear:()=>{k=!1,O.clear();for(let e of H(j,`:scope > tr > .${T} .form-check-input:not(:disabled)`,HTMLInputElement))e.checked=!1;Z()}}}}var qe=/* @__PURE__ */ new WeakSet;function Je(e){let t=e.querySelectorAll?[...e.querySelectorAll(`[data-wui-flash]`)]:[];e instanceof Element&&e.matches(`[data-wui-flash]`)&&t.unshift(e);for(let e of t){let t=e.getAttribute(`data-wui-flash-variant`)||`success`;if(!O(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${M.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||(e.textContent??``).trim();e.remove(),n&&F(n,t)}}function Ye(e=document){let t=e instanceof Element?e.ownerDocument:e;if(!qe.has(t)){qe.add(t);let e=E();e&&F(e.message,e.variant,e.action)}Je(e)}var K=/* @__PURE__ */ new WeakMap;function Xe(e,t){K.set(e,t)}function Ze(e){K.delete(e)}function Qe(e){let t=e?.closest(`[data-app-shell]`);return(t&&K.get(t))??null}var q=()=>r(`shell`,a),J=31536e3;function $e(e,t,n,r){let i=[...e.querySelectorAll(`nav.wui-tabbar a.wui-tabbar-item`)].find(e=>e.getAttribute(`href`)===t);if(!i)throw Error(`setTabCount: no tab bar item links to ${t}.`);let a=i.querySelector(`:scope > .wui-tabbar-badge`);if(n===null||n===0){a?.remove();return}a||(a=document.createElement(`span`),i.append(a)),a.className=`wui-tabbar-badge${r?` tone-${r}`:``}`;let o=e.querySelector(`nav.wui-tabbar`)?.hasAttribute(`data-wui-cap-badges`)===!0;a.textContent=o?et(n):String(n)}var et=e=>e>99?`99+`:String(e),Y=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,()=>String(n)),e);function tt(e,t,n=document){try{n.cookie=`${e}=${t?`1`:`0`}; Path=/; Max-Age=${J}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}function nt(e,t,n,r=document){try{let i=`${e}=`,a=r.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(i)),o=new Set(a?a.slice(i.length).split(`.`).filter(Boolean):[]);n?o.add(t):o.delete(t),r.cookie=`${e}=${[...o].join(`.`)}; Path=/; Max-Age=${J}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}var X=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},rt=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},it=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],Z=e=>{if(!(e.target instanceof Element))throw Error(`event target is not an element`);return e.target},Q=e=>{let t=e.getAttribute(`href`);if(t===null)throw Error(`search hit has no href`);return t},$=(e,t)=>{let n=document.createElement(`div`);return n.className=e,n.textContent=t,n},at=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),ot=(e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}${encodeURIComponent(t)}=${encodeURIComponent(n)}`;function st(t,r){let i=e(X(t,`input.search-input`,HTMLInputElement),`search input missing`),a=X(t,`.wui-topsearch-results`,HTMLElement),s=()=>e(a,`search results missing`),c=X(t,`.wui-topsearch-open`,HTMLElement),l=X(t,`[data-wui-topsearch-live]`,HTMLElement),{src:u,param:d=`q`,resultsHref:f}=t.dataset,ee=Number(t.dataset.minChars??2),m=Number(t.dataset.debounceMs??250),h=t.dataset.noResultsText??q().noResultsText,g=t.dataset.resultsCountText??q().resultsCountText,_=t.dataset.resultCountText??q().resultCountText,te=p(),ne,v=-1,y=()=>it(s(),`.wui-topsearch-hit`,HTMLElement),b=e=>{let t=y();v=t.length===0?-1:(e+t.length)%t.length,t.forEach((e,t)=>{let n=t===v;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)});let n=v>=0?t[v]:void 0;n?(i.setAttribute(`aria-activedescendant`,n.id),n.scrollIntoView?.({block:`nearest`})):i.removeAttribute(`aria-activedescendant`)},x=()=>{s().hidden=!0,i.setAttribute(`aria-expanded`,`false`),i.removeAttribute(`aria-activedescendant`),v=-1},S=()=>{s().hidden=!1,i.setAttribute(`aria-expanded`,`true`)},C=e=>{t.classList.toggle(`is-open`,e),c?.setAttribute(`aria-expanded`,e?`true`:`false`)},w=e=>{let n=new CustomEvent(`wui:search:select`,{bubbles:!0,cancelable:!0,detail:{href:e}});t.dispatchEvent(n)&&window.location.assign(e)},re=async e=>{if(t.classList.add(`is-loading`),u===void 0)throw Error(`search has no data-src`);let n=await te.run(ot(u,d,e));if(n.kind!==`aborted`&&n.kind!==`stale`&&n.kind!==`session`){if(t.classList.remove(`is-loading`),n.ok){let e=o(n.html),t=X(e,`[data-wui-count]`,HTMLElement);s().replaceChildren(e),y().forEach((e,t)=>{e.id=`${s().id}-opt-${t}`});let r=t?Number(t.getAttribute(`data-wui-count`)):y().length;l&&(l.textContent=r===0?h:Y(r===1?_:g,{count:r}))}else s().replaceChildren($(`wui-topsearch-empty`,q().searchUnavailableMessage));v=-1,S()}};i.addEventListener(`input`,()=>{clearTimeout(ne);let e=i.value.trim();e.length<ee?(te.abort(),t.classList.remove(`is-loading`),s().replaceChildren(),x()):ne=setTimeout(()=>re(e),m)}),i.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(s().hidden||y().length===0)return;e.preventDefault(),b(v+(e.key===`ArrowDown`?1:-1))}else if(n(e)){let t=y(),n=v>=0?t[v]:void 0;!s().hidden&&n?(e.preventDefault(),w(Q(n))):f&&i.value.trim()!==``&&(e.preventDefault(),w(ot(f,d,i.value.trim())))}else e.key===`Escape`&&(s().hidden?t.classList.contains(`is-open`)&&(e.preventDefault(),e.stopPropagation(),C(!1),c?.focus()):(e.preventDefault(),e.stopPropagation(),x()))}),s().addEventListener(`click`,e=>{let t=rt(Z(e),`.wui-topsearch-hit`,HTMLElement);!t||e.ctrlKey||e.metaKey||e.shiftKey||e.button===1||(e.preventDefault(),w(Q(t)))}),c?.addEventListener(`click`,()=>{let e=!t.classList.contains(`is-open`);C(e),e&&i.focus()});let ie=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||at(e.target)||(e.preventDefault(),C(!0),i.focus())},ae=e=>{e.target instanceof Node&&t.contains(e.target)||(x(),t.classList.contains(`is-open`)&&C(!1))};document.addEventListener(`keydown`,ie),document.addEventListener(`pointerdown`,ae),r.push(()=>{clearTimeout(ne),te.abort(),document.removeEventListener(`keydown`,ie),document.removeEventListener(`pointerdown`,ae)})}function ct(e){let t=[],n=e.dataset.wuiCollapsedCookie;n&&e.addEventListener(`wui:shell:collapse`,e=>{tt(n,!!e.detail?.collapsed)});let r=e.dataset.wuiFoldedCookie;r&&e.addEventListener(`wui:shell:nav-fold`,e=>{nt(r,e.detail?.key,!!e.detail?.folded)}),e.addEventListener(`click`,t=>{Z(t).closest(`[data-wui-tabbar-more]`)&&X(e,`[data-app-shell-menu]`,HTMLElement)?.click()});let i=X(e,`[data-wui-topsearch]`,HTMLElement);i&&st(i,t);let a={el:e,setTabCount(t,n,r){$e(e,t,n,r)},get collapsed(){return e.classList.contains(`collapsed`)},set collapsed(t){if(!!t===e.classList.contains(`collapsed`))return;let n=X(e,`[data-app-shell-collapse]`,HTMLElement);n?n.click():e.classList.toggle(`collapsed`,!!t)}};Xe(e,a);let o=n=>{if(n.target===e||n.target instanceof Node&&n.target.contains(e)){for(let e of t)e();Ze(e),delete e.dataset.wuiPartsWired,document.removeEventListener(`wui:teardown`,o)}};return document.addEventListener(`wui:teardown`,o),a}function lt(e=document){let t=[];e instanceof HTMLElement&&e.matches(`[data-app-shell]`)&&t.push(e),t.push(...it(e,`[data-app-shell]`,HTMLElement));for(let e of t)e.dataset.wuiPartsWired||(e.dataset.wuiPartsWired=`1`,ct(e))}function ut(e){let t=rt(e,`[data-app-shell]`,HTMLElement);return t?(Qe(t)||lt(t),Qe(t)):null}export{ke as CONFIRM_DIALOG_ID,P as CONFIRM_TONES,_ as CSRF_META_NAME,m as DEFAULT_CSRF_HEADER,Ae as DISCARD_EVENT,j as FLASH_STORAGE_KEY,M as FLASH_VARIANTS,f as HTTP_KINDS,d as TOAST_ACTION_METHODS,De as TOAST_ACTION_MS,s as WUI_HEADERS,N as WuiPostError,A as applyRefresh,g as classifyStatus,be as closeRemotePane,c as configureCsrf,L as confirmAction,Ee as createDiscardPrompt,p as createRequestQueue,I as formValues,ye as getServerTable,ut as getShell,Oe as initDrawerDiscard,Ye as initFlashToasts,B as initRemoteModals,je as initServerActions,Ge as initServerTables,lt as initShellParts,xe as initUnsavedChanges,Ne as loadRemoteDrawer,Se as loadRemoteModal,Me as loadRemotePane,o as parseServerHtml,u as parseToastAction,Ce as postAction,l as readCsrf,me as refreshAfter,k as refreshRegions,he as reloadsPage,z as resetUnsavedChanges,R as runToastAction,Te as showResultToast,F as showToast,h as timeoutFromAttribute,ee as wuiFetch,we as wuiUpload};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.
|
|
1
|
+
(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.184.0`)throw Error(`[webority-ui] calendar-views expects ui-elements 0.184.0 but the page loaded `+r+`.`);function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=`#view=`,l=`wui-calendar-views:view-change`,u=`wui-calendar-views:period-change`,d=[`previous`,`next`,`today`],f=`.wui-cal-views-switch input[type='radio']`,p=class extends n.ElementBase{constructor(){super(),s(this,`_onChange`,void 0),s(this,`_onClick`,void 0),this._onChange=e=>this._choose(e),this._onClick=e=>this._step(e)}static get observedAttributes(){return[`view`]}connectedCallback(){if(this.addEventListener(`change`,this._onChange),this.addEventListener(`click`,this._onClick),!this.hasAttribute(`data-controlled`)){let e=m(this._views());e&&this.setAttribute(`view`,e)}if(!this.hasAttribute(`view`)){let e=this._views()[0];e&&this.setAttribute(`view`,e)}this._sync()}disconnectedCallback(){this.removeEventListener(`change`,this._onChange),this.removeEventListener(`click`,this._onClick)}attributeChangedCallback(){this._sync()}_views(){return Array.from(this.querySelectorAll(f),e=>e.value)}_sync(){let e=this.getAttribute(`view`)??``;for(let t of this.querySelectorAll(f))t.checked=t.value===e;for(let t of this.querySelectorAll(`:scope > .wui-cal-views-body[data-view]`))t.hidden=t.dataset.view!==e}_choose(e){let t=e.target;if(!(t instanceof HTMLInputElement)||t.type!==`radio`||!this.contains(t))return;let n=t.value;this.hasAttribute(`data-controlled`)||this.setAttribute(`view`,n),h(n),this.dispatchEvent(new CustomEvent(l,{bubbles:!0,detail:{view:n}})),this._sync()}_step(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`button[data-step]`),r=n?.getAttribute(`data-step`)??``;n&&this.contains(n)&&d.includes(r)&&this.dispatchEvent(new CustomEvent(u,{bubbles:!0,detail:{step:r}}))}};function m(e){if(!window.location.hash.startsWith(c))return null;let t=window.location.hash.slice(6);return e.includes(t)?t:null}function h(e){let t=new URL(window.location.href);t.hash=`view=${e}`,window.history.replaceState(window.history.state,``,t)}(0,t.defineElement)(`wui-calendar-views`,p),e.WuiCalendarViews=p})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase);
|