@webority/ui-elements 0.173.1 → 0.174.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{WuiCarousel-CFKmFVzc.js → WuiCarousel-B0yPDH5I.js} +1 -1
- package/dist/WuiCodeBlock-BJ14DaLH.js +1 -0
- package/dist/{WuiCommandPalette-BQCy0bon.js → WuiCommandPalette-u1XD5WMv.js} +2 -2
- package/dist/WuiCommentThread-ChTsQWet.js +1 -0
- package/dist/{WuiConsentBanner-DlAE3DTf.js → WuiConsentBanner-nTua-kEd.js} +1 -1
- package/dist/{WuiDataTable-B-JaTsrI.js → WuiDataTable-3Vd8EAMV.js} +1 -1
- package/dist/{WuiDatePicker-4tdWakGX.js → WuiDatePicker-CPr0Yni3.js} +1 -1
- package/dist/{WuiDateRange-D7LJuY2F.js → WuiDateRange-DvuE4wfG.js} +1 -1
- package/dist/{WuiDateTime-BSJfyZ0q.js → WuiDateTime-Vimu6grS.js} +1 -1
- package/dist/{WuiDrawer-D-XfW1kl.js → WuiDrawer-BsY0fs_u.js} +1 -1
- package/dist/WuiGantt-DJat5idS.js +1 -0
- package/dist/{WuiImageCrop-CIAjHOGk.js → WuiImageCrop-UakcSM2k.js} +1 -1
- package/dist/{WuiInlineEdit-C9FxCWCk.js → WuiInlineEdit-Bfe_m5px.js} +1 -1
- package/dist/{WuiLeadPopup-KyguGV-q.js → WuiLeadPopup-DaYZ2zCJ.js} +1 -1
- package/dist/{WuiLightbox-CBiqJmGE.js → WuiLightbox-CuzbFBck.js} +1 -1
- package/dist/WuiMentionInput-Dmtm3N62.js +1 -0
- package/dist/{WuiNotificationCenter-DZariS2K.js → WuiNotificationCenter-1Hw7W0st.js} +1 -1
- package/dist/{WuiOrgTree-CFxoY9Vr.js → WuiOrgTree-DYMNCGTh.js} +1 -1
- package/dist/{WuiOverflow-CXYk2ubC.js → WuiOverflow-fZKqdsr-.js} +1 -1
- package/dist/{WuiPhone-BI438y4S.js → WuiPhone-BEyz-J2q.js} +1 -1
- package/dist/{WuiRecordPager-DAyoD650.js → WuiRecordPager-BXoe4KfU.js} +1 -1
- package/dist/{WuiRelativeTime-CPzs4tjM.js → WuiRelativeTime-CSg9vzfk.js} +1 -1
- package/dist/{WuiSavedViews-BAqHgVj2.js → WuiSavedViews-OjB-ZiCo.js} +1 -1
- package/dist/WuiSelect-C_nfrNr5.js +1 -0
- package/dist/{WuiShortcuts-DWzmRKEG.js → WuiShortcuts-CRCctX82.js} +1 -1
- package/dist/{WuiShowMore-DyfGnrob.js → WuiShowMore-BoYCrYYf.js} +1 -1
- package/dist/{WuiSlider-LE2wquOo.js → WuiSlider-R_mTula0.js} +1 -1
- package/dist/{WuiSortable-DxwYjicc.js → WuiSortable-x8Mg0tOv.js} +1 -1
- package/dist/{WuiTimePicker-xrPYytjq.js → WuiTimePicker-Bcc1PfCT.js} +1 -1
- package/dist/{WuiTour-D-H5sMJS.js → WuiTour-C71Wmed-.js} +1 -1
- package/dist/WuiTree-BQk23SSF.js +1 -0
- package/dist/WuiTreePicker-DP1lCno3.js +1 -0
- package/dist/{WuiWizardStep-n8Ge5GDI.js → WuiWizardStep-Uag__kTu.js} +1 -1
- package/dist/buttonClass-C8BRtTk8.js +1 -0
- package/dist/{calendarMath-rI1aBVRd.js → calendarMath-CT99RyhR.js} +1 -1
- package/dist/chips-BaB5xZXq.js +2 -0
- package/dist/{country-B7jmc--B.js → country-T7AfpJpN.js} +1 -1
- package/dist/{customRule-BXJdj57A.js → customRule-BpwcjVLb.js} +1 -1
- package/dist/{dataTable-Bz6HxUx0.js → dataTable-VB3nBucm.js} +1 -1
- package/dist/drawerDiscard-DGmosZR2.js +1 -0
- package/dist/elements/carousel.js +1 -1
- 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/consent-banner.js +1 -1
- package/dist/elements/data-table.js +1 -1
- package/dist/elements/date-range.js +1 -1
- package/dist/elements/date-time.js +1 -1
- package/dist/elements/datepicker.js +1 -1
- package/dist/elements/drawer.js +1 -1
- package/dist/elements/filter-popover.js +1 -1
- package/dist/elements/gantt.js +1 -1
- package/dist/elements/image-crop.js +1 -1
- package/dist/elements/inline-edit.js +1 -1
- package/dist/elements/kanban.js +1 -1
- package/dist/elements/lead-popup.js +1 -1
- package/dist/elements/lightbox.js +1 -1
- package/dist/elements/mention-input.js +1 -1
- package/dist/elements/notification-center.js +1 -1
- package/dist/elements/org-tree.js +1 -1
- package/dist/elements/overflow.js +1 -1
- package/dist/elements/phone.js +1 -1
- package/dist/elements/record-pager.js +1 -1
- 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/show-more.js +1 -1
- package/dist/elements/slider.js +1 -1
- package/dist/elements/sortable.js +1 -1
- package/dist/elements/timepicker.js +1 -1
- package/dist/elements/tour.js +1 -1
- package/dist/elements/tree-picker.js +1 -1
- package/dist/elements/tree.js +1 -1
- package/dist/elements/wizard.js +1 -1
- package/dist/fileViewer.g-DupSpQYS.js +1 -0
- package/dist/{fileViewerImage-ItX9j9U9.js → fileViewerImage-CCtdOYm3.js} +1 -1
- package/dist/{fileViewerMedia-BCqp2Z96.js → fileViewerMedia-Dbwn694I.js} +1 -1
- package/dist/{fileViewerPdf-aaI2R2nB.js → fileViewerPdf-Lu6vcnYW.js} +1 -1
- package/dist/{filterPopover-D7LGrhnO.js → filterPopover-DskHFNLi.js} +1 -1
- package/dist/{formatters-DikbTYA4.js → formatters-DTW53DjY.js} +1 -1
- package/dist/hasOwn-CJsplJ62.js +1 -0
- package/dist/helpers.js +1 -1
- package/dist/iconGlyphs.g-Dj8sa1HF.js +1 -0
- package/dist/{inlineEditText-C6g6qhye.js → inlineEditText-DRBhMnam.js} +1 -1
- package/dist/kanban-DlVHIpxL.js +1 -0
- package/dist/{kanbanModel-CuMgMnSc.js → kanbanModel-BzXK4SkM.js} +1 -1
- package/dist/{loader-B3lirubB.js → loader-C2hgZrCR.js} +1 -1
- package/dist/{notificationDays-grsj1DtM.js → notificationDays-wMr8rZko.js} +1 -1
- package/dist/{optionLabel-CmrOSHbD.js → optionLabel-CghX6DYo.js} +1 -1
- package/dist/{recents-BQ0fD7Y0.js → recents-B9efQ1Au.js} +1 -1
- package/dist/{relativeTime-vdCXtfKg.js → relativeTime-CNgauvqB.js} +1 -1
- package/dist/{search-DwboX91o.js → search-Cj1eEPIN.js} +1 -1
- package/dist/server.js +1 -1
- package/dist/{shortcutKeys-6iLc6oDR.js → shortcutKeys-BMTWgV2g.js} +1 -1
- package/dist/text.js +1 -1
- package/dist/textStore-DBplASiZ.js +1 -0
- package/dist/{themeTransition-D7HJ4A4m.js → themeTransition-CRnGw929.js} +1 -1
- package/dist/ui-calendar.global.js +1 -1
- package/dist/ui-calendar.js +1 -1
- package/dist/ui-chart.global.js +2 -2
- package/dist/ui-chart.js +2 -2
- package/dist/ui-consent-banner.global.js +1 -1
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +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 +1 -1
- package/dist/ui-elements/date-time.global.js +1 -1
- package/dist/ui-elements/datepicker.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/dropdown.global.js +1 -1
- package/dist/ui-elements/entry-grid.global.js +1 -1
- package/dist/ui-elements/gantt.global.js +1 -1
- package/dist/ui-elements/glyphs.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -1
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lead-popup.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +1 -1
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/popover.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +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/select-window.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/table-export.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree-picker.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +1 -1
- package/dist/ui-elements.js +1 -1
- package/dist/ui-file-viewer.global.js +10 -10
- package/dist/ui-file-viewer.js +1 -1
- package/dist/ui-lead-popup.global.js +1 -1
- package/dist/ui-rich-text.global.js +51 -51
- package/dist/ui-rich-text.js +53 -53
- package/dist/ui-tour.global.js +1 -1
- package/package.json +5 -5
- package/types/global/shared.d.ts +2 -0
- package/types/hasOwn.d.ts +1 -0
- package/dist/WuiCodeBlock-fBc3Uwsw.js +0 -1
- package/dist/WuiCommentThread-B58UyYGD.js +0 -1
- package/dist/WuiGantt-XMvgsZsn.js +0 -1
- package/dist/WuiMentionInput-CktKQjQc.js +0 -1
- package/dist/WuiSelect-htggZB0v.js +0 -1
- package/dist/WuiTree-BnlK9fYL.js +0 -1
- package/dist/WuiTreePicker-Bx9nvRrC.js +0 -1
- package/dist/buttonClass-GtEi8hAY.js +0 -1
- package/dist/chips-DrTvHdbb.js +0 -2
- package/dist/drawerDiscard-B33Oc_Sv.js +0 -1
- package/dist/fileViewer.g-B6N9K2xi.js +0 -1
- package/dist/iconGlyphs.g-P04RJkSE.js +0 -1
- package/dist/kanban-CX6DyApZ.js +0 -1
- package/dist/textStore-opIEM4lu.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./anchorOverlay-daGdh_91.js";import{t}from"./avatarNode-BaEvz5Xr.js";import{n}from"./devWarn-DXdRWZs3.js";import{i as r,r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{r as o,t as s}from"./fieldState-D-zQcXUS.js";import{n as c,t as l}from"./formMirror-9IpSgeZb.js";import{n as u}from"./loader-C2hgZrCR.js";import{t as d}from"./iconGlyphs.g-Dj8sa1HF.js";import{t as f}from"./imeSafeEnter-DPs9qL3S.js";import{n as p,t as m}from"./listboxKeyNav-DtlIOryj.js";import{a as h,l as g,s as _}from"./nativeOverlay-BHD2QV02.js";import{i as v,n as y,t as b}from"./optionLabel-CghX6DYo.js";import{r as x}from"./textStore-DBplASiZ.js";import{n as S,r as C,t as w}from"./search.g-B5d1s59A.js";import{t as T}from"./hasOwn-CJsplJ62.js";import{n as E,r as D,t as O}from"./window-BZWK3rQk.js";var k=()=>x(`select`,C);function A(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[y(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var j=/* @__PURE__ */ new WeakMap,M=e=>e?{"data-index":String(e.index),"aria-setsize":String(e.size),"aria-posinset":String(e.index+1)}:{},N=e=>e.map(e=>e instanceof Element?e.outerHTML:e.textContent??``).join(``),P;function F(e){P=e}function I(e){P?.clear(e),j.delete(e),e.replaceChildren()}function L(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=k().emptyText,searchingText:c=k().searchingText,hintText:l=k().hintText,actionRow:u=[],recents:d=null}=n,f=new Set(r.map(String)),p=A(t,a),m=e.id,h=u.filter(e=>e.position===`top`),g=u.filter(e=>e.position===`bottom`),_=d?.options.length?d.options:[],v=h.length+_.length+p.length+g.length,y=p.length>300,b=P,x=y&&b!==void 0,S=e=>x?{index:e,size:v}:void 0,C=0,w=e=>{let t=C++;return i(`button`,{type:`button`,role:`option`,id:R(m,t),class:`wui-select-option wui-select-add`,"data-value":String(e.value??``),"data-custom":`true`,"aria-selected":`false`,...M(S(t))},e.label)},T=e=>{let t=C++;return V(e,R(m,t),f.has(String(e.value)),S(t))},E=h.map(w),D=_.length&&d?[i(`div`,{class:`wui-select-group`},d.label),..._.map(T),i(`div`,{class:`wui-select-sep`,"aria-hidden":`true`})]:[],O=C,F=[];if(x)C+=p.length;else{let e=``;for(let t of p)t.group&&t.group!==e&&F.push(i(`div`,{class:`wui-select-group`},t.group)),e=t.group??``,F.push(T(t))}let I=g.map(w),L=[];if(o===`loading`?L=[i(`div`,{class:`wui-select-loading`},i(`span`,{class:`wui-select-spinner spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`}),c)]:o===`hint`?L=[i(`div`,{class:`wui-select-hint`},l)]:(o===`empty`||p.length===0&&u.length===0)&&(L=[i(`div`,{class:`wui-select-empty`},s)]),x&&b){let n=[...E,...D],r=[...I,...L];return b.render(e,{options:t,query:a,rows:p,pre:n,post:r,preSig:N(n),postSig:N(r),picked:f,top:h,recent:_,bottom:g,bodyBase:O,total:v}),{rows:v,windowed:!0,long:y}}b?.clear(e);let z=[...E,...D,...F,...I,...L],B=N(z);return j.get(e)===B||(j.set(e,B),e.replaceChildren(...z)),{rows:C,windowed:!1,long:y}}var R=(e,t)=>`${e}-opt-${t}`,z=e=>[...e.querySelectorAll(`.wui-select-option`)];function B(e){return P?P.refresh(e):!1}function ee(e,t){return P?P.reveal(e,t):z(e)[t]??null}function te(e,t){if(P)return P.indexOfValue(e,t);let n=new Set(t.map(String));return z(e).findIndex(e=>n.has(e.dataset.value??``))}function ne(e,t){return P?P.indexByPrefix(e,t):z(e).findIndex(e=>(e.textContent??``).trim().toLowerCase().startsWith(t))}function V(e,n,r,a){let o=!!e.disabled,s={id:n,role:`option`,"data-value":String(e.value??``),"aria-selected":String(r),"aria-disabled":o?`true`:void 0,title:o&&e.disabledHint?e.disabledHint:void 0,...M(a)},c=i(`span`,{class:`wui-select-check`,"aria-hidden":`true`},d(`check`));if(!e.description&&!e.meta)return i(`button`,{type:`button`,class:`wui-select-option${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-opt-name`},...b(e)),c);let l=e.description?i(`span`,{class:`wui-select-opt-desc`},e.description):null,u=e.meta?i(`span`,{class:`wui-select-opt-meta`},e.meta):null;return i(`div`,{class:`wui-select-option wui-select-option-rich${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-option-text`},i(`span`,{class:`wui-opt-label`},...b(e)),l),u,c)}var re=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),H=e=>e===`multiple`||e===`tag`,ie={recents:()=>import(`./recents-B9efQ1Au.js`),chips:()=>import(`./chips-BaB5xZXq.js`),search:()=>import(`./search-Cj1eEPIN.js`),country:()=>import(`./country-T7AfpJpN.js`)};function ae(e){let t=T(ie,e)?ie[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var U=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),oe=300,W=`<div class="wui-select-spacer" aria-hidden="true"></div>`,G=()=>i(`div`,{class:`wui-select-spacer`,"aria-hidden":`true`}),K=/* @__PURE__ */ new WeakMap;function se(e,t,n,r){let i=K.get(e);if(i&&i.options===t&&i.query===n&&i.count===r.length)return i;let a=[],o=new Int32Array(r.length),s=``;r.forEach((e,t)=>{e.group&&e.group!==s&&a.push({kind:`group`,label:e.group}),s=e.group??``,o[t]=a.length,a.push({kind:`option`,option:e,ord:t})});let c={options:t,query:n,count:r.length,entries:a,optionEntry:o,heights:O(a.length),estimated:!1,bodyTop:0,start:0,end:0,pre:[],post:[],preSig:``,postSig:``,picked:/* @__PURE__ */ new Set,top:[],recent:[],bottom:[],bodyBase:0,total:0};return K.set(e,c),e.scrollTop=0,c}var q=e=>e.clientHeight||oe,J=(e,t)=>D(t.heights,{scrollTop:Math.max(0,e.scrollTop-t.bodyTop),viewport:q(e)});function ce(e,t,n,r){let a=[];for(let o=n;o<r;o++){let n=e.entries[o];if(n){if(n.kind===`group`)a.push(i(`div`,{class:`wui-select-group`,"data-entry":o},n.label));else{let r=e.bodyBase+n.ord;a.push(V(n.option,R(t,r),e.picked.has(String(n.option.value)),{index:r,size:e.total}))}}}return a}function le(e,t){let[n,r]=e.querySelectorAll(`.wui-select-spacer`);n&&r&&(n.style.flex=r.style.flex=`none`,n.style.height=`${t.heights.offsetOf(t.start)}px`,r.style.height=`${t.heights.total()-t.heights.offsetOf(t.end)}px`)}function ue(e,t){let{start:n,end:r}=J(e,t);t.start=n,t.end=r;let i=ce(t,e.id,n,r),a=t.preSig+W+N(i)+W+t.postSig,o=e.scrollTop;j.get(e)!==a&&(j.set(e,a),e.replaceChildren(...t.pre,G(),...i,G(),...t.post)),le(e,t),e.scrollTop!==o&&(e.scrollTop=o)}function de(e,t){let n={changed:!1,delta:0};if(!e.clientHeight)return n;let{heights:r}=t,i=e.querySelector(`.wui-select-spacer`),a=[],o=!0,s=!1;if(i){let n=i.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;Math.abs(n-t.bodyTop)>.5&&(t.bodyTop=n,s=!0)}let c=r.indexAt(Math.max(0,e.scrollTop-t.bodyTop)),l=r.offsetOf(c),u=0;for(let n of e.querySelectorAll(`.wui-select-option[data-index], .wui-select-group[data-entry]`)){let e=n.getBoundingClientRect().height;if(n.dataset.entry!==void 0)a.push([Number(n.dataset.entry),e]);else{let r=Number(n.dataset.index)-t.bodyBase,i=r>=0?t.optionEntry[r]:void 0;if(i===void 0)continue;o&&(u=e),o=!1,a.push([i,e])}}if(!t.estimated&&u>0){let e=r.estimate;r.setEstimate(u),t.estimated=!0,r.estimate!==e&&(s=!0)}for(let[e,t]of a)r.set(e,t)&&(s=!0);return s?{changed:s,delta:r.offsetOf(c)-l}:n}function Y(e,t){ue(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=de(e,t);if(!n)return;le(e,t),r&&(e.scrollTop+=r),ue(e,t)}}function fe(e,t){let n=se(e,t.options,t.query,t.rows);Object.assign(n,{pre:t.pre,post:t.post,preSig:t.preSig,postSig:t.postSig,picked:t.picked,top:t.top,recent:t.recent,bottom:t.bottom,bodyBase:t.bodyBase,total:t.total}),Y(e,n)}function pe(e){let t=K.get(e);if(!t)return!1;let{start:n,end:r}=J(e,t);return n===t.start&&r===t.end?!1:(Y(e,t),!0)}function me(e,t){let n=K.get(e);if(!n||t<0||t>=n.total)return null;let r=t-n.bodyBase,i=r>=0?n.optionEntry[r]:void 0,a=()=>e.querySelector(`[data-index="${t}"]`);if(i===void 0)return a();for(let t=0;t<2;t++){let t={scrollTop:e.scrollTop-n.bodyTop,viewport:q(e)},r=n.bodyTop+E(n.heights,i,t);if(Math.abs(r-e.scrollTop)>.5)e.scrollTop=r;else if(a())break;Y(e,n)}return a()}function he(e,t){if(t<0||t>=e.total)return;if(t<e.top.length)return e.top[t];let n=t-e.top.length;if(n<e.recent.length)return e.recent[n];let r=t-e.bodyBase;if(r<e.count){let t=e.entries[e.optionEntry[r]??-1];return t?.kind===`option`?t.option:void 0}return e.bottom[r-e.count]}var ge=e=>e&&!(`position`in e)?e:void 0;function _e(e,t){let n=K.get(e);if(!n||t.length===0)return-1;let r=new Set(t.map(String));for(let e=0;e<n.total;e++){let t=ge(he(n,e));if(t&&r.has(String(t.value)))return e}return-1}var ve=e=>`position`in e?e.label:`${e.initials??``}${y(e)}${e.description??``}${e.meta??``}`;function ye(e,t){let n=K.get(e);if(!n)return-1;for(let e=0;e<n.total;e++){let r=he(n,e);if(r&&ve(r).trim().toLowerCase().startsWith(t))return e}return-1}F({render:fe,refresh:pe,reveal:me,indexOfValue:_e,indexByPrefix:ye,clear(e){K.delete(e)}});function be(){return Promise.resolve()}var X=()=>x(`select`,C),xe=()=>x(`search`,w),Se=()=>x(`field`,S),Ce=class extends a{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_rows;_windowed;_windowLoad;_windowFailed;_scrollFrame;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_panelShown;_pressOpen;static get observedAttributes(){return/* @__PURE__ */ `mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.open-on-hover.lazy-options.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._rows=0,this._windowed=!1,this._windowLoad=null,this._windowFailed=!1,this._scrollFrame=null,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._searchShown=!1,this._defaultValue=void 0,this._warnedMode=null,this._hoverTimer=null,this._hoverOpened=!1,this._panelShown=!1,this._pressOpen=null,this._onHoverOver=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&(this._clearHover(),!this._menuOpen()&&this._hoverEligible()&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,!this._menuOpen()&&this._hoverEligible()&&(this._open({focus:!1}),this._hoverOpened=!0)},De)))},this._onHoverOut=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&!this._hoverZone(e.relatedTarget)&&(this._clearHover(),this._menuOpen()&&this.hasAttribute(`open-on-hover`)&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._close()},Oe)))}}connectedCallback(){this.addEventListener(`pointerover`,this._onHoverOver),this.addEventListener(`pointerout`,this._onHoverOut),this._rendered||this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this.removeEventListener(`pointerover`,this._onHoverOver),this.removeEventListener(`pointerout`,this._onHoverOut),this._clearHover(),this._dropMenu(),this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`value`?(this._value=Z(n,H(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):e===`open-on-hover`?this.hasAttribute(`open-on-hover`)||this._clearHover():e!==`lazy-options`&&(e===`mode`&&(this._value=Z(this._value,H(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),Me.has(e)?this._rendered&&(this._drawValue(),this.renderList()):je.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null?`single`:Te(e)?e:(e!==this._warnedMode&&(this._warnedMode=e,n(`<wui-select> mode "${e}" is not one of ${re.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||Ee.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,n(`<wui-select> density "${e}" is not one of ${Ee.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=Z(e,H(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();if(this._rendered){if(this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._autoSearch()!==this._searchShown){this.render();return}this._drawValue(),this.renderList()}}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){s(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();if(!e.list)return;let t=this._ownsFilter?``:this._query,n=this._actionRows(),r=this._recents();if(this.hasAttribute(`lazy-options`)&&!this._menuOpen()){this._rows=A(this._listOptions(),t).length+n.length+(r?.options.length??0),this._windowed=!1,I(e.list),this._anchorMenu();return}let i=L(e.list,this._listOptions(),{selected:this._selectedValues(),query:t,status:this._status,emptyText:this.getAttribute(`empty-text`)||X().emptyText,searchingText:this.getAttribute(`searching-text`)||X().searchingText,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:n,recents:r});this._rows=i.rows,this._windowed=i.windowed,i.long&&!i.windowed&&!this._windowFailed&&this._loadWindow(),this._active>=this._rowCount()&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._anchorMenu()}render(){this._dropMenu();let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=H(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=Z(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=Z(this._value,n));let s=this.getAttribute(`size`),c=s===`sm`?` wui-select-sm`:s===`lg`?` wui-select-lg`:s===`xl`?` wui-select-xl`:``,l=this.getAttribute(`icon`),u=this.getAttribute(`prefix`),f=this.hasAttribute(`clearable`),p=this.hasAttribute(`disabled`);this.id||=`wui-select-${Math.random().toString(36).slice(2,9)}`;let m=`${this.id}-listbox`,h=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${h}`:h,v=this.hasAttribute(`aria-invalid`)||!!this._error,y=this.hasAttribute(`required`)&&!a,b=this._accessibleName(),x=a?{}:{role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":m},S={"aria-label":b,"aria-describedby":_,"aria-invalid":v?`true`:void 0,"aria-required":y?`true`:void 0},C=n?i(`div`,{class:`input wui-select-control wui-select-multi`,...x,...S,"aria-disabled":p?`true`:void 0,tabindex:!p&&!r?`0`:void 0}):i(`button`,{type:`button`,class:`input wui-select-control`,...x,...S,disabled:p||void 0}),w=[l?d(l,{className:`wui-select-icon`}):null,u?i(`span`,{class:`wui-select-prefix`},u):null,i(`span`,{class:`wui-select-value`,"data-label":!0}),f?i(`span`,{class:`wui-select-reset`,role:`button`,"aria-label":X().clearSelectionLabel,hidden:!0},d(`x`)):null,d(`chevron-down`,{className:`wui-select-caret`})];C.append(...w.filter(e=>e!==null));let T=this.getAttribute(`searchable`),E=T===null?t===`multiple`||t===`country`||this._autoSearch():T!==`false`,D=t===`search`||E&&!a;this._searchShown=D;let O=this.getAttribute(`search-placeholder`)||(t===`country`?X().countrySearchPlaceholder:xe().placeholder),k=D?i(`div`,{class:`wui-select-search`},d(`search`),i(`input`,{class:`wui-select-input`,placeholder:O,"aria-label":O,"aria-autocomplete":`list`}),i(`button`,{type:`button`,class:`wui-select-clear`,"aria-label":xe().clearLabel,hidden:!0},d(`x`))):null,A=i(`div`,{class:`wui-select-options`,role:`listbox`,id:m,tabindex:`-1`,"aria-multiselectable":n?`true`:void 0}),j=i(`div`,{class:`wui-select-menu wui-select-menu-fixed`,popover:`auto`},k,A),M=i(`div`,{class:`field-error wui-select-error`,id:h,"aria-live":`polite`,hidden:!this._error||void 0},this._error||null);this.replaceChildren(i(`div`,{class:`wui-select${c}`},C,j),M),this._rendered=!0,this._syncMirror(),this._syncValidity(),this._drawValue(),this._syncReset(),this.renderList(),this._wire(),o(this,this.querySelector(`.wui-select-control`)),this._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||X().fallbackName}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t=document.createDocumentFragment();for(let n of e.childNodes)t.append(n.cloneNode(!0));let n={value:e.getAttribute(`value`)??$(e).trim(),label:t.textContent??``,selected:e.hasAttribute(`selected`)};for(let[t,r]of Ne){let i=e.getAttribute(t);i&&(n[r]=i)}return e.hasAttribute(`disabled`)&&(n.disabled=!0),v(n,t)}))}_readOptions(){return this.mode===`country`?this._partOptions||[]:this._partOptions?this._partOptions:this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_listOptions(){let e=this._readOptions(),t=this.getAttribute(`value-label`);if(this.mode!==`search`||!t||this._value===``)return e;let n=String(this._value);return e.some(e=>String(e.value)===n)?e:[...e,{value:n,label:t}]}_declaredSelected(){return this._optionsProp?[]:(this._declared??[]).filter(e=>e.selected).map(e=>String(e.value))}_preselect(){let e=this._readOptions(),t=this._value!==``&&e.find(e=>String(e.value)===this._value)||e.find(e=>`selected`in e&&!!e.selected);t&&(this._value=String(t.value))}_optionFor(e){let t=String(e),n=this._readOptions().find(e=>String(e.value)===t);return n?(this._known.set(t,n),n):this._known.get(t)}_placeholder(){return this.getAttribute(`placeholder`)||Ae()[this.mode]}_hasValue(){return Array.isArray(this._value)?this._value.length>0:this._value!==``}_selectedValues(){return Array.isArray(this._value)?this._value:this._value===``?this._listOptions().some(e=>String(e.value)===``)?[``]:[]:[this._value]}_applyValue(){this._syncMirror(),this._syncValidity(),this._rendered&&(this._drawValue(),this._syncReset(),this.renderList())}_syncMirror(){H(this.mode)?c(this,this._selectedValues()):l(this,this._value)}_drawValue(){let e=this._refs();if(!e.value)return;let t=H(this.mode),n=t?void 0:this._optionFor(this._value);if(this._syncTitle(n),this._syncValueAvatar(),this._activePartsList().some(e=>e.renderValue?.()===!0))return;if(t){e.value.classList.remove(`wui-select-placeholder`),e.value.textContent=``;return}e.value.classList.toggle(`wui-select-placeholder`,!n);let r=this._placeholder();e.value.replaceChildren(...n?b(n):r?[r]:[])}_syncTitle(e){let t=this.querySelector(`.wui-select-control`);if(!t)return;let n=e&&!this.hasAttribute(`title`)?y(e).trim():``;n?t.setAttribute(`title`,n):t.removeAttribute(`title`)}_syncValueAvatar(){let e=this.querySelector(`.wui-select-control`);if(!e)return;e.querySelector(`:scope > .wui-select-value-avatar`)?.remove();let n=!H(this.mode)&&this._hasValue()?t({avatar:this.getAttribute(`value-avatar`),initials:this.getAttribute(`value-initials`)},`avatar-xs`):null;e.classList.toggle(`wui-has-value-avatar`,!!n),n&&e.prepend(i(`span`,{class:`wui-select-value-avatar`,"aria-hidden":`true`},n))}_syncValidity(){let e=this._internals;if(typeof e?.setValidity==`function`){if(this.hasAttribute(`required`)&&!this._hasValue()){let t=this.querySelector(`.wui-select-control`);e.setValidity({valueMissing:!0},Se().requiredFieldMessage,t instanceof HTMLElement?t:void 0)}else e.setValidity({})}}_syncReset(){let e=Q(this,`.wui-select-reset`,HTMLElement);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!s(this)))}_syncInvalid(){let e=this.querySelector(`.wui-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._error?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}_syncError(){let e=Q(this,`.wui-select-error`,HTMLElement);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:Q(this,`.wui-select-control`,HTMLElement),value:Q(this,`.wui-select-value`,HTMLElement),menu:Q(this,`.wui-select-menu`,HTMLElement),list:Q(this,`.wui-select-options`,HTMLElement),search:Q(this,`.wui-select-search input`,HTMLInputElement),input:Q(this,`.wui-select-draft`,HTMLInputElement)}}_menuOpen(){let e=Q(this,`.wui-select-menu`,HTMLElement);return e!==null&&_(e)}_hoverZone(e){if(!(e instanceof Element))return!1;let t=e.closest(`.wui-select-control, .wui-select-menu`);return t!==null&&this.contains(t)}_hoverEligible(){if(!this.hasAttribute(`open-on-hover`)||s(this)||this.mode===`tag`)return!1;let e=this._refs();return e.search===null&&e.input===null}_clearHover(){this._hoverTimer!==null&&clearTimeout(this._hoverTimer),this._hoverTimer=null}_autoSearch(){return this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._readOptions().length>ke}_visible(){let e=this._refs();return e.list?Re(e.list,`.wui-select-option`):[]}_rowCount(){return this._windowed?this._rows:this._visible().length}_rowEl(e){if(!this._windowed)return this._visible()[e];let t=this._refs().list?.querySelector(`[data-index="${e}"]`);return t instanceof HTMLElement?t:void 0}_setActive(e,{reveal:t=!0}={}){let n=this._refs();if(!n.list||!n.control)return;this._active=e;let r=null;e>=0&&e<this._rowCount()&&(r=this._rowEl(e)??(this._windowed&&t?ee(n.list,e):null)),p(n.list,r),r?(t&&r.scrollIntoView({block:`nearest`}),n.control.setAttribute(`aria-activedescendant`,r.id)):n.control.removeAttribute(`aria-activedescendant`)}_onListScroll(){this._scrollFrame=null;let e=this._refs().list;e&&B(e)&&this._active>=0&&this._setActive(this._active,{reveal:!1})}_actionRows(){let e=[];for(let t of this._activePartsList()){let n=t.actionRow?.(this._query);n&&e.push(n)}return e}_recents(){if(this._query.trim()!==``)return null;for(let e of this._activePartsList()){let t=e.recents?.(this._listOptions());if(t)return t}return null}_menuPlacement(e,t){let n=this.hasAttribute(`open`)?{below:!0}:{};if(this.getAttribute(`density`)!==`compact`)return{matchWidth:!0,...n};let r=e.getBoundingClientRect();return t.style.width=`max-content`,t.style.minWidth=`${r.width}px`,t.style.maxWidth=`280px`,n}_anchorMenu(){let t=this._refs();t.control&&t.menu&&this._menuOpen()&&e(t.control,t.menu,this._menuPlacement(t.control,t.menu))}_showMenu(e,t){g(e,t,{...this._menuPlacement(e,t),mode:`auto`,keepOffscreen:this.hasAttribute(`open`),onClosed:()=>this._onPanelClosed()}),this._panelShown=!0}_onPanelClosed(){if(!this._panelShown)return;this._panelShown=!1;let e=this._refs();e.control&&(e.control.setAttribute(`aria-expanded`,`false`),this._setActive(-1),this._nav?.clearTypeahead(),this.dispatchEvent(new CustomEvent(`wui-select:close`,{bubbles:!0})))}_open({focus:e=!0}={}){let t=this._refs();if(!t.menu||!t.control)return;let n=this._menuOpen();this._hoverOpened=!1,t.control.setAttribute(`aria-expanded`,`true`),this._query=t.input?t.input.value:``,this._ownsFilter=this._ownsFilter&&this._query!==``;let r=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement);if(r&&(r.hidden=!0),t.search&&(t.search.value=``),n||this._showMenu(t.control,t.menu),this.renderList(),e&&(t.search?.focus(),this._setActive(this._windowed&&t.list?te(t.list,this._selectedValues()):this._visible().findIndex(e=>e.classList.contains(`selected`)))),!n){this.dispatchEvent(new CustomEvent(`wui-select:open`,{bubbles:!0}));for(let e of this._activePartsList())e.onOpen?.()}}_close({force:e=!1}={}){if(!e&&this.hasAttribute(`open`))return;let t=this._refs();if(!t.menu||!t.control)return;this._hoverOpened=!1;let n=t.menu.contains(document.activeElement);_(t.menu)&&h(t.menu),this._onPanelClosed(),n&&t.control.focus()}_onQueryChange(e){this._query=e,this._setActive(-1);let t=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement);t&&(t.hidden=!e);let n=!1;for(let t of this._activePartsList())t.onQuery?.(e)===!0&&(n=!0);this._ownsFilter=n,this.renderList()}_pick(e){if(e.getAttribute(`aria-disabled`)===`true`)return;let t=e.dataset.custom===`true`,n=e.dataset.value??``,r=t?{value:n,label:$(e).trim()}:this._listOptions().find(e=>String(e.value)===n)??{value:n,label:n},i=this._activePartsList().some(e=>e.onPick?.(r,{isCustom:t})===!0);H(this.mode)||(i||this.commit(n,{isCustom:t}),this._close(),this._refs().control?.focus())}_draftOpens(){return this.mode===`multiple`?this.hasAttribute(`allow-custom`):this.mode===`tag`&&U(this)}_onKeyDown(e){if(!s(this)){for(let t of this._activePartsList())if(t.onKey?.(e)===!0)return;if(!this._menuOpen()){if(e.target instanceof HTMLInputElement){if(e.key!==`ArrowDown`||!this._draftOpens())return;this._open({focus:!1})}else{(e.key===`ArrowDown`||f(e)||e.key===` `)&&(e.preventDefault(),this._open({focus:!0}));return}}r(this._nav,`Listbox keys are not wired.`).handler(e)}}_wire(){this._teardown();let e=this._refs(),t=e.control,n=e.list;if(!t||!e.menu||!n)return;let i=r(Q(this,`.wui-select`,HTMLElement),`The select wrapper is missing.`),a=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement),o=Q(this,`.wui-select-reset`,HTMLElement);this._nav=m({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>this._setActive(e),getCount:()=>this._rowCount(),getOptionAt:e=>this._rowEl(e),findByPrefix:e=>this._windowed?ne(n,e):this._visible().findIndex(t=>t.textContent.trim().toLowerCase().startsWith(e)),onEnter:(e,t)=>{if(e)this._pick(e);else if(this._query.trim()!==``){let e=t.find(e=>e.dataset.custom===`true`);if(e)this._pick(e);else if(t.length===1){let e=t[0];e&&this._pick(e)}}},onEscape:e=>{e.preventDefault(),this._nav?.clearTypeahead(),this._close(),t.focus()}}),i.addEventListener(`keydown`,e=>this._onKeyDown(e)),i.addEventListener(`input`,e=>{let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-select-input, .wui-select-draft`))return;this._onQueryChange(t.value);let n=t.matches(`.wui-select-draft`),r=this._rows>0||this._actionRows().length>0;n&&r&&!this._menuOpen()&&!s(this)&&this._draftOpens()&&this._open({focus:!1})}),i.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||!this._activePartsList().some(e=>e.onBlur?.()===!0)&&t&&this._close()}),a?.addEventListener(`click`,()=>{let t=r(e.search,`The search input is missing.`);t.value=``,this._onQueryChange(``),t.focus()}),t.addEventListener(`pointerdown`,()=>{this._pressOpen=this._menuOpen()}),t.addEventListener(`click`,e=>{if(e.target instanceof Element&&e.target.closest(`[data-remove]`))return;if(this.mode===`tag`){if(s(this))return;this._refs().input?.focus(),!this._menuOpen()&&this._draftOpens()&&this._open({focus:!1});return}if(e.target instanceof HTMLInputElement){!this._menuOpen()&&!s(this)&&this._open({focus:!1});return}let t=e.detail>0&&this._pressOpen!==null?this._pressOpen:this._menuOpen();this._pressOpen=null,this._clearHover(),this._hoverOpened&&t?(this._hoverOpened=!1,this._open({focus:!0})):t?this._close():s(this)||this._open({focus:!0})}),o?.addEventListener(`click`,e=>{e.stopPropagation(),this.commit(H(this.mode)?[]:``),this._close(),t.focus()}),n.addEventListener(`click`,n=>{let r=Le(n).closest(`.wui-select-option`);if(r instanceof HTMLElement&&(this._pick(r),H(this.mode))){let n=this.querySelector(`.wui-select-draft`);(e.search??(n instanceof HTMLElement?n:t)).focus()}}),n.addEventListener(`mousedown`,e=>{H(this.mode)&&e.target instanceof Element&&e.target.closest(`.wui-select-option`)&&e.preventDefault()}),n.addEventListener(`mousemove`,e=>{let t=Le(e).closest(`.wui-select-option`);t instanceof HTMLElement&&!t.classList.contains(`is-active`)&&this._setActive(this._windowed?Number(t.dataset.index):this._visible().indexOf(t),{reveal:!1})}),n.addEventListener(`scroll`,()=>{this._windowed&&this._scrollFrame===null&&(this._scrollFrame=requestAnimationFrame(()=>this._onListScroll()))},{passive:!0}),n.addEventListener(`mouseleave`,()=>this._setActive(-1)),n.addEventListener(`error`,e=>{let t=e.target;t instanceof Element&&t.classList.contains(`avatar-img`)&&t.remove()},!0),this.hasAttribute(`open`)&&this._open({focus:!1})}_teardown(){this._nav?.teardown(),this._scrollFrame!==null&&cancelAnimationFrame(this._scrollFrame),this._scrollFrame=null}_dropMenu(){let e=Q(this,`.wui-select-menu`,HTMLElement);e&&h(e)}_activePartsList(){return this._partsMounted?r(this._parts,`The mounted parts are missing.`):[]}_ensureParts(){if(!this.isConnected)return;(this.hasAttribute(`source`)||this.hasAttribute(`remote`)||this.hasAttribute(`recents-key`)||this._loadOptionsFn!==null)&&this._loadWindow();let e=Fe(this,this.mode),t=e.join(`,`);if(t===this._partSig)return;this._teardownParts(),this._parts=null,this._partSig=t;let n=++this._partToken;Promise.all(e.map(e=>ze(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(e=>e!==null),this._mountParts())})}_loadWindow(){this._windowLoad===null&&(this._windowLoad=be().then(()=>this.renderList(),()=>{this._windowFailed=!0,document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:`select-window`}})),this.setError(X().partLoadMessage)}))}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=we(this._refs());for(let n of this._parts)n.mount(this,t,{carry:e});this._drawValue(),this.renderList()}_teardownParts(){let e=this._activePartsList();this._partsMounted=!1;for(let t of e)t.teardown()}_remountParts(){if(!this._partsMounted)return;let e=this._carry();this._teardownParts(),this._mountParts(e)}_carry(){let e=this._refs();return{draft:e.input?.value??``,query:e.search?.value??``}}},we=e=>{let{control:t,value:n,menu:i,list:a}=e;return{control:r(t,`control missing`),value:r(n,`value missing`),menu:r(i,`menu missing`),list:r(a,`list missing`),search:e.search,input:e.input}},Te=e=>re.includes(e),Ee=[`comfortable`,`compact`],De=150,Oe=250,ke=10,Ae=()=>{let e=X();return{single:e.placeholder,search:e.placeholder,multiple:e.placeholder,tag:e.tagPlaceholder,country:e.countryPlaceholder}},je=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),Me=/* @__PURE__ */ new Set([`separators`,`allow-duplicates`,`invalid-message`,`create-label`,`add-label`,`selected-text`,`clear-all-label`,`value-label`,`value-avatar`,`value-initials`,`hint-text`,`recents-key`,`recents-limit`,`recents-label`]),Ne=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],Z=(e,t)=>t?Array.isArray(e)?e.map(String):e==null||e===``?[]:String(e).split(`,`).map(e=>e.trim()).filter(Boolean):Array.isArray(e)?e.length?String(e[0]):``:e==null?``:String(e),Pe=(e,t)=>t===`multiple`?U(e)?[`chips`,`search`]:[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?U(e)?[`chips`,`search`]:[`chips`]:[],Fe=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...Pe(e,t)]:Pe(e,t),Ie=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,Le=e=>{if(e.target instanceof Element)return e.target;throw Error(`The event target is not an element.`)},Q=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Re=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),$=e=>{let t=e.textContent;if(t===null)throw Error(`The element has no text.`);return t},ze=(e,t)=>ae(t).then(e=>{if(!Ie(e))throw Error(`The part ${t} has no default export.`);return e.default()}).catch(()=>(document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:t}})),e.setError(X().partLoadMessage),null));export{U as n,A as r,Ce as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./dom-DMQu--xV.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{a as r,l as i,s as a}from"./nativeOverlay-BHD2QV02.js";import{a as o,c as s,d as c,f as l,l as u,o as d,p as f,r as p}from"./shortcutKeys-
|
|
1
|
+
import{i as e,t}from"./dom-DMQu--xV.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{a as r,l as i,s as a}from"./nativeOverlay-BHD2QV02.js";import{a as o,c as s,d as c,f as l,l as u,o as d,p as f,r as p}from"./shortcutKeys-BMTWgV2g.js";var m=`wui-shortcuts-open-change`;function h(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}function g(e,t){return[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement)}var _=class extends n{_doc;_onKeyDown;_onClick;_onDocClick;_onPointerDown;_onPressEnd;_pressedOpen;_pinned;_mirroring;static get observedAttributes(){return[`open`,`no-trigger`]}constructor(){super(),this._doc=null,this._pressedOpen=!1,this._pinned=!1,this._mirroring=!1,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._onPointerDown=e=>{t(e.target,`.wui-shortcut-toggle`)&&(this._pressedOpen=this.open)},this._onPressEnd=e=>{e.type===`pointerup`&&t(e.target,`.wui-shortcut-toggle`)||(this._pressedOpen=!1)}}connectedCallback(){this._doc=this.ownerDocument,this._doc.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`click`,this._onDocClick),this._doc.addEventListener(`pointerup`,this._onPressEnd,!0),this._doc.addEventListener(`pointercancel`,this._onPressEnd,!0),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.hasAttribute(`open`)&&!this.open&&(this._pinned=!0,this.setOpen(!0,{focus:!1})),this._syncTrigger()}attributeChangedCallback(e,t,n){e===`no-trigger`?this._syncTrigger():(this._mirroring||(this._pinned=n!==null),this._sheet()&&n!==null!==this.open&&this.setOpen(n!==null))}disconnectedCallback(){let e=this._sheet();e&&r(e),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`click`,this._onDocClick),this._doc?.removeEventListener(`pointerup`,this._onPressEnd,!0),this._doc?.removeEventListener(`pointercancel`,this._onPressEnd,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this._doc=null}get open(){let e=this._sheet();return!!(e&&a(e))}set open(e){let t=e===!0||e===``||e===`true`;this._pinned=t,this._sheet()?t!==this.open&&this.setOpen(t):this.toggleAttribute(`open`,t)}setOpen(t,{focus:n=!0}={}){let o=this._sheet();if(!o)return;let s=h(this,`.wui-shortcut-toggle`);if(t||(this._pinned=!1),t){o.removeAttribute(`hidden`);let t=this.hasAttribute(`no-trigger`)?s??this:e(s,`<wui-shortcuts> needs its toggle to anchor the sheet.`);i(t,o,{mode:`auto`,side:`top`,align:`end`,flipAlign:!0,gap:8,keepOffscreen:this._pinned,onClosed:()=>{this._pinned=!1,this._mirror(!1)}})}else r(o);this._mirror(t),n&&(t?queueMicrotask(()=>{a(o)&&h(o,`.wui-shortcut-close`)?.focus()}):s?.focus())}_mirror(e){let t=this._sheet();t&&(t.hidden=!e),h(this,`.wui-shortcut-toggle`)?.setAttribute(`aria-expanded`,String(e)),this.hasAttribute(`open`)!==e&&(this._mirroring=!0,this.toggleAttribute(`open`,e),this._mirroring=!1,this.dispatchEvent(new CustomEvent(m,{bubbles:!0,detail:{open:e}})))}_sheet(){return h(this,`.wui-shortcut-sheet`)}_syncTrigger(){let e=h(this,`.wui-shortcut-toggle`);e&&(e.hidden=this.hasAttribute(`no-trigger`))}_scope(){let e=this.closest(`[${p}]`);return e instanceof HTMLElement?e:null}_items(){let t=this.getAttribute(`items`);return t?g(e(this._scope()??this._doc,`WuiShortcuts used before it was connected`),t):[]}_click(e){let t=e.target;if(t instanceof Element){if(t.closest(`.wui-shortcut-toggle`)){let e=this._pressedOpen;this._pressedOpen=!1,this.setOpen(!e&&!this.open)}else 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`);(h(this._scope()??n,t)??h(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(),i={help:()=>this.setOpen(!this.open)};if(this.getAttribute(`items`)&&(i.j=()=>s(this._items(),1),i.k=()=>s(this._items(),-1),i.x=()=>this._tickFocused()),this.getAttribute(`search`)&&(i.slash=()=>this._focusSearch()),i[n]){u(t,i,r);return}if(n===`enter`)return;let a=e(this._doc,`WuiShortcuts used before it was connected`),p=t.target instanceof Node?t.target:null;if(f(a)||!o(p,r)||d(p))return;let m=c(n),_=g(this,`.wui-shortcut-keys [data-shortcut]`).find(e=>e.dataset.shortcut===m);if(!_)return;let v=(r??a).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:m,itemKey:y}}))){t.preventDefault();return}let b=_.dataset.target,x=b?h(a,b):null;x&&(t.preventDefault(),x.click())}};export{_ as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{r as n}from"./textStore-
|
|
1
|
+
import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{r as n}from"./textStore-DBplASiZ.js";import{t as r}from"./showMore.g-BdQ5MUSd.js";var i=3,a=()=>n(`showMore`,r),o=class extends t{_width;_observer;_toggle;_onClick;constructor(){super(),this._width=-1,this._observer=null,this._toggle=null,this._onClick=()=>this.toggle()}connectedCallback(){let e=this.querySelector(`.wui-show-more-toggle`);if(this._toggle=e instanceof HTMLButtonElement?e:null,!this._toggle)return;let t=Number.parseInt(this.getAttribute(`lines`)??``,10);this.style.setProperty(`--wui-show-more-lines`,String(t>=1?t:i)),this._toggle.addEventListener(`click`,this._onClick),this._sync(),this._check(),typeof ResizeObserver<`u`&&(this._observer=new ResizeObserver(()=>{this.clientWidth!==this._width&&this._check()}),this._observer.observe(this))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._toggle?.removeEventListener(`click`,this._onClick),this._toggle=null}get expanded(){return this.hasAttribute(`expanded`)}toggle(e=!this.expanded){this.toggleAttribute(`expanded`,!!e),this._sync(),this.dispatchEvent(new CustomEvent(`wui:show-more:toggle`,{bubbles:!0,detail:{expanded:this.expanded}}))}_sync(){let t=e(this._toggle,`WuiShowMore used before it was connected`),n=this.expanded;t.setAttribute(`aria-expanded`,String(n)),t.textContent=n?this.getAttribute(`less-label`)||a().lessLabel:this.getAttribute(`more-label`)||a().moreLabel}_check(){let t=this.querySelector(`.wui-show-more-body`);if(!(t instanceof HTMLElement))return;this._width=this.clientWidth;let n=this.expanded;n&&this.removeAttribute(`expanded`);let r=t.scrollHeight>t.clientHeight+1;n&&this.setAttribute(`expanded`,``);let i=e(this._toggle,`WuiShowMore used before it was connected`);i.hidden=!r}};export{o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./digitGrouping-CCPI3HK3.js";import{r}from"./dom-DMQu--xV.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{r as a,t as o}from"./fieldState-D-zQcXUS.js";import{t as s}from"./formMirror-9IpSgeZb.js";import{r as c,t as l}from"./textStore-opIEM4lu.js";import{t as u}from"./slider.g-BPNfxZEV.js";var d=()=>c(`slider`,u),f=class extends i{static formAssociated=!0;_internals;_value;_start;_end;_isDragging;_dragThumb;_pointerDownListener;_pointerMoveListener;_pointerUpListener;_thumbKeyListener;_trackClickListener;_rendered;_defaultsCaptured;_defaultValue;_defaultStart;_defaultEnd;static get observedAttributes(){return[`min`,`max`,`step`,`value`,`start`,`end`,`name`,`start-name`,`end-name`,`disabled`,`readonly`,`loading`,`size`,`show-value`,`unit`,`grouping`,`aria-label`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=50,this._start=25,this._end=75,this._isDragging=!1,this._dragThumb=null,this._pointerDownListener=null,this._pointerMoveListener=null,this._pointerUpListener=null,this._thumbKeyListener=null,this._trackClickListener=null}connectedCallback(){this._rendered?this._wire():this.render()}get value(){return this._value}set value(e){this._value=this._snapToStep(this._clamp(p(e,this._value))),this._syncValue(),this._syncMirrors()}get start(){return this._start}set start(e){this._start=Math.min(this._snapToStep(this._clamp(p(e,this._start))),this._end),this._syncValue(),this._syncMirrors()}get end(){return this._end}set end(e){this._end=Math.max(this._snapToStep(this._clamp(p(e,this._end))),this._start),this._syncValue(),this._syncMirrors()}attributeChangedCallback(e,t,n){e===`value`||e===`start`||e===`end`||e===`min`||e===`max`||e===`step`?(this._updateFromAttribute(e),this._rendered&&(this._syncValue(),this._syncMirrors())):this._rendered&&this.render()}formResetCallback(){this._isRange()?this._resetRange():this._resetSingle()}_updateFromAttribute(e){e===`value`?this._value=this._snapToStep(this._clamp(p(this.getAttribute(`value`),this._value))):e===`start`?this._start=this._snapToStep(this._clamp(p(this.getAttribute(`start`),this._start))):e===`end`&&(this._end=this._snapToStep(this._clamp(p(this.getAttribute(`end`),this._end))))}_isRange(){return this.hasAttribute(`range`)}_min(){return p(this.getAttribute(`min`),0)}_max(){return p(this.getAttribute(`max`),100)}_step(){return p(this.getAttribute(`step`),1)}_clamp(e){return Math.max(this._min(),Math.min(e,this._max()))}_snapToStep(e){let t=this._step();if(t<=0)return e;let n=this._min();return this._clamp(n+Math.round((e-n)/t)*t)}_captureDefaults(){this._defaultsCaptured||=(this._isRange()?(this._defaultStart=this._start,this._defaultEnd=this._end):this._defaultValue=this._value,!0)}_resetSingle(){this._value=this._defaultValue??50,this._syncValue(),this._syncMirrors()}_resetRange(){this._start=this._defaultStart??25,this._end=this._defaultEnd??75,this._syncValue(),this._syncMirrors()}render(){this._captureDefaults();let e=this._min(),t=this._max(),n=this._isRange(),i=this.getAttribute(`size`),o=i===`sm`?` slider-sm`:i===`lg`?` slider-lg`:``,s=this.hasAttribute(`disabled`),c=this.hasAttribute(`readonly`);n?(this._start=this._clamp(this._start),this._end=this._clamp(this._end),this._start>this._end&&([this._start,this._end]=[this._end,this._start])):this._value=this._clamp(this._value);let u=n?[r(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`start`,"aria-label":d().minimumLabel,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._start,"aria-valuetext":this._formatValue(this._start),"aria-readonly":c?`true`:void 0,disabled:s}),r(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`end`,"aria-label":d().maximumLabel,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._end,"aria-valuetext":this._formatValue(this._end),"aria-readonly":c?`true`:void 0,disabled:s})]:[r(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`single`,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._value,"aria-valuetext":this._formatValue(this._value),"aria-readonly":c?`true`:void 0,disabled:s,"aria-label":this.getAttribute(`aria-label`)||d().ariaLabel})],f=r(`div`,{class:`wui-slider-rail`},r(`div`,{class:`slider-track`,role:`presentation`}),r(`div`,{class:`slider-fill`,role:`presentation`}),...u),p=this.hasAttribute(`show-value`)?r(`span`,{class:`slider-value`},n?l(d().rangeText,{start:this._formatValue(this._start),end:this._formatValue(this._end)}):this._formatValue(this._value)):!1;this.replaceChildren(r(`div`,{class:`slider${o}`},f,p)),this._rendered=!0,this._placeParts(),this._syncMirrors(),a(this,this.querySelector(`.slider`)),this._wire()}_formatValue(e){let t=this.getAttribute(`unit`)||``;return`${this._grouping()===`indian`?n(String(e)):String(e)}${t}`}_grouping(){let n=this.getAttribute(`grouping`)??`none`;if(!t(n))throw Error(e(n));return n}_placeParts(){let e=this._min(),t=this._max(),n=n=>t===e?0:(n-e)/(t-e),r=this._isRange(),i=r?n(this._start):0,a=n(r?this._end:this._value),o=m(this,`.slider-fill`);o&&(o.style.left=`${i*100}%`,o.style.right=`${100-a*100}%`,r&&o.style.setProperty(`--wui-fill-start`,String(i)),o.style.setProperty(`--wui-fill-end`,String(a)));let s=(e,t)=>{e&&(e.style.left=`${t*100}%`,e.style.setProperty(`--wui-t`,String(t)))};r?(s(m(this,`[data-thumb="start"]`),i),s(m(this,`[data-thumb="end"]`),a)):s(m(this,`.slider-thumb`),a)}_syncValue(){if(this._rendered){if(this._placeParts(),this._isRange()){let e=m(this,`[data-thumb="start"]`),t=m(this,`[data-thumb="end"]`);e&&(e.setAttribute(`aria-valuenow`,String(this._start)),e.setAttribute(`aria-valuetext`,this._formatValue(this._start))),t&&(t.setAttribute(`aria-valuenow`,String(this._end)),t.setAttribute(`aria-valuetext`,this._formatValue(this._end)));let n=m(this,`.slider-value`);n&&(n.textContent=l(d().rangeText,{start:this._formatValue(this._start),end:this._formatValue(this._end)}))}else{let e=m(this,`.slider-thumb`);e&&(e.setAttribute(`aria-valuenow`,String(this._value)),e.setAttribute(`aria-valuetext`,this._formatValue(this._value)));let t=m(this,`.slider-value`);t&&(t.textContent=this._formatValue(this._value))}}}_syncMirrors(){this._isRange()?this._syncRangeMirrors():this._syncSingleMirror()}_syncSingleMirror(){this.getAttribute(`name`)&&s(this,String(this._value))}_syncRangeMirrors(){let e=this.getAttribute(`start-name`)||this.getAttribute(`name`),t=this.getAttribute(`end-name`);this._mirrorRange(`start`,e,this._start),this._mirrorRange(`end`,t,this._end)}_mirrorRange(e,t,n){if(!t)return;let r=h(this,`input[type="hidden"][data-slider-mirror="${e}"]`);r||(r=document.createElement(`input`),r.type=`hidden`,r.setAttribute(`data-slider-mirror`,e),this.appendChild(r)),r.name=t,r.value=String(n),r.disabled=this.hasAttribute(`disabled`)}_valueAtPosition(e){let t=m(this,`.slider-track`);if(!t)return this._min();let n=t.getBoundingClientRect(),r=m(this,`.slider-thumb`),i=r?r.offsetWidth/2:0,a=n.width-i*2,o=a>0?Math.max(0,Math.min(1,(e-n.left-i)/a)):0,s=this._min()+o*(this._max()-this._min());return this._snapToStep(s)}_nearestThumb(e){return Math.abs(e-this._start)<=Math.abs(e-this._end)?`start`:`end`}_wire(){if(this._teardown(),o(this))return;let e=g(this,`.slider-thumb`),t=m(this,`.slider-track`),n=this._isRange(),r=e=>{if(o(this))return;let t=e.target;if(!(t instanceof Element))throw Error(`Pointer event target is not an element`);let n=t.closest(`.slider-thumb`);n&&(e.preventDefault(),this._isDragging=!0,this._dragThumb=n.getAttribute(`data-thumb`),document.addEventListener(`pointermove`,i),document.addEventListener(`pointerup`,a),document.addEventListener(`pointercancel`,a))},i=e=>{if(!this._isDragging)return;e.preventDefault();let t=this._valueAtPosition(e.clientX);if(this._dragThumb===`single`)this._value=this._clamp(t),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{value:this._value}}));else if(this._dragThumb===`start`){let e=Math.min(t,this._end);this._start=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}else if(this._dragThumb===`end`){let e=Math.max(t,this._start);this._end=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}},a=()=>{this._isDragging&&(this._isDragging=!1,this._dragThumb=null,document.removeEventListener(`pointermove`,i),document.removeEventListener(`pointerup`,a),document.removeEventListener(`pointercancel`,a),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},s=e=>{if(!(e.currentTarget instanceof HTMLElement))throw Error(`Keyboard event target is not an element`);let t=e.currentTarget;if(o(this))return;let n=this._step(),r=n*10,i=null,a=t.getAttribute(`data-thumb`),s=a===`end`?this._end:a===`start`?this._start:this._value;e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),i=s-n):e.key===`ArrowRight`||e.key===`ArrowUp`?(e.preventDefault(),i=s+n):e.key===`PageDown`?(e.preventDefault(),i=s-r):e.key===`PageUp`?(e.preventDefault(),i=s+r):e.key===`Home`?(e.preventDefault(),i=this._min()):e.key===`End`&&(e.preventDefault(),i=this._max()),i!=null&&(i=this._clamp(i),a===`single`?this._value=i:a===`start`?this._start=Math.min(i,this._end):a===`end`&&(this._end=Math.max(i,this._start)),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},c=e=>{if(o(this))return;let t=this._valueAtPosition(e.clientX);n?this._nearestThumb(t)===`start`?this._start=Math.min(this._clamp(t),this._end):this._end=Math.max(this._clamp(t),this._start):this._value=this._clamp(t),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))};this._pointerDownListener=r,this._pointerMoveListener=i,this._pointerUpListener=a,this._thumbKeyListener=s,this._trackClickListener=c,e.forEach(e=>{e.addEventListener(`pointerdown`,r),e.addEventListener(`keydown`,s)}),t?.addEventListener(`click`,c)}_teardown(){for(let e of g(this,`.slider-thumb`))this._pointerDownListener&&e.removeEventListener(`pointerdown`,this._pointerDownListener),this._thumbKeyListener&&e.removeEventListener(`keydown`,this._thumbKeyListener);this._pointerMoveListener&&document.removeEventListener(`pointermove`,this._pointerMoveListener),this._pointerUpListener&&(document.removeEventListener(`pointerup`,this._pointerUpListener),document.removeEventListener(`pointercancel`,this._pointerUpListener)),this._isDragging=!1,this._dragThumb=null;let e=m(this,`.slider-track`);e&&this._trackClickListener&&e.removeEventListener(`click`,this._trackClickListener)}disconnectedCallback(){this._teardown()}},p=(e,t)=>{let n=Number.parseFloat(String(e));return Number.isFinite(n)?n:t},m=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},h=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLInputElement?n:null},g=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement);export{f as t};
|
|
1
|
+
import{n as e,r as t,t as n}from"./digitGrouping-CCPI3HK3.js";import{r}from"./dom-DMQu--xV.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{r as a,t as o}from"./fieldState-D-zQcXUS.js";import{t as s}from"./formMirror-9IpSgeZb.js";import{r as c,t as l}from"./textStore-DBplASiZ.js";import{t as u}from"./slider.g-BPNfxZEV.js";var d=()=>c(`slider`,u),f=class extends i{static formAssociated=!0;_internals;_value;_start;_end;_isDragging;_dragThumb;_pointerDownListener;_pointerMoveListener;_pointerUpListener;_thumbKeyListener;_trackClickListener;_rendered;_defaultsCaptured;_defaultValue;_defaultStart;_defaultEnd;static get observedAttributes(){return[`min`,`max`,`step`,`value`,`start`,`end`,`name`,`start-name`,`end-name`,`disabled`,`readonly`,`loading`,`size`,`show-value`,`unit`,`grouping`,`aria-label`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=50,this._start=25,this._end=75,this._isDragging=!1,this._dragThumb=null,this._pointerDownListener=null,this._pointerMoveListener=null,this._pointerUpListener=null,this._thumbKeyListener=null,this._trackClickListener=null}connectedCallback(){this._rendered?this._wire():this.render()}get value(){return this._value}set value(e){this._value=this._snapToStep(this._clamp(p(e,this._value))),this._syncValue(),this._syncMirrors()}get start(){return this._start}set start(e){this._start=Math.min(this._snapToStep(this._clamp(p(e,this._start))),this._end),this._syncValue(),this._syncMirrors()}get end(){return this._end}set end(e){this._end=Math.max(this._snapToStep(this._clamp(p(e,this._end))),this._start),this._syncValue(),this._syncMirrors()}attributeChangedCallback(e,t,n){e===`value`||e===`start`||e===`end`||e===`min`||e===`max`||e===`step`?(this._updateFromAttribute(e),this._rendered&&(this._syncValue(),this._syncMirrors())):this._rendered&&this.render()}formResetCallback(){this._isRange()?this._resetRange():this._resetSingle()}_updateFromAttribute(e){e===`value`?this._value=this._snapToStep(this._clamp(p(this.getAttribute(`value`),this._value))):e===`start`?this._start=this._snapToStep(this._clamp(p(this.getAttribute(`start`),this._start))):e===`end`&&(this._end=this._snapToStep(this._clamp(p(this.getAttribute(`end`),this._end))))}_isRange(){return this.hasAttribute(`range`)}_min(){return p(this.getAttribute(`min`),0)}_max(){return p(this.getAttribute(`max`),100)}_step(){return p(this.getAttribute(`step`),1)}_clamp(e){return Math.max(this._min(),Math.min(e,this._max()))}_snapToStep(e){let t=this._step();if(t<=0)return e;let n=this._min();return this._clamp(n+Math.round((e-n)/t)*t)}_captureDefaults(){this._defaultsCaptured||=(this._isRange()?(this._defaultStart=this._start,this._defaultEnd=this._end):this._defaultValue=this._value,!0)}_resetSingle(){this._value=this._defaultValue??50,this._syncValue(),this._syncMirrors()}_resetRange(){this._start=this._defaultStart??25,this._end=this._defaultEnd??75,this._syncValue(),this._syncMirrors()}render(){this._captureDefaults();let e=this._min(),t=this._max(),n=this._isRange(),i=this.getAttribute(`size`),o=i===`sm`?` slider-sm`:i===`lg`?` slider-lg`:``,s=this.hasAttribute(`disabled`),c=this.hasAttribute(`readonly`);n?(this._start=this._clamp(this._start),this._end=this._clamp(this._end),this._start>this._end&&([this._start,this._end]=[this._end,this._start])):this._value=this._clamp(this._value);let u=n?[r(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`start`,"aria-label":d().minimumLabel,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._start,"aria-valuetext":this._formatValue(this._start),"aria-readonly":c?`true`:void 0,disabled:s}),r(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`end`,"aria-label":d().maximumLabel,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._end,"aria-valuetext":this._formatValue(this._end),"aria-readonly":c?`true`:void 0,disabled:s})]:[r(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`single`,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._value,"aria-valuetext":this._formatValue(this._value),"aria-readonly":c?`true`:void 0,disabled:s,"aria-label":this.getAttribute(`aria-label`)||d().ariaLabel})],f=r(`div`,{class:`wui-slider-rail`},r(`div`,{class:`slider-track`,role:`presentation`}),r(`div`,{class:`slider-fill`,role:`presentation`}),...u),p=this.hasAttribute(`show-value`)?r(`span`,{class:`slider-value`},n?l(d().rangeText,{start:this._formatValue(this._start),end:this._formatValue(this._end)}):this._formatValue(this._value)):!1;this.replaceChildren(r(`div`,{class:`slider${o}`},f,p)),this._rendered=!0,this._placeParts(),this._syncMirrors(),a(this,this.querySelector(`.slider`)),this._wire()}_formatValue(e){let t=this.getAttribute(`unit`)||``;return`${this._grouping()===`indian`?n(String(e)):String(e)}${t}`}_grouping(){let n=this.getAttribute(`grouping`)??`none`;if(!t(n))throw Error(e(n));return n}_placeParts(){let e=this._min(),t=this._max(),n=n=>t===e?0:(n-e)/(t-e),r=this._isRange(),i=r?n(this._start):0,a=n(r?this._end:this._value),o=m(this,`.slider-fill`);o&&(o.style.left=`${i*100}%`,o.style.right=`${100-a*100}%`,r&&o.style.setProperty(`--wui-fill-start`,String(i)),o.style.setProperty(`--wui-fill-end`,String(a)));let s=(e,t)=>{e&&(e.style.left=`${t*100}%`,e.style.setProperty(`--wui-t`,String(t)))};r?(s(m(this,`[data-thumb="start"]`),i),s(m(this,`[data-thumb="end"]`),a)):s(m(this,`.slider-thumb`),a)}_syncValue(){if(this._rendered){if(this._placeParts(),this._isRange()){let e=m(this,`[data-thumb="start"]`),t=m(this,`[data-thumb="end"]`);e&&(e.setAttribute(`aria-valuenow`,String(this._start)),e.setAttribute(`aria-valuetext`,this._formatValue(this._start))),t&&(t.setAttribute(`aria-valuenow`,String(this._end)),t.setAttribute(`aria-valuetext`,this._formatValue(this._end)));let n=m(this,`.slider-value`);n&&(n.textContent=l(d().rangeText,{start:this._formatValue(this._start),end:this._formatValue(this._end)}))}else{let e=m(this,`.slider-thumb`);e&&(e.setAttribute(`aria-valuenow`,String(this._value)),e.setAttribute(`aria-valuetext`,this._formatValue(this._value)));let t=m(this,`.slider-value`);t&&(t.textContent=this._formatValue(this._value))}}}_syncMirrors(){this._isRange()?this._syncRangeMirrors():this._syncSingleMirror()}_syncSingleMirror(){this.getAttribute(`name`)&&s(this,String(this._value))}_syncRangeMirrors(){let e=this.getAttribute(`start-name`)||this.getAttribute(`name`),t=this.getAttribute(`end-name`);this._mirrorRange(`start`,e,this._start),this._mirrorRange(`end`,t,this._end)}_mirrorRange(e,t,n){if(!t)return;let r=h(this,`input[type="hidden"][data-slider-mirror="${e}"]`);r||(r=document.createElement(`input`),r.type=`hidden`,r.setAttribute(`data-slider-mirror`,e),this.appendChild(r)),r.name=t,r.value=String(n),r.disabled=this.hasAttribute(`disabled`)}_valueAtPosition(e){let t=m(this,`.slider-track`);if(!t)return this._min();let n=t.getBoundingClientRect(),r=m(this,`.slider-thumb`),i=r?r.offsetWidth/2:0,a=n.width-i*2,o=a>0?Math.max(0,Math.min(1,(e-n.left-i)/a)):0,s=this._min()+o*(this._max()-this._min());return this._snapToStep(s)}_nearestThumb(e){return Math.abs(e-this._start)<=Math.abs(e-this._end)?`start`:`end`}_wire(){if(this._teardown(),o(this))return;let e=g(this,`.slider-thumb`),t=m(this,`.slider-track`),n=this._isRange(),r=e=>{if(o(this))return;let t=e.target;if(!(t instanceof Element))throw Error(`Pointer event target is not an element`);let n=t.closest(`.slider-thumb`);n&&(e.preventDefault(),this._isDragging=!0,this._dragThumb=n.getAttribute(`data-thumb`),document.addEventListener(`pointermove`,i),document.addEventListener(`pointerup`,a),document.addEventListener(`pointercancel`,a))},i=e=>{if(!this._isDragging)return;e.preventDefault();let t=this._valueAtPosition(e.clientX);if(this._dragThumb===`single`)this._value=this._clamp(t),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{value:this._value}}));else if(this._dragThumb===`start`){let e=Math.min(t,this._end);this._start=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}else if(this._dragThumb===`end`){let e=Math.max(t,this._start);this._end=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}},a=()=>{this._isDragging&&(this._isDragging=!1,this._dragThumb=null,document.removeEventListener(`pointermove`,i),document.removeEventListener(`pointerup`,a),document.removeEventListener(`pointercancel`,a),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},s=e=>{if(!(e.currentTarget instanceof HTMLElement))throw Error(`Keyboard event target is not an element`);let t=e.currentTarget;if(o(this))return;let n=this._step(),r=n*10,i=null,a=t.getAttribute(`data-thumb`),s=a===`end`?this._end:a===`start`?this._start:this._value;e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),i=s-n):e.key===`ArrowRight`||e.key===`ArrowUp`?(e.preventDefault(),i=s+n):e.key===`PageDown`?(e.preventDefault(),i=s-r):e.key===`PageUp`?(e.preventDefault(),i=s+r):e.key===`Home`?(e.preventDefault(),i=this._min()):e.key===`End`&&(e.preventDefault(),i=this._max()),i!=null&&(i=this._clamp(i),a===`single`?this._value=i:a===`start`?this._start=Math.min(i,this._end):a===`end`&&(this._end=Math.max(i,this._start)),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},c=e=>{if(o(this))return;let t=this._valueAtPosition(e.clientX);n?this._nearestThumb(t)===`start`?this._start=Math.min(this._clamp(t),this._end):this._end=Math.max(this._clamp(t),this._start):this._value=this._clamp(t),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))};this._pointerDownListener=r,this._pointerMoveListener=i,this._pointerUpListener=a,this._thumbKeyListener=s,this._trackClickListener=c,e.forEach(e=>{e.addEventListener(`pointerdown`,r),e.addEventListener(`keydown`,s)}),t?.addEventListener(`click`,c)}_teardown(){for(let e of g(this,`.slider-thumb`))this._pointerDownListener&&e.removeEventListener(`pointerdown`,this._pointerDownListener),this._thumbKeyListener&&e.removeEventListener(`keydown`,this._thumbKeyListener);this._pointerMoveListener&&document.removeEventListener(`pointermove`,this._pointerMoveListener),this._pointerUpListener&&(document.removeEventListener(`pointerup`,this._pointerUpListener),document.removeEventListener(`pointercancel`,this._pointerUpListener)),this._isDragging=!1,this._dragThumb=null;let e=m(this,`.slider-track`);e&&this._trackClickListener&&e.removeEventListener(`click`,this._trackClickListener)}disconnectedCallback(){this._teardown()}},p=(e,t)=>{let n=Number.parseFloat(String(e));return Number.isFinite(n)?n:t},m=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},h=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLInputElement?n:null},g=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement);export{f as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t}from"./formMirror-9IpSgeZb.js";import{n,t as r}from"./rtl-g7G8Bsib.js";import{r as i,t as a}from"./textStore-opIEM4lu.js";import{t as o}from"./sortable.g-BsTKys5-.js";var s=()=>i(`sortable`,o),c=/* @__PURE__ */ new Set,l=`.wui-sortable-handle`,u=`a[href],button,input,select,textarea,label,summary,[contenteditable='true'],[role='button'],[role='link']`,d=4,f=8,p=250,m=48,h=18,g=class extends e{_drag;_kb;_moving;controlled;_observer;_onDragStart;_onDocTouchMove;_onSelectStart;static get observedAttributes(){return[`name`,`disabled`]}constructor(){super(),this._drag=null,this._kb=null,this._moving=!1,this.controlled=!1,this._observer=null,this._onPointerDown=this._onPointerDown.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onDragStart=e=>e.preventDefault(),this._onDocMove=this._onDocMove.bind(this),this._onDocUp=this._onDocUp.bind(this),this._onDocCancel=this._onDocCancel.bind(this),this._onDocKey=this._onDocKey.bind(this),this._onDocTouchMove=e=>{this._drag?.started&&e.preventDefault()},this._onSelectStart=e=>e.preventDefault(),this._scrollTick=this._scrollTick.bind(this)}connectedCallback(){c.add(this),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`dragstart`,this._onDragStart),this._observer=new MutationObserver(()=>this._syncMirrors()),this._observer.observe(this,{childList:!0}),this._syncMirrors()}disconnectedCallback(){c.delete(this),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`dragstart`,this._onDragStart),this._observer?.disconnect(),this._observer=null,this._abort()}attributeChangedCallback(e){e===`disabled`&&this._abort(),this.isConnected&&this._syncMirrors()}get order(){return this._items().map(e=>e.getAttribute(`data-id`))}set order(e){if(this._drag?.started||this._kb)return;let t=this._items(),n=new Map(t.map(e=>[e.getAttribute(`data-id`),e])),r=[];for(let t of e??[]){let e=n.get(String(t));e&&!r.includes(e)&&r.push(e)}[...r,...t.filter(e=>!r.includes(e))].forEach((e,t)=>{let n=this._items()[t]??null;n!==e&&this.insertBefore(e,n)}),this._syncMirrors()}_items(){return[...this.querySelectorAll(`:scope > [data-id]`)].filter(e=>e instanceof HTMLElement)}_itemFrom(e){let t=e;for(;t&&t.parentElement!==this;)t=t.parentElement;return t instanceof HTMLElement&&t.hasAttribute(`data-id`)?t:null}_itemDisabled(e){return e.hasAttribute(`data-disabled`)}_horizontal(){return this.getAttribute(`orientation`)===`horizontal`}_syncMirrors(){t(this,this.order.map(e=>e??``))}_insertAt(e,t){let n=this._items();if(n.indexOf(e)===t)return;let r=n.filter(t=>t!==e),i=r[t]??null;i?this.insertBefore(e,i):r.length>0?r[r.length-1]?.after(e):this.appendChild(e)}_indexFor(e,t,n){let i=this._items().filter(t=>t!==e),a=this._horizontal(),o=r(this);for(let[e,r]of i.entries()){let i=r.getBoundingClientRect(),s=n<=i.bottom&&(o?t>i.left+i.width/2:t<i.left+i.width/2);if(a?n<i.top||s:n<i.top+i.height/2)return e}return i.length}_peers(){let e=this.getAttribute(`group`);return[...c].filter(t=>t===this||e&&t.getAttribute(`group`)===e&&!t.hasAttribute(`disabled`))}_labelOf(e){return e.getAttribute(`data-label`)||(e.textContent??``).replace(/\s+/g,` `).trim()||e.getAttribute(`data-id`)}_announce(e){let t=this.querySelector(`:scope > .wui-sortable-live`);t||(t=document.createElement(`div`),t.className=`wui-sortable-live`,t.setAttribute(`role`,`status`),t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-atomic`,`true`),this.appendChild(t)),t.textContent=e}_position(e){let t=this._items();return a(s().positionText,{position:t.indexOf(e)+1,total:t.length})}_onPointerDown(e){if(this._drag||this._kb||this.hasAttribute(`disabled`)||e.pointerType===`mouse`&&e.button!==0)return;let t=e.target;if(!(t instanceof Element))return;let n=this._itemFrom(t);if(!n||this._itemDisabled(n))return;let r=n.querySelector(`:scope > ${l}`),i=!!r&&r.contains(t);if(this.hasAttribute(`handle`)&&!i)return;if(!i){let e=t.closest?.(u);if(e&&e!==n&&n.contains(e))return}let a=e.pointerType===`touch`&&!i,o={item:n,pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY,slop:e.pointerType===`touch`?f:d,ready:!a,started:!1,timer:null,raf:0,list:this,ghost:null,offsetX:0,offsetY:0,fromIndex:0};this._drag=o,a&&(o.timer=setTimeout(()=>{o.timer=null,o.ready=!0,this._begin()},p)),document.addEventListener(`pointermove`,this._onDocMove),document.addEventListener(`pointerup`,this._onDocUp),document.addEventListener(`pointercancel`,this._onDocCancel),document.addEventListener(`keydown`,this._onDocKey,!0),document.addEventListener(`touchmove`,this._onDocTouchMove,{passive:!1})}_onDocMove(e){let t=this._drag;if(t&&e.pointerId===t.pointerId){if(t.x=e.clientX,t.y=e.clientY,!t.started){let e=Math.hypot(t.x-t.startX,t.y-t.startY);if(!t.ready){e>t.slop&&this._finish(!0);return}if(e<t.slop||(this._begin(),!this._drag?.started))return}e.preventDefault?.(),this._moveGhost(),this._update()}}_onDocUp(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!1)}_onDocCancel(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!0)}_onDocKey(e){e.key===`Escape`&&this._drag&&(e.preventDefault(),e.stopPropagation(),this._finish(!0))}_begin(){let e=this._drag;if(!e||e.started)return;e.started=!0;let t=e.item.getBoundingClientRect();e.offsetX=e.startX-t.left,e.offsetY=e.startY-t.top,e.fromIndex=this._items().indexOf(e.item);let n=e.item.cloneNode(!0);if(!(n instanceof HTMLElement))throw Error(`drag ghost is not an HTML element`);for(let e of[n,...n.querySelectorAll(`[id],[data-id]`)])e.removeAttribute(`id`),e.removeAttribute(`data-id`);n.classList.add(`wui-sortable-ghost`),n.setAttribute(`aria-hidden`,`true`),n.inert=!0,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,e.ghost=n,e.item.classList.add(`wui-sortable-dragging`),document.body.appendChild(n),document.documentElement.classList.add(`wui-sortable-active`),document.addEventListener(`selectstart`,this._onSelectStart),this._moveGhost(),e.raf=requestAnimationFrame(this._scrollTick),this._emit(this,`wui-sortable:start`,{id:e.item.getAttribute(`data-id`)})}_moveGhost(){let e=this._drag;e?.ghost&&(e.ghost.style.transform=`translate(${e.x-e.offsetX}px, ${e.y-e.offsetY}px)`)}_update(){let e=this._drag;if(!e?.started)return;let t=e.list;for(let n of this._peers()){let r=n.getBoundingClientRect();if(e.x>=r.left&&e.x<=r.right&&e.y>=r.top&&e.y<=r.bottom){t=n;break}}let n=t._indexFor(e.item,e.x,e.y);(t!==e.list||n!==t._items().indexOf(e.item))&&t._insertAt(e.item,n),e.list=t}_scrollTick(){let e=this._drag;if(!e?.started)return;let t=v(e.list),n=t?t.getBoundingClientRect():null,r=Math.max(n?.top??0,0),i=Math.min(n?.bottom??window.innerHeight,window.innerHeight),a=Math.max(n?.left??0,0),o=Math.min(n?.right??window.innerWidth,window.innerWidth),s=_(e.y,r,i),c=_(e.x,a,o);(c||s)&&(t?(t.scrollTop+=s,t.scrollLeft+=c):window.scrollBy(c,s),this._update()),e.raf=requestAnimationFrame(this._scrollTick)}_finish(e){let t=this._drag;if(!t||(this._drag=null,clearTimeout(t.timer??void 0),cancelAnimationFrame(t.raf),document.removeEventListener(`pointermove`,this._onDocMove),document.removeEventListener(`pointerup`,this._onDocUp),document.removeEventListener(`pointercancel`,this._onDocCancel),document.removeEventListener(`keydown`,this._onDocKey,!0),document.removeEventListener(`touchmove`,this._onDocTouchMove),document.removeEventListener(`selectstart`,this._onSelectStart),!t.started))return;t.ghost?.remove(),document.documentElement.classList.remove(`wui-sortable-active`),t.item.classList.remove(`wui-sortable-dragging`);let n=t.item.getAttribute(`data-id`);e?(this._insertAt(t.item,t.fromIndex),this._syncMirrors(),t.list!==this&&t.list._syncMirrors()):this._settle(t.item,this,t.fromIndex,t.list),this._emit(this,`wui-sortable:end`,{id:n,cancelled:e})}_settle(e,t,n,r){let i=r._items().indexOf(e);if(r===t&&i===n)return;let o=e.getAttribute(`data-id`),c=r.order,l=r!==t,u=t.order;l&&(t.controlled||r.controlled)&&t._insertAt(e,n),t._syncMirrors(),r._syncMirrors();let d=r._labelOf(e),f=l&&r.getAttribute(`aria-label`)?a(s().destinationText,{destination:String(r.getAttribute(`aria-label`))}):``,p={id:o,fromIndex:n,toIndex:i,from:t,to:r};l&&this._emit(t,`wui-sortable:change`,{...p,ids:u}),this._emit(r,`wui-sortable:change`,{...p,ids:c}),r._announce(a(s().movedPositionText,{label:String(d),destination:f,position:i+1,total:c.length}))}_emit(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))}_abort(){this._drag&&this._finish(!0),this._kb&&this._dropKeyboard(!0)}_onKeyDown(e){if(this.hasAttribute(`disabled`))return;let t=e.target;if(!(t instanceof Element))return;let i=t.closest(l),o=i instanceof HTMLElement?i:null,c=o&&o.parentElement?.parentElement===this?o.parentElement:null;if(!o||!c||this._itemDisabled(c)||this._drag)return;let u=n(e.key,r(this));if(!this._kb){if(u!==` `&&u!==`Enter`)return;e.preventDefault(),this._liftKeyboard(c,o)}else if(this._kb.item===c){if(u===` `||u===`Enter`)e.preventDefault(),this._dropKeyboard(!1);else if(u===`Escape`)e.preventDefault(),e.stopPropagation(),this._dropKeyboard(!0);else if([`ArrowUp`,`ArrowLeft`,`ArrowDown`,`ArrowRight`,`Home`,`End`].includes(u)){e.preventDefault();let t=this._items(),n=t.indexOf(c),r=t.length-1,i=u===`Home`?0:u===`End`?r:Math.max(0,Math.min(r,n+(u===`ArrowUp`||u===`ArrowLeft`?-1:1)));if(i===n){let e=s();this._announce(a(n===0?e.alreadyFirstText:e.alreadyLastText,{label:String(this._labelOf(c)),position:this._position(c)}));return}this._moveFocused(()=>this._insertAt(c,i),o),this._announce(a(s().movedText,{label:String(this._labelOf(c)),position:this._position(c)}))}}}_onFocusOut(e){if(!this._kb||this._moving)return;let t=e.relatedTarget;if(t&&!(t instanceof Node))throw Error(`focus moved to a non-node target`);t&&this._kb.handle.contains(t)||this._dropKeyboard(!1)}_liftKeyboard(e,t){this._kb={item:e,handle:t,fromIndex:this._items().indexOf(e)},t.setAttribute(`aria-pressed`,`true`),this._announce(a(s().liftedText,{label:String(this._labelOf(e)),position:this._position(e)}))}_dropKeyboard(e){let t=this._kb;t&&(this._kb=null,t.handle.removeAttribute(`aria-pressed`),e?(this._moveFocused(()=>this._insertAt(t.item,t.fromIndex),t.handle),this._announce(a(s().reorderCancelledText,{label:String(this._labelOf(t.item)),position:this._position(t.item)}))):this._items().indexOf(t.item)===t.fromIndex?this._announce(a(s().droppedText,{label:String(this._labelOf(t.item)),position:this._position(t.item)})):this._settle(t.item,this,t.fromIndex,this))}_moveFocused(e,t){this._moving=!0;let n=this.contains(document.activeElement);e(),n&&document.activeElement!==t&&t.focus(),this._moving=!1}};function _(e,t,n){return e<t+m?-Math.ceil(h*Math.min(1,(t+m-e)/m)):e>n-m?Math.ceil(h*Math.min(1,(e-(n-m))/m)):0}function v(e){for(let t=e.parentElement;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement){let e=getComputedStyle(t),n=/(auto|scroll)/.test(e.overflowY)&&t.scrollHeight>t.clientHeight,r=/(auto|scroll)/.test(e.overflowX)&&t.scrollWidth>t.clientWidth;if(n||r)return t}return null}export{g as t};
|
|
1
|
+
import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t}from"./formMirror-9IpSgeZb.js";import{n,t as r}from"./rtl-g7G8Bsib.js";import{r as i,t as a}from"./textStore-DBplASiZ.js";import{t as o}from"./sortable.g-BsTKys5-.js";var s=()=>i(`sortable`,o),c=/* @__PURE__ */ new Set,l=`.wui-sortable-handle`,u=`a[href],button,input,select,textarea,label,summary,[contenteditable='true'],[role='button'],[role='link']`,d=4,f=8,p=250,m=48,h=18,g=class extends e{_drag;_kb;_moving;controlled;_observer;_onDragStart;_onDocTouchMove;_onSelectStart;static get observedAttributes(){return[`name`,`disabled`]}constructor(){super(),this._drag=null,this._kb=null,this._moving=!1,this.controlled=!1,this._observer=null,this._onPointerDown=this._onPointerDown.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onDragStart=e=>e.preventDefault(),this._onDocMove=this._onDocMove.bind(this),this._onDocUp=this._onDocUp.bind(this),this._onDocCancel=this._onDocCancel.bind(this),this._onDocKey=this._onDocKey.bind(this),this._onDocTouchMove=e=>{this._drag?.started&&e.preventDefault()},this._onSelectStart=e=>e.preventDefault(),this._scrollTick=this._scrollTick.bind(this)}connectedCallback(){c.add(this),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`dragstart`,this._onDragStart),this._observer=new MutationObserver(()=>this._syncMirrors()),this._observer.observe(this,{childList:!0}),this._syncMirrors()}disconnectedCallback(){c.delete(this),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`dragstart`,this._onDragStart),this._observer?.disconnect(),this._observer=null,this._abort()}attributeChangedCallback(e){e===`disabled`&&this._abort(),this.isConnected&&this._syncMirrors()}get order(){return this._items().map(e=>e.getAttribute(`data-id`))}set order(e){if(this._drag?.started||this._kb)return;let t=this._items(),n=new Map(t.map(e=>[e.getAttribute(`data-id`),e])),r=[];for(let t of e??[]){let e=n.get(String(t));e&&!r.includes(e)&&r.push(e)}[...r,...t.filter(e=>!r.includes(e))].forEach((e,t)=>{let n=this._items()[t]??null;n!==e&&this.insertBefore(e,n)}),this._syncMirrors()}_items(){return[...this.querySelectorAll(`:scope > [data-id]`)].filter(e=>e instanceof HTMLElement)}_itemFrom(e){let t=e;for(;t&&t.parentElement!==this;)t=t.parentElement;return t instanceof HTMLElement&&t.hasAttribute(`data-id`)?t:null}_itemDisabled(e){return e.hasAttribute(`data-disabled`)}_horizontal(){return this.getAttribute(`orientation`)===`horizontal`}_syncMirrors(){t(this,this.order.map(e=>e??``))}_insertAt(e,t){let n=this._items();if(n.indexOf(e)===t)return;let r=n.filter(t=>t!==e),i=r[t]??null;i?this.insertBefore(e,i):r.length>0?r[r.length-1]?.after(e):this.appendChild(e)}_indexFor(e,t,n){let i=this._items().filter(t=>t!==e),a=this._horizontal(),o=r(this);for(let[e,r]of i.entries()){let i=r.getBoundingClientRect(),s=n<=i.bottom&&(o?t>i.left+i.width/2:t<i.left+i.width/2);if(a?n<i.top||s:n<i.top+i.height/2)return e}return i.length}_peers(){let e=this.getAttribute(`group`);return[...c].filter(t=>t===this||e&&t.getAttribute(`group`)===e&&!t.hasAttribute(`disabled`))}_labelOf(e){return e.getAttribute(`data-label`)||(e.textContent??``).replace(/\s+/g,` `).trim()||e.getAttribute(`data-id`)}_announce(e){let t=this.querySelector(`:scope > .wui-sortable-live`);t||(t=document.createElement(`div`),t.className=`wui-sortable-live`,t.setAttribute(`role`,`status`),t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-atomic`,`true`),this.appendChild(t)),t.textContent=e}_position(e){let t=this._items();return a(s().positionText,{position:t.indexOf(e)+1,total:t.length})}_onPointerDown(e){if(this._drag||this._kb||this.hasAttribute(`disabled`)||e.pointerType===`mouse`&&e.button!==0)return;let t=e.target;if(!(t instanceof Element))return;let n=this._itemFrom(t);if(!n||this._itemDisabled(n))return;let r=n.querySelector(`:scope > ${l}`),i=!!r&&r.contains(t);if(this.hasAttribute(`handle`)&&!i)return;if(!i){let e=t.closest?.(u);if(e&&e!==n&&n.contains(e))return}let a=e.pointerType===`touch`&&!i,o={item:n,pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY,slop:e.pointerType===`touch`?f:d,ready:!a,started:!1,timer:null,raf:0,list:this,ghost:null,offsetX:0,offsetY:0,fromIndex:0};this._drag=o,a&&(o.timer=setTimeout(()=>{o.timer=null,o.ready=!0,this._begin()},p)),document.addEventListener(`pointermove`,this._onDocMove),document.addEventListener(`pointerup`,this._onDocUp),document.addEventListener(`pointercancel`,this._onDocCancel),document.addEventListener(`keydown`,this._onDocKey,!0),document.addEventListener(`touchmove`,this._onDocTouchMove,{passive:!1})}_onDocMove(e){let t=this._drag;if(t&&e.pointerId===t.pointerId){if(t.x=e.clientX,t.y=e.clientY,!t.started){let e=Math.hypot(t.x-t.startX,t.y-t.startY);if(!t.ready){e>t.slop&&this._finish(!0);return}if(e<t.slop||(this._begin(),!this._drag?.started))return}e.preventDefault?.(),this._moveGhost(),this._update()}}_onDocUp(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!1)}_onDocCancel(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!0)}_onDocKey(e){e.key===`Escape`&&this._drag&&(e.preventDefault(),e.stopPropagation(),this._finish(!0))}_begin(){let e=this._drag;if(!e||e.started)return;e.started=!0;let t=e.item.getBoundingClientRect();e.offsetX=e.startX-t.left,e.offsetY=e.startY-t.top,e.fromIndex=this._items().indexOf(e.item);let n=e.item.cloneNode(!0);if(!(n instanceof HTMLElement))throw Error(`drag ghost is not an HTML element`);for(let e of[n,...n.querySelectorAll(`[id],[data-id]`)])e.removeAttribute(`id`),e.removeAttribute(`data-id`);n.classList.add(`wui-sortable-ghost`),n.setAttribute(`aria-hidden`,`true`),n.inert=!0,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,e.ghost=n,e.item.classList.add(`wui-sortable-dragging`),document.body.appendChild(n),document.documentElement.classList.add(`wui-sortable-active`),document.addEventListener(`selectstart`,this._onSelectStart),this._moveGhost(),e.raf=requestAnimationFrame(this._scrollTick),this._emit(this,`wui-sortable:start`,{id:e.item.getAttribute(`data-id`)})}_moveGhost(){let e=this._drag;e?.ghost&&(e.ghost.style.transform=`translate(${e.x-e.offsetX}px, ${e.y-e.offsetY}px)`)}_update(){let e=this._drag;if(!e?.started)return;let t=e.list;for(let n of this._peers()){let r=n.getBoundingClientRect();if(e.x>=r.left&&e.x<=r.right&&e.y>=r.top&&e.y<=r.bottom){t=n;break}}let n=t._indexFor(e.item,e.x,e.y);(t!==e.list||n!==t._items().indexOf(e.item))&&t._insertAt(e.item,n),e.list=t}_scrollTick(){let e=this._drag;if(!e?.started)return;let t=v(e.list),n=t?t.getBoundingClientRect():null,r=Math.max(n?.top??0,0),i=Math.min(n?.bottom??window.innerHeight,window.innerHeight),a=Math.max(n?.left??0,0),o=Math.min(n?.right??window.innerWidth,window.innerWidth),s=_(e.y,r,i),c=_(e.x,a,o);(c||s)&&(t?(t.scrollTop+=s,t.scrollLeft+=c):window.scrollBy(c,s),this._update()),e.raf=requestAnimationFrame(this._scrollTick)}_finish(e){let t=this._drag;if(!t||(this._drag=null,clearTimeout(t.timer??void 0),cancelAnimationFrame(t.raf),document.removeEventListener(`pointermove`,this._onDocMove),document.removeEventListener(`pointerup`,this._onDocUp),document.removeEventListener(`pointercancel`,this._onDocCancel),document.removeEventListener(`keydown`,this._onDocKey,!0),document.removeEventListener(`touchmove`,this._onDocTouchMove),document.removeEventListener(`selectstart`,this._onSelectStart),!t.started))return;t.ghost?.remove(),document.documentElement.classList.remove(`wui-sortable-active`),t.item.classList.remove(`wui-sortable-dragging`);let n=t.item.getAttribute(`data-id`);e?(this._insertAt(t.item,t.fromIndex),this._syncMirrors(),t.list!==this&&t.list._syncMirrors()):this._settle(t.item,this,t.fromIndex,t.list),this._emit(this,`wui-sortable:end`,{id:n,cancelled:e})}_settle(e,t,n,r){let i=r._items().indexOf(e);if(r===t&&i===n)return;let o=e.getAttribute(`data-id`),c=r.order,l=r!==t,u=t.order;l&&(t.controlled||r.controlled)&&t._insertAt(e,n),t._syncMirrors(),r._syncMirrors();let d=r._labelOf(e),f=l&&r.getAttribute(`aria-label`)?a(s().destinationText,{destination:String(r.getAttribute(`aria-label`))}):``,p={id:o,fromIndex:n,toIndex:i,from:t,to:r};l&&this._emit(t,`wui-sortable:change`,{...p,ids:u}),this._emit(r,`wui-sortable:change`,{...p,ids:c}),r._announce(a(s().movedPositionText,{label:String(d),destination:f,position:i+1,total:c.length}))}_emit(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))}_abort(){this._drag&&this._finish(!0),this._kb&&this._dropKeyboard(!0)}_onKeyDown(e){if(this.hasAttribute(`disabled`))return;let t=e.target;if(!(t instanceof Element))return;let i=t.closest(l),o=i instanceof HTMLElement?i:null,c=o&&o.parentElement?.parentElement===this?o.parentElement:null;if(!o||!c||this._itemDisabled(c)||this._drag)return;let u=n(e.key,r(this));if(!this._kb){if(u!==` `&&u!==`Enter`)return;e.preventDefault(),this._liftKeyboard(c,o)}else if(this._kb.item===c){if(u===` `||u===`Enter`)e.preventDefault(),this._dropKeyboard(!1);else if(u===`Escape`)e.preventDefault(),e.stopPropagation(),this._dropKeyboard(!0);else if([`ArrowUp`,`ArrowLeft`,`ArrowDown`,`ArrowRight`,`Home`,`End`].includes(u)){e.preventDefault();let t=this._items(),n=t.indexOf(c),r=t.length-1,i=u===`Home`?0:u===`End`?r:Math.max(0,Math.min(r,n+(u===`ArrowUp`||u===`ArrowLeft`?-1:1)));if(i===n){let e=s();this._announce(a(n===0?e.alreadyFirstText:e.alreadyLastText,{label:String(this._labelOf(c)),position:this._position(c)}));return}this._moveFocused(()=>this._insertAt(c,i),o),this._announce(a(s().movedText,{label:String(this._labelOf(c)),position:this._position(c)}))}}}_onFocusOut(e){if(!this._kb||this._moving)return;let t=e.relatedTarget;if(t&&!(t instanceof Node))throw Error(`focus moved to a non-node target`);t&&this._kb.handle.contains(t)||this._dropKeyboard(!1)}_liftKeyboard(e,t){this._kb={item:e,handle:t,fromIndex:this._items().indexOf(e)},t.setAttribute(`aria-pressed`,`true`),this._announce(a(s().liftedText,{label:String(this._labelOf(e)),position:this._position(e)}))}_dropKeyboard(e){let t=this._kb;t&&(this._kb=null,t.handle.removeAttribute(`aria-pressed`),e?(this._moveFocused(()=>this._insertAt(t.item,t.fromIndex),t.handle),this._announce(a(s().reorderCancelledText,{label:String(this._labelOf(t.item)),position:this._position(t.item)}))):this._items().indexOf(t.item)===t.fromIndex?this._announce(a(s().droppedText,{label:String(this._labelOf(t.item)),position:this._position(t.item)})):this._settle(t.item,this,t.fromIndex,this))}_moveFocused(e,t){this._moving=!0;let n=this.contains(document.activeElement);e(),n&&document.activeElement!==t&&t.focus(),this._moving=!1}};function _(e,t,n){return e<t+m?-Math.ceil(h*Math.min(1,(t+m-e)/m)):e>n-m?Math.ceil(h*Math.min(1,(e-(n-m))/m)):0}function v(e){for(let t=e.parentElement;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement){let e=getComputedStyle(t),n=/(auto|scroll)/.test(e.overflowY)&&t.scrollHeight>t.clientHeight,r=/(auto|scroll)/.test(e.overflowX)&&t.scrollWidth>t.clientWidth;if(n||r)return t}return null}export{g as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./devWarn-DXdRWZs3.js";import{r as t}from"./dom-DMQu--xV.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{r,t as i}from"./fieldState-D-zQcXUS.js";import{t as a}from"./formMirror-9IpSgeZb.js";import{t as o}from"./iconGlyphs.g-P04RJkSE.js";import{t as s}from"./imeSafeEnter-DPs9qL3S.js";import{a as c,l,s as u}from"./nativeOverlay-BHD2QV02.js";import{n as d,t as f}from"./rtl-g7G8Bsib.js";import{r as p,t as m}from"./textStore-opIEM4lu.js";import{t as h}from"./timePicker.g-IEczeE48.js";var g=()=>p(`timePicker`,h),_=e=>String(e).padStart(2,`0`),v=(e,t)=>`${_(e)}:${_(t)}`,y=e=>{let t=/^(\d{2}):(\d{2})$/.exec(e||``);return t?{h:Number(t[1]),m:Number(t[2])}:null},b=(e,t=`24`)=>{if(!e)return``;if(t===`24`)return v(e.h,e.m);let n=e.h%12||12,r=e.h>=12?`PM`:`AM`;return`${n}:${_(e.m)} ${r}`},x=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}},S=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},C=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),w=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},T=()=>{throw Error(`wui-timepicker is not rendered`)},E=0,D=class extends n{static formAssociated=!0;_internals;_value;_uid;_typedError;_typeahead;_typeaheadTimer;_rendered;_defaultValue;_isOpen;_lastPointer;_open=T;_close=T;_revertOnClose=!1;_refocusOnClose=!1;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-${++E}`,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.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=``,a(this,this._value),this._syncText(),this._syncInvalid()}_format(){return this.getAttribute(`format`)||`24`}_step(){let e=this.getAttribute(`step`);return e===null||e===``?1:/^[1-9]\d*$/.test(e)?Number(e):null}_bounds(){let e=y(this.getAttribute(`min`))||{h:0,m:0},t=y(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=this._step();if(n===null)return!1;let r=e*60+t,{min:i,max:a}=this._bounds();return r>=i&&r<=a&&r%n===0}_times(){let e=[],t=this._step();if(t===null)return e;for(let n=0;n<1440;n+=t){let t=Math.floor(n/60),r=n%60;this._allowed(t,r)&&e.push({h:t,m:r})}return e}_example(){let e=this._times(),t=e.find(e=>e.h*60+e.m>=540)??e[0];return t?b(t,this._format()):null}_notATime(){let e=this._example();return e?m(g().refusalText,{example:e}):g().noTimeText}_refusal(e){if(this._allowed(e.h,e.m))return``;let t=this._step();if(t===null)return g().noTimeText;let n=this._format(),{min:r,max:i}=this._bounds(),a=e.h*60+e.m,o=e=>b({h:Math.floor(e/60),m:e%60},n);if(a<r||a>i){let e=!!y(this.getAttribute(`min`)),t=!!y(this.getAttribute(`max`));return e&&t?m(g().rangeText,{min:o(r),max:o(i)}):e?m(g().minText,{min:o(r)}):m(g().maxText,{max:o(i)})}return m(g().stepText,{step:t})}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value),this._step()===null&&e(`[@webority/ui-elements] <wui-timepicker> step="${this.getAttribute(`step`)}" is not a whole number of minutes, 1 or more; no time can be picked until it is.`),this._endOpenColumns(),this._isOpen=null;let n=this.getAttribute(`size`),r=n===`sm`?` wui-input-sm`:n===`lg`?` wui-input-lg`:n===`xl`?` wui-input-xl`:``,i=this._uid,s=t(`button`,{type:`button`,class:`wui-timepicker-toggle`,tabindex:-1,"aria-label":g().chooseTimeLabel,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":`${i}-pop`},o(`clock`)),c=t(`div`,{class:`wui-timepicker-field`},t(`input`,{type:`text`,class:`input timepicker-trigger${r}`,id:`${i}-input`,role:`combobox`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":`${i}-pop`,"aria-autocomplete":`none`,autocomplete:`off`,spellcheck:`false`}),` `,s),l=t(`div`,{class:`timepicker-pop`,id:`${i}-pop`,role:`dialog`,"aria-label":g().chooseTimeLabel,popover:`auto`}),u=t(`div`,{class:`field-error wui-timepicker-error`,id:`${i}-error`,hidden:!0});this.replaceChildren(t(`div`,{class:`timepicker`},c,l,u)),this._rendered=!0,this._syncAttrs(),this._syncText(),this._syncInvalid(),a(this,this._value),this._wire()}_input(){return S(this,`.timepicker-trigger`,HTMLInputElement)}_pop(){return S(this,`.timepicker-pop`,HTMLDivElement)}_syncFormValue(){a(this,this._value)}_syncAttrs(){let e=this._input(),t=S(this,`.wui-timepicker-toggle`,HTMLButtonElement);if(!e)return;let n=this.hasAttribute(`disabled`);e.disabled=n,e.readOnly=i(this),t&&(t.disabled=n),r(this,e),e.placeholder=this.getAttribute(`placeholder`)||g().placeholder,this.hasAttribute(`required`)?e.setAttribute(`aria-required`,`true`):e.removeAttribute(`aria-required`);let o=this.getAttribute(`aria-label`);o?e.setAttribute(`aria-label`,o):e.removeAttribute(`aria-label`),a(this,this._value),i(this)&&this._isOpen?.()&&this._close({commit:!1})}_syncText(){let e=this._input();e&&(e.value=b(y(this._value),this._format()),this._isOpen?.()&&this._syncColumns())}_syncInvalid(){let e=this._input(),t=S(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===b(y(this._value),this._format()))return!0;let t=e.value.trim(),n=``;if(t){let e=x(t),r=e?this._refusal(e):this._notATime();if(!e||r)return this._typedError=r,this._syncInvalid(),!1;n=v(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=x(this._input()?.value);return e&&this._allowed(e.h,e.m)?e:null}_columnsNodes(){let e=this._format(),n=this._times(),r=(e,n,r)=>t(`div`,{class:`wui-timepicker-col`,role:`listbox`,"aria-label":n,"data-col":e},...r.map(e=>t(`button`,{type:`button`,class:`timepicker-option`,role:`option`,tabindex:-1,"aria-selected":`false`,"data-v":e.v},e.text))),i=[...new Set(n.map(e=>e.h))],a=[...new Set(n.map(e=>e.m))].sort((e,t)=>e-t),o;if(e===`12`){let e=[...new Set(i.map(e=>e%12))].sort((e,t)=>e-t),t=[...new Set(i.map(e=>e>=12?`pm`:`am`))].sort();o=[r(`hour`,g().hour,e.map(e=>({v:e,text:String(e||12)}))),r(`minute`,g().minute,a.map(e=>({v:e,text:_(e)}))),r(`period`,g().periodLabel,t.map(e=>({v:e,text:e.toUpperCase()})))]}else o=[r(`hour`,g().hour,i.map(e=>({v:e,text:_(e)}))),r(`minute`,g().minute,a.map(e=>({v:e,text:_(e)})))];return[t(`div`,{class:`wui-timepicker-cols`},...o)]}_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 C(t,`.wui-timepicker-col`,HTMLElement)){let t=r.dataset.col,i=this._selectedIn(t,n),a=C(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=b({h:o,m:s},this._format()),this._typedError=``,this._syncInvalid(),this._syncColumns())}_onColumnKey(e){let t=e.target instanceof Element?w(e.target,`.timepicker-option`,HTMLButtonElement):null,n=t&&w(t,`.wui-timepicker-col`,HTMLElement);if(!t||!n)return;let r=C(n,`.timepicker-option`,HTMLButtonElement).filter(e=>!e.disabled),i=r.indexOf(t),a=this._pop();if(!a)return;let o=C(a,`.wui-timepicker-col`,HTMLElement),c=e=>{e&&(this._pick(n.dataset.col,e.dataset.v),(S(n,`.timepicker-option.is-selected`,HTMLElement)||e).focus())},l=d(e.key,f(this));switch(l){case`ArrowDown`:e.preventDefault(),c(r[Math.min(i+1,r.length-1)]);return;case`ArrowUp`:e.preventDefault(),c(r[Math.max(i-1,0)]);return;case`Home`:e.preventDefault(),c(r[0]);return;case`End`:e.preventDefault(),c(r[r.length-1]);return;case`PageDown`:e.preventDefault(),c(r[Math.min(i+8,r.length-1)]);return;case`PageUp`:e.preventDefault(),c(r[Math.max(i-8,0)]);return;case`ArrowRight`:case`ArrowLeft`:{e.preventDefault();let t=o[o.indexOf(n)+(l===`ArrowRight`?1:-1)];(t&&S(t,`.timepicker-option[tabindex="0"]`,HTMLButtonElement))?.focus();return}case`Enter`:if(!s(e))return;e.preventDefault(),this._close({commit:!0,refocus:!0});return;case` `:e.preventDefault(),c(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),c(r.find(e=>(e.textContent??``).trim().toLowerCase().startsWith(this._typeahead))))}}_wire(){this._teardown();let e=this._input(),t=S(this,`.wui-timepicker-toggle`,HTMLButtonElement),n=this._pop(),r=S(this,`.timepicker`,HTMLDivElement);if(!e)throw Error(`<wui-timepicker> has no .timepicker-trigger input.`);if(!n)throw Error(`<wui-timepicker> has no .timepicker-pop list.`);let a=S(this,`.wui-timepicker-field`,HTMLElement);if(!a)throw Error(`<wui-timepicker> has no .wui-timepicker-field to place its list against.`);let o=()=>u(n);this._isOpen=o;let d=()=>S(n,`.wui-timepicker-col .timepicker-option[tabindex="0"]`,HTMLElement)?.focus(),f=e=>{e.key===`Escape`&&(this._revertOnClose=!0,this._refocusOnClose=!0)};this._open=({focus:s=!1}={})=>{if(!i(this)){if(!o()){if(n.replaceChildren(...this._columnsNodes()),l(a,n,{mode:`auto`,onClosed:()=>{this.removeEventListener(`keydown`,f,!0);let e=this._revertOnClose,t=this._refocusOnClose;this._revertOnClose=!1,this._refocusOnClose=!1,p({commit:!e,refocus:t})}}),!o())return;r?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),t?.setAttribute(`aria-expanded`,`true`),this.addEventListener(`keydown`,f,!0),this._syncColumns({scroll:!0})}s&&d()}};let p=({commit:i=!0,refocus:a=!1}={})=>{let o=n.contains(document.activeElement);n.replaceChildren(),r?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),t?.setAttribute(`aria-expanded`,`false`),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=void 0,this._typeahead=``,i?this._commitText():(this._typedError=``,this._syncText(),this._syncInvalid()),(a||o)&&e.focus()};this._close=(e={})=>{if(!o())return;let{commit:t=!0,refocus:r=!1}=e;this._revertOnClose=!t,this._refocusOnClose=r,c(n)},e.addEventListener(`pointerdown`,e=>{this._lastPointer=e.pointerType}),e.addEventListener(`click`,()=>{this._lastPointer!==`touch`&&!o()&&this._open(),this._lastPointer=null}),t?.addEventListener(`click`,()=>{o()?this._close({commit:!0,refocus:!0}):this._open({focus:!0})}),t?.addEventListener(`keydown`,e=>{e.key===`Escape`&&o()&&(e.preventDefault(),e.stopPropagation(),this._close({commit:!1,refocus:!0}))}),e.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._open({focus:!0});else if(s(e)){let t=o(),n=this._commitText();t&&n&&this._close({commit:!1}),(!n||t)&&e.preventDefault()}else e.key===`Escape`&&o()?(e.preventDefault(),e.stopPropagation(),this._close({commit:!1})):e.key===`Tab`&&o()&&this._close({commit:!0})}),e.addEventListener(`input`,e=>{e.stopPropagation(),this._typedError&&(this._typedError=``,this._syncInvalid()),o()&&this._syncColumns({scroll:!0})}),e.addEventListener(`change`,e=>{e.stopPropagation(),o()||this._commitText()}),n.addEventListener(`click`,e=>{let t=e.target instanceof Element?w(e.target,`.timepicker-option`,HTMLButtonElement):null,n=t&&w(t,`.wui-timepicker-col`,HTMLElement);t&&n&&!t.disabled&&this._pick(n.dataset.col,t.dataset.v)}),n.addEventListener(`keydown`,e=>{o()&&this._onColumnKey(e)})}_teardown(){clearTimeout(this._typeaheadTimer),this._typeaheadTimer=void 0,this._typeahead=``}_endOpenColumns(){let e=this._pop();e&&(this._revertOnClose=!0,c(e),this._revertOnClose=!1)}disconnectedCallback(){this._teardown(),this._endOpenColumns()}};export{D as t};
|
|
1
|
+
import{n as e}from"./devWarn-DXdRWZs3.js";import{r as t}from"./dom-DMQu--xV.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{r,t as i}from"./fieldState-D-zQcXUS.js";import{t as a}from"./formMirror-9IpSgeZb.js";import{t as o}from"./iconGlyphs.g-Dj8sa1HF.js";import{t as s}from"./imeSafeEnter-DPs9qL3S.js";import{a as c,l,s as u}from"./nativeOverlay-BHD2QV02.js";import{n as d,t as f}from"./rtl-g7G8Bsib.js";import{r as p,t as m}from"./textStore-DBplASiZ.js";import{t as h}from"./timePicker.g-IEczeE48.js";var g=()=>p(`timePicker`,h),_=e=>String(e).padStart(2,`0`),v=(e,t)=>`${_(e)}:${_(t)}`,y=e=>{let t=/^(\d{2}):(\d{2})$/.exec(e||``);return t?{h:Number(t[1]),m:Number(t[2])}:null},b=(e,t=`24`)=>{if(!e)return``;if(t===`24`)return v(e.h,e.m);let n=e.h%12||12,r=e.h>=12?`PM`:`AM`;return`${n}:${_(e.m)} ${r}`},x=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}},S=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},C=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),w=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},T=()=>{throw Error(`wui-timepicker is not rendered`)},E=0,D=class extends n{static formAssociated=!0;_internals;_value;_uid;_typedError;_typeahead;_typeaheadTimer;_rendered;_defaultValue;_isOpen;_lastPointer;_open=T;_close=T;_revertOnClose=!1;_refocusOnClose=!1;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-${++E}`,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.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=``,a(this,this._value),this._syncText(),this._syncInvalid()}_format(){return this.getAttribute(`format`)||`24`}_step(){let e=this.getAttribute(`step`);return e===null||e===``?1:/^[1-9]\d*$/.test(e)?Number(e):null}_bounds(){let e=y(this.getAttribute(`min`))||{h:0,m:0},t=y(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=this._step();if(n===null)return!1;let r=e*60+t,{min:i,max:a}=this._bounds();return r>=i&&r<=a&&r%n===0}_times(){let e=[],t=this._step();if(t===null)return e;for(let n=0;n<1440;n+=t){let t=Math.floor(n/60),r=n%60;this._allowed(t,r)&&e.push({h:t,m:r})}return e}_example(){let e=this._times(),t=e.find(e=>e.h*60+e.m>=540)??e[0];return t?b(t,this._format()):null}_notATime(){let e=this._example();return e?m(g().refusalText,{example:e}):g().noTimeText}_refusal(e){if(this._allowed(e.h,e.m))return``;let t=this._step();if(t===null)return g().noTimeText;let n=this._format(),{min:r,max:i}=this._bounds(),a=e.h*60+e.m,o=e=>b({h:Math.floor(e/60),m:e%60},n);if(a<r||a>i){let e=!!y(this.getAttribute(`min`)),t=!!y(this.getAttribute(`max`));return e&&t?m(g().rangeText,{min:o(r),max:o(i)}):e?m(g().minText,{min:o(r)}):m(g().maxText,{max:o(i)})}return m(g().stepText,{step:t})}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value),this._step()===null&&e(`[@webority/ui-elements] <wui-timepicker> step="${this.getAttribute(`step`)}" is not a whole number of minutes, 1 or more; no time can be picked until it is.`),this._endOpenColumns(),this._isOpen=null;let n=this.getAttribute(`size`),r=n===`sm`?` wui-input-sm`:n===`lg`?` wui-input-lg`:n===`xl`?` wui-input-xl`:``,i=this._uid,s=t(`button`,{type:`button`,class:`wui-timepicker-toggle`,tabindex:-1,"aria-label":g().chooseTimeLabel,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":`${i}-pop`},o(`clock`)),c=t(`div`,{class:`wui-timepicker-field`},t(`input`,{type:`text`,class:`input timepicker-trigger${r}`,id:`${i}-input`,role:`combobox`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":`${i}-pop`,"aria-autocomplete":`none`,autocomplete:`off`,spellcheck:`false`}),` `,s),l=t(`div`,{class:`timepicker-pop`,id:`${i}-pop`,role:`dialog`,"aria-label":g().chooseTimeLabel,popover:`auto`}),u=t(`div`,{class:`field-error wui-timepicker-error`,id:`${i}-error`,hidden:!0});this.replaceChildren(t(`div`,{class:`timepicker`},c,l,u)),this._rendered=!0,this._syncAttrs(),this._syncText(),this._syncInvalid(),a(this,this._value),this._wire()}_input(){return S(this,`.timepicker-trigger`,HTMLInputElement)}_pop(){return S(this,`.timepicker-pop`,HTMLDivElement)}_syncFormValue(){a(this,this._value)}_syncAttrs(){let e=this._input(),t=S(this,`.wui-timepicker-toggle`,HTMLButtonElement);if(!e)return;let n=this.hasAttribute(`disabled`);e.disabled=n,e.readOnly=i(this),t&&(t.disabled=n),r(this,e),e.placeholder=this.getAttribute(`placeholder`)||g().placeholder,this.hasAttribute(`required`)?e.setAttribute(`aria-required`,`true`):e.removeAttribute(`aria-required`);let o=this.getAttribute(`aria-label`);o?e.setAttribute(`aria-label`,o):e.removeAttribute(`aria-label`),a(this,this._value),i(this)&&this._isOpen?.()&&this._close({commit:!1})}_syncText(){let e=this._input();e&&(e.value=b(y(this._value),this._format()),this._isOpen?.()&&this._syncColumns())}_syncInvalid(){let e=this._input(),t=S(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===b(y(this._value),this._format()))return!0;let t=e.value.trim(),n=``;if(t){let e=x(t),r=e?this._refusal(e):this._notATime();if(!e||r)return this._typedError=r,this._syncInvalid(),!1;n=v(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=x(this._input()?.value);return e&&this._allowed(e.h,e.m)?e:null}_columnsNodes(){let e=this._format(),n=this._times(),r=(e,n,r)=>t(`div`,{class:`wui-timepicker-col`,role:`listbox`,"aria-label":n,"data-col":e},...r.map(e=>t(`button`,{type:`button`,class:`timepicker-option`,role:`option`,tabindex:-1,"aria-selected":`false`,"data-v":e.v},e.text))),i=[...new Set(n.map(e=>e.h))],a=[...new Set(n.map(e=>e.m))].sort((e,t)=>e-t),o;if(e===`12`){let e=[...new Set(i.map(e=>e%12))].sort((e,t)=>e-t),t=[...new Set(i.map(e=>e>=12?`pm`:`am`))].sort();o=[r(`hour`,g().hour,e.map(e=>({v:e,text:String(e||12)}))),r(`minute`,g().minute,a.map(e=>({v:e,text:_(e)}))),r(`period`,g().periodLabel,t.map(e=>({v:e,text:e.toUpperCase()})))]}else o=[r(`hour`,g().hour,i.map(e=>({v:e,text:_(e)}))),r(`minute`,g().minute,a.map(e=>({v:e,text:_(e)})))];return[t(`div`,{class:`wui-timepicker-cols`},...o)]}_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 C(t,`.wui-timepicker-col`,HTMLElement)){let t=r.dataset.col,i=this._selectedIn(t,n),a=C(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=b({h:o,m:s},this._format()),this._typedError=``,this._syncInvalid(),this._syncColumns())}_onColumnKey(e){let t=e.target instanceof Element?w(e.target,`.timepicker-option`,HTMLButtonElement):null,n=t&&w(t,`.wui-timepicker-col`,HTMLElement);if(!t||!n)return;let r=C(n,`.timepicker-option`,HTMLButtonElement).filter(e=>!e.disabled),i=r.indexOf(t),a=this._pop();if(!a)return;let o=C(a,`.wui-timepicker-col`,HTMLElement),c=e=>{e&&(this._pick(n.dataset.col,e.dataset.v),(S(n,`.timepicker-option.is-selected`,HTMLElement)||e).focus())},l=d(e.key,f(this));switch(l){case`ArrowDown`:e.preventDefault(),c(r[Math.min(i+1,r.length-1)]);return;case`ArrowUp`:e.preventDefault(),c(r[Math.max(i-1,0)]);return;case`Home`:e.preventDefault(),c(r[0]);return;case`End`:e.preventDefault(),c(r[r.length-1]);return;case`PageDown`:e.preventDefault(),c(r[Math.min(i+8,r.length-1)]);return;case`PageUp`:e.preventDefault(),c(r[Math.max(i-8,0)]);return;case`ArrowRight`:case`ArrowLeft`:{e.preventDefault();let t=o[o.indexOf(n)+(l===`ArrowRight`?1:-1)];(t&&S(t,`.timepicker-option[tabindex="0"]`,HTMLButtonElement))?.focus();return}case`Enter`:if(!s(e))return;e.preventDefault(),this._close({commit:!0,refocus:!0});return;case` `:e.preventDefault(),c(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),c(r.find(e=>(e.textContent??``).trim().toLowerCase().startsWith(this._typeahead))))}}_wire(){this._teardown();let e=this._input(),t=S(this,`.wui-timepicker-toggle`,HTMLButtonElement),n=this._pop(),r=S(this,`.timepicker`,HTMLDivElement);if(!e)throw Error(`<wui-timepicker> has no .timepicker-trigger input.`);if(!n)throw Error(`<wui-timepicker> has no .timepicker-pop list.`);let a=S(this,`.wui-timepicker-field`,HTMLElement);if(!a)throw Error(`<wui-timepicker> has no .wui-timepicker-field to place its list against.`);let o=()=>u(n);this._isOpen=o;let d=()=>S(n,`.wui-timepicker-col .timepicker-option[tabindex="0"]`,HTMLElement)?.focus(),f=e=>{e.key===`Escape`&&(this._revertOnClose=!0,this._refocusOnClose=!0)};this._open=({focus:s=!1}={})=>{if(!i(this)){if(!o()){if(n.replaceChildren(...this._columnsNodes()),l(a,n,{mode:`auto`,onClosed:()=>{this.removeEventListener(`keydown`,f,!0);let e=this._revertOnClose,t=this._refocusOnClose;this._revertOnClose=!1,this._refocusOnClose=!1,p({commit:!e,refocus:t})}}),!o())return;r?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),t?.setAttribute(`aria-expanded`,`true`),this.addEventListener(`keydown`,f,!0),this._syncColumns({scroll:!0})}s&&d()}};let p=({commit:i=!0,refocus:a=!1}={})=>{let o=n.contains(document.activeElement);n.replaceChildren(),r?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),t?.setAttribute(`aria-expanded`,`false`),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=void 0,this._typeahead=``,i?this._commitText():(this._typedError=``,this._syncText(),this._syncInvalid()),(a||o)&&e.focus()};this._close=(e={})=>{if(!o())return;let{commit:t=!0,refocus:r=!1}=e;this._revertOnClose=!t,this._refocusOnClose=r,c(n)},e.addEventListener(`pointerdown`,e=>{this._lastPointer=e.pointerType}),e.addEventListener(`click`,()=>{this._lastPointer!==`touch`&&!o()&&this._open(),this._lastPointer=null}),t?.addEventListener(`click`,()=>{o()?this._close({commit:!0,refocus:!0}):this._open({focus:!0})}),t?.addEventListener(`keydown`,e=>{e.key===`Escape`&&o()&&(e.preventDefault(),e.stopPropagation(),this._close({commit:!1,refocus:!0}))}),e.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._open({focus:!0});else if(s(e)){let t=o(),n=this._commitText();t&&n&&this._close({commit:!1}),(!n||t)&&e.preventDefault()}else e.key===`Escape`&&o()?(e.preventDefault(),e.stopPropagation(),this._close({commit:!1})):e.key===`Tab`&&o()&&this._close({commit:!0})}),e.addEventListener(`input`,e=>{e.stopPropagation(),this._typedError&&(this._typedError=``,this._syncInvalid()),o()&&this._syncColumns({scroll:!0})}),e.addEventListener(`change`,e=>{e.stopPropagation(),o()||this._commitText()}),n.addEventListener(`click`,e=>{let t=e.target instanceof Element?w(e.target,`.timepicker-option`,HTMLButtonElement):null,n=t&&w(t,`.wui-timepicker-col`,HTMLElement);t&&n&&!t.disabled&&this._pick(n.dataset.col,t.dataset.v)}),n.addEventListener(`keydown`,e=>{o()&&this._onColumnKey(e)})}_teardown(){clearTimeout(this._typeaheadTimer),this._typeaheadTimer=void 0,this._typeahead=``}_endOpenColumns(){let e=this._pop();e&&(this._revertOnClose=!0,c(e),this._revertOnClose=!1)}disconnectedCallback(){this._teardown(),this._endOpenColumns()}};export{D as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./anchorOverlay-daGdh_91.js";import{n,t as r}from"./buttonClass-GtEi8hAY.js";import{r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{d as o,f as s,o as c,u as l}from"./nativeOverlay-BHD2QV02.js";import{n as u,t as d}from"./rtl-g7G8Bsib.js";import{r as f}from"./textStore-opIEM4lu.js";import{n as p,t as m}from"./tourAdvance.g-BJqDnqag.js";import{t as h}from"./imeSafeEnter-DPs9qL3S.js";import{t as g}from"./svgNodes-CyPS2oFH.js";import{t as _}from"./tourOpenMark-nPeAJFSo.js";import{t as v}from"./tourSeenStore-z0Y_Znzx.js";var y=`data-advance`,b=`wui-tour-hint`,x=`wui-tour-pointer`,ee=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,te=()=>f(`tourAdvance`,m),S=(e,t)=>e?.advanceOn===`click`&&!!t,C=e=>(e??``).replace(/\s+/g,` `).trim(),ne=e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLMeterElement||e instanceof HTMLOutputElement||e instanceof HTMLProgressElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.labels:null,re=e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLFieldSetElement||e instanceof HTMLOptGroupElement||e instanceof HTMLOptionElement?e.disabled:!1;function ie(e){let t=e.ownerDocument,n=(e.getAttribute(`aria-labelledby`)||``).split(/\s+/).filter(Boolean),r=e instanceof HTMLInputElement&&/^(button|submit|reset)$/.test(e.type)?e.value:``,i=[n.map(e=>t.getElementById(e)?.textContent??``).join(` `),e.getAttribute(`aria-label`),Array.from(ne(e)??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=C(e);if(t)return t}return``}function ae(e){for(let t of[e,...e.querySelectorAll(ee)])if((t instanceof HTMLElement||t instanceof SVGElement)&&t.tabIndex>=0&&!re(t))return t;return null}function w(e,t,n){let r=(e.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(e=>e&&e!==t);n&&r.push(t),r.length>0?e.setAttribute(`aria-describedby`,r.join(` `)):e.removeAttribute(`aria-describedby`)}function oe(e,t){let n=e.querySelector(`.${b}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;if(!t)n?.remove(),i&&w(e,i,!1);else{if(!n){n=e.ownerDocument.createElement(`p`),n.className=b,i&&(n.id=i);let t=e.querySelector(`.wui-tour-actions`);if(!t)throw Error(`Tour card has no actions row.`);t.before(n)}n.textContent=t,i&&w(e,i,!0)}}function se(e,t){let n=e.querySelector(`.${x}`);if(!t){n?.remove();return}if(n)return;let r=e.ownerDocument.createElement(`span`);r.className=x,r.setAttribute(`aria-hidden`,`true`),e.append(r)}var ce=e=>getComputedStyle(e).animationName;function T(e,{layer:t,spot:n,card:r},i,a){let o=S(i,a);t.toggleAttribute(y,o&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(y)&&(n.removeAttribute(y),o&&ce(n)),o&&n.setAttribute(y,``),se(n,o);let s=r.querySelector(`.wui-tour-next`);if(!(s instanceof HTMLElement))throw Error(`Tour card has no next button.`);s.classList.toggle(`btn-primary`,!o),s.classList.toggle(`btn-link`,o);let c=o?C(i?.actionLabel)||ie(a):``,l=e.getAttribute(`advance-label`)||te().advanceLabel,u=c?l.replace(/\{actionName\}/g,()=>c):``;return oe(r,u),u}function le(e,t,n){if(!S(e,t))return()=>{};let r,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function ue(e,t,n,r){return e.contains(r)||S(t,n)&&n.contains(r)}function de(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=S(r,i)?ae(i):null;o&&a.push(o);let s=a.findIndex(e=>e===n||e===o&&i?.contains(n));e.preventDefault();let c=a[s===-1?e.shiftKey?a.length-1:0:(s+(e.shiftKey?-1:1)+a.length)%a.length];if(!c)throw Error(`Tour card has no focus stop.`);c.focus()}var fe=2/3,pe=1e3,me=/* @__PURE__ */ new Set([`top`,`left`,`width`,`height`]),E=/* @__PURE__ */ new WeakMap,D=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],O=e=>`transitionProperty`in e&&e.transitionProperty===`opacity`,he=e=>`transitionProperty`in e&&typeof e.transitionProperty==`string`&&me.has(e.transitionProperty),ge=e=>`animationName`in e&&typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function k(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,pe);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function _e(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?D(t,he):[]){let t=e.effect?.getComputedTiming?.();if(typeof t?.duration!=`number`)continue;let r=typeof e.currentTime==`number`?e.currentTime:0;n=Math.max(n,(t.delay??0)+t.duration*fe-r)}return n}function A(e){let t=_e(e);t>0?e.style.setProperty(`--wui-tour-card-delay`,`${Math.round(t)}ms`):e.style.removeProperty(`--wui-tour-card-delay`),e.dataset.state=`entering`;let n={};E.set(e,n);let r=()=>{E.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=D(e,ge);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function j(e){return e.dataset.state=`leaving`,k(D(e,O))}function ve(e){let t=e.shadowRoot?.querySelector(`.wui-tour-layer`),n=e.classList.contains(`wui-tour-layer`)?e:t instanceof HTMLElement?t:null;n&&(n.dataset.state=`leaving`);let r=n?k(D(n,O)):null;r?(e.setAttribute(`inert`,``),r.then(()=>e.remove())):e.remove()}var ye=2,M=12,N=8,P=4,F=20,be=`(max-width: 575.98px)`,xe=[`bottom`,`top`,`right`,`left`],Se=[`bottom`,`top`,`left`,`right`],I=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],L,R=(e,t,n)=>Math.max(t,Math.min(e,n)),z=(e,t,n,r)=>(Math.max(e,n)+Math.min(t,r))/2;function Ce(e,t){if(!t?.scrollIntoView)return;e.style.maxHeight=``;let n=V(e),r=e.offsetHeight+M;if(t.getBoundingClientRect().height+4+r*2<=n.bottom-n.top){t.scrollIntoView({block:`center`,inline:`nearest`});return}let i=t.style.scrollMarginTop;t.style.scrollMarginTop=`${n.top+r+ye}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function B(e,t,n){let r=e.style,i=t.style,a=Oe(t);if(!n){r.top=`50%`,r.left=`50%`,r.width=`0px`,r.height=`0px`,r.boxShadow=`0 0 0 100vmax var(--color-scrim-strong)`;for(let e of I)r.removeProperty(`border-${e}-radius`),r.removeProperty(`corner-${e}-shape`);t.dataset.placement=`center`,a.hidden=!0,i.position=`fixed`,i.top=`50%`,i.left=`50%`,i.transform=`translate(-50%, -50%)`,i.maxHeight=`calc(100vh - 16px)`;return}r.boxShadow=``,i.transform=``,i.position=`fixed`;let o=n.getBoundingClientRect();r.top=`${o.top}px`,r.left=`${o.left}px`,r.width=`${o.width}px`,r.height=`${o.height}px`,we(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=V(t),u=l.bottom-l.top,f={bottom:l.bottom-o.bottom-M,top:o.top-M-l.top,right:l.right-o.right-M,left:o.left-M-l.left},p=window.matchMedia(be).matches,m=(d(n)?Se:xe).find(e=>e===`top`||e===`bottom`?c.height<=f[e]+1:!p&&c.width<=f[e]+1&&c.height<=u+1),h=Math.min(o.bottom,l.bottom+N)-Math.max(o.top,l.top-N);m?Te(t,a,m,o,l,c):h>=Math.min(c.height,u)+8?Ee(t,a,o,l,c):De(t,a,f.bottom>=f.top?`bottom`:`top`,o,l,c,f),t.scrollTop=s}function we(e,t){L??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of I)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),L&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function Te(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=z(r.left,r.right,i.left,i.right);s=R(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+M:r.top-M-a.height,l=R(e-s,F,a.width-F)}else{let e=z(r.top,r.bottom,i.top,i.bottom);c=R(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+M:r.left-M-a.width,l=R(e-c,F,a.height-F)}e.dataset.placement=n,e.style.top=`${c}px`,e.style.left=`${s}px`,t.hidden=!1,t.style.left=o?`${l-e.clientLeft-t.offsetWidth/2}px`:``,t.style.top=o?``:`${l-e.clientTop-t.offsetHeight/2}px`}function Ee(e,t,n,r,i){let a=r.bottom-r.top;e.dataset.placement=`overlap`,t.hidden=!0,e.style.maxHeight=i.height>a?`${Math.max(a,0)}px`:``;let o=Math.min(n.bottom,r.bottom)-P;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${R(n.left+P,r.left,r.right-i.width)}px`}function De(e,t,n,r,i,a,o){let s=Math.max(o[n],0),c=Math.min(a.height,s);e.dataset.placement=n,t.hidden=!0,e.style.maxHeight=a.height>s?`${s}px`:``,e.style.top=`${n===`bottom`?r.bottom+M:r.top-M-c}px`;let l=z(r.left,r.right,i.left,i.right);e.style.left=`${R(l-a.width/2,i.left,i.right-a.width)}px`}function V(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e]??``)||0;return{top:r(`paddingTop`)+N,bottom:window.innerHeight-r(`paddingBottom`)-N,left:r(`paddingLeft`)+N,right:window.innerWidth-r(`paddingRight`)-N}}function Oe(e){let t=e.querySelector(`:scope > .wui-tour-arrow`);if(t instanceof HTMLElement)return t;let n=document.createElement(`span`);return n.className=`wui-tour-arrow`,n.setAttribute(`aria-hidden`,`true`),n.hidden=!0,e.append(n),n}var ke=0,Ae=`btn btn-sm btn-link`;function H(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`Expected "${t}" to match a ${n.name}.`);return r}function je(e,t){let a=`wui-tour-end-${++ke}`,{nextLabel:o,nextHref:s}=e,c=o&&s?i(`a`,{class:`${n(`primary`,`solid`,`sm`)} wui-tour-end-next`,"data-wui":r,href:s},o):null,l=c!==null,u=l?Ae:n(`primary`,`solid`,`sm`),d=i(`button`,{type:`button`,class:`${u} wui-tour-end-button`,"data-wui":r},e.button);return i(t?`dialog`:`div`,{class:`wui-tour-card wui-tour-end`,"data-layout":`center`,"data-next":l||void 0,role:`dialog`,tabindex:-1,"aria-labelledby":`${a}-title`,"aria-describedby":`${a}-message`},i(`div`,{class:`wui-tour-end-mark`,"aria-hidden":`true`},g({viewBox:`0 0 24 24`,focusable:`false`},[[`path`,{d:`M5 12.5l4.5 4.5L19 7.5`}]])),i(`h2`,{class:`wui-tour-title wui-tour-end-title`,id:`${a}-title`},e.title),i(`p`,{class:`wui-tour-text wui-tour-end-message`,id:`${a}-message`},e.message),i(`div`,{class:`wui-tour-actions`},c,d))}var Me=e=>e.button===0&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey;function Ne(e,t,n){let r=e.ownerDocument,i=je(t,e.getRootNode()===r),a=H(i,`.wui-tour-end-button`,HTMLButtonElement),o=i.querySelector(`.wui-tour-end-next`);if(o!==null&&!(o instanceof HTMLAnchorElement))throw Error(`The end dialog's next link is not a link.`);let s=o,u=s??a,d=new AbortController,f=i instanceof HTMLDialogElement?i:null,p=null;return new Promise(o=>{let m=e=>{if(d.abort(),p&&f){let e=p;p=null,c(f).then(e)}o(e)};if(n?.aborted){m(`done`);return}let g=H(e,`.wui-tour-card:not(.wui-tour-end)`,HTMLElement),_=H(e,`.wui-tour-spot`,HTMLElement),v=H(e,`[role=status]`,HTMLElement),y={signal:d.signal};n?.addEventListener(`abort`,()=>m(`done`),y),a.addEventListener(`click`,()=>m(`done`),y),s&&s.addEventListener(`click`,e=>{Me(e)&&(e.preventDefault(),m(`next`))},y),r.addEventListener(`keydown`,e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`){if(p)return;e.preventDefault(),e.stopPropagation(),m(`done`)}else h(e)&&s&&!e.shiftKey&&(e.composedPath?.()[0]??e.target)===s&&(e.preventDefault(),m(`next`))}},{capture:!0,signal:d.signal});let b=()=>{d.signal.aborted||(g.hidden=!0,B(_,g,null),e.append(i),A(i),f&&(p=l(f,{escape:!0,backdrop:!1,focus:`first-control`,onRequestClose:()=>m(`done`)})),v.textContent=[t.title,t.message].filter(Boolean).join(`. `),u.focus())},x=j(g);x===null?b():x.then(b)})}var Pe=` :host { all: initial; display: revert-layer; position: fixed; inset: 0; ${Object.entries({"--wui-z-tour":`1550`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-popover":`0px 8px 28px -6px rgba(7, 20, 55, 0.14)`,"--wui-ease-out":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-ease-linear":`cubic-bezier(0, 0, 1, 1)`,"--wui-duration-fast":`150ms`,"--wui-duration-default":`250ms`,"--wui-duration-slow":`400ms`,"--wui-space-xs":`4px`,"--wui-tour-motion-duration":`200ms`,"--wui-tour-motion-ease":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-tour-spot-duration":`240ms`,"--wui-tour-spot-ease":`cubic-bezier(0.32, 0.72, 0, 1)`,"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-text":`#4F46E5`,"--color-focus-ring":`#4F46E5`,"--wui-focus-ring-width":`2px`,"--wui-focus-ring-offset":`2px`,"--color-on-primary":`#FFFFFF`,"--color-success-soft":`#E8FAEE`,"--color-success-text":`#0e7531`,"--color-on-scrim":`#FFFFFF`,"--color-scrim-strong":`color-mix(in srgb, #071437 62%, transparent)`,"--color-surface":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-bg-muted":`#F5F6FA`}).map(([e,t])=>` ${e}: ${t};`).join(` `)} } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; } .btn { display: inline-block; margin: 0; padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; line-height: 1.5; text-align: center; text-decoration: none; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; } .btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); } .btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); } .btn-outline-neutral { border-color: var(--color-text-muted); color: var(--color-text-muted); } .btn-outline-neutral:hover { background: var(--color-bg-muted); color: var(--color-text); } .btn-link { font-weight: 400; color: var(--color-primary-text); text-decoration: underline; } .btn-link:hover { color: var(--color-primary-hover); } .wui-tour-layer { pointer-events: none; font-family: "Webority Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-weight: 400; line-height: 1.5; color: var(--color-text); text-align: start; } .wui-tour-card { pointer-events: auto; } .wui-tour-layer { position: fixed; inset: 0; z-index: var(--wui-z-tour); width: auto; height: auto; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; overflow: visible; background: none; } .wui-tour-spot { position: fixed; box-shadow: 0 0 0 2px var(--color-primary), 0 0 4px 2px color-mix(in srgb, var(--color-primary) 30%, transparent), 0 0 0 100vmax var(--color-scrim-strong); pointer-events: none; } .wui-tour-card { display: flex; flex-direction: column; gap: 8px; width: min(360px, 100vw - 16px); padding: 16px; overflow-y: auto; background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--wui-radius-lg); corner-shape: squircle; box-shadow: var(--wui-shadow-popover); } .wui-tour-card:focus { outline: none; } .wui-tour-card:focus-visible { outline: var(--wui-focus-ring-width) solid var(--color-focus-ring); outline-offset: var(--wui-focus-ring-offset); } .wui-tour-title { margin: 0; font-size: 16px; font-weight: 600; } .wui-tour-text { margin: 0; font-size: 14px; color: var(--color-text-muted); } .wui-tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; } .wui-tour-nav { display: flex; gap: 8px; } .wui-tour-skip { color: var(--color-text-muted); } .wui-tour-back, .wui-tour-next { min-width: 64px; } @keyframes wui-tour-fade-in { from { opacity: 0; } to { opacity: 1; } } @keyframes wui-tour-card-enter { from { opacity: 0; scale: 0.96; translate: var(--wui-tour-card-lift, 0 6px); } to { opacity: 1; scale: 1; translate: 0 0; } } .wui-tour-layer[data-state=leaving], .wui-tour-card[data-state=leaving] { opacity: 0; } .wui-tour-layer[data-state=leaving], .wui-tour-layer[data-state=leaving] * { pointer-events: none; } @media (prefers-reduced-motion: no-preference) { .wui-tour-layer { animation: wui-tour-fade-in var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-layer[data-state=leaving] { transition: opacity var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-spot { transition: top var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), left var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), width var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), height var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), border-radius var(--wui-tour-spot-duration) var(--wui-tour-spot-ease); } .wui-tour-spot[data-tracking] { transition: none; } .wui-tour-card { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=top] { --wui-tour-card-lift: 0 -6px; transform-origin: bottom center; } .wui-tour-card[data-placement=bottom] { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=left] { --wui-tour-card-lift: -6px 0; transform-origin: right center; } .wui-tour-card[data-placement=right] { --wui-tour-card-lift: 6px 0; transform-origin: left center; } .wui-tour-card[data-placement=overlap], .wui-tour-card[data-placement=center] { --wui-tour-card-lift: 0 0; transform-origin: center; } .wui-tour-card[data-state=entering] { animation: wui-tour-card-enter var(--wui-tour-motion-duration) var(--wui-tour-motion-ease) var(--wui-tour-card-delay, 0ms) both; } .wui-tour-card[data-state=leaving] { transition: opacity calc(var(--wui-tour-motion-duration) / 2) var(--wui-tour-motion-ease); } } @media (prefers-reduced-motion: reduce) { .wui-tour-layer { animation: wui-tour-fade-in var(--wui-duration-fast) var(--wui-ease-linear); } .wui-tour-layer[data-state=leaving] { transition: opacity var(--wui-duration-fast) var(--wui-ease-linear); } .wui-tour-card[data-state=entering] { animation: wui-tour-fade-in var(--wui-duration-fast) var(--wui-ease-linear) both; } } .wui-tour-progress-bar { display: flex; gap: 4px; } .wui-tour-progress-segment { flex: 1 1 0; height: 4px; border-radius: 999px; background: var(--color-border); } .wui-tour-progress-segment[data-filled] { background: var(--color-primary); } .wui-tour-position { margin: 0; font-size: 12px; color: var(--color-text-muted); } .wui-tour-layer { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); } .wui-tour-card:has(.wui-tour-arrow:not([hidden])) { overflow: visible; } .wui-tour-arrow { position: absolute; width: 8px; height: 8px; background: var(--color-surface); border: 1px solid var(--color-border); rotate: 45deg; pointer-events: none; } .wui-tour-card[data-placement=bottom] .wui-tour-arrow { top: -5px; border-right-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=top] .wui-tour-arrow { bottom: -5px; border-top-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=right] .wui-tour-arrow { left: -5px; border-top-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=left] .wui-tour-arrow { right: -5px; border-bottom-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } @media (max-width: 575.98px) { .wui-tour-card { width: calc(100vw - 16px); } .wui-tour-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; } } .wui-tour-media { position: relative; order: -1; flex: none; aspect-ratio: 16/9; margin: -16px -16px 4px; overflow: hidden; background: var(--color-border); } .wui-tour-media>img, .wui-tour-media>video { display: block; width: 100%; height: 100%; object-fit: cover; } .wui-tour-card[data-welcome] { width: min(420px, 100vw - 16px); } .wui-tour-media-toggle { position: absolute; inset-block-end: 8px; inset-inline-end: 8px; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--color-scrim-strong); color: var(--color-on-scrim); cursor: pointer; } .wui-tour-media-toggle>svg { width: 20px; height: 20px; fill: currentColor; } .wui-tour-media-toggle:focus-visible { outline: 2px solid var(--color-on-scrim); outline-offset: var(--wui-focus-ring-offset); } .wui-tour-layer[data-advance] { pointer-events: none; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-card { pointer-events: auto; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-spot::before { content: ""; position: absolute; inset: -100vmax; pointer-events: auto; clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, 100vmax 100vmax, calc(100% - 100vmax) 100vmax, calc(100% - 100vmax) calc(100% - 100vmax), 100vmax calc(100% - 100vmax), 100vmax 100vmax); } .wui-tour-hint { margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text); } .wui-tour-pointer { position: absolute; top: 50%; left: 50%; width: 18px; height: 24px; pointer-events: none; } .wui-tour-pointer::before { content: ""; position: absolute; inset: 0; background: var(--color-primary); clip-path: polygon(0 0, 0 75%, 28% 58%, 46% 100%, 62% 92%, 45% 52%, 85% 52%); filter: drop-shadow(1px 0 0 var(--color-surface)) drop-shadow(-1px 0 0 var(--color-surface)) drop-shadow(0 1px 0 var(--color-surface)) drop-shadow(0 -1px 0 var(--color-surface)); } .wui-tour-pointer::after { content: ""; position: absolute; top: -16px; left: -16px; width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); opacity: 0; display: none; } @media (max-width: 575.98px) { .wui-tour-pointer { width: 24px; height: 24px; translate: -50% -50%; } .wui-tour-pointer::before { clip-path: none; border-radius: 50%; box-shadow: 0 0 0 2px var(--color-surface); filter: none; } .wui-tour-pointer::after { top: -4px; left: -4px; } } @keyframes wui-tour-tap { 0% { opacity: 0; transform: translate(56px, 44px) scale(1); } 10% { opacity: 1; transform: translate(56px, 44px) scale(1); } 45% { transform: translate(0, 0) scale(1); } 52% { transform: translate(0, 0) scale(0.86); } 60% { transform: translate(0, 0) scale(1); } 85% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(0, 0) scale(1); } } @keyframes wui-tour-tap-rtl { 0% { opacity: 0; transform: translate(-56px, 44px) scale(1); } 10% { opacity: 1; transform: translate(-56px, 44px) scale(1); } 45% { transform: translate(0, 0) scale(1); } 52% { transform: translate(0, 0) scale(0.86); } 60% { transform: translate(0, 0) scale(1); } 85% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(0, 0) scale(1); } } @keyframes wui-tour-ripple { 0%, 50% { opacity: 0; transform: scale(0.2); } 52% { opacity: 0.35; transform: scale(0.2); } 80%, 100% { opacity: 0; transform: scale(1); } } @media (prefers-reduced-motion: no-preference) { .wui-tour-pointer { opacity: 0; animation: wui-tour-tap calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } .wui-tour-pointer:dir(rtl) { animation-name: wui-tour-tap-rtl; } .wui-tour-pointer::after { display: block; animation: wui-tour-ripple calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } } @keyframes wui-tour-check { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } } .wui-tour-end[data-layout=center] { --wui-tour-card-lift: 0 0; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); transform-origin: center; align-items: center; gap: 8px; width: min(420px, 100vw - 16px); max-height: calc(100vh - 16px); padding: 24px; text-align: center; } .wui-tour-end[data-layout=center] .wui-tour-actions { justify-content: center; margin-top: 8px; } .wui-tour-end[data-layout=center][data-next] .wui-tour-actions { flex-direction: column; align-items: stretch; width: 100%; gap: var(--wui-space-xs); } .wui-tour-end-mark { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; background: var(--color-success-soft); color: var(--color-success-text); } .wui-tour-end-mark>svg { width: 26px; height: 26px; } .wui-tour-end-mark path { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; } .wui-tour-end-title { font-size: 18px; } .wui-tour-end-message { text-wrap: balance; } .wui-tour-end-next { text-wrap: balance; } .wui-tour-end-button { min-width: 120px; } @media (prefers-reduced-motion: no-preference) { .wui-tour-end-mark path { animation: wui-tour-check var(--wui-duration-default) var(--wui-ease-out) calc(var(--wui-tour-card-delay, 0ms) + var(--wui-duration-fast)) both; } } `,U=()=>f(`tour`,p),W=`wui-tour-media`,Fe=`wui-tour-media-toggle`,G=`http://www.w3.org/2000/svg`,Ie=`M6 5h4v14H6zM14 5h4v14h-4z`,Le=`M8 5v14l11-7z`,Re=()=>({pause:U().mediaPauseLabel,play:U().mediaPlayLabel}),ze=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function Be(e){let t=document.createElementNS(G,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(G,`path`);return n.setAttribute(`d`,e),t.appendChild(n),t}function Ve(e){let t=document.createElement(`img`);return t.setAttribute(`alt`,e.mediaAlt??``),t.setAttribute(`width`,`1280`),t.setAttribute(`height`,`720`),t.setAttribute(`loading`,`lazy`),t.setAttribute(`decoding`,`async`),t.setAttribute(`src`,e.media??``),t}function He(e,t){let n=document.createElement(`video`);return n.muted=!0,n.setAttribute(`muted`,``),n.loop=!0,n.setAttribute(`playsinline`,``),t&&n.setAttribute(`autoplay`,``),n.setAttribute(`preload`,t?`auto`:`metadata`),e.mediaAlt&&n.setAttribute(`aria-label`,e.mediaAlt),e.mediaPoster&&n.setAttribute(`poster`,e.mediaPoster),n.setAttribute(`src`,e.media??``),n}function Ue(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=Fe;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(Be(r?Ie:Le))};return e.addEventListener(`play`,()=>r()),e.addEventListener(`pause`,()=>r()),n.addEventListener(`click`,()=>{e.paused?e.play()?.catch(()=>r()):e.pause()}),r(e.hasAttribute(`autoplay`)),n}function We(e){let t=e.querySelector(`:scope > .${W}`);if(!t)return;let n=t.querySelector(`video`);n&&(n.pause(),n.removeAttribute(`src`),n.load()),t.remove()}function Ge(e,t,n=Re()){if(We(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=W,t.mediaType===`video`){let e=He(t,!ze());r.append(e,Ue(e,n))}else r.appendChild(Ve(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var Ke=()=>f(`tour`,p);function K(e){let t=/* @__PURE__ */ new Set;return{drop:e=>{t.add(e)},position:e=>{t.delete(e);let n=0;for(let r of t)r<e&&n++;return e+1-n},total:()=>e-t.size}}function qe(e,t,n){return(e.getAttribute(`progress-label`)||Ke().progressLabel).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function Je(e,{text:t,position:n,total:r}){let i=e.querySelector(`.wui-tour-position`);if(!(i instanceof HTMLElement))throw Error(`tour position label missing`);i.textContent=t;let a=e.querySelector(`.wui-tour-progress-bar`);if(!a){let t=e.ownerDocument,n=t.createElement(`div`);n.className=`wui-tour-progress`,n.setAttribute(`aria-hidden`,`true`),a=t.createElement(`div`),a.className=`wui-tour-progress-bar`,n.append(a),i.before(n)}let o=a.children;for(;o.length<r;){let t=e.ownerDocument.createElement(`span`);t.className=`wui-tour-progress-segment`,a.append(t)}for(;o.length>r;){let e=a.lastElementChild;if(!e)throw Error(`progress bar segment missing`);e.remove()}for(let e=0;e<o.length;e++){let t=o[e];if(!t)throw Error(`progress bar segment missing`);t.toggleAttribute(`data-filled`,e<n)}}var Ye=`wui-tour-step`,Xe=`wui-tour-host`,q=`data-tracking`,J=()=>f(`tour`,p),Ze=()=>({back:J().backLabel,next:J().nextLabel,skip:J().skipLabel,done:J().doneLabel,mediaPause:J().mediaPauseLabel,mediaPlay:J().mediaPlayLabel,endTitle:J().endTitle,endMessage:J().endMessage,endButton:J().doneLabel}),Qe={back:`back-label`,next:`next-label`,skip:`skip-label`,done:`done-label`,mediaPause:`media-pause-label`,mediaPlay:`media-play-label`,endTitle:`end-title`,endMessage:`end-message`,endButton:`end-button`},$e=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],Y={index:null,position:null,total:null},et=0,X=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,Z=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function Q(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`<wui-tour> layer has no ${t}`);return r}var tt=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},$=null;function nt(e){$||($=new CSSStyleSheet,$.replaceSync(Pe)),e.adoptedStyleSheets=[$]}var rt=class extends a{seenStore;onBeforeStep;_run;_running;_layer;_outer;_shadow;_unbindAdvance;_ending;_seenMark;_steps=[];_progress=K(0);_firstIndex=0;_returnFocus=null;_current=null;_moving=!1;_card=null;_spot=null;_live=null;_onKey=null;_onFocusIn=null;static get observedAttributes(){return[`open`]}constructor(){super(),this.seenStore=null,this.onBeforeStep=null,this._run=0,this._running=!1,this._layer=null,this._outer=null,this._shadow=null,this._unbindAdvance=null,this._ending=null,this._seenMark=null}connectedCallback(){this.hasAttribute(`open`)&&this.start()}disconnectedCallback(){this.stop()}attributeChangedCallback(e,t,n){e===`open`&&this.isConnected&&(n===null?this.stop():this.start())}get tourId(){return this.getAttribute(`tour-id`)||``}set tourId(e){e==null||e===``?this.removeAttribute(`tour-id`):this.setAttribute(`tour-id`,String(e))}get isolated(){return this.hasAttribute(`isolated`)}set isolated(e){this.toggleAttribute(`isolated`,e===!0||e===``||e===`true`)}_stepList(){return Array.from(this.querySelectorAll(`:scope > ${Ye}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:(e.textContent??``).trim()};for(let[n,r]of $e)e.hasAttribute(r)&&(t[n]=e.getAttribute(r)??``);return t})}_stepAt(e){let t=this._steps[e];if(!t)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);return t}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?v():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(Qe[e])||Ze()[e]}_endDialogText(){if(this.getAttribute(`end-dialog`)===`false`)return null;let e=(this.getAttribute(`end-next-label`)??``).trim(),t=(this.getAttribute(`end-next-href`)??``).trim();return{title:this._label(`endTitle`),message:this._label(`endMessage`),button:this._label(`endButton`),nextLabel:e,nextHref:t}}_markSeen(e){let t=this._store();return t?t.markSeen(this.tourId,e):null}async start(){if(this._running)return;this._running=!0;let e=++this._run;this.hasAttribute(`open`)||this.setAttribute(`open`,``);try{await this._start(e)}catch(t){throw e===this._run&&(this._running=!1),t}}async _start(e){this._steps=this._stepList(),this._progress=K(this._steps.length);let t=this._store();if(t&&!this.tourId)throw Error(`<wui-tour> needs a tour-id to use a seen store.`);if(t&&await t.isSeen(this.tourId)){e===this._run&&this._finish(`alreadySeen`);return}for(let[e,t]of this._steps.entries())t.target&&!X(document.querySelector(t.target))&&this._progress.drop(e);this._returnFocus=document.activeElement;let n=await this._locate(0,1,e);e===this._run&&(n?(this._firstIndex=n.index,this.dispatchEvent(new CustomEvent(`wui-tour:start`,{bubbles:!0,detail:{total:this._progress.total()}})),e===this._run&&(this._build(),this._show(n))):this._finish(`noTargets`))}next(){return this._move(1)}back(){return!this._current||this._current.index<=this._firstIndex?Promise.resolve():this._move(-1)}async goTo(e){if(this._current){if(!Number.isInteger(e)||e<0||e>=this._steps.length)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);await this._go(e,1)}}stop(){this._running&&(this._run++,this._teardown(),this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`))}async _locate(e,t,n){let r=this._steps;for(let i=e;i>=0&&i<r.length;i+=t){let e=r[i];if(!e)break;if(await this._beforeStep(e,i),n!==this._run)return null;if(!e.target)return{index:i,target:null};let t=document.querySelector(e.target),a=t instanceof HTMLElement||t instanceof SVGElement?t:null;if(X(a))return this._progress.position(i),{index:i,target:a};this._progress.drop(i)}return null}async _beforeStep(e,t){let n=[];this.dispatchEvent(new CustomEvent(`wui-tour:beforestep`,{bubbles:!0,detail:{step:e,index:t,wait:e=>n.push(e)}})),await Promise.all(n),typeof this.onBeforeStep==`function`&&await this.onBeforeStep(e,t)}_build(){let t=`wui-tour-${++et}`,a=document.createElement(`div`);a.className=`wui-tour-layer`,a.replaceChildren(i(`div`,{class:`wui-tour-spot`,"aria-hidden":`true`}),i(`div`,{class:`wui-tour-card`,role:`dialog`,tabindex:`-1`,"aria-labelledby":`${t}-title`,"aria-describedby":`${t}-text`},i(`p`,{class:`wui-tour-position`}),i(`h2`,{class:`wui-tour-title`,id:`${t}-title`}),i(`p`,{class:`wui-tour-text`,id:`${t}-text`}),i(`div`,{class:`wui-tour-actions`},i(`button`,{type:`button`,class:`btn btn-sm btn-link wui-tour-skip`}),i(`div`,{class:`wui-tour-nav`},i(`button`,{type:`button`,class:`${n(`neutral`,`outline`,`sm`)} wui-tour-back`,"data-wui":r}),i(`button`,{type:`button`,class:`${n(`primary`,`solid`,`sm`)} wui-tour-next`,"data-wui":r})))),i(`div`,{class:`visually-hidden`,role:`status`,"aria-live":`polite`}));let s=a;this._shadow=null,this.isolated&&(s=document.createElement(Xe),this._shadow=s.attachShadow({mode:`open`}),nt(this._shadow),this._shadow.appendChild(a)),s.setAttribute(`popover`,`manual`),o(document).appendChild(s),document.documentElement.setAttribute(_,``),this._outer=s,this._layer=a;let c=Q(a,`.wui-tour-spot`,HTMLDivElement),l=Q(a,`.wui-tour-card`,HTMLDivElement),u=Q(a,`[role=status]`,HTMLElement);this._spot=c,this._card=l,this._live=u,Q(l,`.wui-tour-skip`,HTMLElement).addEventListener(`click`,()=>this._close(`skipped`,`button`)),Q(l,`.wui-tour-back`,HTMLElement).addEventListener(`click`,()=>this._move(-1)),Q(l,`.wui-tour-next`,HTMLElement).addEventListener(`click`,()=>this._move(1));let d=e=>this._key(e);this._onKey=d;let f=e=>{let t=this._layer;if(!t||this._ending)return;let n=this._current,r=n?this._stepAt(n.index):null;if(!(e.target instanceof Node))throw Error(`<wui-tour> saw a focus change from a non-node target`);ue(t,r,n?.target??null,e.target)||l.focus()};this._onFocusIn=f,document.addEventListener(`keydown`,d,!0),this._shadow||document.addEventListener(`focusin`,f),e(s,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_raise(){let e=this._outer;if(!e)throw Error(`<wui-tour> raises a step before its host is built`);let t=o(this.ownerDocument);e.parentElement!==t&&t.appendChild(e),s(e)}_show(e){this._current=e;let{index:t,target:n}=e,r=this._stepAt(t),i=this._layer,a=this._spot,o=this._card,s=this._live;if(!i||!a||!o||!s)throw Error(`<wui-tour> shows a step before its layer is built`);this._raise();let c=this._progress.position(t),l=this._progress.total(),u=c===l&&!this._endDialogText(),d=qe(this,c,l);Je(o,{text:d,position:c,total:l}),Ge(o,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)}),o.toggleAttribute(`data-welcome`,!n);let f=T(this,{layer:i,spot:a,card:o},r,n),p=Q(o,`.wui-tour-title`,HTMLElement);p.textContent=r.title||``,p.hidden=!r.title,Q(o,`.wui-tour-text`,HTMLElement).textContent=r.description||``,Q(o,`.wui-tour-skip`,HTMLElement).textContent=this._label(`skip`);let m=Q(o,`.wui-tour-back`,HTMLElement);m.textContent=this._label(`back`),m.hidden=t<=this._firstIndex,Q(o,`.wui-tour-next`,HTMLElement).textContent=this._label(u?`done`:`next`);let h=[d,r.title,r.description].filter(Boolean).join(`. `);s.textContent=f?[h,f].join(/[.!?]$/.test(h)?` `:`. `):h,Ce(o,n),a.removeAttribute(q),this._place(),A(o),this._unbindAdvance?.(),this._unbindAdvance=le(r,n,()=>void this._move(1));let g=this._active();(g!==null&&o.contains(g)?!(g instanceof HTMLElement&&g.hidden):this._shadow!==null&&Z(tt()))||o.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t,position:c,total:l}}))}_place(){if(!this._current||!this._layer)return;let e=this._spot,t=this._card;if(!e||!t)throw Error(`<wui-tour> places a step before its layer is built`);B(e,t,this._current.target)}_follow(){if(!this._current||!this._layer||this._ending)return;let e=this._spot;if(!e)throw Error(`<wui-tour> follows a step before its spot is built`);let t=e.style.cssText;this._place(),e.style.cssText!==t&&e.setAttribute(q,``)}async _move(e){this._current&&await this._go(this._current.index+e,e)}async _go(e,t){if(!this._current||this._moving)return;this._moving=!0;let n=this._run;try{let r=await this._locate(e,t,n);if(n!==this._run)return;if(r){let e=this._card;if(!e)throw Error(`<wui-tour> moved with no card showing`);let t=j(e);if(t!==null&&await t,n!==this._run)return;this._show(r)}else if(t>0){let e=this._endDialogText(),t=e?await this._showEnd(e):`done`;if(n!==this._run)return;let r=await this._close(t===`next`?`next`:`finished`);if(t===`next`&&r&&e){let t=this.ownerDocument.defaultView;if(!t)throw Error(`<wui-tour> has no window to follow its next link in`);t.location.assign(e.nextHref)}}}finally{this._moving=!1}}_showEnd(e){this._unbindAdvance?.(),this._unbindAdvance=null;let t=this._layer,n=this._spot,r=this._card;if(!t||!n||!r)throw Error(`<wui-tour> ends a tour before its layer is built`);return T(this,{layer:t,spot:n,card:r},null,null),n.removeAttribute(q),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),Ne(t,e,this._ending.signal)}_key(e){if(!this._layer||this._ending||e.altKey||e.ctrlKey||e.metaKey)return;let t=u(e.key,d(this));if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this._close(`skipped`,`escape`);else if(t===`ArrowRight`||t===`ArrowLeft`){if(Z(e.composedPath?.()[0]??e.target))return;if(e.preventDefault(),t===`ArrowRight`)this._move(1);else{let e=this._current;if(!e)throw Error(`<wui-tour> moved back with no step showing`);e.index>this._firstIndex&&this._move(-1)}}else if(e.key===`Tab`&&!this._shadow){let t=this._current,n=this._card;if(!t||!n)throw Error(`<wui-tour> cycled focus with no step showing`);de(e,{card:n,active:this._active(),step:this._stepAt(t.index),target:t.target})}}_teardown(){if(!this._layer)return;this._onKey&&document.removeEventListener(`keydown`,this._onKey,!0),this._onFocusIn&&document.removeEventListener(`focusin`,this._onFocusIn);let e=!this._shadow||this._shadow.activeElement!==null||!document.activeElement||document.activeElement===document.body;this._unbindAdvance?.(),this._unbindAdvance=null,this._ending?.abort(),this._ending=null,this._seenMark=null;let n=this._outer;if(t(n),!n)throw Error(`<wui-tour> has a layer with no host to remove`);ve(n),document.documentElement.removeAttribute(_),this._outer=null,this._shadow=null,this._layer=null,this._current=null;let r=this._returnFocus;this._returnFocus=null,e&&r?.isConnected&&(r instanceof HTMLElement||r instanceof SVGElement)&&r.focus()}async _close(e,t=null){let n=this._run,r=this._current,i=r?{index:r.index,position:this._progress.position(r.index),total:this._progress.total()}:Y,a=this._seenMark;this._teardown();let o=e===`next`?`finished`:e,s=!1;try{n===this._run&&await(a??this._markSeen(o)),s=n===this._run}finally{this._finish(e,i,t)}return s}_finish(e,t=Y,n=null){this._run++,this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`),this.dispatchEvent(new CustomEvent(`wui-tour:close`,{bubbles:!0,detail:{reason:e,...t,via:n}}))}};export{rt as t};
|
|
1
|
+
import{n as e,r as t}from"./anchorOverlay-daGdh_91.js";import{n,t as r}from"./buttonClass-C8BRtTk8.js";import{r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{d as o,f as s,o as c,u as l}from"./nativeOverlay-BHD2QV02.js";import{n as u,t as d}from"./rtl-g7G8Bsib.js";import{r as f}from"./textStore-DBplASiZ.js";import{n as p,t as m}from"./tourAdvance.g-BJqDnqag.js";import{t as h}from"./imeSafeEnter-DPs9qL3S.js";import{t as g}from"./svgNodes-CyPS2oFH.js";import{t as _}from"./tourOpenMark-nPeAJFSo.js";import{t as v}from"./tourSeenStore-z0Y_Znzx.js";var y=`data-advance`,b=`wui-tour-hint`,x=`wui-tour-pointer`,ee=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,te=()=>f(`tourAdvance`,m),S=(e,t)=>e?.advanceOn===`click`&&!!t,C=e=>(e??``).replace(/\s+/g,` `).trim(),ne=e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLMeterElement||e instanceof HTMLOutputElement||e instanceof HTMLProgressElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.labels:null,re=e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLFieldSetElement||e instanceof HTMLOptGroupElement||e instanceof HTMLOptionElement?e.disabled:!1;function ie(e){let t=e.ownerDocument,n=(e.getAttribute(`aria-labelledby`)||``).split(/\s+/).filter(Boolean),r=e instanceof HTMLInputElement&&/^(button|submit|reset)$/.test(e.type)?e.value:``,i=[n.map(e=>t.getElementById(e)?.textContent??``).join(` `),e.getAttribute(`aria-label`),Array.from(ne(e)??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=C(e);if(t)return t}return``}function ae(e){for(let t of[e,...e.querySelectorAll(ee)])if((t instanceof HTMLElement||t instanceof SVGElement)&&t.tabIndex>=0&&!re(t))return t;return null}function w(e,t,n){let r=(e.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(e=>e&&e!==t);n&&r.push(t),r.length>0?e.setAttribute(`aria-describedby`,r.join(` `)):e.removeAttribute(`aria-describedby`)}function oe(e,t){let n=e.querySelector(`.${b}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;if(!t)n?.remove(),i&&w(e,i,!1);else{if(!n){n=e.ownerDocument.createElement(`p`),n.className=b,i&&(n.id=i);let t=e.querySelector(`.wui-tour-actions`);if(!t)throw Error(`Tour card has no actions row.`);t.before(n)}n.textContent=t,i&&w(e,i,!0)}}function se(e,t){let n=e.querySelector(`.${x}`);if(!t){n?.remove();return}if(n)return;let r=e.ownerDocument.createElement(`span`);r.className=x,r.setAttribute(`aria-hidden`,`true`),e.append(r)}var ce=e=>getComputedStyle(e).animationName;function T(e,{layer:t,spot:n,card:r},i,a){let o=S(i,a);t.toggleAttribute(y,o&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(y)&&(n.removeAttribute(y),o&&ce(n)),o&&n.setAttribute(y,``),se(n,o);let s=r.querySelector(`.wui-tour-next`);if(!(s instanceof HTMLElement))throw Error(`Tour card has no next button.`);s.classList.toggle(`btn-primary`,!o),s.classList.toggle(`btn-link`,o);let c=o?C(i?.actionLabel)||ie(a):``,l=e.getAttribute(`advance-label`)||te().advanceLabel,u=c?l.replace(/\{actionName\}/g,()=>c):``;return oe(r,u),u}function le(e,t,n){if(!S(e,t))return()=>{};let r,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function ue(e,t,n,r){return e.contains(r)||S(t,n)&&n.contains(r)}function de(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=S(r,i)?ae(i):null;o&&a.push(o);let s=a.findIndex(e=>e===n||e===o&&i?.contains(n));e.preventDefault();let c=a[s===-1?e.shiftKey?a.length-1:0:(s+(e.shiftKey?-1:1)+a.length)%a.length];if(!c)throw Error(`Tour card has no focus stop.`);c.focus()}var fe=2/3,pe=1e3,me=/* @__PURE__ */ new Set([`top`,`left`,`width`,`height`]),E=/* @__PURE__ */ new WeakMap,D=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],O=e=>`transitionProperty`in e&&e.transitionProperty===`opacity`,he=e=>`transitionProperty`in e&&typeof e.transitionProperty==`string`&&me.has(e.transitionProperty),ge=e=>`animationName`in e&&typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function k(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,pe);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function _e(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?D(t,he):[]){let t=e.effect?.getComputedTiming?.();if(typeof t?.duration!=`number`)continue;let r=typeof e.currentTime==`number`?e.currentTime:0;n=Math.max(n,(t.delay??0)+t.duration*fe-r)}return n}function A(e){let t=_e(e);t>0?e.style.setProperty(`--wui-tour-card-delay`,`${Math.round(t)}ms`):e.style.removeProperty(`--wui-tour-card-delay`),e.dataset.state=`entering`;let n={};E.set(e,n);let r=()=>{E.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=D(e,ge);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function j(e){return e.dataset.state=`leaving`,k(D(e,O))}function ve(e){let t=e.shadowRoot?.querySelector(`.wui-tour-layer`),n=e.classList.contains(`wui-tour-layer`)?e:t instanceof HTMLElement?t:null;n&&(n.dataset.state=`leaving`);let r=n?k(D(n,O)):null;r?(e.setAttribute(`inert`,``),r.then(()=>e.remove())):e.remove()}var ye=2,M=12,N=8,P=4,F=20,be=`(max-width: 575.98px)`,xe=[`bottom`,`top`,`right`,`left`],Se=[`bottom`,`top`,`left`,`right`],I=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],L,R=(e,t,n)=>Math.max(t,Math.min(e,n)),z=(e,t,n,r)=>(Math.max(e,n)+Math.min(t,r))/2;function Ce(e,t){if(!t?.scrollIntoView)return;e.style.maxHeight=``;let n=V(e),r=e.offsetHeight+M;if(t.getBoundingClientRect().height+4+r*2<=n.bottom-n.top){t.scrollIntoView({block:`center`,inline:`nearest`});return}let i=t.style.scrollMarginTop;t.style.scrollMarginTop=`${n.top+r+ye}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function B(e,t,n){let r=e.style,i=t.style,a=Oe(t);if(!n){r.top=`50%`,r.left=`50%`,r.width=`0px`,r.height=`0px`,r.boxShadow=`0 0 0 100vmax var(--color-scrim-strong)`;for(let e of I)r.removeProperty(`border-${e}-radius`),r.removeProperty(`corner-${e}-shape`);t.dataset.placement=`center`,a.hidden=!0,i.position=`fixed`,i.top=`50%`,i.left=`50%`,i.transform=`translate(-50%, -50%)`,i.maxHeight=`calc(100vh - 16px)`;return}r.boxShadow=``,i.transform=``,i.position=`fixed`;let o=n.getBoundingClientRect();r.top=`${o.top}px`,r.left=`${o.left}px`,r.width=`${o.width}px`,r.height=`${o.height}px`,we(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=V(t),u=l.bottom-l.top,f={bottom:l.bottom-o.bottom-M,top:o.top-M-l.top,right:l.right-o.right-M,left:o.left-M-l.left},p=window.matchMedia(be).matches,m=(d(n)?Se:xe).find(e=>e===`top`||e===`bottom`?c.height<=f[e]+1:!p&&c.width<=f[e]+1&&c.height<=u+1),h=Math.min(o.bottom,l.bottom+N)-Math.max(o.top,l.top-N);m?Te(t,a,m,o,l,c):h>=Math.min(c.height,u)+8?Ee(t,a,o,l,c):De(t,a,f.bottom>=f.top?`bottom`:`top`,o,l,c,f),t.scrollTop=s}function we(e,t){L??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of I)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),L&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function Te(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=z(r.left,r.right,i.left,i.right);s=R(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+M:r.top-M-a.height,l=R(e-s,F,a.width-F)}else{let e=z(r.top,r.bottom,i.top,i.bottom);c=R(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+M:r.left-M-a.width,l=R(e-c,F,a.height-F)}e.dataset.placement=n,e.style.top=`${c}px`,e.style.left=`${s}px`,t.hidden=!1,t.style.left=o?`${l-e.clientLeft-t.offsetWidth/2}px`:``,t.style.top=o?``:`${l-e.clientTop-t.offsetHeight/2}px`}function Ee(e,t,n,r,i){let a=r.bottom-r.top;e.dataset.placement=`overlap`,t.hidden=!0,e.style.maxHeight=i.height>a?`${Math.max(a,0)}px`:``;let o=Math.min(n.bottom,r.bottom)-P;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${R(n.left+P,r.left,r.right-i.width)}px`}function De(e,t,n,r,i,a,o){let s=Math.max(o[n],0),c=Math.min(a.height,s);e.dataset.placement=n,t.hidden=!0,e.style.maxHeight=a.height>s?`${s}px`:``,e.style.top=`${n===`bottom`?r.bottom+M:r.top-M-c}px`;let l=z(r.left,r.right,i.left,i.right);e.style.left=`${R(l-a.width/2,i.left,i.right-a.width)}px`}function V(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e]??``)||0;return{top:r(`paddingTop`)+N,bottom:window.innerHeight-r(`paddingBottom`)-N,left:r(`paddingLeft`)+N,right:window.innerWidth-r(`paddingRight`)-N}}function Oe(e){let t=e.querySelector(`:scope > .wui-tour-arrow`);if(t instanceof HTMLElement)return t;let n=document.createElement(`span`);return n.className=`wui-tour-arrow`,n.setAttribute(`aria-hidden`,`true`),n.hidden=!0,e.append(n),n}var ke=0,Ae=`btn btn-sm btn-link`;function H(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`Expected "${t}" to match a ${n.name}.`);return r}function je(e,t){let a=`wui-tour-end-${++ke}`,{nextLabel:o,nextHref:s}=e,c=o&&s?i(`a`,{class:`${n(`primary`,`solid`,`sm`)} wui-tour-end-next`,"data-wui":r,href:s},o):null,l=c!==null,u=l?Ae:n(`primary`,`solid`,`sm`),d=i(`button`,{type:`button`,class:`${u} wui-tour-end-button`,"data-wui":r},e.button);return i(t?`dialog`:`div`,{class:`wui-tour-card wui-tour-end`,"data-layout":`center`,"data-next":l||void 0,role:`dialog`,tabindex:-1,"aria-labelledby":`${a}-title`,"aria-describedby":`${a}-message`},i(`div`,{class:`wui-tour-end-mark`,"aria-hidden":`true`},g({viewBox:`0 0 24 24`,focusable:`false`},[[`path`,{d:`M5 12.5l4.5 4.5L19 7.5`}]])),i(`h2`,{class:`wui-tour-title wui-tour-end-title`,id:`${a}-title`},e.title),i(`p`,{class:`wui-tour-text wui-tour-end-message`,id:`${a}-message`},e.message),i(`div`,{class:`wui-tour-actions`},c,d))}var Me=e=>e.button===0&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey;function Ne(e,t,n){let r=e.ownerDocument,i=je(t,e.getRootNode()===r),a=H(i,`.wui-tour-end-button`,HTMLButtonElement),o=i.querySelector(`.wui-tour-end-next`);if(o!==null&&!(o instanceof HTMLAnchorElement))throw Error(`The end dialog's next link is not a link.`);let s=o,u=s??a,d=new AbortController,f=i instanceof HTMLDialogElement?i:null,p=null;return new Promise(o=>{let m=e=>{if(d.abort(),p&&f){let e=p;p=null,c(f).then(e)}o(e)};if(n?.aborted){m(`done`);return}let g=H(e,`.wui-tour-card:not(.wui-tour-end)`,HTMLElement),_=H(e,`.wui-tour-spot`,HTMLElement),v=H(e,`[role=status]`,HTMLElement),y={signal:d.signal};n?.addEventListener(`abort`,()=>m(`done`),y),a.addEventListener(`click`,()=>m(`done`),y),s&&s.addEventListener(`click`,e=>{Me(e)&&(e.preventDefault(),m(`next`))},y),r.addEventListener(`keydown`,e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`){if(p)return;e.preventDefault(),e.stopPropagation(),m(`done`)}else h(e)&&s&&!e.shiftKey&&(e.composedPath?.()[0]??e.target)===s&&(e.preventDefault(),m(`next`))}},{capture:!0,signal:d.signal});let b=()=>{d.signal.aborted||(g.hidden=!0,B(_,g,null),e.append(i),A(i),f&&(p=l(f,{escape:!0,backdrop:!1,focus:`first-control`,onRequestClose:()=>m(`done`)})),v.textContent=[t.title,t.message].filter(Boolean).join(`. `),u.focus())},x=j(g);x===null?b():x.then(b)})}var Pe=` :host { all: initial; display: revert-layer; position: fixed; inset: 0; ${Object.entries({"--wui-z-tour":`1550`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-popover":`0px 8px 28px -6px rgba(7, 20, 55, 0.14)`,"--wui-ease-out":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-ease-linear":`cubic-bezier(0, 0, 1, 1)`,"--wui-duration-fast":`150ms`,"--wui-duration-default":`250ms`,"--wui-duration-slow":`400ms`,"--wui-space-xs":`4px`,"--wui-tour-motion-duration":`200ms`,"--wui-tour-motion-ease":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-tour-spot-duration":`240ms`,"--wui-tour-spot-ease":`cubic-bezier(0.32, 0.72, 0, 1)`,"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-text":`#4F46E5`,"--color-focus-ring":`#4F46E5`,"--wui-focus-ring-width":`2px`,"--wui-focus-ring-offset":`2px`,"--color-on-primary":`#FFFFFF`,"--color-success-soft":`#E8FAEE`,"--color-success-text":`#0e7531`,"--color-on-scrim":`#FFFFFF`,"--color-scrim-strong":`color-mix(in srgb, #071437 62%, transparent)`,"--color-surface":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-bg-muted":`#F5F6FA`}).map(([e,t])=>` ${e}: ${t};`).join(` `)} } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; } .btn { display: inline-block; margin: 0; padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; line-height: 1.5; text-align: center; text-decoration: none; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; } .btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); } .btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); } .btn-outline-neutral { border-color: var(--color-text-muted); color: var(--color-text-muted); } .btn-outline-neutral:hover { background: var(--color-bg-muted); color: var(--color-text); } .btn-link { font-weight: 400; color: var(--color-primary-text); text-decoration: underline; } .btn-link:hover { color: var(--color-primary-hover); } .wui-tour-layer { pointer-events: none; font-family: "Webority Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-weight: 400; line-height: 1.5; color: var(--color-text); text-align: start; } .wui-tour-card { pointer-events: auto; } .wui-tour-layer { position: fixed; inset: 0; z-index: var(--wui-z-tour); width: auto; height: auto; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; overflow: visible; background: none; } .wui-tour-spot { position: fixed; box-shadow: 0 0 0 2px var(--color-primary), 0 0 4px 2px color-mix(in srgb, var(--color-primary) 30%, transparent), 0 0 0 100vmax var(--color-scrim-strong); pointer-events: none; } .wui-tour-card { display: flex; flex-direction: column; gap: 8px; width: min(360px, 100vw - 16px); padding: 16px; overflow-y: auto; background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--wui-radius-lg); corner-shape: squircle; box-shadow: var(--wui-shadow-popover); } .wui-tour-card:focus { outline: none; } .wui-tour-card:focus-visible { outline: var(--wui-focus-ring-width) solid var(--color-focus-ring); outline-offset: var(--wui-focus-ring-offset); } .wui-tour-title { margin: 0; font-size: 16px; font-weight: 600; } .wui-tour-text { margin: 0; font-size: 14px; color: var(--color-text-muted); } .wui-tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; } .wui-tour-nav { display: flex; gap: 8px; } .wui-tour-skip { color: var(--color-text-muted); } .wui-tour-back, .wui-tour-next { min-width: 64px; } @keyframes wui-tour-fade-in { from { opacity: 0; } to { opacity: 1; } } @keyframes wui-tour-card-enter { from { opacity: 0; scale: 0.96; translate: var(--wui-tour-card-lift, 0 6px); } to { opacity: 1; scale: 1; translate: 0 0; } } .wui-tour-layer[data-state=leaving], .wui-tour-card[data-state=leaving] { opacity: 0; } .wui-tour-layer[data-state=leaving], .wui-tour-layer[data-state=leaving] * { pointer-events: none; } @media (prefers-reduced-motion: no-preference) { .wui-tour-layer { animation: wui-tour-fade-in var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-layer[data-state=leaving] { transition: opacity var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-spot { transition: top var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), left var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), width var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), height var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), border-radius var(--wui-tour-spot-duration) var(--wui-tour-spot-ease); } .wui-tour-spot[data-tracking] { transition: none; } .wui-tour-card { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=top] { --wui-tour-card-lift: 0 -6px; transform-origin: bottom center; } .wui-tour-card[data-placement=bottom] { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=left] { --wui-tour-card-lift: -6px 0; transform-origin: right center; } .wui-tour-card[data-placement=right] { --wui-tour-card-lift: 6px 0; transform-origin: left center; } .wui-tour-card[data-placement=overlap], .wui-tour-card[data-placement=center] { --wui-tour-card-lift: 0 0; transform-origin: center; } .wui-tour-card[data-state=entering] { animation: wui-tour-card-enter var(--wui-tour-motion-duration) var(--wui-tour-motion-ease) var(--wui-tour-card-delay, 0ms) both; } .wui-tour-card[data-state=leaving] { transition: opacity calc(var(--wui-tour-motion-duration) / 2) var(--wui-tour-motion-ease); } } @media (prefers-reduced-motion: reduce) { .wui-tour-layer { animation: wui-tour-fade-in var(--wui-duration-fast) var(--wui-ease-linear); } .wui-tour-layer[data-state=leaving] { transition: opacity var(--wui-duration-fast) var(--wui-ease-linear); } .wui-tour-card[data-state=entering] { animation: wui-tour-fade-in var(--wui-duration-fast) var(--wui-ease-linear) both; } } .wui-tour-progress-bar { display: flex; gap: 4px; } .wui-tour-progress-segment { flex: 1 1 0; height: 4px; border-radius: 999px; background: var(--color-border); } .wui-tour-progress-segment[data-filled] { background: var(--color-primary); } .wui-tour-position { margin: 0; font-size: 12px; color: var(--color-text-muted); } .wui-tour-layer { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); } .wui-tour-card:has(.wui-tour-arrow:not([hidden])) { overflow: visible; } .wui-tour-arrow { position: absolute; width: 8px; height: 8px; background: var(--color-surface); border: 1px solid var(--color-border); rotate: 45deg; pointer-events: none; } .wui-tour-card[data-placement=bottom] .wui-tour-arrow { top: -5px; border-right-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=top] .wui-tour-arrow { bottom: -5px; border-top-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=right] .wui-tour-arrow { left: -5px; border-top-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=left] .wui-tour-arrow { right: -5px; border-bottom-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } @media (max-width: 575.98px) { .wui-tour-card { width: calc(100vw - 16px); } .wui-tour-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; } } .wui-tour-media { position: relative; order: -1; flex: none; aspect-ratio: 16/9; margin: -16px -16px 4px; overflow: hidden; background: var(--color-border); } .wui-tour-media>img, .wui-tour-media>video { display: block; width: 100%; height: 100%; object-fit: cover; } .wui-tour-card[data-welcome] { width: min(420px, 100vw - 16px); } .wui-tour-media-toggle { position: absolute; inset-block-end: 8px; inset-inline-end: 8px; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--color-scrim-strong); color: var(--color-on-scrim); cursor: pointer; } .wui-tour-media-toggle>svg { width: 20px; height: 20px; fill: currentColor; } .wui-tour-media-toggle:focus-visible { outline: 2px solid var(--color-on-scrim); outline-offset: var(--wui-focus-ring-offset); } .wui-tour-layer[data-advance] { pointer-events: none; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-card { pointer-events: auto; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-spot::before { content: ""; position: absolute; inset: -100vmax; pointer-events: auto; clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, 100vmax 100vmax, calc(100% - 100vmax) 100vmax, calc(100% - 100vmax) calc(100% - 100vmax), 100vmax calc(100% - 100vmax), 100vmax 100vmax); } .wui-tour-hint { margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text); } .wui-tour-pointer { position: absolute; top: 50%; left: 50%; width: 18px; height: 24px; pointer-events: none; } .wui-tour-pointer::before { content: ""; position: absolute; inset: 0; background: var(--color-primary); clip-path: polygon(0 0, 0 75%, 28% 58%, 46% 100%, 62% 92%, 45% 52%, 85% 52%); filter: drop-shadow(1px 0 0 var(--color-surface)) drop-shadow(-1px 0 0 var(--color-surface)) drop-shadow(0 1px 0 var(--color-surface)) drop-shadow(0 -1px 0 var(--color-surface)); } .wui-tour-pointer::after { content: ""; position: absolute; top: -16px; left: -16px; width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); opacity: 0; display: none; } @media (max-width: 575.98px) { .wui-tour-pointer { width: 24px; height: 24px; translate: -50% -50%; } .wui-tour-pointer::before { clip-path: none; border-radius: 50%; box-shadow: 0 0 0 2px var(--color-surface); filter: none; } .wui-tour-pointer::after { top: -4px; left: -4px; } } @keyframes wui-tour-tap { 0% { opacity: 0; transform: translate(56px, 44px) scale(1); } 10% { opacity: 1; transform: translate(56px, 44px) scale(1); } 45% { transform: translate(0, 0) scale(1); } 52% { transform: translate(0, 0) scale(0.86); } 60% { transform: translate(0, 0) scale(1); } 85% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(0, 0) scale(1); } } @keyframes wui-tour-tap-rtl { 0% { opacity: 0; transform: translate(-56px, 44px) scale(1); } 10% { opacity: 1; transform: translate(-56px, 44px) scale(1); } 45% { transform: translate(0, 0) scale(1); } 52% { transform: translate(0, 0) scale(0.86); } 60% { transform: translate(0, 0) scale(1); } 85% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(0, 0) scale(1); } } @keyframes wui-tour-ripple { 0%, 50% { opacity: 0; transform: scale(0.2); } 52% { opacity: 0.35; transform: scale(0.2); } 80%, 100% { opacity: 0; transform: scale(1); } } @media (prefers-reduced-motion: no-preference) { .wui-tour-pointer { opacity: 0; animation: wui-tour-tap calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } .wui-tour-pointer:dir(rtl) { animation-name: wui-tour-tap-rtl; } .wui-tour-pointer::after { display: block; animation: wui-tour-ripple calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } } @keyframes wui-tour-check { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } } .wui-tour-end[data-layout=center] { --wui-tour-card-lift: 0 0; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); transform-origin: center; align-items: center; gap: 8px; width: min(420px, 100vw - 16px); max-height: calc(100vh - 16px); padding: 24px; text-align: center; } .wui-tour-end[data-layout=center] .wui-tour-actions { justify-content: center; margin-top: 8px; } .wui-tour-end[data-layout=center][data-next] .wui-tour-actions { flex-direction: column; align-items: stretch; width: 100%; gap: var(--wui-space-xs); } .wui-tour-end-mark { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; background: var(--color-success-soft); color: var(--color-success-text); } .wui-tour-end-mark>svg { width: 26px; height: 26px; } .wui-tour-end-mark path { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; } .wui-tour-end-title { font-size: 18px; } .wui-tour-end-message { text-wrap: balance; } .wui-tour-end-next { text-wrap: balance; } .wui-tour-end-button { min-width: 120px; } @media (prefers-reduced-motion: no-preference) { .wui-tour-end-mark path { animation: wui-tour-check var(--wui-duration-default) var(--wui-ease-out) calc(var(--wui-tour-card-delay, 0ms) + var(--wui-duration-fast)) both; } } `,U=()=>f(`tour`,p),W=`wui-tour-media`,Fe=`wui-tour-media-toggle`,G=`http://www.w3.org/2000/svg`,Ie=`M6 5h4v14H6zM14 5h4v14h-4z`,Le=`M8 5v14l11-7z`,Re=()=>({pause:U().mediaPauseLabel,play:U().mediaPlayLabel}),ze=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function Be(e){let t=document.createElementNS(G,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(G,`path`);return n.setAttribute(`d`,e),t.appendChild(n),t}function Ve(e){let t=document.createElement(`img`);return t.setAttribute(`alt`,e.mediaAlt??``),t.setAttribute(`width`,`1280`),t.setAttribute(`height`,`720`),t.setAttribute(`loading`,`lazy`),t.setAttribute(`decoding`,`async`),t.setAttribute(`src`,e.media??``),t}function He(e,t){let n=document.createElement(`video`);return n.muted=!0,n.setAttribute(`muted`,``),n.loop=!0,n.setAttribute(`playsinline`,``),t&&n.setAttribute(`autoplay`,``),n.setAttribute(`preload`,t?`auto`:`metadata`),e.mediaAlt&&n.setAttribute(`aria-label`,e.mediaAlt),e.mediaPoster&&n.setAttribute(`poster`,e.mediaPoster),n.setAttribute(`src`,e.media??``),n}function Ue(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=Fe;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(Be(r?Ie:Le))};return e.addEventListener(`play`,()=>r()),e.addEventListener(`pause`,()=>r()),n.addEventListener(`click`,()=>{e.paused?e.play()?.catch(()=>r()):e.pause()}),r(e.hasAttribute(`autoplay`)),n}function We(e){let t=e.querySelector(`:scope > .${W}`);if(!t)return;let n=t.querySelector(`video`);n&&(n.pause(),n.removeAttribute(`src`),n.load()),t.remove()}function Ge(e,t,n=Re()){if(We(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=W,t.mediaType===`video`){let e=He(t,!ze());r.append(e,Ue(e,n))}else r.appendChild(Ve(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var Ke=()=>f(`tour`,p);function K(e){let t=/* @__PURE__ */ new Set;return{drop:e=>{t.add(e)},position:e=>{t.delete(e);let n=0;for(let r of t)r<e&&n++;return e+1-n},total:()=>e-t.size}}function qe(e,t,n){return(e.getAttribute(`progress-label`)||Ke().progressLabel).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function Je(e,{text:t,position:n,total:r}){let i=e.querySelector(`.wui-tour-position`);if(!(i instanceof HTMLElement))throw Error(`tour position label missing`);i.textContent=t;let a=e.querySelector(`.wui-tour-progress-bar`);if(!a){let t=e.ownerDocument,n=t.createElement(`div`);n.className=`wui-tour-progress`,n.setAttribute(`aria-hidden`,`true`),a=t.createElement(`div`),a.className=`wui-tour-progress-bar`,n.append(a),i.before(n)}let o=a.children;for(;o.length<r;){let t=e.ownerDocument.createElement(`span`);t.className=`wui-tour-progress-segment`,a.append(t)}for(;o.length>r;){let e=a.lastElementChild;if(!e)throw Error(`progress bar segment missing`);e.remove()}for(let e=0;e<o.length;e++){let t=o[e];if(!t)throw Error(`progress bar segment missing`);t.toggleAttribute(`data-filled`,e<n)}}var Ye=`wui-tour-step`,Xe=`wui-tour-host`,q=`data-tracking`,J=()=>f(`tour`,p),Ze=()=>({back:J().backLabel,next:J().nextLabel,skip:J().skipLabel,done:J().doneLabel,mediaPause:J().mediaPauseLabel,mediaPlay:J().mediaPlayLabel,endTitle:J().endTitle,endMessage:J().endMessage,endButton:J().doneLabel}),Qe={back:`back-label`,next:`next-label`,skip:`skip-label`,done:`done-label`,mediaPause:`media-pause-label`,mediaPlay:`media-play-label`,endTitle:`end-title`,endMessage:`end-message`,endButton:`end-button`},$e=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],Y={index:null,position:null,total:null},et=0,X=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,Z=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function Q(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`<wui-tour> layer has no ${t}`);return r}var tt=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},$=null;function nt(e){$||($=new CSSStyleSheet,$.replaceSync(Pe)),e.adoptedStyleSheets=[$]}var rt=class extends a{seenStore;onBeforeStep;_run;_running;_layer;_outer;_shadow;_unbindAdvance;_ending;_seenMark;_steps=[];_progress=K(0);_firstIndex=0;_returnFocus=null;_current=null;_moving=!1;_card=null;_spot=null;_live=null;_onKey=null;_onFocusIn=null;static get observedAttributes(){return[`open`]}constructor(){super(),this.seenStore=null,this.onBeforeStep=null,this._run=0,this._running=!1,this._layer=null,this._outer=null,this._shadow=null,this._unbindAdvance=null,this._ending=null,this._seenMark=null}connectedCallback(){this.hasAttribute(`open`)&&this.start()}disconnectedCallback(){this.stop()}attributeChangedCallback(e,t,n){e===`open`&&this.isConnected&&(n===null?this.stop():this.start())}get tourId(){return this.getAttribute(`tour-id`)||``}set tourId(e){e==null||e===``?this.removeAttribute(`tour-id`):this.setAttribute(`tour-id`,String(e))}get isolated(){return this.hasAttribute(`isolated`)}set isolated(e){this.toggleAttribute(`isolated`,e===!0||e===``||e===`true`)}_stepList(){return Array.from(this.querySelectorAll(`:scope > ${Ye}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:(e.textContent??``).trim()};for(let[n,r]of $e)e.hasAttribute(r)&&(t[n]=e.getAttribute(r)??``);return t})}_stepAt(e){let t=this._steps[e];if(!t)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);return t}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?v():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(Qe[e])||Ze()[e]}_endDialogText(){if(this.getAttribute(`end-dialog`)===`false`)return null;let e=(this.getAttribute(`end-next-label`)??``).trim(),t=(this.getAttribute(`end-next-href`)??``).trim();return{title:this._label(`endTitle`),message:this._label(`endMessage`),button:this._label(`endButton`),nextLabel:e,nextHref:t}}_markSeen(e){let t=this._store();return t?t.markSeen(this.tourId,e):null}async start(){if(this._running)return;this._running=!0;let e=++this._run;this.hasAttribute(`open`)||this.setAttribute(`open`,``);try{await this._start(e)}catch(t){throw e===this._run&&(this._running=!1),t}}async _start(e){this._steps=this._stepList(),this._progress=K(this._steps.length);let t=this._store();if(t&&!this.tourId)throw Error(`<wui-tour> needs a tour-id to use a seen store.`);if(t&&await t.isSeen(this.tourId)){e===this._run&&this._finish(`alreadySeen`);return}for(let[e,t]of this._steps.entries())t.target&&!X(document.querySelector(t.target))&&this._progress.drop(e);this._returnFocus=document.activeElement;let n=await this._locate(0,1,e);e===this._run&&(n?(this._firstIndex=n.index,this.dispatchEvent(new CustomEvent(`wui-tour:start`,{bubbles:!0,detail:{total:this._progress.total()}})),e===this._run&&(this._build(),this._show(n))):this._finish(`noTargets`))}next(){return this._move(1)}back(){return!this._current||this._current.index<=this._firstIndex?Promise.resolve():this._move(-1)}async goTo(e){if(this._current){if(!Number.isInteger(e)||e<0||e>=this._steps.length)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);await this._go(e,1)}}stop(){this._running&&(this._run++,this._teardown(),this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`))}async _locate(e,t,n){let r=this._steps;for(let i=e;i>=0&&i<r.length;i+=t){let e=r[i];if(!e)break;if(await this._beforeStep(e,i),n!==this._run)return null;if(!e.target)return{index:i,target:null};let t=document.querySelector(e.target),a=t instanceof HTMLElement||t instanceof SVGElement?t:null;if(X(a))return this._progress.position(i),{index:i,target:a};this._progress.drop(i)}return null}async _beforeStep(e,t){let n=[];this.dispatchEvent(new CustomEvent(`wui-tour:beforestep`,{bubbles:!0,detail:{step:e,index:t,wait:e=>n.push(e)}})),await Promise.all(n),typeof this.onBeforeStep==`function`&&await this.onBeforeStep(e,t)}_build(){let t=`wui-tour-${++et}`,a=document.createElement(`div`);a.className=`wui-tour-layer`,a.replaceChildren(i(`div`,{class:`wui-tour-spot`,"aria-hidden":`true`}),i(`div`,{class:`wui-tour-card`,role:`dialog`,tabindex:`-1`,"aria-labelledby":`${t}-title`,"aria-describedby":`${t}-text`},i(`p`,{class:`wui-tour-position`}),i(`h2`,{class:`wui-tour-title`,id:`${t}-title`}),i(`p`,{class:`wui-tour-text`,id:`${t}-text`}),i(`div`,{class:`wui-tour-actions`},i(`button`,{type:`button`,class:`btn btn-sm btn-link wui-tour-skip`}),i(`div`,{class:`wui-tour-nav`},i(`button`,{type:`button`,class:`${n(`neutral`,`outline`,`sm`)} wui-tour-back`,"data-wui":r}),i(`button`,{type:`button`,class:`${n(`primary`,`solid`,`sm`)} wui-tour-next`,"data-wui":r})))),i(`div`,{class:`visually-hidden`,role:`status`,"aria-live":`polite`}));let s=a;this._shadow=null,this.isolated&&(s=document.createElement(Xe),this._shadow=s.attachShadow({mode:`open`}),nt(this._shadow),this._shadow.appendChild(a)),s.setAttribute(`popover`,`manual`),o(document).appendChild(s),document.documentElement.setAttribute(_,``),this._outer=s,this._layer=a;let c=Q(a,`.wui-tour-spot`,HTMLDivElement),l=Q(a,`.wui-tour-card`,HTMLDivElement),u=Q(a,`[role=status]`,HTMLElement);this._spot=c,this._card=l,this._live=u,Q(l,`.wui-tour-skip`,HTMLElement).addEventListener(`click`,()=>this._close(`skipped`,`button`)),Q(l,`.wui-tour-back`,HTMLElement).addEventListener(`click`,()=>this._move(-1)),Q(l,`.wui-tour-next`,HTMLElement).addEventListener(`click`,()=>this._move(1));let d=e=>this._key(e);this._onKey=d;let f=e=>{let t=this._layer;if(!t||this._ending)return;let n=this._current,r=n?this._stepAt(n.index):null;if(!(e.target instanceof Node))throw Error(`<wui-tour> saw a focus change from a non-node target`);ue(t,r,n?.target??null,e.target)||l.focus()};this._onFocusIn=f,document.addEventListener(`keydown`,d,!0),this._shadow||document.addEventListener(`focusin`,f),e(s,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_raise(){let e=this._outer;if(!e)throw Error(`<wui-tour> raises a step before its host is built`);let t=o(this.ownerDocument);e.parentElement!==t&&t.appendChild(e),s(e)}_show(e){this._current=e;let{index:t,target:n}=e,r=this._stepAt(t),i=this._layer,a=this._spot,o=this._card,s=this._live;if(!i||!a||!o||!s)throw Error(`<wui-tour> shows a step before its layer is built`);this._raise();let c=this._progress.position(t),l=this._progress.total(),u=c===l&&!this._endDialogText(),d=qe(this,c,l);Je(o,{text:d,position:c,total:l}),Ge(o,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)}),o.toggleAttribute(`data-welcome`,!n);let f=T(this,{layer:i,spot:a,card:o},r,n),p=Q(o,`.wui-tour-title`,HTMLElement);p.textContent=r.title||``,p.hidden=!r.title,Q(o,`.wui-tour-text`,HTMLElement).textContent=r.description||``,Q(o,`.wui-tour-skip`,HTMLElement).textContent=this._label(`skip`);let m=Q(o,`.wui-tour-back`,HTMLElement);m.textContent=this._label(`back`),m.hidden=t<=this._firstIndex,Q(o,`.wui-tour-next`,HTMLElement).textContent=this._label(u?`done`:`next`);let h=[d,r.title,r.description].filter(Boolean).join(`. `);s.textContent=f?[h,f].join(/[.!?]$/.test(h)?` `:`. `):h,Ce(o,n),a.removeAttribute(q),this._place(),A(o),this._unbindAdvance?.(),this._unbindAdvance=le(r,n,()=>void this._move(1));let g=this._active();(g!==null&&o.contains(g)?!(g instanceof HTMLElement&&g.hidden):this._shadow!==null&&Z(tt()))||o.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t,position:c,total:l}}))}_place(){if(!this._current||!this._layer)return;let e=this._spot,t=this._card;if(!e||!t)throw Error(`<wui-tour> places a step before its layer is built`);B(e,t,this._current.target)}_follow(){if(!this._current||!this._layer||this._ending)return;let e=this._spot;if(!e)throw Error(`<wui-tour> follows a step before its spot is built`);let t=e.style.cssText;this._place(),e.style.cssText!==t&&e.setAttribute(q,``)}async _move(e){this._current&&await this._go(this._current.index+e,e)}async _go(e,t){if(!this._current||this._moving)return;this._moving=!0;let n=this._run;try{let r=await this._locate(e,t,n);if(n!==this._run)return;if(r){let e=this._card;if(!e)throw Error(`<wui-tour> moved with no card showing`);let t=j(e);if(t!==null&&await t,n!==this._run)return;this._show(r)}else if(t>0){let e=this._endDialogText(),t=e?await this._showEnd(e):`done`;if(n!==this._run)return;let r=await this._close(t===`next`?`next`:`finished`);if(t===`next`&&r&&e){let t=this.ownerDocument.defaultView;if(!t)throw Error(`<wui-tour> has no window to follow its next link in`);t.location.assign(e.nextHref)}}}finally{this._moving=!1}}_showEnd(e){this._unbindAdvance?.(),this._unbindAdvance=null;let t=this._layer,n=this._spot,r=this._card;if(!t||!n||!r)throw Error(`<wui-tour> ends a tour before its layer is built`);return T(this,{layer:t,spot:n,card:r},null,null),n.removeAttribute(q),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),Ne(t,e,this._ending.signal)}_key(e){if(!this._layer||this._ending||e.altKey||e.ctrlKey||e.metaKey)return;let t=u(e.key,d(this));if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this._close(`skipped`,`escape`);else if(t===`ArrowRight`||t===`ArrowLeft`){if(Z(e.composedPath?.()[0]??e.target))return;if(e.preventDefault(),t===`ArrowRight`)this._move(1);else{let e=this._current;if(!e)throw Error(`<wui-tour> moved back with no step showing`);e.index>this._firstIndex&&this._move(-1)}}else if(e.key===`Tab`&&!this._shadow){let t=this._current,n=this._card;if(!t||!n)throw Error(`<wui-tour> cycled focus with no step showing`);de(e,{card:n,active:this._active(),step:this._stepAt(t.index),target:t.target})}}_teardown(){if(!this._layer)return;this._onKey&&document.removeEventListener(`keydown`,this._onKey,!0),this._onFocusIn&&document.removeEventListener(`focusin`,this._onFocusIn);let e=!this._shadow||this._shadow.activeElement!==null||!document.activeElement||document.activeElement===document.body;this._unbindAdvance?.(),this._unbindAdvance=null,this._ending?.abort(),this._ending=null,this._seenMark=null;let n=this._outer;if(t(n),!n)throw Error(`<wui-tour> has a layer with no host to remove`);ve(n),document.documentElement.removeAttribute(_),this._outer=null,this._shadow=null,this._layer=null,this._current=null;let r=this._returnFocus;this._returnFocus=null,e&&r?.isConnected&&(r instanceof HTMLElement||r instanceof SVGElement)&&r.focus()}async _close(e,t=null){let n=this._run,r=this._current,i=r?{index:r.index,position:this._progress.position(r.index),total:this._progress.total()}:Y,a=this._seenMark;this._teardown();let o=e===`next`?`finished`:e,s=!1;try{n===this._run&&await(a??this._markSeen(o)),s=n===this._run}finally{this._finish(e,i,t)}return s}_finish(e,t=Y,n=null){this._run++,this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`),this.dispatchEvent(new CustomEvent(`wui-tour:close`,{bubbles:!0,detail:{reason:e,...t,via:n}}))}};export{rt as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./devWarn-DXdRWZs3.js";import{r as t}from"./dom-DMQu--xV.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{n as r,t as i}from"./formMirror-9IpSgeZb.js";import{t as a}from"./hasOwn-CJsplJ62.js";import{t as o}from"./iconGlyphs.g-Dj8sa1HF.js";import{t as s}from"./listboxKeyNav-DtlIOryj.js";import{n as c,t as l}from"./rtl-g7G8Bsib.js";import{n as u,r as d,t as f}from"./window-BZWK3rQk.js";import{d as p}from"./wuiHttp-BWf9dDsZ.js";import{r as m}from"./textStore-DBplASiZ.js";import{t as h}from"./tree.g-RId8xZSk.js";var g=()=>m(`tree`,h),_=[`none`,`single`,`multiple`],v=e=>_.some(t=>t===e),y=300,b=8,x=300,S=`parentId`,C=`:scope > input[data-wui-mirror]`,w=[`nodes`,`selection`,`selected`,`values`,`loadChildren`,`loadUrl`,`name`],T=0;function E(e){for(let t=e;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement)if(/^(auto|scroll|overlay)$/.test(getComputedStyle(t).overflowY))return t;return null}var D=class extends n{_uid;_seq;_roots;_byId;_prev;_staged;_els;_checked;_selected;_focusId;_loader;_list;_live;_ready;_flat;_win;_rowH;_rowMeasured;_box;_unbind;_frame;_nav;_onKeyDown;_onClick;_onFocusIn;static get observedAttributes(){return[`selection`,`selected`,`name`,`aria-label`,`loading-text`,`error-text`]}constructor(){super(),this._uid=`wui-tree-${++T}`,this._seq=0,this._roots=[],this._byId=/* @__PURE__ */ new Map,this._prev=null,this._staged=null,this._els=/* @__PURE__ */ new Map,this._checked=/* @__PURE__ */ new Set,this._selected=null,this._focusId=null,this._loader=null,this._list=null,this._live=null,this._ready=!1,this._flat=null,this._win=null,this._rowH=36,this._rowMeasured=!1,this._box=null,this._unbind=null,this._frame=0,this._nav=s({getVisibleOptions:()=>[...this._els.values()].map(e=>e.row),getActive:()=>this._visible().findIndex(e=>e.id===this._focusId),setActive:e=>this._focusNode(this._visible()[e]),getCount:()=>this._visible().length,getOptionAt:e=>this._els.get(this._visible()[e]?.id??``)?.row,findByPrefix:e=>this._visible().findIndex(t=>t.label.toLowerCase().startsWith(e)),onEnter:()=>{let e=this._focusId===null?void 0:this._byId.get(this._focusId);e&&this._activate(e)}}),this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>this._handleClick(e),this._onFocusIn=e=>{if(e.target===this._list){this._focusNode(this._focusId===null?void 0:this._byId.get(this._focusId));return}let t=this._nodeFrom(e.target);t&&t.id!==this._focusId&&this._setRoving(t)}}connectedCallback(){let e=/* @__PURE__ */ new Map;for(let t of w)a(this,t)&&(e.set(t,Reflect.get(this,t)),Reflect.deleteProperty(this,t));if(!this._ready){this._ready=!0;let e=this._readScript();this.replaceChildren(),this._list=t(`ul`,{class:`wui-tree`}),this._list.setAttribute(`role`,`tree`),this._live=t(`div`,{class:`visually-hidden`,role:`status`,"aria-live":`polite`}),this.append(this._list,this._live),e&&this._adoptAll(e)}for(let[t,n]of e)Reflect.set(this,t,n);this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`focusin`,this._onFocusIn),this._render(),this._loadOpenNodes()}disconnectedCallback(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`focusin`,this._onFocusIn),this._unbindWindow(),this._nav.teardown()}attributeChangedCallback(e,t,n){e===`selected`&&(this._selected=n),this._ready&&this.isConnected&&this._render()}get nodes(){return this._roots.map(e=>e.raw)}set nodes(e){this._adoptAll(e??[]),this._render(),this._loadOpenNodes()}get selection(){let e=this.getAttribute(`selection`);return v(e)?e:`none`}set selection(e){this.setAttribute(`selection`,String(e))}get selected(){return this._selected}set selected(e){this._selected=e==null?null:String(e),this._render()}get values(){let e=[],t=n=>{for(let r of n)this._state(r)===`checked`&&e.push(r.id),r.children&&t(r.children)};return t(this._roots),[...e,...[...this._checked].filter(e=>!this._byId.has(e))]}set values(e){this._checked.clear();for(let t of e??[]){let e=this._byId.get(String(t));e?this._setChecked(e,!0):this._checked.add(String(t))}this._render()}get loadChildren(){return this._loader}set loadChildren(e){this._loader=typeof e==`function`?e:null}get loadUrl(){return this.getAttribute(`load-url`)}set loadUrl(e){e==null?this.removeAttribute(`load-url`):this.setAttribute(`load-url`,String(e))}get name(){return this.getAttribute(`name`)}set name(e){e==null?this.removeAttribute(`name`):this.setAttribute(`name`,String(e))}get loadingText(){return this.getAttribute(`loading-text`)??g().loadingText}set loadingText(e){this.setAttribute(`loading-text`,String(e??``))}get errorText(){return this.getAttribute(`error-text`)??g().errorText}set errorText(e){this.setAttribute(`error-text`,String(e??``))}_readScript(){let t=this.querySelector(`:scope > script[type='application/json']`);if(!t)return null;try{return JSON.parse(t.textContent??``)}catch(t){return e(`[@webority/ui-elements] <wui-tree> could not read its JSON nodes:`,t instanceof Error?t.message:void 0),null}}_adoptAll(e){this._flat=null;let t=this._byId;this._prev=t,this._byId=/* @__PURE__ */ new Map;let n;try{n=this._adoptStaged(e,null,1)}catch(e){throw this._byId=t,e}finally{this._prev=null}this._roots=n;for(let e of t.keys())this._byId.has(e)||this._checked.delete(e);for(let e of this._roots)this._passChecksDown(e);this._focusId&&!this._byId.has(this._focusId)&&(this._focusId=null)}_adoptStaged(e,t,n){let r=[],i=[];this._staged={ids:r,checks:i};try{let r=this._adopt(e,t,n);for(let e of i)this._checked.add(e);return r}catch(e){for(let e of r)this._byId.delete(e);throw e}finally{this._staged=null}}_adopt(e,t,n){if(!Array.isArray(e))throw Error(`<wui-tree> nodes must be an array.`);return e.map((e,r)=>{let i=e?.id==null?``:String(e.id);if(!i)throw Error(`<wui-tree> every node needs an id.`);if(this._byId.has(i))throw Error(`<wui-tree> node id "${i}" is used twice.`);let a=this._prev?.get(i),o={id:i,raw:e,parent:t,level:n,seq:++this._seq,pos:r,label:e.label==null?i:String(e.label),icon:e.icon||null,badge:e.badge==null||e.badge===``?null:String(e.badge),badgeTone:e.badgeTone||null,disabled:!!e.disabled,hasChildren:!!e.hasChildren,children:null,expanded:a?a.expanded:!!e.expanded,loading:!1,failed:!1};this._byId.set(i,o),this._staged?.ids.push(i);let s=e.children??(e.hasChildren?a?.children?.map(e=>e.raw):void 0);return Array.isArray(s)&&(o.children=this._adopt(s,o,n+1)),o.loading=!!a?.loading&&o.children===null&&o.hasChildren,e.checked&&!a&&this._staged?.checks.push(i),o})}_passChecksDown(e){e.children?.length&&this._checked.has(e.id)&&(this._checked.delete(e.id),this._setChecked(e,!0));for(let t of e.children??[])this._passChecksDown(t)}_loadOpenNodes(){queueMicrotask(()=>{if(this.isConnected)for(let e of[...this._byId.values()])e.expanded&&e.children===null&&e.hasChildren&&!e.loading&&this._load(e)})}_isBranch(e){return e.children?e.children.length>0:e.hasChildren}_visible(){if(this._flat)return this._flat;let e=[],t=n=>{for(let r of n)e.push(r),r.expanded&&r.children&&t(r.children)};return t(this._roots),this._flat=e,e}_state(e){if(e.children?.length){let t=0,n=0;for(let r of e.children){let e=this._state(r);e===`checked`?t++:e===`unchecked`&&n++}return t===e.children.length?`checked`:n===e.children.length?`unchecked`:`mixed`}return this._checked.has(e.id)?`checked`:`unchecked`}_setChecked(e,t){if(e.children?.length)for(let n of e.children)n.disabled||this._setChecked(n,t);else t?this._checked.add(e.id):this._checked.delete(e.id)}_nodeFrom(e){if(!(e instanceof Element))return null;let t=e.closest(`li.wui-tree-item`);if(!t)return null;for(let[e,n]of this._els)if(n.li===t)return this._byId.get(e)??null;return null}_emit(e,t){this.dispatchEvent(new CustomEvent(`wui-tree:${e}`,{detail:t,bubbles:!0,composed:!0}))}_announce(e){this._live&&(this._live.textContent=e)}_setRoving(e){let t=this._focusId===null?void 0:this._els.get(this._focusId);t&&(t.li.tabIndex=-1),this._focusId=e.id;let n=this._els.get(e.id);n&&(n.li.tabIndex=0),this._syncTab()}_syncTab(){this._list&&(this._focusId!==null&&!this._els.has(this._focusId)?this._list.tabIndex=0:this._list.removeAttribute(`tabindex`))}_focusNode(e){e&&(this._win&&!this._els.has(e.id)&&this._reveal(e),this._setRoving(e),this._els.get(e.id)?.li.focus())}_activate(e){e.disabled||(this.selection===`single`&&(this._selected=e.id,this._render(),this._syncForm()),this._emit(`select`,{id:e.id,node:e.raw}))}_enabledLeaves(e){return e.disabled?[]:e.children?.length?e.children.flatMap(e=>this._enabledLeaves(e)):[e]}_toggleCheck(e){let t=this._enabledLeaves(e);if(!t.length)return;let n=!t.every(e=>this._checked.has(e.id));this._setChecked(e,n),this._render(),this._syncForm(),this._emit(`check`,{id:e.id,checked:n,values:this.values})}_toggleExpand(e){!e.disabled&&this._isBranch(e)&&(e.expanded?(e.expanded=!1,this._render()):this._expand(e))}_expand(e){e.expanded=!0,e.children===null?this._load(e):this._render()}async _load(e){if(e.loading)return;e.loading=!0,e.failed=!1,this._announce(this.loadingText),this._render();let t=[],n=null;try{t=await this._fetchChildren(e)}catch(e){n=e}let r=this._byId.get(e.id);if(!r)this._announce(``);else if(r.loading){if(r.loading=!1,!n)try{r.children=this._adoptStaged(t,r,r.level+1),this._passChecksDown(r),this._announce(``)}catch(e){n=e}n&&(r.failed=!0,r.expanded=!1,this._announce(this.errorText),this._emit(`error`,{id:r.id,message:n instanceof Error?n.message:String(n)})),this._render(),this._syncForm()}}async _fetchChildren(e){if(this._loader)return this._loader(e.raw);let t=this.getAttribute(`load-url`);if(!t)throw Error(`<wui-tree> has a node with children to load but no loadChildren or load-url.`);let n=new URL(t,window.location.href);n.searchParams.set(S,e.id);let r=await p(n.href,{headers:{Accept:`application/json`}});if(!r.ok)throw Error(`Loading children answered ${r.kind}.`);return JSON.parse(r.html)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=this._nodeFrom(t);n&&!n.disabled&&(this._focusNode(n),t.closest(`.wui-tree-toggle`)?this._toggleExpand(n):t.closest(`.wui-tree-check`)?(e.preventDefault(),this._toggleCheck(n)):this._activate(n))}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=this._nodeFrom(e.target);if(!t||e.target!==this._els.get(t.id)?.li)return;let n=c(e.key,l(this));if(n===`ArrowRight`){if(e.preventDefault(),!this._isBranch(t)||t.disabled)return;t.expanded?t.children?.length&&this._focusNode(t.children[0]):this._expand(t)}else n===`ArrowLeft`?(e.preventDefault(),t.expanded&&this._isBranch(t)&&!t.disabled?this._toggleExpand(t):t.parent&&this._focusNode(t.parent)):e.key===` `?(e.preventDefault(),this.selection===`multiple`?this._toggleCheck(t):this.selection===`single`&&this._activate(t)):this._nav.handler(e)}_syncForm(){let e=this.selection;if(e===`multiple`)r(this,this.values);else if(e===`single`)i(this,this._selected??``);else for(let e of this.querySelectorAll(C))e.remove()}_render(){if(!this._list)return;this._flat=null;let e=document.activeElement,t=!!e&&this._list.contains(e),n=this._visible();n.some(e=>e.id===this._focusId)||(this._focusId=(n.find(e=>e.id===this._selected)??n[0])?.id??null);let r=this.getAttribute(`aria-label`);if(r?this._list.setAttribute(`aria-label`,r):this._list.removeAttribute(`aria-label`),n.length>y){this._bindWindow();let e={heights:f(n.length,this._rowH),start:0,end:0};this._win=e,this._paint(n,e)}else this._unbindWindow(),this._win=null,this._list.style.paddingTop=``,this._list.style.paddingBottom=``,this._drawRows(n);t&&this._focusId&&this._els.get(this._focusId)?.li.focus(),this._syncForm()}_drawRows(e){this._list&&(this._els=/* @__PURE__ */ new Map,this._list.replaceChildren(...e.map(e=>this._buildItem(e))),this._syncTab())}_metrics(){let e=this._box,t=this._list?.getBoundingClientRect().top??0,n=e?e.getBoundingClientRect().top:0,r=(e?e.clientHeight:window.innerHeight)||x;return{scrollTop:Math.max(0,n-t),viewport:r}}_rangeOf(e){return d(e.heights,{...this._metrics(),overscan:b})}_draw(e,t){let{start:n,end:r}=this._rangeOf(t);t.start=n,t.end=r,this._drawRows(e.slice(n,r));let i=this._list?.style;i&&(i.paddingTop=`${t.heights.offsetOf(n)}px`,i.paddingBottom=`${t.heights.total()-t.heights.offsetOf(r)}px`)}_measure(e,t){let{heights:n}=t,r=n.indexAt(this._metrics().scrollTop),i=n.offsetOf(r),a=!1;for(let r=t.start;r<t.end;r++){let t=e[r]?.id,i=t===void 0?void 0:this._els.get(t)?.li,o=i?i.getBoundingClientRect().height:0;if(o>0){if(!this._rowMeasured){this._rowMeasured=!0,this._rowH=o;let e=n.estimate;n.setEstimate(o),n.estimate!==e&&(a=!0)}n.set(r,o)&&(a=!0)}}return a?{changed:a,delta:n.offsetOf(r)-i}:{changed:!1,delta:0}}_scrollBy(e){this._box?this._box.scrollTop+=e:window.scrollBy(0,e)}_paint(e,t){this._draw(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=this._measure(e,t);if(!n)return;r&&this._scrollBy(r),this._draw(e,t)}}_repaintWindow(){let e=this._win;if(!e||!this._list)return;let{start:t,end:n}=this._rangeOf(e);if(t===e.start&&n===e.end)return;let r=document.activeElement,i=!!r&&this._list.contains(r);this._paint(this._visible(),e),i&&this._focusId&&this._els.get(this._focusId)?.li.focus({preventScroll:!0})}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._repaintWindow()})}_reveal(e){let t=this._win;if(!t)return;let n=this._visible(),r=n.indexOf(e);if(!(r<0))for(let i=0;i<2;i++){let i=this._metrics(),a=u(t.heights,r,i);if(Math.abs(a-i.scrollTop)>.5)this._scrollBy(a-i.scrollTop);else if(this._els.has(e.id))break;this._paint(n,t)}}_bindWindow(){if(this._unbind||!this.isConnected)return;let e=E(this),t=e??window,n=()=>this._schedule();t.addEventListener(`scroll`,n,{passive:!0});let r=null;e?(r=new ResizeObserver(n),r.observe(e)):window.addEventListener(`resize`,n),this._box=e,this._unbind=()=>{t.removeEventListener(`scroll`,n),r?r.disconnect():window.removeEventListener(`resize`,n)}}_unbindWindow(){this._unbind?.(),this._unbind=null,this._box=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0}_buildItem(e){let n=e.parent?e.parent.children?.length??0:this._roots.length,r=this.selection,i=this._isBranch(e),a=this._state(e),s=t(`li`,{class:`wui-tree-item`,role:`treeitem`,tabindex:e.id===this._focusId?0:-1,"aria-level":e.level,"aria-setsize":n,"aria-posinset":e.pos+1,"aria-labelledby":`${this._uid}-${e.seq}`,"aria-describedby":e.badge?`${this._uid}-${e.seq}-badge`:null});i&&s.setAttribute(`aria-expanded`,String(e.expanded)),e.disabled&&s.setAttribute(`aria-disabled`,`true`),e.loading&&s.setAttribute(`aria-busy`,`true`),r===`single`&&s.setAttribute(`aria-selected`,String(e.id===this._selected)),r===`multiple`&&s.setAttribute(`aria-checked`,a===`mixed`?`mixed`:String(a===`checked`));let c=t(`div`,{class:`wui-tree-row`,role:`presentation`});c.style.setProperty(`--wui-tree-level`,String(e.level-1)),r===`single`&&e.id===this._selected&&c.classList.add(`wui-tree-row-selected`),e.failed&&c.classList.add(`wui-tree-row-error`);let l=t(`span`,{class:i?`wui-tree-toggle`:`wui-tree-toggle wui-tree-toggle-leaf`,"aria-hidden":`true`});if(i){let e=o(`chevron-right`,{size:16});l.replaceChildren(...e?[e]:[])}if(c.append(l),r===`multiple`){let n=t(`input`,{class:`form-check-input wui-tree-check`,type:`checkbox`,tabindex:-1,"aria-hidden":`true`});n.checked=a===`checked`,n.indeterminate=a===`mixed`,n.disabled=e.disabled,n.addEventListener(`mousedown`,e=>e.preventDefault()),c.append(n)}if(e.icon){let n=t(`span`,{class:`wui-tree-icon`,"aria-hidden":`true`}),r=o(e.icon,{size:16});n.replaceChildren(...r?[r]:[]),c.append(n)}let u=t(`span`,{class:`wui-tree-label`,id:`${this._uid}-${e.seq}`});if(u.textContent=e.label,c.append(u),e.badge){let n=e.badgeTone&&e.badgeTone!==`neutral`?` badge-${e.badgeTone}`:``,r=t(`span`,{class:`badge wui-tree-badge${n}`,id:`${this._uid}-${e.seq}-badge`});r.textContent=e.badge,c.append(r)}return e.loading&&c.append(t(`span`,{class:`wui-tree-spinner`,"aria-hidden":`true`})),s.append(c),this._els.set(e.id,{li:s,row:c}),s}};export{D as t};
|