@webority/ui-elements 0.75.1 → 0.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{WuiAutocomplete-CYpMjHs3.js → WuiAutocomplete-Cvoyr30K.js} +1 -1
- package/dist/WuiCarousel-DjQNKykv.js +1 -0
- package/dist/{WuiCodeBlock-BcLJhLBJ.js → WuiCodeBlock-8qgxTcyK.js} +1 -1
- package/dist/{WuiCommandPalette-CcmFOWNc.js → WuiCommandPalette-DMXm40wj.js} +1 -1
- package/dist/{WuiCommentThread-BHtcGLX0.js → WuiCommentThread-WL1GX7Jy.js} +1 -1
- package/dist/WuiConsentBanner-D6YE84__.js +1 -0
- package/dist/{WuiCountrySelect-DlmQ6qeN.js → WuiCountrySelect-Dac15o75.js} +1 -1
- package/dist/WuiDataTable-BVAsbW-S.js +1 -0
- package/dist/{WuiDatePicker-CpRYPtYz.js → WuiDatePicker-BUtDjbek.js} +1 -1
- package/dist/{WuiDateRange-h4lDtS-H.js → WuiDateRange-DCNf4MSb.js} +11 -11
- package/dist/{WuiInlineEdit-2XnVPzY-.js → WuiInlineEdit-DrQmhWZ6.js} +1 -1
- package/dist/{WuiLightbox-hluak_-q.js → WuiLightbox-DQ47WenM.js} +1 -1
- package/dist/{WuiMentionInput-BxYXpBRt.js → WuiMentionInput-BqcTKb8b.js} +1 -1
- package/dist/WuiMultiSelect-CAMJOfq1.js +25 -0
- package/dist/{WuiNotificationCenter-BLsM1WkE.js → WuiNotificationCenter-Dc7hD9w-.js} +1 -1
- package/dist/{WuiPhone-BfM_ttOi.js → WuiPhone-BhmKncvF.js} +2 -2
- package/dist/{WuiSelect-DJgzL9Z_.js → WuiSelect-DR4PYwAw.js} +2 -2
- package/dist/{WuiSlider-Br6V2amU.js → WuiSlider-CH4vFmtk.js} +2 -5
- package/dist/{WuiTagInput-DQ79rmjZ.js → WuiTagInput-BO7Fah7w.js} +1 -1
- package/dist/{WuiTimePicker-BIhwlHuA.js → WuiTimePicker-CaJrTq3m.js} +1 -1
- package/dist/{WuiTour-Bi_0ayiH.js → WuiTour-DOeTJa4V.js} +1 -1
- package/dist/WuiTree-amrUzT-J.js +1 -0
- package/dist/WuiWizardStep-1O75EzB2.js +1 -0
- package/dist/devWarn-DXdRWZs3.js +1 -0
- package/dist/elements/autocomplete.js +1 -1
- 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/country-select.js +1 -1
- package/dist/elements/data-table.js +1 -1
- package/dist/elements/date-range.js +1 -1
- package/dist/elements/datepicker.js +1 -1
- package/dist/elements/inline-edit.js +1 -1
- package/dist/elements/kanban.js +1 -1
- package/dist/elements/lightbox.js +1 -1
- package/dist/elements/mention-input.js +1 -1
- package/dist/elements/multiselect.js +1 -1
- package/dist/elements/notification-center.js +1 -1
- package/dist/elements/phone.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/slider.js +1 -1
- package/dist/elements/taginput.js +1 -1
- package/dist/elements/timepicker.js +1 -1
- package/dist/elements/tour.js +1 -1
- package/dist/elements/tree.js +1 -1
- package/dist/elements/wizard.js +1 -1
- package/dist/fileViewerImage-BWrW3zAb.js +3 -0
- package/dist/fileViewerMedia-CbvjcIc6.js +1 -0
- package/dist/{fileViewerPdf-CL451vuw.js → fileViewerPdf-qmMcAn1q.js} +12 -14
- package/dist/fileViewerUi-CSOkacnB.js +1 -0
- package/dist/helpers.js +1 -1
- package/dist/{iconGlyphs.g-CUm_mfze.js → iconGlyphs.g-Bk8AzmSO.js} +1 -1
- package/dist/kanban-yqsg7glT.js +1 -0
- package/dist/{optionLabel-BBaur8Bs.js → optionLabel-Bd3vP-XI.js} +1 -1
- package/dist/types/chatClient.d.ts +3 -3
- 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-chat.global.js +2 -2
- package/dist/ui-chat.js +2 -2
- package/dist/ui-consent-banner.global.js +1 -1
- package/dist/ui-elements.global.js +54 -57
- package/dist/ui-elements.js +1 -1
- package/dist/ui-file-viewer.global.js +12 -17
- package/dist/ui-file-viewer.js +1 -1
- package/dist/ui-rich-text.global.js +56 -56
- package/dist/ui-rich-text.js +56 -56
- package/dist/ui-tour.global.js +1 -1
- package/dist/wuiHttp-27mq9Jpn.js +1 -0
- package/package.json +1 -1
- package/dist/WuiCarousel-C33Z8FBt.js +0 -1
- package/dist/WuiConsentBanner-jdTxzdJs.js +0 -1
- package/dist/WuiDataTable-Bqs6FW2t.js +0 -1
- package/dist/WuiMultiSelect-CBbY_sPD.js +0 -25
- package/dist/WuiTree-BSx5pKJo.js +0 -1
- package/dist/WuiWizardStep-DtA3nVPi.js +0 -1
- package/dist/fileViewerImage-Du71Tgbf.js +0 -6
- package/dist/fileViewerMedia-BWRNH-we.js +0 -1
- package/dist/fileViewerUi-DAWY2fNB.js +0 -1
- package/dist/kanban-C0RiKTUx.js +0 -1
- package/dist/wuiHttp-0pGmgUIV.js +0 -1
package/dist/ui-tour.global.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){function e(e,t){typeof customElements<`u`&&!customElements.get(e)&&customElements.define(e,t)}var t=typeof HTMLElement>`u`?class{}:HTMLElement;function n(e,t){r(e),e._reanchor=t,e._reanchorScroll=n=>{n.target instanceof Node&&typeof e.contains==`function`&&e.contains(n.target)||t()},window.addEventListener(`resize`,e._reanchor),window.addEventListener(`scroll`,e._reanchorScroll,!0)}function r(e){e?._reanchor&&(window.removeEventListener(`resize`,e._reanchor),window.removeEventListener(`scroll`,e._reanchorScroll,!0),e._reanchor=null,e._reanchorScroll=null)}var i=`data-advance`,a=`wui-tour-hint`,o=`Click {actionName} to continue.`,s=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,c=(e,t)=>e?.advanceOn===`click`&&!!t,l=e=>(e??``).replace(/\s+/g,` `).trim();function u(e){let t=e.ownerDocument,n=(e.getAttribute(`aria-labelledby`)||``).split(/\s+/).filter(Boolean),r=e.tagName===`INPUT`&&/^(button|submit|reset)$/.test(e.type)?e.value:``,i=[n.map(e=>t.getElementById(e)?.textContent??``).join(` `),e.getAttribute(`aria-label`),Array.from(e.labels??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=l(e);if(t)return t}return``}function d(e){for(let t of[e,...e.querySelectorAll(s)])if(t.tabIndex>=0&&!t.disabled)return t;return null}function f(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 p(e,t){let n=e.querySelector(`.${a}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;if(!t){n?.remove(),i&&f(e,i,!1);return}n||(n=e.ownerDocument.createElement(`p`),n.className=a,i&&(n.id=i),e.querySelector(`.wui-tour-actions`).before(n)),n.textContent=t,i&&f(e,i,!0)}var m=e=>getComputedStyle(e).animationName;function h(e,{layer:t,spot:n,card:r},a,s){let d=c(a,s);t.toggleAttribute(i,d&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(i)&&(n.removeAttribute(i),d&&m(n)),d&&n.setAttribute(i,``);let f=r.querySelector(`.wui-tour-next`);f.classList.toggle(`btn-primary`,!d),f.classList.toggle(`btn-link`,d);let h=d?l(a.actionLabel)||u(s):``,g=e.getAttribute(`advance-label`)||o,_=h?g.replace(/\{actionName\}/g,()=>h):``;return p(r,_),_}function g(e,t,n){if(!c(e,t))return()=>{};let r=null,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function _(e,t,n,r){return e.contains(r)||c(t,n)&&n.contains(r)}function ee(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=c(r,i)?d(i):null;o&&a.push(o);let s=a.findIndex(e=>e===n||e===o&&i.contains(n));e.preventDefault(),a[s===-1?e.shiftKey?a.length-1:0:(s+(e.shiftKey?-1:1)+a.length)%a.length].focus()}var te=2/3,ne=1e3,v=new Set([`top`,`left`,`width`,`height`]),y=new WeakMap,b=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],x=e=>e.transitionProperty===`opacity`,re=e=>v.has(e.transitionProperty),S=e=>typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function C(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,ne);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function ie(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?b(t,re):[]){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*te-r)}return n}function w(e){let t=ie(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={};y.set(e,n);let r=()=>{y.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=b(e,S);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function T(e){return e.dataset.state=`leaving`,C(b(e,x))}function ae(e){let t=e.classList.contains(`wui-tour-layer`)?e:e.shadowRoot?.querySelector(`.wui-tour-layer`);t&&(t.dataset.state=`leaving`);let n=t?C(b(t,x)):null;if(!n){e.remove();return}e.setAttribute(`inert`,``),n.then(()=>e.remove())}var E=2,D=12,O=8,k=4,A=20,oe=`(max-width: 575.98px)`,se=[`bottom`,`top`,`right`,`left`],j=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],M,N=(e,t,n)=>Math.max(t,Math.min(e,n)),P=(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=z(e),r=e.offsetHeight+D;if(t.getBoundingClientRect().height+E*2+r*2<=n.bottom-n.top){t.scrollIntoView({block:`center`,inline:`nearest`});return}let i=t.style.scrollMarginTop;t.style.scrollMarginTop=`${n.top+r+E}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function F(e,t,n){let r=e.style,i=t.style,a=B(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 j)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`,le(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=z(t),u=l.bottom-l.top,d={bottom:l.bottom-o.bottom-D,top:o.top-D-l.top,right:l.right-o.right-D,left:o.left-D-l.left},f=window.matchMedia(oe).matches,p=se.find(e=>e===`top`||e===`bottom`?c.height<=d[e]+1:!f&&c.width<=d[e]+1&&c.height<=u+1),m=Math.min(o.bottom,l.bottom+O)-Math.max(o.top,l.top-O);p?I(t,a,p,o,l,c):m>=Math.min(c.height,u)+k*2?L(t,a,o,l,c):R(t,a,d.bottom>=d.top?`bottom`:`top`,o,l,c,d),t.scrollTop=s}function le(e,t){M??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of j)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),M&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function I(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=P(r.left,r.right,i.left,i.right);s=N(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+D:r.top-D-a.height,l=N(e-s,A,a.width-A)}else{let e=P(r.top,r.bottom,i.top,i.bottom);c=N(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+D:r.left-D-a.width,l=N(e-c,A,a.height-A)}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 L(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)-k;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${N(n.left+k,r.left,r.right-i.width)}px`}function R(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+D:r.top-D-c}px`;let l=P(r.left,r.right,i.left,i.right);e.style.left=`${N(l-a.width/2,i.left,i.right-a.width)}px`}function z(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e])||0;return{top:r(`paddingTop`)+O,bottom:window.innerHeight-r(`paddingBottom`)-O,left:r(`paddingLeft`)+O,right:window.innerWidth-r(`paddingRight`)-O}}function B(e){let t=e.querySelector(`:scope > .wui-tour-arrow`);return t||(t=document.createElement(`span`),t.className=`wui-tour-arrow`,t.setAttribute(`aria-hidden`,`true`),t.hidden=!0,e.append(t)),t}var V=0;function H(e,t,n){let r=`wui-tour-end-${++V}`,i=e.createElement(`div`);return i.className=`wui-tour-card wui-tour-end`,i.dataset.layout=`center`,i.setAttribute(`role`,`dialog`),n&&i.setAttribute(`aria-modal`,`true`),i.tabIndex=-1,i.setAttribute(`aria-labelledby`,`${r}-title`),i.setAttribute(`aria-describedby`,`${r}-message`),i.innerHTML=` <div class="wui-tour-end-mark" aria-hidden="true"><svg viewBox="0 0 24 24" focusable="false"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></div> <h2 class="wui-tour-title wui-tour-end-title" id="${r}-title"></h2> <p class="wui-tour-text wui-tour-end-message" id="${r}-message"></p> <div class="wui-tour-actions"><button type="button" class="btn btn-sm btn-primary wui-tour-end-button"></button></div>`,i.querySelector(`.wui-tour-end-title`).textContent=t.title,i.querySelector(`.wui-tour-end-message`).textContent=t.message,i.querySelector(`.wui-tour-end-button`).textContent=t.button,i}function U(e,t,n){let r=e.ownerDocument,i=e.getRootNode()===r,a=e.querySelector(`.wui-tour-card:not(.wui-tour-end)`),o=e.querySelector(`.wui-tour-spot`),s=e.querySelector(`[role=status]`),c=H(r,t,i),l=c.querySelector(`.wui-tour-end-button`),u=new AbortController;return new Promise(d=>{let f=()=>{u.abort(),d()};if(n?.aborted){f();return}let p={signal:u.signal};n?.addEventListener(`abort`,f,p),l.addEventListener(`click`,f,p),r.addEventListener(`keydown`,e=>{e.altKey||e.ctrlKey||e.metaKey||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),f()):e.key===`Tab`&&i&&(e.preventDefault(),l.focus()))},{capture:!0,signal:u.signal}),i&&r.addEventListener(`focusin`,e=>{c.contains(e.target)||l.focus()},p);let m=()=>{u.signal.aborted||(a.hidden=!0,F(o,a,null),e.append(c),w(c),s.textContent=[t.title,t.message].filter(Boolean).join(`. `),l.focus())},h=T(a);h?h.then(m):m()})}var W=` :host { all: initial; ${Object.entries({"--wui-z-tour":`1550`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-overlay":`0 8px 28px -6px rgba(7, 20, 55, 0.14)`,"--wui-ease-out-quart":`cubic-bezier(0.22, 1, 0.36, 1)`,"--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-ink":`#4F46E5`,"--color-focus-ring":`#4F46E5`,"--wui-focus-ring-width":`2px`,"--wui-focus-ring-offset":`2px`,"--color-primary-text":`#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-primary-text); } .btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); } .btn-outline-secondary { border-color: var(--color-text-muted); color: var(--color-text-muted); } .btn-outline-secondary:hover { background: var(--color-bg-muted); color: var(--color-text); } .btn-link { font-weight: 400; color: var(--color-primary-ink); 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); } .wui-tour-spot { position: fixed; box-shadow: 0 0 0 2px var(--color-primary), 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-overlay); } .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 120ms linear; } .wui-tour-layer[data-state=leaving] { transition: opacity 120ms linear; } .wui-tour-card[data-state=entering] { animation: wui-tour-fade-in 120ms 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-media=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: 2px; } .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); } @keyframes wui-tour-pulse { from { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 85%, transparent); } to { box-shadow: 0 0 0 14px color-mix(in srgb, var(--color-primary) 0%, transparent); } } @media (prefers-reduced-motion: no-preference) { .wui-tour-spot[data-advance]::after { content: ""; position: absolute; inset: 0; border-radius: inherit; corner-shape: inherit; pointer-events: none; animation: wui-tour-pulse 600ms var(--wui-ease-out-quart) var(--wui-tour-spot-duration); } } @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-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-button { min-width: 120px; } @media (prefers-reduced-motion: no-preference) { .wui-tour-end-mark path { animation: wui-tour-check 300ms var(--wui-ease-out-quart) calc(var(--wui-tour-card-delay, 0ms) + 120ms) both; } } `,G=`wui-tour-media`,ue=`wui-tour-media-toggle`,K=`http://www.w3.org/2000/svg`,de=`M6 5h4v14H6zM14 5h4v14h-4z`,fe=`M8 5v14l11-7z`,pe={pause:`Pause animation`,play:`Play animation`},me=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function he(e){let t=document.createElementNS(K,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(K,`path`);return n.setAttribute(`d`,e),t.appendChild(n),t}function ge(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 _e(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 ve(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=ue;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(he(r?de:fe))};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 ye(e){let t=e.querySelector(`:scope > .${G}`);if(!t)return;let n=t.querySelector(`video`);n&&(n.pause(),n.removeAttribute(`src`),n.load()),t.remove()}function be(e,t,n=pe){if(ye(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=G,t.mediaType===`video`){let e=_e(t,!me());r.append(e,ve(e,n))}else r.appendChild(ge(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var q=`data-wui-tour-open`,xe=`Step {current} of {total}`;function Se(e){let t=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 Ce(e,t,n){return(e.getAttribute(`progress-label`)||xe).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function we(e,{text:t,position:n,total:r}){let i=e.querySelector(`.wui-tour-position`);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;)a.lastElementChild.remove();for(let e=0;e<o.length;e++)o[e].toggleAttribute(`data-filled`,e<n)}var Te=`wui-tour-step`,Ee=`wui-tour-host`,De=`wui-tour-seen:`,J=`data-tracking`,Oe={back:`Back`,next:`Next`,skip:`Skip`,done:`Done`,mediaPause:`Pause animation`,mediaPlay:`Play animation`,endTitle:`You're all set`,endMessage:`You know your way around now. Enjoy exploring.`,endButton:`Done`},ke={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`},Ae=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],Y={index:null,position:null,total:null},X=0;function je(e=De,t=globalThis.localStorage){return{isSeen:async n=>t.getItem(e+n)===`1`,markSeen:async n=>{t.setItem(e+n,`1`)}}}var Z=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,Q=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),Me=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},$=null;function Ne(e){if(`adoptedStyleSheets`in e&&typeof CSSStyleSheet==`function`&&`replaceSync`in CSSStyleSheet.prototype){$||($=new CSSStyleSheet,$.replaceSync(W)),e.adoptedStyleSheets=[$];return}let t=document.createElement(`style`);t.textContent=W,e.appendChild(t)}var Pe=class extends t{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 > ${Te}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:e.textContent.trim()};for(let[n,r]of Ae)e.hasAttribute(r)&&(t[n]=e.getAttribute(r));return t})}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?je():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(ke[e])||Oe[e]}_endDialogText(){return this.getAttribute(`end-dialog`)===`false`?null:{title:this._label(`endTitle`),message:this._label(`endMessage`),button:this._label(`endButton`)}}_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=Se(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&&!Z(document.querySelector(t.target))&&this._progress.drop(e);this._returnFocus=document.activeElement;let n=await this._locate(0,1,e);if(e===this._run){if(!n){this._finish(`noTargets`);return}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))}}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(await this._beforeStep(e,i),n!==this._run)return null;if(!e.target)return{index:i,target:null};let t=document.querySelector(e.target);if(Z(t))return this._progress.position(i),{index:i,target:t};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 e=`wui-tour-${++X}`,t=document.createElement(`div`);t.className=`wui-tour-layer`,t.innerHTML=` <div class="wui-tour-spot" aria-hidden="true"></div> <div class="wui-tour-card" role="dialog" aria-modal="true" tabindex="-1" aria-labelledby="${e}-title" aria-describedby="${e}-text"> <p class="wui-tour-position"></p> <h2 class="wui-tour-title" id="${e}-title"></h2> <p class="wui-tour-text" id="${e}-text"></p> <div class="wui-tour-actions"> <button type="button" class="btn btn-sm btn-link wui-tour-skip"></button> <div class="wui-tour-nav"> <button type="button" class="btn btn-sm btn-outline-secondary wui-tour-back"></button> <button type="button" class="btn btn-sm btn-primary wui-tour-next"></button> </div> </div> </div> <div class="visually-hidden" role="status" aria-live="polite"></div>`;let r=t;this._shadow=null,this.isolated&&(r=document.createElement(Ee),this._shadow=r.attachShadow({mode:`open`}),Ne(this._shadow),this._shadow.appendChild(t)),document.body.appendChild(r),document.documentElement.setAttribute(q,``),this._outer=r,this._layer=t,this._spot=t.querySelector(`.wui-tour-spot`),this._card=t.querySelector(`.wui-tour-card`),this._live=t.querySelector(`[role=status]`),this._card.querySelector(`.wui-tour-skip`).addEventListener(`click`,()=>this._close(`skipped`,`button`)),this._card.querySelector(`.wui-tour-back`).addEventListener(`click`,()=>this._move(-1)),this._card.querySelector(`.wui-tour-next`).addEventListener(`click`,()=>this._move(1)),this._shadow&&this._card.removeAttribute(`aria-modal`),this._onKey=e=>this._key(e),this._onFocusIn=e=>{if(!this._layer||this._ending)return;let t=this._current,n=t?this._steps[t.index]:null;_(this._layer,n,t?.target??null,e.target)||this._card.focus()},document.addEventListener(`keydown`,this._onKey,!0),this._shadow||document.addEventListener(`focusin`,this._onFocusIn),n(r,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_show(e){this._current=e;let{index:t,target:n}=e,r=this._steps[t],i=this._card,a=this._progress.position(t),o=this._progress.total(),s=a===o&&!this._endDialogText(),c=Ce(this,a,o);we(i,{text:c,position:a,total:o}),be(i,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)});let l=h(this,{layer:this._layer,spot:this._spot,card:i},r,n),u=i.querySelector(`.wui-tour-title`);u.textContent=r.title||``,u.hidden=!r.title,i.querySelector(`.wui-tour-text`).textContent=r.description||``,i.querySelector(`.wui-tour-skip`).textContent=this._label(`skip`),i.querySelector(`.wui-tour-back`).textContent=this._label(`back`),i.querySelector(`.wui-tour-back`).hidden=t<=this._firstIndex,i.querySelector(`.wui-tour-next`).textContent=this._label(s?`done`:`next`);let d=[c,r.title,r.description].filter(Boolean).join(`. `);this._live.textContent=l?[d,l].join(/[.!?]$/.test(d)?` `:`. `):d,ce(i,n),this._spot.removeAttribute(J),this._place(),w(i),this._unbindAdvance?.(),this._unbindAdvance=g(r,n,()=>this._move(1));let f=this._active();(i.contains(f)?!f.hidden:this._shadow!==null&&Q(Me()))||i.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t,position:a,total:o}}))}_place(){!this._current||!this._layer||F(this._spot,this._card,this._current.target)}_follow(){if(!this._current||!this._layer||this._ending)return;let e=this._spot.style.cssText;this._place(),this._spot.style.cssText!==e&&this._spot.setAttribute(J,``)}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=T(this._card);if(e&&await e,n!==this._run)return;this._show(r)}else if(t>0){let e=this._endDialogText();if(e&&await this._showEnd(e),n!==this._run)return;await this._close(`finished`)}}finally{this._moving=!1}}_showEnd(e){return this._unbindAdvance?.(),this._unbindAdvance=null,h(this,{layer:this._layer,spot:this._spot,card:this._card},null,null),this._spot.removeAttribute(J),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),U(this._layer,e,this._ending.signal)}_key(e){if(!(!this._layer||this._ending||e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this._close(`skipped`,`escape`);else if(e.key===`ArrowRight`||e.key===`ArrowLeft`){if(Q(e.composedPath?.()[0]??e.target))return;e.preventDefault(),e.key===`ArrowRight`?this._move(1):this._current.index>this._firstIndex&&this._move(-1)}else if(e.key===`Tab`&&!this._shadow){let{index:t,target:n}=this._current;ee(e,{card:this._card,active:this._active(),step:this._steps[t],target:n})}}}_teardown(){if(!this._layer)return;document.removeEventListener(`keydown`,this._onKey,!0),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,r(this._outer),ae(this._outer),document.documentElement.removeAttribute(q),this._outer=null,this._shadow=null,this._layer=null,this._current=null;let t=this._returnFocus;this._returnFocus=null,e&&t?.isConnected&&t.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();try{n===this._run&&await(a??this._markSeen(e))}finally{this._finish(e,i,t)}}_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}}))}},Fe=class extends t{constructor(){super(),this.shadowRoot||this.attachShadow({mode:`open`})}};e(`wui-tour`,Pe),e(`wui-tour-step`,Fe)})();
|
|
1
|
+
(function(){function e(e,t){typeof customElements<`u`&&!customElements.get(e)&&customElements.define(e,t)}var t=typeof HTMLElement>`u`?class{}:HTMLElement;function n(e,t){r(e),e._reanchor=t,e._reanchorScroll=n=>{n.target instanceof Node&&typeof e.contains==`function`&&e.contains(n.target)||t()},window.addEventListener(`resize`,e._reanchor),window.addEventListener(`scroll`,e._reanchorScroll,!0)}function r(e){e?._reanchor&&(window.removeEventListener(`resize`,e._reanchor),window.removeEventListener(`scroll`,e._reanchorScroll,!0),e._reanchor=null,e._reanchorScroll=null)}var i=`data-advance`,a=`wui-tour-hint`,o=`Click {actionName} to continue.`,s=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,c=(e,t)=>e?.advanceOn===`click`&&!!t,l=e=>(e??``).replace(/\s+/g,` `).trim();function u(e){let t=e.ownerDocument,n=(e.getAttribute(`aria-labelledby`)||``).split(/\s+/).filter(Boolean),r=e.tagName===`INPUT`&&/^(button|submit|reset)$/.test(e.type)?e.value:``,i=[n.map(e=>t.getElementById(e)?.textContent??``).join(` `),e.getAttribute(`aria-label`),Array.from(e.labels??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=l(e);if(t)return t}return``}function d(e){for(let t of[e,...e.querySelectorAll(s)])if(t.tabIndex>=0&&!t.disabled)return t;return null}function f(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 p(e,t){let n=e.querySelector(`.${a}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;if(!t){n?.remove(),i&&f(e,i,!1);return}n||(n=e.ownerDocument.createElement(`p`),n.className=a,i&&(n.id=i),e.querySelector(`.wui-tour-actions`).before(n)),n.textContent=t,i&&f(e,i,!0)}var m=e=>getComputedStyle(e).animationName;function h(e,{layer:t,spot:n,card:r},a,s){let d=c(a,s);t.toggleAttribute(i,d&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(i)&&(n.removeAttribute(i),d&&m(n)),d&&n.setAttribute(i,``);let f=r.querySelector(`.wui-tour-next`);f.classList.toggle(`btn-primary`,!d),f.classList.toggle(`btn-link`,d);let h=d?l(a.actionLabel)||u(s):``,g=e.getAttribute(`advance-label`)||o,_=h?g.replace(/\{actionName\}/g,()=>h):``;return p(r,_),_}function g(e,t,n){if(!c(e,t))return()=>{};let r=null,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function _(e,t,n,r){return e.contains(r)||c(t,n)&&n.contains(r)}function ee(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=c(r,i)?d(i):null;o&&a.push(o);let s=a.findIndex(e=>e===n||e===o&&i.contains(n));e.preventDefault(),a[s===-1?e.shiftKey?a.length-1:0:(s+(e.shiftKey?-1:1)+a.length)%a.length].focus()}var te=2/3,ne=1e3,re=new Set([`top`,`left`,`width`,`height`]),v=new WeakMap,y=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],b=e=>e.transitionProperty===`opacity`,ie=e=>re.has(e.transitionProperty),x=e=>typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function S(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,ne);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function ae(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?y(t,ie):[]){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*te-r)}return n}function C(e){let t=ae(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={};v.set(e,n);let r=()=>{v.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=y(e,x);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function w(e){return e.dataset.state=`leaving`,S(y(e,b))}function oe(e){let t=e.classList.contains(`wui-tour-layer`)?e:e.shadowRoot?.querySelector(`.wui-tour-layer`);t&&(t.dataset.state=`leaving`);let n=t?S(y(t,b)):null;if(!n){e.remove();return}e.setAttribute(`inert`,``),n.then(()=>e.remove())}var T=2,E=12,D=8,O=4,k=20,se=`(max-width: 575.98px)`,ce=[`bottom`,`top`,`right`,`left`],A=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],j,M=(e,t,n)=>Math.max(t,Math.min(e,n)),N=(e,t,n,r)=>(Math.max(e,n)+Math.min(t,r))/2;function le(e,t){if(!t?.scrollIntoView)return;e.style.maxHeight=``;let n=z(e),r=e.offsetHeight+E;if(t.getBoundingClientRect().height+T*2+r*2<=n.bottom-n.top){t.scrollIntoView({block:`center`,inline:`nearest`});return}let i=t.style.scrollMarginTop;t.style.scrollMarginTop=`${n.top+r+T}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function P(e,t,n){let r=e.style,i=t.style,a=B(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 A)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`,F(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=z(t),u=l.bottom-l.top,d={bottom:l.bottom-o.bottom-E,top:o.top-E-l.top,right:l.right-o.right-E,left:o.left-E-l.left},f=window.matchMedia(se).matches,p=ce.find(e=>e===`top`||e===`bottom`?c.height<=d[e]+1:!f&&c.width<=d[e]+1&&c.height<=u+1),m=Math.min(o.bottom,l.bottom+D)-Math.max(o.top,l.top-D);p?I(t,a,p,o,l,c):m>=Math.min(c.height,u)+O*2?L(t,a,o,l,c):R(t,a,d.bottom>=d.top?`bottom`:`top`,o,l,c,d),t.scrollTop=s}function F(e,t){j??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of A)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),j&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function I(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=N(r.left,r.right,i.left,i.right);s=M(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+E:r.top-E-a.height,l=M(e-s,k,a.width-k)}else{let e=N(r.top,r.bottom,i.top,i.bottom);c=M(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+E:r.left-E-a.width,l=M(e-c,k,a.height-k)}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 L(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)-O;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${M(n.left+O,r.left,r.right-i.width)}px`}function R(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+E:r.top-E-c}px`;let l=N(r.left,r.right,i.left,i.right);e.style.left=`${M(l-a.width/2,i.left,i.right-a.width)}px`}function z(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e])||0;return{top:r(`paddingTop`)+D,bottom:window.innerHeight-r(`paddingBottom`)-D,left:r(`paddingLeft`)+D,right:window.innerWidth-r(`paddingRight`)-D}}function B(e){let t=e.querySelector(`:scope > .wui-tour-arrow`);return t||(t=document.createElement(`span`),t.className=`wui-tour-arrow`,t.setAttribute(`aria-hidden`,`true`),t.hidden=!0,e.append(t)),t}var V=0;function H(e,t,n){let r=`wui-tour-end-${++V}`,i=e.createElement(`div`);return i.className=`wui-tour-card wui-tour-end`,i.dataset.layout=`center`,i.setAttribute(`role`,`dialog`),n&&i.setAttribute(`aria-modal`,`true`),i.tabIndex=-1,i.setAttribute(`aria-labelledby`,`${r}-title`),i.setAttribute(`aria-describedby`,`${r}-message`),i.innerHTML=` <div class="wui-tour-end-mark" aria-hidden="true"><svg viewBox="0 0 24 24" focusable="false"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></div> <h2 class="wui-tour-title wui-tour-end-title" id="${r}-title"></h2> <p class="wui-tour-text wui-tour-end-message" id="${r}-message"></p> <div class="wui-tour-actions"><button type="button" class="btn btn-sm btn-primary wui-tour-end-button"></button></div>`,i.querySelector(`.wui-tour-end-title`).textContent=t.title,i.querySelector(`.wui-tour-end-message`).textContent=t.message,i.querySelector(`.wui-tour-end-button`).textContent=t.button,i}function U(e,t,n){let r=e.ownerDocument,i=e.getRootNode()===r,a=e.querySelector(`.wui-tour-card:not(.wui-tour-end)`),o=e.querySelector(`.wui-tour-spot`),s=e.querySelector(`[role=status]`),c=H(r,t,i),l=c.querySelector(`.wui-tour-end-button`),u=new AbortController;return new Promise(d=>{let f=()=>{u.abort(),d()};if(n?.aborted){f();return}let p={signal:u.signal};n?.addEventListener(`abort`,f,p),l.addEventListener(`click`,f,p),r.addEventListener(`keydown`,e=>{e.altKey||e.ctrlKey||e.metaKey||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),f()):e.key===`Tab`&&i&&(e.preventDefault(),l.focus()))},{capture:!0,signal:u.signal}),i&&r.addEventListener(`focusin`,e=>{c.contains(e.target)||l.focus()},p);let m=()=>{u.signal.aborted||(a.hidden=!0,P(o,a,null),e.append(c),C(c),s.textContent=[t.title,t.message].filter(Boolean).join(`. `),l.focus())},h=w(a);h?h.then(m):m()})}var W=` :host { all: initial; ${Object.entries({"--wui-z-tour":`1550`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-overlay":`0 8px 28px -6px rgba(7, 20, 55, 0.14)`,"--wui-ease-out-quart":`cubic-bezier(0.22, 1, 0.36, 1)`,"--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-ink":`#4F46E5`,"--color-focus-ring":`#4F46E5`,"--wui-focus-ring-width":`2px`,"--wui-focus-ring-offset":`2px`,"--color-primary-text":`#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-primary-text); } .btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); } .btn-outline-secondary { border-color: var(--color-text-muted); color: var(--color-text-muted); } .btn-outline-secondary:hover { background: var(--color-bg-muted); color: var(--color-text); } .btn-link { font-weight: 400; color: var(--color-primary-ink); 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); } .wui-tour-spot { position: fixed; box-shadow: 0 0 0 2px var(--color-primary), 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-overlay); } .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 120ms linear; } .wui-tour-layer[data-state=leaving] { transition: opacity 120ms linear; } .wui-tour-card[data-state=entering] { animation: wui-tour-fade-in 120ms 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-media=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: 2px; } .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); } @keyframes wui-tour-pulse { from { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 85%, transparent); } to { box-shadow: 0 0 0 14px color-mix(in srgb, var(--color-primary) 0%, transparent); } } @media (prefers-reduced-motion: no-preference) { .wui-tour-spot[data-advance]::after { content: ""; position: absolute; inset: 0; border-radius: inherit; corner-shape: inherit; pointer-events: none; animation: wui-tour-pulse 600ms var(--wui-ease-out-quart) var(--wui-tour-spot-duration); } } @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-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-button { min-width: 120px; } @media (prefers-reduced-motion: no-preference) { .wui-tour-end-mark path { animation: wui-tour-check 300ms var(--wui-ease-out-quart) calc(var(--wui-tour-card-delay, 0ms) + 120ms) both; } } `,G=`wui-tour-media`,ue=`wui-tour-media-toggle`,K=`http://www.w3.org/2000/svg`,de=`M6 5h4v14H6zM14 5h4v14h-4z`,fe=`M8 5v14l11-7z`,pe={pause:`Pause animation`,play:`Play animation`},me=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function he(e){let t=document.createElementNS(K,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(K,`path`);return n.setAttribute(`d`,e),t.appendChild(n),t}function ge(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 _e(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 ve(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=ue;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(he(r?de:fe))};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 ye(e){let t=e.querySelector(`:scope > .${G}`);if(!t)return;let n=t.querySelector(`video`);n&&(n.pause(),n.removeAttribute(`src`),n.load()),t.remove()}function be(e,t,n=pe){if(ye(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=G,t.mediaType===`video`){let e=_e(t,!me());r.append(e,ve(e,n))}else r.appendChild(ge(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var q=`data-wui-tour-open`,xe=`Step {current} of {total}`;function Se(e){let t=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 Ce(e,t,n){return(e.getAttribute(`progress-label`)||xe).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function we(e,{text:t,position:n,total:r}){let i=e.querySelector(`.wui-tour-position`);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;)a.lastElementChild.remove();for(let e=0;e<o.length;e++)o[e].toggleAttribute(`data-filled`,e<n)}var Te=`wui-tour-step`,Ee=`wui-tour-host`,De=`wui-tour-seen:`,J=`data-tracking`,Oe={back:`Back`,next:`Next`,skip:`Skip`,done:`Done`,mediaPause:`Pause animation`,mediaPlay:`Play animation`,endTitle:`You're all set`,endMessage:`You know your way around now. Enjoy exploring.`,endButton:`Done`},ke={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`},Ae=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],Y={index:null,position:null,total:null},X=0;function je(e=De,t=globalThis.localStorage){return{isSeen:async n=>t.getItem(e+n)===`1`,markSeen:async n=>{t.setItem(e+n,`1`)}}}var Z=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,Q=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),Me=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},$=null;function Ne(e){$||($=new CSSStyleSheet,$.replaceSync(W)),e.adoptedStyleSheets=[$]}var Pe=class extends t{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 > ${Te}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:e.textContent.trim()};for(let[n,r]of Ae)e.hasAttribute(r)&&(t[n]=e.getAttribute(r));return t})}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?je():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(ke[e])||Oe[e]}_endDialogText(){return this.getAttribute(`end-dialog`)===`false`?null:{title:this._label(`endTitle`),message:this._label(`endMessage`),button:this._label(`endButton`)}}_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=Se(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&&!Z(document.querySelector(t.target))&&this._progress.drop(e);this._returnFocus=document.activeElement;let n=await this._locate(0,1,e);if(e===this._run){if(!n){this._finish(`noTargets`);return}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))}}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(await this._beforeStep(e,i),n!==this._run)return null;if(!e.target)return{index:i,target:null};let t=document.querySelector(e.target);if(Z(t))return this._progress.position(i),{index:i,target:t};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 e=`wui-tour-${++X}`,t=document.createElement(`div`);t.className=`wui-tour-layer`,t.innerHTML=` <div class="wui-tour-spot" aria-hidden="true"></div> <div class="wui-tour-card" role="dialog" aria-modal="true" tabindex="-1" aria-labelledby="${e}-title" aria-describedby="${e}-text"> <p class="wui-tour-position"></p> <h2 class="wui-tour-title" id="${e}-title"></h2> <p class="wui-tour-text" id="${e}-text"></p> <div class="wui-tour-actions"> <button type="button" class="btn btn-sm btn-link wui-tour-skip"></button> <div class="wui-tour-nav"> <button type="button" class="btn btn-sm btn-outline-secondary wui-tour-back"></button> <button type="button" class="btn btn-sm btn-primary wui-tour-next"></button> </div> </div> </div> <div class="visually-hidden" role="status" aria-live="polite"></div>`;let r=t;this._shadow=null,this.isolated&&(r=document.createElement(Ee),this._shadow=r.attachShadow({mode:`open`}),Ne(this._shadow),this._shadow.appendChild(t)),document.body.appendChild(r),document.documentElement.setAttribute(q,``),this._outer=r,this._layer=t,this._spot=t.querySelector(`.wui-tour-spot`),this._card=t.querySelector(`.wui-tour-card`),this._live=t.querySelector(`[role=status]`),this._card.querySelector(`.wui-tour-skip`).addEventListener(`click`,()=>this._close(`skipped`,`button`)),this._card.querySelector(`.wui-tour-back`).addEventListener(`click`,()=>this._move(-1)),this._card.querySelector(`.wui-tour-next`).addEventListener(`click`,()=>this._move(1)),this._shadow&&this._card.removeAttribute(`aria-modal`),this._onKey=e=>this._key(e),this._onFocusIn=e=>{if(!this._layer||this._ending)return;let t=this._current,n=t?this._steps[t.index]:null;_(this._layer,n,t?.target??null,e.target)||this._card.focus()},document.addEventListener(`keydown`,this._onKey,!0),this._shadow||document.addEventListener(`focusin`,this._onFocusIn),n(r,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_show(e){this._current=e;let{index:t,target:n}=e,r=this._steps[t],i=this._card,a=this._progress.position(t),o=this._progress.total(),s=a===o&&!this._endDialogText(),c=Ce(this,a,o);we(i,{text:c,position:a,total:o}),be(i,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)});let l=h(this,{layer:this._layer,spot:this._spot,card:i},r,n),u=i.querySelector(`.wui-tour-title`);u.textContent=r.title||``,u.hidden=!r.title,i.querySelector(`.wui-tour-text`).textContent=r.description||``,i.querySelector(`.wui-tour-skip`).textContent=this._label(`skip`),i.querySelector(`.wui-tour-back`).textContent=this._label(`back`),i.querySelector(`.wui-tour-back`).hidden=t<=this._firstIndex,i.querySelector(`.wui-tour-next`).textContent=this._label(s?`done`:`next`);let d=[c,r.title,r.description].filter(Boolean).join(`. `);this._live.textContent=l?[d,l].join(/[.!?]$/.test(d)?` `:`. `):d,le(i,n),this._spot.removeAttribute(J),this._place(),C(i),this._unbindAdvance?.(),this._unbindAdvance=g(r,n,()=>this._move(1));let f=this._active();(i.contains(f)?!f.hidden:this._shadow!==null&&Q(Me()))||i.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t,position:a,total:o}}))}_place(){!this._current||!this._layer||P(this._spot,this._card,this._current.target)}_follow(){if(!this._current||!this._layer||this._ending)return;let e=this._spot.style.cssText;this._place(),this._spot.style.cssText!==e&&this._spot.setAttribute(J,``)}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=w(this._card);if(e&&await e,n!==this._run)return;this._show(r)}else if(t>0){let e=this._endDialogText();if(e&&await this._showEnd(e),n!==this._run)return;await this._close(`finished`)}}finally{this._moving=!1}}_showEnd(e){return this._unbindAdvance?.(),this._unbindAdvance=null,h(this,{layer:this._layer,spot:this._spot,card:this._card},null,null),this._spot.removeAttribute(J),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),U(this._layer,e,this._ending.signal)}_key(e){if(!(!this._layer||this._ending||e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this._close(`skipped`,`escape`);else if(e.key===`ArrowRight`||e.key===`ArrowLeft`){if(Q(e.composedPath?.()[0]??e.target))return;e.preventDefault(),e.key===`ArrowRight`?this._move(1):this._current.index>this._firstIndex&&this._move(-1)}else if(e.key===`Tab`&&!this._shadow){let{index:t,target:n}=this._current;ee(e,{card:this._card,active:this._active(),step:this._steps[t],target:n})}}}_teardown(){if(!this._layer)return;document.removeEventListener(`keydown`,this._onKey,!0),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,r(this._outer),oe(this._outer),document.documentElement.removeAttribute(q),this._outer=null,this._shadow=null,this._layer=null,this._current=null;let t=this._returnFocus;this._returnFocus=null,e&&t?.isConnected&&t.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();try{n===this._run&&await(a??this._markSeen(e))}finally{this._finish(e,i,t)}}_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}}))}},Fe=class extends t{constructor(){super(),this.shadowRoot||this.attachShadow({mode:`open`})}};e(`wui-tour`,Pe),e(`wui-tour-step`,Fe)})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./devWarn-DXdRWZs3.js";import{E as n,k as r,r as i,w as a,y as o}from"./dataTable-Cd_IJQcs.js";import{t as s}from"./iconGlyphs.g-Bk8AzmSO.js";var c=`Select all rows`,l=`Select row`,u=`wui-select-cell`,d=(e,t)=>{let n=e.createElement(`input`);return n.type=`checkbox`,n.className=`wui-check`,n.setAttribute(`aria-label`,t),n};function f(e=document){let t=e.createElement(`th`);return t.className=u,t.appendChild(d(e,c)),t}function p(e=document,{disabled:t=!1}={}){let n=e.createElement(`td`);n.className=u;let r=d(e,l);return r.disabled=t,n.appendChild(r),n}function m(e=document){let t=e.createElement(`td`);return t.className=u,t}var h=e=>e.firstElementChild?.classList.contains(u),g=e=>e.matches(`.wui-group-row, .wui-virtual-spacer`);function _(e){for(let t of e){if(h(t)||g(t))continue;let e=t.getAttribute(`data-row-selectable`)===`false`;t.insertBefore(p(t.ownerDocument,{disabled:e}),t.firstChild)}}function v(e){let t=e.querySelector(`thead tr`);if(!t)return null;h(t)||t.insertBefore(f(e.ownerDocument),t.firstChild),_(e.querySelectorAll(`tbody tr`));for(let t of e.querySelectorAll(`tfoot tr`))h(t)||t.insertBefore(m(e.ownerDocument),t.firstChild);return t.querySelector(`.${u} .wui-check`)}function y(e){let t=e.querySelector(`thead .${u} .wui-check`),n=[...e.querySelectorAll(`tbody tr .wui-check:not(:disabled)`)],r=n.length,i=n.filter(e=>e.checked).length;t&&(t.checked=r>0&&i===r,t.indeterminate=i>0&&i<r);for(let t of e.querySelectorAll(`tbody tr`))t.classList.toggle(`is-selected`,!!t.querySelector(`.wui-check`)?.checked);return{selected:i,total:r}}var b=`tbody .${u} .wui-check:not(:disabled)`;function ee(e,t){let n=null,r=e=>e instanceof Element&&e.matches(`.wui-select-cell .wui-check:not(:disabled)`)&&!!e.closest(`tbody`);e.addEventListener(`mousedown`,e=>{e.shiftKey&&r(e.target)&&e.preventDefault()}),e.addEventListener(`click`,i=>{let a=i.target;if(r(a)){if(i.shiftKey&&n?.isConnected&&n!==a){let r=[...e.querySelectorAll(b)],i=r.indexOf(n),o=r.indexOf(a);if(i>=0&&o>=0){let e=[];for(let t of r.slice(Math.min(i,o),Math.max(i,o)+1))t===a||t.checked===a.checked||(t.checked=a.checked,e.push(t));e.length&&t?.(e,a.checked)}}n=a}})}var te=Object.freeze([`page`,`pageSize`,`sortBy`,`sortOrder`]),x=`search`,S=Object.freeze({loading:`Loading rows`,error:`These rows did not load. Try again.`,network:`The connection dropped before the rows loaded. Check it and try again.`,forbidden:`You do not have access to these rows.`,retry:`Retry`,actionFailed:`That did not work. Try again.`,actionForbidden:`You do not have permission to do that.`,empty:`No rows`}),ne=5,C=new WeakMap,w=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},re=e=>({total:w(e.dataset.total,0),page:w(e.dataset.page,1),pageSize:w(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`}),ie=(e,t)=>{e&&window.WUI?.toast?.(e,{variant:t})};function T(e=document){let t=e.querySelectorAll?[...e.querySelectorAll(`[data-wui-server]`)]:[];e instanceof Element&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t)C.has(e)||C.set(e,D(e))}function E(e){let t=e instanceof Element?e.closest(`[data-wui-server]`):null;return t&&C.get(t)||null}function D(e){let c=e.querySelector(`.table-wrap`),l=c?.querySelector(`:scope > table`),d=e.dataset.src;if(!l||!d)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let f=c.querySelector(`:scope > [data-wui-table-state]`),p=e.querySelector(`[data-wui-table-pager]`),m=e.querySelector(`[data-wui-table-status]`),h={urlState:e.dataset.urlState!==`false`,refreshOnSuccess:e.dataset.refreshOnSuccess!==`false`,filtersForm:e.dataset.filtersForm||null,filtersRegion:e.dataset.filtersRegion||null,searchInput:e.dataset.searchInput||null,loadingText:e.dataset.loadingText||S.loading,errorText:e.dataset.errorText||S.error},g=new URL(d,window.location.href),b=new Set(g.searchParams.keys()),C=l.hasAttribute(`data-app-datatable-selectable`),w=new Set,T=!1,E=se(),D=new AbortController,O={signal:D.signal},k=l.querySelector(`:scope > tbody[data-wui-rows]`);if(!k)throw Error(`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`);let A=re(k),j=null,M=null,P=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))b.has(n)||t.append(n,r);return t},F=e=>P(new URL(e,window.location.href).search),I=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},ae=e=>{let t=new URL(g.href);for(let[n,r]of e)b.has(n)||t.searchParams.append(n,r);return t.origin===window.location.origin?`${t.pathname}${t.search}`:t.href},L=(e,t)=>{let n=new URLSearchParams(e);return n.has(`page`)&&n.set(`page`,String(t.page)),n.has(`pageSize`)&&n.set(`pageSize`,String(t.pageSize)),n.has(`sortBy`)?t.sortBy?(n.set(`sortBy`,t.sortBy),n.set(`sortOrder`,t.sortOrder)):(n.delete(`sortBy`),n.delete(`sortOrder`)):n.delete(`sortOrder`),n},R=L(h.urlState?P(window.location.search):new URLSearchParams,A);h.urlState&&I(R)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,I(R));let z=(e,t)=>c.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),B=e=>{m&&(m.textContent=e)},oe=e=>{if(e.total===0)return S.empty;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1;return`Page ${e.page} of ${t}, ${e.total} ${e.total===1?`row`:`rows`}`},V=()=>[...l.querySelectorAll(`:scope > thead > tr:first-child > th`)],H=e=>{if(C&&[...e.querySelectorAll(`:scope > tr`)].some(e=>!e.dataset.rowKey))throw Error(`A selectable server-paged table needs data-row-key on every row, so a selection can span pages.`)},U=t=>{let n=e.dataset.activeRowKey;if(n!==void 0)for(let e of t){let t=e.classList.contains(`wui-row-active`),r=n!==``&&e.dataset.rowKey===n;e.classList.toggle(`wui-row-active`,r),r?e.setAttribute(`aria-current`,`true`):t&&e.removeAttribute(`aria-current`)}},G=e=>{if(C){_(e);for(let t of e){let e=t.querySelector(`.${u} .wui-check:not(:disabled)`);e&&(T&&w.add(t.dataset.rowKey),e.checked=w.has(t.dataset.rowKey))}y(l)}U(e);let t=V();if(l.classList.contains(`wui-table-stack`))for(let n of e)[...n.cells].forEach((e,n)=>{let r=t[n]?.textContent.trim();r&&!e.hasAttribute(`data-label`)&&e.setAttribute(`data-label`,r)});t.forEach((t,n)=>{if(t.classList.contains(`wui-col-hidden`))for(let t of e)t.cells[n]?.classList.add(`wui-col-hidden`)})},ce=e=>G([...e.querySelectorAll(`:scope > tr`)]),le=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},K=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),ue=(e,t)=>{if(!f)return;let n=e.querySelector(`:scope > template[data-wui-empty]`);K(f),t.total===0&&n?(f.replaceChildren(n.content.cloneNode(!0)),f.hidden=!1):(f.replaceChildren(),f.hidden=!0)},de=e=>{let t=re(e),n=t.sortBy!==A.sortBy||t.sortOrder!==A.sortOrder?o(k.rows):null;if(p){let t=e.querySelector(`:scope > template[data-wui-pager]`);K(p),p.replaceChildren(...t?[t.content.cloneNode(!0)]:[]),p.hidden=!1}ue(e,t);let r=e.querySelector(`:scope > template[data-wui-filters]`),i=h.filtersRegion&&r?document.querySelector(h.filtersRegion):null;i&&(K(i),i.replaceChildren(r.content.cloneNode(!0))),le(e),K(k),l.replaceChild(e,k),k=e;let s=T&&t.total!==A.total;A=t,s&&(T=!1),c.removeAttribute(`data-wui-table-error`),ce(e),ye(),a(e.rows,n),s&&X()},fe=e=>{let t=document.createElement(`template`);t.innerHTML=`<table>${e}</table>`;let n=t.content.querySelector(`tbody[data-wui-rows]`);return n&&H(n),n?document.importNode(n,!0):null},pe=e=>{let t=document.createElement(`tr`);for(let n=0;n<e;n++){let e=document.createElement(`td`),r=document.createElement(`span`);r.className=`skeleton`,r.setAttribute(`aria-hidden`,`true`),r.style.cssText=`display:block;width:${n===0?70:50}%;height:12px;border-radius:6px`,e.append(r),t.append(e)}return t},me=()=>{if(k.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,V().length);k.replaceChildren(...Array.from({length:ne},()=>{let t=pe(e);return t.setAttribute(`data-wui-skeleton`,``),t})),c.removeAttribute(`data-wui-table-error`),f&&(f.hidden=!0)},he=e=>{e?(c.setAttribute(`aria-busy`,`true`),me()):c.removeAttribute(`aria-busy`)},ge=e=>e===`forbidden`?S.forbidden:e===`network`?S.network:h.errorText,_e=e=>{let t=ge(e);if(c.setAttribute(`data-wui-table-error`,e),p&&(p.hidden=!0),f){let n=document.createElement(`div`);n.className=`tbl-empty wui-table-error`,n.setAttribute(`role`,`alert`);let r=document.createElement(`span`);r.className=`tbl-empty-icon`,r.innerHTML=s(e===`forbidden`?`lock`:`alert-circle`,{size:24});let i=document.createElement(`div`);i.className=`tbl-empty-title`,i.textContent=t;let a=document.createElement(`div`);a.className=`tbl-empty-action`;let o=document.createElement(`button`);o.type=`button`,o.className=`btn btn-outline-primary btn-sm`,o.setAttribute(`data-wui-table-retry`,``),o.textContent=S.retry,a.append(o),n.append(r,i,a),K(f),f.replaceChildren(n),f.hidden=!1}B(t)},q=async(e,n=`none`)=>{let r=new URLSearchParams(e);j={query:r,mode:n},he(!0),B(h.loadingText),z(`wui:table:loading`,{query:r.toString()});let i=await E.run(ae(r));if(i.kind===`aborted`||i.kind===`stale`||i.kind===`session`)return i;he(!1);let a=null,o=i.ok?null:i.kind;if(i.ok){try{a=fe(i.html)}catch(e){t(e)}a||(o=`server`)}return o?(_e(o),z(`wui:table:error`,{status:i.status,kind:o,message:ge(o)}),i):(de(a),R=L(r,A),h.urlState&&n===`push`?window.history.pushState(window.history.state,``,I(R)):h.urlState&&n===`replace`&&window.history.replaceState(window.history.state,``,I(R)),B(oe(A)),window.WUI?.refresh?.(),z(`wui:table:loaded`,{...A,query:R.toString()}),i)},J=e=>(e.delete(`page`),e),ve=()=>[...l.querySelectorAll(`:scope > thead th[data-sort-key]`)],ye=()=>{for(let e of ve()){let t=e.dataset.sortKey===A.sortBy;e.setAttribute(`aria-sort`,t?A.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of ve())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=e.classList.contains(`num`)||e.classList.contains(`text-end`),n=document.createElement(`span`);n.className=t?`sort-icon wui-sort-lead`:`sort-icon`,n.innerHTML=s(`chevrons-up-down`,{size:14}),t?e.prepend(n):e.append(n)}let Y=e=>{let t=J(new URLSearchParams(R)),n=A.sortBy===e&&A.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),q(t,`push`)};l.addEventListener(`click`,e=>{let t=e.target.closest(`th[data-sort-key]`);t&&l.tHead?.contains(t)&&Y(t.dataset.sortKey)}),l.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target.closest?.(`th[data-sort-key]`);!t||!l.tHead?.contains(t)||(e.preventDefault(),Y(t.dataset.sortKey))});let X=()=>{y(l);let e=T?{selected:A.total,total:A.total,allMatching:T}:{selected:w.size,total:A.total};l.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};C&&(ee(l,(e,t)=>{for(let n of e){let e=n.closest(`tr`)?.dataset.rowKey;e&&(t?w.add(e):w.delete(e))}t||(T=!1)}),l.addEventListener(`change`,e=>{let t=e.target;if(t.matches?.(`.wui-select-cell .wui-check:not(:disabled)`)){if(t.checked||(T=!1),l.tHead?.contains(t))for(let e of k.querySelectorAll(`:scope > tr`)){let n=e.querySelector(`.${u} .wui-check:not(:disabled)`);n&&(n.checked=t.checked,t.checked?w.add(e.dataset.rowKey):w.delete(e.dataset.rowKey))}else{let e=t.closest(`tr`)?.dataset.rowKey;if(!e)return;t.checked?w.add(e):w.delete(e)}X()}})),p&&(p.addEventListener(`click`,e=>{let t=e.target.closest(`a[href]`);!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),q(F(t.getAttribute(`href`)),`push`))}),p.addEventListener(`change`,e=>{!e.target.classList?.contains(`tpg-select`)||!e.target.value||(e.stopPropagation(),q(F(e.target.value),`push`))}));let Z=()=>{if(!h.searchInput)return null;let e=document.querySelector(h.searchInput);return e&&(e.matches(`input, textarea`)?e:e.querySelector(`input`))},Q=()=>e.isConnected?!0:(D.abort(),clearTimeout(M),!1),be=(e,t)=>{let n=t?.name?new FormData(e,t):new FormData(e),r=new Set([...e.querySelectorAll(`[name]`)].map(e=>e.getAttribute(`name`))),i=new URLSearchParams;for(let[e,t]of R)e!==`page`&&(te.includes(e)||!r.has(e))&&i.append(e,t);for(let[e,t]of n)typeof t!=`string`||t===``||te.includes(e)||b.has(e)||i.append(e,t);let a=Z();if(a){i.delete(x);let e=a.value.trim();e&&i.set(x,e)}return q(i,`push`)},xe=e=>h.filtersForm&&e.closest?.(h.filtersForm)||h.filtersRegion&&e.closest?.(h.filtersRegion)||null;document.addEventListener(`submit`,e=>{!Q()||!h.filtersForm||!(e.target instanceof HTMLFormElement)||!e.target.matches(h.filtersForm)||(e.preventDefault(),be(e.target,e.submitter))},O),document.addEventListener(`change`,e=>{if(!Q()||!h.filtersForm)return;let t=e.target.closest?.(h.filtersForm);!t||e.target===Z()||be(t)},O);let Se=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of e.querySelectorAll(`input[name]:not([type=hidden])`))if(r.type===`checkbox`)r.checked=t.getAll(r.name).includes(r.value);else if(r.type===`radio`){let e=n(r.name)===r.value;if(r.checked===e)continue;r.checked=e,e&&r.dispatchEvent(new Event(`change`))}else r.value!==n(r.name)&&(r.value=n(r.name),r.dispatchEvent(new Event(`input`,{bubbles:!0})));for(let r of e.querySelectorAll(`select[name]`))if(!r.multiple)r.value=n(r.name);else for(let e of r.options)e.selected=t.getAll(r.name).includes(e.value);for(let t of e.querySelectorAll(`wui-select[name]`))t.value=n(t.getAttribute(`name`));for(let n of e.querySelectorAll(`wui-multiselect[name]`))n.values=t.getAll(n.getAttribute(`name`));for(let t of e.querySelectorAll(`wui-date-range`)){let e=t.getAttribute(`start-name`)||t.getAttribute(`name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!Q())return;let t=e.target.closest?.(`a[href]`);if(!t||!xe(t)||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let n=new URL(t.getAttribute(`href`),window.location.href);if(n.origin!==window.location.origin||n.pathname!==window.location.pathname)return;e.preventDefault();let r=J(F(n.href));Se(t.closest(`form`),r),q(r,`push`)},O),document.addEventListener(`input`,e=>{if(!Q())return;let t=Z();!t||e.target!==t||(clearTimeout(M),M=setTimeout(()=>{let e=J(new URLSearchParams(R)),n=t.value.trim();n?e.set(x,n):e.delete(x),e.toString()!==R.toString()&&q(e,`replace`)},300))},O),h.urlState&&window.addEventListener(`popstate`,()=>{if(!Q())return;let e=P(window.location.search),t=Z();t&&(t.value=e.get(`search`)??``),q(e,`none`)},O),document.addEventListener(`wui:modal:success`,()=>{Q()&&h.refreshOnSuccess&&q(R,`none`)},O),f?.addEventListener(`click`,e=>{e.target.closest(`[data-wui-table-retry]`)&&j&&q(j.query,j.mode)});let Ce=e=>[...k.rows].find(t=>t.dataset.rowKey===e)??null,we=e=>{if(!e?.trim())return null;let t=document.createElement(`template`);if(t.innerHTML=`<table><tbody>${e}</tbody></table>`,t.content.querySelector(`tbody[data-wui-rows]`))return null;let n=[...t.content.querySelectorAll(`table > tbody > tr[data-row-key]`)];return n.length?n.map(e=>document.importNode(e,!0)):null},Te=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let i=[];for(let n of e){let e=n===r?t:Ce(n.dataset.rowKey);e&&(K(e),e.replaceWith(n),i.push(n))}return G(i),window.WUI?.refresh?.(),r},Ee=e=>e.message||(e.kind===`forbidden`?S.actionForbidden:S.actionFailed),$=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&r(e,null)},De=e=>{if(e instanceof HTMLTableRowElement)return e;let t=document.createElement(`template`);t.innerHTML=`<table><tbody>${String(e)}</tbody></table>`;let n=t.content.querySelector(`table > tbody > tr`);if(!n)throw Error("saveRow's `row` is the row as it will read: a <tr> element or its HTML.");return document.importNode(n,!0)},Oe=async({url:e,method:t=`POST`,body:a,key:o,row:s}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let l=o==null,d=l?null:Ce(String(o));if(!l&&!d)throw Error(`saveRow found no row with data-row-key="${o}" on this page.`);let p=V().filter(e=>!e.classList.contains(u)).length,m=s?De(s):d??pe(Math.max(1,p));d&&m!==d?d.replaceWith(m):d||k.insertBefore(m,k.firstChild),m!==d&&G([m]),f&&!c.hasAttribute(`data-wui-table-error`)&&(f.hidden=!0),r(m,`saving`);let h=n(m),g=await W(e,{method:t.toUpperCase(),body:a});if(g.kind===`session`)return!1;if(g.ok){let e=we(g.html),t=e&&m.isConnected?Te(e,m,l):null;return t?B(i.saved(n(t)||h)):(await q(R,`none`),$(m)),N(g,g.toastVariant||`success`),z(`wui:table:saved`,{key:t?.dataset.rowKey??(l?null:String(o)),added:l,status:g.status}),!0}let _=Ee(g),v=m;return d&&m!==d&&m.isConnected?(m.replaceWith(d),v=d):l&&!s&&(m.remove(),v=null,f?.childElementCount&&!k.querySelector(`:scope > tr`)&&(f.hidden=!1)),v?.isConnected&&r(v,`error`,_),g.kind!==`aborted`&&ie(_,`danger`),B(i.notSaved(h,_)),z(`wui:table:failed`,{key:l?null:String(o),added:l,status:g.status,kind:g.kind,message:_}),!1},ke=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let a=e.closest(`tr`),o=a?.dataset.rowKey??null,s=e.dataset.wuiRowAction||``,c=a?n(a):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),a&&r(a,`saving`);let l=await W(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),l.kind===`session`||l.kind===`aborted`){$(a);return}if(l.ok){N(l,l.toastVariant||`success`);let e=a?.isConnected?we(l.html):null,t=e?Te(e,a,!1):null;t?B(i.saved(n(t)||c)):(await q(R,`none`),$(a))}else{let e=Ee(l);ie(e,`danger`),a?.isConnected&&r(a,`error`,e),B(i.notSaved(c,e))}z(`wui:table:action`,{action:s,key:o,ok:l.ok,status:l.status})};return l.addEventListener(`click`,e=>{let t=e.target.closest(`[data-wui-row-action]`);!t||!k.contains(t)||t.disabled||(e.preventDefault(),ke(t))}),H(k),le(k),C&&v(l),ce(k),ye(),{el:e,reload:()=>q(R,`none`),query:()=>new URLSearchParams(R),setQuery:e=>{let t=new URLSearchParams(R);for(let[n,r]of Object.entries(e??{})){t.delete(n);for(let e of Array.isArray(r)?r:[r])e!=null&&e!==``&&t.append(n,String(e))}return(!e||!(`page`in e))&&t.delete(`page`),q(t,`push`)},saveRow:Oe,setActiveRow:t=>{e.dataset.activeRowKey=t==null?``:String(t),U([...k.querySelectorAll(`:scope > tr`)])},selection:{keys:()=>[...w],count:()=>T?A.total:w.size,allMatching:()=>T,selectAllMatching:()=>{T=!0;for(let e of k.querySelectorAll(`:scope > tr`)){let t=e.querySelector(`.${u} .wui-check`);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&w.add(e.dataset.rowKey))}X()},clear:()=>{T=!1,w.clear();for(let e of k.querySelectorAll(`:scope > tr > .${u} .wui-check:not(:disabled)`))e.checked=!1;X()}}}}var O=8e3,k=Object.freeze([`POST`,`PUT`,`PATCH`,`DELETE`]),A=`That did not work. Try again.`,j=t=>(e(`[@webority/ui-elements] X-Wui-Toast-Action: ${t}; the toast shows no action.`),null);function M(e){if(e==null||e===``)return null;let t;try{t=JSON.parse(e)}catch{return j(`the value is not JSON`)}let n=t?.label,r=t?.url,i=String(t?.method??`POST`).toUpperCase();return typeof n!=`string`||n===``||typeof r!=`string`||r===``?j(`label and url must be non-empty strings`):k.includes(i)?{label:n,url:r,method:i}:j(`method must be one of ${k.join(`, `)}`)}function N(e,t=`success`){if(!e?.message)return;let n=e.toastAction;if(!n){window.WUI?.toast?.(e.message,{variant:t});return}window.WUI?.toast?.(e.message,{variant:t,duration:O,action:{label:n.label,onClick:()=>P(n)}})}async function P(e){let t=await W(e.url,{method:e.method});if(!(t.kind===`session`||t.kind===`aborted`)){if(t.ok){N(t,t.toastVariant||`success`);for(let e of document.querySelectorAll(`[data-wui-server]`))e.dataset.refreshOnSuccess!==`false`&&E(e)?.reload();return}window.WUI?.toast?.(t.message||A,{variant:`danger`})}}var F=`wui-csrf`,I=`RequestVerificationToken`,ae=`X-Wui-Request`,L=Object.freeze({fragment:`X-Wui-Fragment`,message:`X-Wui-Message`,redirect:`X-Wui-Redirect`,result:`X-Wui-Result`,keepOpen:`X-Wui-Keep-Open`,toastVariant:`X-Wui-Toast-Variant`,toastAction:`X-Wui-Toast-Action`,data:`X-Wui-Data`,next:`X-Wui-Next`}),R=Object.freeze([`ok`,`validation`,`forbidden`,`client`,`server`,`network`,`aborted`,`stale`,`session`]),z=new Set([`GET`,`HEAD`]);function B(e=document){let t=e.querySelector(`meta[name="${F}"]`),n=t?.getAttribute(`content`);return n?{header:t.getAttribute(`data-header`)||`RequestVerificationToken`,token:n}:null}var oe=e=>{try{return new URL(e,window.location.href).origin===window.location.origin}catch{return!1}};function V(e){return e>=200&&e<300?`ok`:e===401?`session`:e===403?`forbidden`:e===422?`validation`:e>=400&&e<500?`client`:`server`}var H=e=>e?.name===`AbortError`,U=e=>{if(e==null||e===``)return null;try{return JSON.parse(e)}catch{return t(`X-Wui-Data is not JSON; it was ignored.`),null}};async function W(e,t={}){let n=(t.method||`GET`).toUpperCase(),r=t.navigate||(e=>window.location.assign(e)),i={Accept:`text/html`,"X-Requested-With":`XMLHttpRequest`,[ae]:`1`,...t.headers};if(!z.has(n)&&oe(e)){let e=B();e&&(i[e.header]=e.token)}let a=e=>{if(e==null)return null;try{return decodeURIComponent(e)}catch{return e}},o=(e,t=null,n=``)=>{let r=e=>t?.headers.get(e)??null;return{kind:e,ok:e===`ok`,status:t?.status??0,html:n,response:t,message:a(r(L.message)),redirect:r(L.redirect),result:r(L.result),keepOpen:r(L.keepOpen)===`1`,toastVariant:r(L.toastVariant),toastAction:M(r(L.toastAction)),fragment:r(L.fragment)===`1`,data:U(a(r(L.data))),next:r(L.next)}},s;try{s=await fetch(e,{method:n,body:t.body,headers:i,signal:t.signal,credentials:`same-origin`})}catch(e){return o(H(e)||t.signal?.aborted?`aborted`:`network`)}let c=V(s.status);if(c===`ok`&&s.redirected&&s.headers.get(L.fragment)!==`1`&&(c=`session`),c===`session`)return r(s.status===401?s.headers.get(`Location`)||window.location.href:s.url),o(c,s);let l=``;if(c===`ok`||c===`validation`)try{l=await s.text()}catch(e){return o(H(e)||t.signal?.aborted?`aborted`:`network`,s)}return o(c,s,l)}function se(){let e=null,t=0;return{async run(n,r={}){e?.abort();let i=new AbortController;e=i;let a=++t,o=r.signal;o&&(o.aborted?i.abort():o.addEventListener(`abort`,()=>i.abort(),{once:!0}));let s=await W(n,{...r,signal:i.signal});return e===i&&(e=null),a!==t&&s.kind!==`aborted`?{...s,kind:`stale`,ok:!1}:s},abort(){e?.abort(),e=null}}}export{p as C,f as S,y as T,u as _,V as a,v as b,W as c,M as d,P as f,c as g,T as h,L as i,k as l,E as m,I as n,se as o,N as p,R as r,B as s,F as t,O as u,l as v,m as w,ee as x,_ as y};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/ui-elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.0",
|
|
4
4
|
"description": "Webority framework-agnostic UI custom elements (<wui-*>) — the single implementation of the interactive components, styled by @webority/theme. Used natively in Razor and wrapped by @webority/ui-react.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-BlsR4tqa.js";var t=Object.freeze({slide:(e,t)=>`${e} of ${t}`,status:(e,t,n)=>e===t?`Slide ${e} of ${n}`:`Slides ${e} to ${t} of ${n}`,dot:`Go to slide`,pause:`Pause`,play:`Play`}),n=120,r=class extends e{static get observedAttributes(){return[`autoplay`]}constructor(){super(),this._page=0,this._pages=1,this._perView=1,this._paused=!1,this._hover=!1,this._focus=!1,this._timer=null,this._settleTimer=null,this._status=``,this._ready=!1,this._motion=null,this._mutations=null,this._resizer=null,this._doc=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onScroll=()=>{clearTimeout(this._settleTimer),this._settleTimer=setTimeout(()=>this._settle(),n)},this._onEnter=()=>this._hold({hover:!0}),this._onLeave=()=>this._hold({hover:!1}),this._onFocusIn=()=>this._hold({focus:!0}),this._onFocusOut=e=>this._hold({focus:!!e.relatedTarget&&this.contains(e.relatedTarget)}),this._onVisibility=()=>this._sync(),this._onMotion=()=>this._sync(),this._tick=()=>{this._timer=null,this._go(this._page+1<this._pages?this._page+1:0)}}connectedCallback(){if(this._track=this.querySelector(`.wui-carousel-track`),!this._track){this.ownerDocument.readyState===`loading`&&this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this._doc=this.ownerDocument,this._motion=typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(`(prefers-reduced-motion: reduce)`):null,this._motion?.addEventListener(`change`,this._onMotion),this.addEventListener(`click`,this._onClick),this.addEventListener(`mouseenter`,this._onEnter),this.addEventListener(`mouseleave`,this._onLeave),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._track.addEventListener(`keydown`,this._onKeyDown),this._track.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._doc.addEventListener(`visibilitychange`,this._onVisibility),typeof MutationObserver<`u`&&(this._mutations=new MutationObserver(()=>this._refresh()),this._mutations.observe(this._track,{childList:!0})),typeof ResizeObserver<`u`&&(this._resizer=new ResizeObserver(()=>this._refresh()),this._resizer.observe(this._track)),this._ready=!0,this._refresh()}disconnectedCallback(){this._ready=!1,clearTimeout(this._timer),clearTimeout(this._settleTimer),this._timer=null,this._motion?.removeEventListener(`change`,this._onMotion),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mouseenter`,this._onEnter),this.removeEventListener(`mouseleave`,this._onLeave),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._track?.removeEventListener(`keydown`,this._onKeyDown),this._track?.removeEventListener(`scroll`,this._onScroll),this._doc?.removeEventListener(`visibilitychange`,this._onVisibility),this._mutations?.disconnect(),this._resizer?.disconnect(),this._mutations=this._resizer=this._motion=this._doc=null}attributeChangedCallback(){this._ready&&this._sync()}get paused(){return this._paused}set paused(e){this._paused=!!e,this._ready&&this._sync()}next(){this._page+1<this._pages?this._go(this._page+1):this.hasAttribute(`loop`)&&this._go(0)}prev(){this._page>0?this._go(this._page-1):this.hasAttribute(`loop`)&&this._go(this._pages-1)}goTo(e){this._go(Number(e))}_interval(){let e=Number.parseInt(this.getAttribute(`autoplay`)??``,10);return e>0?e:0}_slides(){return Array.from(this._track.children).filter(e=>e.classList.contains(`wui-carousel-slide`))}_playing(){return this._interval()>0&&this._pages>1&&!this._paused&&!this._hover&&!this._focus&&!this._motion?.matches&&!this._doc?.hidden}_hold({hover:e=this._hover,focus:t=this._focus}){this._hover=e,this._focus=t,this._sync()}_click(e){let t=e.target.closest?.(`.wui-carousel-pause, .wui-carousel-prev, .wui-carousel-next, .wui-carousel-dot`);!t||!this.contains(t)||this._track.contains(t)||(t.classList.contains(`wui-carousel-pause`)?(this._paused=!this._paused,this._hover=!1,this._focus=!1,this._sync()):t.getAttribute(`aria-disabled`)===`true`?e.preventDefault():t.classList.contains(`wui-carousel-prev`)?this.prev():t.classList.contains(`wui-carousel-next`)?this.next():this._go(Number(t.dataset.page)))}_key(e){if(e.target!==this._track||e.altKey||e.ctrlKey||e.metaKey)return;let t={ArrowRight:()=>this.next(),ArrowLeft:()=>this.prev(),Home:()=>this._go(0),End:()=>this._go(this._pages-1)}[e.key];t&&(e.preventDefault(),t())}_perViewNow(){let e=typeof window<`u`?window.getComputedStyle(this._track).getPropertyValue(`--wui-carousel-view`):``,t=Number.parseInt(e,10);return t>=1?t:1}_start(e){return Math.min(e*this._perView,Math.max(0,this._slides().length-this._perView))}_label(){let e=this._slides();return e.forEach((n,r)=>{let i=t.slide(r+1,e.length);n.getAttribute(`aria-label`)!==i&&n.setAttribute(`aria-label`,i)}),e.length}_refresh(){let e=this._label();this._perView=this._perViewNow();let n=Math.max(1,Math.ceil(e/this._perView)),r=this.querySelector(`.wui-carousel-dots`);if(r&&r.children.length!==n){let e=this.getAttribute(`dot-label`)||t.dot;r.replaceChildren(...Array.from({length:n},(t,n)=>{let r=this.ownerDocument.createElement(`button`);return r.type=`button`,r.className=`wui-carousel-dot`,r.dataset.page=String(n),r.setAttribute(`aria-label`,`${e} ${this._start(n)+1}`),r}))}this._pages=n,this._page=Math.min(this._page,n-1),this.toggleAttribute(`data-single`,n<=1),this._render(!1),this._sync()}_settle(){let e=this._track,t=this._slides();if(!t.length)return;let n;if(e.scrollWidth>e.clientWidth&&e.scrollLeft+e.clientWidth>=e.scrollWidth-2)n=this._pages-1;else{let r=0,i=1/0;t.forEach((t,n)=>{let a=Math.abs(t.offsetLeft-e.scrollLeft);a<i&&(i=a,r=n)}),n=Math.min(this._pages-1,Math.round(r/this._perView))}n!==this._page&&(this._page=n,this._render(!0),this._sync())}_go(e){if(!Number.isInteger(e))return;this._page=Math.max(0,Math.min(this._pages-1,e));let t=this._slides()[this._start(this._page)];if(t){let e=this._motion?.matches?`auto`:`smooth`;typeof this._track.scrollTo==`function`?this._track.scrollTo({left:t.offsetLeft,behavior:e}):this._track.scrollLeft=t.offsetLeft}this._render(!0),this._sync()}_render(e){let n=this.hasAttribute(`loop`);for(let e of this.querySelectorAll(`.wui-carousel-dot`))Number(e.dataset.page)===this._page?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`);this.querySelector(`.wui-carousel-prev`)?.setAttribute(`aria-disabled`,String(!n&&this._page===0)),this.querySelector(`.wui-carousel-next`)?.setAttribute(`aria-disabled`,String(!n&&this._page===this._pages-1));let r=this._slides().length,i=this._start(this._page)+1,a=Math.min(r,i+this._perView-1),o=t.status(i,a,r);if(o===this._status||(this._status=o,!e))return;let s=this.querySelector(`[data-wui-status]`);s&&!this._playing()&&(s.textContent=o),this.dispatchEvent(new CustomEvent(`wui:carousel:change`,{bubbles:!0,detail:{page:this._page,pages:this._pages}}))}_sync(){clearTimeout(this._timer),this._timer=null;let e=this._interval(),n=this.querySelector(`.wui-carousel-pause`);if(n){n.hidden=e===0||this._pages<=1||!!this._motion?.matches;let r=this._paused?this.getAttribute(`play-label`)||t.play:this.getAttribute(`pause-label`)||t.pause,i=n.querySelector(`.wui-carousel-pause-text`);i&&i.textContent!==r&&(i.textContent=r),this.toggleAttribute(`data-paused`,this._paused)}this._playing()&&(this._timer=setTimeout(this._tick,e))}};export{r as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-BlsR4tqa.js";import{t}from"./tourOpenMark-nPeAJFSo.js";var n={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-ink":`#4F46E5`,"--color-primary-text":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-surface":`#FFFFFF`,"--wui-radius-lg":`14px`,"--wui-shadow-overlay-lg":`0 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-fixed":`1030`},r=e=>`var(${e}, ${n[e]})`,i=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${r(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${r(`--color-text`)}; } :host([position="bottom-right"]) { right: 20px; left: auto; } :host(:not([open])) { pointer-events: none; } :host([tour-open]) { visibility: hidden; } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .wui-consent-banner-panel { padding: 20px; background: ${r(`--color-surface`)}; border: 1px solid ${r(`--color-border`)}; border-radius: ${r(`--wui-radius-lg`)}; box-shadow: ${r(`--wui-shadow-overlay-lg`)}; text-align: start; pointer-events: auto; } .wui-consent-banner-heading { margin: 0 0 8px; font-size: 18px; font-weight: 600; line-height: 1.3; color: ${r(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${r(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${r(`--color-primary-ink`)}; font-weight: 500; } .wui-consent-banner-settings { display: grid; gap: 12px; max-height: 50vh; margin: 0 0 16px; padding: 12px 0; overflow-y: auto; border-top: 1px solid ${r(`--color-border`)}; border-bottom: 1px solid ${r(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${r(`--color-text-muted`)}; } .form-check { display: flex; align-items: center; gap: 0.5em; margin: 0; font-size: 14px; } .form-check-input { appearance: none; flex: none; width: 2em; height: 1em; margin: 0; border: 1px solid rgba(0, 0, 0, 0.25); border-radius: 2em; background: ${r(`--color-surface`)} radial-gradient(circle, rgba(0, 0, 0, 0.25) 0.35em, transparent 0.4em) left / 1em 1em no-repeat; cursor: pointer; transition: background-position 0.15s ease-in-out; } .form-check-input:checked { border-color: ${r(`--color-primary`)}; background: ${r(`--color-primary`)} radial-gradient(circle, #fff 0.35em, transparent 0.4em) right / 1em 1em no-repeat; } .form-check-input:disabled { opacity: 0.5; cursor: default; } .form-check-input:focus-visible { outline: 2px solid ${r(`--color-primary`)}; outline-offset: 2px; } .form-check-label { cursor: pointer; } .wui-consent-banner-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; } .btn { display: inline-block; 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; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid ${r(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${r(`--color-primary`)}; border-color: ${r(`--color-primary`)}; color: ${r(`--color-primary-text`)}; } .btn-primary:hover { background: ${r(`--color-primary-hover`)}; border-color: ${r(`--color-primary-hover`)}; } .btn-outline-secondary { border-color: ${r(`--color-text-muted`)}; color: ${r(`--color-text-muted`)}; } .btn-outline-secondary:hover { background: ${r(`--color-bg-muted`)}; color: ${r(`--color-text`)}; } .btn-link { font-weight: 400; color: ${r(`--color-primary-ink`)}; text-decoration: underline; } .btn-link:hover { color: ${r(`--color-primary-hover`)}; } .wui-consent-banner-settings-toggle { margin-inline-end: auto; padding-inline: 0; } .wui-consent-banner-save { flex: 1 1 100%; } @media (max-width: 575.98px) { :host, :host([position="bottom-right"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } .wui-consent-banner-panel { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } /* Hidden on phones, but it stays the dialog's accessible name. */ .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } .wui-consent-banner-description { margin: 0 0 8px; font-size: 13px; line-height: 1.4; } .wui-consent-banner-actions { gap: 6px; } } `,a=`wui-consent-save`,o=`[data-consent-settings]`,s=`tour-open`,c=`--wui-consent-banner-block`,l=`--wui-consent-banner-inline`,u={heading:`Cookies on this site`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,policyLabel:`Cookie policy`,essentialLabel:`Essential cookies`,essentialDescription:`Required for the site to work and stay secure. Always on.`,analyticsLabel:`Analytics cookies`,analyticsDescription:`Help us understand how visitors use the site.`,functionalLabel:`Functional cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,marketingLabel:`Marketing cookies`,marketingDescription:`Measure how well our campaigns work.`,settingsLabel:`Cookie settings`,rejectLabel:`Reject all`,acceptLabel:`Accept all`,saveLabel:`Save preferences`},d=[`analytics`,`functional`,`marketing`],f={analytics:{label:u.analyticsLabel,description:`analyticsDescription`},functional:{label:u.functionalLabel,description:`functionalDescription`},marketing:{label:u.marketingLabel,description:`marketingDescription`}},p=new Set;function m(e){p.has(e)||(p.add(e),console.warn(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${d.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var h=0,g=class extends e{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),h+=1,this._uid=`wui-consent-${h}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(o)&&(e.preventDefault(),this.open({settings:!0,focus:!0}))},this._tourWatch=null,this._roomObserver=null,this._onWindowResize=()=>this._reserveRoom()}get position(){return this.getAttribute(`position`)===`bottom-right`?`bottom-right`:`bottom-left`}set position(e){this.setAttribute(`position`,String(e??`bottom-left`))}get standalone(){return this.hasAttribute(`standalone`)}set standalone(e){this.toggleAttribute(`standalone`,e===!0||e===``||e===`true`)}get heading(){return this.getAttribute(`heading`)||u.heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||u.description}set description(e){this.setAttribute(`description`,String(e??``))}get policyHref(){return this.getAttribute(`policy-href`)||``}set policyHref(e){this.setAttribute(`policy-href`,String(e??``))}get policyLabel(){return this.getAttribute(`policy-label`)||u.policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||u.analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||u.functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||u.marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...d];let t=e.split(/\s+/).filter(Boolean);for(let e of t)d.includes(e)||m(e);let n=d.filter(e=>t.includes(e));return n.length?n:[...d]}set categories(e){e==null?this.removeAttribute(`categories`):this.setAttribute(`categories`,Array.isArray(e)?e.join(` `):String(e))}get preferences(){let e=this.categories;return Object.fromEntries(d.map(t=>[t,e.includes(t)&&this._preferences[t]]))}set preferences(e){this._preferences={analytics:e?.analytics===!0,functional:e?.functional===!0,marketing:e?.marketing===!0},this._applyPreferences()}get isOpen(){return this.hasAttribute(`open`)}connectedCallback(){this._rendered||this.render(),document.addEventListener(`click`,this._onDocumentClick),this._syncTour(),this._tourWatch??=new MutationObserver(()=>this._syncTour()),this._tourWatch.observe(document.documentElement,{attributes:!0,attributeFilter:[t]}),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(s,document.documentElement.hasAttribute(t))}attributeChangedCallback(){this._rendered&&this.render()}render(){let e=this.isOpen,t=this._uid,n=this.policyHref?` <a class="wui-consent-banner-policy" href="${y(this.policyHref)}">${v(this.policyLabel)}</a>`:``,r=this._root();r.innerHTML=`${r===this?``:`<style>${i}</style>`} <div class="wui-consent-banner-panel" role="dialog" aria-labelledby="${t}-heading" aria-describedby="${t}-description" hidden> <h2 class="wui-consent-banner-heading" id="${t}-heading">${v(this.heading)}</h2> <p class="wui-consent-banner-description" id="${t}-description">${v(this.description)}${n}</p> <div class="wui-consent-banner-settings" hidden> ${_(t,`essential`,u.essentialLabel,u.essentialDescription,!0)} ${this.categories.map(e=>_(t,e,f[e].label,this[f[e].description],!1)).join(` `)} </div> <div class="wui-consent-banner-actions"> <button type="button" class="btn btn-sm btn-link wui-consent-banner-settings-toggle" aria-expanded="false">${u.settingsLabel}</button> <button type="button" class="btn btn-sm btn-outline-secondary wui-consent-banner-reject">${u.rejectLabel}</button> <button type="button" class="btn btn-sm btn-primary wui-consent-banner-accept">${u.acceptLabel}</button> <button type="button" class="btn btn-sm btn-primary wui-consent-banner-save" hidden>${u.saveLabel}</button> </div> </div>`,this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),e&&(this._panel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._panel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t&&(e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`))?.focus()}close(){let e=this._panel();e&&(e.hidden=!0),this.removeAttribute(`open`),this._showSettings(!1),this._untrackRoom()}_trackRoom(){this.isConnected&&(typeof ResizeObserver<`u`&&(this._roomObserver??=new ResizeObserver(()=>this._reserveRoom()),this._roomObserver.observe(this)),window.addEventListener(`resize`,this._onWindowResize),this._reserveRoom())}_untrackRoom(){this._roomObserver?.disconnect(),window.removeEventListener(`resize`,this._onWindowResize),document.documentElement.style.removeProperty(c),document.documentElement.style.removeProperty(l)}_reserveRoom(){let e=this.getBoundingClientRect(),t=this.position===`bottom-right`?window.innerWidth-e.left:e.right,n=document.documentElement.style;n.setProperty(c,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(l,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){return this._root().querySelector(`.wui-consent-banner-panel`)}_wire(){let e=this._root();e.querySelector(`.wui-consent-banner-accept`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!0))),e.querySelector(`.wui-consent-banner-reject`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!1))),e.querySelector(`.wui-consent-banner-save`)?.addEventListener(`click`,()=>this._save(this._switchValues())),e.querySelector(`.wui-consent-banner-settings-toggle`)?.addEventListener(`click`,()=>this._showSettings(!this._settings))}_save(e){this._preferences={...e},this.dispatchEvent(new CustomEvent(a,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return Object.fromEntries(d.map(n=>[n,e&&t.includes(n)]))}_switchValues(){let e={};for(let t of d)e[t]=this._root().querySelector(`input[data-category="${t}"]`)?.checked===!0;return e}_applyPreferences(){for(let e of d){let t=this._root().querySelector(`input[data-category="${e}"]`);t&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!n)return;n.hidden=!e,t.querySelector(`.wui-consent-banner-settings-toggle`)?.setAttribute(`aria-expanded`,e?`true`:`false`);let r=t.querySelector(`.wui-consent-banner-save`);r&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r&&(r.hidden=e)}}};function _(e,t,n,r,i){let a=`${e}-${t}`;return`<div class="wui-consent-banner-category"> <div class="form-check form-switch"> <input class="form-check-input" type="checkbox" role="switch" id="${a}" data-category="${t}"${i?` checked disabled`:``} /> <label class="form-check-label" for="${a}">${v(n)}</label> </div> <p class="wui-consent-banner-category-description">${v(r)}</p> </div>`}var v=e=>String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),y=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`);export{g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-BlsR4tqa.js";import{C as t,M as n,S as r,T as i,_ as a,b as o,c as s,g as c,h as l,i as u,j as d,r as f,t as p}from"./dataTable-Cd_IJQcs.js";var m=`.wui-col-resize`,h=`.wui-group-row, .wui-virtual-spacer`,g=`.wui-select-cell, .wui-expand-cell`,_=`<svg class="wui-icon" data-icon="chevron-down" width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true" style="vertical-align:-.125em"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="1.5" d="M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95"></path></svg>`,v=e=>e.hasAttribute(`data-wui-skeleton`)||!!e.querySelector(`:scope > td > .skeleton`),y=class extends e{constructor(){super(),this._frame=0,this._headDirty=!0,this._rowsDirty=!0,this._frozenSig=null,this._natural=[],this._widths={},this._collapsed=new Set,this._groupOrder=[],this._items=[],this._range=null,this._drag=null,this._userSized=!1,this._swallowClick=!1,this._mo=null,this._ro=null,this._fonts=null,this._onPointerDown=e=>this._startDrag(e),this._onKeyDown=e=>this._key(e),this._onClick=e=>this._click(e),this._onDblClick=e=>{let t=e.target.closest?.(m);t&&this.contains(t)&&this._reset(t.closest(`th`))},this._onScroll=()=>{this.hasAttribute(`virtual`)&&this._schedule()},this._onFonts=()=>{this._userSized||this._drag||this._frozenSig===null||!this.hasAttribute(`resizable`)||(this._frozenSig=null,this._schedule())}}connectedCallback(){this._widths=i(this.getAttribute(`view-key`)),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick,!0),this.addEventListener(`dblclick`,this._onDblClick),this.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._fonts=this.ownerDocument.fonts??null,this._fonts?.addEventListener(`loadingdone`,this._onFonts),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(e=>this._mutated(e)),this._mo.observe(this,{childList:!0,subtree:!0})),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._schedule()),this._ro.observe(this)),this._headDirty=!0,this._rowsDirty=!0,this._schedule()}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick,!0),this.removeEventListener(`dblclick`,this._onDblClick),this.removeEventListener(`scroll`,this._onScroll),this._fonts?.removeEventListener(`loadingdone`,this._onFonts),this._fonts=null,this._mo?.disconnect(),this._ro?.disconnect(),this._mo=null,this._ro=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this._drag=null}refresh(){this._headDirty=!0,this._rowsDirty=!0,this._run()}get _table(){return this.querySelector(`:scope > table`)}_headCells(e){let t=e.tHead?.rows[0];return t?[...t.cells]:[]}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._run()})}_mutated(e){for(let t of e){let e=t.target.nodeType===1?t.target:t.target.parentElement;e&&((e.closest(`thead`)||e===this._table||e===this)&&(this._headDirty=!0),(e.closest(`tbody, tfoot`)||e===this._table||e===this)&&(this._rowsDirty=!0))}this._schedule()}_run(){let e=this._table;if(!e)return;let t=this._headDirty,n=this._rowsDirty;this._headDirty=!1,this._rowsDirty=!1,n&&this.hasAttribute(`group-by`)&&this._group(e),this._pins(e,t||n),this.hasAttribute(`resizable`)&&(t&&this._handles(e),this._layout(e)),this.hasAttribute(`virtual`)&&this._virtual(e,t||n),this._mo?.takeRecords()}_pins(e,n){let i=this._headCells(e),a=i.map(e=>{let t=e.dataset.pin;return t===`start`||t===`end`?t:e.matches(g)?`lead`:null});if(!a.some(e=>e===`start`||e===`end`))return;let s=t(a);s.forEach((e,t)=>{e&&this._ro?.observe(i[t])});let c=e=>i[e].getBoundingClientRect().width,l=0;s.forEach((t,n)=>{t?.side===`start`&&(this._setVar(e,r(`start`,t.ordinal),l),l+=c(n))}),l=0;for(let t=s.length-1;t>=0;t--){let n=s[t];n?.side===`end`&&(this._setVar(e,r(`end`,n.ordinal),l),l+=c(t))}if(n)for(let t of e.rows)t.matches(`${h}, .wui-row-expanded`)||t.cells.length!==i.length||s.forEach((e,n)=>{if(!e)return;let r=t.cells[n];r.classList.contains(`wui-pin-${e.side}`)||r.classList.add(`wui-pin-${e.side}`),e.edge&&!r.classList.contains(`wui-pin-${e.side}-edge`)&&r.classList.add(`wui-pin-${e.side}-edge`);let i=o(e.side,e.ordinal);r.style.getPropertyValue(`--wui-pin-at`)!==i&&r.style.setProperty(u,i)})}_setVar(e,t,n){let r=`${Math.round(n*100)/100}px`;e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}_resizable(e){return e.map((t,n)=>n<e.length-1&&!t.matches(g))}_handles(e){let t=this._headCells(e),n=this._resizable(t);t.forEach((e,t)=>{if(!n[t]||e.querySelector(m))return;let r=e.ownerDocument.createElement(`span`);r.className=`wui-col-resize`,r.setAttribute(`role`,`separator`),r.setAttribute(`aria-orientation`,`vertical`),r.setAttribute(`aria-valuemin`,`48`),r.setAttribute(`aria-valuemax`,String(p)),r.setAttribute(`tabindex`,`0`);let i=e.textContent.trim();r.setAttribute(`aria-label`,f.resize(i)),i&&!e.hasAttribute(`aria-label`)&&e.setAttribute(`aria-label`,i),e.classList.add(`wui-col-resizable`),e.appendChild(r)})}_hasRows(e){for(let t of e.tBodies)for(let e of t.rows)if(!e.matches(h)&&!v(e))return!0;return!1}_signature(e){return e.map(e=>e.dataset.key||e.textContent.trim()).join(``)}_layout(e){let t=this._headCells(e),n=this._signature(t);!t.length||n===this._frozenSig||(this._hasRows(e)?this._freeze(e,t,n):this._applyRemembered(t))}_applyRemembered(e){for(let t of e){let e=t.dataset.key&&this._widths[t.dataset.key];e&&(t.style.width=`${e}px`);let n=t.querySelector(m);n&&this._handleValue(n,l(e||t.getBoundingClientRect().width))}}_freeze(e,t,n){e.style.tableLayout=``,e.style.width=``,e.removeAttribute(`data-wui-fixed`);for(let e of t)e.hasAttribute(`data-wui-width`)&&(e.style.width=``,e.removeAttribute(`data-wui-width`));this._natural=t.map(e=>e.getBoundingClientRect().width),t.forEach((e,n)=>{if(n===t.length-1||e.matches(g))return;let r=e.dataset.key&&this._widths[e.dataset.key];this._setWidth(e,r||this._natural[n])}),e.style.tableLayout=`fixed`,e.setAttribute(`data-wui-fixed`,``),this._frozenSig=n,this._fitTable(e,t)}_setWidth(e,t){let n=l(t);e.style.width=`${n}px`,e.setAttribute(`data-wui-width`,``);let r=e.querySelector(m);return r&&this._handleValue(r,n),n}_handleValue(e,t){e.setAttribute(`aria-valuenow`,String(t)),e.setAttribute(`aria-valuetext`,f.width(t))}_fitTable(e,t){let n=t.length-1,r=this._natural[n]||0;for(let e=0;e<n;e++)r+=Number.parseFloat(t[e].style.width)||this._natural[e]||0;e.style.width=`max(100%, ${Math.round(r)}px)`}_ensureFrozen(e){let t=this._headCells(e),n=this._signature(t);return n!==this._frozenSig&&this._freeze(e,t,n),t}_resizeTo(e,t,n){let r=this._table;if(!r)return;let i=this._ensureFrozen(r);this._userSized=!0,this._setWidth(e,t),this._fitTable(r,i),n&&this._remember(e),this._pins(r,!1)}_remember(e){let t=e.dataset.key;t&&(this._widths={...this._widths,[t]:Number.parseFloat(e.style.width)},n(this.getAttribute(`view-key`),this._widths))}_reset(e){let t=this._table;if(!e||!t)return;let r=this._ensureFrozen(t);this._userSized=!0;let i=e.dataset.key;if(i&&i in this._widths){let{[i]:e,...t}=this._widths;this._widths=t,n(this.getAttribute(`view-key`),this._widths)}this._setWidth(e,this._natural[r.indexOf(e)]||0),this._fitTable(t,r),this._pins(t,!1)}_rtl(){return getComputedStyle(this).direction===`rtl`}_startDrag(e){let t=e.target.closest?.(m);if(!t||!this.contains(t)||e.button!==0)return;e.preventDefault(),e.stopPropagation();let n=t.closest(`th`),r=this._table;if(!n||!r)return;this._ensureFrozen(r);let i={th:n,x:e.clientX,from:n.getBoundingClientRect().width,dir:this._rtl()?-1:1,moved:!1};this._drag=i,t.setPointerCapture?.(e.pointerId),t.classList.add(`is-dragging`);let a=e=>{let t=(e.clientX-i.x)*i.dir;Math.abs(t)>1&&(i.moved=!0),this._resizeTo(n,i.from+t,!1)},o=e=>{t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o),t.classList.remove(`is-dragging`),this._drag=null,e.type===`pointercancel`?this._resizeTo(n,i.from,!1):i.moved&&this._remember(n),this._swallowClick=!0,setTimeout(()=>{this._swallowClick=!1},0)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}_key(e){let t=e.target.closest?.(m);if(!t||!this.contains(t))return;let n=t.closest(`th`);if(e.key===`Enter`||e.key===` `){e.preventDefault(),e.stopPropagation();return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),this._reset(n);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault(),e.stopPropagation();let r=this._table;if(!r)return;this._ensureFrozen(r);let i=e.shiftKey?50:10,a=e.key===`ArrowRight`!==this._rtl(),o=Number.parseFloat(n.style.width)||n.getBoundingClientRect().width;this._resizeTo(n,o+(a?i:-i),!0)}_click(e){let t=!!e.target.closest?.(m);if(this._swallowClick||t){e.stopPropagation(),(t||this._swallowClick)&&e.preventDefault(),this._swallowClick=!1;return}if(!this.hasAttribute(`group-by`))return;let n=(e.target.closest?.(`.wui-group-toggle`))?.closest(`.wui-group-row`);if(!n||!this.contains(n))return;let r=n.dataset.groupKey;this._collapsed.has(r)?this._collapsed.delete(r):this._collapsed.add(r),this._showGroup(n,!this._collapsed.has(r));let i=this._table;i&&this.hasAttribute(`virtual`)&&(this._virtual(i,!0),this._mo?.takeRecords())}_group(e){let t=this.getAttribute(`group-by`),n=this._headCells(e),r=n.findIndex(e=>e.dataset.key===t);if(r<0)throw Error(`<wui-data-table group-by="${t}"> needs a header cell with data-key="${t}".`);let i=e.tBodies[0];if(!i)return;let o=[...i.rows].filter(e=>!e.matches(h));if(o.some(v))return;let s=this.ownerDocument,l=new Map([...i.querySelectorAll(`:scope > tr.wui-group-row`)].map(e=>[e.dataset.groupKey,e])),u=a(o,e=>e.dataset.group??e.cells[r]?.textContent.trim()??``,this._groupOrder);this._groupOrder=u.map(e=>e.key);let d=s.createDocumentFragment(),p=u.map(e=>{let t=l.get(e.key)??this._groupRow(s,e.key);return l.delete(e.key),t.querySelector(`.wui-group-cell`).colSpan=n.length,t.querySelector(`.wui-group-count`).textContent=c(e.items.length),t.querySelector(`.wui-group-rows`).textContent=`, ${f.rows(e.items.length)}`,d.append(t,...e.items),[t,e.key]});for(let e of l.values())e.remove();i.insertBefore(d,this._bottom?.parentNode===i?this._bottom:null);for(let[e,t]of p)this._showGroup(e,!this._collapsed.has(t))}_groupRow(e,t){let n=e.createElement(`tr`);n.className=`wui-group-row`,n.dataset.groupKey=t;let r=e.createElement(`th`);r.className=`wui-group-cell`,r.scope=`rowgroup`;let i=e.createElement(`button`);i.type=`button`,i.className=`wui-group-toggle`,i.innerHTML=_;let a=e.createElement(`span`);a.className=`wui-group-label`,a.textContent=t;let o=e.createElement(`span`);o.className=`wui-group-count`,o.setAttribute(`aria-hidden`,`true`);let s=e.createElement(`span`);return s.className=`visually-hidden wui-group-rows`,i.append(a,o,s),r.append(i),n.append(r),n}_showGroup(e,t){if(e){e.querySelector(`.wui-group-toggle`)?.setAttribute(`aria-expanded`,String(t));for(let n=e.nextElementSibling;n&&!n.matches(h);n=n.nextElementSibling)n.hidden=!t}}_spacer(e,t){if(t?.parentNode===e)return t;let n=e.ownerDocument,r=n.createElement(`tr`);return r.className=`wui-virtual-spacer`,r.setAttribute(`aria-hidden`,`true`),r.append(n.createElement(`td`)),r}_virtual(e,t){let n=e.tBodies[0];if(!n)return;if(t){this._top=this._spacer(n,this._top),this._bottom=this._spacer(n,this._bottom),n.firstElementChild!==this._top&&n.insertBefore(this._top,n.firstChild),n.lastElementChild!==this._bottom&&n.append(this._bottom);let t=Math.max(1,this._headCells(e).length);this._top.cells[0].colSpan=t,this._bottom.cells[0].colSpan=t,this._items=[...n.rows].filter(e=>!e.classList.contains(`wui-virtual-spacer`)&&!e.hidden),this._range=null,e.setAttribute(`aria-rowcount`,String(this._items.length+1)),e.tHead?.rows[0]?.setAttribute(`aria-rowindex`,`1`),this._items.forEach((e,t)=>e.setAttribute(`aria-rowindex`,String(t+2))),this._rowHeight>0||(this._rowHeight=this._measureRow(e))}let r=e.tHead?.getBoundingClientRect().height||0,i=d({scrollTop:this.scrollTop-r,viewport:this.clientHeight,rowHeight:this._rowHeight,count:this._items.length}),a=this._range;if(a&&a.start===i.start&&a.end===i.end)return;let o=a?Math.min(a.start,i.start):0,s=a?Math.max(a.end,i.end):this._items.length;for(let e=o;e<s;e++){let t=e<i.start||e>=i.end,n=this._items[e];n.classList.contains(`wui-virtual-off`)!==t&&n.classList.toggle(`wui-virtual-off`,t)}this._range=i,this._top.hidden=i.before===0,this._bottom.hidden=i.after===0,this._top.cells[0].style.height=`${i.before}px`,this._bottom.cells[0].style.height=`${i.after}px`}_measureRow(e){let t=this._items.find(e=>!e.classList.contains(`wui-group-row`)&&!e.classList.contains(`wui-virtual-off`))?.getBoundingClientRect().height;return t>0?t:e.classList.contains(`wui-table-compact`)?s.compact:e.classList.contains(`wui-table-cozy`)?s.cozy:s.comfortable}};export{y as t};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-HAWsGzlr.js";import{t as i}from"./iconGlyphs.g-CUm_mfze.js";import{n as a,t as o}from"./focusOrigin-2imUSs-u.js";import{n as s}from"./formMirror-BgY7zkC3.js";import{n as c,t as l}from"./listboxKeyNav-DMIvs9d6.js";import{a as u,i as d,n as f,r as p,t as m}from"./optionLabel-BBaur8Bs.js";import{i as h,t as g}from"./tokenCommit-BKckxgtg.js";var _=class extends e{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`placeholder`,`search-placeholder`,`searchable`,`disabled`,`icon`,`size`,`collapse-chips`,`aria-label`,`aria-invalid`,`allow-custom`,`custom-pattern`,`custom-invalid-message`]}constructor(){super(),this._values=[],this._optionsProp=null,this._active=-1,this._typeahead=``,this._typeaheadTimer=null,this._customError=``;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){if(!this._valuesInit&&!this._optionsProp&&!this._values.length){let e=this.getAttribute(`value`);if(e!=null&&e!==``)this._values=e.split(`,`).map(e=>e.trim()).filter(Boolean);else{let e=[...this.querySelectorAll(`:scope > wui-option[selected]`)].map(e=>e.getAttribute(`value`)??e.textContent.trim());e.length&&(this._values=e.map(String))}}this._valuesInit=!0,this._defaultCaptured||=(this._defaultValues=this._values.slice(),!0),this.render();return}this._bindGlobal?.()}formResetCallback(){this.values=(this._defaultValues||[]).slice();let e=this.querySelector(`[data-input]`);e&&(e.value=``),this._setCustomError(``)}attributeChangedCallback(e){if(e===`aria-invalid`){this._syncInvalid();return}e===`custom-pattern`||e===`custom-invalid-message`||this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._customError?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get values(){return this._values.slice()}set values(e){this._values=Array.isArray(e)?e.map(String):[],s(this,this._values),this._rendered&&(this._renderControl(),this._renderOptions(this._query()))}set options(e){if(this._optionsProp=Array.isArray(e)?e:null,this._rendered&&this._allowCustom){this._renderControl(),this._renderOptions(this._query());return}this.isConnected&&this.render()}get options(){return this._readOptions()}get validateCustom(){return this._validateCustom??null}set validateCustom(e){this._validateCustom=typeof e==`function`?e:null}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_query(){let e=this.querySelector(this._allowCustom?`[data-input]`:`.search-select-input`);return e?e.value:``}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t={value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[m]:!0,selected:e.hasAttribute(`selected`)};for(let[n,r]of y){let i=e.getAttribute(n);i&&(t[r]=i)}return e.hasAttribute(`disabled`)&&(t.disabled=!0),t}))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_labelFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?d(t):u(e)}_labelHtmlFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?p(t):f(e)}render(){this._snapshotDeclared();let e=this._allowCustom,t=this.hasAttribute(`searchable`)&&!e,n=this.getAttribute(`search-placeholder`)||`Search…`,r=this.getAttribute(`icon`),a=this.getAttribute(`size`),o=a===`sm`?` search-select-sm`:a===`lg`?` search-select-lg`:``;s(this,this._values),this.id||=`wui-multiselect-${Math.random().toString(36).slice(2,9)}`;let c=`${this.id}-listbox`;this._listboxId=c;let l=this.hasAttribute(`disabled`);if(e){let e=`${this.id}-custom-error`;this.innerHTML=`
|
|
2
|
-
<div class="search-select${o}">
|
|
3
|
-
<div class="input search-select-control search-select-multi"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${l?` aria-disabled="true"`:``}>
|
|
4
|
-
${r?i(r,{className:`search-select-icon`}):``}
|
|
5
|
-
<div class="ms-chips" data-chips><input type="text" class="ms-input" data-input role="combobox" aria-autocomplete="list" aria-haspopup="listbox" aria-expanded="false" aria-controls="${E(c)}" aria-label="${E(this._accessibleName())}" aria-describedby="${E(e)}" autocomplete="off"${l?` disabled`:``} /></div>
|
|
6
|
-
${i(`chevron-down`,{className:`search-select-caret`})}
|
|
7
|
-
</div>
|
|
8
|
-
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${E(c)}" aria-multiselectable="true" tabindex="-1" hidden>
|
|
9
|
-
<div class="search-select-options"></div>
|
|
10
|
-
</div>
|
|
11
|
-
</div>
|
|
12
|
-
<div class="field-error wui-ms-custom-error" id="${E(e)}" aria-live="polite" hidden></div>`}else this.innerHTML=`
|
|
13
|
-
<div class="search-select${o}">
|
|
14
|
-
<div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${E(c)}" aria-label="${E(this._accessibleName())}"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${l?` aria-disabled="true"`:` tabindex="0"`}>
|
|
15
|
-
${r?i(r,{className:`search-select-icon`}):``}
|
|
16
|
-
<div class="ms-chips" data-chips></div>
|
|
17
|
-
${i(`chevron-down`,{className:`search-select-caret`})}
|
|
18
|
-
</div>
|
|
19
|
-
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${E(c)}" aria-multiselectable="true" tabindex="-1" hidden>
|
|
20
|
-
${t?`<div class="search-select-search">${i(`search`)}<input class="search-select-input" placeholder="${E(n)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden>${i(`x`)}</button></div>`:``}
|
|
21
|
-
<div class="search-select-options"></div>
|
|
22
|
-
<div class="search-select-empty" hidden>No matches</div>
|
|
23
|
-
</div>
|
|
24
|
-
</div>`;this._rendered=!0,this._customError=``,s(this,this._values),this._renderControl(),this._renderOptions(),this._wire()}_renderControl(){let e=this.querySelector(`[data-chips]`);if(!e)return;let t=this.getAttribute(`placeholder`)||`Select…`,n=this._allowCustom?e.querySelector(`[data-input]`):null,r=this._values.map(e=>`<span class="chip chip-sm"><span class="chip-label">${this._labelHtmlFor(e)}</span><button type="button" class="chip-remove" data-remove="${E(e)}" aria-label="Remove ${E(this._labelFor(e))}">${i(`x`)}</button></span>`).join(``);if(n){for(let t of[...e.querySelectorAll(`:scope > .chip`)])t.remove();n.insertAdjacentHTML(`beforebegin`,r),n.placeholder=this._values.length?``:t,this._collapseChips();return}if(!this._values.length){e.innerHTML=`<span class="search-select-placeholder">${f(t)}</span>`;return}e.innerHTML=r,this._collapseChips()}_collapseChips(){let e=this.querySelector(`[data-chips]`);if(!e||!this.hasAttribute(`collapse-chips`)||!this._values.length)return;e.querySelector(`.chip-more`)?.remove();let t=[...e.querySelectorAll(`:scope > .chip:not(.chip-more)`)];for(let e of t)e.style.display=``;if(!t.length)return;let n=e.clientWidth,r=e=>e.offsetLeft+e.offsetWidth;if(r(t[t.length-1])<=n)return;let i=document.createElement(`span`);i.className=`chip chip-sm chip-more`,i.textContent=`+${t.length}`,t[t.length-1].after(i);let a=i.offsetWidth+6,o=0;for(let e of t)if(r(e)<=n-a)o+=1;else break;o<1&&(o=1);for(let e=o;e<t.length;e+=1)t[e].style.display=`none`;i.textContent=`+${t.length-o}`}_matches(e,t){return d(e).toLowerCase().includes(t)||String(e.description??``).toLowerCase().includes(t)}_optionNamed(e){let t=e.trim().toLowerCase();return this._readOptions().find(e=>String(e.value??``).toLowerCase()===t||d(e).trim().toLowerCase()===t)}_renderOptions(e){let t=this.querySelector(`.search-select-options`),n=this.querySelector(`.search-select-empty`);if(!t)return;let r=(e||``).trim(),a=r.toLowerCase(),o=this._readOptions();a&&(o=o.filter(e=>this._matches(e,a)));let s=this._listboxId||`${this.id||`wui-multiselect`}-listbox`,c=this._allowCustom&&r&&!this._optionNamed(r),l=o.map((e,t)=>{let n=this._values.includes(String(e.value)),r=`${s}-opt-${t}`;return b(e)?C(e,r,n):`<button type="button" role="option" id="${E(r)}" class="search-select-option${n?` selected`:``}" data-value="${E(e.value)}" aria-selected="${n}"><span class="ms-opt-label">${p(e)}</span><span class="ms-check">${i(`check`)}</span></button>`});c&&l.push(`<button type="button" role="option" id="${E(`${s}-opt-${o.length}`)}" class="search-select-option search-select-option-custom" data-value="${E(r)}" data-custom="true" aria-selected="false">Add “${f(r)}”</button>`),t.innerHTML=l.join(``),n&&(n.hidden=o.length>0),this._active=-1,this._combobox()?.removeAttribute(`aria-activedescendant`),this._allowCustom&&this._syncCustomMenu?.(),this._reanchor?.()}_combobox(){return this._allowCustom?this.querySelector(`[data-input]`):this.querySelector(`.search-select-control`)}_setCustomError(e){this._customError=e||``;let t=this.querySelector(`.wui-ms-custom-error`),n=this.querySelector(`[data-input]`);t&&(t.textContent=this._customError,t.hidden=!this._customError),n&&(this._customError?n.setAttribute(`aria-invalid`,`true`):n.removeAttribute(`aria-invalid`)),this._syncInvalid()}_customRefusal(e){let t=this.getAttribute(`custom-invalid-message`)||`Enter a valid value.`,n=this.getAttribute(`custom-pattern`);if(n){let r=T(n);if(r&&!r.test(e))return t}let r=this._validateCustom;if(r){let n=r(e);return n===!0?``:typeof n==`string`&&n?n:t}return``}_commitTyped(e){let t=e.trim().replace(/,+$/,``).trim();if(!t)return``;let n=this._optionNamed(t),r;if(n){if(n.disabled)return n.disabledHint||this.getAttribute(`custom-invalid-message`)||`That option is not available.`;r=String(n.value)}else{let e=this._customRefusal(t);if(e)return e;r=t}let i=r.toLowerCase();return this._values.some(e=>e.toLowerCase()===i)||(this._values=[...this._values,r]),``}_wire(){this._teardown();let e=this.querySelector(`.search-select-control`),i=this.querySelector(`.search-select-menu`),u=this.querySelector(`.search-select-input`),d=this.querySelector(`.search-select-clear`),f=this.querySelector(`.search-select-options`),p=this._allowCustom,m=p?this.querySelector(`[data-input]`):null,_=m||e;if(!e||!i)return;let y=()=>this.hasAttribute(`disabled`),b=()=>r(e,i,{matchWidth:!0}),x=()=>[...this.querySelectorAll(`.search-select-option`)],S=()=>x().filter(e=>!e.hidden),C=(e,{reveal:t=!0}={})=>{let n=S();this._active=e,c(f,e>=0&&n[e]||null),e>=0&&n[e]?(t&&n[e].scrollIntoView({block:`nearest`}),_.setAttribute(`aria-activedescendant`,n[e].id)):_.removeAttribute(`aria-activedescendant`)},w=!1,T=()=>p?w:!i.hidden,E=()=>{let t=w&&x().length>0,n=i.hidden;i.hidden=!t,_.setAttribute(`aria-expanded`,String(t)),e.classList.toggle(`open`,t),t&&n&&b()};this._syncCustomMenu=p?E:null;let D=()=>{T()&&b()},O=()=>{if(!y()){if(t(this,D),p){w=!0,E();return}i.hidden=!1,e.setAttribute(`aria-expanded`,`true`),e.classList.add(`open`),b(),u&&(u.value=``,this._renderOptions(``),u.focus())}},k=()=>{p?(w=!1,E()):(i.hidden=!0,e.setAttribute(`aria-expanded`,`false`),e.classList.remove(`open`)),C(-1),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,n(this)},A=()=>{s(this,this._values),this.dispatchEvent(new Event(`change`,{bubbles:!0}))},j=e=>{let t=String(e);if(this._values.includes(t))this._values=this._values.filter(e=>e!==t);else if(p&&this._values.some(e=>e.toLowerCase()===t.toLowerCase()))return;else this._values=[...this._values,t];this._renderControl(),this._renderOptions(this._query()),A()},M=e=>{this._values=this._values.filter(t=>t!==String(e)),this._renderControl(),this._renderOptions(this._query()),A()},N=(e,{quiet:t=!1}={})=>{let n=this._values.length,r=g(e,v)?h(e,v):[e],i=[],a=``;for(let e of r){let t=this._commitTyped(e);t&&(i.push(e.trim()),a||=t)}t&&i.length||(m.value=i.join(`, `),this._setCustomError(a),this._values.length!==n&&(this._renderControl(),A()),this._renderOptions(m.value))},P=e=>{if(!(!e||e.getAttribute(`aria-disabled`)===`true`)){if(e.dataset.custom===`true`){N(e.dataset.value);return}j(e.dataset.value),m?.value&&(m.value=``,this._setCustomError(``),this._renderOptions(``))}};e.addEventListener(`click`,e=>{if(y())return;let t=e.target.closest(`[data-remove]`);if(t){e.stopPropagation(),M(t.dataset.remove),m?.focus();return}if(m){let t=T();e.target!==m&&m.focus(),e.target===m||!t?O():k();return}T()?k():O()}),f.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&(P(t),(m||u)?.focus())}),f.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&!t.classList.contains(`is-active`)&&C(S().indexOf(t),{reveal:!1})}),f.addEventListener(`mouseleave`,()=>C(-1)),f.addEventListener(`error`,e=>{e.target?.classList?.contains(`avatar-img`)&&e.target.remove()},!0),u?.addEventListener(`input`,()=>{this._renderOptions(u.value),d&&(d.hidden=!u.value),C(-1)}),this._navHandler=l({getVisibleOptions:S,getActive:()=>this._active,setActive:e=>C(e),onEnter:e=>{e?P(e):m?.value.trim()&&N(m.value)},onEscape:()=>{this._navHandler.clearTypeahead(),k(),m||e.focus()}});let F=e=>{let t=m||u;if(e.key===`Backspace`&&!t?.value&&this._values.length){M(this._values[this._values.length-1]);return}e.key===`Escape`&&T()&&(e.preventDefault(),e.stopPropagation()),this._navHandler.handler(e)};if(u?.addEventListener(`keydown`,F),d?.addEventListener(`click`,()=>{u.value=``,this._renderOptions(``),d.hidden=!0,u.focus()}),m){let t=e=>{e.target!==m&&e.preventDefault()};f.addEventListener(`mousedown`,t),e.addEventListener(`mousedown`,t),a(),m.addEventListener(`focus`,()=>{o()&&O()}),m.addEventListener(`input`,()=>{this._customError&&this._setCustomError(``),this._renderOptions(m.value),O()}),m.addEventListener(`keydown`,e=>{if(e.key===`,`&&m.value.trim()){e.preventDefault(),N(m.value);return}if(e.key===`Enter`){if(this._active<0&&!m.value.trim())return;this._navHandler.handler(e);return}(e.key===`ArrowDown`||e.key===`ArrowUp`)&&!T()&&O(),F(e)}),m.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text/plain`)??``;g(t,v)&&(e.preventDefault(),N(`${m.value}${t}`))}),m.addEventListener(`blur`,e=>{e.relatedTarget&&this.contains(e.relatedTarget)||(m.value.trim()&&N(m.value,{quiet:!0}),k())})}else e.addEventListener(`keydown`,e=>{if(T()){F(e);return}(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),O())});this._bindGlobal=()=>{this._teardown(),!this._ro&&typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._collapseChips()),this._ro.observe(this)),this._onDocClick=e=>{T()&&!this.contains(e.target)&&k()},document.addEventListener(`click`,this._onDocClick),T()&&t(this,D)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this),this._navHandler?.teardown()}disconnectedCallback(){this._teardown(),this._ro?.disconnect(),this._ro=null}},v=[`,`,`;`,`
|
|
25
|
-
`,` `],y=[[`description`,`description`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],b=e=>!!(e.description||e.avatar||e.initials||e.disabled||e.disabledHint),x=e=>{let t=String(e??``).trim();return/^(https?:)?\/\//i.test(t)||/^\/(?!\/)/.test(t)||/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(t)?t:``},S=e=>{let t=x(e.avatar);return!t&&!e.initials?``:`<span class="avatar wui-opt-avatar" aria-hidden="true"><span class="avatar-face">${f(e.initials??``)}</span>${t?`<img class="avatar-img" src="${E(t)}" alt="" />`:``}</span>`},C=(e,t,n)=>{let r=!!e.disabled,a=e.description?`<span class="wui-opt-desc">${f(e.description)}</span>`:``,o=e.disabledHint&&r?`<span class="wui-opt-hint">${f(e.disabledHint)}</span>`:``;return`<button type="button" role="option" id="${E(t)}" class="search-select-option wui-opt-rich${n?` selected`:``}" data-value="${E(e.value)}" aria-selected="${n}"${r?` aria-disabled="true"`:``}><span class="ms-opt-label"><span class="wui-opt-name">${p(e)}</span>${a}</span>${o}${S(e)}<span class="ms-check">${i(`check`)}</span></button>`},w=new Map,T=e=>{if(w.has(e))return w.get(e);let t=null;try{t=RegExp(`^(?:${e})$`,`u`)}catch{console.warn(`<wui-multiselect> custom-pattern is not a valid regular expression and is ignored: ${e}`)}return w.set(e,t),t},E=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`);export{_ as t};
|
package/dist/WuiTree-BSx5pKJo.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-BlsR4tqa.js";import{t}from"./iconGlyphs.g-CUm_mfze.js";import{c as n}from"./wuiHttp-0pGmgUIV.js";import{n as r,t as i}from"./formMirror-BgY7zkC3.js";import{t as a}from"./listboxKeyNav-DMIvs9d6.js";var o=[`none`,`single`,`multiple`],s=`parentId`,c=`Loading`,l=`Could not load. Try again.`,u=`:scope > input[data-wui-mirror]`,d=[`nodes`,`selection`,`selected`,`values`,`loadChildren`,`loadUrl`,`name`],f=0;function p(e,t,n){let r=document.createElement(e);t&&(r.className=t);for(let[e,t]of Object.entries(n??{}))t!=null&&r.setAttribute(e,String(t));return r}var m=class extends e{static get observedAttributes(){return[`selection`,`selected`,`name`,`aria-label`,`loading-text`,`error-text`]}constructor(){super(),this._uid=`wui-tree-${++f}`,this._seq=0,this._roots=[],this._byId=new Map,this._prev=null,this._staged=null,this._els=new Map,this._checked=new Set,this._selected=null,this._focusId=null,this._loader=null,this._list=null,this._live=null,this._ready=!1,this._nav=a({getVisibleOptions:()=>this._visible().map(e=>this._els.get(e.id)?.row),getActive:()=>this._visible().findIndex(e=>e.id===this._focusId),setActive:e=>this._focusNode(this._visible()[e]),onEnter:()=>{let e=this._byId.get(this._focusId);e&&this._activate(e)}}),this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>this._handleClick(e),this._onFocusIn=e=>{let t=this._nodeFrom(e.target);t&&t.id!==this._focusId&&this._setRoving(t)}}connectedCallback(){let e={};for(let t of d)Object.hasOwn(this,t)&&(e[t]=this[t],delete this[t]);if(!this._ready){this._ready=!0;let e=this._readScript();this.replaceChildren(),this._list=p(`ul`,`wui-tree`),this._list.setAttribute(`role`,`tree`),this._live=p(`div`,`visually-hidden`,{role:`status`,"aria-live":`polite`}),this.append(this._list,this._live),e&&this._adoptAll(e)}for(let[t,n]of Object.entries(e))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._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 o.includes(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`)??c}set loadingText(e){this.setAttribute(`loading-text`,String(e??``))}get errorText(){return this.getAttribute(`error-text`)??l}set errorText(e){this.setAttribute(`error-text`,String(e??``))}_readScript(){let e=this.querySelector(`:scope > script[type='application/json']`);if(!e)return null;try{return JSON.parse(e.textContent)}catch(e){return console.error(`[@webority/ui-elements] <wui-tree> could not read its JSON nodes:`,e?.message),null}}_adoptAll(e){let t=this._byId;this._prev=t,this._byId=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=>{let r=e?.id==null?``:String(e.id);if(!r)throw Error(`<wui-tree> every node needs an id.`);if(this._byId.has(r))throw Error(`<wui-tree> node id "${r}" is used twice.`);let i=this._prev?.get(r),a={id:r,raw:e,parent:t,level:n,seq:++this._seq,label:e.label==null?r: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:i?i.expanded:!!e.expanded,loading:!1,failed:!1};this._byId.set(r,a),this._staged.ids.push(r);let o=e.children??(e.hasChildren?i?.children?.map(e=>e.raw):void 0);return Array.isArray(o)&&(a.children=this._adopt(o,a,n+1)),a.loading=!!i?.loading&&a.children===null&&a.hasChildren,e.checked&&!i&&this._staged.checks.push(r),a})}_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(){let e=[],t=n=>{for(let r of n)e.push(r),r.expanded&&r.children&&t(r.children)};return t(this._roots),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){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._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)}_focusNode(e){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(``);return}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?.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 r=new URL(t,window.location.href);r.searchParams.set(s,e.id);let i=await n(r.href,{headers:{Accept:`application/json`}});if(!i.ok)throw Error(`Loading children answered ${i.kind}.`);return JSON.parse(i.html)}_handleClick(e){let t=this._nodeFrom(e.target);!t||t.disabled||(this._focusNode(t),e.target.closest(`.wui-tree-toggle`)?this._toggleExpand(t):e.target.closest(`.wui-tree-check`)?(e.preventDefault(),this._toggleCheck(t)):this._activate(t))}_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))if(e.key===`ArrowRight`){if(e.preventDefault(),!this._isBranch(t)||t.disabled)return;t.expanded?t.children?.length&&this._focusNode(t.children[0]):this._expand(t)}else e.key===`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(u))e.remove()}_render(){if(!this._list)return;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),this._els=new Map;let r=this.getAttribute(`aria-label`);r?this._list.setAttribute(`aria-label`,r):this._list.removeAttribute(`aria-label`),this._list.replaceChildren(...this._buildLevel(this._roots)),t&&this._focusId&&this._els.get(this._focusId)?.li.focus(),this._syncForm()}_buildLevel(e){return e.map((t,n)=>this._buildItem(t,n+1,e.length))}_buildItem(e,n,r){let i=this.selection,a=this._isBranch(e),o=this._state(e),s=p(`li`,`wui-tree-item`,{role:`treeitem`,tabindex:e.id===this._focusId?0:-1,"aria-level":e.level,"aria-setsize":r,"aria-posinset":n,"aria-labelledby":`${this._uid}-${e.seq}`,"aria-describedby":e.badge?`${this._uid}-${e.seq}-badge`:null});a&&s.setAttribute(`aria-expanded`,String(e.expanded)),e.disabled&&s.setAttribute(`aria-disabled`,`true`),e.loading&&s.setAttribute(`aria-busy`,`true`),i===`single`&&s.setAttribute(`aria-selected`,String(e.id===this._selected)),i===`multiple`&&s.setAttribute(`aria-checked`,o===`mixed`?`mixed`:String(o===`checked`));let c=p(`div`,`wui-tree-row`,{role:`presentation`});c.style.setProperty(`--wui-tree-level`,String(e.level-1)),i===`single`&&e.id===this._selected&&c.classList.add(`wui-tree-row-selected`),e.failed&&c.classList.add(`wui-tree-row-error`);let l=p(`span`,a?`wui-tree-toggle`:`wui-tree-toggle wui-tree-toggle-leaf`,{"aria-hidden":`true`});if(a&&(l.innerHTML=t(`chevron-right`,{size:16})),c.append(l),i===`multiple`){let t=p(`input`,`form-check-input wui-tree-check`,{type:`checkbox`,tabindex:-1,"aria-hidden":`true`});t.checked=o===`checked`,t.indeterminate=o===`mixed`,t.disabled=e.disabled,t.addEventListener(`mousedown`,e=>e.preventDefault()),c.append(t)}if(e.icon){let n=p(`span`,`wui-tree-icon`,{"aria-hidden":`true`});n.innerHTML=t(e.icon,{size:16}),c.append(n)}let u=p(`span`,`wui-tree-label`,{id:`${this._uid}-${e.seq}`});if(u.textContent=e.label,c.append(u),e.badge){let t=p(`span`,`badge wui-tree-badge${e.badgeTone&&e.badgeTone!==`neutral`?` badge-${e.badgeTone}`:``}`,{id:`${this._uid}-${e.seq}-badge`});t.textContent=e.badge,c.append(t)}if(e.loading&&c.append(p(`span`,`wui-tree-spinner`,{"aria-hidden":`true`})),s.append(c),e.expanded&&e.children?.length){let t=p(`ul`,`wui-tree-group`,{role:`group`});t.append(...this._buildLevel(e.children)),s.append(t)}return this._els.set(e.id,{li:s,row:c}),s}};export{m as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-BlsR4tqa.js";import{t}from"./iconGlyphs.g-CUm_mfze.js";var n=`wui-wizard-step`,r=`:scope > [data-wui-glyphs]`,i=class extends e{static get observedAttributes(){return[`active`,`variant`,`orientation`,`icon-size`,`non-linear`,`hide-stepper`,`hide-connectors`,`disabled`,`skippable`,`label`,`back-label`,`next-label`,`skip-label`,`finish-label`]}constructor(){super(),this._active=0,this._skipped=new Set,this._invalid=new Set,this._finished=!1,this._rendered=!1,this._reflecting=!1,this._beforeNext=null,this._header=null,this._footer=null,this._known=[],this._observer=null,this._glyphs=null,this._glyphObserver=null}get active(){return this._active}set active(e){let t=Number.parseInt(e,10);Number.isFinite(t)&&this._go(t,`set`)}get beforeNext(){return this._beforeNext}set beforeNext(e){this._beforeNext=typeof e==`function`?e:null}get _steps(){return[...this.querySelectorAll(`:scope > ${n}`)]}refresh(){this._rendered&&this._renderChrome()}connectedCallback(){if(this._rendered)this._wire(),this._onStepsMutated();else{let e=Number.parseInt(this.getAttribute(`active`),10);this._active=Number.isFinite(e)&&e>=0?e:0,this.render()}}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){if(!(!this._rendered||this._reflecting)){if(e===`active`){let e=Number.parseInt(n,10);Number.isFinite(e)&&this._go(e,`set`);return}this._renderChrome()}}render(){let e=this._steps;this._header||(this._header=document.createElement(`nav`),this._header.className=`stepper wizard-stepper`,this._footer=document.createElement(`div`),this._footer.className=`form-actions wizard-footer form-actions-between`,e.length?(this.insertBefore(this._header,e[0]),e[e.length-1].after(this._footer)):(this.prepend(this._header),this.append(this._footer))),this._known=e,this._renderChrome(),this._rendered=!0,this._wire()}_renderChrome(){let e=this._reconcileSteps();this._placeChrome(e),this._clampActive(e),this._syncPanels(e),this._header.innerHTML=this._headerHtml(e),this._footer.innerHTML=this._footerHtml(e),this._header.hidden=this.hasAttribute(`hide-stepper`)}_clampActive(e){let t=Math.max(0,e.length-1);this._active>t&&(this._active=t),this._active<0&&(this._active=0)}_reconcileSteps(){let e=this._steps,t=this._known;if(this._known=e,a(e,t))return e;let n=n=>new Set([...n].map(n=>e.indexOf(t[n])).filter(e=>e>=0));this._skipped=n(this._skipped),this._invalid=n(this._invalid);let r=t[this._active];if(!r)return e;let i=e.indexOf(r);if(i<0){let n=t=>e.includes(t),r=t.slice(this._active+1).find(n)??t.slice(0,this._active).reverse().find(n);i=r?e.indexOf(r):this._active}return i=Math.min(i,Math.max(0,e.length-1)),i!==this._active&&(this._active=i,this._reflectActive(i)),e}_placeChrome(e){if(!e.length)return;let t=e[e.length-1];this._header.nextElementSibling!==e[0]&&this.insertBefore(this._header,e[0]),this._footer.previousElementSibling!==t&&t.after(this._footer)}_onStepsMutated(){if(!this._rendered)return;let e=this._steps,t=!e.length||this._header.nextElementSibling===e[0]&&this._footer.previousElementSibling===e[e.length-1];this.querySelector(r)!==this._glyphs&&(this._watchGlyphs(),this._renderHeader()),!(t&&a(e,this._known))&&(this._renderChrome(),this._observer?.takeRecords())}_syncPanels(e){e.forEach((e,t)=>{let n=t===this._active;e.classList.add(`wizard-panel`),e.hidden=!n,e.setAttribute(`role`,`tabpanel`),e.setAttribute(`aria-hidden`,n?`false`:`true`)})}_stepStatus(e,t){return e.getAttribute(`status`)||(this._invalid.has(t)?`error`:this._finished?`done`:t===this._active?`active`:t<this._active?this._skipped.has(t)?`skipped`:`done`:`pending`)}_headerHtml(e){let t=this.getAttribute(`variant`)===`journey`,n=this.getAttribute(`variant`)===`icons`,r=this.getAttribute(`orientation`)===`vertical`,i=!this.hasAttribute(`hide-connectors`);this._header.className=[`stepper`,`wizard-stepper`,t&&`stepper-journey`,n&&`stepper-icons`,r&&`stepper-vertical`,!i&&`wui-stepper-no-connectors`].filter(Boolean).join(` `),this._header.setAttribute(`aria-label`,this.getAttribute(`label`)||`Progress`);let a=this.hasAttribute(`non-linear`);return e.map((r,s)=>{let c=this._stepStatus(r,s),l=r.getAttribute(`label`)||``,u=r.getAttribute(`description`)||``,d=r.getAttribute(`icon`)||``,f=s+1,p;p=c===`done`?this._glyph(`check`):c===`error`?this._glyph(`alert-triangle`):c===`skipped`?this._glyph(`minus`):d?this._glyph(d):String(f);let m=c===`pending`?`step`:`step ${c}`,h=c===`active`?` aria-current="step"`:``,g=a||s<this._active,_=u?`<span class="step-desc">${o(u)}</span>`:``,v;v=t?`<span class="step-circle">${p}</span><span class="step-text"><span class="step-index">Step ${f}</span><span class="step-label">${o(l)}</span>${_}</span>`:n?`<span class="step-circle">${p}</span><span class="step-index">Step ${f}</span><span class="step-label">${o(l)}</span>${_}`:`<span class="step-circle">${p}</span><span class="step-label">${o(l)}</span>${_}`;let y=g?`<button type="button" class="${m}" data-step="${s}"${h}>${v}</button>`:`<div class="${m}"${h}>${v}</div>`;return t&&i&&s<e.length-1?`${y}<span class="step-line${c===`done`?` done`:``}" aria-hidden="true"></span>`:y}).join(``)}_footerHtml(e){let n=this._active,r=e.length-1,i=this.hasAttribute(`disabled`)?` disabled`:``,a=e[n]?.hasAttribute(`optional`)||this.hasAttribute(`skippable`),s=this.getAttribute(`back-label`)||`Back`,c=this.getAttribute(`next-label`)||`Next`,l=this.getAttribute(`skip-label`)||`Skip`,u=this.getAttribute(`finish-label`)||`Finish`;return`${n>0?`<button type="button" class="btn btn-secondary" data-nav="back"${i}>${t(`arrow-left`,{className:`me-2`})}${o(s)}</button>`:`<span></span>`}<span class="wizard-footer-actions">${a&&n<r?`<button type="button" class="btn btn-neutral" data-nav="skip"${i}>${o(l)}</button>`:``}${n<r?`<button type="button" class="btn btn-primary" data-nav="next"${i}>${o(c)}${t(`arrow-right`,{className:`ms-2`})}</button>`:`<button type="button" class="btn btn-primary" data-nav="finish"${i}>${o(u)}</button>`}</span>`}_wire(){this._teardown(),this._onHeaderClick=e=>{let t=e.target.closest(`[data-step]`);t&&this.contains(t)&&this._stepTo(Number.parseInt(t.dataset.step,10))},this._onFooterClick=e=>{let t=e.target.closest(`[data-nav]`);if(!t||!this.contains(t)||this.hasAttribute(`disabled`))return;let n=t.dataset.nav;n===`back`?this._back():n===`skip`?this._skip():(n===`next`||n===`finish`)&&this._next()},this._header.addEventListener(`click`,this._onHeaderClick),this._footer.addEventListener(`click`,this._onFooterClick),this._observer=new MutationObserver(()=>this._onStepsMutated()),this._observer.observe(this,{childList:!0}),this._watchGlyphs()}_glyph(e){let n=this.querySelector(r),i=n&&[...n.children].find(t=>t.getAttribute(`data-icon`)===e);if(i)return i.outerHTML;let a=Number.parseInt(this.getAttribute(`icon-size`),10);return t(e,a>0?{size:a}:void 0)}_watchGlyphs(){this._glyphObserver?.disconnect(),this._glyphObserver=null,this._glyphs=this.querySelector(r),this._glyphs&&(this._glyphObserver=new MutationObserver(()=>this._renderHeader()),this._glyphObserver.observe(this._glyphs,{childList:!0,subtree:!0,attributes:!0,characterData:!0}))}_renderHeader(){this._rendered&&(this._header.innerHTML=this._headerHtml(this._steps))}_teardown(){this._header&&this._onHeaderClick&&this._header.removeEventListener(`click`,this._onHeaderClick),this._footer&&this._onFooterClick&&this._footer.removeEventListener(`click`,this._onFooterClick),this._observer?.disconnect(),this._observer=null,this._glyphObserver?.disconnect(),this._glyphObserver=null}_stepTo(e){this.hasAttribute(`disabled`)||!this.hasAttribute(`non-linear`)&&e>=this._active||this._go(e,`step`)}_back(){this._active>0&&this._go(this._active-1,`back`)}async _next(){this._reconcileSteps();let e=this._active,t=this._steps,n=e>=t.length-1,r=t[e];if(!this.dispatchEvent(new CustomEvent(`wui-wizard:beforechange`,{detail:n?{index:e,next:e,reason:`finish`}:{index:e,next:e+1,reason:`next`},cancelable:!0})))return this._flagInvalid(e);if(this._beforeNext){let i;try{i=await this._beforeNext(e)}catch{i=!1}if(this._reconcileSteps(),t=this._steps,e=t.indexOf(r),e<0)return;if(n=e>=t.length-1,i===!1)return this._flagInvalid(e)}if(this._invalid.delete(e),this._skipped.delete(e),n)return this._finish();this._go(e+1,`next`)}_skip(){let e=this._active,t=this._steps;if(!(!t[e]?.hasAttribute(`optional`)&&!this.hasAttribute(`skippable`))){if(this._invalid.delete(e),this._skipped.add(e),this.dispatchEvent(new CustomEvent(`wui-wizard:skip`,{detail:{index:e}})),e>=t.length-1)return this._finish();this._go(e+1,`skip`)}}_flagInvalid(e){this._invalid.add(e),this._renderChrome(),this.dispatchEvent(new CustomEvent(`wui-wizard:invalid`,{detail:{index:e}}))}_finish(){this._invalid.delete(this._active),this._finished=!0,this._renderChrome(),this.dispatchEvent(new CustomEvent(`wui-wizard:finish`,{detail:{index:this._active}}))}_go(e,t){let n=this._reconcileSteps(),r=Math.max(0,n.length-1),i=Math.min(Math.max(e,0),r),a=this._active;this._finished=!1,this._invalid.delete(a),this._active=i,this._reflectActive(i),this._renderChrome(),t!==`silent`&&i!==a&&this.dispatchEvent(new CustomEvent(`wui-wizard:change`,{detail:{index:i,previous:a,reason:t}}))}_reflectActive(e){this._reflecting=!0,this.setAttribute(`active`,String(e)),this._reflecting=!1}},a=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),o=e=>String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),s=class extends e{static get observedAttributes(){return[`label`,`description`,`optional`,`icon`,`status`]}attributeChangedCallback(){let e=this.closest(`wui-wizard`);e&&typeof e.refresh==`function`&&e.refresh()}};export{i as n,s as t};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./fileViewerUi-DAWY2fNB.js";var r=[.1,.25,.5,.75,1,1.5,2,3,4],i=[.25,.5,1,2,4],a=16,o=5,s=class{constructor(e,t){this.shell=e,this.source=t,this.zoom=`fit`,this.rotation=0,this.area={width:0,height:0},this.destroyed=!1}load(){let e=document.createElement(`img`);e.className=`wui-file-viewer-image`,e.alt=this.shell.name(),e.decoding=`async`,e.draggable=!1,e.addEventListener(`load`,()=>{this.destroyed||(this.natural={width:e.naturalWidth||300,height:e.naturalHeight||150},this._build(e),this.shell.loaded({kind:`image`,pages:1}))}),e.addEventListener(`error`,()=>{this.destroyed||this.shell.fail(Error(`The image could not be decoded.`))}),e.src=this.source.src,this.img=e}destroy(){this.destroyed=!0,this._resizeObserver?.disconnect(),this._onKeyDown&&this.shell.host.removeEventListener(`keydown`,this._onKeyDown),this._printFrame?.remove(),this.img?.removeAttribute(`src`)}_build(e){let{center:r,end:a,body:o,host:s}=this.shell;this.zoomOutButton=n(`zoom-out`,`Zoom out`),this.zoomOutButton.addEventListener(`click`,()=>this._stepZoom(-1)),this.zoomButton=document.createElement(`button`),this.zoomButton.type=`button`,this.zoomButton.className=`wui-file-viewer-zoom`,t(this.zoomButton,{label:`Zoom`,items:()=>[...i.map(e=>({key:String(e),label:`${Math.round(e*100)}%`,checked:this.zoom===e})),{key:`fit-divider`,divider:!0},{key:`fit`,label:`Fit`,checked:this.zoom===`fit`}],onPick:e=>this._setZoom(e===`fit`?`fit`:Number(e))}),this.zoomInButton=n(`zoom-in`,`Zoom in`),this.zoomInButton.addEventListener(`click`,()=>this._stepZoom(1));let c=n(`rotate-ccw`,`Rotate left`);c.addEventListener(`click`,()=>this._rotate(-90));let l=n(`rotate-cw`,`Rotate right`);l.addEventListener(`click`,()=>this._rotate(90));let u=document.createElement(`span`);u.className=`wui-file-viewer-divider wui-file-viewer-print`;let d=n(`printer`,`Print`,{className:`wui-file-viewer-print`});d.addEventListener(`click`,()=>this.print()),u.hidden=d.hidden=!this.shell.print(),r.append(this.zoomOutButton,this.zoomButton,this.zoomInButton),a.prepend(c,l,u,d),this.scroller=document.createElement(`div`),this.scroller.className=`wui-file-viewer-scroll wui-file-viewer-image-scroll wui-scroll`,this.scroller.tabIndex=0,this.scroller.setAttribute(`role`,`region`),this.scroller.setAttribute(`aria-label`,`Image`),this.stage=document.createElement(`div`),this.stage.className=`wui-file-viewer-image-stage`,this.stage.append(e),this.scroller.append(this.stage),o.replaceChildren(this.scroller),this.scroller.addEventListener(`pointerdown`,e=>this._panStart(e)),this.scroller.addEventListener(`pointermove`,e=>this._panMove(e));for(let e of[`pointerup`,`pointercancel`,`lostpointercapture`])this.scroller.addEventListener(e,()=>this._panEnd());this.scroller.addEventListener(`wheel`,e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let t=performance.now();t-(this._lastWheelZoom??0)<120||(this._lastWheelZoom=t,this._stepZoom(e.deltaY<0?1:-1))},{passive:!1}),this._onKeyDown=e=>this._keyDown(e),s.addEventListener(`keydown`,this._onKeyDown),this._resizeObserver=new ResizeObserver(()=>{let e=this.scroller.clientWidth,t=this.scroller.clientHeight;e===this.area.width&&t===this.area.height||(this.area={width:e,height:t},this._layout())}),this._resizeObserver.observe(this.scroller),this.area={width:this.scroller.clientWidth,height:this.scroller.clientHeight},this._layout()}_turned(){let{width:e,height:t}=this.natural;return this.rotation%180==0?{width:e,height:t}:{width:t,height:e}}scale(){if(typeof this.zoom==`number`)return this.zoom;let{width:e,height:t}=this._turned(),n=Math.min((this.area.width-2*a)/e,(this.area.height-2*a)/t);return Math.max(n,.01)}_layout(){if(!this.stage)return;let t=this.scale(),n=this._turned();this.stage.style.width=`${Math.round(n.width*t)}px`,this.stage.style.height=`${Math.round(n.height*t)}px`,this.img.style.width=`${Math.round(this.natural.width*t)}px`,this.img.style.height=`${Math.round(this.natural.height*t)}px`,this.img.style.transform=`translate(-50%, -50%) rotate(${this.rotation}deg)`;let r=Math.round(t*100);this.zoomButton.innerHTML=`${r}%${e(`chevron-down`,{size:12})}`,this.zoomButton.setAttribute(`aria-label`,`Zoom, ${r}%`),this.zoomOutButton.disabled=this._zoomStep(-1)==null,this.zoomInButton.disabled=this._zoomStep(1)==null}_zoomStep(e){let t=this.scale();return e>0?r.find(e=>e>t+.001)??null:[...r].reverse().find(e=>e<t-.001)??null}_stepZoom(e){let t=this._zoomStep(e);t!=null&&this._setZoom(t)}_setZoom(e){let t=this.scroller,n=(t.scrollLeft+t.clientWidth/2)/Math.max(t.scrollWidth,1),r=(t.scrollTop+t.clientHeight/2)/Math.max(t.scrollHeight,1);this.zoom=e,this._layout(),t.scrollLeft=n*t.scrollWidth-t.clientWidth/2,t.scrollTop=r*t.scrollHeight-t.clientHeight/2}_rotate(e){this.rotation=(this.rotation+e+360)%360,this._setZoom(this.zoom)}_keyDown(e){if(!(e.defaultPrevented||e.altKey||!(e.ctrlKey||e.metaKey))){if(e.key===`+`||e.key===`=`)this._stepZoom(1);else if(e.key===`-`||e.key===`_`)this._stepZoom(-1);else if(e.key===`0`)this._setZoom(`fit`);else return;e.preventDefault()}}_panStart(e){let t=this.scroller;e.button!==0||t.scrollWidth<=t.clientWidth&&t.scrollHeight<=t.clientHeight||(this._pan={id:e.pointerId,x:e.clientX,y:e.clientY,left:t.scrollLeft,top:t.scrollTop,active:!1})}_panMove(e){let t=this._pan;if(!t)return;let n=e.clientX-t.x,r=e.clientY-t.y;if(!t.active){if(Math.abs(n)<o&&Math.abs(r)<o)return;t.active=!0,this.scroller.setPointerCapture(t.id),this.scroller.classList.add(`wui-file-viewer-panning`)}this.scroller.scrollLeft=t.left-n,this.scroller.scrollTop=t.top-r}_panEnd(){let e=this._pan;e?.active&&(this.scroller.hasPointerCapture(e.id)&&this.scroller.releasePointerCapture(e.id),this.scroller.classList.remove(`wui-file-viewer-panning`)),this._pan=null}print(){this._printFrame?.remove();let e=document.createElement(`iframe`);e.className=`wui-file-viewer-print-frame`,e.title=`Image for printing`,e.tabIndex=-1,e.setAttribute(`aria-hidden`,`true`);let t=this.rotation%180!=0,n=new URL(this.source.src,document.baseURI).href,r=t?`max-width: 100vh; max-height: 100vw;`:`max-width: 100vw; max-height: 100vh;`;e.srcdoc=`<!doctype html><html><head><title>${c(this.shell.name())}</title><style>
|
|
2
|
-
@page { margin: 10mm; }
|
|
3
|
-
html, body { margin: 0; height: 100%; }
|
|
4
|
-
body { display: flex; align-items: center; justify-content: center; }
|
|
5
|
-
img { ${r} transform: rotate(${this.rotation}deg); }
|
|
6
|
-
</style></head><body><img src="${c(n)}" alt=""></body></html>`,e.addEventListener(`load`,()=>{try{e.contentWindow.focus(),e.contentWindow.print()}catch(e){console.warn(`[wui-file-viewer] print failed:`,e?.message),window.open(this.source.src,`_blank`,`noopener`)}},{once:!0}),this._printFrame=e,document.body.append(e)}},c=e=>String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`);export{s as ImageView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./fileViewerUi-DAWY2fNB.js";var a=[.5,.75,1,1.25,1.5,2],o=5,s=.1;function c(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=String(t%60).padStart(2,`0`);return n?`${n}:${String(r).padStart(2,`0`)}:${i}`:`${r}:${i}`}var l=e=>e instanceof Element&&e.closest(`input, textarea, select, button, a, .dropdown-menu`),u=class{constructor(e,t){this.shell=e,this.source=t,this.destroyed=!1}load(){let{kind:e,src:t,captions:n}=this.source,r=document.createElement(e);if(r.className=`wui-file-viewer-${e}`,r.preload=`metadata`,r.playsInline=!0,e===`video`&&n){let e=document.createElement(`track`);e.kind=`captions`,e.label=`Captions`,e.srclang=`en`,e.src=n,r.append(e)}let i=this.shell.prefs;typeof i.volume==`number`&&(r.volume=Math.min(Math.max(i.volume,0),1)),r.muted=i.muted===!0,r.addEventListener(`loadedmetadata`,()=>{this.destroyed||(r.playbackRate=a.includes(i.speed)?i.speed:1,this._build(),this.shell.loaded({kind:e,pages:1}))},{once:!0}),r.addEventListener(`error`,()=>{this.destroyed||this.shell.fail(Error(`The file could not be played.`))}),r.src=t,this.media=r}destroy(){this.destroyed=!0,this._onKeyDown&&this.shell.host.removeEventListener(`keydown`,this._onKeyDown),this.media&&(this.media.pause(),this.media.removeAttribute(`src`),this.media.load())}_build(){let{body:t,host:r}=this.shell,o=this.media,s=this.source.kind,c=document.createElement(`div`);c.className=`wui-file-viewer-player wui-file-viewer-player-${s}`;let l=document.createElement(`div`);if(l.className=`wui-file-viewer-stage`,l.tabIndex=0,l.setAttribute(`role`,`group`),l.setAttribute(`aria-label`,s===`video`?`Video`:`Audio`),s===`audio`){let t=document.createElement(`div`);t.className=`wui-file-viewer-audio-art`,t.innerHTML=e(`music`,{size:40}),l.append(t,o)}else l.append(o),o.addEventListener(`click`,()=>this.togglePlay());let u=document.createElement(`div`);u.className=`wui-file-viewer-controls`,this.playButton=i(`play`,`Play`,{size:18}),this.playButton.addEventListener(`click`,()=>this.togglePlay()),this.timeNow=document.createElement(`span`),this.timeNow.className=`wui-file-viewer-time`,this.seek=document.createElement(`input`),this.seek.type=`range`,this.seek.className=`form-range wui-file-viewer-seek`,this.seek.min=`0`,this.seek.step=`any`,this.seek.setAttribute(`aria-label`,`Seek`),this.seek.addEventListener(`input`,()=>{o.currentTime=Number(this.seek.value)}),this.timeTotal=document.createElement(`span`),this.timeTotal.className=`wui-file-viewer-time`,this.muteButton=i(`volume-high`,`Mute`,{size:18}),this.muteButton.addEventListener(`click`,()=>this._setMuted(!o.muted)),this.volume=document.createElement(`input`),this.volume.type=`range`,this.volume.className=`form-range wui-file-viewer-volume`,this.volume.min=`0`,this.volume.max=`1`,this.volume.step=`0.05`,this.volume.setAttribute(`aria-label`,`Volume`),this.volume.addEventListener(`input`,()=>this._setVolume(Number(this.volume.value))),this.speedButton=document.createElement(`button`),this.speedButton.type=`button`,this.speedButton.className=`wui-file-viewer-zoom wui-file-viewer-speed`,n(this.speedButton,{label:`Playback speed`,items:()=>a.map(e=>({key:String(e),label:`${e}x`,checked:o.playbackRate===e})),onPick:e=>this._setSpeed(Number(e))}),u.append(this.playButton,this.timeNow,this.seek,this.timeTotal,this.muteButton,this.volume,this.speedButton),s===`video`&&this.source.captions&&(this.captionsButton=i(`subtitle`,`Show captions`,{size:18}),this.captionsButton.addEventListener(`click`,()=>this._setCaptions(!this._captionsOn())),u.append(this.captionsButton)),c.append(l,u),t.replaceChildren(c);for(let e of[`play`,`pause`,`ended`])o.addEventListener(e,()=>this._syncPlay());o.addEventListener(`timeupdate`,()=>this._syncTime()),o.addEventListener(`durationchange`,()=>this._syncTime()),o.addEventListener(`volumechange`,()=>this._syncVolume()),o.addEventListener(`ratechange`,()=>this._syncSpeed()),this._onKeyDown=e=>this._keyDown(e),r.addEventListener(`keydown`,this._onKeyDown),this._syncPlay(),this._syncTime(),this._syncVolume(),this._syncSpeed(),this._syncCaptions()}seekTo(e){let t=this.media.duration;this.media.currentTime=Math.min(Math.max(e,0),Number.isFinite(t)?t:1/0)}togglePlay(){this.media.paused||this.media.ended?this.media.play().catch(e=>{console.warn(`[wui-file-viewer] play refused:`,e?.message)}):this.media.pause()}_setMuted(e){this.media.muted=e,!e&&this.media.volume===0&&(this.media.volume=.5),this.shell.savePrefs({muted:this.media.muted,volume:this.media.volume})}_setVolume(e){this.media.volume=Math.min(Math.max(e,0),1),this.media.muted=this.media.volume===0,this.shell.savePrefs({muted:this.media.muted,volume:this.media.volume})}_setSpeed(e){this.media.playbackRate=e,this.shell.savePrefs({speed:e})}_captionsOn(){return this.media.textTracks?.[0]?.mode===`showing`}_setCaptions(e){let t=this.media.textTracks?.[0];t&&(t.mode=e?`showing`:`hidden`),this._syncCaptions()}_syncPlay(){let e=!this.media.paused&&!this.media.ended;r(this.playButton,e?`pause`:`play`,18),t(this.playButton,e?`Pause`:`Play`),this.shell.host.classList.toggle(`wui-file-viewer-playing`,e)}_syncTime(){let e=this.media.currentTime,t=this.media.duration;this.timeNow.textContent=c(e),this.timeTotal.textContent=c(t),this.seek.max=String(Number.isFinite(t)?t:0),this.seek.value=String(e),this.seek.setAttribute(`aria-valuetext`,`${c(e)} of ${c(t)}`)}_syncVolume(){let e=this.media.muted||this.media.volume===0;r(this.muteButton,e?`volume-mute`:`volume-high`,18),t(this.muteButton,e?`Unmute`:`Mute`),this.volume.value=String(this.media.muted?0:this.media.volume)}_syncSpeed(){let e=`${this.media.playbackRate}x`;this.speedButton.textContent=e,this.speedButton.setAttribute(`aria-label`,`Playback speed, ${e}`)}_syncCaptions(){if(!this.captionsButton)return;let e=this._captionsOn();this.captionsButton.setAttribute(`aria-pressed`,String(e)),t(this.captionsButton,e?`Hide captions`:`Show captions`)}_keyDown(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||l(e.target))return;let t=this.media,n=e.key.toLowerCase();if(n===` `||n===`k`)this.togglePlay();else if(n===`arrowleft`)t.currentTime=Math.max(0,t.currentTime-o);else if(n===`arrowright`)t.currentTime=Math.min(t.duration||0,t.currentTime+o);else if(n===`arrowup`)this._setVolume(t.volume+s);else if(n===`arrowdown`)this._setVolume(t.volume-s);else if(n===`m`)this._setMuted(!t.muted);else if(n===`c`&&this.captionsButton)this._setCaptions(!this._captionsOn());else return;e.preventDefault()}};export{u as MediaView};
|