@webority/ui-elements 0.37.0 → 0.39.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-Comrnbmf.js +13 -0
- package/dist/WuiCommandPalette-CKna1GlO.js +2 -0
- package/dist/WuiConsentBanner-CFll7vxN.js +201 -0
- package/dist/WuiContextMenu-CBy0O4HT.js +1 -0
- package/dist/WuiCountrySelect-oLBUHvMM.js +1 -0
- package/dist/WuiDatePicker-nB1B3eWW.js +31 -0
- package/dist/WuiDateRange-Di5YE9mg.js +25 -0
- package/dist/WuiDock-BD2HgMmP.js +1 -0
- package/dist/WuiImageCrop-Cr3D2iPo.js +17 -0
- package/dist/WuiMultiSelect-BUw-7apM.js +25 -0
- package/dist/WuiOtp-BbO_75RB.js +14 -0
- package/dist/WuiPhone-GJglNelp.js +15 -0
- package/dist/WuiSelect-DvtN4qC2.js +14 -0
- package/dist/WuiSlider-Br6V2amU.js +49 -0
- package/dist/WuiSortable-Bd7Fz5Ox.js +1 -0
- package/dist/WuiTagInput-DzEZooIn.js +6 -0
- package/dist/WuiTimePicker-Bolpp93P.js +9 -0
- package/dist/WuiTour-DiKZEWeb.js +15 -0
- package/dist/WuiTree-SA0QU9AF.js +1 -0
- package/dist/WuiWizardStep-DIHxrXn9.js +1 -0
- package/dist/anchorOverlay-WcDeH46q.js +1 -0
- package/dist/calendarMath-BC2wGCD-.js +1 -0
- package/dist/countries-CvmZ2xpG.js +1 -0
- package/dist/elementBase-BlsR4tqa.js +1 -0
- package/dist/elements/autocomplete.js +1 -6
- package/dist/elements/command-palette.js +1 -6
- package/dist/elements/consent-banner.js +1 -6
- package/dist/elements/context-menu.js +1 -6
- package/dist/elements/country-select.js +1 -6
- package/dist/elements/date-range.js +1 -6
- package/dist/elements/datepicker.js +1 -6
- package/dist/elements/dock.js +1 -6
- package/dist/elements/image-crop.js +1 -6
- package/dist/elements/kanban.js +1 -6
- package/dist/elements/multiselect.js +1 -6
- package/dist/elements/otp.js +1 -6
- package/dist/elements/phone.js +1 -6
- package/dist/elements/select.js +1 -6
- package/dist/elements/slider.js +1 -6
- package/dist/elements/sortable.js +1 -6
- package/dist/elements/status-icon.js +1 -6
- package/dist/elements/taginput.js +1 -6
- package/dist/elements/timepicker.js +1 -6
- package/dist/elements/tour.js +1 -6
- package/dist/elements/tree.js +1 -6
- package/dist/elements/wizard.js +1 -5
- package/dist/examples.mobile.json-GS1_MGh9.js +1 -0
- package/dist/fileViewerImage-Y9QBn2Rj.js +6 -0
- package/dist/fileViewerMedia-CaJaVnjE.js +1 -0
- package/dist/fileViewerPdf-BN0zuehw.js +19 -0
- package/dist/fileViewerUi-DasgDsU-.js +1 -0
- package/dist/focusOrigin-2imUSs-u.js +1 -0
- package/dist/formMirror-BgY7zkC3.js +1 -0
- package/dist/formatters-BAE__8ye.js +1 -0
- package/dist/helpers.js +1 -5
- package/dist/iconGlyphs.g-CUm_mfze.js +1 -0
- package/dist/kanban-CdELdS3U.js +1 -0
- package/dist/listboxKeyNav-DMIvs9d6.js +1 -0
- package/dist/max-CNrKnpEj.js +17 -0
- package/dist/optionLabel-DsX2fhWs.js +1 -0
- package/dist/statusIcons-2X4iGkKL.js +10 -0
- package/dist/textMatch-wdY7XLIc.js +1 -0
- package/dist/themeTransition-lkmQm8FR.js +1 -0
- package/dist/tokenCommit-BKckxgtg.js +2 -0
- package/dist/ui-calendar.global.js +1 -1
- package/dist/ui-calendar.js +1 -9905
- package/dist/ui-chart.js +21 -34563
- package/dist/ui-chat-core.js +10 -347
- package/dist/ui-chat.js +10 -1066
- package/dist/ui-elements.global.js +52 -53
- package/dist/ui-elements.js +1 -692
- package/dist/ui-file-viewer.js +1 -311
- package/dist/ui-rich-text.js +193 -16887
- package/dist/wuiHttp-BC8co934.js +1 -0
- package/package.json +5 -7
- package/dist/WuiAutocomplete-ByxnwJNQ.js +0 -283
- package/dist/WuiCommandPalette-CtZ04JxZ.js +0 -130
- package/dist/WuiConsentBanner-oVe-jxCO.js +0 -399
- package/dist/WuiContextMenu-Bx_U2X3t.js +0 -211
- package/dist/WuiCountrySelect-CUAwKnL9.js +0 -28
- package/dist/WuiDatePicker-DkNbc-z7.js +0 -325
- package/dist/WuiDateRange-BocnVO6L.js +0 -233
- package/dist/WuiDock-BSDY9g8Q.js +0 -57
- package/dist/WuiImageCrop-1yaAONTk.js +0 -462
- package/dist/WuiMultiSelect-BrCGRNCt.js +0 -416
- package/dist/WuiOtp-D8-4Pqil.js +0 -128
- package/dist/WuiPhone-BvbhiP2r.js +0 -731
- package/dist/WuiSelect-BXrpiuXG.js +0 -214
- package/dist/WuiSlider-BcU0psYf.js +0 -256
- package/dist/WuiSortable-JjJqstSU.js +0 -280
- package/dist/WuiTagInput-D1ay3OcL.js +0 -158
- package/dist/WuiTimePicker-C7n-VFGt.js +0 -370
- package/dist/WuiTour-R5O9l--J.js +0 -205
- package/dist/WuiTree-DXP7pGeI.js +0 -393
- package/dist/WuiWizardStep-BU5w9_Ds.js +0 -221
- package/dist/anchorOverlay-DluGZ8ef.js +0 -23
- package/dist/calendarMath-BAF2Jkg_.js +0 -42
- package/dist/countries-B-M_LTgS.js +0 -1234
- package/dist/elementBase-Bg1xpvup.js +0 -9
- package/dist/examples.mobile.json-BMXTGiGC.js +0 -250
- package/dist/fileViewerImage-Dky4nQZS.js +0 -185
- package/dist/fileViewerMedia-DPk_YcvC.js +0 -133
- package/dist/fileViewerPdf-BnIsj-J-.js +0 -15799
- package/dist/fileViewerUi-R6hlcShk.js +0 -272
- package/dist/formMirror-jGf5M4gk.js +0 -29
- package/dist/formatters-DusKbTyV.js +0 -138
- package/dist/iconGlyphs.g-Cpg1BUHm.js +0 -215
- package/dist/kanban-BIiEMkTK.js +0 -985
- package/dist/listboxKeyNav-zts_8d5e.js +0 -36
- package/dist/max-BDKx469G.js +0 -14478
- package/dist/optionLabel-Dn-I7zyp.js +0 -16
- package/dist/statusIcons-C3zjycpa.js +0 -37
- package/dist/textMatch-DEUjlkdy.js +0 -27
- package/dist/themeTransition-BpCuMnjk.js +0 -589
- package/dist/tokenCommit-VWz-2jEf.js +0 -20
- package/dist/wuiHttp-oeHs7X_c.js +0 -118
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-WcDeH46q.js";import{t as i}from"./formMirror-BgY7zkC3.js";import{t as a}from"./iconGlyphs.g-CUm_mfze.js";import{n as o,t as s}from"./listboxKeyNav-DMIvs9d6.js";import{n as c,r as l,t as u}from"./optionLabel-DsX2fhWs.js";var d=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`placeholder`,`search-placeholder`,`searchable`,`disabled`,`compact`,`size`,`clearable`,`icon`,`prefix`,`aria-label`,`aria-invalid`]}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._active=-1,this._typeahead=``,this._typeaheadTimer=null}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`value`){this.value=n;return}if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e==null?``:String(e),i(this,this._value),this._syncSelected(),this._syncReset()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.isConnected&&this.render()}get options(){return this._readOptions()}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>({value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[u]:!0,selected:e.hasAttribute(`selected`)})))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``),this._snapshotDeclared();let e=this._readOptions(),t=this.hasAttribute(`searchable`),n=this.hasAttribute(`clearable`),r=this.getAttribute(`size`),o=r===`sm`?` search-select-sm`:r===`lg`?` search-select-lg`:``,s=this.getAttribute(`icon`),u=this.getAttribute(`prefix`),d=this.getAttribute(`placeholder`)||`Select...`,p=this.getAttribute(`search-placeholder`)||`Search...`,m=e.find(e=>String(e.value)===String(this._value))||e.find(e=>e.selected);m&&(this._value=String(m.value)),i(this,this._value),this.id||=`wui-select-${Math.random().toString(36).slice(2,9)}`;let h=`${this.id}-listbox`;this._listboxId=h;let g=e.map((e,t)=>{let n=String(e.value)===String(this._value);return`<button type="button" role="option" id="${f(`${h}-opt-${t}`)}" class="search-select-option${n?` selected`:``}" data-value="${f(e.value)}" aria-selected="${n}">${l(e)}</button>`}).join(``);this.innerHTML=`
|
|
2
|
+
<div class="search-select${this.hasAttribute(`compact`)?` search-select-compact`:``}${o}">
|
|
3
|
+
<button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-controls="${f(h)}" aria-label="${f(this._accessibleName())}"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}>
|
|
4
|
+
${s?a(s,{className:`search-select-icon`}):``}
|
|
5
|
+
${u?`<span class="search-select-prefix">${c(u)}</span>`:``}
|
|
6
|
+
<span class="${m?``:`search-select-placeholder`}" data-label>${m?l(m):c(d)}</span>
|
|
7
|
+
${n?`<span class="search-select-reset" role="button" aria-label="Clear selection" hidden>${a(`x`)}</span>`:``}
|
|
8
|
+
${a(`chevron-down`,{className:`search-select-caret`})}
|
|
9
|
+
</button>
|
|
10
|
+
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${f(h)}" tabindex="-1" hidden>
|
|
11
|
+
${t?`<div class="search-select-search">${a(`search`)}<input class="search-select-input" placeholder="${f(p)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden>${a(`x`)}</button></div>`:``}
|
|
12
|
+
<div class="search-select-options">${g}<div class="search-select-empty" hidden>No matches</div></div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>`,this._rendered=!0,i(this,this._value),this._wire(),this._syncReset()}_refs(){return{control:this.querySelector(`.search-select-control`),menu:this.querySelector(`.search-select-menu`),label:this.querySelector(`[data-label]`),reset:this.querySelector(`.search-select-reset`),search:this.querySelector(`.search-select-input`),clear:this.querySelector(`.search-select-clear`),empty:this.querySelector(`.search-select-empty`),optionsWrap:this.querySelector(`.search-select-options`)}}_optionEls(){return[...this.querySelectorAll(`.search-select-option`)]}_visible(){return this._optionEls().filter(e=>!e.hidden)}_syncSelected(){let{label:e}=this._refs(),t=this._readOptions().find(e=>String(e.value)===String(this._value));for(let e of this._optionEls()){let t=e.dataset.value===String(this._value);e.classList.toggle(`selected`,t),e.setAttribute(`aria-selected`,String(t))}e&&(e.innerHTML=t?l(t):c(this.getAttribute(`placeholder`)||`Select...`),e.classList.toggle(`search-select-placeholder`,!t))}_syncReset(){let{reset:e}=this._refs();e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._value!==``&&!this.hasAttribute(`disabled`)))}_wire(){this._teardown();let e=this._refs();if(!e.control||!e.menu)return;let i=()=>{if(this.hasAttribute(`compact`)){let t=e.control.getBoundingClientRect();e.menu.style.width=`max-content`,e.menu.style.minWidth=`${t.width}px`,e.menu.style.maxWidth=`280px`,r(e.control,e.menu)}else r(e.control,e.menu,{matchWidth:!0})},a=(t,{reveal:n=!0}={})=>{let r=this._visible();this._active=t,o(e.optionsWrap,t>=0&&r[t]||null),t>=0&&r[t]?(n&&r[t].scrollIntoView({block:`nearest`}),e.control.setAttribute(`aria-activedescendant`,r[t].id)):e.control.removeAttribute(`aria-activedescendant`)},c=t=>{let n=t.trim().toLowerCase(),r=0;for(let e of this._optionEls()){let t=!n||e.textContent.toLowerCase().includes(n);e.hidden=!t,t&&(r+=1)}e.empty&&(e.empty.hidden=r>0),e.clear&&(e.clear.hidden=!n),e.menu.hidden||i()},l=()=>!e.menu.hidden,u=()=>{l()&&i()},d=()=>{e.menu.hidden=!1,e.control.setAttribute(`aria-expanded`,`true`),e.control.classList.add(`open`),i(),t(this,u),e.search&&(e.search.value=``,c(``),e.search.focus()),a(this._optionEls().findIndex(e=>e.classList.contains(`selected`)))},f=()=>{e.menu.hidden=!0,e.control.setAttribute(`aria-expanded`,`false`),e.control.classList.remove(`open`),a(-1),n(this)},p=t=>{this.value=t.dataset.value,this.dispatchEvent(new Event(`change`,{bubbles:!0})),f(),e.control.focus()};this._navHandler=s({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>a(e),onEnter:e=>{e&&p(e)},onEscape:()=>{this._navHandler.clearTypeahead(),f(),e.control.focus()}}),e.reset?.addEventListener(`click`,t=>{t.stopPropagation(),this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),e.control.focus()}),e.control.addEventListener(`click`,()=>l()?f():d()),e.control.addEventListener(`keydown`,e=>{if(l()){this._navHandler.handler(e);return}(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d())}),e.optionsWrap.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&p(t)}),e.optionsWrap.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&!t.classList.contains(`is-active`)&&a(this._visible().indexOf(t),{reveal:!1})}),e.optionsWrap.addEventListener(`mouseleave`,()=>a(-1)),e.search?.addEventListener(`input`,()=>{c(e.search.value),a(-1)}),e.clear?.addEventListener(`click`,()=>{e.search.value=``,c(``),e.search.focus()}),e.menu.addEventListener(`keydown`,this._navHandler.handler),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{l()&&!this.contains(e.target)&&f()},document.addEventListener(`click`,this._onDocClick),l()&&t(this,u)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this),this._navHandler?.teardown()}disconnectedCallback(){this._teardown()}},f=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`);export{d as t};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import{t as e}from"./elementBase-BlsR4tqa.js";import{t}from"./formMirror-BgY7zkC3.js";var n=class extends e{static formAssociated=!0;static get observedAttributes(){return[`min`,`max`,`step`,`value`,`start`,`end`,`name`,`start-name`,`end-name`,`disabled`,`size`,`show-value`,`unit`,`aria-label`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=50,this._start=25,this._end=75,this._isDragging=!1,this._dragThumb=null,this._pointerDownListener=null,this._pointerMoveListener=null,this._pointerUpListener=null,this._thumbKeyListener=null,this._trackClickListener=null}connectedCallback(){if(!this._rendered){this.render();return}this._wire()}get value(){return this._value}set value(e){this._value=this._snapToStep(this._clamp(r(e,this._value))),this._syncValue(),this._syncMirrors()}get start(){return this._start}set start(e){this._start=Math.min(this._snapToStep(this._clamp(r(e,this._start))),this._end),this._syncValue(),this._syncMirrors()}get end(){return this._end}set end(e){this._end=Math.max(this._snapToStep(this._clamp(r(e,this._end))),this._start),this._syncValue(),this._syncMirrors()}attributeChangedCallback(e,t,n){if(e===`value`||e===`start`||e===`end`||e===`min`||e===`max`||e===`step`){this._updateFromAttribute(e),this._rendered&&(this._syncValue(),this._syncMirrors());return}this._rendered&&this.render()}formResetCallback(){this._isRange()?this._resetRange():this._resetSingle()}_updateFromAttribute(e){e===`value`?this._value=this._snapToStep(this._clamp(r(this.getAttribute(`value`),this._value))):e===`start`?this._start=this._snapToStep(this._clamp(r(this.getAttribute(`start`),this._start))):e===`end`&&(this._end=this._snapToStep(this._clamp(r(this.getAttribute(`end`),this._end))))}_isRange(){return this.hasAttribute(`range`)}_min(){return r(this.getAttribute(`min`),0)}_max(){return r(this.getAttribute(`max`),100)}_step(){return r(this.getAttribute(`step`),1)}_clamp(e){return Math.max(this._min(),Math.min(e,this._max()))}_snapToStep(e){let t=this._step();if(t<=0)return e;let n=this._min();return this._clamp(n+Math.round((e-n)/t)*t)}_captureDefaults(){this._defaultsCaptured||=(this._isRange()?(this._defaultStart=this._start,this._defaultEnd=this._end):this._defaultValue=this._value,!0)}_resetSingle(){this._value=this._defaultValue??50,this._syncValue(),this._syncMirrors()}_resetRange(){this._start=this._defaultStart??25,this._end=this._defaultEnd??75,this._syncValue(),this._syncMirrors()}render(){this._captureDefaults();let e=this._min(),t=this._max(),n=this._isRange(),r=this.getAttribute(`size`),a=r===`sm`?` slider-sm`:r===`lg`?` slider-lg`:``,o=this.hasAttribute(`disabled`);n?(this._start=this._clamp(this._start),this._end=this._clamp(this._end),this._start>this._end&&([this._start,this._end]=[this._end,this._start])):this._value=this._clamp(this._value);let s=n=>t===e?0:(n-e)/(t-e)*100,c=n?s(this._start):0,l=s(n?this._end:this._value);this.innerHTML=`
|
|
2
|
+
<div class="slider${a}">
|
|
3
|
+
<div class="slider-track" role="presentation"></div>
|
|
4
|
+
<div class="slider-fill" style="left: ${c}%; right: ${100-l}%;" role="presentation"></div>
|
|
5
|
+
${n?`
|
|
6
|
+
<button
|
|
7
|
+
type="button"
|
|
8
|
+
role="slider"
|
|
9
|
+
class="slider-thumb"
|
|
10
|
+
data-thumb="start"
|
|
11
|
+
style="left: ${c}%;"
|
|
12
|
+
aria-label="Minimum"
|
|
13
|
+
aria-valuemin="${e}"
|
|
14
|
+
aria-valuemax="${t}"
|
|
15
|
+
aria-valuenow="${this._start}"
|
|
16
|
+
aria-valuetext="${this._formatValue(this._start)}"
|
|
17
|
+
${o?`disabled`:``}
|
|
18
|
+
></button>
|
|
19
|
+
<button
|
|
20
|
+
type="button"
|
|
21
|
+
role="slider"
|
|
22
|
+
class="slider-thumb"
|
|
23
|
+
data-thumb="end"
|
|
24
|
+
style="left: ${l}%;"
|
|
25
|
+
aria-label="Maximum"
|
|
26
|
+
aria-valuemin="${e}"
|
|
27
|
+
aria-valuemax="${t}"
|
|
28
|
+
aria-valuenow="${this._end}"
|
|
29
|
+
aria-valuetext="${this._formatValue(this._end)}"
|
|
30
|
+
${o?`disabled`:``}
|
|
31
|
+
></button>
|
|
32
|
+
`:`
|
|
33
|
+
<button
|
|
34
|
+
type="button"
|
|
35
|
+
role="slider"
|
|
36
|
+
class="slider-thumb"
|
|
37
|
+
data-thumb="single"
|
|
38
|
+
style="left: ${l}%;"
|
|
39
|
+
aria-valuemin="${e}"
|
|
40
|
+
aria-valuemax="${t}"
|
|
41
|
+
aria-valuenow="${this._value}"
|
|
42
|
+
aria-valuetext="${this._formatValue(this._value)}"
|
|
43
|
+
${o?`disabled`:``}
|
|
44
|
+
aria-label="${i(this.getAttribute(`aria-label`)||`Value`)}"
|
|
45
|
+
></button>
|
|
46
|
+
`}
|
|
47
|
+
${this.hasAttribute(`show-value`)?n?`<span class="slider-value">${this._formatValue(this._start)} to ${this._formatValue(this._end)}</span>`:`<span class="slider-value">${this._formatValue(this._value)}</span>`:``}
|
|
48
|
+
</div>
|
|
49
|
+
`,this._rendered=!0,this._placeParts(),this._syncMirrors(),this._wire()}_formatValue(e){return`${e}${this.getAttribute(`unit`)||``}`}_placeParts(){let e=this._min(),t=this._max(),n=n=>t===e?0:(n-e)/(t-e),r=this._isRange(),i=r?n(this._start):0,a=n(r?this._end:this._value),o=this.querySelector(`.slider-fill`);o&&(o.style.left=`${i*100}%`,o.style.right=`${100-a*100}%`,r&&o.style.setProperty(`--wui-fill-start`,String(i)),o.style.setProperty(`--wui-fill-end`,String(a)));let s=(e,t)=>{e&&(e.style.left=`${t*100}%`,e.style.setProperty(`--wui-t`,String(t)))};r?(s(this.querySelector(`[data-thumb="start"]`),i),s(this.querySelector(`[data-thumb="end"]`),a)):s(this.querySelector(`.slider-thumb`),a)}_syncValue(){if(this._rendered)if(this._placeParts(),this._isRange()){let e=this.querySelector(`[data-thumb="start"]`),t=this.querySelector(`[data-thumb="end"]`);e&&(e.setAttribute(`aria-valuenow`,String(this._start)),e.setAttribute(`aria-valuetext`,this._formatValue(this._start))),t&&(t.setAttribute(`aria-valuenow`,String(this._end)),t.setAttribute(`aria-valuetext`,this._formatValue(this._end)));let n=this.querySelector(`.slider-value`);n&&(n.textContent=`${this._formatValue(this._start)} to ${this._formatValue(this._end)}`)}else{let e=this.querySelector(`.slider-thumb`);e&&(e.setAttribute(`aria-valuenow`,String(this._value)),e.setAttribute(`aria-valuetext`,this._formatValue(this._value)));let t=this.querySelector(`.slider-value`);t&&(t.textContent=this._formatValue(this._value))}}_syncMirrors(){this._isRange()?this._syncRangeMirrors():this._syncSingleMirror()}_syncSingleMirror(){this.getAttribute(`name`)&&t(this,String(this._value))}_syncRangeMirrors(){let e=this.getAttribute(`start-name`)||this.getAttribute(`name`),t=this.getAttribute(`end-name`);this._mirrorRange(`start`,e,this._start),this._mirrorRange(`end`,t,this._end)}_mirrorRange(e,t,n){if(!t)return;let r=this.querySelector(`input[type="hidden"][data-slider-mirror="${e}"]`);r||(r=document.createElement(`input`),r.type=`hidden`,r.setAttribute(`data-slider-mirror`,e),this.appendChild(r)),r.name=t,r.value=String(n),r.disabled=this.hasAttribute(`disabled`)}_valueAtPosition(e){let t=this.querySelector(`.slider-track`);if(!t)return this._min();let n=t.getBoundingClientRect(),r=this.querySelector(`.slider-thumb`),i=r?r.offsetWidth/2:0,a=n.width-i*2,o=a>0?Math.max(0,Math.min(1,(e-n.left-i)/a)):0,s=this._min()+o*(this._max()-this._min());return this._snapToStep(s)}_nearestThumb(e){return Math.abs(e-this._start)<=Math.abs(e-this._end)?`start`:`end`}_wire(){if(this._teardown(),this.hasAttribute(`disabled`))return;let e=this.querySelectorAll(`.slider-thumb`),t=this.querySelector(`.slider-track`),n=this._isRange();this._pointerDownListener=e=>{if(this.hasAttribute(`disabled`))return;let t=e.target.closest(`.slider-thumb`);t&&(e.preventDefault(),this._isDragging=!0,this._dragThumb=t.getAttribute(`data-thumb`),document.addEventListener(`pointermove`,this._pointerMoveListener),document.addEventListener(`pointerup`,this._pointerUpListener),document.addEventListener(`pointercancel`,this._pointerUpListener))},this._pointerMoveListener=e=>{if(!this._isDragging)return;e.preventDefault();let t=this._valueAtPosition(e.clientX);if(this._dragThumb===`single`)this._value=this._clamp(t),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{value:this._value}}));else if(this._dragThumb===`start`){let e=Math.min(t,this._end);this._start=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}else if(this._dragThumb===`end`){let e=Math.max(t,this._start);this._end=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}},this._pointerUpListener=()=>{this._isDragging&&(this._isDragging=!1,this._dragThumb=null,document.removeEventListener(`pointermove`,this._pointerMoveListener),document.removeEventListener(`pointerup`,this._pointerUpListener),document.removeEventListener(`pointercancel`,this._pointerUpListener),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},this._thumbKeyListener=e=>{let t=e.currentTarget;if(this.hasAttribute(`disabled`))return;let n=this._step(),r=n*10,i=null,a=t.getAttribute(`data-thumb`),o=a===`end`?this._end:a===`start`?this._start:this._value;e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),i=o-n):e.key===`ArrowRight`||e.key===`ArrowUp`?(e.preventDefault(),i=o+n):e.key===`PageDown`?(e.preventDefault(),i=o-r):e.key===`PageUp`?(e.preventDefault(),i=o+r):e.key===`Home`?(e.preventDefault(),i=this._min()):e.key===`End`&&(e.preventDefault(),i=this._max()),i!=null&&(i=this._clamp(i),a===`single`?this._value=i:a===`start`?this._start=Math.min(i,this._end):a===`end`&&(this._end=Math.max(i,this._start)),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},this._trackClickListener=e=>{if(this.hasAttribute(`disabled`))return;let t=this._valueAtPosition(e.clientX);n?this._nearestThumb(t)===`start`?this._start=Math.min(this._clamp(t),this._end):this._end=Math.max(this._clamp(t),this._start):this._value=this._clamp(t),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))},e.forEach(e=>{e.addEventListener(`pointerdown`,this._pointerDownListener),e.addEventListener(`keydown`,this._thumbKeyListener)}),t?.addEventListener(`click`,this._trackClickListener)}_teardown(){for(let e of this.querySelectorAll(`.slider-thumb`))e.removeEventListener(`pointerdown`,this._pointerDownListener),e.removeEventListener(`keydown`,this._thumbKeyListener);document.removeEventListener(`pointermove`,this._pointerMoveListener),document.removeEventListener(`pointerup`,this._pointerUpListener),document.removeEventListener(`pointercancel`,this._pointerUpListener),this._isDragging=!1,this._dragThumb=null,this.querySelector(`.slider-track`)?.removeEventListener(`click`,this._trackClickListener)}disconnectedCallback(){this._teardown()}},r=(e,t)=>{let n=Number.parseFloat(e);return Number.isFinite(n)?n:t},i=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t}from"./formMirror-BgY7zkC3.js";var n=new Set,r=`.wui-sortable-handle`,i=`a[href],button,input,select,textarea,label,summary,[contenteditable='true'],[role='button'],[role='link']`,a=4,o=8,s=250,c=48,l=18,u=class extends e{static get observedAttributes(){return[`name`,`disabled`]}constructor(){super(),this._drag=null,this._kb=null,this._moving=!1,this.controlled=!1,this._observer=null,this._onPointerDown=this._onPointerDown.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onDragStart=e=>e.preventDefault(),this._onDocMove=this._onDocMove.bind(this),this._onDocUp=this._onDocUp.bind(this),this._onDocCancel=this._onDocCancel.bind(this),this._onDocKey=this._onDocKey.bind(this),this._onDocTouchMove=e=>{this._drag?.started&&e.preventDefault()},this._onSelectStart=e=>e.preventDefault(),this._scrollTick=this._scrollTick.bind(this)}connectedCallback(){n.add(this),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`dragstart`,this._onDragStart),this._observer=new MutationObserver(()=>this._syncMirrors()),this._observer.observe(this,{childList:!0}),this._syncMirrors()}disconnectedCallback(){n.delete(this),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`dragstart`,this._onDragStart),this._observer?.disconnect(),this._observer=null,this._abort()}attributeChangedCallback(e){e===`disabled`&&this._abort(),this.isConnected&&this._syncMirrors()}get order(){return this._items().map(e=>e.getAttribute(`data-id`))}set order(e){if(this._drag?.started||this._kb)return;let t=this._items(),n=new Map(t.map(e=>[e.getAttribute(`data-id`),e])),r=[];for(let t of e??[]){let e=n.get(String(t));e&&!r.includes(e)&&r.push(e)}[...r,...t.filter(e=>!r.includes(e))].forEach((e,t)=>{let n=this._items()[t];n!==e&&this.insertBefore(e,n)}),this._syncMirrors()}_items(){return[...this.querySelectorAll(`:scope > [data-id]`)]}_itemFrom(e){let t=e;for(;t&&t.parentElement!==this;)t=t.parentElement;return t?.hasAttribute(`data-id`)?t:null}_itemDisabled(e){return e.hasAttribute(`data-disabled`)}_horizontal(){return this.getAttribute(`orientation`)===`horizontal`}_syncMirrors(){t(this,this.order)}_insertAt(e,t){let n=this._items();if(n.indexOf(e)===t)return;let r=n.filter(t=>t!==e),i=r[t]??null;i?this.insertBefore(e,i):r.length>0?r[r.length-1].after(e):this.appendChild(e)}_indexFor(e,t,n){let r=this._items().filter(t=>t!==e),i=this._horizontal();for(let e=0;e<r.length;e++){let a=r[e].getBoundingClientRect();if(i?n<a.top||n<=a.bottom&&t<a.left+a.width/2:n<a.top+a.height/2)return e}return r.length}_peers(){let e=this.getAttribute(`group`);return[...n].filter(t=>t===this||e&&t.getAttribute(`group`)===e&&!t.hasAttribute(`disabled`))}_labelOf(e){return e.getAttribute(`data-label`)||e.textContent.replace(/\s+/g,` `).trim()||e.getAttribute(`data-id`)}_announce(e){let t=this.querySelector(`:scope > .wui-sortable-live`);t||(t=document.createElement(`div`),t.className=`wui-sortable-live`,t.setAttribute(`role`,`status`),t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-atomic`,`true`),this.appendChild(t)),t.textContent=e}_position(e){let t=this._items();return`position ${t.indexOf(e)+1} of ${t.length}`}_onPointerDown(e){if(this._drag||this._kb||this.hasAttribute(`disabled`)||e.pointerType===`mouse`&&e.button!==0)return;let t=this._itemFrom(e.target);if(!t||this._itemDisabled(t))return;let n=t.querySelector(`:scope > ${r}`),c=!!n&&n.contains(e.target);if(this.hasAttribute(`handle`)&&!c)return;if(!c){let n=e.target.closest?.(i);if(n&&n!==t&&t.contains(n))return}let l=e.pointerType===`touch`&&!c,u={item:t,pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY,slop:e.pointerType===`touch`?o:a,ready:!l,started:!1,timer:null,raf:0,list:this,ghost:null};this._drag=u,l&&(u.timer=setTimeout(()=>{u.timer=null,u.ready=!0,this._begin()},s)),document.addEventListener(`pointermove`,this._onDocMove),document.addEventListener(`pointerup`,this._onDocUp),document.addEventListener(`pointercancel`,this._onDocCancel),document.addEventListener(`keydown`,this._onDocKey,!0),document.addEventListener(`touchmove`,this._onDocTouchMove,{passive:!1})}_onDocMove(e){let t=this._drag;if(!(!t||e.pointerId!==t.pointerId)){if(t.x=e.clientX,t.y=e.clientY,!t.started){let e=Math.hypot(t.x-t.startX,t.y-t.startY);if(!t.ready){e>t.slop&&this._finish(!0);return}if(e<t.slop||(this._begin(),!this._drag?.started))return}e.preventDefault?.(),this._moveGhost(),this._update()}}_onDocUp(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!1)}_onDocCancel(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!0)}_onDocKey(e){e.key!==`Escape`||!this._drag||(e.preventDefault(),e.stopPropagation(),this._finish(!0))}_begin(){let e=this._drag;if(!e||e.started)return;e.started=!0;let t=e.item.getBoundingClientRect();e.offsetX=e.startX-t.left,e.offsetY=e.startY-t.top,e.fromIndex=this._items().indexOf(e.item);let n=e.item.cloneNode(!0);for(let e of[n,...n.querySelectorAll(`[id],[data-id]`)])e.removeAttribute(`id`),e.removeAttribute(`data-id`);n.classList.add(`wui-sortable-ghost`),n.setAttribute(`aria-hidden`,`true`),n.inert=!0,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,e.ghost=n,e.item.classList.add(`wui-sortable-dragging`),document.body.appendChild(n),document.documentElement.classList.add(`wui-sortable-active`),document.addEventListener(`selectstart`,this._onSelectStart),this._moveGhost(),e.raf=requestAnimationFrame(this._scrollTick),this._emit(this,`wui-sortable:start`,{id:e.item.getAttribute(`data-id`)})}_moveGhost(){let e=this._drag;e?.ghost&&(e.ghost.style.transform=`translate(${e.x-e.offsetX}px, ${e.y-e.offsetY}px)`)}_update(){let e=this._drag;if(!e?.started)return;let t=e.list;for(let n of this._peers()){let r=n.getBoundingClientRect();if(e.x>=r.left&&e.x<=r.right&&e.y>=r.top&&e.y<=r.bottom){t=n;break}}let n=t._indexFor(e.item,e.x,e.y);(t!==e.list||n!==t._items().indexOf(e.item))&&t._insertAt(e.item,n),e.list=t}_scrollTick(){let e=this._drag;if(!e?.started)return;let t=f(e.list),n=t?t.getBoundingClientRect():null,r=Math.max(n?.top??0,0),i=Math.min(n?.bottom??window.innerHeight,window.innerHeight),a=Math.max(n?.left??0,0),o=Math.min(n?.right??window.innerWidth,window.innerWidth),s=d(e.y,r,i),c=d(e.x,a,o);(c||s)&&(t?(t.scrollTop+=s,t.scrollLeft+=c):window.scrollBy(c,s),this._update()),e.raf=requestAnimationFrame(this._scrollTick)}_finish(e){let t=this._drag;if(!t||(this._drag=null,clearTimeout(t.timer),cancelAnimationFrame(t.raf),document.removeEventListener(`pointermove`,this._onDocMove),document.removeEventListener(`pointerup`,this._onDocUp),document.removeEventListener(`pointercancel`,this._onDocCancel),document.removeEventListener(`keydown`,this._onDocKey,!0),document.removeEventListener(`touchmove`,this._onDocTouchMove),document.removeEventListener(`selectstart`,this._onSelectStart),!t.started))return;t.ghost?.remove(),document.documentElement.classList.remove(`wui-sortable-active`),t.item.classList.remove(`wui-sortable-dragging`);let n=t.item.getAttribute(`data-id`);e?(this._insertAt(t.item,t.fromIndex),this._syncMirrors(),t.list!==this&&t.list._syncMirrors()):this._settle(t.item,this,t.fromIndex,t.list),this._emit(this,`wui-sortable:end`,{id:n,cancelled:e})}_settle(e,t,n,r){let i=r._items().indexOf(e);if(r===t&&i===n)return;let a=e.getAttribute(`data-id`),o=r.order,s=r!==t,c=t.order;s&&(t.controlled||r.controlled)&&t._insertAt(e,n),t._syncMirrors(),r._syncMirrors();let l=r._labelOf(e),u=s&&r.getAttribute(`aria-label`)?` to ${r.getAttribute(`aria-label`)}`:``,d={id:a,fromIndex:n,toIndex:i,from:t,to:r};s&&this._emit(t,`wui-sortable:change`,{...d,ids:c}),this._emit(r,`wui-sortable:change`,{...d,ids:o}),r._announce(`${l} moved${u}, position ${i+1} of ${o.length}.`)}_emit(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))}_abort(){this._drag&&this._finish(!0),this._kb&&this._dropKeyboard(!0)}_onKeyDown(e){if(this.hasAttribute(`disabled`))return;let t=e.target.closest?.(r),n=t&&t.parentElement?.parentElement===this?t.parentElement:null;if(!n||this._itemDisabled(n)||this._drag)return;let i=e.key;if(!this._kb){if(i!==` `&&i!==`Enter`)return;e.preventDefault(),this._liftKeyboard(n,t);return}if(this._kb.item===n){if(i===` `||i===`Enter`)e.preventDefault(),this._dropKeyboard(!1);else if(i===`Escape`)e.preventDefault(),e.stopPropagation(),this._dropKeyboard(!0);else if([`ArrowUp`,`ArrowLeft`,`ArrowDown`,`ArrowRight`,`Home`,`End`].includes(i)){e.preventDefault();let r=this._items(),a=r.indexOf(n),o=r.length-1,s=i===`Home`?0:i===`End`?o:Math.max(0,Math.min(o,a+(i===`ArrowUp`||i===`ArrowLeft`?-1:1)));if(s===a){this._announce(`${this._labelOf(n)} is already ${a===0?`first`:`last`}, ${this._position(n)}.`);return}this._moveFocused(()=>this._insertAt(n,s),t),this._announce(`${this._labelOf(n)} moved to ${this._position(n)}.`)}}}_onFocusOut(e){!this._kb||this._moving||e.relatedTarget&&this._kb.handle.contains(e.relatedTarget)||this._dropKeyboard(!1)}_liftKeyboard(e,t){this._kb={item:e,handle:t,fromIndex:this._items().indexOf(e)},t.setAttribute(`aria-pressed`,`true`),this._announce(`${this._labelOf(e)} lifted, ${this._position(e)}. Use the arrow keys to move it, Space to drop it, Escape to cancel.`)}_dropKeyboard(e){let t=this._kb;if(t){if(this._kb=null,t.handle.removeAttribute(`aria-pressed`),e){this._moveFocused(()=>this._insertAt(t.item,t.fromIndex),t.handle),this._announce(`Reorder cancelled. ${this._labelOf(t.item)} is back at ${this._position(t.item)}.`);return}if(this._items().indexOf(t.item)===t.fromIndex){this._announce(`${this._labelOf(t.item)} dropped, ${this._position(t.item)}.`);return}this._settle(t.item,this,t.fromIndex,this)}}_moveFocused(e,t){this._moving=!0;let n=this.contains(document.activeElement);e(),n&&document.activeElement!==t&&t.focus(),this._moving=!1}};function d(e,t,n){return e<t+c?-Math.ceil(l*Math.min(1,(t+c-e)/c)):e>n-c?Math.ceil(l*Math.min(1,(e-(n-c))/c)):0}function f(e){for(let t=e.parentElement;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement){let e=getComputedStyle(t),n=/(auto|scroll)/.test(e.overflowY)&&t.scrollHeight>t.clientHeight,r=/(auto|scroll)/.test(e.overflowX)&&t.scrollWidth>t.clientWidth;if(n||r)return t}return null}export{u as t};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t}from"./formMirror-BgY7zkC3.js";import{t as n}from"./iconGlyphs.g-CUm_mfze.js";import{i as r,n as i,r as a,t as o}from"./tokenCommit-BKckxgtg.js";var s=class extends e{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Add tags`}static get observedAttributes(){return[`placeholder`,`disabled`,`size`,`max-tags`,`aria-label`,`separators`,`allow-duplicates`,`aria-invalid`]}constructor(){super(),this._values=[],this._draftText=``;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){if(!this._valuesInit&&!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-tag`)].map(e=>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._wire()}formResetCallback(){this.values=(this._defaultValues||[]).slice(),this._draftText=``;let e=this.querySelector(`[data-input]`);e&&(e.value=``)}attributeChangedCallback(e){if(e===`aria-invalid`){this._syncInvalid();return}if(this._rendered){if(e===`separators`||e===`allow-duplicates`){this._wire();return}this.render()}}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)?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):[],t(this,this._values),this._rendered&&this._renderControl()}render(){let e=this.getAttribute(`size`),n=e===`sm`?` search-select-sm`:e===`lg`?` search-select-lg`:``;t(this,this._values),this.innerHTML=`
|
|
2
|
+
<div class="search-select${n}">
|
|
3
|
+
<div class="input search-select-control search-select-multi"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` aria-disabled="true"`:``}>
|
|
4
|
+
<div class="ms-chips" data-chips><input type="text" class="ms-input" data-input aria-label="${l(this._accessibleName())}" placeholder="${l(this.getAttribute(`placeholder`)||`Add…`)}" autocomplete="off"${this.hasAttribute(`disabled`)?` disabled`:``}/></div>
|
|
5
|
+
</div>
|
|
6
|
+
</div>`,this._rendered=!0,t(this,this._values),this._renderControl(),this._wire()}_renderControl(){let e=this.querySelector(`[data-chips]`);if(e){for(let t of e.querySelectorAll(`:scope > .chip`))t.remove();this._values.length&&e.querySelector(`[data-input]`).insertAdjacentHTML(`beforebegin`,this._values.map(e=>`<span class="chip chip-sm"><span class="chip-label">${c(e)}</span><button type="button" class="chip-remove" data-remove="${l(e)}" aria-label="Remove ${l(e)}">${n(`x`)}</button></span>`).join(``))}}_wire(){this._teardown();let e=this.querySelector(`.search-select-control`),n=this.querySelector(`[data-input]`);if(!e||!n)return;let s=()=>this.hasAttribute(`disabled`),c=(this.getAttribute(`separators`)||`enter,comma`).split(`,`).map(e=>e.trim()),l=this.getAttribute(`max-tags`),u=this.hasAttribute(`allow-duplicates`),d=new Set(c.map(a).filter(Boolean)),f=()=>{t(this,this._values),this.dispatchEvent(new Event(`change`,{bubbles:!0}))},p=e=>{let t=e.trim();if(!t||l&&this._values.length>=parseInt(l,10))return;let n=u?t:t.toLowerCase();(!this._values.some(e=>u?e===t:e.toLowerCase()===n)||u)&&(this._values.push(t),this._renderControl(),f())},m=e=>{this._values=this._values.filter(t=>t!==e),this._renderControl(),f()},h=e=>{if(e.key===`Enter`&&d.has(`Enter`)){e.preventDefault(),p(n.value),n.value=``;return}if(e.key===`,`&&d.has(`,`)){e.preventDefault(),p(n.value.replace(/,+$/,``)),n.value=``;return}if(e.key===` `&&d.has(` `)){let t=n.value.trim();t&&(e.preventDefault(),p(t),n.value=``);return}if(e.key===`Tab`&&d.has(`Tab`)){e.preventDefault(),p(n.value),n.value=``;return}e.key===`Backspace`&&!n.value&&this._values.length&&(e.preventDefault(),m(this._values[this._values.length-1])),e.key===`Escape`&&(n.value=``)},g=e=>{e.preventDefault();let t=e.clipboardData.getData(`text/plain`),a=[];for(let e of c){let n=i(e)??e;if(o(t,[n])){a.push(...r(t,[n]));break}}a.length||a.push(t.trim());for(let e of a)if(p(e),l&&this._values.length>=parseInt(l,10))break;n.value=``};this._onControlClick=e=>{if(s())return;let t=e.target.closest(`[data-remove]`);if(t){e.stopPropagation(),m(t.dataset.remove),n.focus();return}n.focus()},this._onInputKey=h,this._onInputPaste=g,e.addEventListener(`click`,this._onControlClick),n.addEventListener(`keydown`,this._onInputKey),n.addEventListener(`paste`,this._onInputPaste),this._onDocClick=e=>{this.contains(e.target)||n.blur()},document.addEventListener(`click`,this._onDocClick)}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null);let e=this.querySelector(`.search-select-control`),t=this.querySelector(`[data-input]`);e&&this._onControlClick&&e.removeEventListener(`click`,this._onControlClick),t&&this._onInputKey&&(t.removeEventListener(`keydown`,this._onInputKey),t.removeEventListener(`paste`,this._onInputPaste))}disconnectedCallback(){this._teardown()}},c=e=>String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),l=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`);export{s as t};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-WcDeH46q.js";import{t as i}from"./formMirror-BgY7zkC3.js";import{t as a}from"./iconGlyphs.g-CUm_mfze.js";var o=e=>String(e).padStart(2,`0`),s=(e,t)=>`${o(e)}:${o(t)}`,c=e=>{let t=/^(\d{2}):(\d{2})$/.exec(e||``);return t?{h:+t[1],m:+t[2]}:null},l=(e,t=`24`)=>{if(!e)return``;if(t===`24`)return s(e.h,e.m);let n=e.h%12||12,r=e.h>=12?`PM`:`AM`;return`${n}:${o(e.m)} ${r}`},u=e=>{let t=String(e||``).trim().toLowerCase(),n=/^(\d{1,2})(?:[:.](\d{2})|(\d{2}))?\s*(?:([ap])\.?\s*(?:m\.?)?)?$/.exec(t);if(!n)return null;let r=+n[1],i=+(n[2]??n[3]??`0`);if(i>59)return null;if(n[4]){if(r<1||r>12)return null;r=r%12+(n[4]===`p`?12:0)}else if(r>23)return null;return{h:r,m:i}},d=0,f=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`step`,`format`,`placeholder`,`disabled`,`required`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._uid=`wui-tp-${++d}`,this._typedError=``,this._typeahead=``,this._typeaheadTimer=null,this.addEventListener(`focusout`,e=>{this._isOpen?.()&&e.relatedTarget&&!this.contains(e.relatedTarget)&&this._close({commit:!0})})}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(this._rendered)switch(e){case`value`:this._value=n||``,this._typedError=``,this._syncFormValue(),this._syncText(),this._syncInvalid();return;case`aria-invalid`:case`aria-describedby`:this._syncInvalid();return;case`aria-label`:case`placeholder`:case`disabled`:case`required`:this._syncAttrs();return;default:this.render()}}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,this._typedError=``,i(this,this._value),this._syncText(),this._syncInvalid()}_format(){return this.getAttribute(`format`)||`24`}_step(){return Math.max(1,parseInt(this.getAttribute(`step`)||`30`,10)||30)}_bounds(){let e=c(this.getAttribute(`min`))||{h:0,m:0},t=c(this.getAttribute(`max`))||{h:23,m:59};return{min:e.h*60+e.m,max:t.h*60+t.m}}_allowed(e,t){let n=e*60+t,{min:r,max:i}=this._bounds();return n>=r&&n<=i&&n%this._step()===0}_times(){let e=[];for(let t=0;t<1440;t+=this._step()){let n=Math.floor(t/60),r=t%60;this._allowed(n,r)&&e.push({h:n,m:r})}return e}_refusal(e){if(this._allowed(e.h,e.m))return``;let t=this._format(),{min:n,max:r}=this._bounds(),i=e.h*60+e.m,a=e=>l({h:Math.floor(e/60),m:e%60},t);if(i<n||i>r){let e=!!c(this.getAttribute(`min`)),t=!!c(this.getAttribute(`max`));return e&&t?`Enter a time between ${a(n)} and ${a(r)}.`:e?`Enter a time at or after ${a(n)}.`:`Enter a time at or before ${a(r)}.`}return`Enter a time in ${this._step()}-minute steps.`}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value),this._isOpen=null;let e=this.getAttribute(`size`),t=e===`sm`?` input-sm`:e===`lg`?` input-lg`:``,n=this._uid;this.innerHTML=`
|
|
2
|
+
<div class="timepicker">
|
|
3
|
+
<div class="wui-timepicker-field">
|
|
4
|
+
<input type="text" class="input timepicker-trigger${t}" id="${n}-input" role="combobox" aria-haspopup="dialog" aria-expanded="false" aria-controls="${n}-pop" aria-autocomplete="none" autocomplete="off" spellcheck="false">
|
|
5
|
+
<button type="button" class="wui-timepicker-toggle" tabindex="-1" aria-label="Choose time" aria-haspopup="dialog" aria-expanded="false" aria-controls="${n}-pop">${a(`clock`)}</button>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="timepicker-pop" id="${n}-pop" role="dialog" aria-label="Choose time" hidden></div>
|
|
8
|
+
<div class="field-error wui-timepicker-error" id="${n}-error" hidden></div>
|
|
9
|
+
</div>`,this._rendered=!0,this._syncAttrs(),this._syncText(),this._syncInvalid(),i(this,this._value),this._wire()}_input(){return this.querySelector(`.timepicker-trigger`)}_pop(){return this.querySelector(`.timepicker-pop`)}_syncFormValue(){i(this,this._value)}_syncAttrs(){let e=this._input(),t=this.querySelector(`.wui-timepicker-toggle`);if(!e)return;let n=this.hasAttribute(`disabled`);e.disabled=n,t&&(t.disabled=n),e.placeholder=this.getAttribute(`placeholder`)||`Select time`,this.hasAttribute(`required`)?e.setAttribute(`aria-required`,`true`):e.removeAttribute(`aria-required`);let r=this.getAttribute(`aria-label`);r?e.setAttribute(`aria-label`,r):e.removeAttribute(`aria-label`),i(this,this._value),n&&this._isOpen?.()&&this._close({commit:!1})}_syncText(){let e=this._input();e&&(e.value=l(c(this._value),this._format()),this._isOpen?.()&&this._syncColumns())}_syncInvalid(){let e=this._input(),t=this.querySelector(`.wui-timepicker-error`);if(!e||!t)return;let n=this._typedError;t.textContent=n,t.hidden=!n,this.hasAttribute(`aria-invalid`)||n?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`);let r=[this.getAttribute(`aria-describedby`),n?t.id:null].filter(Boolean).join(` `);r?e.setAttribute(`aria-describedby`,r):e.removeAttribute(`aria-describedby`),e.setCustomValidity?.(n)}_commitText(){let e=this._input();if(!e||e.value===l(c(this._value),this._format()))return!0;let t=e.value.trim(),n=``;if(t){let e=u(t),r=e?this._refusal(e):`Enter a time like ${this._format()===`12`?`7:45 PM`:`19:45`}.`;if(r)return this._typedError=r,this._syncInvalid(),!1;n=s(e.h,e.m)}let r=n!==this._value;return this.value=n,r&&this.dispatchEvent(new Event(`change`,{bubbles:!0})),!0}_pending(){let e=u(this._input()?.value);return e&&this._allowed(e.h,e.m)?e:null}_columnsHtml(){let e=this._format(),t=this._times(),n=(e,t,n)=>`<div class="wui-timepicker-col" role="listbox" aria-label="${t}" data-col="${e}">${n.map(e=>`<button type="button" class="timepicker-option" role="option" tabindex="-1" aria-selected="false" data-v="${e.v}">${e.text}</button>`).join(``)}</div>`,r=[...new Set(t.map(e=>e.h))],i=[...new Set(t.map(e=>e.m))].sort((e,t)=>e-t),a;if(e===`12`){let e=[...new Set(r.map(e=>e%12))].sort((e,t)=>e-t),t=[...new Set(r.map(e=>e>=12?`pm`:`am`))].sort();a=n(`hour`,`Hour`,e.map(e=>({v:e,text:String(e||12)})))+n(`minute`,`Minute`,i.map(e=>({v:e,text:o(e)})))+n(`period`,`AM or PM`,t.map(e=>({v:e,text:e.toUpperCase()})))}else a=n(`hour`,`Hour`,r.map(e=>({v:e,text:o(e)})))+n(`minute`,`Minute`,i.map(e=>({v:e,text:o(e)})));return`<div class="wui-timepicker-cols">${a}</div>`}_selectedIn(e,t){return t?e===`minute`?String(t.m):e===`period`?t.h>=12?`pm`:`am`:String(this._format()===`12`?t.h%12:t.h):null}_optionEnabled(e,t,n){if(!n)return!0;let r=this._format()===`12`,i=n.h>=12,a=e=>r?[e+(i?12:0)]:[e],o=Array.from({length:60},(e,t)=>t);if(e===`hour`)return a(+t).some(e=>o.some(t=>this._allowed(e,t)));if(e===`minute`)return this._allowed(n.h,+t);let s=t===`pm`?12:0;return Array.from({length:12},(e,t)=>s+t).some(e=>o.some(t=>this._allowed(e,t)))}_syncColumns({scroll:e=!1}={}){let t=this._pop();if(!t)return;let n=this._pending();for(let r of t.querySelectorAll(`.wui-timepicker-col`)){let t=r.dataset.col,i=this._selectedIn(t,n),a=[...r.querySelectorAll(`.timepicker-option`)],o=null;for(let e of a){let r=e.dataset.v===i;e.classList.toggle(`is-selected`,r),e.setAttribute(`aria-selected`,r?`true`:`false`),e.disabled=!r&&!this._optionEnabled(t,e.dataset.v,n),r&&(o=e)}o=o||a.find(e=>!e.disabled)||null;for(let e of a)e.tabIndex=e===o?0:-1;e&&o&&(r.scrollTop=o.offsetTop-(r.clientHeight-o.offsetHeight)/2)}}_pick(e,t){let n=this._times();if(!n.length)return;let r=this._pending()||n[0],i=this._format()===`12`,a=r.h,o=r.m;if(e===`minute`?o=+t:a=e===`period`?a%12+(t===`pm`?12:0):i?+t+(r.h>=12?12:0):+t,!this._allowed(a,o)){let t=a*60+o,r=n.filter(t=>e===`minute`?t.m===o:e===`period`?t.h>=12==a>=12:i?t.h%12==a%12&&t.h>=12==a>=12:t.h===a).sort((e,n)=>Math.abs(e.h*60+e.m-t)-Math.abs(n.h*60+n.m-t))[0];if(!r)return;a=r.h,o=r.m}let s=this._input();s.value=l({h:a,m:o},this._format()),this._typedError=``,this._syncInvalid(),this._syncColumns()}_position(){r(this.querySelector(`.wui-timepicker-field`),this._pop())}_onColumnKey(e){let t=e.target.closest?.(`.timepicker-option`),n=t?.closest(`.wui-timepicker-col`);if(!t||!n)return;let r=[...n.querySelectorAll(`.timepicker-option`)].filter(e=>!e.disabled),i=r.indexOf(t),a=[...this._pop().querySelectorAll(`.wui-timepicker-col`)],o=e=>{e&&(this._pick(n.dataset.col,e.dataset.v),(n.querySelector(`.timepicker-option.is-selected`)||e).focus())};switch(e.key){case`ArrowDown`:e.preventDefault(),o(r[Math.min(i+1,r.length-1)]);return;case`ArrowUp`:e.preventDefault(),o(r[Math.max(i-1,0)]);return;case`Home`:e.preventDefault(),o(r[0]);return;case`End`:e.preventDefault(),o(r[r.length-1]);return;case`PageDown`:e.preventDefault(),o(r[Math.min(i+8,r.length-1)]);return;case`PageUp`:e.preventDefault(),o(r[Math.max(i-8,0)]);return;case`ArrowRight`:case`ArrowLeft`:e.preventDefault(),a[a.indexOf(n)+(e.key===`ArrowRight`?1:-1)]?.querySelector(`.timepicker-option[tabindex="0"]`)?.focus();return;case`Enter`:e.preventDefault(),this._close({commit:!0,refocus:!0});return;case` `:e.preventDefault(),o(t);return;case`Escape`:e.preventDefault(),this._close({commit:!1,refocus:!0});return;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),clearTimeout(this._typeaheadTimer),this._typeahead+=e.key.toLowerCase(),this._typeaheadTimer=setTimeout(()=>{this._typeahead=``,this._typeaheadTimer=null},500),o(r.find(e=>e.textContent.trim().toLowerCase().startsWith(this._typeahead))))}}_wire(){this._teardown();let e=this._input(),r=this.querySelector(`.wui-timepicker-toggle`),i=this._pop(),a=this.querySelector(`.timepicker`);if(!e||!i)return;let o=()=>!i.hidden;this._isOpen=o;let s=()=>{o()&&this._position()},c=()=>i.querySelector(`.wui-timepicker-col .timepicker-option[tabindex="0"]`)?.focus();this._open=({focus:n=!1}={})=>{this.hasAttribute(`disabled`)||(o()||(i.innerHTML=this._columnsHtml(),i.hidden=!1,a?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),r?.setAttribute(`aria-expanded`,`true`),this._position(),t(this,s),this._syncColumns({scroll:!0})),n&&c())},this._close=({commit:t=!0,refocus:s=!1}={})=>{if(!o())return;let c=i.contains(document.activeElement);i.hidden=!0,i.innerHTML=``,a?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),r?.setAttribute(`aria-expanded`,`false`),n(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,t?this._commitText():(this._typedError=``,this._syncText(),this._syncInvalid()),(s||c)&&e.focus()},e.addEventListener(`pointerdown`,e=>{this._lastPointer=e.pointerType}),e.addEventListener(`click`,()=>{this._lastPointer!==`touch`&&!o()&&this._open(),this._lastPointer=null}),r?.addEventListener(`click`,()=>{o()?this._close({commit:!0,refocus:!0}):this._open({focus:!0})}),e.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._open({focus:!0});else if(e.key===`Enter`){let t=o(),n=this._commitText();t&&n&&this._close({commit:!1}),(!n||t)&&e.preventDefault()}else e.key===`Escape`&&o()?(e.preventDefault(),this._close({commit:!1})):e.key===`Tab`&&o()&&this._close({commit:!0})}),e.addEventListener(`input`,e=>{e.stopPropagation(),this._typedError&&(this._typedError=``,this._syncInvalid()),o()&&this._syncColumns({scroll:!0})}),e.addEventListener(`change`,e=>{e.stopPropagation(),o()||this._commitText()}),i.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`.timepicker-option`),n=t?.closest(`.wui-timepicker-col`);t&&n&&!t.disabled&&this._pick(n.dataset.col,t.dataset.v)}),i.addEventListener(`keydown`,e=>{o()&&this._onColumnKey(e)}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,o()&&!t&&!this.contains(e.target)&&this._close({commit:!0})},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{o()&&e.key===`Escape`&&this._close({commit:!1})},document.addEventListener(`keydown`,this._onDocKey),o()&&t(this,s)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),n(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``}disconnectedCallback(){this._teardown()}};export{f as t};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-WcDeH46q.js";var i=`wui-tour-step`,a=`wui-tour-seen:`,o={back:`Back`,next:`Next`,skip:`Skip`,done:`Done`},s={back:`back-label`,next:`next-label`,skip:`skip-label`,done:`done-label`},c=4,l=0;function u(e=a,t=globalThis.localStorage){return{isSeen:async n=>t.getItem(e+n)===`1`,markSeen:async n=>{t.setItem(e+n,`1`)}}}var d=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,f=class extends e{static get observedAttributes(){return[`open`]}constructor(){super(),this.seenStore=null,this.onBeforeStep=null,this._run=0,this._running=!1,this._layer=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))}_stepList(){return Array.from(this.querySelectorAll(`:scope > ${i}`),e=>({target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:e.textContent.trim()}))}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?u():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(s[e])||o[e]}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();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}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._build(),this._show(n)}}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;let t=document.querySelector(e.target);if(d(t))return{index:i,target:t}}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-${++l}`,n=document.createElement(`div`);n.className=`wui-tour-layer`,n.innerHTML=`
|
|
2
|
+
<div class="wui-tour-spot" aria-hidden="true"></div>
|
|
3
|
+
<div class="wui-tour-card" role="dialog" aria-modal="true" tabindex="-1" aria-labelledby="${e}-title" aria-describedby="${e}-text">
|
|
4
|
+
<p class="wui-tour-position"></p>
|
|
5
|
+
<h2 class="wui-tour-title" id="${e}-title"></h2>
|
|
6
|
+
<p class="wui-tour-text" id="${e}-text"></p>
|
|
7
|
+
<div class="wui-tour-actions">
|
|
8
|
+
<button type="button" class="btn btn-sm btn-link wui-tour-skip"></button>
|
|
9
|
+
<div class="wui-tour-nav">
|
|
10
|
+
<button type="button" class="btn btn-sm btn-outline-secondary wui-tour-back"></button>
|
|
11
|
+
<button type="button" class="btn btn-sm btn-primary wui-tour-next"></button>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="visually-hidden" role="status" aria-live="polite"></div>`,document.body.appendChild(n),this._layer=n,this._spot=n.querySelector(`.wui-tour-spot`),this._card=n.querySelector(`.wui-tour-card`),this._live=n.querySelector(`[role=status]`),this._card.querySelector(`.wui-tour-skip`).addEventListener(`click`,()=>this._close(`skipped`)),this._card.querySelector(`.wui-tour-back`).addEventListener(`click`,()=>this._move(-1)),this._card.querySelector(`.wui-tour-next`).addEventListener(`click`,()=>this._move(1)),this._onKey=e=>this._key(e),this._onFocusIn=e=>{this._layer&&!this._layer.contains(e.target)&&this._card.focus()},document.addEventListener(`keydown`,this._onKey,!0),document.addEventListener(`focusin`,this._onFocusIn),t(n,()=>this._place())}_show(e){this._current=e;let{index:t,target:n}=e,r=this._steps[t],i=this._steps,a=t===i.length-1,o=this._card;o.querySelector(`.wui-tour-position`).textContent=`Step ${t+1} of ${i.length}`;let s=o.querySelector(`.wui-tour-title`);s.textContent=r.title||``,s.hidden=!r.title,o.querySelector(`.wui-tour-text`).textContent=r.description||``,o.querySelector(`.wui-tour-skip`).textContent=this._label(`skip`),o.querySelector(`.wui-tour-back`).textContent=this._label(`back`),o.querySelector(`.wui-tour-back`).hidden=t<=this._firstIndex,o.querySelector(`.wui-tour-next`).textContent=this._label(a?`done`:`next`),this._live.textContent=[`Step ${t+1} of ${i.length}`,r.title,r.description].filter(Boolean).join(`. `),n.scrollIntoView?.({block:`center`,inline:`nearest`}),this._place(),(!o.contains(document.activeElement)||document.activeElement.hidden)&&o.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t}}))}_place(){if(!this._current||!this._layer)return;let e=this._current.target.getBoundingClientRect(),t=this._spot.style;t.top=`${e.top-c}px`,t.left=`${e.left-c}px`,t.width=`${e.width+c*2}px`,t.height=`${e.height+c*2}px`,r(this._spot,this._card,{clampHeight:!0})}async _move(e){if(!this._current||this._moving)return;this._moving=!0;let t=this._run;try{let n=await this._locate(this._current.index+e,e,t);if(t!==this._run)return;n?this._show(n):e>0&&await this._close(`finished`)}finally{this._moving=!1}}_key(e){if(!(!this._layer||e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this._close(`skipped`);else if(e.key===`ArrowRight`||e.key===`ArrowLeft`)e.preventDefault(),e.key===`ArrowRight`?this._move(1):this._current.index>this._firstIndex&&this._move(-1);else if(e.key===`Tab`){let t=Array.from(this._card.querySelectorAll(`button`)).filter(e=>!e.hidden),n=t[0],r=t[t.length-1],i=document.activeElement;!this._card.contains(i)||e.shiftKey&&(i===n||i===this._card)?(e.preventDefault(),(e.shiftKey?r:n).focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())}}}_teardown(){if(!this._layer)return;document.removeEventListener(`keydown`,this._onKey,!0),document.removeEventListener(`focusin`,this._onFocusIn),n(this._layer),this._layer.remove(),this._layer=null,this._current=null;let e=this._returnFocus;this._returnFocus=null,e?.isConnected&&e.focus?.()}async _close(e){let t=this._run;this._teardown();let n=this._store();try{n&&t===this._run&&await n.markSeen(this.tourId)}finally{this._finish(e)}}_finish(e){this._run++,this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`),this.dispatchEvent(new CustomEvent(`wui-tour:close`,{bubbles:!0,detail:{reason:e}}))}};export{u as n,f as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./elementBase-BlsR4tqa.js";import{c as t}from"./wuiHttp-BC8co934.js";import{n,t as r}from"./formMirror-BgY7zkC3.js";import{t as i}from"./iconGlyphs.g-CUm_mfze.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 n=this.getAttribute(`load-url`);if(!n)throw Error(`<wui-tree> has a node with children to load but no loadChildren or load-url.`);let r=new URL(n,window.location.href);r.searchParams.set(s,e.id);let i=await t(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`)n(this,this.values);else if(e===`single`)r(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,t,n){let r=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":n,"aria-posinset":t,"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`),r===`single`&&s.setAttribute(`aria-selected`,String(e.id===this._selected)),r===`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)),r===`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=i(`chevron-right`,{size:16})),c.append(l),r===`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 t=p(`span`,`wui-tree-icon`,{"aria-hidden":`true`});t.innerHTML=i(e.icon,{size:16}),c.append(t)}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};
|
|
@@ -0,0 +1 @@
|
|
|
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-subtle" 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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t,n={}){if(!e||!t)return;let r=e.getBoundingClientRect(),i=n.clampHeight?t.scrollTop:0;n.clampHeight&&(t.style.maxHeight=``);let a=t.offsetHeight,o=window.innerHeight-r.bottom,s=o<a+4&&r.top>o;if(t.classList.toggle(`drop-up`,s),t.style.position=`fixed`,t.style.top=s?`${Math.max(4,r.top-a-4)}px`:`${r.bottom+4}px`,n.clampHeight){let e=s?r.top-8:window.innerHeight-r.bottom-8;e<a&&(t.style.maxHeight=`${Math.max(e,0)}px`),t.scrollTop=i}n.matchWidth&&(r.width>=300?(t.style.minWidth=`${r.width}px`,t.style.width=`${r.width}px`,t.style.maxWidth=`${r.width}px`):(t.style.minWidth=`${r.width}px`,t.style.width=`max-content`,t.style.maxWidth=`${Math.min(400,window.innerWidth-8)}px`));let c=t.offsetWidth,l=Math.min(r.left,window.innerWidth-c-4);t.style.left=`${Math.max(4,l)}px`}function t(e,t){n(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 n(e){e?._reanchor&&(window.removeEventListener(`resize`,e._reanchor),window.removeEventListener(`scroll`,e._reanchorScroll,!0),e._reanchor=null,e._reanchorScroll=null)}export{t as n,n as r,e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],t=[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],n=e=>{let t=String(e??``).trim();return/^[0-6]$/.test(t)?Number(t):null},r=e=>n(e.getAttribute(`first-day`))??n(getComputedStyle(e).getPropertyValue(`--wui-first-day`))??1,i=e=>String(e).padStart(2,`0`),a=(e,t,n)=>`${e}-${i(t+1)}-${i(n)}`,o=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e||``);return t?{y:+t[1],m:t[2]-1,d:+t[3]}:null},s=`dd-MMM-yyyy`,c=(t,n=s)=>{let r=o(t);if(!r)return``;let a={yyyy:r.y,MMMM:e[r.m],MMM:e[r.m].slice(0,3),MM:i(r.m+1),dd:i(r.d),d:r.d};return(n||`dd-MMM-yyyy`).replace(/yyyy|MMMM|MMM|MM|dd|d/g,e=>a[e])},l=(e,t)=>new Date(e,t+1,0).getDate(),u=(e,t)=>{for(;t<0;)t+=12,--e;for(;t>11;)t-=12,e+=1;return{y:e,m:t}};export{r as a,a as c,l as i,t as n,c as o,u as r,o as s,e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=[[`AF`,`Afghanistan`,`93`],[`AX`,`Åland Islands`,`358`],[`AL`,`Albania`,`355`],[`DZ`,`Algeria`,`213`],[`AS`,`American Samoa`,`1`],[`AD`,`Andorra`,`376`],[`AO`,`Angola`,`244`],[`AI`,`Anguilla`,`1`],[`AG`,`Antigua & Barbuda`,`1`],[`AR`,`Argentina`,`54`],[`AM`,`Armenia`,`374`],[`AW`,`Aruba`,`297`],[`AC`,`Ascension Island`,`247`],[`AU`,`Australia`,`61`],[`AT`,`Austria`,`43`],[`AZ`,`Azerbaijan`,`994`],[`BS`,`Bahamas`,`1`],[`BH`,`Bahrain`,`973`],[`BD`,`Bangladesh`,`880`],[`BB`,`Barbados`,`1`],[`BY`,`Belarus`,`375`],[`BE`,`Belgium`,`32`],[`BZ`,`Belize`,`501`],[`BJ`,`Benin`,`229`],[`BM`,`Bermuda`,`1`],[`BT`,`Bhutan`,`975`],[`BO`,`Bolivia`,`591`],[`BA`,`Bosnia & Herzegovina`,`387`],[`BW`,`Botswana`,`267`],[`BR`,`Brazil`,`55`],[`IO`,`British Indian Ocean Territory`,`246`],[`VG`,`British Virgin Islands`,`1`],[`BN`,`Brunei`,`673`],[`BG`,`Bulgaria`,`359`],[`BF`,`Burkina Faso`,`226`],[`BI`,`Burundi`,`257`],[`KH`,`Cambodia`,`855`],[`CM`,`Cameroon`,`237`],[`CA`,`Canada`,`1`],[`CV`,`Cape Verde`,`238`],[`BQ`,`Caribbean Netherlands`,`599`],[`KY`,`Cayman Islands`,`1`],[`CF`,`Central African Republic`,`236`],[`TD`,`Chad`,`235`],[`CL`,`Chile`,`56`],[`CN`,`China`,`86`],[`CX`,`Christmas Island`,`61`],[`CC`,`Cocos (Keeling) Islands`,`61`],[`CO`,`Colombia`,`57`],[`KM`,`Comoros`,`269`],[`CG`,`Congo - Brazzaville`,`242`],[`CD`,`Congo - Kinshasa`,`243`],[`CK`,`Cook Islands`,`682`],[`CR`,`Costa Rica`,`506`],[`CI`,`Côte d’Ivoire`,`225`],[`HR`,`Croatia`,`385`],[`CU`,`Cuba`,`53`],[`CW`,`Curaçao`,`599`],[`CY`,`Cyprus`,`357`],[`CZ`,`Czechia`,`420`],[`DK`,`Denmark`,`45`],[`DJ`,`Djibouti`,`253`],[`DM`,`Dominica`,`1`],[`DO`,`Dominican Republic`,`1`],[`EC`,`Ecuador`,`593`],[`EG`,`Egypt`,`20`],[`SV`,`El Salvador`,`503`],[`GQ`,`Equatorial Guinea`,`240`],[`ER`,`Eritrea`,`291`],[`EE`,`Estonia`,`372`],[`SZ`,`Eswatini`,`268`],[`ET`,`Ethiopia`,`251`],[`FK`,`Falkland Islands`,`500`],[`FO`,`Faroe Islands`,`298`],[`FJ`,`Fiji`,`679`],[`FI`,`Finland`,`358`],[`FR`,`France`,`33`],[`GF`,`French Guiana`,`594`],[`PF`,`French Polynesia`,`689`],[`GA`,`Gabon`,`241`],[`GM`,`Gambia`,`220`],[`GE`,`Georgia`,`995`],[`DE`,`Germany`,`49`],[`GH`,`Ghana`,`233`],[`GI`,`Gibraltar`,`350`],[`GR`,`Greece`,`30`],[`GL`,`Greenland`,`299`],[`GD`,`Grenada`,`1`],[`GP`,`Guadeloupe`,`590`],[`GU`,`Guam`,`1`],[`GT`,`Guatemala`,`502`],[`GG`,`Guernsey`,`44`],[`GN`,`Guinea`,`224`],[`GW`,`Guinea-Bissau`,`245`],[`GY`,`Guyana`,`592`],[`HT`,`Haiti`,`509`],[`HN`,`Honduras`,`504`],[`HK`,`Hong Kong SAR China`,`852`],[`HU`,`Hungary`,`36`],[`IS`,`Iceland`,`354`],[`IN`,`India`,`91`],[`ID`,`Indonesia`,`62`],[`IR`,`Iran`,`98`],[`IQ`,`Iraq`,`964`],[`IE`,`Ireland`,`353`],[`IM`,`Isle of Man`,`44`],[`IL`,`Israel`,`972`],[`IT`,`Italy`,`39`],[`JM`,`Jamaica`,`1`],[`JP`,`Japan`,`81`],[`JE`,`Jersey`,`44`],[`JO`,`Jordan`,`962`],[`KZ`,`Kazakhstan`,`7`],[`KE`,`Kenya`,`254`],[`KI`,`Kiribati`,`686`],[`XK`,`Kosovo`,`383`],[`KW`,`Kuwait`,`965`],[`KG`,`Kyrgyzstan`,`996`],[`LA`,`Laos`,`856`],[`LV`,`Latvia`,`371`],[`LB`,`Lebanon`,`961`],[`LS`,`Lesotho`,`266`],[`LR`,`Liberia`,`231`],[`LY`,`Libya`,`218`],[`LI`,`Liechtenstein`,`423`],[`LT`,`Lithuania`,`370`],[`LU`,`Luxembourg`,`352`],[`MO`,`Macao SAR China`,`853`],[`MG`,`Madagascar`,`261`],[`MW`,`Malawi`,`265`],[`MY`,`Malaysia`,`60`],[`MV`,`Maldives`,`960`],[`ML`,`Mali`,`223`],[`MT`,`Malta`,`356`],[`MH`,`Marshall Islands`,`692`],[`MQ`,`Martinique`,`596`],[`MR`,`Mauritania`,`222`],[`MU`,`Mauritius`,`230`],[`YT`,`Mayotte`,`262`],[`MX`,`Mexico`,`52`],[`FM`,`Micronesia`,`691`],[`MD`,`Moldova`,`373`],[`MC`,`Monaco`,`377`],[`MN`,`Mongolia`,`976`],[`ME`,`Montenegro`,`382`],[`MS`,`Montserrat`,`1`],[`MA`,`Morocco`,`212`],[`MZ`,`Mozambique`,`258`],[`MM`,`Myanmar (Burma)`,`95`],[`NA`,`Namibia`,`264`],[`NR`,`Nauru`,`674`],[`NP`,`Nepal`,`977`],[`NL`,`Netherlands`,`31`],[`NC`,`New Caledonia`,`687`],[`NZ`,`New Zealand`,`64`],[`NI`,`Nicaragua`,`505`],[`NE`,`Niger`,`227`],[`NG`,`Nigeria`,`234`],[`NU`,`Niue`,`683`],[`NF`,`Norfolk Island`,`672`],[`KP`,`North Korea`,`850`],[`MK`,`North Macedonia`,`389`],[`MP`,`Northern Mariana Islands`,`1`],[`NO`,`Norway`,`47`],[`OM`,`Oman`,`968`],[`PK`,`Pakistan`,`92`],[`PW`,`Palau`,`680`],[`PS`,`Palestinian Territories`,`970`],[`PA`,`Panama`,`507`],[`PG`,`Papua New Guinea`,`675`],[`PY`,`Paraguay`,`595`],[`PE`,`Peru`,`51`],[`PH`,`Philippines`,`63`],[`PL`,`Poland`,`48`],[`PT`,`Portugal`,`351`],[`PR`,`Puerto Rico`,`1`],[`QA`,`Qatar`,`974`],[`RE`,`Réunion`,`262`],[`RO`,`Romania`,`40`],[`RU`,`Russia`,`7`],[`RW`,`Rwanda`,`250`],[`WS`,`Samoa`,`685`],[`SM`,`San Marino`,`378`],[`ST`,`São Tomé & Príncipe`,`239`],[`SA`,`Saudi Arabia`,`966`],[`SN`,`Senegal`,`221`],[`RS`,`Serbia`,`381`],[`SC`,`Seychelles`,`248`],[`SL`,`Sierra Leone`,`232`],[`SG`,`Singapore`,`65`],[`SX`,`Sint Maarten`,`1`],[`SK`,`Slovakia`,`421`],[`SI`,`Slovenia`,`386`],[`SB`,`Solomon Islands`,`677`],[`SO`,`Somalia`,`252`],[`ZA`,`South Africa`,`27`],[`KR`,`South Korea`,`82`],[`SS`,`South Sudan`,`211`],[`ES`,`Spain`,`34`],[`LK`,`Sri Lanka`,`94`],[`BL`,`St. Barthélemy`,`590`],[`SH`,`St. Helena`,`290`],[`KN`,`St. Kitts & Nevis`,`1`],[`LC`,`St. Lucia`,`1`],[`MF`,`St. Martin`,`590`],[`PM`,`St. Pierre & Miquelon`,`508`],[`VC`,`St. Vincent & Grenadines`,`1`],[`SD`,`Sudan`,`249`],[`SR`,`Suriname`,`597`],[`SJ`,`Svalbard & Jan Mayen`,`47`],[`SE`,`Sweden`,`46`],[`CH`,`Switzerland`,`41`],[`SY`,`Syria`,`963`],[`TW`,`Taiwan`,`886`],[`TJ`,`Tajikistan`,`992`],[`TZ`,`Tanzania`,`255`],[`TH`,`Thailand`,`66`],[`TL`,`Timor-Leste`,`670`],[`TG`,`Togo`,`228`],[`TK`,`Tokelau`,`690`],[`TO`,`Tonga`,`676`],[`TT`,`Trinidad & Tobago`,`1`],[`TA`,`Tristan da Cunha`,`290`],[`TN`,`Tunisia`,`216`],[`TR`,`Türkiye`,`90`],[`TM`,`Turkmenistan`,`993`],[`TC`,`Turks & Caicos Islands`,`1`],[`TV`,`Tuvalu`,`688`],[`VI`,`U.S. Virgin Islands`,`1`],[`UG`,`Uganda`,`256`],[`UA`,`Ukraine`,`380`],[`AE`,`United Arab Emirates`,`971`],[`GB`,`United Kingdom`,`44`],[`US`,`United States`,`1`],[`UY`,`Uruguay`,`598`],[`UZ`,`Uzbekistan`,`998`],[`VU`,`Vanuatu`,`678`],[`VA`,`Vatican City`,`39`],[`VE`,`Venezuela`,`58`],[`VN`,`Vietnam`,`84`],[`WF`,`Wallis & Futuna`,`681`],[`EH`,`Western Sahara`,`212`],[`YE`,`Yemen`,`967`],[`ZM`,`Zambia`,`260`],[`ZW`,`Zimbabwe`,`263`]],t=t=>(e.find(e=>e[0]===t)||[``,``,``])[2];export{t as n,e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t){typeof customElements<`u`&&!customElements.get(e)&&customElements.define(e,t)}var t=typeof HTMLElement>`u`?class{}:HTMLElement;export{e as n,t};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiAutocomplete-ByxnwJNQ.js";
|
|
3
|
-
//#region src/elements/autocomplete.js
|
|
4
|
-
e("wui-autocomplete", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiAutocomplete };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiAutocomplete-Comrnbmf.js";e(`wui-autocomplete`,t);export{t as WuiAutocomplete};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiCommandPalette-CtZ04JxZ.js";
|
|
3
|
-
//#region src/elements/command-palette.js
|
|
4
|
-
e("wui-command-palette", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiCommandPalette };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiCommandPalette-CKna1GlO.js";e(`wui-command-palette`,t);export{t as WuiCommandPalette};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiConsentBanner-oVe-jxCO.js";
|
|
3
|
-
//#region src/elements/consent-banner.js
|
|
4
|
-
e("wui-consent-banner", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiConsentBanner };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiConsentBanner-CFll7vxN.js";e(`wui-consent-banner`,t);export{t as WuiConsentBanner};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiContextMenu-Bx_U2X3t.js";
|
|
3
|
-
//#region src/elements/context-menu.js
|
|
4
|
-
e("wui-context-menu", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiContextMenu };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiContextMenu-CBy0O4HT.js";e(`wui-context-menu`,t);export{t as WuiContextMenu};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiCountrySelect-CUAwKnL9.js";
|
|
3
|
-
//#region src/elements/country-select.js
|
|
4
|
-
e("wui-country-select", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiCountrySelect };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiCountrySelect-oLBUHvMM.js";e(`wui-country-select`,t);export{t as WuiCountrySelect};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiDateRange-BocnVO6L.js";
|
|
3
|
-
//#region src/elements/date-range.js
|
|
4
|
-
e("wui-date-range", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiDateRange };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiDateRange-Di5YE9mg.js";e(`wui-date-range`,t);export{t as WuiDateRange};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiDatePicker-DkNbc-z7.js";
|
|
3
|
-
//#region src/elements/datepicker.js
|
|
4
|
-
e("wui-datepicker", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiDatePicker };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiDatePicker-nB1B3eWW.js";e(`wui-datepicker`,t);export{t as WuiDatePicker};
|
package/dist/elements/dock.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiDock-BSDY9g8Q.js";
|
|
3
|
-
//#region src/elements/dock.js
|
|
4
|
-
e("wui-dock", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiDock };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiDock-BD2HgMmP.js";e(`wui-dock`,t);export{t as WuiDock};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiImageCrop-1yaAONTk.js";
|
|
3
|
-
//#region src/elements/image-crop.js
|
|
4
|
-
e("wui-image-crop", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiImageCrop };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiImageCrop-Cr3D2iPo.js";e(`wui-image-crop`,t);export{t as WuiImageCrop};
|
package/dist/elements/kanban.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g } from "../kanban-BIiEMkTK.js";
|
|
3
|
-
//#region src/elements/kanban.js
|
|
4
|
-
e("wui-kanban", n);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { h as KANBAN_DRAG_THRESHOLD_PX, u as KANBAN_LONG_PRESS_MS, p as KANBAN_PHONE_QUERY, s as KANBAN_STORAGE_PREFIX, t as KANBAN_SUMMARY_FORMATS, d as KANBAN_TEXT, m as KANBAN_TONES, n as WuiKanban, c as kanbanCardLabel, g as kanbanOverflow, r as kanbanStorageKey, i as kanbanSummaryFormat, f as kanbanVisibleLimit, l as readKanbanCollapsed, o as sumKanbanValues, a as writeKanbanCollapsed };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g}from"../kanban-CdELdS3U.js";e(`wui-kanban`,n);export{h as KANBAN_DRAG_THRESHOLD_PX,u as KANBAN_LONG_PRESS_MS,p as KANBAN_PHONE_QUERY,s as KANBAN_STORAGE_PREFIX,t as KANBAN_SUMMARY_FORMATS,d as KANBAN_TEXT,m as KANBAN_TONES,n as WuiKanban,c as kanbanCardLabel,g as kanbanOverflow,r as kanbanStorageKey,i as kanbanSummaryFormat,f as kanbanVisibleLimit,l as readKanbanCollapsed,o as sumKanbanValues,a as writeKanbanCollapsed};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiMultiSelect-BrCGRNCt.js";
|
|
3
|
-
//#region src/elements/multiselect.js
|
|
4
|
-
e("wui-multiselect", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiMultiSelect };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiMultiSelect-BUw-7apM.js";e(`wui-multiselect`,t);export{t as WuiMultiSelect};
|
package/dist/elements/otp.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiOtp-D8-4Pqil.js";
|
|
3
|
-
//#region src/elements/otp.js
|
|
4
|
-
e("wui-otp", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiOtp };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiOtp-BbO_75RB.js";e(`wui-otp`,t);export{t as WuiOtp};
|
package/dist/elements/phone.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiPhone-BvbhiP2r.js";
|
|
3
|
-
//#region src/elements/phone.js
|
|
4
|
-
e("wui-phone", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiPhone };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiPhone-GJglNelp.js";e(`wui-phone`,t);export{t as WuiPhone};
|
package/dist/elements/select.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiSelect-BXrpiuXG.js";
|
|
3
|
-
//#region src/elements/select.js
|
|
4
|
-
e("wui-select", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiSelect };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiSelect-DvtN4qC2.js";e(`wui-select`,t);export{t as WuiSelect};
|
package/dist/elements/slider.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiSlider-BcU0psYf.js";
|
|
3
|
-
//#region src/elements/slider.js
|
|
4
|
-
e("wui-slider", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiSlider };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiSlider-Br6V2amU.js";e(`wui-slider`,t);export{t as WuiSlider};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiSortable-JjJqstSU.js";
|
|
3
|
-
//#region src/elements/sortable.js
|
|
4
|
-
e("wui-sortable", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiSortable };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiSortable-Bd7Fz5Ox.js";e(`wui-sortable`,t);export{t as WuiSortable};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { n as t, t as n } from "../statusIcons-C3zjycpa.js";
|
|
3
|
-
//#region src/elements/status-icon.js
|
|
4
|
-
e("wui-status-icon", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { n as STATUS_TONES, t as WuiStatusIcon };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{n as t,t as n}from"../statusIcons-2X4iGkKL.js";e(`wui-status-icon`,t);export{n as STATUS_TONES,t as WuiStatusIcon};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiTagInput-D1ay3OcL.js";
|
|
3
|
-
//#region src/elements/taginput.js
|
|
4
|
-
e("wui-taginput", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiTagInput };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiTagInput-DzEZooIn.js";e(`wui-taginput`,t);export{t as WuiTagInput};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiTimePicker-C7n-VFGt.js";
|
|
3
|
-
//#region src/elements/timepicker.js
|
|
4
|
-
e("wui-timepicker", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiTimePicker };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiTimePicker-Bolpp93P.js";e(`wui-timepicker`,t);export{t as WuiTimePicker};
|
package/dist/elements/tour.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { n as t, t as n } from "../WuiTour-R5O9l--J.js";
|
|
3
|
-
//#region src/elements/tour.js
|
|
4
|
-
e("wui-tour", n);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { n as WuiTour, t as createLocalSeenStore };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{n as t,t as n}from"../WuiTour-DiKZEWeb.js";e(`wui-tour`,n);export{n as WuiTour,t as createLocalSeenStore};
|
package/dist/elements/tree.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "../WuiTree-DXP7pGeI.js";
|
|
3
|
-
//#region src/elements/tree.js
|
|
4
|
-
e("wui-tree", t);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as WuiTree };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiTree-SA0QU9AF.js";e(`wui-tree`,t);export{t as WuiTree};
|
package/dist/elements/wizard.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { n as t, t as n } from "../WuiWizardStep-BU5w9_Ds.js";
|
|
3
|
-
e("wui-wizard-step", n), e("wui-wizard", t);
|
|
4
|
-
//#endregion
|
|
5
|
-
export { t as WuiWizard, n as WuiWizardStep };
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{n as t,t as n}from"../WuiWizardStep-DIHxrXn9.js";e(`wui-wizard-step`,n),e(`wui-wizard`,t);export{t as WuiWizard,n as WuiWizardStep};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={AC:`40123`,AD:`312345`,AE:`501234567`,AF:`701234567`,AG:`2684641234`,AI:`2642351234`,AL:`672123456`,AM:`77123456`,AO:`923123456`,AR:`91123456789`,AS:`6847331234`,AT:`664123456`,AU:`412345678`,AW:`5601234`,AX:`412345678`,AZ:`401234567`,BA:`61123456`,BB:`2462501234`,BD:`1812345678`,BE:`450001234`,BF:`70123456`,BG:`43012345`,BH:`36001234`,BI:`79561234`,BJ:`0195123456`,BL:`690001234`,BM:`4413701234`,BN:`7123456`,BO:`71234567`,BQ:`3181234`,BR:`11961234567`,BS:`2423591234`,BT:`17123456`,BW:`71123456`,BY:`294911911`,BZ:`6221234`,CA:`5062345678`,CC:`412345678`,CD:`991234567`,CF:`70012345`,CG:`061234567`,CH:`781234567`,CI:`0123456789`,CK:`71234`,CL:`221234567`,CM:`671234567`,CN:`13123456789`,CO:`3211234567`,CR:`83123456`,CU:`51234567`,CV:`9911234`,CW:`95181234`,CX:`412345678`,CY:`96123456`,CZ:`601123456`,DE:`15123456789`,DJ:`77831001`,DK:`34412345`,DM:`7672251234`,DO:`8092345678`,DZ:`551234567`,EC:`991234567`,EE:`51234567`,EG:`1001234567`,EH:`650123456`,ER:`7123456`,ES:`612345678`,ET:`911234567`,FI:`412345678`,FJ:`7012345`,FK:`51234`,FM:`3501234`,FO:`211234`,FR:`612345678`,GA:`06031234`,GB:`7400123456`,GD:`4734031234`,GE:`555123456`,GF:`694201234`,GG:`7781123456`,GH:`231234567`,GI:`57123456`,GL:`221234`,GM:`3012345`,GN:`601123456`,GP:`690001234`,GQ:`222123456`,GR:`6912345678`,GT:`51234567`,GU:`6713001234`,GW:`955012345`,GY:`6091234`,HK:`51234567`,HN:`91234567`,HR:`921234567`,HT:`34101234`,HU:`201234567`,ID:`812345678`,IE:`850123456`,IL:`502345678`,IM:`7924123456`,IN:`8123456789`,IO:`3801234`,IQ:`7912345678`,IR:`9123456789`,IS:`6111234`,IT:`3123456789`,JE:`7797712345`,JM:`8762101234`,JO:`790123456`,JP:`9012345678`,KE:`712123456`,KG:`700123456`,KH:`91234567`,KI:`72001234`,KM:`3212345`,KN:`8697652917`,KP:`1921234567`,KR:`1020000000`,KW:`50012345`,KY:`3453231234`,KZ:`7710009998`,LA:`2023123456`,LB:`71123456`,LC:`7582845678`,LI:`660234567`,LK:`712345678`,LR:`770123456`,LS:`50123456`,LT:`61234567`,LU:`628123456`,LV:`21234567`,LY:`912345678`,MA:`650123456`,MC:`612345678`,MD:`62112345`,ME:`60123456`,MF:`690001234`,MG:`321234567`,MH:`2351234`,MK:`72345678`,ML:`65012345`,MM:`92123456`,MN:`88123456`,MO:`66123456`,MP:`6702345678`,MQ:`696201234`,MR:`22123456`,MS:`6644923456`,MT:`96961234`,MU:`52512345`,MV:`7712345`,MW:`991234567`,MX:`2221234567`,MY:`123456789`,MZ:`821234567`,NA:`811234567`,NC:`751234`,NE:`93123456`,NF:`381234`,NG:`8021234567`,NI:`81234567`,NL:`612345678`,NO:`40612345`,NP:`9841234567`,NR:`5551234`,NU:`8884012`,NZ:`211234567`,OM:`92123456`,PA:`61234567`,PE:`912345678`,PF:`87123456`,PG:`70123456`,PH:`9051234567`,PK:`3012345678`,PL:`512345678`,PM:`551234`,PR:`7872345678`,PS:`599123456`,PT:`912345678`,PW:`6201234`,PY:`961456789`,QA:`33123456`,RE:`692123456`,RO:`712034567`,RS:`601234567`,RU:`9123456789`,RW:`720123456`,SA:`512345678`,SB:`7421234`,SC:`2510123`,SD:`911231234`,SE:`701234567`,SG:`81234567`,SH:`51234`,SI:`31234567`,SJ:`41234567`,SK:`912123456`,SL:`25123456`,SM:`66661212`,SN:`701234567`,SO:`71123456`,SR:`7412345`,SS:`977123456`,ST:`9812345`,SV:`70123456`,SX:`7215205678`,SY:`944567890`,SZ:`76123456`,TA:`8999`,TC:`6492311234`,TD:`63012345`,TG:`90112345`,TH:`812345678`,TJ:`917123456`,TK:`7290`,TL:`77212345`,TM:`66123456`,TN:`20123456`,TO:`7715123`,TR:`5012345678`,TT:`8682911234`,TV:`901234`,TW:`912345678`,TZ:`621234567`,UA:`501234567`,UG:`712345678`,US:`2015550123`,UY:`94231234`,UZ:`912345678`,VA:`3123456789`,VC:`7844301234`,VE:`4121234567`,VG:`2843001234`,VI:`3406421234`,VN:`912345678`,VU:`5912345`,WF:`821234`,WS:`7212345`,XK:`43201234`,YE:`712345678`,YT:`639012345`,ZA:`711234567`,ZM:`955123456`,ZW:`712345678`};export{e as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as e,n as t,t as n}from"./fileViewerUi-DasgDsU-.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`;let d=n(`printer`,`Print`);d.addEventListener(`click`,()=>this.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(Math.min(1,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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./fileViewerUi-DasgDsU-.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};
|