@webority/ui-elements 0.175.0 → 0.177.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/WuiCommentThread-e5t7HceL.js +1 -0
- package/dist/WuiDateRange-BnEJ2WpL.js +1 -0
- package/dist/WuiInlineEdit-p0cm_i90.js +1 -0
- package/dist/{WuiMarkdown-DsN4YbiZ.js → WuiMarkdown-DRtGPxQX.js} +1 -1
- package/dist/WuiMentionInput-DPpEVL2s.js +1 -0
- package/dist/WuiNotificationCenter-DuvGrqwr.js +1 -0
- package/dist/{WuiPhone-CBge7oVA.js → WuiPhone--w-taM5Q.js} +1 -1
- package/dist/{WuiSavedViews-OjB-ZiCo.js → WuiSavedViews-BKpnSd-Y.js} +1 -1
- package/dist/{WuiSelect-D89S-POU.js → WuiSelect-iUXaHKw5.js} +1 -1
- package/dist/{WuiSlider-R_mTula0.js → WuiSlider-CK7_l_R5.js} +1 -1
- package/dist/WuiTour-BgpMa8J5.js +1 -0
- package/dist/WuiTree-BjtuCasB.js +1 -0
- package/dist/{chips-_rw5Aev4.js → chips-xXgAvIFy.js} +1 -1
- package/dist/{httpFailure.g-DBKzEpAf.js → commentThread.g-C7L18Tvy.js} +1 -1
- package/dist/drawerDiscard-z1PsI4cx.js +1 -0
- package/dist/elements/comment-thread.js +1 -1
- package/dist/elements/date-range.js +1 -1
- package/dist/elements/inline-edit.js +1 -1
- package/dist/elements/kanban.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/elements/mention-input.js +1 -1
- package/dist/elements/notification-center.js +1 -1
- package/dist/elements/phone.js +1 -1
- package/dist/elements/saved-views.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/slider.js +1 -1
- package/dist/elements/tour.js +1 -1
- package/dist/elements/tree.js +1 -1
- package/dist/helpers.js +1 -1
- package/dist/httpFailure.g-DjZzGxPj.js +1 -0
- package/dist/kanban-jQCTLG3Q.js +1 -0
- package/dist/{listboxKeyNav-DNtuh6Ob.js → listboxKeyNav-CNso9shL.js} +1 -1
- package/dist/{loader-C2hgZrCR.js → loader-DvNLnnaO.js} +1 -1
- package/dist/{search-D-lfoHy9.js → search-Bhn-bjLL.js} +1 -1
- package/dist/server.js +1 -1
- package/dist/text/en.json +2 -1
- package/dist/text.js +1 -1
- package/dist/themeTransition-TF0BqM20.js +1 -0
- package/dist/ui-calendar.global.js +1 -1
- package/dist/ui-calendar.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/date-range.global.js +1 -1
- package/dist/ui-elements/date-time.global.js +1 -1
- package/dist/ui-elements/datepicker.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/dropdown.global.js +1 -1
- package/dist/ui-elements/entry-grid.global.js +1 -1
- package/dist/ui-elements/gantt.global.js +1 -1
- package/dist/ui-elements/glyphs.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -1
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lead-popup.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +2 -2
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/popover.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +1 -1
- package/dist/ui-elements/select-recents.global.js +1 -1
- package/dist/ui-elements/select-search.global.js +1 -1
- package/dist/ui-elements/select-window.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/table-export.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree-picker.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +1 -1
- package/dist/ui-elements.js +1 -1
- package/dist/ui-tour.global.js +1 -1
- package/dist/wuiHttp-Cw7V8u2w.js +1 -0
- package/package.json +6 -6
- package/types/calendarAdapter.d.ts +8 -21
- package/types/calendarEngine.d.ts +22 -0
- package/types/commandShortcut.d.ts +12 -0
- package/types/global/shared.d.ts +2 -0
- package/types/globals.d.ts +0 -4
- package/types/helpers.d.ts +1 -1
- package/types/listboxKeyNav.d.ts +2 -3
- package/types/razor-js/modules/api.d.ts +0 -5
- package/types/server/index.d.ts +1 -0
- package/types/server/shellParts.d.ts +6 -0
- package/types/server/wuiHttp.d.ts +6 -3
- package/types/server/wuiUpload.d.ts +15 -0
- package/types/text/web/httpFailure.g.d.ts +1 -0
- package/dist/WuiCommentThread-C5n933uz.js +0 -1
- package/dist/WuiDateRange-qTncGobM.js +0 -1
- package/dist/WuiInlineEdit-BwB-w61N.js +0 -1
- package/dist/WuiMentionInput-DJv-WwW6.js +0 -1
- package/dist/WuiNotificationCenter-1Hw7W0st.js +0 -1
- package/dist/WuiTour-BU00-6Lf.js +0 -1
- package/dist/WuiTree-CIOM1G59.js +0 -1
- package/dist/drawerDiscard-D_n8guAp.js +0 -1
- package/dist/kanban-DlVHIpxL.js +0 -1
- package/dist/themeTransition-DBv2olsl.js +0 -1
- package/dist/wuiHttp-BWf9dDsZ.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t,r as n,s as r,t as i,u as a}from"./calendarMath-CT99RyhR.js";import{n as o}from"./devWarn-DXdRWZs3.js";import{r as s,t as c}from"./textStore-DBplASiZ.js";import{t as l}from"./dateRangePicker.g-Pnc37vgX.js";import{n as u,r as d,t as f}from"./zone-BR02ZkHF.js";import{r as p}from"./dom-DMQu--xV.js";import{t as m}from"./elementBase-Cxeyx0tU.js";import{r as h,t as g}from"./fieldState-D-zQcXUS.js";import{_,b as v}from"./formatters-DTW53DjY.js";import{t as y}from"./iconGlyphs.g-a9FtjPXh.js";import{a as b,l as x,s as S}from"./nativeOverlay-BHD2QV02.js";var C=4,w=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],T={today:`todayLabel`,yesterday:`yesterdayLabel`,last7Days:`last7DaysLabel`,last30Days:`last30DaysLabel`,thisMonth:`thisMonthLabel`,lastMonth:`lastMonthLabel`,thisFinancialYear:`thisFinancialYearLabel`},E=e=>String(e).padStart(2,`0`),D=e=>`${e.getUTCFullYear()}-${E(e.getUTCMonth()+1)}-${E(e.getUTCDate())}`;function O(e){return w.includes(e)}function k(e,t=/* @__PURE__ */ new Date,{timeZone:n=f,financialYearStart:i=C}={}){if(!O(e))return null;let a=r(d(n,t));if(!a)throw Error(`today missing`);let{y:o,m:c,d:u}=a,p=(e,t,n)=>D(new Date(Date.UTC(e,t,n))),m=s(`dateRangePicker`,l)[T[e]];switch(e){case`today`:return{label:m,start:p(o,c,u),end:p(o,c,u)};case`yesterday`:return{label:m,start:p(o,c,u-1),end:p(o,c,u-1)};case`last7Days`:return{label:m,start:p(o,c,u-6),end:p(o,c,u)};case`last30Days`:return{label:m,start:p(o,c,u-29),end:p(o,c,u)};case`thisMonth`:return{label:m,start:p(o,c,1),end:p(o,c+1,0)};case`lastMonth`:return{label:m,start:p(o,c-1,1),end:p(o,c,0)};case`thisFinancialYear`:{let e=i-1,t=c>=e?o:o-1;return{label:m,start:p(t,e,1),end:p(t+1,e,0)}}default:return null}}function A(e){o(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function j(e){return typeof e==`object`&&!!e}function M(e,t=/* @__PURE__ */ new Date,n={}){let i=String(e??``).trim();if(!i)return[];let a;if(i.startsWith(`[`))try{a=JSON.parse(i)}catch{return A(`the attribute is not valid JSON`),[]}else a=i.split(`,`).map(e=>e.trim());let o=[];for(let e of a)if(typeof e==`string`){let r=k(e,t,n);r?o.push(r):A(`"${e}" is not one of ${w.join(`, `)}`)}else j(e)&&typeof e.label==`string`&&e.label&&typeof e.start==`string`&&typeof e.end==`string`&&r(e.start)&&r(e.end)?o.push({label:e.label,start:e.start,end:e.end}):A(`an item needs a label and ISO start and end dates, or a preset name`);return o}var N=()=>s(`dateRangePicker`,l);function P(e){if(!(e.target instanceof Element))throw Error(`Expected the event target to be an element.`);return e.target}function F(e,t){return[...e.querySelectorAll(t)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`Expected every "${t}" to be an HTML element.`);return e})}var I=class extends m{static formAssociated=!0;_internals;_start;_end;_hover;_viewY;_viewM;get open(){return this.querySelector(`.daterange`)?.classList.contains(`open`)??!1}set open(e){e?!g(this)&&!this.open&&this._open?.():this.open&&this._close?.()}static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`time-zone`,`financial-year-start`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){e===`aria-invalid`?this._syncInvalid():this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){return n(this)}_label(){let t=this.getAttribute(`placeholder`)||N().placeholder;return!this._start&&!this._end?{text:t,empty:!0}:{text:c(N().rangeText,{start:e(this._start)||N().startLabel,end:e(this._end)||N().endLabel}),empty:!1}}render(){this._dropPanel(),this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=r(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` wui-input-sm`:t===`lg`?` wui-input-lg`:t===`xl`?` wui-input-xl`:``,{text:i,empty:a}=this._label(),o=this.getAttribute(`aria-label`),s=this.getAttribute(`aria-describedby`),c=p(`button`,{type:`button`,class:`input daterange-trigger${n}${a?``:` has-value`}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:null,disabled:this.hasAttribute(`disabled`),"aria-label":o||null,"aria-describedby":s||null},p(`span`,{"data-range-label":!0,class:a?`wui-select-placeholder`:``},i),y(`calendar`));this.replaceChildren(p(`div`,{class:`daterange`},c,p(`div`,{class:`daterange-pop`,role:`dialog`,popover:`auto`}))),h(this,this.querySelector(`.daterange-trigger`)),this._rendered=!0,this._syncMirrors(),this._wire()}formResetCallback(){this.value={start:this._defaultStart||``,end:this._defaultEnd||``}}_syncTrigger(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`[data-range-label]`);if(!t)return;let{text:n,empty:r}=this._label();t.textContent=n,t.classList.toggle(`wui-select-placeholder`,r),e?.classList.toggle(`has-value`,!r)}_syncMirrors(){let e=this.getAttribute(`start-name`)||this.getAttribute(`name`),t=this.getAttribute(`end-name`);this._mirror(`start`,e,this._start),this._mirror(`end`,t,this._end)}_mirror(e,t,n){if(!t)return;let r=this.querySelector(`input[type="hidden"][data-range-mirror="${e}"]`),i;r instanceof HTMLInputElement?i=r:(i=document.createElement(`input`),i.type=`hidden`,i.setAttribute(`data-range-mirror`,e),this.appendChild(i)),i.name=t,i.value=n||``,i.disabled=this.hasAttribute(`disabled`)}_limits(){let e=r(this.getAttribute(`min`)),t=r(this.getAttribute(`max`)),n=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=t?new Date(t.y,t.m,t.d).getTime():1/0;return(e,t,r)=>{let a=new Date(e,t,r).getTime();return a<n||a>i}}_monthHtml(e,n){let r=this._firstDay(),o=(new Date(e,n,1).getDay()-r+7)%7,s=t(e,n),c=this._limits(),l=Array.from({length:7},(e,t)=>p(`span`,null,v((t+r)%7,`min`))),u=(e,t,n,r)=>{let i=a(e,t,n),o=c(e,t,n),s=[`datepicker-day`,r?`is-outside`:``].filter(Boolean).join(` `);return p(`button`,{type:`button`,class:s,"data-iso":i,disabled:o},n)},d=[],f=i(e,n-1),m=t(f.y,f.m);for(let e=o-1;e>=0;e--)d.push(u(f.y,f.m,m-e,!0));for(let t=1;t<=s;t++)d.push(u(e,n,t,!1));let h=i(e,n+1),g=(7-(o+s)%7)%7;for(let e=1;e<=g;e++)d.push(u(h.y,h.m,e,!0));return p(`div`,{class:`daterange-cal`},p(`div`,{class:`datepicker-month-label`},`${_(n)} ${e}`),p(`div`,{class:`datepicker-weekdays`},...l),p(`div`,{class:`datepicker-grid`,role:`grid`},...d))}_presetOptions(){let e=this.getAttribute(`time-zone`),t=f;e!==null&&(u(e)?t=e:o(`[@webority/ui-elements] <wui-date-range> time-zone="${e}" is not a time zone this browser knows; India Standard Time is used.`));let n=this.getAttribute(`financial-year-start`),r=4;if(n!==null){let e=Number(n);Number.isInteger(e)&&e>=1&&e<=12?r=e:o(`[@webority/ui-elements] <wui-date-range> financial-year-start="${n}" must be a month number from 1 to 12; April (4) is used.`)}return{timeZone:t,financialYearStart:r}}_presetsHtml(){if(!this._presetList?.length)return null;let e=this._limits(),t=t=>{let n=r(t);if(!n)throw Error(`Expected a preset date, found "${t}".`);return e(n.y,n.m,n.d)},n=this._presetList.map((e,n)=>p(`button`,{type:`button`,class:`wui-daterange-preset`,"data-preset":n,disabled:t(e.start)||t(e.end)},e.label));return p(`div`,{class:`wui-daterange-presets`,role:`group`,"aria-label":N().quickRangesLabel},...n)}_renderView(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=i(this._viewY,this._viewM+1),n=this._presetsHtml(),r=[p(`div`,{class:`daterange-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":-1,"aria-label":N().previousMonthLabel},y(`chevron-left`)),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":1,"aria-label":N().nextMonthLabel},y(`chevron-right`))),p(`div`,{class:`daterange-cals`},this._monthHtml(this._viewY,this._viewM),this._monthHtml(t.y,t.m)),p(`div`,{class:`datepicker-foot`},p(`span`,{class:`daterange-hint`,"data-range-hint":!0}),p(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},N().clearLabel))];e.classList.toggle(`wui-daterange-pop--presets`,n!==null),e.replaceChildren(...n?[n,p(`div`,{class:`wui-daterange-main`},...r)]:r),this._paint()}_paint(){let t=this.querySelector(`.daterange-pop`);if(!t)return;let n=this._start?new Date(this._start).getTime():null,r=this._end;n&&!this._end&&this._hover&&new Date(this._hover).getTime()>=n&&(r=this._hover);let i=r?new Date(r).getTime():null;for(let e of F(t,`.datepicker-day[data-iso]`)){let t=new Date(e.dataset.iso??``).getTime(),r=n!=null&&t===n,a=i!=null&&t===i,o=n!=null&&i!=null&&t>n&&t<i;e.classList.toggle(`is-range-start`,r),e.classList.toggle(`is-range-end`,a),e.classList.toggle(`in-range`,o)}F(t,`[data-preset]`).forEach(e=>{let t=this._presetList?.[Number(e.dataset.preset)],n=!!t&&t.start===this._start&&t.end===this._end;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-pressed`,String(n))});let a=t.querySelector(`[data-range-hint]`);a&&(a.textContent=this._start?this._end?c(N().rangeText,{start:e(this._start),end:e(this._end)}):N().pickEndDateLabel:N().pickStartDateLabel)}_pick(e){!this._start||this._start&&this._end?(this._start=e,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint()):new Date(e).getTime()<new Date(this._start).getTime()?(this._start=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))):(this._end=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}_applyPreset({start:e,end:t}){this._start=e,this._end=t,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close()}_dropPanel(){let e=this.querySelector(`.daterange-pop`);e instanceof HTMLDivElement&&b(e)}_wire(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`.daterange-pop`),n=this.querySelector(`.daterange`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let a=()=>S(t),o=()=>{this._hover=``,n?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!1}}))};this._open=()=>{let i=r(this._start);if(i)this._viewY=i.y,this._viewM=i.m;else{let e=/* @__PURE__ */ new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._presetList=M(this.getAttribute(`presets`),/* @__PURE__ */ new Date,this._presetOptions()),this._renderView(),x(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),a()&&(n?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!0}})))},this._close=()=>{b(t)},e.addEventListener(`click`,()=>{a()?this._close():g(this)||this._open()}),t.addEventListener(`click`,e=>{let t=P(e),n=t.closest(`[data-nav]`);if(n instanceof HTMLElement){let e=i(this._viewY,this._viewM+Number(n.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._renderView();return}if(t.closest(`[data-clear]`)){this._start=``,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._renderView(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let r=t.closest(`[data-preset]`);if(r instanceof HTMLButtonElement&&!r.disabled){let e=this._presetList?.[Number(r.dataset.preset)];e&&this._applyPreset(e);return}let a=t.closest(`.datepicker-day[data-iso]`);if(a instanceof HTMLButtonElement&&!a.disabled){let e=a.dataset.iso;e!==void 0&&this._pick(e)}}),t.addEventListener(`mouseover`,e=>{let t=P(e).closest(`.datepicker-day[data-iso]`),n=t instanceof HTMLButtonElement?t.dataset.iso:void 0;n!==void 0&&this._start&&!this._end&&(this._hover=n,this._paint())}),this._syncMirrors()}};export{I as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./calendarMath-CT99RyhR.js";import{n as t,r as n,t as r}from"./digitGrouping-CCPI3HK3.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{o as a}from"./formatters-DTW53DjY.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s,t as c}from"./inlineEditText-DRBhMnam.js";import{d as l}from"./wuiHttp-BWf9dDsZ.js";import{r as u,t as d}from"./textStore-DBplASiZ.js";import{t as f}from"./inlineEdit.g-ZxRNYq0t.js";var p=()=>u(`inlineEdit`,f),m=e=>s.some(t=>t===e),h=`[data-wui-display]`,g=`[data-wui-value]`,_=`[data-wui-editor]`,v=`[data-wui-control]`,y=`[data-wui-error]`,b=`[data-wui-live]`,x=`[aria-expanded="true"]`,S=/* @__PURE__ */ new Set([`select`,`date`]),C=e=>{let t=(typeof e==`object`||typeof e==`function`)&&e!==null&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:p().serverMessage},w=e=>e instanceof HTMLElement&&typeof(`value`in e?e.value:void 0)==`string`,T=(e,t)=>{let n=e?.querySelector(t)??null;return n instanceof HTMLElement?n:null},E=class extends i{_wired;_editing;_busy;_draft;_pressed;_popupOpen;_savedTimer;static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this._grouping(),this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=T(this,h),t=T(this,_),n=this._control();e&&t&&n&&(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._focusControl(n),e.hidden=!0)}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_onClick(e){e.stopPropagation();let t=e.target instanceof Node?e.target:null;e.type===`click`&&!this._editing&&this.querySelector(h)?.contains(t)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(_)?.querySelector(x))}_onKeyDown(e){if(!this._editing){(o(e)||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||S.has(t)||(t!==`textarea`||e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget instanceof Node?e.relatedTarget:null;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!S.has(this._type()))return;let t=this._control();t&&e.target===t&&queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let i=r?null:this._readShown();r||this._showValue(e),this._close();let a=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let o=this.getAttribute(`label`)||``;a.ok?(this.setAttribute(`value`,e),!r&&a.text&&this._showText(a.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),c),this._announce(d(p().savedText,{label:o})),this._fire(`wui:inline-edit:saved`,{value:e,previous:t})):(i&&this._restoreShown(i),a.kind===`session`||a.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(a.message),this._announce(d(p().notSavedText,{label:o,reason:a.message})),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:a.kind,message:a.message})))}async _persist(e,t){if(t){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:C(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let r=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),i=await l(n,{method:`POST`,body:r});if(i.ok)return{ok:!0,text:i.html.trim()};let a={forbidden:p().forbiddenMessage,client:p().clientMessage,validation:p().validationMessage,server:p().serverMessage,network:p().networkMessage};return{ok:!1,kind:i.kind,message:i.message||a[i.kind]||p().serverMessage}}_close(){let e=T(this,h),t=T(this,_),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),T(t,x)?.click(),n&&e?.focus()}_focusControl(e){if(!S.has(this._type())){e.focus(),e.select?.();return}let t=T(e,`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(t){if(t===``){this._showText(this.getAttribute(`placeholder`)||a(),!0);return}let n=this._type(),i=t;if(n===`date`)i=e(t)||t;else if(n===`select`){let e=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(e=>e.getAttribute(`data-value`)===t);e&&(i=(e.textContent??``).trim())}else n===`number`&&this._grouping()===`indian`&&(i=r(t));this._showText(i,!1)}_readShown(){let e=this.querySelector(g);return e?{nodes:[...e.childNodes].map(e=>e.cloneNode(!0)),empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(g);t&&(t.replaceChildren(...e.nodes),t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(g);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=T(this,y),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(b);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){let e=this.querySelector(v);return w(e)?e:null}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return m(e)?e:`text`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!n(e))throw Error(t(e));return e}};export{E as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t,r as n,t as r}from"./fieldState-D-zQcXUS.js";import{f as i}from"./formatters-DTW53DjY.js";import{t as a}from"./hasOwn-CJsplJ62.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s}from"./listboxKeyNav-DNtuh6Ob.js";import{i as c,n as l,r as u,t as d}from"./mentionText-BJsw_opZ.js";import{a as f,l as p,s as m}from"./nativeOverlay-BHD2QV02.js";import{t as h}from"./serverHtml-BC6tAyAl.js";import{d as g}from"./wuiHttp-BWf9dDsZ.js";import{n as _,r as v,t as y}from"./textStore-DBplASiZ.js";import{t as b}from"./mentionInput.g-DJo6d2Gm.js";var x=8,S=40,C=()=>v(`mentionInput`,b),w=`[data-wui-control]`,T=`[data-wui-field]`,E=`[data-wui-menu]`,D=`[data-wui-live]`,O=0,k=e=>!!(e&&d.test(String(e.value??``))&&l(e.label)!==``);function A(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`wui-input-sm`,n===`sm`),t.classList.toggle(`wui-input-lg`,n===`lg`),t.classList.toggle(`wui-input-xl`,n===`xl`)}function j(e,n){n.readOnly=t(e)||e.hasAttribute(`loading`)}function M(e){let t=e.ownerDocument;e.id||=`wui-mention-${++O}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control textarea wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),j(e,n),A(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??C().listNameLabel),o.setAttribute(`data-wui-menu`,``),o.setAttribute(`popover`,`manual`),e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var N=class extends e{_wired;_pendingValue;_text;_mentions;_peopleProp;_declared;_loading;_searchFailed;_query;_results;_active;_timer;_searchSeq;_lastSearch;_abort;_onMenuDown;static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._searchFailed=!1,this._query=null,this._results=[],this._active=-1,this._timer=void 0,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this)}connectedCallback(){for(let e of[`people`,`loading`,`searchFailed`,`value`])if(a(this,e)){let t=Reflect.get(this,e);Reflect.deleteProperty(this,e),Reflect.set(this,e,t)}if(this._wired)return;this._wired=!0,this.querySelector(w)||M(this);let e=this._requireControl(),t=this.querySelector(T)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._requireMenu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(j(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(j(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?A(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return c(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=/* @__PURE__ */ new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(k):[],this._searchFailed=!1,(this._isOpen()||this._query!==null)&&this._refresh()}get searchFailed(){return this._searchFailed}set searchFailed(e){this._searchFailed=!!e,this._query!==null&&this._renderMenu()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(w)}_menu(){return this.querySelector(E)}_requireControl(){let e=this._control();if(!e)throw Error(`<wui-mention-input> has no text box.`);return e}_requireMenu(){let e=this._menu();if(!e)throw Error(`<wui-mention-input> has no people list.`);return e}_load(e){let{text:t,mentions:n}=u(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(T);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._requireControl(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e instanceof KeyboardEvent&&e.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||r(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,i=n.lastIndexOf(`@`,t-1);if(i<0||i>0&&!/[\s([{"'“‘]/.test(n.charAt(i-1)))return null;let a=n.slice(i+1,t);return a.length>40||/[\n@]/.test(a)||/^\s/.test(a)||/\s{2}/.test(a)||this._mentions.some(e=>i>=e.start&&i<e.end)?null:{start:i,end:t,text:a}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>l(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,a=await g(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this._searchFailed=!0,this.loading=!1,this._refresh();return}this._searchFailed=!1;let o=h(a.html);this._peopleProp=[...o.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(k),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return e!==null&&m(e)}_renderMenu(){let e=this._menu(),t=this._control();if(!e||!t||!this._query)return;this._syncState();let n=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,r)=>{let i=n.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${r}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(r),t.src){let e=n.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=n.createElement(`span`);a.className=`wui-mention-option-text`;let o=n.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=l(t.label),a.appendChild(o),t.description){let e=n.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=n.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this.loading?C().searchingLabel:this._searchFailed?C().searchFailedMessage:`${C().noMatchLabel} “${this._query.text}”`,e.appendChild(t)}p(t,e,{mode:`manual`}),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?_(C(),`foundText`,this._results.length,{count:i(this._results.length,{decimals:0})}):this._searchFailed?C().searchFailedMessage:`${C().noMatchLabel}.`)}_syncState(){let e=this._control();e&&n(this,e)}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();if(e){let t=m(e);f(e),t&&e.replaceChildren()}this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`)}_setActive(e,{reveal:t=!0}={}){let n=this._requireMenu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]??null:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);s(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._requireControl().setAttribute(`aria-activedescendant`,i.id)):this._requireControl().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((o(e)||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}o(e)&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._requireControl();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=l(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(y(C().mentioned,{label:t}))}_replace(e,t,n,r){let i=this._requireControl(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(D);t&&(t.textContent=``,t.textContent=e)}};export{x as n,N as r,S as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{t as n}from"./isDrawn-BbF4phmB.js";import{a as r,l as i,m as a,s as o}from"./nativeOverlay-BHD2QV02.js";import{o as s,r as c,s as l}from"./notificationDays-wMr8rZko.js";import{d as u}from"./wuiHttp-BWf9dDsZ.js";import{r as d}from"./textStore-DBplASiZ.js";import{t as f}from"./notificationCentre.g-UsAurkUz.js";var p=()=>d(`notificationCentre`,f),m=`.wui-notification-center-trigger`,h=`.wui-notification-center-panel`,g=`.wui-notification-center-count`,_=`.wui-notification-center-live`,v=`.wui-notification-center-markall`,y=`.wui-notification-center-item`,b=`wui-notification-center-item-read`,x=`.wui-notification-center-unread-label`,S=`.app-tabs`,C=`.wui-notification-center-tabs [role='tablist']`,w=`.wui-notification-center-tabs [role='tab']`,T=`.wui-notification-center-empty`,E=`(max-width: 767.98px)`,D={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`},O=e=>!!e,k=()=>({forbidden:p().forbiddenMessage,client:p().clientMessage,validation:p().clientMessage,server:p().serverMessage,network:p().networkMessage}),A=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},j=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),M=class extends t{constructor(){super(),this._unread=0,this._busy=!1,this._sheet=!1,this._awaitChildren=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onToggle=e=>{e.type===`toggle`&&`newState`in e&&e.newState===`closed`&&this._closedByBrowser()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}static get observedAttributes(){return[`open`]}connectedCallback(){this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`toggle`,this._onToggle,!0),this.isOpen&&(A(this,h)===null||A(this,m)===null)?(this._awaitChildren=new MutationObserver(()=>this._finishAwaitedOpen()),this._awaitChildren.observe(this,{childList:!0})):(this._syncOpen(),this.isOpen&&this._showPanel())}disconnectedCallback(){this._disarmAwait(),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`toggle`,this._onToggle,!0);let e=A(this,h);e&&r(e)}attributeChangedCallback(e,t,n){e===`open`&&t!==n&&(this._awaitChildren?n===null&&this._disarmAwait():this.isConnected&&(n===null?this._hidePanel():this._showPanel()))}_finishAwaitedOpen(){A(this,h)!==null&&A(this,m)!==null&&(this._disarmAwait(),this._syncOpen(),this._showPanel())}_disarmAwait(){this._awaitChildren?.disconnect(),this._awaitChildren=null}_showPanel(){let t=e(A(this,h),`<wui-notification-center> needs its panel to open.`),n=e(A(this,m),`<wui-notification-center> needs its trigger to open.`);o(t)||(this._sheet=window.matchMedia(E).matches,this._sheet?a(t,!0):i(n,t,{mode:`auto`,onClosed:()=>this._closedByBrowser()}),o(t)&&this._layoutTabs())}_hidePanel(){let e=A(this,h);e&&o(e)&&(this._sheet?a(e,!1):r(e))}_closedByBrowser(){if(!this.isConnected||!this.hasAttribute(`open`))return;let e=A(this,h);this.close({restoreFocus:e?.contains(this.ownerDocument.activeElement)??!1})}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(e(A(this,h),`<wui-notification-center> needs its panel to open.`),e(A(this,m),`<wui-notification-center> needs its trigger to open.`),this.setAttribute(`open`,``),this._syncOpen(),A(this,h)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&A(this,m)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(m)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${y}:not(.${b}):not([data-archived="true"])`).length}_click(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(w);if(n instanceof HTMLElement&&this.contains(n)){if(this.hasAttribute(`controlled`))return;this._pickTab(n);return}let r=t.closest(`${m}, ${v}, ${y}`);r instanceof HTMLElement&&this.contains(r)&&(r.matches(m)?this.toggle():this.hasAttribute(`controlled`)||(r.matches(v)?this._markAll():this._markItem(r)))}_key(e){if(!this.isOpen)return;let t=e.target;if(!(t instanceof Element))throw Error(`Keyboard event target is not an element.`);if(!this.querySelector(h)?.contains(t)||t.closest(S))return;let r=D[e.key];if(r===void 0)return;let i=j(this,y).filter(n);if(i.length===0)return;let a=t.closest(y),o=a instanceof HTMLElement?i.indexOf(a):-1,s;s=r===`first`?0:r===`last`?i.length-1:o===-1?r===1?0:i.length-1:Math.min(i.length-1,Math.max(0,o+r)),e.preventDefault(),i[s]?.focus()}_markItem(e){e.classList.contains(b)||(this._applyRead(e),e.dataset.archived!==`true`&&(this._unread=Math.max(0,this._unread-1)),this._render(),this._say(l(this._unread)),this._emitRead([e.dataset.id].filter(O),!1))}async _markAll(){if(this._busy)return;let e=j(this,`${y}:not(.${b})`);if(e.length===0&&this._unread===0)return;let t=e.map(e=>e.dataset.id).filter(O),n=this.getAttribute(`read-action`);if(n){this._setBusy(!0);let e=new URLSearchParams;for(let n of t)e.append(`ids`,n);let r=await u(n,{method:`POST`,body:e});if(this._setBusy(!1),!r.ok){if(r.kind===`session`||r.kind===`aborted`)return;let e=r.kind,t=r.message||k()[e]||p().serverMessage;this._say(t),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:e,message:t}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(p().allReadText),this._emitRead(t,!0)}_pickTab(e){let t=e.closest(C);if(t instanceof HTMLElement){for(let n of j(t,w)){let t=n===e;n.classList.toggle(`active`,t),n.setAttribute(`aria-selected`,t?`true`:`false`),n.setAttribute(`tabindex`,t?`0`:`-1`)}this._layoutTabs(),this._filterItems(e.dataset.key)}}_layoutTabs(){for(let e of j(this,C)){let t=A(e,`.app-tab.active`);t&&(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.setAttribute(`data-wui-tabs`,``)}}_filterItems(e){let t=!1;for(let n of j(this,y)){let r=n.dataset.archived===`true`,i=n.classList.contains(b),a=e===`archived`?r:!r&&(e!==`unread`||!i);a&&(t=!0);let o=n.closest(`li`);o&&(o.hidden=!a)}for(let e of j(this,`.wui-notification-center-list section`))e.hidden=[...e.querySelectorAll(`li`)].every(e=>e.hidden);let n=A(this,T);n&&(n.hidden=t)}_applyRead(e){e.classList.add(b),e.querySelector(x)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(v);t instanceof HTMLButtonElement&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=A(this,g);e&&(e.textContent=c(this._unread),e.hidden=this._unread===0),this.querySelector(m)?.setAttribute(`aria-label`,s(this.getAttribute(`label`)||p().label,this._unread));let t=this.querySelector(v);t instanceof HTMLButtonElement&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(_);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{M as t};
|
package/dist/WuiTour-BU00-6Lf.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t}from"./anchorOverlay-daGdh_91.js";import{n,t as r}from"./buttonClass-C8BRtTk8.js";import{r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{d as o,f as s,o as c,u as l}from"./nativeOverlay-BHD2QV02.js";import{n as u,t as d}from"./rtl-g7G8Bsib.js";import{r as f}from"./textStore-DBplASiZ.js";import{n as p,t as m}from"./tourAdvance.g-BJqDnqag.js";import{n as h}from"./imeSafeEnter-DeO_3lXy.js";import{t as g}from"./svgNodes-CyPS2oFH.js";import{t as _}from"./tourOpenMark-nPeAJFSo.js";import{t as v}from"./tourSeenStore-z0Y_Znzx.js";var y=`data-advance`,b=`wui-tour-hint`,x=`wui-tour-pointer`,ee=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,te=()=>f(`tourAdvance`,m),S=(e,t)=>e?.advanceOn===`click`&&!!t,C=e=>(e??``).replace(/\s+/g,` `).trim(),ne=e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLMeterElement||e instanceof HTMLOutputElement||e instanceof HTMLProgressElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.labels:null,re=e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLFieldSetElement||e instanceof HTMLOptGroupElement||e instanceof HTMLOptionElement?e.disabled:!1;function ie(e){let t=e.ownerDocument,n=(e.getAttribute(`aria-labelledby`)||``).split(/\s+/).filter(Boolean),r=e instanceof HTMLInputElement&&/^(button|submit|reset)$/.test(e.type)?e.value:``,i=[n.map(e=>t.getElementById(e)?.textContent??``).join(` `),e.getAttribute(`aria-label`),Array.from(ne(e)??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=C(e);if(t)return t}return``}function ae(e){for(let t of[e,...e.querySelectorAll(ee)])if((t instanceof HTMLElement||t instanceof SVGElement)&&t.tabIndex>=0&&!re(t))return t;return null}function w(e,t,n){let r=(e.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(e=>e&&e!==t);n&&r.push(t),r.length>0?e.setAttribute(`aria-describedby`,r.join(` `)):e.removeAttribute(`aria-describedby`)}function oe(e,t){let n=e.querySelector(`.${b}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;if(!t)n?.remove(),i&&w(e,i,!1);else{if(!n){n=e.ownerDocument.createElement(`p`),n.className=b,i&&(n.id=i);let t=e.querySelector(`.wui-tour-actions`);if(!t)throw Error(`Tour card has no actions row.`);t.before(n)}n.textContent=t,i&&w(e,i,!0)}}function se(e,t){let n=e.querySelector(`.${x}`);if(!t){n?.remove();return}if(n)return;let r=e.ownerDocument.createElement(`span`);r.className=x,r.setAttribute(`aria-hidden`,`true`),e.append(r)}var ce=e=>getComputedStyle(e).animationName;function T(e,{layer:t,spot:n,card:r},i,a){let o=S(i,a);t.toggleAttribute(y,o&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(y)&&(n.removeAttribute(y),o&&ce(n)),o&&n.setAttribute(y,``),se(n,o);let s=r.querySelector(`.wui-tour-next`);if(!(s instanceof HTMLElement))throw Error(`Tour card has no next button.`);s.classList.toggle(`btn-primary`,!o),s.classList.toggle(`btn-link`,o);let c=o?C(i?.actionLabel)||ie(a):``,l=e.getAttribute(`advance-label`)||te().advanceLabel,u=c?l.replace(/\{actionName\}/g,()=>c):``;return oe(r,u),u}function le(e,t,n){if(!S(e,t))return()=>{};let r,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function ue(e,t,n,r){return e.contains(r)||S(t,n)&&n.contains(r)}function de(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=S(r,i)?ae(i):null;o&&a.push(o);let s=a.findIndex(e=>e===n||e===o&&i?.contains(n));e.preventDefault();let c=a[s===-1?e.shiftKey?a.length-1:0:(s+(e.shiftKey?-1:1)+a.length)%a.length];if(!c)throw Error(`Tour card has no focus stop.`);c.focus()}var fe=2/3,pe=1e3,me=/* @__PURE__ */ new Set([`top`,`left`,`width`,`height`]),E=/* @__PURE__ */ new WeakMap,D=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],O=e=>`transitionProperty`in e&&e.transitionProperty===`opacity`,he=e=>`transitionProperty`in e&&typeof e.transitionProperty==`string`&&me.has(e.transitionProperty),ge=e=>`animationName`in e&&typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function k(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,pe);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function _e(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?D(t,he):[]){let t=e.effect?.getComputedTiming?.();if(typeof t?.duration!=`number`)continue;let r=typeof e.currentTime==`number`?e.currentTime:0;n=Math.max(n,(t.delay??0)+t.duration*fe-r)}return n}function A(e){let t=_e(e);t>0?e.style.setProperty(`--wui-tour-card-delay`,`${Math.round(t)}ms`):e.style.removeProperty(`--wui-tour-card-delay`),e.dataset.state=`entering`;let n={};E.set(e,n);let r=()=>{E.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=D(e,ge);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function j(e){return e.dataset.state=`leaving`,k(D(e,O))}function ve(e){let t=e.shadowRoot?.querySelector(`.wui-tour-layer`),n=e.classList.contains(`wui-tour-layer`)?e:t instanceof HTMLElement?t:null;n&&(n.dataset.state=`leaving`);let r=n?k(D(n,O)):null;r?(e.setAttribute(`inert`,``),r.then(()=>e.remove())):e.remove()}var ye=2,M=12,N=8,P=4,F=20,be=`(max-width: 575.98px)`,xe=[`bottom`,`top`,`right`,`left`],Se=[`bottom`,`top`,`left`,`right`],I=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],L,R=(e,t,n)=>Math.max(t,Math.min(e,n)),z=(e,t,n,r)=>(Math.max(e,n)+Math.min(t,r))/2;function Ce(e,t){if(!t?.scrollIntoView)return;e.style.maxHeight=``;let n=V(e),r=e.offsetHeight+M;if(t.getBoundingClientRect().height+4+r*2<=n.bottom-n.top){t.scrollIntoView({block:`center`,inline:`nearest`});return}let i=t.style.scrollMarginTop;t.style.scrollMarginTop=`${n.top+r+ye}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function B(e,t,n){let r=e.style,i=t.style,a=Oe(t);if(!n){r.top=`50%`,r.left=`50%`,r.width=`0px`,r.height=`0px`,r.boxShadow=`0 0 0 100vmax var(--color-scrim-strong)`;for(let e of I)r.removeProperty(`border-${e}-radius`),r.removeProperty(`corner-${e}-shape`);t.dataset.placement=`center`,a.hidden=!0,i.position=`fixed`,i.top=`50%`,i.left=`50%`,i.transform=`translate(-50%, -50%)`,i.maxHeight=`calc(100vh - 16px)`;return}r.boxShadow=``,i.transform=``,i.position=`fixed`;let o=n.getBoundingClientRect();r.top=`${o.top}px`,r.left=`${o.left}px`,r.width=`${o.width}px`,r.height=`${o.height}px`,we(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=V(t),u=l.bottom-l.top,f={bottom:l.bottom-o.bottom-M,top:o.top-M-l.top,right:l.right-o.right-M,left:o.left-M-l.left},p=window.matchMedia(be).matches,m=(d(n)?Se:xe).find(e=>e===`top`||e===`bottom`?c.height<=f[e]+1:!p&&c.width<=f[e]+1&&c.height<=u+1),h=Math.min(o.bottom,l.bottom+N)-Math.max(o.top,l.top-N);m?Te(t,a,m,o,l,c):h>=Math.min(c.height,u)+8?Ee(t,a,o,l,c):De(t,a,f.bottom>=f.top?`bottom`:`top`,o,l,c,f),t.scrollTop=s}function we(e,t){L??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of I)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),L&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function Te(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=z(r.left,r.right,i.left,i.right);s=R(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+M:r.top-M-a.height,l=R(e-s,F,a.width-F)}else{let e=z(r.top,r.bottom,i.top,i.bottom);c=R(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+M:r.left-M-a.width,l=R(e-c,F,a.height-F)}e.dataset.placement=n,e.style.top=`${c}px`,e.style.left=`${s}px`,t.hidden=!1,t.style.left=o?`${l-e.clientLeft-t.offsetWidth/2}px`:``,t.style.top=o?``:`${l-e.clientTop-t.offsetHeight/2}px`}function Ee(e,t,n,r,i){let a=r.bottom-r.top;e.dataset.placement=`overlap`,t.hidden=!0,e.style.maxHeight=i.height>a?`${Math.max(a,0)}px`:``;let o=Math.min(n.bottom,r.bottom)-P;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${R(n.left+P,r.left,r.right-i.width)}px`}function De(e,t,n,r,i,a,o){let s=Math.max(o[n],0),c=Math.min(a.height,s);e.dataset.placement=n,t.hidden=!0,e.style.maxHeight=a.height>s?`${s}px`:``,e.style.top=`${n===`bottom`?r.bottom+M:r.top-M-c}px`;let l=z(r.left,r.right,i.left,i.right);e.style.left=`${R(l-a.width/2,i.left,i.right-a.width)}px`}function V(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e]??``)||0;return{top:r(`paddingTop`)+N,bottom:window.innerHeight-r(`paddingBottom`)-N,left:r(`paddingLeft`)+N,right:window.innerWidth-r(`paddingRight`)-N}}function Oe(e){let t=e.querySelector(`:scope > .wui-tour-arrow`);if(t instanceof HTMLElement)return t;let n=document.createElement(`span`);return n.className=`wui-tour-arrow`,n.setAttribute(`aria-hidden`,`true`),n.hidden=!0,e.append(n),n}var ke=0,Ae=`btn btn-sm btn-link`;function H(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`Expected "${t}" to match a ${n.name}.`);return r}function je(e,t){let a=`wui-tour-end-${++ke}`,{nextLabel:o,nextHref:s}=e,c=o&&s?i(`a`,{class:`${n(`primary`,`solid`,`sm`)} wui-tour-end-next`,"data-wui":r,href:s},o):null,l=c!==null,u=l?Ae:n(`primary`,`solid`,`sm`),d=i(`button`,{type:`button`,class:`${u} wui-tour-end-button`,"data-wui":r},e.button);return i(t?`dialog`:`div`,{class:`wui-tour-card wui-tour-end`,"data-layout":`center`,"data-next":l||void 0,role:`dialog`,tabindex:-1,"aria-labelledby":`${a}-title`,"aria-describedby":`${a}-message`},i(`div`,{class:`wui-tour-end-mark`,"aria-hidden":`true`},g({viewBox:`0 0 24 24`,focusable:`false`},[[`path`,{d:`M5 12.5l4.5 4.5L19 7.5`}]])),i(`h2`,{class:`wui-tour-title wui-tour-end-title`,id:`${a}-title`},e.title),i(`p`,{class:`wui-tour-text wui-tour-end-message`,id:`${a}-message`},e.message),i(`div`,{class:`wui-tour-actions`},c,d))}var Me=e=>e.button===0&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey;function Ne(e,t,n){let r=e.ownerDocument,i=je(t,e.getRootNode()===r),a=H(i,`.wui-tour-end-button`,HTMLButtonElement),o=i.querySelector(`.wui-tour-end-next`);if(o!==null&&!(o instanceof HTMLAnchorElement))throw Error(`The end dialog's next link is not a link.`);let s=o,u=s??a,d=new AbortController,f=i instanceof HTMLDialogElement?i:null,p=null;return new Promise(o=>{let m=e=>{if(d.abort(),p&&f){let e=p;p=null,c(f).then(e)}o(e)};if(n?.aborted){m(`done`);return}let g=H(e,`.wui-tour-card:not(.wui-tour-end)`,HTMLElement),_=H(e,`.wui-tour-spot`,HTMLElement),v=H(e,`[role=status]`,HTMLElement),y={signal:d.signal};n?.addEventListener(`abort`,()=>m(`done`),y),a.addEventListener(`click`,()=>m(`done`),y),s&&s.addEventListener(`click`,e=>{Me(e)&&(e.preventDefault(),m(`next`))},y),r.addEventListener(`keydown`,e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`){if(p)return;e.preventDefault(),e.stopPropagation(),m(`done`)}else h(e)&&s&&!e.shiftKey&&(e.composedPath?.()[0]??e.target)===s&&(e.preventDefault(),m(`next`))}},{capture:!0,signal:d.signal});let b=()=>{d.signal.aborted||(g.hidden=!0,B(_,g,null),e.append(i),A(i),f&&(p=l(f,{escape:!0,backdrop:!1,focus:`first-control`,onRequestClose:()=>m(`done`)})),v.textContent=[t.title,t.message].filter(Boolean).join(`. `),u.focus())},x=j(g);x===null?b():x.then(b)})}var Pe=` :host { all: initial; display: revert-layer; position: fixed; inset: 0; ${Object.entries({"--wui-z-tour":`1550`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-popover":`0px 8px 28px -6px rgba(7, 20, 55, 0.14)`,"--wui-ease-out":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-ease-linear":`cubic-bezier(0, 0, 1, 1)`,"--wui-duration-fast":`150ms`,"--wui-duration-default":`250ms`,"--wui-duration-slow":`400ms`,"--wui-space-xs":`4px`,"--wui-tour-motion-duration":`200ms`,"--wui-tour-motion-ease":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-tour-spot-duration":`240ms`,"--wui-tour-spot-ease":`cubic-bezier(0.32, 0.72, 0, 1)`,"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-text":`#4F46E5`,"--color-focus-ring":`#4F46E5`,"--wui-focus-ring-width":`2px`,"--wui-focus-ring-offset":`2px`,"--color-on-primary":`#FFFFFF`,"--color-success-soft":`#E8FAEE`,"--color-success-text":`#0e7531`,"--color-on-scrim":`#FFFFFF`,"--color-scrim-strong":`color-mix(in srgb, #071437 62%, transparent)`,"--color-surface":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-bg-muted":`#F5F6FA`}).map(([e,t])=>` ${e}: ${t};`).join(` `)} } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; } .btn { display: inline-block; margin: 0; padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; line-height: 1.5; text-align: center; text-decoration: none; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; } .btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); } .btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); } .btn-outline-neutral { border-color: var(--color-text-muted); color: var(--color-text-muted); } .btn-outline-neutral:hover { background: var(--color-bg-muted); color: var(--color-text); } .btn-link { font-weight: 400; color: var(--color-primary-text); text-decoration: underline; } .btn-link:hover { color: var(--color-primary-hover); } .wui-tour-layer { pointer-events: none; font-family: "Webority Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-weight: 400; line-height: 1.5; color: var(--color-text); text-align: start; } .wui-tour-card { pointer-events: auto; } .wui-tour-layer { position: fixed; inset: 0; z-index: var(--wui-z-tour); width: auto; height: auto; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; overflow: visible; background: none; } .wui-tour-spot { position: fixed; box-shadow: 0 0 0 2px var(--color-primary), 0 0 4px 2px color-mix(in srgb, var(--color-primary) 30%, transparent), 0 0 0 100vmax var(--color-scrim-strong); pointer-events: none; } .wui-tour-card { display: flex; flex-direction: column; gap: 8px; width: min(360px, 100vw - 16px); padding: 16px; overflow-y: auto; background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--wui-radius-lg); corner-shape: squircle; box-shadow: var(--wui-shadow-popover); } .wui-tour-card:focus { outline: none; } .wui-tour-card:focus-visible { outline: var(--wui-focus-ring-width) solid var(--color-focus-ring); outline-offset: var(--wui-focus-ring-offset); } .wui-tour-title { margin: 0; font-size: 16px; font-weight: 600; } .wui-tour-text { margin: 0; font-size: 14px; color: var(--color-text-muted); } .wui-tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; } .wui-tour-nav { display: flex; gap: 8px; } .wui-tour-skip { color: var(--color-text-muted); } .wui-tour-back, .wui-tour-next { min-width: 64px; } @keyframes wui-tour-fade-in { from { opacity: 0; } to { opacity: 1; } } @keyframes wui-tour-card-enter { from { opacity: 0; scale: 0.96; translate: var(--wui-tour-card-lift, 0 6px); } to { opacity: 1; scale: 1; translate: 0 0; } } .wui-tour-layer[data-state=leaving], .wui-tour-card[data-state=leaving] { opacity: 0; } .wui-tour-layer[data-state=leaving], .wui-tour-layer[data-state=leaving] * { pointer-events: none; } @media (prefers-reduced-motion: no-preference) { .wui-tour-layer { animation: wui-tour-fade-in var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-layer[data-state=leaving] { transition: opacity var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-spot { transition: top var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), left var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), width var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), height var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), border-radius var(--wui-tour-spot-duration) var(--wui-tour-spot-ease); } .wui-tour-spot[data-tracking] { transition: none; } .wui-tour-card { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=top] { --wui-tour-card-lift: 0 -6px; transform-origin: bottom center; } .wui-tour-card[data-placement=bottom] { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=left] { --wui-tour-card-lift: -6px 0; transform-origin: right center; } .wui-tour-card[data-placement=right] { --wui-tour-card-lift: 6px 0; transform-origin: left center; } .wui-tour-card[data-placement=overlap], .wui-tour-card[data-placement=center] { --wui-tour-card-lift: 0 0; transform-origin: center; } .wui-tour-card[data-state=entering] { animation: wui-tour-card-enter var(--wui-tour-motion-duration) var(--wui-tour-motion-ease) var(--wui-tour-card-delay, 0ms) both; } .wui-tour-card[data-state=leaving] { transition: opacity calc(var(--wui-tour-motion-duration) / 2) var(--wui-tour-motion-ease); } } @media (prefers-reduced-motion: reduce) { .wui-tour-layer { animation: wui-tour-fade-in var(--wui-duration-fast) var(--wui-ease-linear); } .wui-tour-layer[data-state=leaving] { transition: opacity var(--wui-duration-fast) var(--wui-ease-linear); } .wui-tour-card[data-state=entering] { animation: wui-tour-fade-in var(--wui-duration-fast) var(--wui-ease-linear) both; } } .wui-tour-progress-bar { display: flex; gap: 4px; } .wui-tour-progress-segment { flex: 1 1 0; height: 4px; border-radius: 999px; background: var(--color-border); } .wui-tour-progress-segment[data-filled] { background: var(--color-primary); } .wui-tour-position { margin: 0; font-size: 12px; color: var(--color-text-muted); } .wui-tour-layer { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); } .wui-tour-card:has(.wui-tour-arrow:not([hidden])) { overflow: visible; } .wui-tour-arrow { position: absolute; width: 8px; height: 8px; background: var(--color-surface); border: 1px solid var(--color-border); rotate: 45deg; pointer-events: none; } .wui-tour-card[data-placement=bottom] .wui-tour-arrow { top: -5px; border-right-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=top] .wui-tour-arrow { bottom: -5px; border-top-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=right] .wui-tour-arrow { left: -5px; border-top-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=left] .wui-tour-arrow { right: -5px; border-bottom-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } @media (max-width: 575.98px) { .wui-tour-card { width: calc(100vw - 16px); } .wui-tour-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; } } .wui-tour-media { position: relative; order: -1; flex: none; aspect-ratio: 16/9; margin: -16px -16px 4px; overflow: hidden; background: var(--color-border); } .wui-tour-media>img, .wui-tour-media>video { display: block; width: 100%; height: 100%; object-fit: cover; } .wui-tour-card[data-welcome] { width: min(420px, 100vw - 16px); } .wui-tour-media-toggle { position: absolute; inset-block-end: 8px; inset-inline-end: 8px; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--color-scrim-strong); color: var(--color-on-scrim); cursor: pointer; } .wui-tour-media-toggle>svg { width: 20px; height: 20px; fill: currentColor; } .wui-tour-media-toggle:focus-visible { outline: 2px solid var(--color-on-scrim); outline-offset: var(--wui-focus-ring-offset); } .wui-tour-layer[data-advance] { pointer-events: none; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-card { pointer-events: auto; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-spot::before { content: ""; position: absolute; inset: -100vmax; pointer-events: auto; clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, 100vmax 100vmax, calc(100% - 100vmax) 100vmax, calc(100% - 100vmax) calc(100% - 100vmax), 100vmax calc(100% - 100vmax), 100vmax 100vmax); } .wui-tour-hint { margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text); } .wui-tour-pointer { position: absolute; top: 50%; left: 50%; width: 18px; height: 24px; pointer-events: none; } .wui-tour-pointer::before { content: ""; position: absolute; inset: 0; background: var(--color-primary); clip-path: polygon(0 0, 0 75%, 28% 58%, 46% 100%, 62% 92%, 45% 52%, 85% 52%); filter: drop-shadow(1px 0 0 var(--color-surface)) drop-shadow(-1px 0 0 var(--color-surface)) drop-shadow(0 1px 0 var(--color-surface)) drop-shadow(0 -1px 0 var(--color-surface)); } .wui-tour-pointer::after { content: ""; position: absolute; top: -16px; left: -16px; width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); opacity: 0; display: none; } @media (max-width: 575.98px) { .wui-tour-pointer { width: 24px; height: 24px; translate: -50% -50%; } .wui-tour-pointer::before { clip-path: none; border-radius: 50%; box-shadow: 0 0 0 2px var(--color-surface); filter: none; } .wui-tour-pointer::after { top: -4px; left: -4px; } } @keyframes wui-tour-tap { 0% { opacity: 0; transform: translate(56px, 44px) scale(1); } 10% { opacity: 1; transform: translate(56px, 44px) scale(1); } 45% { transform: translate(0, 0) scale(1); } 52% { transform: translate(0, 0) scale(0.86); } 60% { transform: translate(0, 0) scale(1); } 85% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(0, 0) scale(1); } } @keyframes wui-tour-tap-rtl { 0% { opacity: 0; transform: translate(-56px, 44px) scale(1); } 10% { opacity: 1; transform: translate(-56px, 44px) scale(1); } 45% { transform: translate(0, 0) scale(1); } 52% { transform: translate(0, 0) scale(0.86); } 60% { transform: translate(0, 0) scale(1); } 85% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(0, 0) scale(1); } } @keyframes wui-tour-ripple { 0%, 50% { opacity: 0; transform: scale(0.2); } 52% { opacity: 0.35; transform: scale(0.2); } 80%, 100% { opacity: 0; transform: scale(1); } } @media (prefers-reduced-motion: no-preference) { .wui-tour-pointer { opacity: 0; animation: wui-tour-tap calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } .wui-tour-pointer:dir(rtl) { animation-name: wui-tour-tap-rtl; } .wui-tour-pointer::after { display: block; animation: wui-tour-ripple calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } } @keyframes wui-tour-check { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } } .wui-tour-end[data-layout=center] { --wui-tour-card-lift: 0 0; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); transform-origin: center; align-items: center; gap: 8px; width: min(420px, 100vw - 16px); max-height: calc(100vh - 16px); padding: 24px; text-align: center; } .wui-tour-end[data-layout=center] .wui-tour-actions { justify-content: center; margin-top: 8px; } .wui-tour-end[data-layout=center][data-next] .wui-tour-actions { flex-direction: column; align-items: stretch; width: 100%; gap: var(--wui-space-xs); } .wui-tour-end-mark { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; background: var(--color-success-soft); color: var(--color-success-text); } .wui-tour-end-mark>svg { width: 26px; height: 26px; } .wui-tour-end-mark path { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; } .wui-tour-end-title { font-size: 18px; } .wui-tour-end-message { text-wrap: balance; } .wui-tour-end-next { text-wrap: balance; } .wui-tour-end-button { min-width: 120px; } @media (prefers-reduced-motion: no-preference) { .wui-tour-end-mark path { animation: wui-tour-check var(--wui-duration-default) var(--wui-ease-out) calc(var(--wui-tour-card-delay, 0ms) + var(--wui-duration-fast)) both; } } `,U=()=>f(`tour`,p),W=`wui-tour-media`,Fe=`wui-tour-media-toggle`,G=`http://www.w3.org/2000/svg`,Ie=`M6 5h4v14H6zM14 5h4v14h-4z`,Le=`M8 5v14l11-7z`,Re=()=>({pause:U().mediaPauseLabel,play:U().mediaPlayLabel}),ze=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function Be(e){let t=document.createElementNS(G,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(G,`path`);return n.setAttribute(`d`,e),t.appendChild(n),t}function Ve(e){let t=document.createElement(`img`);return t.setAttribute(`alt`,e.mediaAlt??``),t.setAttribute(`width`,`1280`),t.setAttribute(`height`,`720`),t.setAttribute(`loading`,`lazy`),t.setAttribute(`decoding`,`async`),t.setAttribute(`src`,e.media??``),t}function He(e,t){let n=document.createElement(`video`);return n.muted=!0,n.setAttribute(`muted`,``),n.loop=!0,n.setAttribute(`playsinline`,``),t&&n.setAttribute(`autoplay`,``),n.setAttribute(`preload`,t?`auto`:`metadata`),e.mediaAlt&&n.setAttribute(`aria-label`,e.mediaAlt),e.mediaPoster&&n.setAttribute(`poster`,e.mediaPoster),n.setAttribute(`src`,e.media??``),n}function Ue(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=Fe;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(Be(r?Ie:Le))};return e.addEventListener(`play`,()=>r()),e.addEventListener(`pause`,()=>r()),n.addEventListener(`click`,()=>{e.paused?e.play()?.catch(()=>r()):e.pause()}),r(e.hasAttribute(`autoplay`)),n}function We(e){let t=e.querySelector(`:scope > .${W}`);if(!t)return;let n=t.querySelector(`video`);n&&(n.pause(),n.removeAttribute(`src`),n.load()),t.remove()}function Ge(e,t,n=Re()){if(We(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=W,t.mediaType===`video`){let e=He(t,!ze());r.append(e,Ue(e,n))}else r.appendChild(Ve(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var Ke=()=>f(`tour`,p);function K(e){let t=/* @__PURE__ */ new Set;return{drop:e=>{t.add(e)},position:e=>{t.delete(e);let n=0;for(let r of t)r<e&&n++;return e+1-n},total:()=>e-t.size}}function qe(e,t,n){return(e.getAttribute(`progress-label`)||Ke().progressLabel).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function Je(e,{text:t,position:n,total:r}){let i=e.querySelector(`.wui-tour-position`);if(!(i instanceof HTMLElement))throw Error(`tour position label missing`);i.textContent=t;let a=e.querySelector(`.wui-tour-progress-bar`);if(!a){let t=e.ownerDocument,n=t.createElement(`div`);n.className=`wui-tour-progress`,n.setAttribute(`aria-hidden`,`true`),a=t.createElement(`div`),a.className=`wui-tour-progress-bar`,n.append(a),i.before(n)}let o=a.children;for(;o.length<r;){let t=e.ownerDocument.createElement(`span`);t.className=`wui-tour-progress-segment`,a.append(t)}for(;o.length>r;){let e=a.lastElementChild;if(!e)throw Error(`progress bar segment missing`);e.remove()}for(let e=0;e<o.length;e++){let t=o[e];if(!t)throw Error(`progress bar segment missing`);t.toggleAttribute(`data-filled`,e<n)}}var Ye=`wui-tour-step`,Xe=`wui-tour-host`,q=`data-tracking`,J=()=>f(`tour`,p),Ze=()=>({back:J().backLabel,next:J().nextLabel,skip:J().skipLabel,done:J().doneLabel,mediaPause:J().mediaPauseLabel,mediaPlay:J().mediaPlayLabel,endTitle:J().endTitle,endMessage:J().endMessage,endButton:J().doneLabel}),Qe={back:`back-label`,next:`next-label`,skip:`skip-label`,done:`done-label`,mediaPause:`media-pause-label`,mediaPlay:`media-play-label`,endTitle:`end-title`,endMessage:`end-message`,endButton:`end-button`},$e=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],Y={index:null,position:null,total:null},et=0,X=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,Z=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function Q(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`<wui-tour> layer has no ${t}`);return r}var tt=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},$=null;function nt(e){$||($=new CSSStyleSheet,$.replaceSync(Pe)),e.adoptedStyleSheets=[$]}var rt=class extends a{seenStore;onBeforeStep;_run;_running;_layer;_outer;_shadow;_unbindAdvance;_ending;_seenMark;_steps=[];_progress=K(0);_firstIndex=0;_returnFocus=null;_current=null;_moving=!1;_card=null;_spot=null;_live=null;_onKey=null;_onFocusIn=null;static get observedAttributes(){return[`open`]}constructor(){super(),this.seenStore=null,this.onBeforeStep=null,this._run=0,this._running=!1,this._layer=null,this._outer=null,this._shadow=null,this._unbindAdvance=null,this._ending=null,this._seenMark=null}connectedCallback(){this.hasAttribute(`open`)&&this.start()}disconnectedCallback(){this.stop()}attributeChangedCallback(e,t,n){e===`open`&&this.isConnected&&(n===null?this.stop():this.start())}get tourId(){return this.getAttribute(`tour-id`)||``}set tourId(e){e==null||e===``?this.removeAttribute(`tour-id`):this.setAttribute(`tour-id`,String(e))}get isolated(){return this.hasAttribute(`isolated`)}set isolated(e){this.toggleAttribute(`isolated`,e===!0||e===``||e===`true`)}_stepList(){return Array.from(this.querySelectorAll(`:scope > ${Ye}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:(e.textContent??``).trim()};for(let[n,r]of $e)e.hasAttribute(r)&&(t[n]=e.getAttribute(r)??``);return t})}_stepAt(e){let t=this._steps[e];if(!t)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);return t}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?v():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(Qe[e])||Ze()[e]}_endDialogText(){if(this.getAttribute(`end-dialog`)===`false`)return null;let e=(this.getAttribute(`end-next-label`)??``).trim(),t=(this.getAttribute(`end-next-href`)??``).trim();return{title:this._label(`endTitle`),message:this._label(`endMessage`),button:this._label(`endButton`),nextLabel:e,nextHref:t}}_markSeen(e){let t=this._store();return t?t.markSeen(this.tourId,e):null}async start(){if(this._running)return;this._running=!0;let e=++this._run;this.hasAttribute(`open`)||this.setAttribute(`open`,``);try{await this._start(e)}catch(t){throw e===this._run&&(this._running=!1),t}}async _start(e){this._steps=this._stepList(),this._progress=K(this._steps.length);let t=this._store();if(t&&!this.tourId)throw Error(`<wui-tour> needs a tour-id to use a seen store.`);if(t&&await t.isSeen(this.tourId)){e===this._run&&this._finish(`alreadySeen`);return}for(let[e,t]of this._steps.entries())t.target&&!X(document.querySelector(t.target))&&this._progress.drop(e);this._returnFocus=document.activeElement;let n=await this._locate(0,1,e);e===this._run&&(n?(this._firstIndex=n.index,this.dispatchEvent(new CustomEvent(`wui-tour:start`,{bubbles:!0,detail:{total:this._progress.total()}})),e===this._run&&(this._build(),this._show(n))):this._finish(`noTargets`))}next(){return this._move(1)}back(){return!this._current||this._current.index<=this._firstIndex?Promise.resolve():this._move(-1)}async goTo(e){if(this._current){if(!Number.isInteger(e)||e<0||e>=this._steps.length)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);await this._go(e,1)}}stop(){this._running&&(this._run++,this._teardown(),this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`))}async _locate(e,t,n){let r=this._steps;for(let i=e;i>=0&&i<r.length;i+=t){let e=r[i];if(!e)break;if(await this._beforeStep(e,i),n!==this._run)return null;if(!e.target)return{index:i,target:null};let t=document.querySelector(e.target),a=t instanceof HTMLElement||t instanceof SVGElement?t:null;if(X(a))return this._progress.position(i),{index:i,target:a};this._progress.drop(i)}return null}async _beforeStep(e,t){let n=[];this.dispatchEvent(new CustomEvent(`wui-tour:beforestep`,{bubbles:!0,detail:{step:e,index:t,wait:e=>n.push(e)}})),await Promise.all(n),typeof this.onBeforeStep==`function`&&await this.onBeforeStep(e,t)}_build(){let t=`wui-tour-${++et}`,a=document.createElement(`div`);a.className=`wui-tour-layer`,a.replaceChildren(i(`div`,{class:`wui-tour-spot`,"aria-hidden":`true`}),i(`div`,{class:`wui-tour-card`,role:`dialog`,tabindex:`-1`,"aria-labelledby":`${t}-title`,"aria-describedby":`${t}-text`},i(`p`,{class:`wui-tour-position`}),i(`h2`,{class:`wui-tour-title`,id:`${t}-title`}),i(`p`,{class:`wui-tour-text`,id:`${t}-text`}),i(`div`,{class:`wui-tour-actions`},i(`button`,{type:`button`,class:`btn btn-sm btn-link wui-tour-skip`}),i(`div`,{class:`wui-tour-nav`},i(`button`,{type:`button`,class:`${n(`neutral`,`outline`,`sm`)} wui-tour-back`,"data-wui":r}),i(`button`,{type:`button`,class:`${n(`primary`,`solid`,`sm`)} wui-tour-next`,"data-wui":r})))),i(`div`,{class:`visually-hidden`,role:`status`,"aria-live":`polite`}));let s=a;this._shadow=null,this.isolated&&(s=document.createElement(Xe),this._shadow=s.attachShadow({mode:`open`}),nt(this._shadow),this._shadow.appendChild(a)),s.setAttribute(`popover`,`manual`),o(document).appendChild(s),document.documentElement.setAttribute(_,``),this._outer=s,this._layer=a;let c=Q(a,`.wui-tour-spot`,HTMLDivElement),l=Q(a,`.wui-tour-card`,HTMLDivElement),u=Q(a,`[role=status]`,HTMLElement);this._spot=c,this._card=l,this._live=u,Q(l,`.wui-tour-skip`,HTMLElement).addEventListener(`click`,()=>this._close(`skipped`,`button`)),Q(l,`.wui-tour-back`,HTMLElement).addEventListener(`click`,()=>this._move(-1)),Q(l,`.wui-tour-next`,HTMLElement).addEventListener(`click`,()=>this._move(1));let d=e=>this._key(e);this._onKey=d;let f=e=>{let t=this._layer;if(!t||this._ending)return;let n=this._current,r=n?this._stepAt(n.index):null;if(!(e.target instanceof Node))throw Error(`<wui-tour> saw a focus change from a non-node target`);ue(t,r,n?.target??null,e.target)||l.focus()};this._onFocusIn=f,document.addEventListener(`keydown`,d,!0),this._shadow||document.addEventListener(`focusin`,f),e(s,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_raise(){let e=this._outer;if(!e)throw Error(`<wui-tour> raises a step before its host is built`);let t=o(this.ownerDocument);e.parentElement!==t&&t.appendChild(e),s(e)}_show(e){this._current=e;let{index:t,target:n}=e,r=this._stepAt(t),i=this._layer,a=this._spot,o=this._card,s=this._live;if(!i||!a||!o||!s)throw Error(`<wui-tour> shows a step before its layer is built`);this._raise();let c=this._progress.position(t),l=this._progress.total(),u=c===l&&!this._endDialogText(),d=qe(this,c,l);Je(o,{text:d,position:c,total:l}),Ge(o,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)}),o.toggleAttribute(`data-welcome`,!n);let f=T(this,{layer:i,spot:a,card:o},r,n),p=Q(o,`.wui-tour-title`,HTMLElement);p.textContent=r.title||``,p.hidden=!r.title,Q(o,`.wui-tour-text`,HTMLElement).textContent=r.description||``,Q(o,`.wui-tour-skip`,HTMLElement).textContent=this._label(`skip`);let m=Q(o,`.wui-tour-back`,HTMLElement);m.textContent=this._label(`back`),m.hidden=t<=this._firstIndex,Q(o,`.wui-tour-next`,HTMLElement).textContent=this._label(u?`done`:`next`);let h=[d,r.title,r.description].filter(Boolean).join(`. `);s.textContent=f?[h,f].join(/[.!?]$/.test(h)?` `:`. `):h,Ce(o,n),a.removeAttribute(q),this._place(),A(o),this._unbindAdvance?.(),this._unbindAdvance=le(r,n,()=>void this._move(1));let g=this._active();(g!==null&&o.contains(g)?!(g instanceof HTMLElement&&g.hidden):this._shadow!==null&&Z(tt()))||o.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t,position:c,total:l}}))}_place(){if(!this._current||!this._layer)return;let e=this._spot,t=this._card;if(!e||!t)throw Error(`<wui-tour> places a step before its layer is built`);B(e,t,this._current.target)}_follow(){if(!this._current||!this._layer||this._ending)return;let e=this._spot;if(!e)throw Error(`<wui-tour> follows a step before its spot is built`);let t=e.style.cssText;this._place(),e.style.cssText!==t&&e.setAttribute(q,``)}async _move(e){this._current&&await this._go(this._current.index+e,e)}async _go(e,t){if(!this._current||this._moving)return;this._moving=!0;let n=this._run;try{let r=await this._locate(e,t,n);if(n!==this._run)return;if(r){let e=this._card;if(!e)throw Error(`<wui-tour> moved with no card showing`);let t=j(e);if(t!==null&&await t,n!==this._run)return;this._show(r)}else if(t>0){let e=this._endDialogText(),t=e?await this._showEnd(e):`done`;if(n!==this._run)return;let r=await this._close(t===`next`?`next`:`finished`);if(t===`next`&&r&&e){let t=this.ownerDocument.defaultView;if(!t)throw Error(`<wui-tour> has no window to follow its next link in`);t.location.assign(e.nextHref)}}}finally{this._moving=!1}}_showEnd(e){this._unbindAdvance?.(),this._unbindAdvance=null;let t=this._layer,n=this._spot,r=this._card;if(!t||!n||!r)throw Error(`<wui-tour> ends a tour before its layer is built`);return T(this,{layer:t,spot:n,card:r},null,null),n.removeAttribute(q),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),Ne(t,e,this._ending.signal)}_key(e){if(!this._layer||this._ending||e.altKey||e.ctrlKey||e.metaKey)return;let t=u(e.key,d(this));if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this._close(`skipped`,`escape`);else if(t===`ArrowRight`||t===`ArrowLeft`){if(Z(e.composedPath?.()[0]??e.target))return;if(e.preventDefault(),t===`ArrowRight`)this._move(1);else{let e=this._current;if(!e)throw Error(`<wui-tour> moved back with no step showing`);e.index>this._firstIndex&&this._move(-1)}}else if(e.key===`Tab`&&!this._shadow){let t=this._current,n=this._card;if(!t||!n)throw Error(`<wui-tour> cycled focus with no step showing`);de(e,{card:n,active:this._active(),step:this._stepAt(t.index),target:t.target})}}_teardown(){if(!this._layer)return;this._onKey&&document.removeEventListener(`keydown`,this._onKey,!0),this._onFocusIn&&document.removeEventListener(`focusin`,this._onFocusIn);let e=!this._shadow||this._shadow.activeElement!==null||!document.activeElement||document.activeElement===document.body;this._unbindAdvance?.(),this._unbindAdvance=null,this._ending?.abort(),this._ending=null,this._seenMark=null;let n=this._outer;if(t(n),!n)throw Error(`<wui-tour> has a layer with no host to remove`);ve(n),document.documentElement.removeAttribute(_),this._outer=null,this._shadow=null,this._layer=null,this._current=null;let r=this._returnFocus;this._returnFocus=null,e&&r?.isConnected&&(r instanceof HTMLElement||r instanceof SVGElement)&&r.focus()}async _close(e,t=null){let n=this._run,r=this._current,i=r?{index:r.index,position:this._progress.position(r.index),total:this._progress.total()}:Y,a=this._seenMark;this._teardown();let o=e===`next`?`finished`:e,s=!1;try{n===this._run&&await(a??this._markSeen(o)),s=n===this._run}finally{this._finish(e,i,t)}return s}_finish(e,t=Y,n=null){this._run++,this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`),this.dispatchEvent(new CustomEvent(`wui-tour:close`,{bubbles:!0,detail:{reason:e,...t,via:n}}))}};export{rt as t};
|
package/dist/WuiTree-CIOM1G59.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./devWarn-DXdRWZs3.js";import{r as t}from"./dom-DMQu--xV.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{n as r,t as i}from"./formMirror-9IpSgeZb.js";import{t as a}from"./hasOwn-CJsplJ62.js";import{t as o}from"./iconGlyphs.g-a9FtjPXh.js";import{t as s}from"./listboxKeyNav-DNtuh6Ob.js";import{n as c,t as l}from"./rtl-g7G8Bsib.js";import{n as u,r as d,t as f}from"./window-BZWK3rQk.js";import{d as p}from"./wuiHttp-BWf9dDsZ.js";import{r as m}from"./textStore-DBplASiZ.js";import{t as h}from"./tree.g-RId8xZSk.js";var g=()=>m(`tree`,h),_=[`none`,`single`,`multiple`],v=e=>_.some(t=>t===e),y=300,b=8,x=300,S=`parentId`,C=`:scope > input[data-wui-mirror]`,w=[`nodes`,`selection`,`selected`,`values`,`loadChildren`,`loadUrl`,`name`],T=0;function E(e){for(let t=e;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement)if(/^(auto|scroll|overlay)$/.test(getComputedStyle(t).overflowY))return t;return null}var D=class extends n{_uid;_seq;_roots;_byId;_prev;_staged;_els;_checked;_selected;_focusId;_loader;_list;_live;_ready;_flat;_win;_rowH;_rowMeasured;_box;_unbind;_frame;_nav;_onKeyDown;_onClick;_onFocusIn;static get observedAttributes(){return[`selection`,`selected`,`name`,`aria-label`,`loading-text`,`error-text`]}constructor(){super(),this._uid=`wui-tree-${++T}`,this._seq=0,this._roots=[],this._byId=/* @__PURE__ */ new Map,this._prev=null,this._staged=null,this._els=/* @__PURE__ */ new Map,this._checked=/* @__PURE__ */ new Set,this._selected=null,this._focusId=null,this._loader=null,this._list=null,this._live=null,this._ready=!1,this._flat=null,this._win=null,this._rowH=36,this._rowMeasured=!1,this._box=null,this._unbind=null,this._frame=0,this._nav=s({getVisibleOptions:()=>[...this._els.values()].map(e=>e.row),getActive:()=>this._visible().findIndex(e=>e.id===this._focusId),setActive:e=>this._focusNode(this._visible()[e]),getCount:()=>this._visible().length,getOptionAt:e=>this._els.get(this._visible()[e]?.id??``)?.row,findByPrefix:e=>this._visible().findIndex(t=>t.label.toLowerCase().startsWith(e)),onEnter:()=>{let e=this._focusId===null?void 0:this._byId.get(this._focusId);e&&this._activate(e)}}),this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>this._handleClick(e),this._onFocusIn=e=>{if(e.target===this._list){this._focusNode(this._focusId===null?void 0:this._byId.get(this._focusId));return}let t=this._nodeFrom(e.target);t&&t.id!==this._focusId&&this._setRoving(t)}}connectedCallback(){let e=/* @__PURE__ */ new Map;for(let t of w)a(this,t)&&(e.set(t,Reflect.get(this,t)),Reflect.deleteProperty(this,t));if(!this._ready){this._ready=!0;let e=this._readScript();this.replaceChildren(),this._list=t(`ul`,{class:`wui-tree`}),this._list.setAttribute(`role`,`tree`),this._live=t(`div`,{class:`visually-hidden`,role:`status`,"aria-live":`polite`}),this.append(this._list,this._live),e&&this._adoptAll(e)}for(let[t,n]of e)Reflect.set(this,t,n);this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`focusin`,this._onFocusIn),this._render(),this._loadOpenNodes()}disconnectedCallback(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`focusin`,this._onFocusIn),this._unbindWindow(),this._nav.teardown()}attributeChangedCallback(e,t,n){e===`selected`&&(this._selected=n),this._ready&&this.isConnected&&this._render()}get nodes(){return this._roots.map(e=>e.raw)}set nodes(e){this._adoptAll(e??[]),this._render(),this._loadOpenNodes()}get selection(){let e=this.getAttribute(`selection`);return v(e)?e:`none`}set selection(e){this.setAttribute(`selection`,String(e))}get selected(){return this._selected}set selected(e){this._selected=e==null?null:String(e),this._render()}get values(){let e=[],t=n=>{for(let r of n)this._state(r)===`checked`&&e.push(r.id),r.children&&t(r.children)};return t(this._roots),[...e,...[...this._checked].filter(e=>!this._byId.has(e))]}set values(e){this._checked.clear();for(let t of e??[]){let e=this._byId.get(String(t));e?this._setChecked(e,!0):this._checked.add(String(t))}this._render()}get loadChildren(){return this._loader}set loadChildren(e){this._loader=typeof e==`function`?e:null}get loadUrl(){return this.getAttribute(`load-url`)}set loadUrl(e){e==null?this.removeAttribute(`load-url`):this.setAttribute(`load-url`,String(e))}get name(){return this.getAttribute(`name`)}set name(e){e==null?this.removeAttribute(`name`):this.setAttribute(`name`,String(e))}get loadingText(){return this.getAttribute(`loading-text`)??g().loadingText}set loadingText(e){this.setAttribute(`loading-text`,String(e??``))}get errorText(){return this.getAttribute(`error-text`)??g().errorText}set errorText(e){this.setAttribute(`error-text`,String(e??``))}_readScript(){let t=this.querySelector(`:scope > script[type='application/json']`);if(!t)return null;try{return JSON.parse(t.textContent??``)}catch(t){return e(`[@webority/ui-elements] <wui-tree> could not read its JSON nodes:`,t instanceof Error?t.message:void 0),null}}_adoptAll(e){this._flat=null;let t=this._byId;this._prev=t,this._byId=/* @__PURE__ */ new Map;let n;try{n=this._adoptStaged(e,null,1)}catch(e){throw this._byId=t,e}finally{this._prev=null}this._roots=n;for(let e of t.keys())this._byId.has(e)||this._checked.delete(e);for(let e of this._roots)this._passChecksDown(e);this._focusId&&!this._byId.has(this._focusId)&&(this._focusId=null)}_adoptStaged(e,t,n){let r=[],i=[];this._staged={ids:r,checks:i};try{let r=this._adopt(e,t,n);for(let e of i)this._checked.add(e);return r}catch(e){for(let e of r)this._byId.delete(e);throw e}finally{this._staged=null}}_adopt(e,t,n){if(!Array.isArray(e))throw Error(`<wui-tree> nodes must be an array.`);return e.map((e,r)=>{let i=e?.id==null?``:String(e.id);if(!i)throw Error(`<wui-tree> every node needs an id.`);if(this._byId.has(i))throw Error(`<wui-tree> node id "${i}" is used twice.`);let a=this._prev?.get(i),o={id:i,raw:e,parent:t,level:n,seq:++this._seq,pos:r,label:e.label==null?i:String(e.label),icon:e.icon||null,badge:e.badge==null||e.badge===``?null:String(e.badge),badgeTone:e.badgeTone||null,disabled:!!e.disabled,hasChildren:!!e.hasChildren,children:null,expanded:a?a.expanded:!!e.expanded,loading:!1,failed:!1};this._byId.set(i,o),this._staged?.ids.push(i);let s=e.children??(e.hasChildren?a?.children?.map(e=>e.raw):void 0);return Array.isArray(s)&&(o.children=this._adopt(s,o,n+1)),o.loading=!!a?.loading&&o.children===null&&o.hasChildren,e.checked&&!a&&this._staged?.checks.push(i),o})}_passChecksDown(e){e.children?.length&&this._checked.has(e.id)&&(this._checked.delete(e.id),this._setChecked(e,!0));for(let t of e.children??[])this._passChecksDown(t)}_loadOpenNodes(){queueMicrotask(()=>{if(this.isConnected)for(let e of[...this._byId.values()])e.expanded&&e.children===null&&e.hasChildren&&!e.loading&&this._load(e)})}_isBranch(e){return e.children?e.children.length>0:e.hasChildren}_visible(){if(this._flat)return this._flat;let e=[],t=n=>{for(let r of n)e.push(r),r.expanded&&r.children&&t(r.children)};return t(this._roots),this._flat=e,e}_state(e){if(e.children?.length){let t=0,n=0;for(let r of e.children){let e=this._state(r);e===`checked`?t++:e===`unchecked`&&n++}return t===e.children.length?`checked`:n===e.children.length?`unchecked`:`mixed`}return this._checked.has(e.id)?`checked`:`unchecked`}_setChecked(e,t){if(e.children?.length)for(let n of e.children)n.disabled||this._setChecked(n,t);else t?this._checked.add(e.id):this._checked.delete(e.id)}_nodeFrom(e){if(!(e instanceof Element))return null;let t=e.closest(`li.wui-tree-item`);if(!t)return null;for(let[e,n]of this._els)if(n.li===t)return this._byId.get(e)??null;return null}_emit(e,t){this.dispatchEvent(new CustomEvent(`wui-tree:${e}`,{detail:t,bubbles:!0,composed:!0}))}_announce(e){this._live&&(this._live.textContent=e)}_setRoving(e){let t=this._focusId===null?void 0:this._els.get(this._focusId);t&&(t.li.tabIndex=-1),this._focusId=e.id;let n=this._els.get(e.id);n&&(n.li.tabIndex=0),this._syncTab()}_syncTab(){this._list&&(this._focusId!==null&&!this._els.has(this._focusId)?this._list.tabIndex=0:this._list.removeAttribute(`tabindex`))}_focusNode(e){e&&(this._win&&!this._els.has(e.id)&&this._reveal(e),this._setRoving(e),this._els.get(e.id)?.li.focus())}_activate(e){e.disabled||(this.selection===`single`&&(this._selected=e.id,this._render(),this._syncForm()),this._emit(`select`,{id:e.id,node:e.raw}))}_enabledLeaves(e){return e.disabled?[]:e.children?.length?e.children.flatMap(e=>this._enabledLeaves(e)):[e]}_toggleCheck(e){let t=this._enabledLeaves(e);if(!t.length)return;let n=!t.every(e=>this._checked.has(e.id));this._setChecked(e,n),this._render(),this._syncForm(),this._emit(`check`,{id:e.id,checked:n,values:this.values})}_toggleExpand(e){!e.disabled&&this._isBranch(e)&&(e.expanded?(e.expanded=!1,this._render()):this._expand(e))}_expand(e){e.expanded=!0,e.children===null?this._load(e):this._render()}async _load(e){if(e.loading)return;e.loading=!0,e.failed=!1,this._announce(this.loadingText),this._render();let t=[],n=null;try{t=await this._fetchChildren(e)}catch(e){n=e}let r=this._byId.get(e.id);if(!r)this._announce(``);else if(r.loading){if(r.loading=!1,!n)try{r.children=this._adoptStaged(t,r,r.level+1),this._passChecksDown(r),this._announce(``)}catch(e){n=e}n&&(r.failed=!0,r.expanded=!1,this._announce(this.errorText),this._emit(`error`,{id:r.id,message:n instanceof Error?n.message:String(n)})),this._render(),this._syncForm()}}async _fetchChildren(e){if(this._loader)return this._loader(e.raw);let t=this.getAttribute(`load-url`);if(!t)throw Error(`<wui-tree> has a node with children to load but no loadChildren or load-url.`);let n=new URL(t,window.location.href);n.searchParams.set(S,e.id);let r=await p(n.href,{headers:{Accept:`application/json`}});if(!r.ok)throw Error(`Loading children answered ${r.kind}.`);return JSON.parse(r.html)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=this._nodeFrom(t);n&&!n.disabled&&(this._focusNode(n),t.closest(`.wui-tree-toggle`)?this._toggleExpand(n):t.closest(`.wui-tree-check`)?(e.preventDefault(),this._toggleCheck(n)):this._activate(n))}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=this._nodeFrom(e.target);if(!t||e.target!==this._els.get(t.id)?.li)return;let n=c(e.key,l(this));if(n===`ArrowRight`){if(e.preventDefault(),!this._isBranch(t)||t.disabled)return;t.expanded?t.children?.length&&this._focusNode(t.children[0]):this._expand(t)}else n===`ArrowLeft`?(e.preventDefault(),t.expanded&&this._isBranch(t)&&!t.disabled?this._toggleExpand(t):t.parent&&this._focusNode(t.parent)):e.key===` `?(e.preventDefault(),this.selection===`multiple`?this._toggleCheck(t):this.selection===`single`&&this._activate(t)):this._nav.handler(e)}_syncForm(){let e=this.selection;if(e===`multiple`)r(this,this.values);else if(e===`single`)i(this,this._selected??``);else for(let e of this.querySelectorAll(C))e.remove()}_render(){if(!this._list)return;this._flat=null;let e=document.activeElement,t=!!e&&this._list.contains(e),n=this._visible();n.some(e=>e.id===this._focusId)||(this._focusId=(n.find(e=>e.id===this._selected)??n[0])?.id??null);let r=this.getAttribute(`aria-label`);if(r?this._list.setAttribute(`aria-label`,r):this._list.removeAttribute(`aria-label`),n.length>y){this._bindWindow();let e={heights:f(n.length,this._rowH),start:0,end:0};this._win=e,this._paint(n,e)}else this._unbindWindow(),this._win=null,this._list.style.paddingTop=``,this._list.style.paddingBottom=``,this._drawRows(n);t&&this._focusId&&this._els.get(this._focusId)?.li.focus(),this._syncForm()}_drawRows(e){this._list&&(this._els=/* @__PURE__ */ new Map,this._list.replaceChildren(...e.map(e=>this._buildItem(e))),this._syncTab())}_metrics(){let e=this._box,t=this._list?.getBoundingClientRect().top??0,n=e?e.getBoundingClientRect().top:0,r=(e?e.clientHeight:window.innerHeight)||x;return{scrollTop:Math.max(0,n-t),viewport:r}}_rangeOf(e){return d(e.heights,{...this._metrics(),overscan:b})}_draw(e,t){let{start:n,end:r}=this._rangeOf(t);t.start=n,t.end=r,this._drawRows(e.slice(n,r));let i=this._list?.style;i&&(i.paddingTop=`${t.heights.offsetOf(n)}px`,i.paddingBottom=`${t.heights.total()-t.heights.offsetOf(r)}px`)}_measure(e,t){let{heights:n}=t,r=n.indexAt(this._metrics().scrollTop),i=n.offsetOf(r),a=!1;for(let r=t.start;r<t.end;r++){let t=e[r]?.id,i=t===void 0?void 0:this._els.get(t)?.li,o=i?i.getBoundingClientRect().height:0;if(o>0){if(!this._rowMeasured){this._rowMeasured=!0,this._rowH=o;let e=n.estimate;n.setEstimate(o),n.estimate!==e&&(a=!0)}n.set(r,o)&&(a=!0)}}return a?{changed:a,delta:n.offsetOf(r)-i}:{changed:!1,delta:0}}_scrollBy(e){this._box?this._box.scrollTop+=e:window.scrollBy(0,e)}_paint(e,t){this._draw(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=this._measure(e,t);if(!n)return;r&&this._scrollBy(r),this._draw(e,t)}}_repaintWindow(){let e=this._win;if(!e||!this._list)return;let{start:t,end:n}=this._rangeOf(e);if(t===e.start&&n===e.end)return;let r=document.activeElement,i=!!r&&this._list.contains(r);this._paint(this._visible(),e),i&&this._focusId&&this._els.get(this._focusId)?.li.focus({preventScroll:!0})}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._repaintWindow()})}_reveal(e){let t=this._win;if(!t)return;let n=this._visible(),r=n.indexOf(e);if(!(r<0))for(let i=0;i<2;i++){let i=this._metrics(),a=u(t.heights,r,i);if(Math.abs(a-i.scrollTop)>.5)this._scrollBy(a-i.scrollTop);else if(this._els.has(e.id))break;this._paint(n,t)}}_bindWindow(){if(this._unbind||!this.isConnected)return;let e=E(this),t=e??window,n=()=>this._schedule();t.addEventListener(`scroll`,n,{passive:!0});let r=null;e?(r=new ResizeObserver(n),r.observe(e)):window.addEventListener(`resize`,n),this._box=e,this._unbind=()=>{t.removeEventListener(`scroll`,n),r?r.disconnect():window.removeEventListener(`resize`,n)}}_unbindWindow(){this._unbind?.(),this._unbind=null,this._box=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0}_buildItem(e){let n=e.parent?e.parent.children?.length??0:this._roots.length,r=this.selection,i=this._isBranch(e),a=this._state(e),s=t(`li`,{class:`wui-tree-item`,role:`treeitem`,tabindex:e.id===this._focusId?0:-1,"aria-level":e.level,"aria-setsize":n,"aria-posinset":e.pos+1,"aria-labelledby":`${this._uid}-${e.seq}`,"aria-describedby":e.badge?`${this._uid}-${e.seq}-badge`:null});i&&s.setAttribute(`aria-expanded`,String(e.expanded)),e.disabled&&s.setAttribute(`aria-disabled`,`true`),e.loading&&s.setAttribute(`aria-busy`,`true`),r===`single`&&s.setAttribute(`aria-selected`,String(e.id===this._selected)),r===`multiple`&&s.setAttribute(`aria-checked`,a===`mixed`?`mixed`:String(a===`checked`));let c=t(`div`,{class:`wui-tree-row`,role:`presentation`});c.style.setProperty(`--wui-tree-level`,String(e.level-1)),r===`single`&&e.id===this._selected&&c.classList.add(`wui-tree-row-selected`),e.failed&&c.classList.add(`wui-tree-row-error`);let l=t(`span`,{class:i?`wui-tree-toggle`:`wui-tree-toggle wui-tree-toggle-leaf`,"aria-hidden":`true`});if(i){let e=o(`chevron-right`,{size:16});l.replaceChildren(...e?[e]:[])}if(c.append(l),r===`multiple`){let n=t(`input`,{class:`form-check-input wui-tree-check`,type:`checkbox`,tabindex:-1,"aria-hidden":`true`});n.checked=a===`checked`,n.indeterminate=a===`mixed`,n.disabled=e.disabled,n.addEventListener(`mousedown`,e=>e.preventDefault()),c.append(n)}if(e.icon){let n=t(`span`,{class:`wui-tree-icon`,"aria-hidden":`true`}),r=o(e.icon,{size:16});n.replaceChildren(...r?[r]:[]),c.append(n)}let u=t(`span`,{class:`wui-tree-label`,id:`${this._uid}-${e.seq}`});if(u.textContent=e.label,c.append(u),e.badge){let n=e.badgeTone&&e.badgeTone!==`neutral`?` badge-${e.badgeTone}`:``,r=t(`span`,{class:`badge wui-tree-badge${n}`,id:`${this._uid}-${e.seq}-badge`});r.textContent=e.badge,c.append(r)}return e.loading&&c.append(t(`span`,{class:`wui-tree-spinner`,"aria-hidden":`true`})),s.append(c),this._els.set(e.id,{li:s,row:c}),s}};export{D as t};
|
|
@@ -1 +0,0 @@
|
|
|
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-C2hgZrCR.js";import{r as s,t as c}from"./textStore-DBplASiZ.js";import{t as l}from"./drawer.g-B-zYKBfQ.js";import{a as u,i as d,n as f,r as p,t as m}from"./tableSelect.g-Bmd-ExRE.js";import{M as h,O as ee,T as te,b as ne,j as re,y as ie}from"./dataTable-VB3nBucm.js";import{n as g,t as _}from"./devWarn-DXdRWZs3.js";import{t as ae}from"./hasOwn-CJsplJ62.js";import{t as oe}from"./svgNodes-CyPS2oFH.js";import{t as se}from"./serverHtml-BC6tAyAl.js";import{t as ce}from"./iconGlyphs.g-a9FtjPXh.js";import{LIST_QUERY_RESERVED as le,SEARCH_PARAM as ue}from"./listQuery.js";import{t as de}from"./dataTable.g-DazoWWps.js";import{c as fe,d as v,u as pe}from"./wuiHttp-BWf9dDsZ.js";var y=()=>s(`tableSelect`,m),b=`wui-select-cell`,x=(e,t)=>{let n=e.createElement(`input`);return n.type=`checkbox`,n.className=`wui-check`,n.setAttribute(`aria-label`,t),n};function me(e=document){let t=e.createElement(`th`);return t.className=b,t.appendChild(x(e,y().selectAllLabel)),t}function he(e=document,{disabled:t=!1}={}){let n=e.createElement(`td`);n.className=b;let r=x(e,y().selectRowLabel);return r.disabled=t,n.appendChild(r),n}function S(e=document){let t=e.createElement(`td`);return t.className=b,t}var ge=e=>e.firstElementChild?.classList.contains(b),C=e=>e.matches(`.wui-group-row, .wui-virtual-spacer, .wui-row-expanded`),w=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n);function _e(e){for(let t of e){if(ge(t)||C(t))continue;let e=t.getAttribute(`data-row-selectable`)===`false`;t.insertBefore(he(t.ownerDocument,{disabled:e}),t.firstChild)}}function ve(e){let t=e.querySelector(`thead tr`);if(!(t instanceof HTMLTableRowElement))return null;ge(t)||t.insertBefore(me(e.ownerDocument),t.firstChild),_e(w(e,`tbody tr`,HTMLTableRowElement));for(let t of w(e,`tfoot tr`,HTMLTableRowElement))ge(t)||t.insertBefore(S(e.ownerDocument),t.firstChild);let n=t.querySelector(`.${b} .wui-check`);return n instanceof HTMLInputElement?n:null}function ye(e){let t=e.querySelector(`thead .${b} .wui-check`),n=w(e,`tbody tr .wui-check:not(:disabled)`,HTMLInputElement),r=n.length,i=n.filter(e=>e.checked).length;t instanceof HTMLInputElement&&(t.checked=r>0&&i===r,t.indeterminate=i>0&&i<r);for(let t of w(e,`tbody tr`,HTMLTableRowElement)){let e=t.querySelector(`.wui-check`);t.classList.toggle(`is-selected`,e instanceof HTMLInputElement&&e.checked)}return{selected:i,total:r}}var be=`tbody .${b} .wui-check:not(:disabled)`;function xe(e,t){let n=null,r=e=>e instanceof Element&&e.matches(`.wui-select-cell .wui-check:not(:disabled)`)&&!!e.closest(`tbody`);e.addEventListener(`mousedown`,e=>{e.shiftKey&&r(e.target)&&e.preventDefault()}),e.addEventListener(`click`,i=>{let a=i.target;if(r(a)){if(i.shiftKey&&n?.isConnected&&n!==a){let r=w(e,be,HTMLInputElement),i=r.indexOf(n),o=r.indexOf(a);if(i>=0&&o>=0){let e=[];for(let t of r.slice(Math.min(i,o),Math.max(i,o)+1))t!==a&&t.checked!==a.checked&&(t.checked=a.checked,e.push(t));e.length&&t?.(e,a.checked)}}n=a}})}var T=()=>s(`dataTable`,de),Se=5,Ce=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,we=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,Te=e=>Ce(e)&&`type`in e&&e.type===`hidden`,E=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),D=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},O=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Ee=e=>e.localName===`wui-select`,De=/* @__PURE__ */ new WeakMap,k=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},Oe=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)}),ke=(e,t)=>{e&&P().toast(e,{variant:t})},Ae=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!Te(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!le.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of E(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},je=new Intl.NumberFormat(`en-IN`),Me=(e,t)=>t?`${je.format(e)}+`:je.format(e),Ne=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?D(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Me(t,n))};function Pe(e=document){let t=E(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if(De.has(e))continue;let t=Fe(e);De.set(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function A(e){let t=e instanceof Element?O(e,`[data-wui-server]`,HTMLElement):null;return t&&De.get(t)||null}function Fe(i){let a=D(i,`.table-wrap`,HTMLElement),o=a?D(a,`:scope > table`,HTMLTableElement):null,s=i.dataset.src;if(!a||!o||!s)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let l=D(a,`:scope > [data-wui-table-state]`,HTMLElement),u=D(i,`[data-wui-table-pager]`,HTMLElement),d=D(i,`[data-wui-table-status]`,HTMLElement),f={urlState:i.dataset.urlState!==`false`,refreshOnSuccess:i.dataset.refreshOnSuccess!==`false`,filtersForm:i.dataset.filtersForm||null,filtersRegion:i.dataset.filtersRegion||null,searchInput:i.dataset.searchInput||null,loadingText:i.dataset.loadingText||T().loadingText,errorText:i.dataset.errorText||T().errorText,timeoutMs:pe(i.getAttribute(`data-wui-timeout`))??3e4},p=new URL(s,window.location.href),m=i.dataset.totalSrc||null,ae=m===null?null:new URL(m,window.location.href),oe=/* @__PURE__ */ new Set([...p.searchParams.keys(),...ae?.searchParams.keys()??[]]),de=o.hasAttribute(`data-app-datatable-selectable`),y=/* @__PURE__ */ new Set,x=!1,me=fe(),he=new AbortController,S={signal:he.signal},ge=D(o,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),C=n(ge,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),w=Oe(C),be=null,De=null,je=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))oe.has(n)||t.append(n,r);return t},Pe=e=>je(new URL(e,window.location.href).search),A=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},Fe=(e,t)=>{let n=new URL(e.href);for(let[e,r]of t)oe.has(e)||n.searchParams.append(e,r);return n.origin===window.location.origin?`${n.pathname}${n.search}`:n.href},Ie=e=>Fe(p,e),Le=(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},j=Le(f.urlState?je(window.location.search):new URLSearchParams,w);f.urlState&&A(j)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,A(j));let M=(e,t)=>a.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),N=e=>{d&&(d.textContent=e)},ze=e=>{if(e.pending)return e.rowCount===0?T().emptyLabel:c(T().pageTextPending,{page:e.page});if(e.total===0)return T().emptyLabel;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Me(e.total,!0):`${e.total}`;return c(e.total===1?T().pageTextOne:T().pageTextOther,{page:e.page,pages:t,total:n})},Be=()=>E(o,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),Ve=e=>{if(de&&E(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.`)},He=e=>{let t=i.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`)}},Ue=e=>{if(de){_e(e);for(let t of e){let e=D(t,`.${b} .wui-check:not(:disabled)`,HTMLInputElement);e&&(x&&y.add(t.dataset.rowKey),e.checked=y.has(t.dataset.rowKey))}ye(o)}He(e);let t=Be();if(o.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`)})},We=e=>Ue(E(e,`:scope > tr`,HTMLTableRowElement)),F=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},I=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),Ge=(e,t)=>{if(!l)return;let n=D(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);I(l),(t.pending?t.rowCount:t.total)===0&&n?(l.replaceChildren(n.content.cloneNode(!0)),l.hidden=!1):(l.replaceChildren(),l.hidden=!0)},Ke=e=>{u&&(I(u),u.replaceChildren(...e?[e.content.cloneNode(!0)]:[]),u.hidden=!1)},qe=e=>{let t=f.filtersRegion&&e?D(document,f.filtersRegion,HTMLElement):null;return t&&e&&(I(t),t.replaceChildren(e.content.cloneNode(!0))),t},Je=0,Ye=e=>{let t=Oe(e);t.pending&&Object.assign(t,{total:w.total,totalCapped:w.totalCapped});let n=t.sortBy!==w.sortBy||t.sortOrder!==w.sortOrder?ie(C.rows):null;Ke(D(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement)),Ge(e,t);let r=qe(D(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement));F(e),I(C),o.replaceChild(e,C),C=e,Je+=1;let i=x&&t.total!==w.total;return w=t,i&&(x=!1),a.removeAttribute(`data-wui-table-error`),We(e),nt(),te(e.rows,n),i&&U(),r},Xe=e=>{let t=D(se(`<table>${e}</table>`),`tbody[data-wui-rows]`,HTMLTableSectionElement);return t&&Ve(t),t?document.importNode(t,!0):null},Ze=(e,t=Be())=>{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},Qe=()=>{if(C.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,Be().length);C.replaceChildren(...Array.from({length:Se},()=>{let t=Ze(e);return t.setAttribute(`data-wui-skeleton`,``),t})),a.removeAttribute(`data-wui-table-error`),l&&(l.hidden=!0)},$e=e=>{e?(a.setAttribute(`aria-busy`,`true`),Qe()):a.removeAttribute(`aria-busy`)},L=e=>e===`forbidden`?T().forbiddenMessage:e===`network`?T().networkMessage:e===`timeout`?T().timeoutMessage:f.errorText,et=n=>{let r=L(n);if(a.setAttribute(`data-wui-table-error`,n),u&&(u.hidden=!0),l){let i=document.createElement(`div`);i.className=`empty-state wui-empty-state-table wui-table-error`,i.setAttribute(`role`,`alert`);let a=document.createElement(`span`);a.className=`empty-state-icon`;let o=ce(n===`forbidden`?`lock`:`alert-circle`,{size:24});o&&a.replaceChildren(o);let s=document.createElement(`div`);s.className=`empty-state-title`,s.textContent=r;let c=document.createElement(`div`);c.className=`empty-state-action`;let u=document.createElement(`button`);u.type=`button`,u.className=e(`primary`,`outline`,`sm`),u.dataset.wui=t,u.setAttribute(`data-wui-table-retry`,``),u.textContent=T().retryLabel,c.append(u),i.append(a,s,c),I(l),l.replaceChildren(i),l.hidden=!1}N(r)},R=()=>f.filtersForm?D(document,f.filtersForm,HTMLFormElement):null,z=async(e,t=`none`,{quiet:n=!1}={})=>{let r=new URLSearchParams(e);n||(be={query:r,mode:t},$e(!0),N(f.loadingText)),M(`wui:table:loading`,{query:r.toString()});let o=await me.run(Ie(r),{timeoutMs:f.timeoutMs});if(o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return o;n||$e(!1);let s=null;if(o.ok)try{s=Xe(o.html)}catch(e){_(e)}if(!o.ok||!s){let e=o.ok?`server`:o.kind;return n?g(`A quiet server table refresh failed; the rows on screen are kept.`,e):et(e),M(`wui:table:error`,{status:o.status,kind:e,message:L(e)}),o}let c=Ye(s);return j=Le(r,w),Ae(R(),j),f.urlState&&t===`push`?window.history.pushState(window.history.state,``,A(j)):f.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,A(j)),n||N(ze(w)),P().refresh(a),c&&P().refresh(c),w.pending?tt():Ne(i,w.total,w.totalCapped),M(`wui:table:loaded`,{...w,query:j.toString()}),o},B=e=>(e.delete(`page`),e),tt=()=>{if(!ae||!w.pending)return;let e=Je;v(Fe(ae,j),{timeoutMs:f.timeoutMs}).then(t=>{if(e!==Je)return;if(!t.ok){g(`[@webority/ui-elements] A server table's total did not load; its pager keeps Previous and Next.`,t.kind);return}let n=D(se(t.html),`div[data-wui-total]`,HTMLElement);if(!n){g(`[@webority/ui-elements] A server table's count answer has no div[data-wui-total]; its pager keeps Previous and Next.`);return}if(k(n.dataset.page,-1)!==w.page||k(n.dataset.pageSize,-1)!==w.pageSize)return;let r=k(n.dataset.total,-1);if(r<0){g(`[@webority/ui-elements] A server table's count answer has no whole data-total; its pager keeps Previous and Next.`);return}let a=n.dataset.totalCapped===`true`,o=x&&r!==w.total;w={...w,total:r,totalCapped:a,pending:!1},o&&(x=!1);let s=D(n,`:scope > template[data-wui-pager]`,HTMLTemplateElement);s&&Ke(s);let c=qe(D(n,`:scope > template[data-wui-filters]`,HTMLTemplateElement));c&&P().refresh(c),Ne(i,w.total,w.totalCapped),N(ze(w)),o&&U(),M(`wui:table:total`,{total:r,totalCapped:a})})},V=()=>E(o,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),nt=()=>{for(let e of V()){let t=e.dataset.sortKey===w.sortBy;e.setAttribute(`aria-sort`,t?w.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of V())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=ce(`chevrons-up-down`,{size:14});r&&n.replaceChildren(r),t?e.prepend(n):e.append(n)}let H=e=>{let t=B(new URLSearchParams(j)),n=w.sortBy===e&&w.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),z(t,`push`)};o.addEventListener(`click`,e=>{let t=e.target instanceof Element?O(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&o.tHead?.contains(t)&&H(t.dataset.sortKey??``)}),o.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?O(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&o.tHead?.contains(t)&&(e.preventDefault(),H(t.dataset.sortKey??``))});let U=()=>{ye(o);let e=x?{selected:w.total,total:w.total,allMatching:x}:{selected:y.size,total:w.total};o.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};de&&(xe(o,(e,t)=>{for(let n of e){let e=O(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?y.add(e):y.delete(e))}t||(x=!1)}),o.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.wui-select-cell .wui-check:not(:disabled)`)){if(t.checked||(x=!1),o.tHead?.contains(t))for(let e of E(C,`:scope > tr`,HTMLTableRowElement)){let n=D(e,`.${b} .wui-check:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?y.add(e.dataset.rowKey):y.delete(e.dataset.rowKey))}else{let e=O(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?y.add(e):y.delete(e)}U()}})),u&&(u.addEventListener(`click`,e=>{let t=e.target instanceof Element?O(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),z(Pe(t.getAttribute(`href`)??``),`push`))}),u.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),z(Pe(t.value),`push`))}));let rt=()=>{if(!f.searchInput)return null;let e=D(document,f.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?D(e,`input`,HTMLInputElement):null},W=()=>i.isConnected?!0:(he.abort(),clearTimeout(De??void 0),!1),it=(e,t)=>{let n=[...e.elements].filter(Ce),r=/* @__PURE__ */ new Set;for(let e of n)e.name&&!Te(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!we(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},G=(e,t)=>{let n=new Set([...e.elements].filter(Ce).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&le.includes(e);for(let[e,t]of j)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of it(e,t))a===``||i(n)||oe.has(n)||r.append(n,a);let a=rt();if(a){r.delete(ue);let e=a.value.trim();e&&r.set(ue,e)}return z(r,`push`)},at=e=>f.filtersForm&&e.closest?.(f.filtersForm)||f.filtersRegion&&e.closest?.(f.filtersRegion)||null;document.addEventListener(`submit`,e=>{W()&&f.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(f.filtersForm)&&(e.preventDefault(),G(e.target,e.submitter))},S),document.addEventListener(`change`,e=>{if(!W()||!f.filtersForm||!(e.target instanceof Element))return;let t=O(e.target,f.filtersForm,HTMLFormElement);!t||e.target===rt()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||G(t)},S);let ot=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of E(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 E(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(Ee)){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`)||t.getAttribute(`name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!W())return;let t=e.target instanceof Element?O(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!at(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=B(Pe(n.href));ot(t.closest(`form`),r),Ae(t.closest(`form`),r),z(r,`push`)},S),document.addEventListener(`input`,e=>{if(!W())return;let t=rt();t&&e.target===t&&(clearTimeout(De??void 0),De=setTimeout(()=>{if(!W())return;let e=B(new URLSearchParams(j)),n=t.value.trim();n?e.set(ue,n):e.delete(ue),e.toString()!==j.toString()&&z(e,`replace`)},300))},S),f.urlState&&window.addEventListener(`popstate`,()=>{if(!W())return;let e=je(window.location.search),t=rt();t&&(t.value=e.get(`search`)??``),Ae(R(),e),z(e,`none`)},S),document.addEventListener(`wui:modal:success`,()=>{W()&&f.refreshOnSuccess&&z(j,`none`)},S),l?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&be&&z(be.query,be.mode)});let st=e=>[...C.rows].find(t=>t.dataset.rowKey===e)??null,K=e=>{if(!e?.trim())return null;let t=se(`<table><tbody>${e}</tbody></table>`);if(t.querySelector(`tbody[data-wui-rows]`))return null;let n=E(t,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},ct=(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:st(n.dataset.rowKey);e&&(I(e),e.replaceWith(n),i.push(n))}return Ue(i),P().refresh(a),r},lt=e=>e.message||(e.kind===`forbidden`?T().actionForbiddenMessage:T().actionFailedMessage),ut=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&h(e,null)},dt=async({url:e,method:t=`POST`,body:n,key:i,row:o}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let s=i==null,c=s?null:st(String(i));if(!s&&!c)throw Error(`saveRow found no row with data-row-key="${i}" on this page.`);let u=Be().filter(e=>!e.classList.contains(b)),d=o===void 0?c??Ze(Math.max(1,u.length),u):r(o,HTMLTableRowElement,"saveRow's `row` is required to be a row element: the <tr> as it will read, not its HTML.");c&&d!==c?c.replaceWith(d):c||C.insertBefore(d,C.firstChild),d!==c&&Ue([d]),l&&!a.hasAttribute(`data-wui-table-error`)&&(l.hidden=!0),h(d,`saving`);let f=ee(d),p=await v(e,{method:t.toUpperCase(),body:n});if(p.kind===`session`)return!1;if(p.ok){let e=K(p.html),t=e&&d.isConnected?ct(e,d,s):null;return t?N(re(ee(t)||f)):(await z(j,`none`),ut(d)),Re(p,p.toastVariant||`success`),M(`wui:table:saved`,{key:t?.dataset.rowKey??(s?null:String(i)),added:s,status:p.status}),!0}let m=lt(p),te=d;return c&&d!==c&&d.isConnected?(d.replaceWith(c),te=c):s&&!o&&(d.remove(),te=null,l?.childElementCount&&!C.querySelector(`:scope > tr`)&&(l.hidden=!1)),te?.isConnected&&h(te,`error`,m),p.kind!==`aborted`&&ke(m,`danger`),N(ne(f,m)),M(`wui:table:failed`,{key:s?null:String(i),added:s,status:p.status,kind:p.kind,message:m}),!1},ft=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 n=O(e,`tr`,HTMLTableRowElement),r=n?.dataset.rowKey??null,i=e.dataset.wuiRowAction||``,a=n?ee(n):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),n&&h(n,`saving`);let o=await v(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),o.kind===`session`||o.kind===`aborted`)ut(n);else{if(o.ok){Re(o,o.toastVariant||`success`);let e=n?.isConnected?K(o.html):null,t=e&&n?ct(e,n,!1):null;t?N(re(ee(t)||a)):(await z(j,`none`),ut(n))}else{let e=lt(o);ke(e,`danger`),n?.isConnected&&h(n,`error`,e),N(ne(a,e))}M(`wui:table:action`,{action:i,key:r,ok:o.ok,status:o.status})}};return o.addEventListener(`click`,e=>{let t=e.target instanceof Element?O(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&C.contains(t)&&!t.disabled&&(e.preventDefault(),ft(t))}),Ve(C),F(C),de&&ve(o),We(C),nt(),w.pending&&(N(ze(w)),tt()),{el:i,reload:async e=>{let t=e?.quiet===!0;return t&&a.getAttribute(`aria-busy`)===`true`?null:z(j,`none`,{quiet:t})},query:()=>new URLSearchParams(j),setQuery:e=>{let t=new URLSearchParams(j);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`),z(t,`push`)},saveRow:dt,setActiveRow:e=>{i.dataset.activeRowKey=e==null?``:String(e),He(E(C,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...y],count:()=>x?w.total:y.size,allMatching:()=>x,selectAllMatching:()=>{if(w.pending)g(`[@webority/ui-elements] select all matching needs the total; the table is still waiting for its count.`);else{x=!0;for(let e of E(C,`:scope > tr`,HTMLTableRowElement)){let t=D(e,`.${b} .wui-check`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&y.add(e.dataset.rowKey))}U()}},clear:()=>{x=!1,y.clear();for(let e of E(C,`:scope > tr > .${b} .wui-check:not(:disabled)`,HTMLInputElement))e.checked=!1;U()}}}}var Ie=8e3,Le=()=>s(`toast`,f),j=[`success`,`info`,`warning`,`danger`],M=e=>j.some(t=>t===e);function N(e){if(!M(e))throw RangeError(`Unknown toast variant "${e}".`);return e}function P(){return n(window.WUI,`window.WUI is not defined: the Razor behaviour script did not load on this page.`)}function Re(e,t=`success`){if(!e?.message)return;let n=e.toastAction;n?P().toast(e.message,{variant:N(t),duration:Ie,action:{label:n.label,onClick:()=>ze(n)}}):P().toast(e.message,{variant:N(t)})}async function ze(e){let t=await v(e.url,{method:e.method});if(t.kind!==`session`&&t.kind!==`aborted`){if(t.ok){Re(t,t.toastVariant||`success`);for(let e of document.querySelectorAll(`[data-wui-server]`))e instanceof HTMLElement&&e.dataset.refreshOnSuccess!==`false`&&A(e)?.reload()}else P().toast(t.message||Le().failedText,{variant:`danger`})}}var Be=`wui-remote-modal`,Ve=`wui-remote-drawer`,He=Object.freeze({sm:360,md:480,lg:640,xl:720}),Ue=`wui-modal-fullscreen`,We=`wui-modal-wide`,F=Object.freeze({sm:380,md:440,lg:640,xl:880,wide:1080}),I=()=>s(`modal`,p),Ge=e=>pe(e?.getAttribute(`data-wui-timeout`)??null)??3e4,Ke=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,qe=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,Je=`[aria-invalid="true"], .is-invalid, .input-validation-error`,Ye=`invalid`,Xe=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,Ze=`[data-wui-modal-content]`,Qe=`[data-wui-pane-close], [data-wui-dismiss]`,$e=()=>i(`button`,{type:`button`,class:`wui-modal-close`,"data-wui-dismiss":!0,"aria-label":I().closeLabel},oe({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`}]])),L=/* @__PURE__ */ new WeakMap,et=/* @__PURE__ */ new WeakSet;function R(e,t){if(e==null)throw TypeError(`The remote modal needs ${t}, and the page does not have it.`);return e}var z=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},B=(e,t,n)=>R(z(e,t),n),tt=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),V=()=>Object.assign(/* @__PURE__ */ Error(`The remote modal load was aborted.`),{name:`AbortError`}),nt=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,H=(e,t)=>{let n=e instanceof Element?e.closest(t):null;return n instanceof HTMLElement?n:null},U=e=>ae(F,e),rt=e=>ae(He,e);function W(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(U(e))return e===`wide`?{px:F.wide,wide:!0}:{px:F[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 it=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};if(e.classList.contains(`wui-modal-wide`))return{px:F.wide,wide:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:F.md}},G=(e,t)=>{e.classList.toggle(Ue,!!t.fullscreen),e.classList.toggle(We,!t.fullscreen&&!!t.wide),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},at=[`center`,`top`];function ot(e){if(e==null||e===``)return null;if(rt(e))return{px:He[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 st=e=>e.container===`drawer`,K=e=>e.container===`pane`,ct=e=>e.container!==`modal`,lt=(e,t)=>st(e)?ot(t):W(t),ut=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},dt=e=>K(e)?e.shell:B(e.shell,`.modal-dialog`,`a dialog frame`);function ft(e=`modal`){let t=e===`drawer`,n=t?Ve:Be,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?He.md:F.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 pt=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))),$e()),mt=e=>i(`div`,{class:`modal-content wui-modal`,"aria-busy":`true`},pt(e),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-loading`,role:`status`},i(`span`,{class:`visually-hidden`},I().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`})))),ht=(n,r)=>{let a={forbidden:I().forbiddenMessage,client:I().clientMessage,server:I().serverMessage,network:I().networkMessage,timeout:I().timeoutMessage};return i(`div`,{class:`modal-content wui-modal`,"data-wui-modal-error":r},pt(n),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-state`,role:`alert`},i(`p`,{class:`wui-modal-state-title`},I().errorTitle),i(`p`,{class:`wui-modal-state-text`},a[r]||I().serverMessage),i(`div`,{class:`wui-modal-state-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":!0,"data-wui":t},I().closeLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-wui-modal-retry":!0,"data-wui":t},I().retryLabel)))))},q=e=>z(e.shell,`.modal-content`),gt=e=>r(e.cloneNode(!0),HTMLElement,`a card copy is not an element`);function _t(e){e&&e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}))}function vt(e,t){let n=q(e),r=n?bt(n):/* @__PURE__ */ new Map;_t(n),n?n.replaceWith(t):dt(e).appendChild(t),xt(t,r),P().refresh()}var yt=`input[type="file"][name]`;function bt(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(yt)){if(!(n instanceof HTMLInputElement))continue;let e=n.files;e&&e.length>0&&t.set(n.name,[...e])}return t}function xt(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(yt)){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 St=e=>K(e)?!e.shell.hidden:e.host.hasAttribute(`open`);function Ct(e,t,n=!1){let r=t?z(e,Je):null,i=r?r.matches(Ke)?r:z(r,Ke)||r:null;if(!i&&n)i=z(e,`[data-autofocus]`)||z(e,qe)||z(e,`.wui-modal-close`);else if(!i){let t=tt(e,Ke);i=z(e,`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}r?i?.focus?.():i?.focus?.({preventScroll:!0})}function wt(e,t){let n=z(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`,``),dt(e).appendChild(n)),n.textContent=``,n.textContent=t}var Tt=e=>{let t=z(e.shell,`[data-wui-modal-live]`);t&&(t.textContent=``)},Et=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};function Dt(e,t,n,r){let i={...r,container:e.container};Et(t,`wui:modal:${n}`,i),st(e)&&Et(t,`wui:drawer:${n}`,i),K(e)&&Et(t,`wui:pane:${n}`,i)}var Ot=e=>e.matches(`[data-wui-pane-host]`)?`pane`:B(e,`dialog`,`a dialog`).classList.contains(`wui-remote-drawer`)?`drawer`:`modal`,kt=e=>R(e.host.closest(`wui-modal`),`a wui-modal host`);function At(e){let t=L.get(e);if(t)return t;let n=Ot(e),r=n===`pane`?e:B(e,`dialog`,`a dialog`),a=q({shell:r}),o={host:e,shell:r,container:n,queue:fe(),defaultSize:it(r),defaultLabel:r.getAttribute(`aria-label`),placeholder:a?gt(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 L.set(e,o),e.addEventListener(`submit`,e=>Zt(o,e)),e.addEventListener(`click`,e=>{H(e.target,`[data-wui-modal-retry]`)&&o.session&&(e.preventDefault(),Lt(o,o.session))}),K(o)&&e.addEventListener(`click`,t=>{let n=H(t.target,Qe);n&&e.contains(n)&&o.session&&J(o,o.session,`dismissed`,null)}),e.addEventListener(`wui-modal-close`,t=>{t.target===e&&t instanceof CustomEvent&&qt(t.detail,`reason`)===`escape`&&e.querySelector(`form[data-wui-submitting]`)&&t.preventDefault()}),e.addEventListener(`wui-modal-closed`,t=>{t.target===e&&Pt(o)}),e.addEventListener(`wui-modal-opened`,t=>{if(t.target!==e)return;let n=q(o);o.session&&n?.matches(Ze)&&!n.contains(document.activeElement)&&Ct(n,!1,ct(o))}),o.remoteUrl&&e.addEventListener(`wui-modal-open`,t=>{t.target===e&&Ft(o,t)}),o}function jt(e,t,n){e.session&&(e.queue.abort(),e.session.resolveClosed({status:`dismissed`,detail:{replaced:!0}}));let r=()=>void 0,i=new Promise(e=>{r=e}),a={url:t,method:(n.method||`GET`).toUpperCase(),body:n.body,options:n,trigger:n.trigger||null,explicitSize:null,closing:null,resolveClosed:r,handle:{el:e.shell,closed:i,close:()=>J(e,a,`dismissed`,null),reload:()=>Lt(e,a)}};return e.session=a,a}function J(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},K(e)?Nt(e,t):Mt(e))}function Mt(e){let t=kt(e);t.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:`dismiss`}}))&&t.hide()}function Nt(e,t){let n=e.shell,{status:r,detail:i}=R(t.closing,`the closing state`),a=n.contains(document.activeElement);e.queue.abort(),e.session=null,_t(q(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),Dt(e,n,`closed`,{status:r,url:t.url}),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function Pt(e){let t=e.session;if(e.queue.abort(),e.session=null,Tt(e),t){let n=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n.status,detail:n.detail}),Dt(e,e.shell,`closed`,{status:n.status,url:t.url});let r=document.activeElement;t.trigger?.isConnected&&(!r||r===document.body||e.shell.contains(r))&&t.trigger.focus?.()}e.cache||(vt(e,gt(e.placeholder)),e.loadedUrl=null,G(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function Ft(e,t){let n=qt(t instanceof CustomEvent?t.detail:null,`trigger`),r=n instanceof HTMLElement?n:null,i=r?.getAttribute(`data-wui-url`)||e.remoteUrl||``,a=jt(e,i,{trigger:r});a.explicitSize=It(e,r?.getAttribute(`data-wui-size`)),a.explicitSize&&G(e.shell,a.explicitSize),e.cache&&e.loadedUrl===i||(e.loadedUrl&&vt(e,gt(e.placeholder)),Lt(e,a,{keepPlaceholder:!0}))}function It(e,t){try{return lt(e,t)}catch(e){return _(e),null}}async function Lt(e,t,{keepPlaceholder:n=!1}={}){n||vt(e,mt(t.options.title||Rt(e)));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate,timeoutMs:Ge(t.trigger)});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if(r.kind===`ok`&&Ht(e,t,r.html,!1))return e.loadedUrl=t.url,Dt(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return vt(e,ht(t.options.title||Rt(e),i)),St(e)&&Ct(R(q(e),`a card`),!1,ct(e)),Dt(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var Rt=e=>q(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,zt=`/_content/Webority.Ui.Razor/js/`,Bt=e=>new URL(e,window.location.href).pathname.includes(zt);function Vt(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function Ht(e,t,n,r){let i=se(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&&Bt(t)?Vt(t):a=!0}a&&g(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let o=z(i,Ze);if(!o)return _(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(vt(e,o),r||Tt(e),!K(e)){G(e.shell,t.explicitSize||It(e,o.getAttribute(`data-wui-size`))||e.defaultSize);let n=o.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return St(e)&&Ct(o,r,ct(e)),!0}var Ut=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function Wt(e,t,n){let r=[...e.elements].filter(e=>e.matches(Ut));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 Gt(e){for(let t of e.querySelectorAll(Xe))t.remove();for(let t of e.querySelectorAll(Je))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var Kt=/* @__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(`.`)),qt=(e,t)=>{if(typeof e==`object`&&e&&t in e)return Reflect.get(e,t)};async function Jt(e){if(!e||e.status<400||e.status>499||!e.headers.get(`content-type`)?.toLowerCase().includes(`json`))return null;let t;try{t=JSON.parse(await e.text())}catch{return null}let n=e=>typeof e==`string`?e.trim():``,r=n(qt(t,`title`)),i=(e.statusText||``).trim().toLowerCase(),a=Kt.has(r.toLowerCase())||r.toLowerCase()===i;return n(qt(t,`message`))||n(qt(t,`detail`))||(r&&!a?r:null)}function Yt(e,t,n,r){let i={forbidden:I().forbiddenMessage,client:I().clientMessage,server:I().serverMessage,network:I().networkMessage,timeout:I().timeoutMessage},a=t.closest(`.wui-modal-body`)||t;a.querySelector(`[data-wui-modal-submit-error]`)?.remove(),Gt(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=`${I().submitFailedMessage} ${r||i[n]||I().serverMessage}`,a.prepend(o),wt(e,o.textContent)}var Xt=(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 Zt(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(Ze)||(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`;Wt(n,i,!0);let l;try{l=await e.queue.run(c?Xt(a,s):a,{method:o,body:c?void 0:s,navigate:r.options.navigate,timeoutMs:Ge(r.trigger)})}catch(t){_(t),e.session===r&&n.isConnected&&(Wt(n,i,!1),Yt(e,n,`server`,null));return}if(e.session!==r)return;if(n.isConnected&&Wt(n,i,!1),l.kind===`ok`&&l.result===`success`){Qt(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===Ye;if(Ht(e,r,l.html,t)){if(t){let t=R(q(e),`a card`).querySelector(Xe)?.textContent?.replace(/\s+/g,` `).trim();wt(e,t||I().invalidMessage)}return}}let u=l.kind===`ok`||l.kind===`validation`?`server`:l.kind,d=await Jt(l.response);e.session===r&&Yt(e,n,u,d)}function Qt(e,t,n){let r=n.message,i=n.redirect||null,a=n.toastVariant||`success`;if(!dn(a))throw TypeError(`Unknown toast variant "${a}". Use ${un.join(`, `)}.`);let o={url:t.url,trigger:t.trigger,handle:t.handle,message:r,redirect:i,data:n.data??null,container:e.container};i&&!t.options.navigate?Mn(r,a):r&&P().toast(r,{variant:a}),Dt(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);let s=n.next;s&&!i?(t.url=s,t.method=`GET`,t.body=void 0,Lt(e,t)):n.keepOpen?n.html&&Ht(e,t,n.html,!1):J(e,t,`success`,o)}function $t(e){let t=H(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`)?sn(t.getAttribute(`data-wui-pane`)??``,{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{nt(e)||_(e)}):t.hasAttribute(`data-wui-modal`)?nn(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=>{nt(e)||_(e)}):an(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=>{nt(e)||_(e)})))}function en(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=H(e.target,on);if(!t)return;let n=L.get(t),r=e.currentTarget;n?.session&&r instanceof Document&&!r.querySelector(`wui-modal[open]`)&&(t.querySelector(`form[data-wui-submitting]`)||(e.preventDefault(),J(n,n.session,`dismissed`,null)))}function tn(e=document){let t=e instanceof Document?e:R(e.ownerDocument,`an owner document`);et.has(t)||(et.add(t),t.addEventListener(`click`,$t),t.addEventListener(`keydown`,en));let n=tt(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)At(e)}function nn(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=t.container===`drawer`,r=n?ot(t.size):W(t.size),i=t.placement||`center`;if(!at.includes(i))throw TypeError(`WUI.modal.load: unsupported placement "${i}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(V());let a=ft(n?`drawer`:`modal`);tn(document);let o=At(a),s=St(o),c=jt(o,e,t);c.explicitSize=r,G(o.shell,r||o.defaultSize),n||B(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=Lt(o,c);return s||kt(o).show(),rn(o,c,t,l,u,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function rn(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),J(e,t,`dismissed`,{aborted:!0})),i(V())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw V();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 an(e,t={}){return nn(e,{...t,container:`drawer`,placement:void 0})}var on=`[data-wui-pane-host]`;function sn(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=ut(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(V());tn(document);let r=At(n),i=jt(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=Lt(r,i);return rn(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function cn(e){let t=ut(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=L.get(t);n?.session&&J(n,n.session,`dismissed`,null)}var Y=`wuiConfirm`,ln=Object.freeze([`danger`]),un=Object.freeze([`success`,`info`,`warning`,`danger`]),dn=e=>un.some(t=>t===e),fn=`wui.flash`,X=()=>s(`confirmDialog`,d),pn=/* @__PURE__ */ new WeakSet,mn=/* @__PURE__ */ new WeakSet,hn=null,gn=null,_n=!1,vn=(e,t)=>{e&&P().toast(e,{variant:t})};function yn(){let r=document.getElementById(Y);if(r)return n(r.closest(`wui-modal`),`#${Y} must be a wui-modal.`);let a=document.createElement(`wui-modal`);a.id=Y;let o=document.createElement(`dialog`);return o.className=`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${F.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},X().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 bn(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!ln.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);xn({title:e.getAttribute(`data-wui-confirm-title`),message:e.getAttribute(`data-wui-confirm`),label:e.getAttribute(`data-wui-confirm-label`),danger:n===`danger`},t)}function xn({title:e,message:t,label:r,danger:i},a){let o=yn(),s=o.querySelector(`.wui-confirm-title`),c=o.querySelector(`[data-app-confirm]`);if(!s||!c)throw Error(`#${Y} is not a confirm dialog with a confirm button. Render <app-confirm-dialog id="${Y}"> without confirm-href, or leave the dialog to the library.`);let l=o.querySelector(`.wui-confirm-msg`);l||(l=document.createElement(`p`),l.className=`wui-confirm-msg`,s.after(l));let u=e||X().confirmTitle;s.textContent=u,l.textContent=t,c.textContent=r||X().confirmLabel,c.classList.toggle(`btn-danger`,i),c.classList.toggle(`btn-primary`,!i),o.querySelector(`wui-status-icon`)?.setAttribute(`tone`,i?`delete`:`info`),n(o.querySelector(`dialog`),`#${Y} has no <dialog>.`).setAttribute(`aria-label`,u),gn=a,_n=!1,o.show()}var Sn=(e,t)=>{hn=e;try{t()}finally{hn=null}},Cn=(e,t)=>{let n=Reflect.get(e,t);if(n===void 0||typeof n==`string`)return n;throw TypeError(`confirmAction: ${t} must be text.`)},wn=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:Cn(e,`title`),message:t,label:Cn(e,`label`),tone:Cn(e,`tone`)}};function Tn(e,t,n){let{title:r,message:i,label:a,tone:o}=wn(t);if(o!=null&&!ln.includes(o))throw TypeError(`confirmAction: tone "${o}" is not supported. Use danger, or leave it off.`);Jn(e.ownerDocument),xn({title:r,message:i,label:a,danger:o===`danger`},()=>Sn(e,n))}var En=e=>`disabled`in e&&e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`,Dn=e=>{r(e,HTMLElement,`data-wui-confirm needs an HTML element to click.`).click()};function On(e){let t=a(e.target,`[data-wui-confirm]:not(form)`);t&&t!==hn&&!En(t)&&(e.preventDefault(),e.stopImmediatePropagation(),bn(t,()=>Sn(t,()=>Dn(t))))}function kn(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===hn||e.submitter&&e.submitter===hn||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;bn(t,()=>Sn(t,()=>t.requestSubmit(r)))}function An(e){let t=a(e.target,`#${Y} [data-app-confirm]`);t&&!t.hasAttribute(`disabled`)&&gn&&(_n=!0,n(t.closest(`wui-modal`),`#${Y} is missing around its confirm button.`).hide())}function jn(e){if(!(e.target instanceof Element)||e.target.id!==`wuiConfirm`)return;let t=_n?gn:null;gn=null,_n=!1,t?.()}function Mn(e,t){e&&window.sessionStorage.setItem(fn,JSON.stringify({message:e,variant:t}))}var Nn=e=>e===`forbidden`?X().forbiddenMessage:e===`network`?X().networkMessage:e===`timeout`?X().timeoutMessage:X().failedMessage;function Pn(){for(let e of document.querySelectorAll(`[data-wui-server]`))e.getAttribute(`data-refresh-on-success`)!==`false`&&A(e)?.reload()}var Fn=(e,t)=>{`disabled`in e&&(e.disabled=t)};async function In(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 Ln(t,e)}async function Ln(e,t,n){let r=t.getAttribute(`data-wui-post-reload`);if(r!==null&&r!==`page`)throw TypeError(`data-wui-post-reload="${r}" is not supported. Use page, or leave it off to reload the server tables.`);Fn(t,!0),t.setAttribute(`aria-busy`,`true`);let i=pe(t.getAttribute(`data-wui-timeout`))??3e4,a=await v(e,{method:`POST`,body:n,timeoutMs:i});if(a.kind===`session`||a.kind===`aborted`)return;let o=a.toastVariant||`success`;a.ok&&(a.redirect||r===`page`)?(Mn(a.message,o),a.redirect?window.location.assign(a.redirect):window.location.reload()):(Fn(t,!1),t.removeAttribute(`aria-busy`),a.ok?(Re(a,o),Pn()):vn(a.message||Nn(a.kind),`danger`))}function Rn(e,t){Fn(e,!1),e.removeAttribute(`aria-busy`),_(t),vn(X().failedMessage,`danger`)}function zn(e){let t=a(e.target,`[data-wui-post]`);t&&(e.preventDefault(),En(t)||t.getAttribute(`aria-busy`)===`true`||In(t).catch(e=>Rn(t,e)))}function Bn(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;Ln(i,r,new FormData(t)).catch(e=>Rn(r,e)),t.closest(`wui-dropdown`)?.hide()}var Vn=(e,t)=>{e.disabled=!1,e.removeAttribute(`aria-busy`),t&&h(t,null)};async function Hn(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&&h(t,`saving`);let r=pe(e.getAttribute(`data-wui-timeout`))??3e4,i=await v(n,{method:(e.dataset.method||`post`).toUpperCase(),timeoutMs:r});if(i.kind===`session`)return;if(i.kind===`aborted`){Vn(e,t);return}if(i.ok){Mn(i.message,i.toastVariant||`success`),i.redirect?window.location.assign(i.redirect):window.location.reload();return}let a=i.message||Nn(i.kind);e.disabled=!1,e.removeAttribute(`aria-busy`),t&&h(t,`error`,a),vn(a,`danger`)}function Un(e){let t=a(e.target,`[data-wui-row-action]`);if(!(t instanceof HTMLButtonElement)||t.closest(`[data-wui-server]`)||(e.preventDefault(),t.disabled||t.getAttribute(`aria-busy`)===`true`))return;let n=t.closest(`tr`);Hn(t,n).catch(e=>{Vn(t,n),_(e),vn(X().failedMessage,`danger`)})}function Wn(){let e=window.sessionStorage.getItem(fn);if(!e)return;window.sessionStorage.removeItem(fn);let t=JSON.parse(e);if(typeof t!=`object`||!t)throw TypeError(`stored flash is not an object.`);let n=`message`in t?t.message:void 0,r=`variant`in t?t.variant:void 0;if(typeof r!=`string`||!dn(r))throw TypeError(`stored flash variant "${String(r)}" is not supported.`);if(typeof n!=`string`)throw TypeError(`stored flash message is not text.`);vn(n,r)}function Gn(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(!dn(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${un.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||(e.textContent??``).trim();e.remove(),vn(n,t)}}var Kn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.form:null;function qn(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-wui-auto-submit]`);if(!t)return;let n=Kn(e.target)||t.closest(`form`);n instanceof HTMLFormElement&&n.requestSubmit()}function Jn(e){mn.has(e)||(mn.add(e),e.addEventListener(`click`,An),e.addEventListener(`wui-modal-closed`,jn))}function Yn(e=document){let t=e instanceof Element?e.ownerDocument:e;pn.has(t)||(pn.add(t),t.addEventListener(`click`,On,!0),t.addEventListener(`submit`,kn,!0),Jn(t),t.addEventListener(`click`,zn),t.addEventListener(`click`,Un),t.addEventListener(`submit`,Bn),t.addEventListener(`change`,qn),Wn()),Gn(e)}var Xn=()=>s(`unsavedChanges`,u),Zn=`form[data-wui-unsaved]`,Qn=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,$n=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,er=/* @__PURE__ */ new Set([`submit`,`button`,`reset`,`image`]),tr=/* @__PURE__ */ new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),nr=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,rr=e=>nr(e)?e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled:`disabled`in e&&!!e.disabled,ir=e=>`name`in e&&typeof e.name==`string`&&e.name!==``,ar=e=>typeof e==`object`&&!!e,or=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&typeof e[0]==`string`);function sr(e){let t=JSON.parse(e);if(!or(t))throw Error(`unsaved-changes snapshot is malformed`);return t}var Z=/* @__PURE__ */ new WeakMap,cr=/* @__PURE__ */ new WeakSet,lr=e=>`${e.name}:${e.size}:${e.lastModified}`,ur=e=>[...e.querySelectorAll(Zn)].filter(e=>e instanceof HTMLFormElement);function Q(e){let t=[];for(let n of e.elements)ir(n)&&!rr(n)&&(nr(n)&&er.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(lr)]):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 dr(e){return Q(e)}function fr(e,t){let n=/* @__PURE__ */ new Map,r=sr(t);for(let e of r){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let i=sr(Q(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())i.push(...e);return JSON.stringify(i)}function pr(e){for(let t of e.elements)if(nr(t)&&t.name&&!rr(t)){if(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!tr.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 mr=e=>({saved:e.querySelector(Qn)&&pr(e)?null:Q(e),engaged:!1,discarded:!1});function hr(e){let t=Z.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&Q(e)!==t.saved}var gr=(e,t)=>ur(e).filter(e=>e!==t&&hr(e));function _r(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||Xn().message;Tn(e,{title:Xn().title,message:r,label:Xn().leaveLabel,tone:`danger`},()=>{for(let e of t){let t=Z.get(e);t&&(t.discarded=!0)}n()})}function vr(e){if(e.matches($n))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 yr(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 br(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)||!vr(n))return;let r=gr(n.ownerDocument,null);r.length&&(e.preventDefault(),_r(n,r,()=>n.click()))}function xr(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!yr(t,e.submitter))return;let n=gr(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;_r(t,n,()=>t.requestSubmit(i));return}let r=Z.get(t);r&&(r.saved=Q(t),r.discarded=!1)}function Sr(e){gr(document,null).length&&e.preventDefault()}function Cr(e){let t=e.target,n=a(t,Zn);return n instanceof HTMLFormElement?n:null}function wr(e){let t=Cr(e);if(!t)return;let n=Z.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=Q(t)),n.engaged=!0)}function Tr(e){let t=Cr(e),n=t&&Z.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function Er(e){for(let t of ur(e)){let e=Z.get(t);e?.saved&&(e.saved=fr(t,e.saved))}}function Dr(e){let t=ar(e)?e.handle:void 0;return ar(t)?t.el:void 0}function Or(e){if(!(e instanceof CustomEvent))return;let t=Dr(e.detail);if(t instanceof Element)for(let e of ur(t))Ar(e)}function kr(e=document){let t=e instanceof Document?e:e.ownerDocument;if(!cr.has(t)){cr.add(t);for(let e of[`focusin`,`pointerdown`,`drop`])t.addEventListener(e,wr,!0);for(let e of[`input`,`change`])t.addEventListener(e,Tr,!0);t.addEventListener(`click`,br),t.addEventListener(`submit`,xr),t.addEventListener(`wui:modal:success`,Or),t.addEventListener(o,()=>Er(t)),n(t.defaultView,`unsaved-changes guard needs a document with a window`).addEventListener(`beforeunload`,Sr)}let r=ur(e);e instanceof HTMLFormElement&&e.matches(Zn)&&r.unshift(e);for(let e of r)Z.has(e)||Z.set(e,mr(e))}function Ar(e){if(!(e instanceof HTMLFormElement)||!e.matches(Zn))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);Z.set(e,{saved:Q(e),engaged:!1,discarded:!1})}var jr=()=>s(`drawer`,l),Mr=`wui:drawer:discard`,Nr=`wui-drawer[confirm-discard]`,Pr=`wui-modal`,Fr=`data-wui-no-discard`,Ir=`.wui-drawer-discard`,Lr=`input, select, textarea`,Rr=e=>typeof e==`object`&&!!e||typeof e==`function`;function zr(e){let t=e.currentTarget;if(!(t instanceof Document))throw Error(`The discard guard is not wired on a document.`);return t}function Br(e,t){return a(e,t)}var Vr=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,$=/* @__PURE__ */ new WeakMap,Hr=/* @__PURE__ */ new WeakSet,Ur=/* @__PURE__ */ new WeakSet;function Wr(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 Gr(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,Wr(e,`danger`,`solid`,`data-wui-discard-confirm`,jr().discardLabel),Wr(e,`primary`,`soft`,`data-wui-discard-keep`,jr().keepLabel)),n}function Kr(e){if(!(e instanceof Element))return null;let t=e.closest(Nr);if(t)return t;let n=e.closest(Pr);return n&&Yr(n).length?n:null}function qr(e){return e.closest(Nr)??e.closest(Pr)}function Jr(e,t){return t.hasAttribute(Fr)||e.hasAttribute(Fr)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function Yr(e){return e.matches(Nr)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>Jr(t,e))}function Xr(e){let t=$.get(e);return t!=null&&dr(e)!==t}function Zr(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),Ur.add(t),t}function Qr(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),Ur.add(t),t}function $r(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 ei(e,t,n){let r=e.querySelector(Ir);if(r){$r(r);return}let i=Gr(e.ownerDocument,t),a;if(e.matches(Nr))a=e.querySelector(`.wui-drawer-footer`)??Zr(e),a.prepend(i);else if(e.hasAttribute(`confirm-discard`))a=e.querySelector(`.wui-modal-footer`)??Qr(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`)??Qr(e),a.prepend(i)}a.classList.add(`wui-drawer-discarding`),$r(i)}function ti(e){let t=e.parentElement;if(e.remove(),!t)throw Error(`The discard prompt has no footer.`);t.classList.remove(`wui-drawer-discarding`),Ur.has(t)&&t.remove()}function ni(e){for(let t of Yr(e))for(let e of t.querySelectorAll(Lr))if(Vr(e)&&e.type!==`hidden`&&!e.disabled){e.focus({preventScroll:!0});return}}function ri(e){let t=Kr(e.target);if(t)for(let e of Yr(t))$.get(e)??$.set(e,dr(e))}function ii(e){for(let t of zr(e).querySelectorAll(`form`)){let e=$.get(t);e!=null&&$.set(t,fr(t,e))}}function ai(e){let t=e.target;t instanceof HTMLFormElement&&Kr(t)&&$.set(t,dr(t))}function oi(e){if(!Rr(e))return;let t=`handle`in e?e.handle:void 0;if(Rr(t))return`el`in t?t.el:void 0}function si(e){if(!(e instanceof CustomEvent))return;let t=e.detail,n=oi(t);if(n instanceof Element)for(let e of n.querySelectorAll(`form`))$.delete(e)}function ci(e){let t=e.target;t instanceof Element&&t.matches(Nr)&&[...Yr(t)].some(Xr)&&(e.preventDefault(),ei(t,t.getAttribute(`confirm-discard`),null))}function li(e){let t=e.target;if(!(t instanceof Element)||!t.matches(Pr))return;let n=[...Yr(t)].find(Xr);n&&(e.preventDefault(),ei(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??jr().confirmDiscard,n))}function ui(e){let t=n(e.closest(Ir),`The discard button is outside its prompt.`),r=qr(t);if(ti(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);for(let e of Yr(r))$.set(e,dr(e));r.dispatchEvent(new CustomEvent(Mr,{bubbles:!0})),r.matches(Nr)?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 di(e){let t=n(e.closest(Ir),`The keep button is outside its prompt.`),r=qr(t);if(ti(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);ni(r)}function fi(e){let t=Br(e.target,`[data-wui-discard-confirm]`);if(t){ui(t);return}let n=Br(e.target,`[data-wui-discard-keep]`);n&&di(n)}function pi(e=document){let t=e instanceof Document?e:e.ownerDocument;Hr.has(t)||(Hr.add(t),t.addEventListener(`focusin`,ri),t.addEventListener(`pointerdown`,ri),t.addEventListener(`submit`,ai),t.addEventListener(o,ii),t.addEventListener(`wui:modal:success`,si),t.addEventListener(`wui:modal:loaded`,si),t.addEventListener(`wui-drawer-close`,ci,!0),t.addEventListener(`wui-modal-close`,li),t.addEventListener(`click`,fi))}export{Pe as S,sn as _,kr as a,Re as b,ln as c,Tn as d,Yn as f,nn as g,an as h,dr as i,fn as l,tn as m,Gr as n,Ar as o,cn as p,pi as r,Y as s,Mr as t,un as u,Ie as v,A as x,ze as y};
|
package/dist/kanban-DlVHIpxL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./devWarn-DXdRWZs3.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{m as r}from"./formatters-DTW53DjY.js";import{t as i}from"./hasOwn-CJsplJ62.js";import{c as a,d as o,f as s,m as c,p as l,s as u,u as d}from"./kanbanModel-BzXK4SkM.js";import{n as f,t as p}from"./rtl-g7G8Bsib.js";import{t as m}from"./serverHtml-BC6tAyAl.js";import{d as h}from"./wuiHttp-BWf9dDsZ.js";import{n as g,r as _,t as v}from"./textStore-DBplASiZ.js";import{t as y}from"./kanban.g-dtKYyIpr.js";var b=()=>_(`kanban`,y),x=()=>({forbidden:b().forbiddenMessage,client:b().clientMessage,validation:b().clientMessage,server:b().serverMessage,network:b().networkMessage}),S=`[data-wui-column]`,C=`[data-wui-body]`,w=`[data-wui-card]`,T=`[data-wui-count]`,E=`[data-wui-summary]`,D=`[data-wui-empty]`,O=`[data-wui-drop-note]`,ee=`[data-wui-live]`,te=`[data-wui-help]`,k=`[data-wui-switch]`,A=`[data-wui-scroller]`,j=`[data-wui-collapse]`,M=`[data-wui-more]`,N=`data-wui-visible-limit`,P=`data-wui-overflow`,F=`input, select, textarea, [contenteditable=""], [contenteditable="true"], [data-wui-no-drag]`,I=`[data-wui-load-more]`,L=`data-wui-more-url`,R=`data-wui-total`,z=`data-wui-unloaded`,B=48,V=16,H=160,U=e=>e.getAttribute(`data-wui-column`),W=e=>e.getAttribute(`data-wui-card`),G=e=>e instanceof HTMLElement&&!!e.hidden||e.hasAttribute(`hidden`),K=e=>G(e)||e.hasAttribute(P),q=e=>e instanceof Element?e:null,J=e=>typeof e==`object`&&e&&`name`in e?e.name:void 0,ne=e=>typeof e==`object`&&e&&`message`in e?e.message:void 0,Y=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},X=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),Z=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Q=()=>window.WUI??null,$=(e,t)=>{e&&Q()?.toast(e,{variant:t})},re=class extends n{constructor(){super(),this._wired=!1,this._filter=null,this._expanded=/* @__PURE__ */ new Set,this._revealed=/* @__PURE__ */ new Set,this._press=null,this._drag=null,this._kbd=null,this._suppressClick=!1,this._observer=null,this._refreshQueued=!1,this._scrollTimer=0,this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onPointerCancel=()=>this._endPointer(!1),this._onDocKeyDown=e=>{e.key===`Escape`&&this._drag&&(e.preventDefault(),this._endPointer(!1))},this._onScroll=()=>{clearTimeout(this._scrollTimer),this._scrollTimer=setTimeout(()=>this._syncSwitcherFromScroll(),80)},this.addEventListener(`pointerdown`,e=>this._pointerDown(e)),this.addEventListener(`keydown`,e=>this._keyDown(e)),this.addEventListener(`click`,e=>this._click(e),!0),this.addEventListener(`scroll`,e=>{e.target instanceof Element&&this._loadOnScroll(e.target)},!0),this.addEventListener(`dragstart`,e=>{q(e.target)?.closest(w)&&e.preventDefault()}),this.addEventListener(`touchmove`,e=>{this._drag&&e.preventDefault()},{passive:!1})}_controlled(){return this.hasAttribute(`controlled`)}connectedCallback(){if(!this._wired){this._wired=!0,this._scroller()?.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._restoreCollapsed();for(let e of this._allCards())this._prepareCard(e);if(typeof MutationObserver==`function`){this._observer=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e instanceof HTMLElement&&e.matches(w)&&this._prepareCard(e);this._queueRefresh()});for(let e of this.querySelectorAll(C))this._observer.observe(e,{childList:!0})}this.refresh()}}disconnectedCallback(){this._endPointer(!1),this._observer?.disconnect(),this._observer=null,this._scroller()?.removeEventListener(`scroll`,this._onScroll),clearTimeout(this._scrollTimer),this._wired=!1}setFilter(e){if(e!=null&&typeof e!=`function`)throw TypeError(`wui-kanban setFilter: pass a function or null.`);if(this._filter=e,!e)for(let e of this._allCards())e.hidden=!1;this.refresh()}refresh(){if(this._controlled())return;this._refreshQueued=!1;let e=this._summaryFormat();for(let t of this._columns()){let n=U(t),i=o(t.getAttribute(N)),s=[],c=[];for(let e of this._cardsIn(t))this._filter&&(e.hidden=this._filter(e)===!1),G(e)?e.removeAttribute(P):(s.push(e),c.push(e.getAttribute(`data-wui-value`)));let u=this._expanded.has(n),d=a(s.map(W),i,u,this._revealed);for(let e of s)e.toggleAttribute(P,d.has(W(e)));let f=this._unloadedIn(t),p=String(s.length+f);for(let e of this._countsOf(t))e.textContent!==p&&(e.textContent=p);let m=Y(t,D,HTMLElement);if(m&&(m.hidden=s.length>0),e){let n=t.querySelector(E);n&&(n.textContent=r(l(c),e))}let h=Y(t,M,HTMLElement);if(h){h.hidden=i==null||(u?s.length<=i:d.size===0),h.setAttribute(`aria-expanded`,u?`true`:`false`);let e=u?b().fewerLabel:v(b().moreText,{count:d.size});h.textContent!==e&&(h.textContent=e)}let g=Y(t,I,HTMLButtonElement);if(g&&(g.hidden=f<=0,!t.hasAttribute(`data-wui-loading`))){g.disabled=!1;let e=v(b().loadMoreText,{n:f});g.textContent!==e&&(g.textContent=e)}}}moveCard(e,t,n){let r=this._cardByKey(e);if(!r)throw Error(`wui-kanban moveCard: no card "${String(e)}" on this board.`);if(!this._columnByKey(t))throw Error(`wui-kanban moveCard: no column "${String(t)}" on this board.`);return this._commit(r,t,n)}_columns(){return X(this,S,HTMLElement)}_columnByKey(e){return this._columns().find(t=>U(t)===e)||null}_columnOf(e){return Z(e,S,HTMLElement)}_titleOf(e){return(e.querySelector(`.wui-kanban-title`)?.textContent||U(e)||``).replace(/\s+/g,` `).trim()}_bodyOf(e){return Y(e,C,HTMLElement)}_cardsIn(e){let t=this._bodyOf(e);return t?[...t.children].filter(e=>e instanceof HTMLElement&&e.matches(w)):[]}_visibleCardsIn(e){return this._cardsIn(e).filter(e=>!K(e))}_allCards(){return X(this,`${C} > ${w}`,HTMLElement)}_cardByKey(e){return this._allCards().find(t=>W(t)===e)||null}_countsOf(e){let t=U(e),n=[...this.querySelectorAll(k)].filter(e=>e.getAttribute(`data-wui-switch`)===t);return[...e.querySelectorAll(T),...n.flatMap(e=>[...e.querySelectorAll(T)])]}_scroller(){return Y(this,A,HTMLElement)}_summaryFormat(){let e=this.getAttribute(`summary-format`);return e?d(e,this.getAttribute(`summary-unit`)):null}_queueRefresh(){this._refreshQueued||(this._refreshQueued=!0,queueMicrotask(()=>{this._refreshQueued&&this.refresh()}))}_prepareCard(e){let t=this.querySelector(te);t?.id&&!e.hasAttribute(`aria-describedby`)&&e.setAttribute(`aria-describedby`,t.id),e.hasAttribute(`tabindex`)||(e.tabIndex=0)}_announce(e){let t=Y(this,ee,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t,n=!1){return this.dispatchEvent(new CustomEvent(e,{bubbles:!0,cancelable:n,detail:t}))}_canLift(e){let t=u(e),n=this.hasAttribute(`readonly`);return n||e.hasAttribute(`data-wui-locked`)?(this._announce(v(b().lockedText,{card:t})),this._fire(`wui:kanban:locked`,{key:W(e),card:e,reason:n?`readonly`:`locked`},!0),!1):e.getAttribute(`aria-busy`)!==`true`||(this._announce(b().busyMessage),$(b().busyMessage,`info`),!1)}_check(e,t,n){if(t===n)return{ok:!1,source:!0,reason:null};let r=this._columnByKey(t),i=this._columnByKey(n),a=v(b().refusedText,{from:r?this._titleOf(r):String(t),to:i?this._titleOf(i):String(n)}),o=i?.getAttribute(`data-accept-from`),s=o?.split(/\s+/).filter(Boolean)??[];if(o!=null&&!s.includes(t))return{ok:!1,reason:a};if(typeof this.accept==`function`){let r=this.accept(e,t,n);if(r===!1)return{ok:!1,reason:a};if(typeof r==`string`&&r)return{ok:!1,reason:r}}return{ok:!0,reason:null}}_markTargets(e,t){let n=u(e),r=/* @__PURE__ */ new Map;for(let i of this._columns()){let a=U(i),o=this._check(e,t,a);r.set(a,o),i.setAttribute(`data-wui-drop`,o.source?`source`:o.ok?`ok`:`refused`);let s=Y(i,O,HTMLElement);s&&!o.source&&(s.textContent=o.ok?v(b().dropHereText,{card:n,column:this._titleOf(i)}):o.reason,s.hidden=!1)}return r}_clearTargets(){for(let e of this._columns()){e.removeAttribute(`data-wui-drop`),e.removeAttribute(`data-wui-over`),e.removeAttribute(`data-wui-target`);let t=Y(e,O,HTMLElement);t&&(t.hidden=!0,t.textContent=``)}}async _commit(e,t,n){let r=this._columnOf(e);if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let i=U(r),a=this._columnByKey(t),o=u(e);if(i===t||!this._canLift(e))return!1;let s=this._check(e,i,t);if(!s.ok)return this._announce(s.reason),$(s.reason,`info`),!1;if(!a)throw Error(`wui-kanban: no column "${String(t)}" on this board.`);let c=this._cardsIn(a),l=Number.isInteger(n)?Math.max(0,Math.min(n??0,c.length)):c.length,d={key:W(e),card:e,from:i,to:t,index:l},f=e.contains(document.activeElement);if(this._controlled())return this._fire(`wui:kanban:move`,d),this._announce(v(b().movedText,{card:o,column:this._titleOf(a)})),f&&this._refocusSoon(d.key),!0;if(!this._fire(`wui:kanban:move`,d,!0))return!1;let p=a.hasAttribute(N)&&!this._revealed.has(d.key);p&&this._revealed.add(d.key);let m={parent:e.parentNode,next:e.nextSibling,column:r,revealed:p},g=this._bodyOf(a);if(!g)throw Error(`wui-kanban: the target column has no body.`);g.insertBefore(e,c[l]||null),f&&this._focusMoved(e),this.refresh();let _=a.getAttribute(`data-wui-step`);if(_)return this._runStep(e,d,m,_,a.getAttribute(`data-wui-step-size`));let y=this.getAttribute(`move-url`);if(!y)return this._announce(v(b().movedText,{card:o,column:this._titleOf(a)})),this._fire(`wui:kanban:moved`,{...d,result:null}),!0;this._lock(e,!0),this._announce(v(b().movingText,{card:o,column:this._titleOf(a)}));let S=new URLSearchParams({card:String(d.key),from:String(i),to:String(t),index:String(l)}),C=await h(y,{method:`POST`,body:S});if(this._lock(e,!1),C.kind===`session`)return!1;if(C.ok){let t=this._applyFragment(C.html)||e;return $(C.message,`success`),this._announce(v(b().movedText,{card:u(t),column:this._titleOf(a)})),this._fire(`wui:kanban:moved`,{...d,card:t,result:C}),!0}return this._rollback(e,m),C.kind!==`aborted`&&$(C.message||x()[C.kind]||b().serverMessage,`danger`),this._fire(`wui:kanban:failed`,{...d,kind:C.kind,status:C.status,message:C.message}),!1}async _runStep(e,t,n,r,i){let a=u(e),o=this._columnByKey(t.to),s=new URLSearchParams({card:String(t.key),from:String(t.from),to:String(t.to)}).toString(),c=r+(r.includes(`?`)?`&`:`?`)+s;this._lock(e,!0);let l;try{let t=window.WUI?.modal?.load;if(typeof t!=`function`)throw Error(`<wui-kanban> data-wui-step needs the Razor script webority-ui.js (WUI.modal.load).`);l=await(await t(c,{trigger:e,size:i||void 0})).closed}catch(r){return this._lock(e,!1),this._rollback(e,n),J(r)!==`AbortError`&&$(b().serverMessage,`danger`),this._fire(`wui:kanban:failed`,{...t,kind:`step`,status:0,message:ne(r)??null}),!1}if(l?.status!==`success`)return this._lock(e,!1),this._rollback(e,n),this._announce(v(b().cancelledText,{card:a})),this._fire(`wui:kanban:failed`,{...t,kind:`dismissed`,status:0,message:null}),!1;let d=e,f=this.getAttribute(`card-url`);if(f){let n=await h(`${f}${f.includes(`?`)?`&`:`?`}${new URLSearchParams({card:String(t.key)})}`);n.ok&&(d=this._applyFragment(n.html)||e)}if(this._lock(d,!1),!o)throw Error(`wui-kanban: no column "${String(t.to)}" on this board.`);return this._announce(v(b().movedText,{card:u(d),column:this._titleOf(o)})),this._fire(`wui:kanban:moved`,{...t,card:d,result:l}),!0}_lock(e,t){t?(e.setAttribute(`aria-busy`,`true`),e.setAttribute(`data-wui-saving`,``)):(e.removeAttribute(`aria-busy`),e.removeAttribute(`data-wui-saving`))}_rollback(e,t){let n=e.contains(document.activeElement),r=t.next&&t.next.parentNode===t.parent?t.next:null;if(t.revealed&&this._revealed.delete(W(e)),!t.parent)throw Error(`wui-kanban: the card had no parent to go back to.`);t.parent.insertBefore(e,r),n&&e.focus(),this.refresh(),this._announce(v(b().rolledBackText,{card:u(e),column:this._titleOf(t.column)}))}_applyFragment(t){if(!t)return null;let n=m(t);for(let t of n.querySelectorAll(`script`))e(`[@webority/ui-elements] A kanban fragment carried a script tag; it was removed, not run.`),t.remove();let r=null;for(let e of X(n,w,HTMLElement)){if(e.closest(`template`))continue;let t=this._cardByKey(W(e));if(!t)continue;let n=t.contains(document.activeElement);t.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),t.hidden&&(e.hidden=!0),t.replaceWith(e),this._prepareCard(e),n&&e.focus(),r??=e}for(let e of X(n,`template[data-wui-kanban-summary]`,HTMLTemplateElement))this._columnByKey(e.getAttribute(`data-wui-kanban-summary`))?.querySelector(E)?.replaceChildren(e.content.cloneNode(!0));return this.refresh(),Q()?.refresh(),r}_refocusSoon(e){let t=()=>{let t=this._cardByKey(e);t&&this._focusMoved(t)};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}_focusMoved(e){e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`nearest`})}_pointerDown(e){if(e.button!==0||e.isPrimary===!1||this._drag||this._kbd)return;let t=q(e.target),n=t?Z(t,w,HTMLElement):null;if(!n||!this.contains(n)||t?.closest(F))return;let r={card:n,id:e.pointerId,x:e.clientX,y:e.clientY,type:e.pointerType,timer:0};this._press=r,e.pointerType===`touch`&&(r.timer=setTimeout(()=>{this._press===r&&this._startDrag(r,r.x,r.y)},400)),window.addEventListener(`pointermove`,this._onPointerMove),window.addEventListener(`pointerup`,this._onPointerUp),window.addEventListener(`pointercancel`,this._onPointerCancel)}_pointerMove(e){let t=this._press;if(t&&e.pointerId===t.id){if(!this._drag){if(!(Math.hypot(e.clientX-t.x,e.clientY-t.y)>6))return;if(t.type===`touch`){this._endPointer(!1);return}if(this._startDrag(t,e.clientX,e.clientY),!this._drag)return}this._dragTo(e.clientX,e.clientY)}}_pointerUp(e){this._press&&e.pointerId===this._press.id&&this._endPointer(!!this._drag)}_startDrag(e,t,n){let r=e.card;if(!this._canLift(r)){this._endPointer(!1);return}let i=this._columnOf(r);if(!i)throw Error(`wui-kanban: the card is not inside a column.`);let a=U(i),o=r.getBoundingClientRect(),s=r.cloneNode(!0);if(!(s instanceof HTMLElement))return;let c=s;for(let e of[c,...c.querySelectorAll(`[id]`)])e.removeAttribute(`id`);c.removeAttribute(`data-wui-card`),c.removeAttribute(`tabindex`),c.setAttribute(`aria-hidden`,`true`),c.classList.add(`wui-kanban-ghost`),c.style.width=`${o.width}px`,this.appendChild(c),r.setAttribute(`data-wui-dragging`,``),this.setAttribute(`data-wui-dragging`,``),this._drag={card:r,from:a,ghost:c,dx:t-o.left,dy:n-o.top,x:t,y:n,over:null,verdicts:this._markTargets(r,a)},this._announce(v(b().liftedText,{card:u(r),column:this._titleOf(i)})),document.addEventListener(`keydown`,this._onDocKeyDown),this._dragTo(t,n)}_dragTo(e,t){let n=this._drag;if(!n)throw Error(`wui-kanban: no drag in progress.`);n.x=e,n.y=t,n.ghost.style.transform=`translate(${e-n.dx}px, ${t-n.dy}px)`;let r=this._columnAt(e,t);r!==n.over&&(n.over?.removeAttribute(`data-wui-over`),r?.setAttribute(`data-wui-over`,``),n.over=r),this._autoScroll(e,t,r)}_columnAt(e,t){for(let n of this._columns()){let r=n.getBoundingClientRect();if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom)return n}return null}_indexAt(e,t){let n=this._visibleCardsIn(e).filter(e=>e!==this._drag?.card).find(e=>{let n=e.getBoundingClientRect();return t<n.top+n.height/2}),r=this._cardsIn(e).filter(e=>e!==this._drag?.card);return n?r.indexOf(n):r.length}_autoScroll(e,t,n){let r=this._scroller();if(r){let t=r.getBoundingClientRect();t.width>0&&(e<t.left+B?r.scrollBy?.({left:-16}):e>t.right-B&&r.scrollBy?.({left:V}))}if(n&&this._scrollColumn(n,t))return;let i=window.innerHeight||0;i>0&&(t<B?window.scrollBy?.({top:-16}):t>i-B&&window.scrollBy?.({top:V}))}_scrollColumn(e,t){let n=this._bodyOf(e);if(!n||e.hasAttribute(`data-collapsed`)||n.scrollHeight<=n.clientHeight)return!1;let r=n.getBoundingClientRect();return t<r.top+B&&n.scrollTop>0?(n.scrollBy?.({top:-16}),!0):t>r.bottom-B&&n.scrollTop+n.clientHeight<n.scrollHeight-1&&(n.scrollBy?.({top:V}),!0)}_endPointer(e){let t=this._press,n=this._drag;if(t&&clearTimeout(t.timer||void 0),this._press=null,this._drag=null,window.removeEventListener(`pointermove`,this._onPointerMove),window.removeEventListener(`pointerup`,this._onPointerUp),window.removeEventListener(`pointercancel`,this._onPointerCancel),document.removeEventListener(`keydown`,this._onDocKeyDown),!n)return;n.ghost.remove(),n.card.removeAttribute(`data-wui-dragging`),this.removeAttribute(`data-wui-dragging`),this._suppressClick=!0,setTimeout(()=>{this._suppressClick=!1},0);let r=n.over;if(this._clearTargets(),!e||!r){this._announce(v(b().cancelledText,{card:u(n.card)}));return}let i=U(r),a=n.verdicts.get(i);a?.source?this._announce(v(b().cancelledText,{card:u(n.card)})):a?.ok?this._commit(n.card,i,this._indexAt(r,n.y)):(this._announce(a?.reason),$(a?.reason,`info`))}_click(e){let t=q(e.target);if(this._suppressClick&&t?.closest(w)){e.preventDefault(),e.stopPropagation(),this._suppressClick=!1;return}let n=t?.closest(j);if(n&&this.contains(n)){let e=Z(n,S,HTMLElement);e&&this._setCollapsed(e,!e.hasAttribute(`data-collapsed`),!0);return}let r=t?.closest(I);if(r&&this.contains(r)){this._controlled()||this._loadMore(Z(r,S,HTMLElement));return}let i=t?.closest(M);if(i&&this.contains(i)){this._controlled()||this._toggleMore(Z(i,S,HTMLElement));return}let a=t?.closest(k);a&&this.contains(a)&&this._showColumn(a.getAttribute(`data-wui-switch`))}_keyDown(e){let t=this._kbd;if(t){this._liftedKey(e,t);return}let n=e.target instanceof HTMLElement?e.target:null;if(!n?.matches(w)||!this.contains(n))return;let r=this._columnOf(n),i=f(e.key,p(this));switch(i){case` `:case`Spacebar`:{if(e.preventDefault(),!this._canLift(n))return;if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let t=U(r),i=this._columns();this._kbd={card:n,from:t,target:i.indexOf(r),verdicts:this._markTargets(n,t)},n.setAttribute(`data-wui-lifted`,``),this.setAttribute(`data-wui-dragging`,``),r.setAttribute(`data-wui-target`,``),this._announce(v(b().liftedText,{card:u(n),column:this._titleOf(r)}));return}case`ArrowDown`:case`ArrowUp`:{if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let t=this._visibleCardsIn(r),i=t[t.indexOf(n)+(e.key===`ArrowDown`?1:-1)];i&&(e.preventDefault(),i.focus());return}case`ArrowLeft`:case`ArrowRight`:{let t=this._columns(),n=i===`ArrowRight`?1:-1;for(let i=(r?t.indexOf(r):-1)+n;i>=0&&i<t.length;i+=n){let n=t[i],r=n?this._visibleCardsIn(n)[0]:void 0;if(r&&n&&!n.hasAttribute(`data-collapsed`)){e.preventDefault(),r.focus();return}}return}}}_liftedKey(e,t){let n=this._columns(),r=f(e.key,p(this));switch(r){case`ArrowLeft`:case`ArrowRight`:{e.preventDefault();let i=t.target+(r===`ArrowRight`?1:-1);if(i<0||i>=n.length)return;n[t.target]?.removeAttribute(`data-wui-target`),t.target=i;let a=n[i];if(!a)return;a.setAttribute(`data-wui-target`,``),this._showColumn(U(a),!1);let o=t.verdicts.get(U(a));if(!o)throw Error(`wui-kanban: no verdict for the column.`);let s=this._titleOf(a);this._announce(o.source?v(b().overSourceText,{column:s}):o.ok?g(b(),`overText`,this._cardsIn(a).filter(e=>!G(e)).length,{column:s}):v(b().overRefusedText,{column:s,reason:o.reason??``}));return}case` `:case`Spacebar`:case`Enter`:{e.preventDefault();let r=n[t.target];if(!r)throw Error(`wui-kanban: the lifted card has no target column.`);let i=U(r),a=t.verdicts.get(i);if(!a)throw Error(`wui-kanban: no verdict for the column.`);if(!a.source&&!a.ok){this._announce(a.reason);return}this._endKeyboard(),a.source?this._announce(v(b().cancelledText,{card:u(t.card)})):this._commit(t.card,i);return}case`Escape`:case`Tab`:e.key===`Escape`&&e.preventDefault(),this._endKeyboard(),this._showColumn(t.from,!1),this._announce(v(b().cancelledText,{card:u(t.card)}));return}}_endKeyboard(){let e=this._kbd;this._kbd=null,e&&(e.card.removeAttribute(`data-wui-lifted`),this.removeAttribute(`data-wui-dragging`),this._clearTargets())}_restoreCollapsed(){let e=s(this.getAttribute(`board-id`));for(let t of this._columns()){let n=U(t);t.hasAttribute(`data-collapsible`)&&i(e,String(n))&&this._setCollapsed(t,e[String(n)],!1)}}_setCollapsed(e,t,n){let r=U(e);e.toggleAttribute(`data-collapsed`,t);let i=this._titleOf(e);for(let n of e.querySelectorAll(j))n.setAttribute(`aria-expanded`,t?`false`:`true`),n.setAttribute(`aria-label`,v(t?b().expandLabel:b().collapseLabel,{title:i}));n&&(c(this.getAttribute(`board-id`),r,t),this._fire(`wui:kanban:collapse`,{column:r,collapsed:t}))}_toggleMore(e){if(!e)return;let t=U(e);if(this._expanded.delete(t))for(let t of this._cardsIn(e))this._revealed.delete(W(t));else this._expanded.add(t);this.refresh()}_unloadedIn(e){return e.hasAttribute(L)?(e.hasAttribute(z)||e.setAttribute(z,String(Math.max(0,Number(e.getAttribute(R))-this._cardsIn(e).length))),Number(e.getAttribute(z))):0}async _loadMore(e){if(!e)throw Error(`wui-kanban: the load-more button is outside a column.`);let n=Number(e.getAttribute(z));if(e.hasAttribute(`data-wui-loading`)||!(n>0))return;e.setAttribute(`data-wui-loading`,``);let r=Y(e,I,HTMLButtonElement);r&&(r.disabled=!0,r.textContent=b().loadingLabel);let i=new URL(String(e.getAttribute(L)),document.baseURI);i.searchParams.set(`skip`,String(this._cardsIn(e).length));let a=0,o=!1;try{let t=await h(i.toString());if(t.ok){let r=m(t.html),i=this._bodyOf(e);for(let e of[...r.children])if(e.matches(w)&&!this._cardByKey(W(e))){if(!i)throw Error(`wui-kanban: the column has no body.`);i.append(e),a++}let s=t.response?.headers.get(`Wui-Kanban-Remaining`)??``;e.setAttribute(z,String(/^\d+$/.test(s)?Number(s):Math.max(0,n-a))),o=!0}}catch(e){t(`[@webority/ui-elements] A kanban column could not load its next cards.`,e)}e.removeAttribute(`data-wui-loading`),this.refresh(),o?this._fire(`wui:kanban:loaded`,{key:U(e),added:a}):$(b().loadFailedMessage,`danger`)}_loadOnScroll(e){if(this._controlled()||!e.matches(C))return;let t=Z(e,S,HTMLElement);t?.hasAttribute(L)&&e.scrollTop+e.clientHeight>=e.scrollHeight-H&&this._loadMore(t)}_isPhone(){return typeof matchMedia==`function`&&matchMedia(`(max-width: 767.98px)`).matches}_showColumn(e,t=!0){for(let t of this.querySelectorAll(k))t.getAttribute(`data-wui-switch`)===e?t.setAttribute(`aria-current`,`true`):t.removeAttribute(`aria-current`);let n=this._columnByKey(e),r=this._scroller();if(!n||!r||!t&&!this._isPhone())return;let i=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollTo?.({left:n.offsetLeft-r.offsetLeft,behavior:i?`auto`:`smooth`})}_syncSwitcherFromScroll(){let e=this._scroller();if(!e||!this._isPhone())return;let t=e.clientWidth||1,n=this._columns()[Math.round(e.scrollLeft/t)];if(n)for(let e of this.querySelectorAll(k))e.getAttribute(`data-wui-switch`)===U(n)?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`)}};export{re as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,t}from"./dom-DMQu--xV.js";import{r as n,t as r}from"./textStore-DBplASiZ.js";import{t as i}from"./devWarn-DXdRWZs3.js";import{n as a}from"./imeSafeEnter-DeO_3lXy.js";import{t as o}from"./rowDrop.g-DQpB10Ey.js";var s=`wui:row-drop`,c=`is-drop-over`,l=`application/x-wui-rows`,u=`wui-row-dragging`,d=`[data-wui-drop-target]`,f=`tbody tr[data-row-key]`,ee=`input, button, a, select, textarea, label`,p=`.wui-select-cell .wui-check`,m=/* @__PURE__ */ new WeakMap,h=/* @__PURE__ */ new WeakSet,g=null,_=null;function v(e){let t=e.querySelector(p);return t instanceof HTMLInputElement&&t.checked}function y(e){let t=[];for(let n of e.querySelectorAll(`tbody tr`))n instanceof HTMLElement&&v(n)&&t.push(n.dataset.rowKey);return t}function b(e,n){return t(e,n)}function x(e,t){let n=b(e,t);return n instanceof HTMLElement?n:null}function te(e){let t=e.textContent;if(t===null)throw Error(`A drop target has no text content.`);return t.trim()}var S=e=>typeof e==`object`&&!!e&&`selected`in e&&typeof e.selected==`number`;function C(){g=null,document.body.classList.remove(u);for(let e of document.querySelectorAll(`${d}.${c}`))e.classList.remove(c)}function w(e,t,n){e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{keys:t,target:n.dataset.wuiDropTarget}}))}function T(t){let n=x(t.target,d);if(!n||!g)return;t.preventDefault();let r=e(t.dataTransfer,`A drag event arrived without its DataTransfer.`);r.dropEffect=`move`,n.classList.add(c)}function ne(e){let t=x(e.target,d);!t||e.relatedTarget instanceof Node&&t.contains(e.relatedTarget)||t.classList.remove(c)}function re(e){let t=x(e.target,d);if(!t||!g)return;e.preventDefault(),t.classList.remove(c);let{root:n,keys:r}=g;w(n,r,t),C()}function E(e){let t=x(e.target,d);t&&_?.keys.length&&(e.preventDefault(),w(_.root,_.keys,t))}function ie(e){(a(e)||e.key===` `)&&E(e)}function ae(e){h.has(e)||(h.add(e),e.addEventListener(`dragover`,T),e.addEventListener(`dragenter`,T),e.addEventListener(`dragleave`,ne),e.addEventListener(`drop`,re),e.addEventListener(`click`,E),e.addEventListener(`keydown`,ie))}function oe(t){let n=m.get(t);if(n)return n;ae(t.ownerDocument||t);let r=e=>{let n=x(e.target,f);if(!n||!t.contains(n))return;let r=b(e.target,ee);r&&n.contains(r)||(n.draggable=!0)},i=n=>{let r=x(n.target,f);if(!r||!t.contains(r))return;let i=v(r)?y(t):[r.dataset.rowKey],a=e(n.dataTransfer,`A drag event arrived without its DataTransfer.`);a.setData(l,JSON.stringify(i)),a.setData(`text/plain`,i.join(`,`)),a.effectAllowed=`move`,g={root:t,keys:i},document.body.classList.add(u)},a=e=>{let n=e instanceof CustomEvent?e.detail:void 0;if(S(n)){let{keys:e}=n;n.selected>0?_={root:t,keys:Array.isArray(e)?e:y(t)}:n.selected===0&&(_=null)}O(document)};t.addEventListener(`pointerdown`,r),t.addEventListener(`dragstart`,i),t.addEventListener(`dragend`,C),t.addEventListener(`selectionchange`,a);let o=()=>{t.removeEventListener(`pointerdown`,r),t.removeEventListener(`dragstart`,i),t.removeEventListener(`dragend`,C),t.removeEventListener(`selectionchange`,a),m.delete(t)};return m.set(t,o),o}var D=()=>n(`rowDrop`,o);function O(e=document){let t=e.querySelector(`[data-wui-row-drag] tbody tr ${p}:checked`)!==null;for(let n of e.querySelectorAll(d)){n.tagName!==`BUTTON`&&(n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`)),t?n.removeAttribute(`aria-disabled`):n.setAttribute(`aria-disabled`,`true`);let e=n.getAttribute(`data-wui-drop-label`)||te(n);n.setAttribute(`aria-label`,r(D().moveText,{label:e}))}for(let t of e.querySelectorAll(`.wui-drop-tray`))t.hasAttribute(`role`)||(t.setAttribute(`role`,`toolbar`),t.setAttribute(`aria-label`,D().moveLabel))}var k=[`light`,`dark`,`auto`],A=[`wave`,`circle`,`slide`,`blinds`,`fade`,`none`],j=`fade`,M=`theme`,N={wave:1100,circle:700,slide:600,blinds:900,fade:350,none:0},P=`wui-theme-switching`,F=`wui:theme:change`,I=`(prefers-color-scheme: dark)`,L=e=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(e).matches,R=e=>k.some(t=>t===e);function z(e){return e===`dark`||e===`auto`&&L(I)?`dark`:`light`}function B(e=M){let t=null;try{t=window.localStorage.getItem(e)}catch(e){if(!(e instanceof DOMException))throw e}return R(t)?t:`auto`}function V(e,t=M){try{window.localStorage.setItem(t,e)}catch(e){if(!(e instanceof DOMException))throw e}}function H(e){let t=document.documentElement,n=z(e);t.setAttribute(`data-theme`,e),t.setAttribute(`data-bs-theme`,n),document.dispatchEvent(new CustomEvent(F,{detail:{mode:n,preference:e}}))}var U=`((k)=>{let m;try{m=localStorage.getItem(k)}catch{m=null}if(m!=='light'&&m!=='dark')m='auto';const r=document.documentElement,q=window.matchMedia?window.matchMedia('(prefers-color-scheme: dark)'):null;function s(){const t=r.getAttribute('data-theme');r.setAttribute('data-bs-theme',t==='auto'?(q?.matches?'dark':'light'):t)}r.setAttribute('data-theme',m);s();if(q?.addEventListener)q.addEventListener('change',()=>{if(r.getAttribute('data-theme')==='auto')s()})})(`;function W(e=M){return`${U}${JSON.stringify(String(e)).replace(/</g,`\\u003c`)})`}function G(e,{includeAuto:t=!1}={}){return e===`light`?`dark`:e===`dark`&&t?`auto`:`light`}function K(e){if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>{};let t=window.matchMedia(I),n=()=>e(t.matches?`dark`:`light`);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)}var q=60,se=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,J=e=>e.toFixed(1),Y=(e,t)=>`${J(e)}px ${J(t)}px`,X={amplitude:22,segments:36,cycles:1.5,ripples:2},Z=6,ce=(e,t,n,r,i)=>{let{amplitude:a,segments:o,cycles:s}=X,c=n*(t+2*a),l=i?t+a-c:c-a,u=i?t+2*a:-2*a,d=[Y(0,u)];for(let t=0;t<=o;t++){let n=e*t/o,i=l+a*Math.sin(2*Math.PI*s*t/o+r);d.push(Y(n,i))}return d.push(Y(e,u)),`polygon(${d.join(`, `)})`},le=(e,t,n,r)=>{let i=t/Z,a=[];for(let t=0;t<Z;t++){let o=t*i,s=i*n,c=r?o+i-s:o,l=r?o+i:o+s;a.push(Y(0,c),Y(e,c),Y(e,l),Y(0,l))}return`polygon(${a.join(`, `)})`};function Q(e,{width:t,height:n,to:r=`dark`,origin:i}){let a=r===`dark`,o=[];for(let r=0;r<=q;r++){let s=r/q,c=se(s);switch(e){case`circle`:{let e=i?.x??t/2,r=i?.y??n/2,a=Math.hypot(Math.max(e,t-e),Math.max(r,n-r));o.push({clipPath:`circle(${J(a*c)}px at ${J(e)}px ${J(r)}px)`});break}case`slide`:{let e=n*(1-c);o.push({clipPath:a?`inset(${J(e)}px 0px 0px 0px)`:`inset(0px 0px ${J(e)}px 0px)`});break}case`blinds`:o.push({clipPath:le(t,n,c,a)});break;case`fade`:o.push({clipPath:`none`,opacity:c});break;case`none`:return[];default:o.push({clipPath:ce(t,n,c,s*X.ripples*2*Math.PI,a)})}}return o}var $=e=>{e instanceof DOMException&&(e.name===`AbortError`||e.name===`InvalidStateError`)||i(`[@webority/ui-elements] The theme view transition failed:`,e)};function ue(e,{effect:t=j,to:n,origin:r,duration:i}={}){let a=document.documentElement,o=n!==void 0&&a.getAttribute(`data-bs-theme`)===n;if(t===`none`||o||L(`(prefers-reduced-motion: reduce)`)||typeof document.startViewTransition!=`function`||typeof a.animate!=`function`)return e(),Promise.resolve(!1);a.classList.add(P);let s=document.startViewTransition(e),c=i??N[t]??N.fade;return s.ready.then(()=>{let e=Q(t,{width:window.innerWidth,height:window.innerHeight,to:n,origin:r});a.animate(e,{duration:c,easing:`linear`,fill:`both`,pseudoElement:`::view-transition-new(root)`})}).catch($),s.finished.catch($).finally(()=>a.classList.remove(P)).then(()=>!0)}export{s as _,N as a,H as c,z as d,V as f,K as g,ue as h,A as i,G as l,Q as m,M as n,k as o,W as p,F as r,P as s,j as t,B as u,oe as v,O as y};
|
package/dist/wuiHttp-BWf9dDsZ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./devWarn-DXdRWZs3.js";var t=Object.freeze([`POST`,`PUT`,`PATCH`,`DELETE`]),n=t=>(e(`[@webority/ui-elements] Wui-Toast-Action: ${t}; the toast shows no action.`),null),r=e=>typeof e==`object`&&!!e;function i(e){if(e==null||e===``)return null;let i;try{i=JSON.parse(e)}catch{return n(`the value is not JSON`)}let a=r(i)?i:{},o=a.label,s=a.url,c=String(a.method??`POST`).toUpperCase();return typeof o!=`string`||o===``||typeof s!=`string`||s===``?n(`label and url must be non-empty strings`):t.includes(c)?{label:o,url:s,method:c}:n(`method must be one of ${t.join(`, `)}`)}var a=`wui-csrf`,o=`RequestVerificationToken`,s={metaName:a,header:o};function c({metaName:e=a,header:t=o}={}){s={metaName:e,header:t}}var l=`Wui-Request`,u=Object.freeze({fragment:`Wui-Fragment`,message:`Wui-Message`,redirect:`Wui-Redirect`,result:`Wui-Result`,keepOpen:`Wui-Keep-Open`,toastVariant:`Wui-Toast-Variant`,toastAction:`Wui-Toast-Action`,data:`Wui-Data`,next:`Wui-Next`}),d=Object.freeze([`ok`,`validation`,`forbidden`,`client`,`server`,`network`,`timeout`,`aborted`,`stale`,`session`]),f=/* @__PURE__ */ new Set([`GET`,`HEAD`]);function p(e=document){let t=[...e.querySelectorAll(`meta`)].find(e=>e.getAttribute(`name`)===s.metaName),n=t?.getAttribute(`content`);return!t||!n?null:{header:t.getAttribute(`data-header`)||s.header,token:n}}var m=e=>{try{return new URL(e,window.location.href).origin===window.location.origin}catch{return!1}};function h(e){return e>=200&&e<300?`ok`:e===401?`session`:e===403?`forbidden`:e===422?`validation`:e>=400&&e<500?`client`:`server`}var g=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,_=3e4;function v(e){let t=e?.trim()??``;return/^\d+$/.test(t)?Number(t):void 0}var y=e=>{if(e==null||e===``)return null;try{return JSON.parse(e)}catch(e){throw TypeError(`The ${u.data} response header is not JSON: ${e instanceof Error?e.message:String(e)}`,{cause:e})}};async function b(e,t={}){let n=(t.method||`GET`).toUpperCase(),r=t.navigate||(e=>window.location.assign(e)),a={Accept:`text/html`,"X-Requested-With":`XMLHttpRequest`,[l]:`1`,...t.headers};if(!f.has(n)&&m(e)){let e=p();e&&(a[e.header]=e.token)}let o=e=>{if(e==null)return null;try{return decodeURIComponent(e)}catch{return e}},s=(e,t=null,n=``)=>{let r=e=>t?.headers.get(e)??null;return{kind:e,ok:e===`ok`,status:t?.status??0,html:n,response:t,message:o(r(u.message)),redirect:r(u.redirect),result:r(u.result),keepOpen:r(u.keepOpen)===`1`,toastVariant:r(u.toastVariant),toastAction:i(r(u.toastAction)),fragment:r(u.fragment)===`1`,data:y(o(r(u.data))),next:r(u.next)}},c=new AbortController,d=()=>c.abort(),_=t.signal;_?.aborted&&c.abort(),_?.addEventListener(`abort`,d,{once:!0});let v=t.timeoutMs??0,b=!1,x=v>0?setTimeout(()=>{b=!0,c.abort()},v):void 0,S=e=>_?.aborted?`aborted`:b?`timeout`:g(e)?`aborted`:`network`;try{let i;try{i=await fetch(e,{method:n,...t.body===void 0?{}:{body:t.body},headers:a,signal:c.signal,credentials:`same-origin`})}catch(e){return s(S(e))}let o=h(i.status);if(o===`ok`&&i.redirected&&i.headers.get(u.fragment)!==`1`&&(o=`session`),o===`session`)return r(i.status===401?i.headers.get(`Location`)||window.location.href:i.url),s(o,i);let l=``;if(o===`ok`||o===`validation`)try{l=await i.text()}catch(e){return s(S(e),i)}return s(o,i,l)}finally{clearTimeout(x),_?.removeEventListener(`abort`,d)}}function x(){let e=null,t=0;return{async run(n,r={}){e?.abort();let i=new AbortController;e=i;let a=++t,o=r.signal;o&&(o.aborted?i.abort():o.addEventListener(`abort`,()=>i.abort(),{once:!0}));let s;try{s=await b(n,{...r,signal:i.signal})}finally{e===i&&(e=null)}return a!==t&&s.kind!==`aborted`?{...s,kind:`stale`,ok:!1}:s},abort(){e?.abort(),e=null}}}export{u as a,x as c,b as d,t as f,d as i,p as l,o as n,h as o,i as p,_ as r,c as s,a as t,v as u};
|