@webority/ui-elements 0.163.0 → 0.164.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 +4 -4
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/dist/WuiCodeBlock-7O514Hqe.js +1 -0
- package/dist/{WuiCommandPalette-Dpz0DXKJ.js → WuiCommandPalette-rVScJ2Hy.js} +2 -2
- package/dist/WuiCommentThread-5Uz83s1Y.js +1 -0
- package/dist/WuiContextMenu-_ZeequGf.js +1 -0
- package/dist/{WuiDataTable-C1Rrxmh_.js → WuiDataTable-Bb5hxTfn.js} +1 -1
- package/dist/WuiDatePicker-BF_GVNaj.js +31 -0
- package/dist/WuiDateRange-B6xh25qZ.js +25 -0
- package/dist/WuiDrawer-BGuq6FAZ.js +1 -0
- package/dist/WuiDropdown-DVTtANwz.js +1 -0
- package/dist/WuiHoverCard-FL38ANLM.js +1 -0
- package/dist/WuiInlineEdit-DMK1ESdx.js +1 -0
- package/dist/WuiLightbox-BUD0uefB.js +1 -0
- package/dist/WuiMarkdown-B7nfQ6tW.js +4 -0
- package/dist/WuiMentionInput-Bo9bhe3U.js +1 -0
- package/dist/WuiModal-DvSt_466.js +1 -0
- package/dist/WuiNavigationMenu-Dlo-n-cL.js +1 -0
- package/dist/WuiNotificationCenter-DP-Sf4FQ.js +1 -0
- package/dist/WuiOverflow-CV5y5zkM.js +1 -0
- package/dist/WuiPhone-BC0MQ6bf.js +16 -0
- package/dist/WuiPopover-CQJLfgm_.js +1 -0
- package/dist/WuiRelativeTime-CmlKD-97.js +1 -0
- package/dist/WuiSavedViews-CdjavvPC.js +1 -0
- package/dist/WuiSelect-EquDxkz1.js +9 -0
- package/dist/WuiShortcuts-5PhCS5ri.js +1 -0
- package/dist/WuiTimePicker-OAP_QRwV.js +9 -0
- package/dist/WuiTour-Dxyv9uNz.js +1 -0
- package/dist/{WuiTree-COd5leOB.js → WuiTree-BPT9EZuw.js} +1 -1
- package/dist/{WuiTruncate-C2WV1-NN.js → WuiTruncate-BB4i8wHE.js} +1 -1
- package/dist/WuiWhatsNew-B2mM4MHE.js +1 -0
- package/dist/anchorOverlay-B8fu8hjz.js +1 -0
- package/dist/chips-Dcf6_wuZ.js +2 -0
- package/dist/drawerDiscard-BtPeayNT.js +1 -0
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/command-palette.js +1 -1
- package/dist/elements/comment-thread.js +1 -1
- package/dist/elements/context-menu.js +1 -1
- package/dist/elements/data-table.js +1 -1
- package/dist/elements/date-range.js +1 -1
- package/dist/elements/datepicker.js +1 -1
- package/dist/elements/drawer.js +1 -1
- package/dist/elements/dropdown.js +1 -0
- package/dist/elements/filter-popover.js +1 -1
- package/dist/elements/hover-card.js +1 -1
- package/dist/elements/inline-edit.js +1 -1
- package/dist/elements/lightbox.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/elements/mention-input.js +1 -1
- package/dist/elements/modal.js +1 -0
- package/dist/elements/navigation-menu.js +1 -1
- package/dist/elements/notification-center.js +1 -1
- package/dist/elements/overflow.js +1 -1
- package/dist/elements/phone.js +1 -1
- package/dist/elements/popover.js +1 -0
- package/dist/elements/relative-time.js +1 -1
- package/dist/elements/saved-views.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/shortcuts.js +1 -1
- package/dist/elements/timepicker.js +1 -1
- package/dist/elements/tour.js +1 -1
- package/dist/elements/tree.js +1 -1
- package/dist/elements/truncate.js +1 -1
- package/dist/elements/whats-new.js +1 -1
- package/dist/fileViewerImage-XsUnEv6Z.js +3 -0
- package/dist/fileViewerMedia-DTDM69nT.js +1 -0
- package/dist/{fileViewerPdf-CAbiTCHl.js → fileViewerPdf-vlVCKKyK.js} +2 -2
- package/dist/fileViewerUi-CprJdtCB.js +1 -0
- package/dist/filterPopover-CYzUbKN0.js +1 -0
- package/dist/helpers.js +1 -1
- package/dist/inlineEditText-_GFrdJ6F.js +1 -0
- package/dist/{listboxKeyNav-DkLHwzJE.js → listboxKeyNav-CF7tMDGG.js} +1 -1
- package/dist/loader-B7twHKUy.js +1 -0
- package/dist/menuKeyNav-COGecOjH.js +1 -0
- package/dist/nativeOverlay-BbkCnzFj.js +1 -0
- package/dist/{search-C0IYOzso.js → search-C6r6xpep.js} +1 -1
- package/dist/server.js +1 -1
- package/dist/{themeTransition-CwE2VwQa.js → themeTransition-Dt7Br1QT.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 +2 -2
- 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 +10 -10
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/dropdown.global.js +1 -0
- 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 +3 -3
- package/dist/ui-elements/modal.global.js +1 -0
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/phone.global.js +6 -6
- package/dist/ui-elements/popover.global.js +1 -0
- package/dist/ui-elements/resizable.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +2 -2
- package/dist/ui-elements/select-recents.global.js +1 -1
- package/dist/ui-elements/select-search.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/timepicker.global.js +4 -4
- package/dist/ui-elements/tour.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 +20 -20
- package/dist/ui-elements.js +1 -1
- package/dist/ui-file-viewer.global.js +10 -10
- package/dist/ui-file-viewer.js +1 -1
- package/dist/ui-tour.global.js +1 -1
- package/package.json +17 -5
- package/types/WuiCommandPalette.d.ts +2 -2
- package/types/WuiCommentThread.d.ts +1 -2
- package/types/WuiContextMenu.d.ts +56 -5
- package/types/WuiDatePicker.d.ts +3 -7
- package/types/WuiDateRange.d.ts +2 -9
- package/types/WuiDrawer.d.ts +9 -12
- package/types/WuiDropdown.d.ts +61 -0
- package/types/WuiHoverCard.d.ts +15 -1
- package/types/WuiInlineEdit.d.ts +2 -1
- package/types/WuiLightbox.d.ts +1 -2
- package/types/WuiMentionInput.d.ts +0 -4
- package/types/WuiModal.d.ts +50 -0
- package/types/WuiNavigationMenu.d.ts +8 -3
- package/types/WuiNotificationCenter.d.ts +10 -2
- package/types/WuiPhone.d.ts +1 -5
- package/types/WuiPopover.d.ts +67 -0
- package/types/WuiRelativeTime.d.ts +5 -6
- package/types/WuiSelect.d.ts +8 -6
- package/types/WuiShortcuts.d.ts +6 -1
- package/types/WuiSlider.d.ts +3 -3
- package/types/WuiTimePicker.d.ts +3 -5
- package/types/WuiTour.d.ts +1 -0
- package/types/WuiTruncate.d.ts +2 -2
- package/types/WuiWhatsNew.d.ts +3 -3
- package/types/anchorOverlay.d.ts +24 -8
- package/types/codeHighlight.d.ts +1 -1
- package/types/elements/dropdown.d.ts +2 -0
- package/types/elements/modal.d.ts +2 -0
- package/types/elements/popover.d.ts +2 -0
- package/types/fileViewerImage.d.ts +2 -0
- package/types/fileViewerMedia.d.ts +2 -0
- package/types/fileViewerPdf.d.ts +2 -0
- package/types/fileViewerUi.d.ts +1 -2
- package/types/filterPopover.d.ts +7 -8
- package/types/global/core.d.ts +0 -1
- package/types/global/shared.d.ts +6 -0
- package/types/globals.d.ts +23 -75
- package/types/helpers.d.ts +4 -0
- package/types/iconGlyphs.g.d.ts +1 -1
- package/types/index.d.ts +4 -1
- package/types/inlineEditText.d.ts +12 -1
- package/types/listboxKeyNav.d.ts +3 -3
- package/types/menuKeyNav.d.ts +8 -0
- package/types/nativeOverlay.d.ts +49 -0
- package/types/razor-js/modules/overlays.d.ts +1 -4
- package/types/razor-js/modules/serverBridge.d.ts +15 -13
- package/types/razor-js/modules/shared.d.ts +0 -7
- package/types/razor-js/modules/tables.d.ts +1 -0
- package/types/server/remoteModal.d.ts +0 -1
- package/types/statusIcons.d.ts +1 -1
- package/types/tooltips.d.ts +18 -0
- package/dist/WuiCodeBlock-cLLbSBK4.js +0 -1
- package/dist/WuiCommentThread-CclWHz4C.js +0 -1
- package/dist/WuiContextMenu-B2MrH_LK.js +0 -1
- package/dist/WuiDatePicker-DLEsnzqG.js +0 -31
- package/dist/WuiDateRange-9Xqs5nvv.js +0 -25
- package/dist/WuiDrawer-B3YFmxl2.js +0 -1
- package/dist/WuiHoverCard-CE3dHKaM.js +0 -1
- package/dist/WuiInlineEdit-pG9Z5tUQ.js +0 -1
- package/dist/WuiLightbox-C2A14vHx.js +0 -1
- package/dist/WuiMarkdown-BXY0QKaO.js +0 -4
- package/dist/WuiMentionInput-B_K8AXM5.js +0 -1
- package/dist/WuiNavigationMenu-CZ3XhFam.js +0 -1
- package/dist/WuiNotificationCenter-ClkCTUnp.js +0 -1
- package/dist/WuiOverflow-B0wA6aDe.js +0 -1
- package/dist/WuiPhone-icMSUnua.js +0 -16
- package/dist/WuiRelativeTime-DyeUQOQ8.js +0 -1
- package/dist/WuiSavedViews-Br9YKOVU.js +0 -1
- package/dist/WuiSelect-B199VL24.js +0 -9
- package/dist/WuiShortcuts-D3rWkaOm.js +0 -1
- package/dist/WuiTimePicker-wo9BlOFs.js +0 -9
- package/dist/WuiTour-D3Sx7JCM.js +0 -1
- package/dist/WuiWhatsNew-dLGyA4g1.js +0 -1
- package/dist/anchorOverlay-CXnWfezA.js +0 -1
- package/dist/chips-0jT9fpA9.js +0 -2
- package/dist/drawerDiscard-C-STs39f.js +0 -1
- package/dist/fileViewerImage-Bt1jeArm.js +0 -3
- package/dist/fileViewerMedia-Bp1uHJvC.js +0 -1
- package/dist/fileViewerUi-ResPjO1o.js +0 -1
- package/dist/filterPopover-CaHWe9V0.js +0 -1
- package/dist/inlineEditText-CsLCQbcg.js +0 -1
- package/dist/loader-DRYPWxQL.js +0 -1
- package/types/overlayRelease.d.ts +0 -12
- package/types/razor-js/modules/popovers.d.ts +0 -1
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./anchorOverlay-CXnWfezA.js";import{a as r,c as i,i as a,n as o,o as s,r as c,s as l,t as u}from"./calendarMath-D6UUgYTD.js";import{r as d}from"./dom-Do1pAA12.js";import{t as f}from"./elementBase-Cxeyx0tU.js";import{r as p,t as m}from"./fieldState-D-zQcXUS.js";import{t as h}from"./formMirror-9IpSgeZb.js";import{t as g}from"./iconGlyphs.g-DPqoOoXy.js";import{n as _}from"./optionLabel-4xjXWy74.js";var v=class extends f{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`disabled-weekdays`,`display-format`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}_internals;_value;_defaultValue;_rendered;_viewY;_viewM;_mode;_focus;_slide;_viewNavigated;_openFn;_closeFn;_bindGlobal;_onKeyBound;_onDocClick;_onDocKey;_onHostKey;get _open(){return d(this._openFn,`open missing`)}get _close(){return d(this._closeFn,`close missing`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._slide=``}connectedCallback(){this._rendered?this._bindGlobal?.():this.render()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`)this._syncInvalid();else if(this._rendered){if(e===`value`)this._value=n||``,this._syncFormValue(),this._syncTrigger();else if(e===`display-format`)this._syncTrigger();else if(e===`first-day`){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&e.hidden||this._renderView()}else this.render()}}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e instanceof HTMLButtonElement&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,h(this,this._value),this._syncTrigger()}_firstDay(){return r(this)}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this.getAttribute(`placeholder`)||`Choose a date`,t=l(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),r=n===`sm`?` input-sm`:n===`lg`?` input-lg`:``,i=this.getAttribute(`aria-label`),a=this.getAttribute(`aria-describedby`);this.innerHTML=`
|
|
2
|
-
<div class="datepicker">
|
|
3
|
-
<button type="button" class="input datepicker-trigger${r}${t?` has-value`:``}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${i?` aria-label="${_(i)}"`:``}${a?` aria-describedby="${_(a)}"`:``}>
|
|
4
|
-
<span data-trigger-label class="${t?``:`wui-select-placeholder`}">${_(t?s(this._value,this.getAttribute(`display-format`)):e)}</span>
|
|
5
|
-
${g(`calendar-dots`)}
|
|
6
|
-
</button>
|
|
7
|
-
<div class="datepicker-pop" role="dialog" aria-modal="false" hidden></div>
|
|
8
|
-
</div>`,this._rendered=!0,p(this,this.querySelector(`.datepicker-trigger`)),h(this,this._value),this._wire()}_syncFormValue(){h(this,this._value)}_syncTrigger(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!(t instanceof HTMLSpanElement))return;let n=l(this._value);t.textContent=n?s(this._value,this.getAttribute(`display-format`)):this.getAttribute(`placeholder`)||`Choose a date`,t.classList.toggle(`wui-select-placeholder`,!n),e?.classList.toggle(`has-value`,!!n),p(this,e)}_limits(){let e=l(this.getAttribute(`min`)),t=l(this.getAttribute(`max`)),n=e?new Date(e.y,e.m,e.d).getTime():-1/0,r=t?new Date(t.y,t.m,t.d).getTime():1/0,i=/* @__PURE__ */ new Set;for(let e of(this.getAttribute(`disabled-weekdays`)||``).split(`,`)){let t=e.trim();/^[0-6]$/.test(t)&&i.add(Number(t))}return{dayDisabled:(e,t,a)=>{let o=new Date(e,t,a),s=o.getTime();return s<n||s>r||i.has(o.getDay())},monthDisabled:(e,t)=>{let i=new Date(e,t,1).getTime();return new Date(e,t,a(e,t)).getTime()<n||i>r},yearDisabled:e=>{let t=new Date(e,0,1).getTime();return new Date(e,11,31).getTime()<n||t>r}}}_renderView(){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(e.innerHTML=this._mode===`months`?this._monthsHtml():this._mode===`years`?this._yearsHtml():this._daysHtml(),this._focusActive())}_daysHtml(){let e=this._firstDay(),t=(new Date(this._viewY,this._viewM,1).getDay()-e+7)%7,n=a(this._viewY,this._viewM),r=l(this._value),s=/* @__PURE__ */ new Date,{dayDisabled:d}=this._limits(),f=this._focus||r||{y:this._viewY,m:this._viewM,d:1},p=(e,t,n,a)=>{let o=i(e,t,n),c=r&&r.y===e&&r.m===t&&r.d===n,l=s.getFullYear()===e&&s.getMonth()===t&&s.getDate()===n,u=f.y===e&&f.m===t&&f.d===n,p=d(e,t,n);return`<button type="button" class="${[`datepicker-day`,a?`is-outside`:``,l?`is-today`:``,c?`is-selected`:``].filter(Boolean).join(` `)}" data-iso="${o}" role="gridcell" tabindex="${u&&!p?`0`:`-1`}"${c?` aria-selected="true"`:``}${p?` disabled aria-disabled="true"`:``}>${n}</button>`},h=``,_=c(this._viewY,this._viewM-1),v=a(_.y,_.m);for(let e=t-1;e>=0;e--)h+=p(_.y,_.m,v-e,!0);for(let e=1;e<=n;e++)h+=p(this._viewY,this._viewM,e,!1);let y=c(this._viewY,this._viewM+1),b=(7-(t+n)%7)%7;for(let e=1;e<=b;e++)h+=p(y.y,y.m,e,!0);let x=d(s.getFullYear(),s.getMonth(),s.getDate()),S=m(this)?``:`<button type="button" class="datepicker-link" data-clear>Clear</button>`,C=o.map((t,n)=>o[(n+e)%7]).map(e=>`<span>${e}</span>`).join(``);return`
|
|
9
|
-
<div class="datepicker-head">
|
|
10
|
-
<button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="Previous month">${g(`chevron-left`)}</button>
|
|
11
|
-
<button type="button" class="datepicker-month" data-view="months" aria-label="Choose month and year">${u[this._viewM]} ${this._viewY}</button>
|
|
12
|
-
<button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="Next month">${g(`chevron-right`)}</button>
|
|
13
|
-
</div>
|
|
14
|
-
<div class="datepicker-weekdays">${C}</div>
|
|
15
|
-
<div class="datepicker-grid${this._slide?` ${this._slide}`:``}" role="grid">${h}</div>
|
|
16
|
-
<div class="datepicker-foot">
|
|
17
|
-
<button type="button" class="datepicker-link" data-today${x?` disabled`:``}>Today</button>
|
|
18
|
-
${S}
|
|
19
|
-
</div>`}_monthsHtml(){let e=l(this._value),t=/* @__PURE__ */ new Date,{monthDisabled:n}=this._limits(),r=``;for(let i=0;i<12;i++){let a=e&&e.y===this._viewY&&e.m===i,o=t.getFullYear()===this._viewY&&t.getMonth()===i,s=n(this._viewY,i),c=[`datepicker-cell`,o?`is-today`:``,a?`is-selected`:``].filter(Boolean).join(` `),l=u[i];if(l===void 0)throw Error(`month name missing`);r+=`<button type="button" class="${c}" data-month="${i}"${s?` disabled`:``}>${l.slice(0,3)}</button>`}return`
|
|
20
|
-
<div class="datepicker-head">
|
|
21
|
-
<button type="button" class="datepicker-nav-btn" data-nav-year="-1" aria-label="Previous year">${g(`chevron-left`)}</button>
|
|
22
|
-
<button type="button" class="datepicker-month" data-view="years" aria-label="Choose year">${this._viewY}</button>
|
|
23
|
-
<button type="button" class="datepicker-nav-btn" data-nav-year="1" aria-label="Next year">${g(`chevron-right`)}</button>
|
|
24
|
-
</div>
|
|
25
|
-
<div class="datepicker-cells">${r}</div>`}_yearsHtml(){let e=l(this._value),t=(/* @__PURE__ */ new Date()).getFullYear(),{yearDisabled:n}=this._limits(),r=this._viewY-(this._viewY%10+10)%10-1,i=``;for(let a=0;a<12;a++){let o=r+a,s=e&&e.y===o,c=t===o,l=n(o),u=[`datepicker-cell`,c?`is-today`:``,s?`is-selected`:``].filter(Boolean).join(` `);i+=`<button type="button" class="${u}" data-year="${o}"${l?` disabled`:``}>${o}</button>`}return`
|
|
26
|
-
<div class="datepicker-head">
|
|
27
|
-
<button type="button" class="datepicker-nav-btn" data-nav-decade="-1" aria-label="Previous decade">${g(`chevron-left`)}</button>
|
|
28
|
-
<span class="datepicker-month">${r+1} to ${r+10}</span>
|
|
29
|
-
<button type="button" class="datepicker-nav-btn" data-nav-decade="1" aria-label="Next decade">${g(`chevron-right`)}</button>
|
|
30
|
-
</div>
|
|
31
|
-
<div class="datepicker-cells">${i}</div>`}_focusActive(){let e=this.querySelector(`.datepicker-pop`);if(!(e instanceof HTMLDivElement))return;let t=e.querySelector(`[tabindex="0"]`)||e.querySelector(`.is-selected`)||e.querySelector(`.datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)`);t instanceof HTMLElement&&e.contains(document.activeElement)&&t.focus()}_position(e,t){n(e,t,{clampHeight:!0})}_setFocus(e,t,n,r){let{y:a,m:o}=c(e,t);this._focus={y:a,m:o,d:n};let s=a!==this._viewY||o!==this._viewM;this._viewY=a,this._viewM=o,this._slide=s&&r||``,this._renderView(),this._slide=``;let l=this.querySelector(`.datepicker-day[data-iso="${i(a,o,n)}"]`);l instanceof HTMLButtonElement&&l.focus()}_seek(e,t,n,r){let{dayDisabled:i}=this._limits(),a=new Date(e,t,n);for(let e=0;e<400;e++,a.setDate(a.getDate()+r))if(!i(a.getFullYear(),a.getMonth(),a.getDate()))return new Date(a);return null}_onKey(e){if(this._mode!==`days`)return;let t=this._focus||l(this._value)||{y:this._viewY,m:this._viewM,d:1},n=(e,t,n,r,i)=>{let a=this._seek(e,t,n,r);a&&this._setFocus(a.getFullYear(),a.getMonth(),a.getDate(),i)},r=(r,i,a=r<0?-1:1)=>{e.preventDefault(),n(t.y,t.m,t.d+r,a,i)};switch(e.key){case`ArrowLeft`:r(-1,`slide-prev`);break;case`ArrowRight`:r(1,`slide-next`);break;case`ArrowUp`:r(-7,`slide-prev`);break;case`ArrowDown`:r(7,`slide-next`);break;case`Home`:r(-((new Date(t.y,t.m,t.d).getDay()-this._firstDay()+7)%7),`slide-prev`,1);break;case`End`:r(6-(new Date(t.y,t.m,t.d).getDay()-this._firstDay()+7)%7,`slide-next`,-1);break;case`PageUp`:{e.preventDefault();let r=c(t.y,t.m-(e.shiftKey?12:1));n(r.y,r.m,Math.min(t.d,a(r.y,r.m)),-1,`slide-prev`);break}case`PageDown`:{e.preventDefault();let r=c(t.y,t.m+(e.shiftKey?12:1));n(r.y,r.m,Math.min(t.d,a(r.y,r.m)),1,`slide-next`);break}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(t.y,t.m,t.d)||(this.value=i(t.y,t.m,t.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return}}_wire(){this._teardown();let n=this.querySelector(`.datepicker-trigger`),r=this.querySelector(`.datepicker-pop`),a=this.querySelector(`.datepicker`);if(!(n instanceof HTMLButtonElement)||!(r instanceof HTMLDivElement))return;let o=()=>!r.hidden,s=()=>{o()&&this._position(n,r)};this._openFn=()=>{if(m(this))return;let t=/* @__PURE__ */ new Date,i=l(this._value);(i||!this._viewNavigated)&&(this._viewY=t.getFullYear(),this._viewM=t.getMonth()),this._mode=`days`;let o=t.getFullYear()===this._viewY&&t.getMonth()===this._viewM,c=i&&i.y===this._viewY&&i.m===this._viewM;if(this._focus=c?i:{y:this._viewY,m:this._viewM,d:o?t.getDate():1},this._limits().dayDisabled(this._focus.y,this._focus.m,this._focus.d)){let e=this._focus,t=[1,-1].map(t=>this._seek(e.y,e.m,e.d,t)).find(t=>t&&t.getMonth()===e.m);t&&(this._focus={y:t.getFullYear(),m:t.getMonth(),d:t.getDate()})}this._renderView(),r.hidden=!1,a?.classList.add(`open`),this._position(n,r),e(this,s),n.setAttribute(`aria-expanded`,`true`);let u=r.querySelector(`[tabindex="0"]`);u instanceof HTMLElement&&u.focus()},this._closeFn=()=>{r.hidden=!0,a?.classList.remove(`open`),n.setAttribute(`aria-expanded`,`false`),t(this),n.focus()},n.addEventListener(`click`,()=>o()?this._close():this._open()),r.addEventListener(`click`,e=>{let t=e.target;if(!(t instanceof Element))throw Error(`click target is not an element`);let n=t.closest(`[data-nav]`);if(n instanceof HTMLElement){this._viewNavigated=!0,this._slide=Number(n.dataset.nav)<0?`slide-prev`:`slide-next`;let e=c(this._viewY,this._viewM+Number(n.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._focus={y:e.y,m:e.m,d:1},this._renderView(),this._slide=``;return}let r=t.closest(`[data-nav-year]`);if(r instanceof HTMLElement){this._viewY+=Number(r.dataset.navYear),this._renderView();return}let a=t.closest(`[data-nav-decade]`);if(a instanceof HTMLElement){this._viewY+=Number(a.dataset.navDecade)*10,this._renderView();return}let o=t.closest(`[data-view]`);if(o instanceof HTMLElement){this._mode=o.dataset.view,this._renderView();return}let s=t.closest(`[data-month]`);if(s instanceof HTMLButtonElement&&!s.disabled){this._viewNavigated=!0,this._viewM=Number(s.dataset.month),this._mode=`days`,this._focus={y:this._viewY,m:this._viewM,d:1},this._renderView();return}let l=t.closest(`[data-year]`);if(l instanceof HTMLButtonElement&&!l.disabled){this._viewNavigated=!0,this._viewY=Number(l.dataset.year),this._mode=`months`,this._renderView();return}if(t.closest(`[data-today]`)){let e=/* @__PURE__ */ new Date;if(this._limits().dayDisabled(e.getFullYear(),e.getMonth(),e.getDate()))return;this.value=i(e.getFullYear(),e.getMonth(),e.getDate()),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}if(t.closest(`[data-clear]`)){this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}let u=t.closest(`.datepicker-day[data-iso]`);u instanceof HTMLButtonElement&&!u.disabled&&(this.value=u.dataset.iso,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{o()&&this._onKey(e)},r.addEventListener(`keydown`,this._onKeyBound),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{o()&&!e.composedPath().includes(this)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{o()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),this._onHostKey=e=>{o()&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this._close())},this.addEventListener(`keydown`,this._onHostKey),o()&&e(this,s)},this._bindGlobal(),this._syncFormValue()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),this._onHostKey&&=(this.removeEventListener(`keydown`,this._onHostKey),null),t(this)}disconnectedCallback(){this._teardown()}};export{v as t};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./anchorOverlay-CXnWfezA.js";import{a as r,c as i,i as a,n as o,o as s,r as c,s as l,t as u}from"./calendarMath-D6UUgYTD.js";import{n as d}from"./devWarn-DXdRWZs3.js";import{n as f,r as p,t as m}from"./zone-BR02ZkHF.js";import{t as h}from"./elementBase-Cxeyx0tU.js";import{r as g,t as _}from"./fieldState-D-zQcXUS.js";import{t as v}from"./iconGlyphs.g-DPqoOoXy.js";import{n as y}from"./optionLabel-4xjXWy74.js";var b=4,x=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],S={today:`Today`,yesterday:`Yesterday`,last7Days:`Last 7 days`,last30Days:`Last 30 days`,thisMonth:`This month`,lastMonth:`Last month`,thisFinancialYear:`This financial year`},C=e=>String(e).padStart(2,`0`),w=e=>`${e.getUTCFullYear()}-${C(e.getUTCMonth()+1)}-${C(e.getUTCDate())}`;function T(e){return x.includes(e)}function E(e,t=/* @__PURE__ */ new Date,{timeZone:n=m,financialYearStart:r=b}={}){if(!T(e))return null;let i=l(p(n,t));if(!i)throw Error(`today missing`);let{y:a,m:o,d:s}=i,c=(e,t,n)=>w(new Date(Date.UTC(e,t,n))),u=S[e];switch(e){case`today`:return{label:u,start:c(a,o,s),end:c(a,o,s)};case`yesterday`:return{label:u,start:c(a,o,s-1),end:c(a,o,s-1)};case`last7Days`:return{label:u,start:c(a,o,s-6),end:c(a,o,s)};case`last30Days`:return{label:u,start:c(a,o,s-29),end:c(a,o,s)};case`thisMonth`:return{label:u,start:c(a,o,1),end:c(a,o+1,0)};case`lastMonth`:return{label:u,start:c(a,o-1,1),end:c(a,o,0)};case`thisFinancialYear`:{let e=r-1,t=o>=e?a:a-1;return{label:u,start:c(t,e,1),end:c(t+1,e,0)}}default:return null}}function D(e){d(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function O(e){return typeof e==`object`&&!!e}function k(e,t=/* @__PURE__ */ new Date,n={}){let r=String(e??``).trim();if(!r)return[];let i;if(r.startsWith(`[`))try{i=JSON.parse(r)}catch{return D(`the attribute is not valid JSON`),[]}else i=r.split(`,`).map(e=>e.trim());let a=[];for(let e of i)if(typeof e==`string`){let r=E(e,t,n);r?a.push(r):D(`"${e}" is not one of ${x.join(`, `)}`)}else O(e)&&typeof e.label==`string`&&e.label&&typeof e.start==`string`&&typeof e.end==`string`&&l(e.start)&&l(e.end)?a.push({label:e.label,start:e.start,end:e.end}):D(`an item needs a label and ISO start and end dates, or a preset name`);return a}function A(e){if(!(e.target instanceof Element))throw Error(`Expected the event target to be an element.`);return e.target}function j(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 M=class extends h{static formAssociated=!0;_internals;_start;_end;_hover;_viewY;_viewM;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._bindGlobal?.():this.render()}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 r(this)}_label(){let e=this.getAttribute(`placeholder`)||`Start to End`;return!this._start&&!this._end?{text:e,empty:!0}:{text:`${s(this._start)||`Start`} to ${s(this._end)||`End`}`,empty:!1}}render(){this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=l(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` input-sm`:t===`lg`?` input-lg`:``,{text:r,empty:i}=this._label(),a=this.getAttribute(`aria-label`),o=this.getAttribute(`aria-describedby`);this.innerHTML=`
|
|
2
|
-
<div class="daterange">
|
|
3
|
-
<button type="button" class="input daterange-trigger${n}${i?``:` has-value`}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${a?` aria-label="${y(a)}"`:``}${o?` aria-describedby="${y(o)}"`:``}>
|
|
4
|
-
<span data-range-label class="${i?`wui-select-placeholder`:``}">${y(r)}</span>
|
|
5
|
-
${v(`calendar`)}
|
|
6
|
-
</button>
|
|
7
|
-
<div class="daterange-pop" role="dialog" aria-modal="false" hidden></div>
|
|
8
|
-
</div>`,g(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=l(this.getAttribute(`min`)),t=l(this.getAttribute(`max`)),n=e?new Date(e.y,e.m,e.d).getTime():-1/0,r=t?new Date(t.y,t.m,t.d).getTime():1/0;return(e,t,i)=>{let a=new Date(e,t,i).getTime();return a<n||a>r}}_monthHtml(e,t){let n=this._firstDay(),r=(new Date(e,t,1).getDay()-n+7)%7,s=a(e,t),l=this._limits(),d=o.map((e,t)=>o[(t+n)%7]).map(e=>`<span>${e}</span>`).join(``),f=(e,t,n,r)=>{let a=i(e,t,n),o=l(e,t,n);return`<button type="button" class="${[`datepicker-day`,r?`is-outside`:``].filter(Boolean).join(` `)}" data-iso="${a}"${o?` disabled`:``}>${n}</button>`},p=``,m=c(e,t-1),h=a(m.y,m.m);for(let e=r-1;e>=0;e--)p+=f(m.y,m.m,h-e,!0);for(let n=1;n<=s;n++)p+=f(e,t,n,!1);let g=c(e,t+1),_=(7-(r+s)%7)%7;for(let e=1;e<=_;e++)p+=f(g.y,g.m,e,!0);return`
|
|
9
|
-
<div class="daterange-cal">
|
|
10
|
-
<div class="datepicker-month-label">${u[t]} ${e}</div>
|
|
11
|
-
<div class="datepicker-weekdays">${d}</div>
|
|
12
|
-
<div class="datepicker-grid" role="grid">${p}</div>
|
|
13
|
-
</div>`}_presetOptions(){let e=this.getAttribute(`time-zone`),t=m;e!==null&&(f(e)?t=e:d(`[@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:d(`[@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``;let e=this._limits(),t=t=>{let n=l(t);if(!n)throw Error(`Expected a preset date, found "${t}".`);return e(n.y,n.m,n.d)};return`<div class="wui-daterange-presets" role="group" aria-label="Quick ranges">${this._presetList.map((e,n)=>`<button type="button" class="wui-daterange-preset" data-preset="${n}"${t(e.start)||t(e.end)?` disabled`:``}>${y(e.label)}</button>`).join(``)}</div>`}_renderView(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=c(this._viewY,this._viewM+1),n=this._presetsHtml(),r=`
|
|
14
|
-
<div class="daterange-head">
|
|
15
|
-
<button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="Previous month">${v(`chevron-left`)}</button>
|
|
16
|
-
<button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="Next month">${v(`chevron-right`)}</button>
|
|
17
|
-
</div>
|
|
18
|
-
<div class="daterange-cals">
|
|
19
|
-
${this._monthHtml(this._viewY,this._viewM)}
|
|
20
|
-
${this._monthHtml(t.y,t.m)}
|
|
21
|
-
</div>
|
|
22
|
-
<div class="datepicker-foot">
|
|
23
|
-
<span class="daterange-hint" data-range-hint></span>
|
|
24
|
-
<button type="button" class="datepicker-link" data-clear>Clear</button>
|
|
25
|
-
</div>`;e.classList.toggle(`wui-daterange-pop--presets`,n!==``),e.innerHTML=n?`${n}<div class="wui-daterange-main">${r}</div>`:r,this._paint()}_paint(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=this._start?new Date(this._start).getTime():null,n=this._end;t&&!this._end&&this._hover&&new Date(this._hover).getTime()>=t&&(n=this._hover);let r=n?new Date(n).getTime():null;for(let n of j(e,`.datepicker-day[data-iso]`)){let e=new Date(n.dataset.iso??``).getTime(),i=t!=null&&e===t,a=r!=null&&e===r,o=t!=null&&r!=null&&e>t&&e<r;n.classList.toggle(`is-range-start`,i),n.classList.toggle(`is-range-end`,a),n.classList.toggle(`in-range`,o)}j(e,`[data-preset]`).forEach(e=>{let t=this._presetList?.[Number(e.dataset.preset)],n=!!t&&t.start===this._start&&t.end===this._end;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-pressed`,String(n))});let i=e.querySelector(`[data-range-hint]`);i&&(i.textContent=this._start?this._end?`${s(this._start)} to ${s(this._end)}`:`Pick an end date`:`Pick a start date`)}_position(e,t){n(e,t,{clampHeight:!0})}_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()}_wire(){this._teardown();let n=this.querySelector(`.daterange-trigger`),r=this.querySelector(`.daterange-pop`),i=this.querySelector(`.daterange`);if(!(n instanceof HTMLButtonElement)||!(r instanceof HTMLDivElement))return;let a=()=>!r.hidden,o=()=>{a()&&this._position(n,r)};this._open=()=>{let t=l(this._start);if(t)this._viewY=t.y,this._viewM=t.m;else{let e=/* @__PURE__ */ new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._presetList=k(this.getAttribute(`presets`),/* @__PURE__ */ new Date,this._presetOptions()),this._renderView(),r.hidden=!1,i?.classList.add(`open`),this._position(n,r),e(this,o),n.setAttribute(`aria-expanded`,`true`)},this._close=()=>{r.hidden=!0,this._hover=``,i?.classList.remove(`open`),n.setAttribute(`aria-expanded`,`false`),t(this)},n.addEventListener(`click`,()=>{a()?this._close():_(this)||this._open()}),r.addEventListener(`click`,e=>{let t=A(e),n=t.closest(`[data-nav]`);if(n instanceof HTMLElement){let e=c(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 i=t.closest(`.datepicker-day[data-iso]`);if(i instanceof HTMLButtonElement&&!i.disabled){let e=i.dataset.iso;e!==void 0&&this._pick(e)}}),r.addEventListener(`mouseover`,e=>{let t=A(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._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{a()&&!e.composedPath().includes(this)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{a()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),this._onHostKey=e=>{a()&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this._close())},this.addEventListener(`keydown`,this._onHostKey),a()&&e(this,o)},this._bindGlobal(),this._syncMirrors()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),this._onHostKey&&=(this.removeEventListener(`keydown`,this._onHostKey),null),t(this)}disconnectedCallback(){this._teardown()}};export{M as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";var t=[50,90],n=10,r=100;function i(e,i=t){let a=Array.isArray(e)?e:String(e??``).split(`,`),o=[];for(let e of a){if(typeof e==`string`&&e.trim()===``)return i;let t=Number(e);if(!Number.isFinite(t)||t<n||t>r)return i;o.includes(t)||o.push(t)}return o.length?o.sort((e,t)=>e-t):i}function a(e){let{points:t,index:n,visible:r,velocity:i,canDismiss:a}=e,o=a?-1:0;if(Math.abs(i)>=.5)return i>0?Math.max(n-1,o):Math.min(n+1,t.length-1);let s=t[0];if(a&&s!==void 0&&r<s/2)return-1;let c=0;for(let e=1;e<t.length;e++){let n=t[e],i=t[c];if(n===void 0||i===void 0)throw Error(`snap point missing`);Math.abs(n-r)<Math.abs(i-r)&&(c=e)}return c}var o=`(max-width: 767.98px)`,s=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,c=4,l=0,u=/* @__PURE__ */ new WeakSet;function d(e,t){let n=e[t];if(n===void 0)throw RangeError(`no snap point at ${t}`);return n}function f(e){u.has(e)||(u.add(e),e.addEventListener(`click`,t=>{let n=t.target,r=n instanceof Element?n.closest(`[data-wui-drawer-open]`):null;if(!(r instanceof HTMLElement))return;let i=(r.getAttribute(`data-wui-drawer-open`)??``).replace(/^#/,``),a=e.getElementById(i);a instanceof p&&(t.preventDefault(),a.show(r))}))}var p=class extends e{_doc;_media;_shown;_locked;_opener;_snap;_drag;_onMedia;_onClick;_onPointerDown;_onPointerMove;_onPointerUp;_onKeyDown;_onHostKey;_onTransitionEnd;_announced;static get observedAttributes(){return[`open`,`snap-points`,`no-sheet`]}constructor(){super(),this._doc=null,this._media=null,this._shown=!1,this._locked=!1,this._opener=null,this._snap=0,this._drag=null,this._onMedia=()=>this._syncMode(),this._onClick=e=>this._click(e),this._onPointerDown=e=>this._pointerDown(e),this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onKeyDown=e=>this._keyDown(e),this._onHostKey=e=>{e.key===`Escape`&&this._keyDown(e)},this._onTransitionEnd=e=>{e.target===this._panel()&&e.propertyName===`transform`&&this._announce()},this._announced=!1}connectedCallback(){this._doc=this.ownerDocument,f(this._doc),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`transitionend`,this._onTransitionEnd),this._media=typeof matchMedia==`function`?matchMedia(o):null,this._media?.addEventListener?.(`change`,this._onMedia),this._syncMode(),this._applyPoints(),this.hasAttribute(`open`)?this._open():this.setAttribute(`inert`,``)}disconnectedCallback(){this._endDrag(),this._shown&&this._release(),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`transitionend`,this._onTransitionEnd),this._media?.removeEventListener?.(`change`,this._onMedia),this._media=null,this._doc=null}attributeChangedCallback(e){this._doc&&(e===`open`?this.hasAttribute(`open`)?this._open():this._close():e===`no-sheet`?this._syncMode():(this._snap=Math.min(this._snap,this._points().length-1),this._applyPoints()))}get isOpen(){return this.hasAttribute(`open`)}show(e){e&&(this._opener=e),this.setAttribute(`open`,``)}hide(){this.removeAttribute(`open`)}_points(){return i(this.getAttribute(`snap-points`),t)}_sheet(){return!!this._media?.matches&&!this.hasAttribute(`no-sheet`)}_syncMode(){this.setAttribute(`data-mode`,this._sheet()?`sheet`:`side`)}_applyPoints(){let e=this._points();this._snap=Math.min(Math.max(this._snap,0),e.length-1),this.style.setProperty(`--wui-drawer-max`,String(e[e.length-1])),this.style.setProperty(`--wui-drawer-snap`,String(e[this._snap])),this.setAttribute(`data-snap`,String(this._snap));let t=this.querySelector(`.wui-drawer-handle`);if(!(t instanceof Element))return;let n=e[this._snap];t.setAttribute(`aria-valuemin`,String(e[0])),t.setAttribute(`aria-valuemax`,String(e[e.length-1])),t.setAttribute(`aria-valuenow`,String(n)),t.setAttribute(`aria-valuetext`,`${n}% of the screen`)}_setSnap(e){let t=this._points(),n=Math.min(Math.max(e,0),t.length-1),r=n!==this._snap;this._snap=n,this._applyPoints(),r&&this.dispatchEvent(new CustomEvent(`wui-drawer-snap`,{bubbles:!0,detail:{index:n,percent:t[n]}}))}_open(){if(this._shown)return;this._shown=!0;let e=this._document(),t=e.activeElement;this._opener??=t instanceof HTMLElement||t instanceof SVGElement?t:null;let n=Number.parseInt(this.getAttribute(`default-snap`)??`0`,10);this._snap=Number.isFinite(n)?n:0,this._syncMode(),this._applyPoints(),this.removeAttribute(`inert`),this._locked||(this._locked=!0,l++,e.body.classList.add(`wui-drawer-locked`)),e.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`keydown`,this._onHostKey),this._focusIn(),this._settle()}_close(){if(!this._shown)return;this._endDrag(),this.setAttribute(`inert`,``);let e=this._document(),t=this._opener,n=e.activeElement;this._release(),this._opener=null,t?.isConnected&&(n===e.body||this.contains(n))&&t.focus?.(),this._settle()}_settle(){(this._panel()?.getAnimations?.()??[]).length||this._announce()}_announce(){let e=this.isOpen;e!==this._announced&&(this._announced=e,this.dispatchEvent(new CustomEvent(e?`wui-drawer-opened`:`wui-drawer-closed`,{bubbles:!0})))}_release(){this._shown=!1,this._doc?.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`keydown`,this._onHostKey),this._locked&&(this._locked=!1,l--,l<=0&&(l=0,this._doc?.body.classList.remove(`wui-drawer-locked`)))}_document(){let e=this._doc;if(!e)throw TypeError(`wui-drawer is not connected`);return e}_panel(){let e=this.querySelector(`.wui-drawer-panel`);return e instanceof HTMLElement?e:null}_focusables(){let e=this._panel();if(!e)return[];let t=[];for(let n of e.querySelectorAll(s))n instanceof HTMLElement&&!n.closest(`[hidden],[inert]`)&&t.push(n);return t}_focusIn(){let e=this._panel();if(!e)return;let t=e.querySelector(`[data-autofocus]`),n=this._sheet()?null:this._focusables().find(e=>e.closest(`.wui-drawer-body`));(t instanceof HTMLElement?t:n??e).focus?.({preventScroll:!0})}_dismissible(){return!this.hasAttribute(`static`)&&!this.hasAttribute(`no-dismiss`)}_requestClose(){let e=this.dispatchEvent(new CustomEvent(`wui-drawer-close`,{bubbles:!0,cancelable:!0}));return e&&this.hide(),e}_click(e){if(!this.isOpen)return;let t=e.target;t instanceof Element&&(t.closest(`[data-wui-drawer-close]`)||t.closest(`[data-wui-drawer-backdrop]`)&&this._dismissible())&&this._requestClose()}_keyDown(e){if(e.key===`Escape`){if(e.defaultPrevented||!this._dismissible()||this._document().querySelector(`.modal.show`))return;e.preventDefault(),e.stopPropagation(),this._requestClose()}else e.key===`Tab`?this._trapTab(e):e.target instanceof Element&&e.target.closest(`.wui-drawer-handle`)&&this._sheet()&&this._handleKey(e)}_trapTab(e){let t=this._focusables(),n=this._panel(),r=t[0],i=t[t.length-1];if(!r||!i){e.preventDefault(),n?.focus?.();return}let a=this._document().activeElement;!n?.contains(a)||a===n?(e.preventDefault(),(e.shiftKey?i:r).focus()):e.shiftKey&&a===r?(e.preventDefault(),i.focus()):!e.shiftKey&&a===i&&(e.preventDefault(),r.focus())}_handleKey(e){let t=this._points().length-1,n={ArrowUp:this._snap+1,ArrowDown:this._snap-1,Home:0,End:t};if(!(e.key in n))return;let r=n[e.key];r!==void 0&&(e.preventDefault(),this._setSnap(r))}_pointerDown(e){if(!this.isOpen||!this._sheet()||(e.button??0)!==0)return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[data-wui-drawer-grip]`);n instanceof HTMLElement&&!t.closest(`button`)&&(this._drag={grip:n,id:e.pointerId,startY:e.clientY,lastY:e.clientY,lastT:e.timeStamp,velocity:0,moved:!1},n.setPointerCapture?.(e.pointerId),n.addEventListener(`pointermove`,this._onPointerMove),n.addEventListener(`pointerup`,this._onPointerUp),n.addEventListener(`pointercancel`,this._onPointerUp))}_viewport(){let e=this._document().defaultView;if(!e)throw TypeError(`wui-drawer has no window`);return e.innerHeight}_pointerMove(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let n=e.clientY-t.startY;if(!t.moved&&Math.abs(n)<c)return;t.moved=!0,this.classList.add(`is-dragging`);let r=e.timeStamp-t.lastT;r>0&&(t.velocity=(e.clientY-t.lastY)/r),t.lastY=e.clientY,t.lastT=e.timeStamp;let i=this._points(),a=(d(i,i.length-1)-d(i,this._snap))/100*this._viewport();t.offset=Math.max(n,-a),this.style.setProperty(`--wui-drawer-drag`,`${t.offset}px`)}_pointerUp(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let{moved:n,velocity:r,offset:i=0}=t;if(this._endDrag(),!n)return;let o=this._points(),s=this._viewport(),c=(d(o,this._snap)/100*s-i)/(s/100),l=this._dismissible(),u=a({points:o,index:this._snap,visible:c,velocity:r,canDismiss:l});u>=0?this._setSnap(u):this._requestClose()}_endDrag(){let e=this._drag;e&&(this._drag=null,e.grip.releasePointerCapture?.(e.id),e.grip.removeEventListener(`pointermove`,this._onPointerMove),e.grip.removeEventListener(`pointerup`,this._onPointerUp),e.grip.removeEventListener(`pointercancel`,this._onPointerUp),this.classList.remove(`is-dragging`),this.style.removeProperty(`--wui-drawer-drag`))}};export{p as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./anchorOverlay-CXnWfezA.js";import{t as r}from"./elementBase-Cxeyx0tU.js";var i=300,a=150,o=`.wui-hover-card-trigger`,s=`.wui-hover-card-panel`,c=`a[href],button,input,select,textarea,[tabindex]`,l=0;function u(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}var d=class extends r{_doc;_timer;_described;_refocusing;_onOver;_onOut;_onFocusIn;_onFocusOut;_onKeyDown;static get observedAttributes(){return[`open`]}constructor(){super(),this._doc=null,this._timer=null,this._described=null,this._refocusing=!1,this._onOver=e=>{if(e.pointerType===`touch`||e.pointerType===`pen`)return;let t=this._zone(e.target);t===`panel`?this._clear():t===`trigger`&&this._schedule(!0)},this._onOut=e=>{e.pointerType!==`touch`&&e.pointerType!==`pen`&&this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onFocusIn=e=>{this._refocusing||(this._zone(e.target)===`trigger`?this._schedule(!0):this._zone(e.target)===`panel`&&this._clear())},this._onFocusOut=e=>{this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onKeyDown=e=>{if(e.key!==`Escape`||!this.isOpen||this.hasAttribute(`open`))return;e.stopPropagation();let t=this._panel?.contains(this.ownerDocument.activeElement);this._clear(),this._setOpen(!1),t&&(this._refocusing=!0,this._anchor?.focus(),this._refocusing=!1)}}get isOpen(){return this._panel?.hasAttribute(`data-open`)??!1}connectedCallback(){this._doc=this.ownerDocument,this.addEventListener(`pointerover`,this._onOver),this.addEventListener(`pointerout`,this._onOut),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen()}attributeChangedCallback(){this.isConnected&&this._syncOpen()}disconnectedCallback(){this._clear(),this.removeEventListener(`pointerover`,this._onOver),this.removeEventListener(`pointerout`,this._onOut),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`keydown`,this._onKeyDown),t(this),this._doc=null}get _trigger(){return u(this,o)}get _panel(){return u(this,s)}get _anchor(){let e=this._trigger;return e?u(e,c)??e:null}_zone(e){if(!(e instanceof Node)||!this.contains(e))return null;let t=e instanceof Element?e:e.parentElement;return this._panel?.contains(t)?`panel`:this._trigger?.contains(t)?`trigger`:null}_delay(e,t){let n=Number(this.getAttribute(e));return this.hasAttribute(e)&&Number.isFinite(n)&&n>=0?n:t}_clear(){this._timer!==null&&clearTimeout(this._timer),this._timer=null}_syncOpen(){this._clear(),this._setOpen(this.hasAttribute(`open`))}_schedule(e){if(!e&&this.hasAttribute(`open`)||(this._clear(),this.isOpen===e))return;let t=e?this._delay(`open-delay`,i):this._delay(`close-delay`,a);this._timer=setTimeout(()=>{this._timer=null,this._setOpen(e)},t)}_setOpen(n){let r=this._panel;r&&this.isOpen!==n&&(n?(r.setAttribute(`data-open`,``),this._reposition(),e(this,()=>this._reposition()),this._doc?.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`keydown`,this._onKeyDown),this._describe(r)):(r.removeAttribute(`data-open`),t(this),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`keydown`,this._onKeyDown),this._described?.removeAttribute(`aria-describedby`),this._described=null),this.dispatchEvent(new CustomEvent(n?`wui:hover-card:open`:`wui:hover-card:close`,{bubbles:!0})))}_reposition(){this.isOpen&&n(this._trigger,this._panel,{clampHeight:!0})}_describe(e){let t=this._anchor;t&&(e.id||=`wui-hover-card-${++l}`,t.setAttribute(`aria-describedby`,e.id),this._described=t)}};export{d as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./calendarMath-D6UUgYTD.js";import{t}from"./elementBase-Cxeyx0tU.js";import"./formatters-ljfITOZ3.js";import{t as n}from"./imeSafeEnter-DPs9qL3S.js";import{n as r,r as i,t as a}from"./inlineEditText-CsLCQbcg.js";import{l as o}from"./wuiHttp-DGbD7Fra.js";var s=e=>i.some(t=>t===e),c=`[data-wui-display]`,l=`[data-wui-value]`,u=`[data-wui-editor]`,d=`[data-wui-control]`,f=`[data-wui-error]`,p=`[data-wui-live]`,m=`[aria-expanded="true"]`,h=/* @__PURE__ */ new Set([`select`,`date`]),g=e=>{let t=(typeof e==`object`||typeof e==`function`)&&e!==null&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:r.failed.server},_=e=>e instanceof HTMLElement&&typeof(`value`in e?e.value:void 0)==`string`,v=(e,t)=>{let n=e?.querySelector(t)??null;return n instanceof HTMLElement?n:null},y=class extends t{_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.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=v(this,c),t=v(this,u),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(c)?.contains(t)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(u)?.querySelector(m))}_onKeyDown(e){if(!this._editing){(n(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`||h.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||!h.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 i=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let o=i?null:this._readShown();i||this._showValue(e),this._close();let s=await this._persist(e,i);this._busy=!1,this.removeAttribute(`aria-busy`);let c=this.getAttribute(`label`)||``;s.ok?(this.setAttribute(`value`,e),!i&&s.text&&this._showText(s.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),a),this._announce(r.saved(c)),this._fire(`wui:inline-edit:saved`,{value:e,previous:t})):(o&&this._restoreShown(o),s.kind===`session`||s.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(s.message),this._announce(r.notSaved(c,s.message)),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:s.kind,message:s.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:g(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let i=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),a=await o(n,{method:`POST`,body:i});if(a.ok)return{ok:!0,text:a.html.trim()};let s=r.failed;return{ok:!1,kind:a.kind,message:a.message||s[a.kind]||r.failed.server}}_close(){let e=v(this,c),t=v(this,u),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),v(t,m)?.click(),n&&e?.focus()}_focusControl(e){if(!h.has(this._type())){e.focus(),e.select?.();return}let t=v(e,`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(t){if(t===``){this._showText(this.getAttribute(`placeholder`)||`-`,!0);return}let n=this._type(),r=t;if(n===`date`)r=e(t)||t;else if(n===`select`){let e=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(e=>e.getAttribute(`data-value`)===t);e&&(r=(e.textContent??``).trim())}this._showText(r,!1)}_readShown(){let e=this.querySelector(l);return e?{html:e.innerHTML,empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(l);t&&(t.innerHTML=e.html,t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(l);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=v(this,f),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(p);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){let e=this.querySelector(d);return _(e)?e:null}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return s(e)?e:`text`}};export{y as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{f as t}from"./formatters-ljfITOZ3.js";import{t as n}from"./iconGlyphs.g-DPqoOoXy.js";var r=`a.wui-lightbox-item`,i=1,a=4,o=.5,s=2,c=50,l=6,u=300,d=300;function f(e){return Number.isFinite(e)?Math.min(a,Math.max(i,e)):i}function p(e,t,n,r){let i=(e,n)=>Math.max(0,(e*t-n)/2),a=i(r.width,n.width),o=i(r.height,n.height);return{x:Math.min(a,Math.max(-a,e.x)),y:Math.min(o,Math.max(-o,e.y))}}function m(e,t){return Math.abs(e)<c||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function h(e){let t=(String(e??``).split(/[?#]/)[0]??``).split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}function g(e,t,n={}){let r=document.createElement(e);r.className=t;for(let[e,t]of Object.entries(n))r.setAttribute(e,t);return r}function _(e,t,r){let i=g(`button`,`u-action wui-lightbox-btn ${r}`,{type:`button`,"aria-label":t,title:t});return i.style.setProperty(`--wui-action-size`,`40px`),i.innerHTML=n(e,{size:20}),i}var v=class extends e{_ui;_index;_zoom;_pan;_pointers;_gesture;_lastTap;_returnTo;_lockedOverflow;_onClick;static get observedAttributes(){return[`open-index`]}constructor(){super(),this._ui=null,this._index=0,this._zoom=i,this._pan={x:0,y:0},this._pointers=/* @__PURE__ */ new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._lockedOverflow=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target,n=t instanceof Element?t.closest(r):null;if(!(n instanceof HTMLAnchorElement)||!this.contains(n))return;let i=this._links().indexOf(n);i<0||(e.preventDefault(),this.open(i))}}get _view(){if(!this._ui)throw Error(`<wui-lightbox> viewer is not open.`);return this._ui}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||`Image viewer`}set label(e){this.setAttribute(`label`,String(e??``))}get layout(){return this.getAttribute(`layout`)===`single`?`single`:`gallery`}set layout(e){if(e===`single`)this.setAttribute(`layout`,`single`);else if(e===`gallery`||e===``)this.removeAttribute(`layout`);else throw Error(`<wui-lightbox> layout must be "gallery" or "single", received "${e}".`)}get isOpen(){return this._ui!==null}connectedCallback(){this.addEventListener(`click`,this._onClick),this._syncOpenIndex()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this._teardown()}attributeChangedCallback(){this.isConnected&&this._syncOpenIndex()}_syncOpenIndex(){let e=this.getAttribute(`open-index`);e===null?this.close():this.open(Number(e))}_links(){return[...this.querySelectorAll(r)].filter(e=>e instanceof HTMLAnchorElement)}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||h(t)}})}open(e=0){let t=this._items();if(!t.length)return!1;if(!this._ui){let t=document.activeElement;this._returnTo=t instanceof HTMLElement||t instanceof SVGElement?t:null,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))}return this._show(e,t),this._view.close.focus(),!0}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null,this._lockedOverflow!==null&&(document.documentElement.style.overflow=this._lockedOverflow,this._lockedOverflow=null))}_build(){let e=g(`div`,`wui-lightbox-overlay`,{role:`dialog`,"aria-modal":`true`,"aria-label":this.label,tabindex:`-1`}),t=g(`div`,`wui-lightbox-bar`),r=g(`span`,`wui-lightbox-count`,{"aria-live":`polite`}),i=g(`div`,`wui-lightbox-tools`),a=_(`zoom-out`,`Zoom out`,`wui-lightbox-zoom-out`),s=_(`zoom-in`,`Zoom in`,`wui-lightbox-zoom-in`),c=g(`a`,`u-action wui-lightbox-btn wui-lightbox-download`,{"aria-label":`Download`,title:`Download`});c.style.setProperty(`--wui-action-size`,`40px`),c.innerHTML=n(`download`,{size:20}),c.hidden=!this.download;let l=_(`x`,`Close`,`wui-lightbox-close`);i.append(a,s,c,l),t.append(r,i);let u=g(`div`,`wui-lightbox-stage`),d=_(`chevron-left`,`Previous image`,`wui-lightbox-nav wui-lightbox-prev`),f=_(`chevron-right`,`Next image`,`wui-lightbox-nav wui-lightbox-next`),p=g(`img`,`wui-lightbox-image`,{decoding:`async`,draggable:`false`,alt:``}),m=g(`p`,`wui-lightbox-status`,{role:`status`});u.append(p,m,d,f);let h=g(`p`,`wui-lightbox-caption`);e.append(t,u,h);let v={root:e,count:r,zoomOut:a,zoomIn:s,download:c,close:l,stage:u,prev:d,next:f,image:p,status:m,caption:h};this._ui=v,l.addEventListener(`click`,()=>this.close()),d.addEventListener(`click`,()=>this.step(-1)),f.addEventListener(`click`,()=>this.step(1)),a.addEventListener(`click`,()=>this._setZoom(this._zoom-o)),s.addEventListener(`click`,()=>this._setZoom(this._zoom+o)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),u.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),u.addEventListener(`pointermove`,e=>this._onPointerMove(e)),u.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),u.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),u.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),p.addEventListener(`load`,()=>{this._ui===v&&(m.textContent=``,u.removeAttribute(`aria-busy`),p.hidden=!1,this._applyTransform())}),p.addEventListener(`error`,()=>{this._ui===v&&(u.removeAttribute(`aria-busy`),p.hidden=!0,m.textContent=`This image can't be shown.`)}),this.append(e),this._lockedOverflow=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`}step(e){if(!this._ui||!e)return;let t=this._items();t.length<2||this._show((this._index+e+t.length)%t.length,t)}_show(e,n){let r=this._view,a=Math.min(n.length-1,Math.max(0,Math.trunc(Number(e))||0)),o=n[a];if(!o)throw Error(`<wui-lightbox> image missing.`);let s=a!==this._index||!r.image.getAttribute(`src`);if(this._index=a,this._zoom=i,this._pan={x:0,y:0},r.count.textContent=`${t(a+1,{decimals:0})} of ${t(n.length,{decimals:0})}`,r.caption.textContent=o.caption,r.caption.hidden=!o.caption,r.download.href=o.src,r.download.setAttribute(`download`,o.name),r.prev.hidden=r.next.hidden=n.length<2,r.stage.setAttribute(`aria-busy`,`true`),r.status.textContent=``,r.image.hidden=!1,r.image.alt=o.alt||o.caption,r.image.src=o.src,this._applyTransform(),this._syncZoomButtons(),n.length>1){let e=n[(a+1)%n.length],t=n[(a-1+n.length)%n.length];if(!e||!t)throw Error(`<wui-lightbox> neighbour image missing.`);for(let n of[e,t])new Image().src=n.src}s&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:a}}))}_syncZoomButtons(){let e=this._view;e.zoomOut.disabled=this._zoom<=i,e.zoomIn.disabled=this._zoom>=a;let t=document.activeElement;(t===e.zoomOut||t===e.zoomIn)&&t instanceof HTMLButtonElement&&t.disabled&&e.close.focus()}_setZoom(e){this._ui&&(this._zoom=f(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._view;return p(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._view;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>i)}_onKeyDown(e){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this.close();else if(e.key===`Tab`)this._trapTab(e);else if(e.key===`ArrowLeft`||e.key===`ArrowRight`)e.preventDefault(),this.step(e.key===`ArrowRight`?1:-1);else if(e.key===`Home`||e.key===`End`){e.preventDefault();let t=this._items();this._show(e.key===`Home`?0:t.length-1,t)}else e.key===`+`||e.key===`=`?(e.preventDefault(),this._setZoom(this._zoom+o)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-o)):e.key===`0`&&(e.preventDefault(),this._setZoom(i))}_trapTab(e){let t=this._view.root,n=[...t.querySelectorAll(`button, a[href]`)].filter(e=>e instanceof HTMLElement&&!e.hidden&&!(e instanceof HTMLButtonElement&&e.disabled));if(!n.length){e.preventDefault();return}let r=n[0],i=n[n.length-1];if(!r||!i)throw Error(`<wui-lightbox> focus stops missing.`);let a=document.activeElement;e.shiftKey&&(a===r||!t.contains(a))?(e.preventDefault(),i.focus()):e.shiftKey||a!==i&&t.contains(a)||(e.preventDefault(),r.focus())}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){let t=e.target;if(t instanceof Element&&t.closest(`.wui-lightbox-nav`))return;let n=this._view;if(n.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let e=[...this._pointers.values()],t=e[0],n=e[1];if(!t||!n)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._gesture={kind:`pinch`,distance:Math.hypot(t.x-n.x,t.y-n.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===n.image,moved:!1})}_onPointerMove(e){let t=this._gesture;if(t&&this._pointers.has(e.pointerId)){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let e=[...this._pointers.values()],n=e[0],r=e[1];if(!n||!r)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._setZoom(t.zoom*Math.hypot(n.x-r.x,n.y-r.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>l&&(t.moved=!0),this._zoom>i&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._view.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,a=e.clientY-n.startY;n.moved?this._zoom===i&&this.step(m(r,a)):e.timeStamp-n.startTime>u||(n.onImage?e.timeStamp-this._lastTap<d?(this._lastTap=-1/0,this._setZoom(this._zoom>i?i:s)):this._lastTap=e.timeStamp:this.close())}};export{v as t};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";var t=/\[([^[\]\n]+)\](?!\()/g,n=/* @__PURE__ */ new Set(`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`),r=/\[([^\]\n]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,i=/!\[([^\]\n]*)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,a=new RegExp(t.source,`y`),o=e=>/[\p{L}\p{N}]/u.test(e);function s(e,t){let n=0;for(let r=t-1;r>=0&&e.charAt(r)===`\\`;--r)n+=1;return n%2==1}function c(e,t,n){let r=n.length===1;for(let i=e.indexOf(n,t);i!==-1;i=e.indexOf(n,i+1)){let a=i>t&&!/\s/.test(e.charAt(t))&&!/\s/.test(e.charAt(i-1)),c=r&&(e.charAt(i+1)===n||e.charAt(i-1)===n),l=n===`_`&&o(e.charAt(i+n.length));if(a&&!c&&!l&&!s(e,i))return i}return-1}function l(e,t){let s=t?.isCitation,u=[],d=``,f=()=>{d&&=(u.push({type:`text`,text:d}),``)},p=0;for(;p<e.length;){let m=e.charAt(p),h=e.charAt(p+1);if(m===`\\`&&n.has(h)){d+=h,p+=2;continue}if(m==="`"){let t=e.indexOf("`",p+1);if(t>p+1){f(),u.push({type:`code`,text:e.slice(p+1,t)}),p=t+1;continue}}let g=m+h;if(g===`**`||g===`__`||g===`~~`){let n=c(e,p+2,g);if(n!==-1&&!(g===`__`&&o(e.charAt(p-1)))){f();let r=l(e.slice(p+2,n),t);g===`~~`?u.push({type:`strike`,children:r}):u.push({type:`strong`,children:r}),p=n+2;continue}d+=g,p+=2}else{if(m===`*`||m===`_`){let n=c(e,p+1,m);if(n!==-1&&!(m===`_`&&o(e.charAt(p-1)))){f(),u.push({type:`em`,children:l(e.slice(p+1,n),t)}),p=n+1;continue}}if(m===`[`){r.lastIndex=p;let t=r.exec(e);if(t){let e=t[1],n=t[2];if(e===void 0||n===void 0)throw Error(`The link pattern always captures its label and href`);f(),u.push({type:`link`,href:n,children:l(e)}),p+=t[0].length;continue}if(s){a.lastIndex=p;let t=a.exec(e);if(t){let e=t[1];if(e===void 0)throw Error(`The citation pattern always captures its inner text`);if(s(e)){f(),u.push({type:`citation`,text:e}),p+=t[0].length;continue}}}}if(m===`!`){i.lastIndex=p;let t=i.exec(e);if(t){let e=t[1];if(e===void 0)throw Error(`The image pattern always captures its alt text`);f(),u.push({type:`image`,children:l(e)}),p+=t[0].length;continue}}d+=m,p+=1}}return f(),u.map((e,t)=>({...e,key:t}))}var u=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,d=/^https?:/i,f=/^(mailto|tel):/i,p=/^(?:\/(?![/\\])|#|\?|\.{1,2}\/)/,m=/^https:\/\/[^/?#@\\\s]+$/i,h=/^[a-z][a-z0-9+.-]*:/i;function g(e){if(typeof e!=`string`)return null;let t=e.endsWith(`/`)?e.slice(0,-1):e;return m.test(t)?t:null}function ee(e,t,n,r,i){if(n&&(t===`page`||u.test(e))){let t=n(e);if(t!=null)return{kind:`app`,target:t}}if(t===`app`)return null;let a=i==null?null:g(i),o=a===null?e:_(e,a);return o===null?null:p.test(o)?{kind:`page`,href:o}:t===`page`&&!(d.test(o)&&r&&y(o,r))?null:d.test(o)?{kind:r&&y(o,r)?`page`:`web`,href:o}:f.test(o)?{kind:`contact`,href:o}:null}function _(e,t){if(h.test(e))return e;if(e.startsWith(`//`))return`https:${e}`;if(e===``)return null;let n=e.indexOf(`#`),r=n<0?``:e.slice(n),i=n<0?e:e.slice(0,n),a=i.indexOf(`?`),o=a<0?i:i.slice(0,a),s=a<0?``:i.slice(a);return o===``?`${t}${s}${r}`:`${t}${v(o.startsWith(`/`)?o:`/${o}`)}${s}${r}`}function v(e){let t=e.split(`/`),n=[];return t.forEach((e,r)=>{let i=r===t.length-1;e===`.`?i&&n.push(``):e===`..`?(n.length>1&&n.pop(),i&&n.push(``)):n.push(e)}),n.join(`/`)}function y(e,t){if(e.slice(0,t.length).toLowerCase()!==t.toLowerCase())return!1;let n=e[t.length];return n===void 0||n===`/`||n===`?`||n===`#`}function b(e){return typeof e!=`string`||!e.startsWith(`/`)||e[1]===`/`||e[1]===`\\`?null:e}var x=/^\s*```/,S=/^\s*```\s*(\S*)/,C=/^\s{0,3}(#{1,6})\s+(.*?)(?:\s+#+)?\s*$/,w=/^\s*([-*_])(\s*\1){2,}\s*$/,T=/^(\s*)[-*+]\s+(.*)$/,E=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,D=/^\s*>\s?(.*)$/,O=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,k=[1,2,3,4,5,6],A=e=>e.includes(`|`);function j(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function M(e,t){let n=e[t];if(n===void 0)throw Error(`startsTable was called past the last source line`);let r=e[t+1];return r!==void 0&&A(n)&&r.includes(`|`)&&O.test(r)}function N(e,t){let n=e[t];if(n===void 0)throw Error(`startsBlock was called past the last source line`);return x.test(n)||D.test(n)||T.test(n)||E.test(n)||C.test(n)||w.test(n)||M(e,t)}function P(e){let t=e.replace(/\t/g,` `).length;return Math.min(Math.floor(t/2),4)}function F(e){let t=E.exec(e);if(t){let e=t[1],n=t[2],r=t[3];if(e===void 0||n===void 0||r===void 0)throw Error(`The ordered list pattern always captures its indent, number and text`);return{text:r,depth:P(e),ordered:!0,number:Number(n)}}let n=T.exec(e);if(n){let e=n[1],t=n[2];if(e===void 0||t===void 0)throw Error(`The bullet list pattern always captures its indent and text`);return{text:t,depth:P(e),ordered:!1,number:0}}return null}function I(e){let t=(e??``).replace(/\r\n?/g,`
|
|
2
|
-
`).split(`
|
|
3
|
-
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()){r+=1;continue}if(x.test(e)){let i=S.exec(e)?.[1]||null,a=[];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(x.test(e))break;a.push(e),r+=1}r+=1,n.push({type:`code`,text:a.join(`
|
|
4
|
-
`),language:i});continue}if(M(t,r)){let i=j(e),a=[];for(r+=2;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||!A(e))break;a.push(j(e)),r+=1}n.push({type:`table`,header:i,rows:a});continue}if(w.test(e)){n.push({type:`rule`}),r+=1;continue}let i=C.exec(e);if(i){let e=i[1],t=i[2];if(e===void 0||t===void 0)throw Error(`The heading pattern always captures its hashes and text`);let a=k[e.length-1];if(a===void 0)throw Error(`The heading pattern always captures one to six hashes`);n.push({type:`heading`,level:a,text:t}),r+=1;continue}if(D.test(e)){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);let i=D.exec(n);if(!i)break;let a=i[1];if(a===void 0)throw Error(`The quote pattern always captures its text`);e.push(a),r+=1}n.push({type:`quote`,lines:e});continue}let a=F(e);if(a){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);if(!n.trim())break;let i=F(n);if(i){if(i.depth===0&&i.ordered!==a.ordered)break;e.push(i)}else if(N(t,r))break;else{let t=e[e.length-1];if(t===void 0)throw Error(`A list continuation line follows a list with no item`);t.text+=` ${n.trim()}`}r+=1}n.push({type:`list`,ordered:a.ordered,start:a.ordered?a.number:1,items:e});continue}let o=[e];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||N(t,r))break;o.push(e),r+=1}n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var L=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`],R=[`app`,`web`,`page`],z=e=>e!==void 0&&R.includes(e);function B(e,t,n,r,i=null){let a=V(e.ownerDocument,n,r).map((e,n)=>{let r=t[n],i=r?.sig===e.sig?r.nodes:null;return{sig:e.sig,nodes:i??e.build()}}),o=new Set(a.flatMap(e=>e.nodes));for(let e of t)for(let t of e.nodes)o.has(t)||t.parentNode?.removeChild(t);let s=i;for(let t of a.flatMap(e=>e.nodes))(t.parentNode!==e||t.previousSibling!==s)&&e.insertBefore(t,s?s.nextSibling:e.firstChild),s=t;return a}function V(e,t,n){let r={doc:e,links:z(n.links)?n.links:`web`,headings:n.headings===`text`?`text`:`outline`,resolveLink:n.resolveLink,isCitation:n.isCitation,figureText:typeof n.figureText==`function`?n.figureText:void 0,base:typeof n.base==`string`?n.base:void 0},i=n.resolverGeneration??0;return I(t).map(e=>({sig:`${JSON.stringify(e)}|${r.links}|${r.headings}|${r.base??``}|${i}`,build:()=>W(r,e)}))}var H=class extends e{_drawn;_blocks;_observer;_connected;_resolveLink;_isCitation;_resolverGeneration;_figureText;static get observedAttributes(){return[`links`,`headings`,`base`]}constructor(){super(),this._drawn=[],this._blocks=[],this._observer=null,this._connected=!1,this._resolveLink=void 0,this._isCitation=void 0,this._resolverGeneration=0,this._figureText=void 0}connectedCallback(){this._connected=!0,this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._drawn.some(t=>t.contains(e.target)))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._connected=!1,this._observer?.disconnect(),this._observer=null}get resolveLink(){return this._resolveLink}set resolveLink(e){this._resolveLink=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get base(){return this.getAttribute(`base`)??void 0}set base(e){e==null?this.removeAttribute(`base`):this.setAttribute(`base`,String(e))}get isCitation(){return this._isCitation}set isCitation(e){this._isCitation=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get figureText(){return this._figureText}set figureText(e){this._figureText=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}attributeChangedCallback(e,t,n){t!==n&&this._connected&&this._render()}_source(){return Array.from(this.children).find(e=>e instanceof HTMLPreElement&&e.classList.contains(`wui-markdown-source`))}_render(){let e=this._source();e&&(this._blocks=B(this,this._blocks,e.textContent??``,{links:this.getAttribute(`links`)??void 0,headings:this.getAttribute(`headings`)??void 0,base:this.getAttribute(`base`)??void 0,resolveLink:this._resolveLink,isCitation:this._isCitation,figureText:this._figureText,resolverGeneration:this._resolverGeneration},e),this._drawn=this._blocks.flatMap(e=>e.nodes),e.hidden=!0,this._observer?.takeRecords())}};function U(e,t,n=[]){let r=e.createElement(t);return r.append(...n),r}function W(e,t){switch(t.type){case`paragraph`:return[U(e.doc,`p`,G(e,t.lines))];case`heading`:return[K(e,t)];case`list`:return q(e,t.items);case`table`:return[Y(e,t)];case`code`:return[X(e.doc,t)];case`quote`:return[U(e.doc,`blockquote`,G(e,t.lines))];case`rule`:return[e.doc.createElement(`hr`)];default:return[]}}function G(e,t){let n=[];return t.forEach((t,r)=>{r>0&&n.push(e.doc.createElement(`br`)),n.push(...Z(e,t))}),n}function K(e,t){let n=Z(e,t.text);if(e.headings===`text`){let t=U(e.doc,`p`,n);return t.className=`fw-semibold`,t}return U(e.doc,`h2`,n)}function q(e,t){let n=[];for(let r=0;r<t.length;){let i=J(e,t,r);n.push(i.list),r=i.next}return n}function J(e,t,n){let r=t[n];if(!r)throw Error(`List run starts past its items.`);let{depth:i,ordered:a,number:o}=r,s=e.doc.createElement(a?`ol`:`ul`);a&&o!==1&&s.setAttribute(`start`,String(o));let c=null,l=n,u=t[l];for(;u&&u.depth>=i;){if(u.depth===i)c=U(e.doc,`li`,Z(e,u.text)),s.append(c),l+=1;else{let n=J(e,t,l);if(!c)throw Error(`Nested list has no item before it.`);c.append(n.list),l=n.next}u=t[l]}return{list:s,next:l}}function Y(e,t){let n=t.header.map(t=>{let n=U(e.doc,`th`,Z(e,t));return n.setAttribute(`scope`,`col`),n}),r=t.rows.map(n=>U(e.doc,`tr`,t.header.map((t,r)=>U(e.doc,`td`,Z(e,n[r]??``))))),i=U(e.doc,`table`,[U(e.doc,`thead`,[U(e.doc,`tr`,n)]),U(e.doc,`tbody`,r)]);i.className=`table`;let a=U(e.doc,`div`,[i]);return a.className=`table-responsive`,a}function X(e,t){let n=U(e,`pre`,[U(e,`code`,[e.createTextNode(t.text)])]);n.className=`wui-code-source`;let r=U(e,`wui-code-block`,[n]);return r.className=`wui-code-block`,r.setAttribute(`language`,t.language!==null&&L.includes(t.language)?t.language:`text`),r}function Z(e,t){return Q(e,l(t,{isCitation:e.isCitation}))}function Q(e,t){return t.flatMap(t=>te(e,t))}function te(e,t){let{doc:n}=e;switch(t.type){case`code`:return[U(n,`code`,[n.createTextNode(t.text)])];case`strong`:return[U(n,`strong`,Q(e,t.children))];case`em`:return[U(n,`em`,Q(e,t.children))];case`strike`:return[U(n,`del`,Q(e,t.children))];case`image`:return[n.createTextNode(`[`),...Q(e,t.children),n.createTextNode(`]`)];case`link`:return ne(e,t);case`citation`:return[ie(n,t.text)];case`text`:return e.figureText?re(e,e.figureText,t.text):[n.createTextNode(t.text)];default:throw Error(`wui-markdown: unknown inline token ${JSON.stringify(t)}`)}}function ne(e,t){let n=Q(e,t.children),r=ee(t.href,e.links,e.resolveLink,globalThis.location?.origin,e.base);if(!r)return n;if(r.kind===`app`){let t=b(r.target);return t?[$(e.doc,t,n,!1)]:n}return[$(e.doc,r.href,n,r.kind===`web`)]}function re(e,t,n){return t(n).map(t=>t.kind===`sub`||t.kind===`sup`?U(e.doc,t.kind,[e.doc.createTextNode(t.text)]):e.doc.createTextNode(t.text))}function ie(e,t){let n=e.createElement(`span`);n.className=`chip primary chip-outline chip-sm chip-clickable wui-markdown-citation`,n.setAttribute(`data-wui`,`AppChip`);let r=e.createElement(`button`);r.type=`button`,r.className=`chip-body`,r.setAttribute(`aria-label`,t),r.addEventListener(`click`,()=>{r.dispatchEvent(new CustomEvent(`wui-markdown-citation`,{bubbles:!0,detail:{citation:t}}))});let i=e.createElement(`span`);return i.className=`chip-label`,i.textContent=t,r.append(i),n.append(r),n}function $(e,t,n,r){let i=U(e,`span`,n);i.className=`wui-link__label`;let a=U(e,`a`,[i]);return a.className=`wui-link wui-link--static`,a.setAttribute(`data-wui`,`AppLink`),a.setAttribute(`href`,t),r&&(a.setAttribute(`target`,`_blank`),a.setAttribute(`rel`,`noopener noreferrer`)),a}export{H as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./anchorOverlay-CXnWfezA.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{n as i,r as a,t as o}from"./fieldState-D-zQcXUS.js";import{f as s}from"./formatters-ljfITOZ3.js";import{t as c}from"./imeSafeEnter-DPs9qL3S.js";import{n as l}from"./listboxKeyNav-DkLHwzJE.js";import{i as u,n as d,r as f,t as p}from"./mentionText-BJsw_opZ.js";import{l as m}from"./wuiHttp-DGbD7Fra.js";var h=8,g=40,_=Object.freeze({listName:`People`,searching:`Searching…`,noMatch:`No one matches`,searchFailed:`Couldn't load people. Keep typing to try again.`,found:e=>`${e===1?`1 person`:`${s(e,{decimals:0})} people`}. Up and down to choose, Enter to mention.`,mentioned:e=>`Mentioned ${e}.`}),v=`[data-wui-control]`,y=`[data-wui-field]`,b=`[data-wui-menu]`,x=`[data-wui-live]`,S=0,C=e=>!!(e&&p.test(String(e.value??``))&&d(e.label)!==``);function w(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`input-sm`,n===`sm`),t.classList.toggle(`input-lg`,n===`lg`)}function T(e,t){t.readOnly=i(e)||e.hasAttribute(`loading`)}function E(e){let t=e.ownerDocument;e.id||=`wui-mention-${++S}`;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`),T(e,n),w(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`)??_.listName),o.setAttribute(`data-wui-menu`,``),o.hidden=!0,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 D=class extends r{_wired;_pendingValue;_text;_mentions;_peopleProp;_declared;_loading;_searchFailed;_query;_results;_active;_timer;_searchSeq;_lastSearch;_abort;_onMenuDown;_reposition;_reanchor;_reanchorScroll;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),this._reposition=()=>{this._isOpen()&&this._position()}}connectedCallback(){for(let e of[`people`,`loading`,`searchFailed`,`value`])if(Object.hasOwn(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(v)||E(this);let e=this._requireControl(),t=this.querySelector(y)?.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`?(T(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(T(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?w(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return u(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(C):[],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(v)}_menu(){return this.querySelector(b)}_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}=f(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(y);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||o(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,r=n.lastIndexOf(`@`,t-1);if(r<0||r>0&&!/[\s([{"'“‘]/.test(n.charAt(r-1)))return null;let i=n.slice(r+1,t);return i.length>40||/[\n@]/.test(i)||/^\s/.test(i)||/\s{2}/.test(i)||this._mentions.some(e=>r>=e.start&&r<e.end)?null:{start:r,end:t,text:i}}_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=>d(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 m(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=this.ownerDocument.createElement(`template`);o.innerHTML=a.html,this._peopleProp=[...o.content.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(C),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return!(!e||e.hidden)}_renderMenu(){let t=this._menu(),n=this._control();if(!t||!n||!this._query)return;this._syncState();let r=this.ownerDocument;if(t.replaceChildren(),this._results.forEach((e,n)=>{let i=r.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${t.id}-${n}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(n),e.src){let t=r.createElement(`img`);t.className=`wui-mention-option-photo`,t.src=e.src,t.alt=``,i.appendChild(t)}let a=r.createElement(`span`);a.className=`wui-mention-option-text`;let o=r.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=d(e.label),a.appendChild(o),e.description){let t=r.createElement(`span`);t.className=`wui-mention-option-description`,t.textContent=String(e.description),a.appendChild(t)}i.appendChild(a),t.appendChild(i)}),!this._results.length){let e=r.createElement(`div`);e.className=`wui-mention-empty`,e.textContent=this.loading?_.searching:this._searchFailed?_.searchFailed:`${_.noMatch} “${this._query.text}”`,t.appendChild(e)}let i=this._isOpen();t.hidden=!1,i||e(this,this._reposition),this._position(),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?_.found(this._results.length):this._searchFailed?_.searchFailed:`${_.noMatch}.`)}_syncState(){let e=this._control();e&&a(this,e)}_position(){n(this._control(),this._menu())}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();e&&!e.hidden&&(e.hidden=!0,e.replaceChildren()),this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`),t(this)}_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`);l(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((c(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}}c(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=d(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(_.mentioned(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(x);t&&(t.textContent=``,t.textContent=e)}};export{D as i,h as n,_ as r,g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./dom-Do1pAA12.js";import{t}from"./elementBase-Cxeyx0tU.js";var n=`data-open`,r=8,i=`.wui-nav-menu-link`,a=e=>e instanceof Element?e:e instanceof Node?e.parentElement:null,o=e=>[...e].filter(e=>e instanceof HTMLElement),s=e=>{let t=e.children[0];if(!(t instanceof HTMLElement))throw Error(`Navigation entry has no control.`);return t},c=(e,t,n)=>{let r=e[t];if(r===void 0)throw Error(n);return r},l=class extends t{constructor(){super(),this._onClick=e=>this._handleClick(e),this._onKeyDown=e=>this._handleKeyDown(e),this._onFocusOut=e=>{let t=this._openItem(),n=e.relatedTarget;t&&n instanceof Node&&!t.contains(n)&&this._set(t,!1)},this._onPointerDown=e=>{let t=this._openItem();t&&!e.composedPath().includes(t)&&this._set(t,!1)},this._onResize=()=>{let t=this._openItem();if(!t)return;let n=e(t.children[1],`Navigation entry has no panel.`);this._align(n)}}connectedCallback(){this._teardown(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),document.addEventListener(`pointerdown`,this._onPointerDown,!0)}disconnectedCallback(){this._teardown()}open(e){let t=this._items().find(t=>{let n=t.children[0];return n instanceof HTMLElement&&this._isTrigger(n)&&n.dataset.key===e});t&&this._set(t,!0)}close(e=!1){let t=this._openItem();t&&(this._set(t,!1),e&&s(t).focus({preventScroll:!0}))}_items(){return o(this.querySelectorAll(`.wui-nav-menu-item`))}_openItem(){return this._items().find(e=>e.children[1]?.hasAttribute(n))??null}_isTrigger(e){return!!e?.classList.contains(`wui-nav-menu-trigger`)}_entries(){return this._items().map(s)}_links(e){let t=e.children[1];return t?o(t.querySelectorAll(i)):[]}_set(e,t){let r=e.children[1];if(!r)return;let i=s(e);if(t){let t=this._openItem();t&&t!==e&&this._set(t,!1)}r.hasAttribute(n)!==t&&(r.toggleAttribute(n,t),i.setAttribute(`aria-expanded`,String(t)),t?(this._align(r),window.addEventListener(`resize`,this._onResize)):(r.removeAttribute(`data-align`),this._openItem()||window.removeEventListener(`resize`,this._onResize)),this.dispatchEvent(new CustomEvent(`wui-navigation-menu:toggle`,{bubbles:!0,detail:{key:i.dataset.key??null,open:t}})))}_align(e){e.removeAttribute(`data-align`),e.getBoundingClientRect().right>window.innerWidth-r&&e.setAttribute(`data-align`,`end`)}_handleClick(t){let r=a(t.target),o=r?.closest(`.wui-nav-menu-trigger`);if(o&&this.contains(o)){let t=e(o.parentElement,`Navigation trigger has no entry.`),r=e(t.children[1],`Navigation entry has no panel.`);this._set(t,!r.hasAttribute(n));return}let s=r?.closest(i);s&&this.contains(s)&&this.close()}_handleKeyDown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=a(t.target)?.closest(`.wui-nav-menu-trigger, .wui-nav-menu-toplink, .wui-nav-menu-link`);if(!(n instanceof HTMLElement)||!this.contains(n))return;let r=this._openItem();if(t.key===`Escape`){if(!r)return;t.preventDefault(),t.stopPropagation();let e=r.contains(n);this._set(r,!1),e&&s(r).focus({preventScroll:!0});return}if(n.matches(i)){this._linkKey(t,n);return}let o=this._entries(),l=o.indexOf(n);if(t.key===`ArrowRight`||t.key===`ArrowLeft`||t.key===`Home`||t.key===`End`){t.preventDefault();let e=t.key===`Home`?0:t.key===`End`?o.length-1:(l+(t.key===`ArrowRight`?1:-1)+o.length)%o.length;r&&this._set(r,!1),c(o,e,`Navigation has no entry to focus.`).focus({preventScroll:!0})}else if(t.key===`ArrowDown`&&this._isTrigger(n)){t.preventDefault();let r=e(n.parentElement,`Navigation trigger has no entry.`);this._set(r,!0),c(this._links(r),0,`Navigation panel has no link to focus.`).focus({preventScroll:!0})}}_linkKey(t,n){let r=e(n.closest(`.wui-nav-menu-item`),`Navigation link has no entry.`),i=this._links(r),a=i.indexOf(n);t.key===`ArrowDown`||t.key===`ArrowUp`?(t.preventDefault(),c(i,(a+(t.key===`ArrowDown`?1:-1)+i.length)%i.length,`Navigation panel has no link to focus.`).focus({preventScroll:!0})):t.key===`Home`?(t.preventDefault(),c(i,0,`Navigation panel has no link to focus.`).focus({preventScroll:!0})):t.key===`End`&&(t.preventDefault(),c(i,i.length-1,`Navigation panel has no link to focus.`).focus({preventScroll:!0}))}_teardown(){let e=this._openItem();e&&this._set(e,!1),window.removeEventListener(`resize`,this._onResize),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),document.removeEventListener(`pointerdown`,this._onPointerDown,!0)}};export{l as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{c as t,i as n,n as r,s as i}from"./notificationDays-BIWczft0.js";import{l as a}from"./wuiHttp-DGbD7Fra.js";var o=`.wui-notification-center-trigger`,s=`.wui-notification-center-panel`,c=`.wui-notification-center-count`,l=`.wui-notification-center-live`,u=`.wui-notification-center-markall`,d=`.wui-notification-center-item`,f=`wui-notification-center-item-read`,p=`.wui-notification-center-unread-label`,m=`.app-tabs`,h=`.wui-notification-center-tabs [role='tablist']`,g=`.wui-notification-center-tabs [role='tab']`,_=`.wui-notification-center-empty`,v={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`},y=e=>!!e,b=e=>Object.hasOwn(r.failed,e),x=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},S=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),C=class extends e{constructor(){super(),this._doc=null,this._unread=0,this._busy=!1,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onOutside=e=>{e.composedPath().includes(this)||this.close()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}connectedCallback(){this._doc=this.ownerDocument,this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`mousedown`,this._onOutside),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen(),this.isOpen&&this._layoutTabs()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`mousedown`,this._onOutside),this.removeEventListener(`focusout`,this._onFocusOut),this._doc=null}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(this.setAttribute(`open`,``),this._syncOpen(),this._layoutTabs(),x(this,s)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&x(this,o)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(o)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${d}:not(.${f}):not([data-archived="true"])`).length}_click(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(g);if(n instanceof HTMLElement&&this.contains(n)){if(this.hasAttribute(`controlled`))return;this._pickTab(n);return}let r=t.closest(`${o}, ${u}, ${d}`);r instanceof HTMLElement&&this.contains(r)&&(r.matches(o)?this.toggle():this.hasAttribute(`controlled`)||(r.matches(u)?this._markAll():this._markItem(r)))}_key(e){if(e.key===`Escape`&&this.isOpen){e.preventDefault(),e.stopPropagation(),this.close({restoreFocus:!0});return}if(!this.isOpen)return;let t=e.target;if(!(t instanceof Element))throw Error(`Keyboard event target is not an element.`);if(!this.querySelector(s)?.contains(t)||t.closest(m))return;let n=v[e.key];if(n===void 0)return;let r=S(this,d).filter(e=>!e.closest(`[hidden]`));if(r.length===0)return;let i=t.closest(d),a=i instanceof HTMLElement?r.indexOf(i):-1,o;o=n===`first`?0:n===`last`?r.length-1:a===-1?n===1?0:r.length-1:Math.min(r.length-1,Math.max(0,a+n)),e.preventDefault(),r[o]?.focus()}_markItem(e){e.classList.contains(f)||(this._applyRead(e),e.dataset.archived!==`true`&&(this._unread=Math.max(0,this._unread-1)),this._render(),this._say(t(this._unread)),this._emitRead([e.dataset.id].filter(y),!1))}async _markAll(){if(this._busy)return;let e=S(this,`${d}:not(.${f})`);if(e.length===0&&this._unread===0)return;let t=e.map(e=>e.dataset.id).filter(y),n=this.getAttribute(`read-action`);if(n){this._setBusy(!0);let e=new URLSearchParams;for(let n of t)e.append(`ids`,n);let i=await a(n,{method:`POST`,body:e});if(this._setBusy(!1),!i.ok){if(i.kind===`session`||i.kind===`aborted`)return;let e=i.kind,t=i.message||(b(e)?r.failed[e]:r.failed.server);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(r.allRead),this._emitRead(t,!0)}_pickTab(e){let t=e.closest(h);if(t instanceof HTMLElement){for(let n of S(t,g)){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 S(this,h)){let t=x(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 S(this,d)){let r=n.dataset.archived===`true`,i=n.classList.contains(f),a=e===`archived`?r:!r&&(e!==`unread`||!i);a&&(t=!0);let o=n.closest(`li`);o&&(o.hidden=!a)}for(let e of S(this,`.wui-notification-center-list section`))e.hidden=[...e.querySelectorAll(`li`)].every(e=>e.hidden);let n=x(this,_);n&&(n.hidden=t)}_applyRead(e){e.classList.add(f),e.querySelector(p)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(u);t instanceof HTMLButtonElement&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=x(this,c);e&&(e.textContent=n(this._unread),e.hidden=this._unread===0),this.querySelector(o)?.setAttribute(`aria-label`,i(this.getAttribute(`label`)||r.label,this._unread));let t=this.querySelector(u);t instanceof HTMLButtonElement&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(l);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{C as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./anchorOverlay-CXnWfezA.js";import{t as r}from"./elementBase-Cxeyx0tU.js";var i=`data-wui-overflow-hidden`,a=`[aria-selected="true"], .active`,o=`.chip-body, input, a[href], button:not(.chip-remove)`,s=1,c=0,l=e=>Number.parseFloat(e)||0,u=e=>e.nodeType===1,d=e=>{let t=e.getAttribute(`data-overflow-label`);if(t)return t;let n=[],r=e=>{for(let t of e.childNodes)if(t.nodeType===3){let e=t.textContent?.trim();e&&n.push(e)}else u(t)&&!t.matches(`svg, img, [aria-hidden='true']`)&&r(t)};return r(e),n.join(` `)},f=e=>{if(e.matches(`button, a[href], label, input`))return e;let t=e.querySelector(o);return t instanceof HTMLElement?t:null},p=class extends r{constructor(){super(),this._hiddenKey=``,this._ro=null,this._mo=null,this._observedList=null,this._doc=null,this._onDocDown=e=>{!this._menu.hidden&&!e.composedPath().includes(this)&&this._close(!1)}}connectedCallback(){this.classList.add(`wui-overflow`),this._build(),this._doc=this.ownerDocument,this._doc.addEventListener(`pointerdown`,this._onDocDown,!0),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this.layout()),this._ro.observe(this)),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(()=>this.layout()),this._watch()),this.layout()}disconnectedCallback(){this._ro?.disconnect(),this._mo?.disconnect(),this._ro=null,this._mo=null,this._observedList=null,this._doc?.removeEventListener(`pointerdown`,this._onDocDown,!0),this._doc=null,t(this)}static get observedAttributes(){return[`label`]}attributeChangedCallback(){let e=this._more?.firstChild;e&&(e.textContent=this._label())}_label(){return this.getAttribute(`label`)||`More`}_list(){let e=this.querySelector(`[data-wui-overflow-list]`);return e instanceof HTMLElement?e:null}_items(e){return[...e.children].filter(e=>!e.hasAttribute(`data-wui-overflow-skip`))}_build(){if(this._more)return;let e=`wui-overflow-menu-${++c}`,t=this.ownerDocument.createElement(`button`);t.type=`button`,t.className=`wui-overflow-more`,t.hidden=!0,t.setAttribute(`aria-haspopup`,`menu`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,e),t.append(this._label());let n=this.ownerDocument.createElement(`div`);n.className=`wui-overflow-menu`,n.id=e,n.setAttribute(`role`,`menu`),n.hidden=!0,this.append(t,n),this._more=t,this._menu=n,t.addEventListener(`click`,()=>this._menu.hidden?this._open(!1):this._close(!0)),t.addEventListener(`keydown`,e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),this._open(!0))}),n.addEventListener(`keydown`,e=>this._onMenuKey(e))}_watch(){let e=this._list();this._mo&&e!==this._observedList&&(this._mo.disconnect(),this._observedList=e,e&&this._mo.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`class`,`aria-selected`,`disabled`,`aria-disabled`,`data-overflow-label`]}))}layout(){let e=this._list();if(this._watch(),!e||!this._more)return;let t=this._items(e);for(let e of t)e.removeAttribute(i);this._more.hidden=!0;let n=this.clientWidth,r=[];if(t.length&&n<=0&&this.getClientRects().length>0)r=t;else if(n>0&&t.length){let i=getComputedStyle(e),o=l(i.columnGap),c=l(i.paddingLeft)+l(i.paddingRight)+l(i.borderLeftWidth)+l(i.borderRightWidth),u=t.map(e=>e.offsetWidth);if(u.reduce((e,t)=>e+t,0)+o*(t.length-1)>n-c+s){this._more.hidden=!1;let e=n-c-this._more.offsetWidth-l(getComputedStyle(this).columnGap),i=this.hasAttribute(`keep`)?this.getAttribute(`keep`):a,s=/* @__PURE__ */ new Set,d=0,f=0,p=i?t.filter(e=>e.matches(i)):[];for(let n of p){let r=d+(u[t.indexOf(n)]??0)+(f?o:0);r>e||(s.add(n),d=r,f+=1)}for(let n=0;n<t.length;n+=1){let r=t[n];if(!r||s.has(r))continue;let i=d+(u[n]??0)+(f?o:0);if(i>e)break;s.add(r),d=i,f+=1}r=t.filter(e=>!s.has(e))}}for(let e of r)e.setAttribute(i,``);this._more.hidden=r.length===0,r.length?this._menu.hidden||this._fill(r):this._close(!1);let o=r.map(e=>t.indexOf(e)).join(`,`);o!==this._hiddenKey&&(this._hiddenKey=o,this.dispatchEvent(new CustomEvent(`wui-overflow-change`,{bubbles:!0,detail:{hidden:r.length}})))}_hiddenItems(){let e=this._list();return e?this._items(e).filter(e=>e.hasAttribute(i)):[]}_fill(e){this._menu.replaceChildren();for(let t of e){let e=this.ownerDocument.createElement(`button`);e.type=`button`,e.className=`wui-overflow-item`,e.tabIndex=-1;let n=t.querySelector(`input[type=checkbox], input[type=radio]`);n instanceof HTMLInputElement?(e.setAttribute(`role`,n.type===`radio`?`menuitemradio`:`menuitemcheckbox`),e.setAttribute(`aria-checked`,String(n.checked))):e.setAttribute(`role`,`menuitem`);let r=f(t),i=!r||`disabled`in r&&r.disabled||r.getAttribute(`aria-disabled`)===`true`||t.matches(`.disabled, [aria-disabled='true']`);i&&e.setAttribute(`aria-disabled`,`true`),e.textContent=d(t),e.addEventListener(`click`,()=>{i||r&&this._choose(t,r)}),this._menu.append(e)}}_choose(e,t){this._close(!1),t.click(),this.layout();let n=!e.hasAttribute(i)&&e.matches(`button, a[href]`)?e:this._more;n.hidden||n.focus()}_open(t){let r=this._hiddenItems();if(!r.length)return;this._fill(r),this._menu.hidden=!1,this._more.setAttribute(`aria-expanded`,`true`);let i=()=>n(this._more,this._menu);if(i(),e(this,i),t){let e=this._menu.firstElementChild;e instanceof HTMLElement&&e.focus()}}_close(e){this._menu&&!this._menu.hidden&&(this._menu.hidden=!0,this._more.setAttribute(`aria-expanded`,`false`),t(this),e&&this._more.focus())}_onMenuKey(e){let t=[...this._menu.children].filter(e=>e instanceof HTMLElement),n=this.ownerDocument.activeElement,r=n instanceof HTMLElement?t.indexOf(n):-1,i=null;if(e.key===`ArrowDown`)i=t[(r+1)%t.length];else if(e.key===`ArrowUp`)i=t[(r-1+t.length)%t.length];else if(e.key===`Home`)i=t[0];else if(e.key===`End`)i=t[t.length-1];else if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close(!0);return}else if(e.key===`Tab`){this._close(!1);return}else return;e.preventDefault(),i?.focus()}};export{p as t};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./anchorOverlay-CXnWfezA.js";import{n as r,t as i}from"./countries-DQL9nAUt.js";import{t as a}from"./devWarn-DXdRWZs3.js";import{t as o}from"./elementBase-Cxeyx0tU.js";import{r as s,t as c}from"./fieldState-D-zQcXUS.js";import{t as l}from"./formMirror-9IpSgeZb.js";import{t as u}from"./iconGlyphs.g-DPqoOoXy.js";import{t as d}from"./imeSafeEnter-DPs9qL3S.js";import{n as f}from"./listboxKeyNav-DkLHwzJE.js";var p={AD:[`Europe/Andorra`],AE:[`Asia/Dubai`],AF:[`Asia/Kabul`],AG:[`America/Antigua`],AI:[`America/Anguilla`],AL:[`Europe/Tirane`],AM:[`Asia/Yerevan`],AO:[`Africa/Luanda`],AR:[`America/Argentina/Buenos_Aires`,`America/Argentina/Catamarca`,`America/Argentina/ComodRivadavia`,`America/Argentina/Cordoba`,`America/Argentina/Jujuy`,`America/Argentina/La_Rioja`,`America/Argentina/Mendoza`,`America/Argentina/Rio_Gallegos`,`America/Argentina/Salta`,`America/Argentina/San_Juan`,`America/Argentina/San_Luis`,`America/Argentina/Tucuman`,`America/Argentina/Ushuaia`,`America/Buenos_Aires`,`America/Catamarca`,`America/Cordoba`,`America/Jujuy`,`America/Mendoza`,`America/Rosario`],AS:[`Pacific/Pago_Pago`,`Pacific/Samoa`,`US/Samoa`],AT:[`Europe/Vienna`],AU:[`Antarctica/Macquarie`,`Australia/Adelaide`,`Australia/Brisbane`,`Australia/Broken_Hill`,`Australia/Canberra`,`Australia/Currie`,`Australia/Darwin`,`Australia/Eucla`,`Australia/Hobart`,`Australia/LHI`,`Australia/Lindeman`,`Australia/Lord_Howe`,`Australia/Melbourne`,`Australia/NSW`,`Australia/North`,`Australia/Perth`,`Australia/Queensland`,`Australia/South`,`Australia/Sydney`,`Australia/Tasmania`,`Australia/Victoria`,`Australia/West`,`Australia/Yancowinna`],AW:[`America/Aruba`],AX:[`Europe/Mariehamn`],AZ:[`Asia/Baku`],BA:[`Europe/Sarajevo`],BB:[`America/Barbados`],BD:[`Asia/Dacca`,`Asia/Dhaka`],BE:[`Europe/Brussels`],BF:[`Africa/Ouagadougou`],BG:[`Europe/Sofia`],BH:[`Asia/Bahrain`],BI:[`Africa/Bujumbura`],BJ:[`Africa/Porto-Novo`],BL:[`America/St_Barthelemy`],BM:[`Atlantic/Bermuda`],BN:[`Asia/Brunei`],BO:[`America/La_Paz`],BQ:[`America/Kralendijk`],BR:[`America/Araguaina`,`America/Bahia`,`America/Belem`,`America/Boa_Vista`,`America/Campo_Grande`,`America/Cuiaba`,`America/Eirunepe`,`America/Fortaleza`,`America/Maceio`,`America/Manaus`,`America/Noronha`,`America/Porto_Acre`,`America/Porto_Velho`,`America/Recife`,`America/Rio_Branco`,`America/Santarem`,`America/Sao_Paulo`,`Brazil/DeNoronha`,`Brazil/East`,`Brazil/West`],BS:[`America/Nassau`],BT:[`Asia/Thimbu`,`Asia/Thimphu`],BW:[`Africa/Gaborone`],BY:[`Europe/Minsk`],BZ:[`America/Belize`],CA:/* @__PURE__ */ `America/Atikokan.America/Blanc-Sablon.America/Cambridge_Bay.America/Coral_Harbour.America/Creston.America/Dawson.America/Dawson_Creek.America/Edmonton.America/Fort_Nelson.America/Glace_Bay.America/Goose_Bay.America/Halifax.America/Inuvik.America/Iqaluit.America/Moncton.America/Montreal.America/Nipigon.America/Pangnirtung.America/Rainy_River.America/Rankin_Inlet.America/Regina.America/Resolute.America/St_Johns.America/Swift_Current.America/Thunder_Bay.America/Toronto.America/Vancouver.America/Whitehorse.America/Winnipeg.America/Yellowknife.Canada/Atlantic.Canada/Central.Canada/Eastern.Canada/Mountain.Canada/Newfoundland.Canada/Pacific.Canada/Saskatchewan.Canada/Yukon`.split(`.`),CC:[`Indian/Cocos`],CD:[`Africa/Kinshasa`,`Africa/Lubumbashi`],CF:[`Africa/Bangui`],CG:[`Africa/Brazzaville`],CH:[`Europe/Zurich`],CI:[`Africa/Abidjan`],CK:[`Pacific/Rarotonga`],CL:[`America/Coyhaique`,`America/Punta_Arenas`,`America/Santiago`,`Chile/Continental`,`Chile/EasterIsland`,`Pacific/Easter`],CM:[`Africa/Douala`],CN:[`Asia/Chongqing`,`Asia/Harbin`,`Asia/Kashgar`,`Asia/Shanghai`,`Asia/Urumqi`],CO:[`America/Bogota`],CR:[`America/Costa_Rica`],CU:[`America/Havana`],CV:[`Atlantic/Cape_Verde`],CW:[`America/Curacao`],CX:[`Indian/Christmas`],CY:[`Asia/Famagusta`,`Asia/Nicosia`,`Europe/Nicosia`],CZ:[`Europe/Prague`],DE:[`Europe/Berlin`,`Europe/Busingen`],DJ:[`Africa/Djibouti`],DK:[`Europe/Copenhagen`],DM:[`America/Dominica`],DO:[`America/Santo_Domingo`],DZ:[`Africa/Algiers`],EC:[`America/Guayaquil`,`Pacific/Galapagos`],EE:[`Europe/Tallinn`],EG:[`Africa/Cairo`],EH:[`Africa/El_Aaiun`],ER:[`Africa/Asmara`,`Africa/Asmera`],ES:[`Africa/Ceuta`,`Atlantic/Canary`,`Europe/Madrid`],ET:[`Africa/Addis_Ababa`],FI:[`Europe/Helsinki`],FJ:[`Pacific/Fiji`],FK:[`Atlantic/Stanley`],FM:[`Pacific/Chuuk`,`Pacific/Kosrae`,`Pacific/Pohnpei`,`Pacific/Ponape`,`Pacific/Truk`,`Pacific/Yap`],FO:[`Atlantic/Faeroe`,`Atlantic/Faroe`],FR:[`Europe/Paris`],GA:[`Africa/Libreville`],GB:[`Europe/Belfast`,`Europe/London`],GD:[`America/Grenada`],GE:[`Asia/Tbilisi`],GF:[`America/Cayenne`],GG:[`Europe/Guernsey`],GH:[`Africa/Accra`],GI:[`Europe/Gibraltar`],GL:[`America/Danmarkshavn`,`America/Godthab`,`America/Nuuk`,`America/Scoresbysund`,`America/Thule`],GM:[`Africa/Banjul`],GN:[`Africa/Conakry`],GP:[`America/Guadeloupe`],GQ:[`Africa/Malabo`],GR:[`Europe/Athens`],GT:[`America/Guatemala`],GU:[`Pacific/Guam`],GW:[`Africa/Bissau`],GY:[`America/Guyana`],HK:[`Asia/Hong_Kong`],HN:[`America/Tegucigalpa`],HR:[`Europe/Zagreb`],HT:[`America/Port-au-Prince`],HU:[`Europe/Budapest`],ID:[`Asia/Jakarta`,`Asia/Jayapura`,`Asia/Makassar`,`Asia/Pontianak`,`Asia/Ujung_Pandang`],IE:[`Europe/Dublin`],IL:[`Asia/Jerusalem`,`Asia/Tel_Aviv`],IM:[`Europe/Isle_of_Man`],IN:[`Asia/Calcutta`,`Asia/Kolkata`],IO:[`Indian/Chagos`],IQ:[`Asia/Baghdad`],IR:[`Asia/Tehran`],IS:[`Atlantic/Reykjavik`],IT:[`Europe/Rome`],JE:[`Europe/Jersey`],JM:[`America/Jamaica`],JO:[`Asia/Amman`],JP:[`Asia/Tokyo`],KE:[`Africa/Nairobi`],KG:[`Asia/Bishkek`],KH:[`Asia/Phnom_Penh`],KI:[`Pacific/Enderbury`,`Pacific/Kanton`,`Pacific/Kiritimati`,`Pacific/Tarawa`],KM:[`Indian/Comoro`],KN:[`America/St_Kitts`],KP:[`Asia/Pyongyang`],KR:[`Asia/Seoul`],KW:[`Asia/Kuwait`],KY:[`America/Cayman`],KZ:[`Asia/Almaty`,`Asia/Aqtau`,`Asia/Aqtobe`,`Asia/Atyrau`,`Asia/Oral`,`Asia/Qostanay`,`Asia/Qyzylorda`],LA:[`Asia/Vientiane`],LB:[`Asia/Beirut`],LC:[`America/St_Lucia`],LI:[`Europe/Vaduz`],LK:[`Asia/Colombo`],LR:[`Africa/Monrovia`],LS:[`Africa/Maseru`],LT:[`Europe/Vilnius`],LU:[`Europe/Luxembourg`],LV:[`Europe/Riga`],LY:[`Africa/Tripoli`],MA:[`Africa/Casablanca`],MC:[`Europe/Monaco`],MD:[`Europe/Chisinau`,`Europe/Tiraspol`],ME:[`Europe/Podgorica`],MF:[`America/Marigot`],MG:[`Indian/Antananarivo`],MH:[`Pacific/Kwajalein`,`Pacific/Majuro`],MK:[`Europe/Skopje`],ML:[`Africa/Bamako`,`Africa/Timbuktu`],MM:[`Asia/Rangoon`,`Asia/Yangon`],MN:[`Asia/Choibalsan`,`Asia/Hovd`,`Asia/Ulaanbaatar`,`Asia/Ulan_Bator`],MO:[`Asia/Macao`,`Asia/Macau`],MP:[`Pacific/Saipan`],MQ:[`America/Martinique`],MR:[`Africa/Nouakchott`],MS:[`America/Montserrat`],MT:[`Europe/Malta`],MU:[`Indian/Mauritius`],MV:[`Indian/Maldives`],MW:[`Africa/Blantyre`],MX:[`America/Bahia_Banderas`,`America/Cancun`,`America/Chihuahua`,`America/Ciudad_Juarez`,`America/Ensenada`,`America/Hermosillo`,`America/Matamoros`,`America/Mazatlan`,`America/Merida`,`America/Mexico_City`,`America/Monterrey`,`America/Ojinaga`,`America/Santa_Isabel`,`America/Tijuana`,`Mexico/BajaNorte`,`Mexico/BajaSur`,`Mexico/General`],MY:[`Asia/Kuala_Lumpur`,`Asia/Kuching`],MZ:[`Africa/Maputo`],NA:[`Africa/Windhoek`],NC:[`Pacific/Noumea`],NE:[`Africa/Niamey`],NF:[`Pacific/Norfolk`],NG:[`Africa/Lagos`],NI:[`America/Managua`],NL:[`Europe/Amsterdam`],NO:[`Europe/Oslo`],NP:[`Asia/Kathmandu`,`Asia/Katmandu`],NR:[`Pacific/Nauru`],NU:[`Pacific/Niue`],NZ:[`Pacific/Auckland`,`Pacific/Chatham`],OM:[`Asia/Muscat`],PA:[`America/Panama`],PE:[`America/Lima`],PF:[`Pacific/Gambier`,`Pacific/Marquesas`,`Pacific/Tahiti`],PG:[`Pacific/Bougainville`,`Pacific/Port_Moresby`],PH:[`Asia/Manila`],PK:[`Asia/Karachi`],PL:[`Europe/Warsaw`],PM:[`America/Miquelon`],PR:[`America/Puerto_Rico`],PS:[`Asia/Gaza`,`Asia/Hebron`],PT:[`Atlantic/Azores`,`Atlantic/Madeira`,`Europe/Lisbon`],PW:[`Pacific/Palau`],PY:[`America/Asuncion`],QA:[`Asia/Qatar`],RE:[`Indian/Reunion`],RO:[`Europe/Bucharest`],RS:[`Europe/Belgrade`],RU:/* @__PURE__ */ `Asia/Anadyr.Asia/Barnaul.Asia/Chita.Asia/Irkutsk.Asia/Kamchatka.Asia/Khandyga.Asia/Krasnoyarsk.Asia/Magadan.Asia/Novokuznetsk.Asia/Novosibirsk.Asia/Omsk.Asia/Sakhalin.Asia/Srednekolymsk.Asia/Tomsk.Asia/Ust-Nera.Asia/Vladivostok.Asia/Yakutsk.Asia/Yekaterinburg.Europe/Astrakhan.Europe/Kaliningrad.Europe/Kirov.Europe/Moscow.Europe/Samara.Europe/Saratov.Europe/Ulyanovsk.Europe/Volgograd`.split(`.`),RW:[`Africa/Kigali`],SA:[`Asia/Riyadh`],SB:[`Pacific/Guadalcanal`],SC:[`Indian/Mahe`],SD:[`Africa/Khartoum`],SE:[`Europe/Stockholm`],SG:[`Asia/Singapore`],SH:[`Atlantic/St_Helena`],SI:[`Europe/Ljubljana`],SJ:[`Arctic/Longyearbyen`,`Atlantic/Jan_Mayen`],SK:[`Europe/Bratislava`],SL:[`Africa/Freetown`],SM:[`Europe/San_Marino`],SN:[`Africa/Dakar`],SO:[`Africa/Mogadishu`],SR:[`America/Paramaribo`],SS:[`Africa/Juba`],ST:[`Africa/Sao_Tome`],SV:[`America/El_Salvador`],SX:[`America/Lower_Princes`],SY:[`Asia/Damascus`],SZ:[`Africa/Mbabane`],TC:[`America/Grand_Turk`],TD:[`Africa/Ndjamena`],TG:[`Africa/Lome`],TH:[`Asia/Bangkok`],TJ:[`Asia/Dushanbe`],TK:[`Pacific/Fakaofo`],TL:[`Asia/Dili`],TM:[`Asia/Ashgabat`,`Asia/Ashkhabad`],TN:[`Africa/Tunis`],TO:[`Pacific/Tongatapu`],TR:[`Asia/Istanbul`,`Europe/Istanbul`],TT:[`America/Port_of_Spain`],TV:[`Pacific/Funafuti`],TW:[`Asia/Taipei`],TZ:[`Africa/Dar_es_Salaam`],UA:[`Europe/Kiev`,`Europe/Kyiv`,`Europe/Simferopol`,`Europe/Uzhgorod`,`Europe/Zaporozhye`],UG:[`Africa/Kampala`],US:/* @__PURE__ */ `America/Adak.America/Anchorage.America/Atka.America/Boise.America/Chicago.America/Denver.America/Detroit.America/Fort_Wayne.America/Indiana/Indianapolis.America/Indiana/Knox.America/Indiana/Marengo.America/Indiana/Petersburg.America/Indiana/Tell_City.America/Indiana/Vevay.America/Indiana/Vincennes.America/Indiana/Winamac.America/Indianapolis.America/Juneau.America/Kentucky/Louisville.America/Kentucky/Monticello.America/Knox_IN.America/Los_Angeles.America/Louisville.America/Menominee.America/Metlakatla.America/New_York.America/Nome.America/North_Dakota/Beulah.America/North_Dakota/Center.America/North_Dakota/New_Salem.America/Phoenix.America/Shiprock.America/Sitka.America/Yakutat.Pacific/Honolulu.US/Alaska.US/Aleutian.US/Arizona.US/Central.US/East-Indiana.US/Eastern.US/Hawaii.US/Indiana-Starke.US/Michigan.US/Mountain.US/Pacific`.split(`.`),UY:[`America/Montevideo`],UZ:[`Asia/Samarkand`,`Asia/Tashkent`],VA:[`Europe/Vatican`],VC:[`America/St_Vincent`],VE:[`America/Caracas`],VG:[`America/Tortola`],VI:[`America/St_Thomas`,`America/Virgin`],VN:[`Asia/Ho_Chi_Minh`,`Asia/Saigon`],VU:[`Pacific/Efate`],WF:[`Pacific/Wallis`],WS:[`Pacific/Apia`],YE:[`Asia/Aden`],YT:[`Indian/Mayotte`],ZA:[`Africa/Johannesburg`],ZM:[`Africa/Lusaka`],ZW:[`Africa/Harare`]},m=new Set(i.map(([e])=>e)),h=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(p))for(let n of t)h.set(n,e);function g(e){let t=e===void 0?void 0:h.get(e);return t&&m.has(t)?t:null}function _(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&m.has(t)?t:null}function v(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return g(e)||_(t)||null}function y(){return Promise.all([import(`./max-ByBKGsXq.js`),import(`./examples.mobile.json-GS1_MGh9.js`)]).then(([e,t])=>b(e,t.default||t))}function b(e,t){return{AsYouType:e.AsYouType,getExampleNumber:e.getExampleNumber,isSupportedCountry:e.isSupportedCountry,isValidPhoneNumber:e.isValidPhoneNumber,parsePhoneNumber:e.parsePhoneNumber,examples:t}}function x(e,t){return e.isSupportedCountry(t)}var S=e=>e?`wui-flag wui-flag-${String(e).toLowerCase()}`:`wui-flag`,C=e=>e?`+${r(e)}`:``,w=null,T=null;function E(){return w?Promise.resolve(w):(T||=y().then(e=>(w=e,w)).catch(e=>(a(`[@webority/ui-elements] <wui-phone> could not load its phone number metadata.`,e),null)),T)}function D(e,t){let n=`+${r(e)}`;return t?.startsWith(n)?t.slice(n.length).trimStart():null}function O(e,t){if(!w||!t||!e||!x(w,e))return t;try{return D(e,new w.AsYouType(e).input(`+${r(e)}${t}`))||t}catch{return t}}function k(e,t){if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r++)if(/[0-9]/.test(e[r]??``)&&(n+=1,n===t))return r+1;return e.length}function A(e){if(!w||!e||!x(w,e))return null;try{return D(e,w.getExampleNumber(e,w.examples)?.formatInternational())||null}catch{return null}}function j(e){let t=A(e);return t?`For example ${t}`:null}function M(e){if(!w||!e)return null;try{if(!w.isValidPhoneNumber(e))return!1;let t=w.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function N(e){if(!w||!e||!x(w,e))return null;try{let t=w.getExampleNumber(e,w.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function P(e,t,n){if(!w||!x(w,e))return null;try{let r=w.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function F(e){if(!w||!e?.trim().startsWith(`+`))return null;try{let t=new w.AsYouType;t.input(e.trim());let n=t.getCountry();return!n||!V(t)?null:{country:n,national:t.getNationalNumber()||``}}catch{return null}}function I(e,t){let n=String(t??``).trim();if(!n.startsWith(`+`))return null;let i=n.replace(/[^0-9]/g,``),a=String(r(e));return{country:e,national:i.startsWith(a)?i.slice(a.length):i}}var L=class extends o{static formAssociated=!0;static get observedAttributes(){return[`value`,`country`,`locked-country`,`placeholder`,`disabled`,`readonly`,`loading`,`required`,`aria-label`,`aria-describedby`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._defaultCountry=v()||``,this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``,this._validateOnInput=!1}connectedCallback(){this._rendered?this._bindGlobal?.():this.render()}attributeChangedCallback(e,t,n){if(e===`value`)this.value=n;else if(this._rendered){if(e===`aria-label`){let t=this.querySelector(`input[type=tel]`);t&&(n==null?t.removeAttribute(e):t.setAttribute(e,n))}else if(e===`aria-describedby`)this._syncDescribedBy();else if(e===`country`){if(this._locked)return;let e=this.value;if(this._country=n||this._defaultCountry,this._suppressCountryRender)return;this.render(),this.value!==e&&(this._emitInput(),this._emitChange())}else this.render()}}formResetCallback(){this._validateOnInput=!1,this.value=this._defaultValue||``}get _locked(){return(this.getAttribute(`locked-country`)||``).toUpperCase()||null}get value(){return this._national&&this._country?`+${r(this._country)}${this._national}`:``}set value(e){let t=String(e??``).trim();this._locked&&(this._country=this._locked);let n=this._locked?null:F(t);if(n)this._country=n.country,this._national=n.national.replace(/[^0-9]/g,``);else if(t.startsWith(`+`)){let e=t.replace(/[^0-9]/g,``),n=String(r(this._locked||this.getAttribute(`country`)||this._country));n&&e.startsWith(n)&&(e=e.slice(n.length)),this._national=e}else this._national=t.replace(/[^0-9]/g,``);n&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){l(this,this.value)}_syncDescribedBy(){let e=this.querySelector(`input[type=tel]`);if(!e)return;let t=[this.getAttribute(`aria-describedby`),this.querySelector(`[data-phone-error]`)?.id].filter(Boolean);t.length?e.setAttribute(`aria-describedby`,t.join(` `)):e.removeAttribute(`aria-describedby`)}_emitInput(){this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_emitChange(){this._committedValue=this.value,this.dispatchEvent(new Event(`change`,{bubbles:!0}))}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``),this._country=this._locked||this.getAttribute(`country`)||this._country;let e=this.getAttribute(`placeholder`)||j(this._country)||`Enter phone number`;this.id||=`wui-phone-${Math.random().toString(36).slice(2,9)}`;let t=`${this.id}-listbox`;this._listboxId=t;let n=this._locked?`<div class="phone-country-adornment"><span class="wui-phone-prefix"><span class="${S(this._country)}" data-flag aria-hidden="true"></span><span class="phone-dial" data-dial>${C(this._country)}</span></span></div>`:`<div class="phone-country-adornment">
|
|
2
|
-
<button type="button" class="country-toggle" aria-label="Choose country" aria-haspopup="listbox" aria-expanded="false" aria-controls="${H(t)}"${this.hasAttribute(`disabled`)?` disabled`:``}>
|
|
3
|
-
<span class="${S(this._country)}" data-flag aria-hidden="true"></span>
|
|
4
|
-
${u(`chevron-down`,{className:`phone-chevron`})}
|
|
5
|
-
<span class="phone-dial" data-dial>${C(this._country)}</span>
|
|
6
|
-
</button>
|
|
7
|
-
<div class="country-dropdown-menu" hidden>
|
|
8
|
-
<div class="dropdown-search-wrapper"><span class="dropdown-search-icon">${u(`search`)}</span><input type="text" class="dropdown-search-input" placeholder="Search country or code" aria-label="Search countries" aria-controls="${H(t)}" aria-autocomplete="list" /></div>
|
|
9
|
-
<div class="country-list-scroll" role="listbox" id="${H(t)}" tabindex="-1"></div>
|
|
10
|
-
<div class="country-empty" hidden>No countries found</div>
|
|
11
|
-
</div>
|
|
12
|
-
</div>`;this.innerHTML=`
|
|
13
|
-
<div class="phone-input-wrap">
|
|
14
|
-
${n}
|
|
15
|
-
<input type="tel" class="input" placeholder="${H(e)}" value="${H(O(this._country,this._national))}"${this.getAttribute(`aria-label`)?` aria-label="${H(this.getAttribute(`aria-label`))}"`:``}${this.getAttribute(`aria-describedby`)?` aria-describedby="${H(this.getAttribute(`aria-describedby`))}"`:``}${this.hasAttribute(`required`)?` required aria-required="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${c(this)?` readonly`:``} />
|
|
16
|
-
</div>`,this._rendered=!0,s(this,this.querySelector(`input.input`)),l(this,this.value),this._wire()}_ensureItems(){let e=z(this.querySelector(`.country-list-scroll`),HTMLElement);if(!e||e.querySelector(`.country-dropdown-item`))return;let t=this._listboxId,n=i.map(([e,n,r],i)=>`<button type="button" role="option" id="${H(`${t}-opt-${i}`)}" class="country-dropdown-item${e===this._country?` selected`:``}" data-iso="${e}" aria-selected="${e===this._country}"><span class="${S(e)}" aria-hidden="true"></span><span class="country-name-text">${n}<span class="country-code-text">+${r}</span></span></button>`).join(``);e.insertAdjacentHTML(`afterbegin`,n)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)].filter(e=>e instanceof HTMLElement)}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){this._teardown();let i=z(this.querySelector(`.country-toggle`),HTMLButtonElement),a=R(z(this.querySelector(`.phone-input-wrap`),HTMLElement),`phone input wrapper`),o=z(this.querySelector(`.country-dropdown-menu`),HTMLElement),s=z(this.querySelector(`.dropdown-search-input`),HTMLInputElement),l=z(this.querySelector(`.country-list-scroll`),HTMLElement),u=z(this.querySelector(`.country-empty`),HTMLElement),p=R(z(this.querySelector(`input[type=tel]`),HTMLInputElement),`phone input`),m=z(this.querySelector(`[data-flag]`),HTMLElement),h=z(this.querySelector(`[data-dial]`),HTMLElement),g=()=>!!o&&!R(o,`country menu`).hidden,_=()=>{n(a||i,o)},v=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,f(R(l,`country list`),e>=0&&n[e]||null);let r=e>=0?n[e]:void 0;r?(t&&r.scrollIntoView({block:`nearest`}),s?.setAttribute(`aria-activedescendant`,r.id)):s?.removeAttribute(`aria-activedescendant`)},y=()=>{g()&&_()},b=()=>{if(c(this))return;this._ensureItems(),R(o,`country menu`).hidden=!1,R(i,`country toggle`).setAttribute(`aria-expanded`,`true`);let t=R(s,`country search`);t.value=``,C(``),_(),e(this,y),t.focus(),v(this._visibleItems().findIndex(e=>e.classList.contains(`selected`)))},x=()=>{R(o,`country menu`).hidden=!0,R(i,`country toggle`).setAttribute(`aria-expanded`,`false`),v(-1),t(this)},C=e=>{let t=e.trim().toLowerCase(),n=0;for(let e of this._itemEls()){let r=!t||(e.textContent??``).toLowerCase().includes(t);e.hidden=!r,r&&(n+=1)}u&&(u.hidden=n>0)},w=e=>{this._country=e,this.getAttribute(`country`)!==e&&(this._suppressCountryRender=!0,this.setAttribute(`country`,e),this._suppressCountryRender=!1),m&&(m.className=S(e)),h&&(h.textContent=`+${r(e)}`);for(let t of this._itemEls()){let n=t.dataset.iso===e;t.classList.toggle(`selected`,n),t.setAttribute(`aria-selected`,String(n))}this.getAttribute(`placeholder`)||(p.placeholder=j(e)||`Enter phone number`),this._national&&(p.value=O(e,this._national)),x(),this._syncMirror(),this._emitChange(),this._validateOnInput&&D(L()),p.focus()},T=e=>{let t=this._visibleItems();if(e.key===`ArrowDown`){if(e.preventDefault(),!g()){b();return}v(Math.min(this._active+1,t.length-1))}else if(e.key===`ArrowUp`){if(e.preventDefault(),!g())return;v(Math.max(this._active-1,0))}else if(d(e)){e.preventDefault();let n=t[this._active];g()&&n?.dataset.iso&&w(n.dataset.iso)}else e.key===`Escape`&&g()&&(e.preventDefault(),e.stopPropagation(),x(),R(i,`country toggle`).focus())};i?.addEventListener(`click`,()=>g()?x():b()),i?.addEventListener(`keydown`,e=>{g()?T(e):(e.key===`ArrowDown`||d(e)||e.key===` `)&&(e.preventDefault(),b())}),s&&s.addEventListener(`input`,()=>{C(s.value);let e=this._visibleItems();v(e.length?0:-1)}),l?.addEventListener(`click`,e=>{let t=z(B(e).closest(`.country-dropdown-item`),HTMLElement);t?.dataset.iso&&w(t.dataset.iso)}),l?.addEventListener(`mousemove`,e=>{let t=z(B(e).closest(`.country-dropdown-item`),HTMLElement);t&&!t.classList.contains(`is-active`)&&v(this._visibleItems().indexOf(t),{reveal:!1})}),l?.addEventListener(`mouseleave`,()=>v(-1)),o?.addEventListener(`keydown`,T);let D=e=>{p.classList.toggle(`is-invalid`,e),e?p.setAttribute(`aria-invalid`,`true`):p.removeAttribute(`aria-invalid`);let t=z(this.querySelector(`[data-phone-error]`),HTMLElement);if(e&&!this.hasAttribute(`external-error`)){t||(t=document.createElement(`div`),t.className=`field-error`,t.id=`${this.id}-phone-error`,t.setAttribute(`data-phone-error`,``),a.after(t));let e=A(this._country);t.textContent=this._country?e?`Enter a valid phone number, e.g. ${e}`:`Enter a valid phone number`:`Choose a country`}else t?.remove();this._syncDescribedBy()},L=()=>this._national.length>0&&(!this._country||M(this.value)===!1);p.addEventListener(`input`,e=>{e.stopPropagation();let t=p.selectionStart??p.value.length,n=p.value.slice(0,t).replace(/[^0-9]/g,``).length,r=p.value.replace(/[^0-9]/g,``),i=N(this._country);if(i&&r.length>i){let e=P(this._country,r,i);e?(n=Math.max(0,n-(r.length-e.length)),r=e):r=r.slice(0,i)}this._national=r;let a=O(this._country,this._national);if(p.value!==a){p.value=a;let e=k(a,Math.min(n,r.length));p.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),this._validateOnInput&&D(L())}),p.addEventListener(`change`,e=>e.stopPropagation()),p.addEventListener(`blur`,()=>{let e=L();D(e),e&&(this._validateOnInput=!0),this.value!==this._committedValue&&this._emitChange()}),p.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text`),n=this._locked?I(this._locked,t):F(t);n&&(e.preventDefault(),this._national=n.national.replace(/[^0-9]/g,``),n.country===this._country?p.value=O(this._country,this._national):(this._country=n.country,this.setAttribute(`country`,n.country)),this._syncMirror(),this._emitInput(),this._emitChange(),this._validateOnInput&&p.isConnected&&D(L()),z(this.querySelector(`input[type=tel]`),HTMLInputElement)?.focus())}),this._bindGlobal=()=>{this._teardownGlobals?.(),this._onDocClick=e=>{g()&&!e.composedPath().includes(this)&&x()},document.addEventListener(`click`,this._onDocClick),g()&&e(this,y)},this._teardownGlobals=()=>{this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),t(this)},this._bindGlobal(),this._validateOnInput&&D(L()),E().then(e=>{if(e&&p.isConnected&&(this._national&&(p.value=O(this._country,this._national)),!this.getAttribute(`placeholder`))){let e=j(this._country);e&&(p.placeholder=e)}}),this._syncMirror()}_teardown(){this._teardownGlobals?.()}disconnectedCallback(){this._teardown()}};function R(e,t){if(e==null)throw Error(`${t} missing`);return e}function z(e,t){return e instanceof t?e:null}function B(e){if(!(e.target instanceof Element))throw Error(`Event target is not an element`);return e.target}function V(e){return`getNationalNumber`in e&&typeof e.getNationalNumber==`function`}var H=e=>String(e??``).replace(/"/g,`"`).replace(/</g,`<`);export{L as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t}from"./relativeTime-BahImc8F.js";var n=3e4,r=/* @__PURE__ */ new Set,i=null,a=()=>{if(!(typeof document<`u`&&document.hidden))for(let e of r)e.refresh()},o=e=>{r.add(e),r.size===1&&(i=setInterval(a,n),document.addEventListener(`visibilitychange`,a))},s=e=>{r.delete(e),r.size===0&&(clearInterval(i??void 0),i=null,document.removeEventListener(`visibilitychange`,a))},c=class extends e{_observer;constructor(){super(),this._observer=null}connectedCallback(){this.refresh(),o(this),this._observer=new MutationObserver(()=>this.refresh()),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`datetime`]})}disconnectedCallback(){s(this),this._observer?.disconnect(),this._observer=null}refresh(){let e=this.querySelector(`time[datetime]`);if(!(e instanceof HTMLTimeElement))return;let n=t(e.getAttribute(`datetime`));e.textContent!==n&&(e.textContent=n)}};export{c as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./buttonClass-GtEi8hAY.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{l as r}from"./wuiHttp-DGbD7Fra.js";var i=`wui-saved-views:`,a=20,o=0,s=e=>typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`query`in e&&typeof e.query==`string`,c=class extends n{static get observedAttributes(){return[`key`,`mode`,`action`,`can-share`]}_doc=null;_dom=null;_views;_open;_busy;_error;_trigger;_onTriggerClick;_onKeyDown;_onPointerDown;_onSubmit;constructor(){super(),this._views=[],this._open=!1,this._busy=!1,this._error=null,this._onTriggerClick=()=>this._setOpen(!this._open),this._onKeyDown=e=>{this._open&&e.target instanceof Node&&this.contains(e.target)&&(e.key===`Escape`?(e.stopPropagation(),this._setOpen(!1),this._trigger?.focus()):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&this._ui.menu.contains(e.target)&&!(e.target instanceof Element&&/input|textarea/i.test(e.target.tagName))&&(e.preventDefault(),e.stopPropagation()))},this._onPointerDown=e=>{this._open&&!e.composedPath().includes(this)&&this._setOpen(!1)},this._onSubmit=async e=>{e.preventDefault();let t=this._ui.input.value.trim();if(!t)return;if(this._server()){if(this._busy)return;let e={name:t,query:this._ownerDoc.location.search};this._canShare()&&(e.shared=String(this._ui.share.checked)),await this._request(`save`,e)&&(this._ui.input.value=``,this._ui.share.checked=!1);return}let n=this._ownerDoc.location.search;this._commit([{name:t,query:n},...this._views.filter(e=>e.name!==t)].slice(0,a)),this._ui.input.value=``}}get _ownerDoc(){if(!this._doc)throw Error(`wui-saved-views is not connected`);return this._doc}get _ui(){if(!this._dom)throw Error(`wui-saved-views is not built`);return this._dom}connectedCallback(){this._doc=this.ownerDocument,this._trigger||this._build(),window.addEventListener(`keydown`,this._onKeyDown,!0),this._reload()}disconnectedCallback(){this._setOpen(!1),window.removeEventListener(`keydown`,this._onKeyDown,!0),this._doc=null}attributeChangedCallback(){this._doc&&this._trigger&&this._reload()}_reload(){this._server()?(this._views=[],this._render(),this._request(`list`)):(this._views=this._load(),this._render())}_server(){return this.getAttribute(`mode`)===`server`&&!!this.getAttribute(`action`)&&!!this.getAttribute(`key`)}_canShare(){return this._server()&&this.getAttribute(`can-share`)===`true`}async _request(e,t={}){let n=this.getAttribute(`action`)??``,i=this.getAttribute(`key`)??``,a=n,o;e===`list`?a+=(n.includes(`?`)?`&`:`?`)+new URLSearchParams({intent:`list`,key:i}):o={method:`POST`,body:new URLSearchParams({intent:e,key:i,...t})},this._busy=!0,this._render();let c=await r(a,o);if(this._busy=!1,this._doc===null)return!1;if(c.ok){let e=new DOMParser().parseFromString(c.html,`text/html`);return this._views=[...e.querySelectorAll(`[data-wui-saved-views-items] > li`)].filter(e=>e instanceof HTMLLIElement).map(e=>({name:e.dataset.name,query:e.dataset.query,shared:e.dataset.shared===`true`})).filter(s),this._error=null,this._render(),!0}return this._error=c.message||`The views could not be updated. Try again.`,this._render(),!1}_build(){let n=this._ownerDoc;this.classList.add(`dropdown`),this._trigger=n.createElement(`button`),this._trigger.type=`button`,this._trigger.className=e(`neutral`,`outline`,`sm`),this._trigger.dataset.wui=t,this._trigger.textContent=`Views`,this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,`false`),this._trigger.addEventListener(`click`,this._onTriggerClick);let r=n.createElement(`div`);r.className=`dropdown-menu`;let i=n.createElement(`div`);i.className=`dropdown-divider`;let a=n.createElement(`input`);a.type=`text`,a.className=`form-control form-control-sm`,a.setAttribute(`aria-label`,`View name`),a.placeholder=`Name this view`;let s=n.createElement(`button`);s.type=`submit`,s.className=e(`primary`,`solid`,`sm`),s.dataset.wui=t,s.textContent=`Save this view`;let c=n.createElement(`form`);c.className=`d-flex gap-2 px-3 py-2`,c.append(a,s),c.addEventListener(`submit`,this._onSubmit);let l=n.createElement(`input`);l.type=`checkbox`,l.className=`form-check-input`,l.setAttribute(`role`,`switch`),l.id=`wui-saved-views-share-${o++}`;let u=n.createElement(`label`);u.className=`form-check-label`,u.htmlFor=l.id,u.textContent=`Share with the team`;let d=n.createElement(`div`);d.className=`form-check form-switch mb-0`,d.append(l,u);let f=n.createElement(`div`);f.className=`px-3 pb-2`,f.hidden=!0,f.append(d),this._dom={menu:r,divider:i,form:c,input:a,save:s,shareRow:f,share:l},this.append(this._trigger,r)}_render(){let e=this._ownerDoc,t=this._ui,n=[];for(let t of this._views){let r=e.createElement(`a`);if(r.className=`dropdown-item`,r.setAttribute(`href`,e.location.pathname+t.query),r.textContent=t.name,t.shared){let t=e.createElement(`span`);t.className=`badge text-bg-secondary ms-2`,t.textContent=`Shared`,r.append(t)}let i=e.createElement(`button`);i.type=`button`,i.className=`btn btn-link btn-sm`,i.textContent=`Delete`,i.setAttribute(`aria-label`,`Delete ${t.name}`),i.disabled=this._busy,i.addEventListener(`click`,()=>this._server()?this._request(`delete`,{name:t.name}):this._commit(this._views.filter(e=>e.name!==t.name))),n.push(r,i)}if(this._error){let t=e.createElement(`div`);t.className=`dropdown-item-text text-danger small`,t.setAttribute(`role`,`alert`),t.textContent=this._error,n.push(t)}t.save.disabled=this._busy,t.share.disabled=this._busy,t.shareRow.hidden=!this._canShare(),t.menu.replaceChildren(...n,t.divider,t.form,t.shareRow)}_commit(e){this._views=e,this._write(e),this._render()}_setOpen(e){e!==this._open&&(this._open=e,this._ui.menu.classList.toggle(`show`,e),this._trigger?.setAttribute(`aria-expanded`,String(e)),e?this._ownerDoc.addEventListener(`pointerdown`,this._onPointerDown,!0):this._ownerDoc.removeEventListener(`pointerdown`,this._onPointerDown,!0))}_storage(){let e=this.getAttribute(`key`);if(!e)return null;try{let t=this._ownerDoc.defaultView;return t?{store:t.localStorage,key:i+e}:null}catch{return null}}_load(){let e=this._storage();if(!e)return[];try{let t=JSON.parse(e.store.getItem(e.key)??`[]`);return Array.isArray(t)?t.filter(s).slice(0,a):[]}catch{return[]}}_write(e){let t=this._storage();if(t)try{t.store.setItem(t.key,JSON.stringify(e))}catch(e){if(!(e instanceof DOMException))throw e}}};export{c as t};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./anchorOverlay-CXnWfezA.js";import{i as r,n as i,r as a,t as o}from"./optionLabel-4xjXWy74.js";import{n as s}from"./devWarn-DXdRWZs3.js";import{r as c}from"./dom-Do1pAA12.js";import{t as l}from"./elementBase-Cxeyx0tU.js";import{r as u,t as d}from"./fieldState-D-zQcXUS.js";import{n as f,t as p}from"./formMirror-9IpSgeZb.js";import{n as m}from"./loader-DRYPWxQL.js";import{t as h}from"./iconGlyphs.g-DPqoOoXy.js";import{t as g}from"./imeSafeEnter-DPs9qL3S.js";import{n as _,t as v}from"./listboxKeyNav-DkLHwzJE.js";var y=e=>{let t=String(e??``).trim();return/^(https?:)?\/\//i.test(t)||/^\/(?!\/)/.test(t)||/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(t)?t:``},b=(e,t=`wui-opt-avatar`)=>{let n=y(e.avatar);return!n&&!e.initials?``:`<span class="avatar ${t}" aria-hidden="true"><span class="avatar-face">${i(e.initials??``)}</span>${n?`<img class="avatar-img" src="${x(n)}" alt="" />`:``}</span>`},x=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`);function S(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[r(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var C=/* @__PURE__ */ new WeakMap;function w(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=`No matches`,searchingText:c=`Searching…`,hintText:l=`Type to search…`,actionRow:u=[],recents:d=null}=n,f=new Set(r.map(String)),p=S(t,a),m=e.id,h=0,g=()=>`${m}-opt-${h++}`,_=e=>`<button type="button" role="option" id="${i(g())}" class="wui-select-option wui-select-add" data-value="${i(e.value)}" data-custom="true" aria-selected="false">${i(e.label)}</button>`,v=u.filter(e=>e.position===`top`).map(_).join(``),y=d?.options.length?`<div class="wui-select-group">${i(d.label)}</div>${d.options.map(e=>T(e,g(),f.has(String(e.value)))).join(``)}<div class="wui-select-sep" aria-hidden="true"></div>`:``,b=``,x=``;for(let e of p)e.group&&e.group!==b&&(x+=`<div class="wui-select-group">${i(e.group)}</div>`),b=e.group??``,x+=T(e,g(),f.has(String(e.value)));let w=u.filter(e=>e.position===`bottom`).map(_).join(``),E=``;o===`loading`?E=`<div class="wui-select-loading"><span class="wui-select-spinner spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>${i(c)}</div>`:o===`hint`?E=`<div class="wui-select-hint">${i(l)}</div>`:(o===`empty`||p.length===0&&u.length===0)&&(E=`<div class="wui-select-empty">${i(s)}</div>`);let D=v+y+x+w+E;C.get(e)!==D&&(C.set(e,D),e.innerHTML=D)}function T(e,t,n){let r=!!e.disabled,o=r&&e.disabledHint?` title="${i(e.disabledHint)}"`:``,s=`id="${i(t)}" role="option" data-value="${i(e.value)}" aria-selected="${n}"${r?` aria-disabled="true"`:``}${o}`,c=`<span class="wui-select-check" aria-hidden="true">${h(`check`)}</span>`;if(!e.description&&!e.meta)return`<button type="button" class="wui-select-option${n?` selected`:``}" ${s}>${b(e)}<span class="wui-select-opt-name">${a(e)}</span>${c}</button>`;let l=e.description?`<span class="wui-select-opt-desc">${i(e.description)}</span>`:``,u=e.meta?`<span class="wui-select-opt-meta">${i(e.meta)}</span>`:``;return`<div class="wui-select-option wui-select-option-rich${n?` selected`:``}" ${s}>${b(e)}<span class="wui-select-option-text"><span class="wui-opt-label">${a(e)}</span>${l}</span>${u}${c}</div>`}var E=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),D=e=>e===`multiple`||e===`tag`,O={recents:()=>import(`./recents-Dcw-b5cB.js`),chips:()=>import(`./chips-0jT9fpA9.js`),search:()=>import(`./search-C0IYOzso.js`),country:()=>import(`./country-x5lqC5Xu.js`)};function k(e){let t=Object.hasOwn(O,e)?O[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var A=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),j=class extends l{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_reposition;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_onDocClick;_bindGlobal=()=>{throw Error(`The select is not wired.`)};_reanchor;_reanchorScroll;static get observedAttributes(){return/* @__PURE__ */ `mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.open-on-hover.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._searchShown=!1,this._defaultValue=void 0,this._warnedMode=null,this._reposition=()=>{this._menuOpen()&&this._place()},this._hoverTimer=null,this._hoverOpened=!1,this._onHoverOver=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&(this._clearHover(),!this._menuOpen()&&this._hoverEligible()&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,!this._menuOpen()&&this._hoverEligible()&&(this._open({focus:!1}),this._hoverOpened=!0)},F)))},this._onHoverOut=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&!this._hoverZone(e.relatedTarget)&&(this._clearHover(),this._menuOpen()&&this.hasAttribute(`open-on-hover`)&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._close()},I)))}}connectedCallback(){this.addEventListener(`pointerover`,this._onHoverOver),this.addEventListener(`pointerout`,this._onHoverOut),this._rendered?this._bindGlobal():this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this.removeEventListener(`pointerover`,this._onHoverOver),this.removeEventListener(`pointerout`,this._onHoverOut),this._clearHover(),this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`value`?(this._value=H(n,D(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):e===`open-on-hover`?this.hasAttribute(`open-on-hover`)||this._clearHover():(e===`mode`&&(this._value=H(this._value,D(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),B.has(e)?this._rendered&&(this._drawValue(),this.renderList()):z.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null?`single`:N(e)?e:(e!==this._warnedMode&&(this._warnedMode=e,s(`<wui-select> mode "${e}" is not one of ${E.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||P.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,s(`<wui-select> density "${e}" is not one of ${P.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=H(e,D(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();if(this._rendered){if(this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._autoSearch()!==this._searchShown){this.render();return}this._drawValue(),this.renderList()}}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){d(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();e.list&&(w(e.list,this._listOptions(),{selected:this._selectedValues(),query:this._ownsFilter?``:this._query,status:this._status,emptyText:this.getAttribute(`empty-text`)||`No matches`,searchingText:this.getAttribute(`searching-text`)||`Searching…`,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:this._actionRows(),recents:this._recents()}),this._active>=this._visible().length&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._menuOpen()&&this._place())}render(){let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=D(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=H(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=H(this._value,n));let o=this.getAttribute(`size`),s=o===`sm`?` wui-select-sm`:o===`lg`?` wui-select-lg`:``,c=this.getAttribute(`icon`),l=this.getAttribute(`prefix`),d=this.hasAttribute(`clearable`),f=this.hasAttribute(`disabled`);this.id||=`wui-select-${Math.random().toString(36).slice(2,9)}`;let p=`${this.id}-listbox`,m=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${m}`:m,v=this.hasAttribute(`aria-invalid`)||this._error?` aria-invalid="true"`:``,y=this.hasAttribute(`required`)&&!a?` aria-required="true"`:``,b=` aria-label="${i(this._accessibleName())}" aria-describedby="${i(_)}"${v}${y}`,x=a?``:` role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${i(p)}"`,S=n?`<div class="input wui-select-control wui-select-multi"${x}${b}${f?` aria-disabled="true"`:r?``:` tabindex="0"`}>`:`<button type="button" class="input wui-select-control"${x}${b}${f?` disabled`:``}>`,C=`${c?h(c,{className:`wui-select-icon`}):``}${l?`<span class="wui-select-prefix">${i(l)}</span>`:``}<span class="wui-select-value" data-label></span>${d?`<span class="wui-select-reset" role="button" aria-label="Clear selection" hidden>${h(`x`)}</span>`:``}${h(`chevron-down`,{className:`wui-select-caret`})}`,w=this.getAttribute(`searchable`),T=w===null?t===`multiple`||t===`country`||this._autoSearch():w!==`false`,E=t===`search`||T&&!a;this._searchShown=E;let O=this.getAttribute(`search-placeholder`)||(t===`country`?`Search countries…`:`Search…`),k=E?`<div class="wui-select-search">${h(`search`)}<input class="wui-select-input" placeholder="${i(O)}" aria-label="${i(O)}" aria-autocomplete="list" /><button type="button" class="wui-select-clear" aria-label="Clear search" hidden>${h(`x`)}</button></div>`:``;this.innerHTML=`
|
|
2
|
-
<div class="wui-select${s}">
|
|
3
|
-
${S}${C}${n?`</div>`:`</button>`}
|
|
4
|
-
<div class="wui-select-menu wui-select-menu-fixed" hidden>
|
|
5
|
-
${k}
|
|
6
|
-
<div class="wui-select-options" role="listbox" id="${i(p)}" tabindex="-1"${n?` aria-multiselectable="true"`:``}></div>
|
|
7
|
-
</div>
|
|
8
|
-
</div>
|
|
9
|
-
<div class="field-error wui-select-error" id="${i(m)}" aria-live="polite"${this._error?``:` hidden`}>${i(this._error)}</div>`,this._rendered=!0,this._syncMirror(),this._syncValidity(),this._drawValue(),this._syncReset(),this.renderList(),this._wire(),u(this,this.querySelector(`.wui-select-control`)),this._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t={value:e.getAttribute(`value`)??X(e).trim(),label:e.innerHTML,[o]:!0,selected:e.hasAttribute(`selected`)};for(let[n,r]of V){let i=e.getAttribute(n);i&&(t[r]=i)}return e.hasAttribute(`disabled`)&&(t.disabled=!0),t}))}_readOptions(){return this.mode===`country`?this._partOptions||[]:this._partOptions?this._partOptions:this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_listOptions(){let e=this._readOptions(),t=this.getAttribute(`value-label`);if(this.mode!==`search`||!t||this._value===``)return e;let n=String(this._value);return e.some(e=>String(e.value)===n)?e:[...e,{value:n,label:t}]}_declaredSelected(){return this._optionsProp?[]:(this._declared??[]).filter(e=>e.selected).map(e=>String(e.value))}_preselect(){let e=this._readOptions(),t=this._value!==``&&e.find(e=>String(e.value)===this._value)||e.find(e=>`selected`in e&&!!e.selected);t&&(this._value=String(t.value))}_optionFor(e){let t=String(e),n=this._readOptions().find(e=>String(e.value)===t);return n?(this._known.set(t,n),n):this._known.get(t)}_placeholder(){return this.getAttribute(`placeholder`)||R[this.mode]}_hasValue(){return Array.isArray(this._value)?this._value.length>0:this._value!==``}_selectedValues(){return Array.isArray(this._value)?this._value:this._value===``?this._listOptions().some(e=>String(e.value)===``)?[``]:[]:[this._value]}_applyValue(){this._syncMirror(),this._syncValidity(),this._rendered&&(this._drawValue(),this._syncReset(),this.renderList())}_syncMirror(){D(this.mode)?f(this,this._selectedValues()):p(this,this._value)}_drawValue(){let e=this._refs();if(!e.value)return;let t=D(this.mode),n=t?void 0:this._optionFor(this._value);this._syncTitle(n),this._syncValueAvatar(),this._activePartsList().some(e=>e.renderValue?.()===!0)||(t?(e.value.classList.remove(`wui-select-placeholder`),e.value.textContent=``):(e.value.classList.toggle(`wui-select-placeholder`,!n),e.value.innerHTML=n?a(n):i(this._placeholder())))}_syncTitle(e){let t=this.querySelector(`.wui-select-control`);if(!t)return;let n=e&&!this.hasAttribute(`title`)?r(e).trim():``;n?t.setAttribute(`title`,n):t.removeAttribute(`title`)}_syncValueAvatar(){let e=this.querySelector(`.wui-select-control`);if(!e)return;e.querySelector(`:scope > .wui-select-value-avatar`)?.remove();let t=!D(this.mode)&&this._hasValue()?b({avatar:this.getAttribute(`value-avatar`),initials:this.getAttribute(`value-initials`)},`avatar-xs`):``;e.classList.toggle(`wui-has-value-avatar`,!!t),t&&e.insertAdjacentHTML(`afterbegin`,`<span class="wui-select-value-avatar" aria-hidden="true">${t}</span>`)}_syncValidity(){let e=this._internals;if(typeof e?.setValidity==`function`){if(this.hasAttribute(`required`)&&!this._hasValue()){let t=this.querySelector(`.wui-select-control`);e.setValidity({valueMissing:!0},`Please fill in this field.`,t instanceof HTMLElement?t:void 0)}else e.setValidity({})}}_syncReset(){let e=J(this,`.wui-select-reset`,HTMLElement);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!d(this)))}_syncInvalid(){let e=this.querySelector(`.wui-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._error?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}_syncError(){let e=J(this,`.wui-select-error`,HTMLElement);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:J(this,`.wui-select-control`,HTMLElement),value:J(this,`.wui-select-value`,HTMLElement),menu:J(this,`.wui-select-menu`,HTMLElement),list:J(this,`.wui-select-options`,HTMLElement),search:J(this,`.wui-select-search input`,HTMLInputElement),input:J(this,`.wui-select-draft`,HTMLInputElement)}}_menuOpen(){let e=J(this,`.wui-select-menu`,HTMLElement);return e!==null&&!e.hidden}_hoverZone(e){if(!(e instanceof Element))return!1;let t=e.closest(`.wui-select-control, .wui-select-menu`);return t!==null&&this.contains(t)}_hoverEligible(){if(!this.hasAttribute(`open-on-hover`)||d(this)||this.mode===`tag`)return!1;let e=this._refs();return e.search===null&&e.input===null}_clearHover(){this._hoverTimer!==null&&clearTimeout(this._hoverTimer),this._hoverTimer=null}_autoSearch(){return this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._readOptions().length>L}_visible(){let e=this._refs();return e.list?Y(e.list,`.wui-select-option`):[]}_setActive(e,{reveal:t=!0}={}){let n=this._refs();if(!n.list||!n.control)return;let r=this._visible();this._active=e;let i=e>=0?r[e]??null:null;_(n.list,i),i?(t&&i.scrollIntoView({block:`nearest`}),n.control.setAttribute(`aria-activedescendant`,i.id)):n.control.removeAttribute(`aria-activedescendant`)}_actionRows(){let e=[];for(let t of this._activePartsList()){let n=t.actionRow?.(this._query);n&&e.push(n)}return e}_recents(){if(this._query.trim()!==``)return null;for(let e of this._activePartsList()){let t=e.recents?.(this._listOptions());if(t)return t}return null}_place(){let e=this._refs();if(!e.control||!e.menu)return;let t=this.hasAttribute(`open`)?{below:!0}:{};if(this.getAttribute(`density`)===`compact`){let r=e.control.getBoundingClientRect();e.menu.style.width=`max-content`,e.menu.style.minWidth=`${r.width}px`,e.menu.style.maxWidth=`280px`,n(e.control,e.menu,t)}else n(e.control,e.menu,{matchWidth:!0,...t})}_open({focus:t=!0}={}){let n=this._refs();if(!n.menu||!n.control)return;let r=!n.menu.hidden;n.menu.hidden=!1,n.control.setAttribute(`aria-expanded`,`true`),n.control.classList.add(`open`),this._query=n.input?n.input.value:``,this._ownsFilter=this._ownsFilter&&this._query!==``;let i=J(this,`.wui-select-search .wui-select-clear`,HTMLElement);if(i&&(i.hidden=!0),n.search&&(n.search.value=``),this.renderList(),e(this,this._reposition),t&&(n.search?.focus(),this._setActive(this._visible().findIndex(e=>e.classList.contains(`selected`)))),!r){this.dispatchEvent(new CustomEvent(`wui-select:open`,{bubbles:!0}));for(let e of this._activePartsList())e.onOpen?.()}}_close({force:e=!1}={}){if(!e&&this.hasAttribute(`open`))return;let n=this._refs();if(!n.menu||!n.control)return;this._hoverOpened=!1;let r=!n.menu.hidden;n.menu.hidden=!0,n.control.setAttribute(`aria-expanded`,`false`),n.control.classList.remove(`open`),this._setActive(-1),this._nav?.clearTypeahead(),t(this),r&&this.dispatchEvent(new CustomEvent(`wui-select:close`,{bubbles:!0}))}_onQueryChange(e){this._query=e,this._setActive(-1);let t=J(this,`.wui-select-search .wui-select-clear`,HTMLElement);t&&(t.hidden=!e);let n=!1;for(let t of this._activePartsList())t.onQuery?.(e)===!0&&(n=!0);this._ownsFilter=n,this.renderList()}_pick(e){if(e.getAttribute(`aria-disabled`)===`true`)return;let t=e.dataset.custom===`true`,n=e.dataset.value??``,r=t?{value:n,label:X(e).trim()}:this._listOptions().find(e=>String(e.value)===n)??{value:n,label:n},i=this._activePartsList().some(e=>e.onPick?.(r,{isCustom:t})===!0);D(this.mode)||(i||this.commit(n,{isCustom:t}),this._close(),this._refs().control?.focus())}_draftOpens(){return this.mode===`multiple`?this.hasAttribute(`allow-custom`):this.mode===`tag`&&A(this)}_onKeyDown(e){if(!d(this)){for(let t of this._activePartsList())if(t.onKey?.(e)===!0)return;if(!this._menuOpen()){if(e.target instanceof HTMLInputElement){if(e.key!==`ArrowDown`||!this._draftOpens())return;this._open({focus:!1})}else{(e.key===`ArrowDown`||g(e)||e.key===` `)&&(e.preventDefault(),this._open({focus:!0}));return}}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation()),c(this._nav,`Listbox keys are not wired.`).handler(e)}}_wire(){this._teardown();let t=this._refs(),n=t.control,r=t.list;if(!n||!t.menu||!r)return;let i=c(J(this,`.wui-select`,HTMLElement),`The select wrapper is missing.`),a=J(this,`.wui-select-search .wui-select-clear`,HTMLElement),o=J(this,`.wui-select-reset`,HTMLElement);this._nav=v({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>this._setActive(e),onEnter:(e,t)=>{if(e)this._pick(e);else if(this._query.trim()!==``){let e=t.find(e=>e.dataset.custom===`true`);if(e)this._pick(e);else if(t.length===1){let e=t[0];e&&this._pick(e)}}},onEscape:()=>{this._nav?.clearTypeahead(),this._close(),n.focus()}}),i.addEventListener(`keydown`,e=>this._onKeyDown(e)),i.addEventListener(`input`,e=>{let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-select-input, .wui-select-draft`))return;this._onQueryChange(t.value);let n=t.matches(`.wui-select-draft`),r=this._visible().length>0||this._actionRows().length>0;n&&r&&!this._menuOpen()&&!d(this)&&this._draftOpens()&&this._open({focus:!1})}),i.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||!this._activePartsList().some(e=>e.onBlur?.()===!0)&&t&&this._close()}),a?.addEventListener(`click`,()=>{let e=c(t.search,`The search input is missing.`);e.value=``,this._onQueryChange(``),e.focus()}),n.addEventListener(`click`,e=>{if(!(e.target instanceof Element&&e.target.closest(`[data-remove]`))){if(this.mode===`tag`){if(d(this))return;this._refs().input?.focus(),!this._menuOpen()&&this._draftOpens()&&this._open({focus:!1})}else e.target instanceof HTMLInputElement?!this._menuOpen()&&!d(this)&&this._open({focus:!1}):(this._clearHover(),this._hoverOpened&&this._menuOpen()?(this._hoverOpened=!1,this._open({focus:!0})):this._menuOpen()?this._close():d(this)||this._open({focus:!0}))}}),o?.addEventListener(`click`,e=>{e.stopPropagation(),this.commit(D(this.mode)?[]:``),this._close(),n.focus()}),r.addEventListener(`click`,e=>{let r=q(e).closest(`.wui-select-option`);if(r instanceof HTMLElement&&(this._pick(r),D(this.mode))){let e=this.querySelector(`.wui-select-draft`);(t.search??(e instanceof HTMLElement?e:n)).focus()}}),r.addEventListener(`mousedown`,e=>{D(this.mode)&&e.target instanceof Element&&e.target.closest(`.wui-select-option`)&&e.preventDefault()}),r.addEventListener(`mousemove`,e=>{let t=q(e).closest(`.wui-select-option`);t instanceof HTMLElement&&!t.classList.contains(`is-active`)&&this._setActive(this._visible().indexOf(t),{reveal:!1})}),r.addEventListener(`mouseleave`,()=>this._setActive(-1)),r.addEventListener(`error`,e=>{let t=e.target;t instanceof Element&&t.classList.contains(`avatar-img`)&&t.remove()},!0),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{this._menuOpen()&&!e.composedPath().includes(this)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._menuOpen()&&e(this,this._reposition)},this.hasAttribute(`open`)&&this._open({focus:!1}),this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),t(this),this._nav?.teardown()}_activePartsList(){return this._partsMounted?c(this._parts,`The mounted parts are missing.`):[]}_ensureParts(){if(!this.isConnected)return;let e=W(this,this.mode),t=e.join(`,`);if(t===this._partSig)return;this._teardownParts(),this._parts=null,this._partSig=t;let n=++this._partToken;Promise.all(e.map(e=>Z(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(e=>e!==null),this._mountParts())})}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=M(this._refs());for(let n of this._parts)n.mount(this,t,{carry:e});this._drawValue(),this.renderList()}_teardownParts(){let e=this._activePartsList();this._partsMounted=!1;for(let t of e)t.teardown()}_remountParts(){if(!this._partsMounted)return;let e=this._carry();this._teardownParts(),this._mountParts(e)}_carry(){let e=this._refs();return{draft:e.input?.value??``,query:e.search?.value??``}}},M=e=>{let{control:t,value:n,menu:r,list:i}=e;return{control:c(t,`control missing`),value:c(n,`value missing`),menu:c(r,`menu missing`),list:c(i,`list missing`),search:e.search,input:e.input}},N=e=>E.includes(e),P=[`comfortable`,`compact`],F=150,I=250,L=10,R={single:`Select…`,search:`Select…`,multiple:`Select…`,tag:`Add…`,country:`Select country`},z=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),B=/* @__PURE__ */ new Set([`separators`,`allow-duplicates`,`invalid-message`,`create-label`,`add-label`,`selected-text`,`clear-all-label`,`value-label`,`value-avatar`,`value-initials`,`hint-text`,`recents-key`,`recents-limit`,`recents-label`]),V=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],H=(e,t)=>t?Array.isArray(e)?e.map(String):e==null||e===``?[]:String(e).split(`,`).map(e=>e.trim()).filter(Boolean):Array.isArray(e)?e.length?String(e[0]):``:e==null?``:String(e),U=(e,t)=>t===`multiple`?A(e)?[`chips`,`search`]:[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?A(e)?[`chips`,`search`]:[`chips`]:[],W=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...U(e,t)]:U(e,t),G=`This control could not load. Reload the page.`,K=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,q=e=>{if(e.target instanceof Element)return e.target;throw Error(`The event target is not an element.`)},J=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Y=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),X=e=>{let t=e.textContent;if(t===null)throw Error(`The element has no text.`);return t},Z=(e,t)=>k(t).then(e=>{if(!K(e))throw Error(`The part ${t} has no default export.`);return e.default()}).catch(()=>(document.dispatchEvent(new CustomEvent(m,{bubbles:!0,composed:!0,detail:{chunk:t}})),e.setError(G),null));export{A as n,S as r,j as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,t}from"./dom-Do1pAA12.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{a as r,c as i,d as a,f as o,l as s,m as c,p as l,u}from"./shortcutKeys-COVLox98.js";var d=`wui-shortcuts-open-change`;function f(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}function p(e,t){return[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement)}var m=class extends n{_doc;_onKeyDown;_onClick;_onDocClick;static get observedAttributes(){return[`open`,`no-trigger`]}constructor(){super(),this._doc=null,this._onKeyDown=e=>this._keydown(e),this._onClick=e=>this._click(e),this._onDocClick=e=>{let n=t(e.target,`[data-wui-shortcuts-open]`)?.getAttribute(`data-wui-shortcuts-open`);n&&this.matches(n)?this.setOpen(!0):this.open&&!e.composedPath().includes(this)&&this.setOpen(!1,{focus:!1})}}connectedCallback(){this._doc=this.ownerDocument,this._doc.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`click`,this._onDocClick),this.addEventListener(`click`,this._onClick),this.hasAttribute(`open`)&&!this.open&&this.setOpen(!0,{focus:!1}),this._place(),this._syncTrigger()}attributeChangedCallback(e,t,n){e===`no-trigger`?this._syncTrigger():this._sheet()&&n!==null!==this.open&&this.setOpen(n!==null)}disconnectedCallback(){this._doc?.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`click`,this._onDocClick),this.removeEventListener(`click`,this._onClick),this._doc=null}get open(){let e=this._sheet();return!(!e||e.hidden)}set open(e){let t=e===!0||e===``||e===`true`;this._sheet()?t!==this.open&&this.setOpen(t):this.toggleAttribute(`open`,t)}setOpen(e,{focus:t=!0}={}){let n=this._sheet();if(!n)return;let r=n.hidden===e;n.hidden=!e,this.toggleAttribute(`open`,e),e&&this._place();let i=f(this,`.wui-shortcut-toggle`);i?.setAttribute(`aria-expanded`,String(e)),r&&this.dispatchEvent(new CustomEvent(d,{bubbles:!0,detail:{open:e}})),t&&(e?f(n,`.wui-shortcut-close`)?.focus():i?.focus())}_sheet(){return f(this,`.wui-shortcut-sheet`)}_syncTrigger(){let e=f(this,`.wui-shortcut-toggle`);e&&(e.hidden=this.hasAttribute(`no-trigger`))}_place(){let t=this._sheet();if(!t||t.hidden)return;t.classList.remove(`wui-shortcut-sheet-below`,`wui-shortcut-sheet-start`);let n=e(this.ownerDocument.defaultView,`WuiShortcuts needs a window to place its sheet`),r={top:0,left:0,right:n.innerWidth,bottom:n.innerHeight};for(let e=this.parentElement;e&&e!==this.ownerDocument.documentElement;e=e.parentElement){let t=n.getComputedStyle(e);if(t.overflowX===`visible`&&t.overflowY===`visible`)continue;let i=e.getBoundingClientRect();r.top=Math.max(r.top,i.top),r.left=Math.max(r.left,i.left),r.right=Math.min(r.right,i.right),r.bottom=Math.min(r.bottom,i.bottom)}let i=t.getBoundingClientRect();i.top<r.top&&t.classList.add(`wui-shortcut-sheet-below`),i.left<r.left&&t.classList.add(`wui-shortcut-sheet-start`)}_scope(){let e=this.closest(`[${r}]`);return e instanceof HTMLElement?e:null}_items(){let t=this.getAttribute(`items`);return t?p(e(this._scope()??this._doc,`WuiShortcuts used before it was connected`),t):[]}_click(e){let t=e.target;t instanceof Element&&(t.closest(`.wui-shortcut-toggle`)?this.setOpen(!this.open):t.closest(`.wui-shortcut-close`)&&this.setOpen(!1))}_tickFocused(){let t=this._items(),n=e(this._doc,`WuiShortcuts used before it was connected`).activeElement,r=n?.closest?.(`li, tr`),i=t.find(e=>e===n||e.contains(n)||r?.contains(e)),a=(i?.closest(`li, tr`)??i)?.querySelector(`input[type="checkbox"]`);a instanceof HTMLInputElement&&a.click()}_focusSearch(){let t=this.getAttribute(`search`);if(!t)return;let n=e(this._doc,`WuiShortcuts used before it was connected`);(f(this._scope()??n,t)??f(n,t))?.focus()}_keydown(t){if(t.defaultPrevented)return;let n=l(t);if(!n)return;if(n===`esc`&&this.open){t.preventDefault(),this.setOpen(!1);return}let r=this._scope(),d={help:()=>this.setOpen(!this.open)};if(this.getAttribute(`items`)&&(d.j=()=>u(this._items(),1),d.k=()=>u(this._items(),-1),d.x=()=>this._tickFocused()),this.getAttribute(`search`)&&(d.slash=()=>this._focusSearch()),d[n]){a(t,d,r);return}if(n===`enter`)return;let m=e(this._doc,`WuiShortcuts used before it was connected`),h=t.target instanceof Node?t.target:null;if(c(m)||!i(h,r)||s(h))return;let g=o(n),_=p(this,`.wui-shortcut-keys [data-shortcut]`).find(e=>e.dataset.shortcut===g);if(!_)return;let v=(r??m).querySelector(`[aria-current="true"]`)?.closest(`[data-key]`),y=v instanceof HTMLElement?v.dataset.key??null:null;if(!this.dispatchEvent(new CustomEvent(`wui:shortcut`,{bubbles:!0,cancelable:!0,detail:{key:g,itemKey:y}}))){t.preventDefault();return}let b=_.dataset.target,x=b?f(m,b):null;x&&(t.preventDefault(),x.click())}};export{m as t};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./anchorOverlay-CXnWfezA.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{r as i,t as a}from"./fieldState-D-zQcXUS.js";import{t as o}from"./formMirror-9IpSgeZb.js";import{t as s}from"./iconGlyphs.g-DPqoOoXy.js";import{t as c}from"./imeSafeEnter-DPs9qL3S.js";var l=e=>String(e).padStart(2,`0`),u=(e,t)=>`${l(e)}:${l(t)}`,d=e=>{let t=/^(\d{2}):(\d{2})$/.exec(e||``);return t?{h:Number(t[1]),m:Number(t[2])}:null},f=(e,t=`24`)=>{if(!e)return``;if(t===`24`)return u(e.h,e.m);let n=e.h%12||12,r=e.h>=12?`PM`:`AM`;return`${n}:${l(e.m)} ${r}`},p=e=>{let t=String(e||``).trim().toLowerCase(),n=/^(\d{1,2})(?:[:.](\d{2})|(\d{2}))?\s*(?:([ap])\.?\s*(?:m\.?)?)?$/.exec(t);if(!n)return null;let r=Number(n[1]),i=+(n[2]??n[3]??`0`);if(i>59)return null;if(n[4]){if(r<1||r>12)return null;r=r%12+(n[4]===`p`?12:0)}else if(r>23)return null;return{h:r,m:i}},m=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},h=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),g=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},_=()=>{throw Error(`wui-timepicker is not rendered`)},v=0,y=class extends r{static formAssociated=!0;_internals;_value;_uid;_typedError;_typeahead;_typeaheadTimer;_rendered;_defaultValue;_isOpen;_lastPointer;_open=_;_close=_;_bindGlobal=_;_onDocClick;_onDocKey;_onHostKey;static get observedAttributes(){return[`value`,`min`,`max`,`step`,`format`,`placeholder`,`disabled`,`readonly`,`loading`,`required`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._uid=`wui-tp-${++v}`,this._typedError=``,this._typeahead=``,this._typeaheadTimer=void 0,this.addEventListener(`focusout`,e=>{this._isOpen?.()&&e.relatedTarget instanceof Node&&!this.contains(e.relatedTarget)&&this._close({commit:!0})})}connectedCallback(){this._rendered?this._bindGlobal():this.render()}attributeChangedCallback(e,t,n){if(this._rendered)switch(e){case`value`:this._value=n||``,this._typedError=``,this._syncFormValue(),this._syncText(),this._syncInvalid();return;case`aria-invalid`:case`aria-describedby`:this._syncInvalid();return;case`aria-label`:case`placeholder`:case`disabled`:case`readonly`:case`loading`:case`required`:this._syncAttrs();return;default:this.render()}}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,this._typedError=``,o(this,this._value),this._syncText(),this._syncInvalid()}_format(){return this.getAttribute(`format`)||`24`}_step(){return Math.max(1,parseInt(this.getAttribute(`step`)||`30`,10)||30)}_bounds(){let e=d(this.getAttribute(`min`))||{h:0,m:0},t=d(this.getAttribute(`max`))||{h:23,m:59};return{min:e.h*60+e.m,max:t.h*60+t.m}}_allowed(e,t){let n=e*60+t,{min:r,max:i}=this._bounds();return n>=r&&n<=i&&n%this._step()===0}_times(){let e=[];for(let t=0;t<1440;t+=this._step()){let n=Math.floor(t/60),r=t%60;this._allowed(n,r)&&e.push({h:n,m:r})}return e}_refusal(e){if(this._allowed(e.h,e.m))return``;let t=this._format(),{min:n,max:r}=this._bounds(),i=e.h*60+e.m,a=e=>f({h:Math.floor(e/60),m:e%60},t);if(i<n||i>r){let e=!!d(this.getAttribute(`min`)),t=!!d(this.getAttribute(`max`));return e&&t?`Enter a time between ${a(n)} and ${a(r)}.`:e?`Enter a time at or after ${a(n)}.`:`Enter a time at or before ${a(r)}.`}return`Enter a time in ${this._step()}-minute steps.`}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value),this._isOpen=null;let e=this.getAttribute(`size`),t=e===`sm`?` input-sm`:e===`lg`?` input-lg`:``,n=this._uid;this.innerHTML=`
|
|
2
|
-
<div class="timepicker">
|
|
3
|
-
<div class="wui-timepicker-field">
|
|
4
|
-
<input type="text" class="input timepicker-trigger${t}" id="${n}-input" role="combobox" aria-haspopup="dialog" aria-expanded="false" aria-controls="${n}-pop" aria-autocomplete="none" autocomplete="off" spellcheck="false">
|
|
5
|
-
<button type="button" class="wui-timepicker-toggle" tabindex="-1" aria-label="Choose time" aria-haspopup="dialog" aria-expanded="false" aria-controls="${n}-pop">${s(`clock`)}</button>
|
|
6
|
-
</div>
|
|
7
|
-
<div class="timepicker-pop" id="${n}-pop" role="dialog" aria-label="Choose time" hidden></div>
|
|
8
|
-
<div class="field-error wui-timepicker-error" id="${n}-error" hidden></div>
|
|
9
|
-
</div>`,this._rendered=!0,this._syncAttrs(),this._syncText(),this._syncInvalid(),o(this,this._value),this._wire()}_input(){return m(this,`.timepicker-trigger`,HTMLInputElement)}_pop(){return m(this,`.timepicker-pop`,HTMLDivElement)}_syncFormValue(){o(this,this._value)}_syncAttrs(){let e=this._input(),t=m(this,`.wui-timepicker-toggle`,HTMLButtonElement);if(!e)return;let n=this.hasAttribute(`disabled`);e.disabled=n,e.readOnly=a(this),t&&(t.disabled=n),i(this,e),e.placeholder=this.getAttribute(`placeholder`)||`Select time`,this.hasAttribute(`required`)?e.setAttribute(`aria-required`,`true`):e.removeAttribute(`aria-required`);let r=this.getAttribute(`aria-label`);r?e.setAttribute(`aria-label`,r):e.removeAttribute(`aria-label`),o(this,this._value),a(this)&&this._isOpen?.()&&this._close({commit:!1})}_syncText(){let e=this._input();e&&(e.value=f(d(this._value),this._format()),this._isOpen?.()&&this._syncColumns())}_syncInvalid(){let e=this._input(),t=m(this,`.wui-timepicker-error`,HTMLDivElement);if(!e||!t)return;let n=this._typedError;t.textContent=n,t.hidden=!n,this.hasAttribute(`aria-invalid`)||n?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`);let r=[this.getAttribute(`aria-describedby`),n?t.id:null].filter(Boolean).join(` `);r?e.setAttribute(`aria-describedby`,r):e.removeAttribute(`aria-describedby`),e.setCustomValidity?.(n)}_commitText(){let e=this._input();if(!e||e.value===f(d(this._value),this._format()))return!0;let t=e.value.trim(),n=``;if(t){let e=p(t),r=e?this._refusal(e):`Enter a time like ${this._format()===`12`?`7:45 PM`:`19:45`}.`;if(!e||r)return this._typedError=r,this._syncInvalid(),!1;n=u(e.h,e.m)}let r=n!==this._value;return this.value=n,r&&this.dispatchEvent(new Event(`change`,{bubbles:!0})),!0}_pending(){let e=p(this._input()?.value);return e&&this._allowed(e.h,e.m)?e:null}_columnsHtml(){let e=this._format(),t=this._times(),n=(e,t,n)=>`<div class="wui-timepicker-col" role="listbox" aria-label="${t}" data-col="${e}">${n.map(e=>`<button type="button" class="timepicker-option" role="option" tabindex="-1" aria-selected="false" data-v="${e.v}">${e.text}</button>`).join(``)}</div>`,r=[...new Set(t.map(e=>e.h))],i=[...new Set(t.map(e=>e.m))].sort((e,t)=>e-t),a;if(e===`12`){let e=[...new Set(r.map(e=>e%12))].sort((e,t)=>e-t),t=[...new Set(r.map(e=>e>=12?`pm`:`am`))].sort();a=n(`hour`,`Hour`,e.map(e=>({v:e,text:String(e||12)})))+n(`minute`,`Minute`,i.map(e=>({v:e,text:l(e)})))+n(`period`,`AM or PM`,t.map(e=>({v:e,text:e.toUpperCase()})))}else a=n(`hour`,`Hour`,r.map(e=>({v:e,text:l(e)})))+n(`minute`,`Minute`,i.map(e=>({v:e,text:l(e)})));return`<div class="wui-timepicker-cols">${a}</div>`}_selectedIn(e,t){return t?e===`minute`?String(t.m):e===`period`?t.h>=12?`pm`:`am`:String(this._format()===`12`?t.h%12:t.h):null}_optionEnabled(e,t,n){if(!n)return!0;let r=this._format()===`12`,i=n.h>=12,a=e=>r?[e+(i?12:0)]:[e],o=Array.from({length:60},(e,t)=>t);if(e===`hour`)return a(Number(t)).some(e=>o.some(t=>this._allowed(e,t)));if(e===`minute`)return this._allowed(n.h,Number(t));let s=t===`pm`?12:0;return Array.from({length:12},(e,t)=>s+t).some(e=>o.some(t=>this._allowed(e,t)))}_syncColumns({scroll:e=!1}={}){let t=this._pop();if(!t)return;let n=this._pending();for(let r of h(t,`.wui-timepicker-col`,HTMLElement)){let t=r.dataset.col,i=this._selectedIn(t,n),a=h(r,`.timepicker-option`,HTMLButtonElement),o=null;for(let e of a){let r=e.dataset.v===i;e.classList.toggle(`is-selected`,r),e.setAttribute(`aria-selected`,r?`true`:`false`),e.disabled=!r&&!this._optionEnabled(t,e.dataset.v,n),r&&(o=e)}o=o||a.find(e=>!e.disabled)||null;for(let e of a)e.tabIndex=e===o?0:-1;e&&o&&(r.scrollTop=o.offsetTop-(r.clientHeight-o.offsetHeight)/2)}}_pick(e,t){let n=this._times(),r=n[0];if(!r)return;let i=this._pending()||r,a=this._format()===`12`,o=i.h,s=i.m;if(e===`minute`?s=Number(t):o=e===`period`?o%12+(t===`pm`?12:0):a?Number(t)+(i.h>=12?12:0):Number(t),!this._allowed(o,s)){let t=o*60+s,r=n.filter(t=>e===`minute`?t.m===s:e===`period`?t.h>=12==o>=12:a?t.h%12==o%12&&t.h>=12==o>=12:t.h===o).sort((e,n)=>Math.abs(e.h*60+e.m-t)-Math.abs(n.h*60+n.m-t))[0];if(!r)return;o=r.h,s=r.m}let c=this._input();c&&(c.value=f({h:o,m:s},this._format()),this._typedError=``,this._syncInvalid(),this._syncColumns())}_position(){n(m(this,`.wui-timepicker-field`,HTMLElement),this._pop())}_onColumnKey(e){let t=e.target instanceof Element?g(e.target,`.timepicker-option`,HTMLButtonElement):null,n=t&&g(t,`.wui-timepicker-col`,HTMLElement);if(!t||!n)return;let r=h(n,`.timepicker-option`,HTMLButtonElement).filter(e=>!e.disabled),i=r.indexOf(t),a=this._pop();if(!a)return;let o=h(a,`.wui-timepicker-col`,HTMLElement),s=e=>{e&&(this._pick(n.dataset.col,e.dataset.v),(m(n,`.timepicker-option.is-selected`,HTMLElement)||e).focus())};switch(e.key){case`ArrowDown`:e.preventDefault(),s(r[Math.min(i+1,r.length-1)]);return;case`ArrowUp`:e.preventDefault(),s(r[Math.max(i-1,0)]);return;case`Home`:e.preventDefault(),s(r[0]);return;case`End`:e.preventDefault(),s(r[r.length-1]);return;case`PageDown`:e.preventDefault(),s(r[Math.min(i+8,r.length-1)]);return;case`PageUp`:e.preventDefault(),s(r[Math.max(i-8,0)]);return;case`ArrowRight`:case`ArrowLeft`:{e.preventDefault();let t=o[o.indexOf(n)+(e.key===`ArrowRight`?1:-1)];(t&&m(t,`.timepicker-option[tabindex="0"]`,HTMLButtonElement))?.focus();return}case`Enter`:if(!c(e))return;e.preventDefault(),this._close({commit:!0,refocus:!0});return;case` `:e.preventDefault(),s(t);return;case`Escape`:e.preventDefault(),e.stopPropagation(),this._close({commit:!1,refocus:!0});return;default:e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),clearTimeout(this._typeaheadTimer),this._typeahead+=e.key.toLowerCase(),this._typeaheadTimer=window.setTimeout(()=>{this._typeahead=``,this._typeaheadTimer=void 0},500),s(r.find(e=>(e.textContent??``).trim().toLowerCase().startsWith(this._typeahead))))}}_wire(){this._teardown();let n=this._input(),r=m(this,`.wui-timepicker-toggle`,HTMLButtonElement),i=this._pop(),o=m(this,`.timepicker`,HTMLDivElement);if(!n||!i)return;let s=()=>!i.hidden;this._isOpen=s;let l=()=>{s()&&this._position()},u=()=>m(i,`.wui-timepicker-col .timepicker-option[tabindex="0"]`,HTMLElement)?.focus();this._open=({focus:t=!1}={})=>{a(this)||(s()||(i.innerHTML=this._columnsHtml(),i.hidden=!1,o?.classList.add(`open`),n.setAttribute(`aria-expanded`,`true`),r?.setAttribute(`aria-expanded`,`true`),this._position(),e(this,l),this._syncColumns({scroll:!0})),t&&u())},this._close=({commit:e=!0,refocus:a=!1}={})=>{if(!s())return;let c=i.contains(document.activeElement);i.hidden=!0,i.innerHTML=``,o?.classList.remove(`open`),n.setAttribute(`aria-expanded`,`false`),r?.setAttribute(`aria-expanded`,`false`),t(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=void 0,this._typeahead=``,e?this._commitText():(this._typedError=``,this._syncText(),this._syncInvalid()),(a||c)&&n.focus()},n.addEventListener(`pointerdown`,e=>{this._lastPointer=e.pointerType}),n.addEventListener(`click`,()=>{this._lastPointer!==`touch`&&!s()&&this._open(),this._lastPointer=null}),r?.addEventListener(`click`,()=>{s()?this._close({commit:!0,refocus:!0}):this._open({focus:!0})}),n.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._open({focus:!0});else if(c(e)){let t=s(),n=this._commitText();t&&n&&this._close({commit:!1}),(!n||t)&&e.preventDefault()}else e.key===`Escape`&&s()?(e.preventDefault(),e.stopPropagation(),this._close({commit:!1})):e.key===`Tab`&&s()&&this._close({commit:!0})}),n.addEventListener(`input`,e=>{e.stopPropagation(),this._typedError&&(this._typedError=``,this._syncInvalid()),s()&&this._syncColumns({scroll:!0})}),n.addEventListener(`change`,e=>{e.stopPropagation(),s()||this._commitText()}),i.addEventListener(`click`,e=>{let t=e.target instanceof Element?g(e.target,`.timepicker-option`,HTMLButtonElement):null,n=t&&g(t,`.wui-timepicker-col`,HTMLElement);t&&n&&!t.disabled&&this._pick(n.dataset.col,t.dataset.v)}),i.addEventListener(`keydown`,e=>{s()&&this._onColumnKey(e)}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{s()&&!e.composedPath().includes(this)&&this._close({commit:!0})},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{s()&&e.key===`Escape`&&this._close({commit:!1})},document.addEventListener(`keydown`,this._onDocKey),this._onHostKey=e=>{s()&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this._close({commit:!1,refocus:!0}))},this.addEventListener(`keydown`,this._onHostKey),s()&&e(this,l)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),this._onHostKey&&=(this.removeEventListener(`keydown`,this._onHostKey),null),t(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=void 0,this._typeahead=``}disconnectedCallback(){this._teardown()}};export{y as t};
|