@webority/ui-elements 0.137.0 → 0.137.2
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/{WuiDataTable-BVagEWAU.js → WuiDataTable-XscBy1ct.js} +1 -1
- package/dist/{WuiInlineEdit-C6E6bGpU.js → WuiInlineEdit-CBw0bupF.js} +1 -1
- package/dist/{WuiLightbox-DSRuxbBA.js → WuiLightbox-CDcqNQun.js} +1 -1
- package/dist/{WuiMentionInput-DhJ180iU.js → WuiMentionInput-9iC7Tur2.js} +1 -1
- package/dist/{WuiNotificationCenter-Br_cd0C_.js → WuiNotificationCenter-CClYbyQ2.js} +1 -1
- package/dist/{WuiRelativeTime-CcbKgVjE.js → WuiRelativeTime-BG6rgUhw.js} +1 -1
- package/dist/{WuiRollingNumber-D7uHyeQB.js → WuiRollingNumber-CF3H6l7t.js} +1 -1
- package/dist/{dataTable-CUILMcga.js → dataTable-BGZc5iC1.js} +1 -1
- package/dist/{drawerDiscard-DRTki0-d.js → drawerDiscard-8StN3xcZ.js} +1 -1
- package/dist/elements/data-table.js +1 -1
- package/dist/elements/inline-edit.js +1 -1
- package/dist/elements/kanban.js +1 -1
- package/dist/elements/lightbox.js +1 -1
- package/dist/elements/mention-input.js +1 -1
- package/dist/elements/notification-center.js +1 -1
- package/dist/elements/relative-time.js +1 -1
- package/dist/elements/rolling-number.js +1 -1
- package/dist/formatters-Ba0CvsTs.js +1 -0
- package/dist/helpers.js +1 -1
- package/dist/{kanban-DqdYQ6sC.js → kanban-D-ljbA4A.js} +1 -1
- package/dist/{notificationDays-CMjhBP1Z.js → notificationDays-dNQZGLlB.js} +1 -1
- package/dist/server.js +1 -1
- package/dist/ui-chart.global.js +2 -2
- package/dist/ui-chart.js +2 -2
- package/dist/ui-elements/autocomplete.global.js +1 -1
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +1 -1
- package/dist/ui-elements/comment-thread.global.js +1 -1
- package/dist/ui-elements/consent-banner.global.js +1 -1
- package/dist/ui-elements/context-menu.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -1
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lead-popup.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +1 -1
- package/dist/ui-elements/multiselect.global.js +1 -1
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/resizable.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/taginput.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +26 -26
- package/dist/ui-elements.js +1 -1
- package/package.json +2 -2
- package/dist/formatters-D1zbsEJJ.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,M as t,S as n,T as r,_ as i,b as a,c as o,g as s,h as c,i as l,j as u,r as d,t as f}from"./dataTable-CUILMcga.js";import{t as p}from"./elementBase-DV9IZZCu.js";var m=`.wui-col-resize`,h=`.wui-group-row, .wui-virtual-spacer`,g=`.wui-select-cell, .wui-expand-cell`,_=`<svg class="wui-icon" data-icon="chevron-down" data-wui="AppIcon" width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="1.5" d="M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95"></path></svg>`,v=e=>e.hasAttribute(`data-wui-skeleton`)||!!e.querySelector(`:scope > td > .skeleton`),y=class extends p{constructor(){super(),this._frame=0,this._headDirty=!0,this._rowsDirty=!0,this._frozenSig=null,this._natural=[],this._widths={},this._collapsed=/* @__PURE__ */ new Set,this._groupOrder=[],this._items=[],this._range=null,this._drag=null,this._userSized=!1,this._swallowClick=!1,this._mo=null,this._ro=null,this._fonts=null,this._onPointerDown=e=>this._startDrag(e),this._onKeyDown=e=>this._key(e),this._onClick=e=>this._click(e),this._onDblClick=e=>{let t=e.target.closest?.(m);t&&this.contains(t)&&this._reset(t.closest(`th`))},this._onScroll=()=>{this.hasAttribute(`virtual`)&&this._schedule()},this._onFonts=()=>{this._userSized||this._drag||this._frozenSig===null||!this.hasAttribute(`resizable`)||(this._frozenSig=null,this._schedule())}}connectedCallback(){this._widths=r(this.getAttribute(`view-key`)),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick,!0),this.addEventListener(`dblclick`,this._onDblClick),this.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._fonts=this.ownerDocument.fonts??null,this._fonts?.addEventListener(`loadingdone`,this._onFonts),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(e=>this._mutated(e)),this._mo.observe(this,{childList:!0,subtree:!0})),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._schedule()),this._ro.observe(this)),this._headDirty=!0,this._rowsDirty=!0,this._schedule()}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick,!0),this.removeEventListener(`dblclick`,this._onDblClick),this.removeEventListener(`scroll`,this._onScroll),this._fonts?.removeEventListener(`loadingdone`,this._onFonts),this._fonts=null,this._mo?.disconnect(),this._ro?.disconnect(),this._mo=null,this._ro=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this._drag=null}refresh(){this._headDirty=!0,this._rowsDirty=!0,this._run()}get _table(){return this.querySelector(`:scope > table`)}_headCells(e){let t=e.tHead?.rows[0];return t?[...t.cells]:[]}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._run()})}_mutated(e){for(let t of e){let e=t.target.nodeType===1?t.target:t.target.parentElement;e&&((e.closest(`thead`)||e===this._table||e===this)&&(this._headDirty=!0),(e.closest(`tbody, tfoot`)||e===this._table||e===this)&&(this._rowsDirty=!0))}this._schedule()}_run(){let e=this._table;if(!e)return;let t=this._headDirty,n=this._rowsDirty;this._headDirty=!1,this._rowsDirty=!1,n&&this.hasAttribute(`group-by`)&&this._group(e),this._pins(e,t||n),this.hasAttribute(`resizable`)&&(t&&this._handles(e),this._layout(e)),this.hasAttribute(`virtual`)&&this._virtual(e,t||n),this._mo?.takeRecords()}_pins(t,r){let i=this._headCells(t),o=i.map(e=>{let t=e.dataset.pin;return t===`start`||t===`end`?t:e.matches(g)?`lead`:null});if(!o.some(e=>e===`start`||e===`end`))return;let s=e(o);s.forEach((e,t)=>{e&&this._ro?.observe(i[t])});let c=e=>i[e].getBoundingClientRect().width,u=0;s.forEach((e,r)=>{e?.side===`start`&&(this._setVar(t,n(`start`,e.ordinal),u),u+=c(r))}),u=0;for(let e=s.length-1;e>=0;e--){let r=s[e];r?.side===`end`&&(this._setVar(t,n(`end`,r.ordinal),u),u+=c(e))}if(r)for(let e of t.rows)e.matches(`${h}, .wui-row-expanded`)||e.cells.length!==i.length||s.forEach((t,n)=>{if(!t)return;let r=e.cells[n];r.classList.contains(`wui-pin-${t.side}`)||r.classList.add(`wui-pin-${t.side}`),t.edge&&!r.classList.contains(`wui-pin-${t.side}-edge`)&&r.classList.add(`wui-pin-${t.side}-edge`);let i=a(t.side,t.ordinal);r.style.getPropertyValue(`--wui-pin-at`)!==i&&r.style.setProperty(l,i)})}_setVar(e,t,n){let r=`${Math.round(n*100)/100}px`;e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}_resizable(e){return e.map((t,n)=>n<e.length-1&&!t.matches(g))}_handles(e){let t=this._headCells(e),n=this._resizable(t);t.forEach((e,t)=>{if(!n[t]||e.querySelector(m))return;let r=e.ownerDocument.createElement(`span`);r.className=`wui-col-resize`,r.setAttribute(`role`,`separator`),r.setAttribute(`aria-orientation`,`vertical`),r.setAttribute(`aria-valuemin`,`48`),r.setAttribute(`aria-valuemax`,String(f)),r.setAttribute(`tabindex`,`0`);let i=e.textContent.trim();r.setAttribute(`aria-label`,d.resize(i)),i&&!e.hasAttribute(`aria-label`)&&e.setAttribute(`aria-label`,i),e.classList.add(`wui-col-resizable`),e.appendChild(r)})}_hasRows(e){for(let t of e.tBodies)for(let e of t.rows)if(!e.matches(h)&&!v(e))return!0;return!1}_signature(e){return e.map(e=>e.dataset.key||e.textContent.trim()).join(``)}_layout(e){let t=this._headCells(e),n=this._signature(t);t.length&&n!==this._frozenSig&&(this._hasRows(e)?this._freeze(e,t,n):this._applyRemembered(t))}_applyRemembered(e){for(let t of e){let e=t.dataset.key&&this._widths[t.dataset.key];e&&(t.style.width=`${e}px`);let n=t.querySelector(m);n&&this._handleValue(n,c(e||t.getBoundingClientRect().width))}}_freeze(e,t,n){e.style.tableLayout=``,e.style.width=``,e.removeAttribute(`data-wui-fixed`);for(let e of t)e.hasAttribute(`data-wui-width`)&&(e.style.width=``,e.removeAttribute(`data-wui-width`));this._natural=t.map(e=>e.getBoundingClientRect().width),t.forEach((e,n)=>{if(n===t.length-1||e.matches(g))return;let r=e.dataset.key&&this._widths[e.dataset.key];this._setWidth(e,r||this._natural[n])}),e.style.tableLayout=`fixed`,e.setAttribute(`data-wui-fixed`,``),this._frozenSig=n,this._fitTable(e,t)}_setWidth(e,t){let n=c(t);e.style.width=`${n}px`,e.setAttribute(`data-wui-width`,``);let r=e.querySelector(m);return r&&this._handleValue(r,n),n}_handleValue(e,t){e.setAttribute(`aria-valuenow`,String(t)),e.setAttribute(`aria-valuetext`,d.width(t))}_fitTable(e,t){let n=t.length-1,r=this._natural[n]||0;for(let e=0;e<n;e++)r+=Number.parseFloat(t[e].style.width)||this._natural[e]||0;e.style.width=`max(100%, ${Math.round(r)}px)`}_ensureFrozen(e){let t=this._headCells(e),n=this._signature(t);return n!==this._frozenSig&&this._freeze(e,t,n),t}_resizeTo(e,t,n){let r=this._table;if(!r)return;let i=this._ensureFrozen(r);this._userSized=!0,this._setWidth(e,t),this._fitTable(r,i),n&&this._remember(e),this._pins(r,!1)}_remember(e){let n=e.dataset.key;n&&(this._widths={...this._widths,[n]:Number.parseFloat(e.style.width)},t(this.getAttribute(`view-key`),this._widths))}_reset(e){let n=this._table;if(!e||!n)return;let r=this._ensureFrozen(n);this._userSized=!0;let i=e.dataset.key;if(i&&i in this._widths){let{[i]:e,...n}=this._widths;this._widths=n,t(this.getAttribute(`view-key`),this._widths)}this._setWidth(e,this._natural[r.indexOf(e)]||0),this._fitTable(n,r),this._pins(n,!1)}_rtl(){return getComputedStyle(this).direction===`rtl`}_startDrag(e){let t=e.target.closest?.(m);if(!t||!this.contains(t)||e.button!==0)return;e.preventDefault(),e.stopPropagation();let n=t.closest(`th`),r=this._table;if(!n||!r)return;this._ensureFrozen(r);let i={th:n,x:e.clientX,from:n.getBoundingClientRect().width,dir:this._rtl()?-1:1,moved:!1};this._drag=i,t.setPointerCapture?.(e.pointerId),t.classList.add(`is-dragging`);let a=e=>{let t=(e.clientX-i.x)*i.dir;Math.abs(t)>1&&(i.moved=!0),this._resizeTo(n,i.from+t,!1)},o=e=>{t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o),t.classList.remove(`is-dragging`),this._drag=null,e.type===`pointercancel`?this._resizeTo(n,i.from,!1):i.moved&&this._remember(n),this._swallowClick=!0,setTimeout(()=>{this._swallowClick=!1},0)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}_key(e){let t=e.target.closest?.(m);if(!t||!this.contains(t))return;let n=t.closest(`th`);if(e.key===`Enter`||e.key===` `){e.preventDefault(),e.stopPropagation();return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),this._reset(n);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault(),e.stopPropagation();let r=this._table;if(!r)return;this._ensureFrozen(r);let i=e.shiftKey?50:10,a=e.key===`ArrowRight`!==this._rtl(),o=Number.parseFloat(n.style.width)||n.getBoundingClientRect().width;this._resizeTo(n,o+(a?i:-i),!0)}_click(e){let t=!!e.target.closest?.(m);if(this._swallowClick||t){e.stopPropagation(),(t||this._swallowClick)&&e.preventDefault(),this._swallowClick=!1;return}if(!this.hasAttribute(`group-by`))return;let n=(e.target.closest?.(`.wui-group-toggle`))?.closest(`.wui-group-row`);if(!n||!this.contains(n))return;let r=n.dataset.groupKey;this._collapsed.has(r)?this._collapsed.delete(r):this._collapsed.add(r),this._showGroup(n,!this._collapsed.has(r));let i=this._table;i&&this.hasAttribute(`virtual`)&&(this._virtual(i,!0),this._mo?.takeRecords())}_group(e){let t=this.getAttribute(`group-by`),n=this._headCells(e),r=n.findIndex(e=>e.dataset.key===t);if(r<0)throw Error(`<wui-data-table group-by="${t}"> needs a header cell with data-key="${t}".`);let a=e.tBodies[0];if(!a)return;let o=[...a.rows].filter(e=>!e.matches(h));if(o.some(v))return;let c=this.ownerDocument,l=new Map([...a.querySelectorAll(`:scope > tr.wui-group-row`)].map(e=>[e.dataset.groupKey,e])),u=i(o,e=>e.dataset.group??e.cells[r]?.textContent.trim()??``,this._groupOrder);this._groupOrder=u.map(e=>e.key);let f=c.createDocumentFragment(),p=u.map(e=>{let t=l.get(e.key)??this._groupRow(c,e.key);return l.delete(e.key),t.querySelector(`.wui-group-cell`).colSpan=n.length,t.querySelector(`.wui-group-count`).textContent=s(e.items.length),t.querySelector(`.wui-group-rows`).textContent=`, ${d.rows(e.items.length)}`,f.append(t,...e.items),[t,e.key]});for(let e of l.values())e.remove();a.insertBefore(f,this._bottom?.parentNode===a?this._bottom:null);for(let[e,t]of p)this._showGroup(e,!this._collapsed.has(t))}_groupRow(e,t){let n=e.createElement(`tr`);n.className=`wui-group-row`,n.dataset.groupKey=t;let r=e.createElement(`th`);r.className=`wui-group-cell`,r.scope=`rowgroup`;let i=e.createElement(`button`);i.type=`button`,i.className=`wui-group-toggle`,i.innerHTML=_;let a=e.createElement(`span`);a.className=`wui-group-label`,a.textContent=t;let o=e.createElement(`span`);o.className=`wui-group-count`,o.setAttribute(`aria-hidden`,`true`);let s=e.createElement(`span`);return s.className=`visually-hidden wui-group-rows`,i.append(a,o,s),r.append(i),n.append(r),n}_showGroup(e,t){if(e){e.querySelector(`.wui-group-toggle`)?.setAttribute(`aria-expanded`,String(t));for(let n=e.nextElementSibling;n&&!n.matches(h);n=n.nextElementSibling)n.hidden=!t}}_spacer(e,t){if(t?.parentNode===e)return t;let n=e.ownerDocument,r=n.createElement(`tr`);return r.className=`wui-virtual-spacer`,r.setAttribute(`aria-hidden`,`true`),r.append(n.createElement(`td`)),r}_virtual(e,t){let n=e.tBodies[0];if(!n)return;if(t){this._top=this._spacer(n,this._top),this._bottom=this._spacer(n,this._bottom),n.firstElementChild!==this._top&&n.insertBefore(this._top,n.firstChild),n.lastElementChild!==this._bottom&&n.append(this._bottom);let t=Math.max(1,this._headCells(e).length);this._top.cells[0].colSpan=t,this._bottom.cells[0].colSpan=t,this._items=[...n.rows].filter(e=>!e.classList.contains(`wui-virtual-spacer`)&&!e.hidden),this._range=null,e.setAttribute(`aria-rowcount`,String(this._items.length+1)),e.tHead?.rows[0]?.setAttribute(`aria-rowindex`,`1`),this._items.forEach((e,t)=>{e.setAttribute(`aria-rowindex`,String(t+2))}),this._rowHeight>0||(this._rowHeight=this._measureRow(e))}let r=e.tHead?.getBoundingClientRect().height||0,i=u({scrollTop:this.scrollTop-r,viewport:this.clientHeight,rowHeight:this._rowHeight,count:this._items.length}),a=this._range;if(a&&a.start===i.start&&a.end===i.end)return;let o=a?Math.min(a.start,i.start):0,s=a?Math.max(a.end,i.end):this._items.length;for(let e=o;e<s;e++){let t=e<i.start||e>=i.end,n=this._items[e];n.classList.contains(`wui-virtual-off`)!==t&&n.classList.toggle(`wui-virtual-off`,t)}this._range=i,this._top.hidden=i.before===0,this._bottom.hidden=i.after===0,this._top.cells[0].style.height=`${i.before}px`,this._bottom.cells[0].style.height=`${i.after}px`}_measureRow(e){let t=this._items.find(e=>!e.classList.contains(`wui-group-row`)&&!e.classList.contains(`wui-virtual-off`))?.getBoundingClientRect().height;return t>0?t:e.classList.contains(`wui-table-compact`)?o.compact:e.classList.contains(`wui-table-cozy`)?o.cozy:o.comfortable}};export{y as t};
|
|
1
|
+
import{C as e,M as t,S as n,T as r,_ as i,b as a,c as o,g as s,h as c,i as l,j as u,r as d,t as f}from"./dataTable-BGZc5iC1.js";import{t as p}from"./elementBase-DV9IZZCu.js";var m=`.wui-col-resize`,h=`.wui-group-row, .wui-virtual-spacer`,g=`.wui-select-cell, .wui-expand-cell`,_=`<svg class="wui-icon" data-icon="chevron-down" data-wui="AppIcon" width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="1.5" d="M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95"></path></svg>`,v=e=>e.hasAttribute(`data-wui-skeleton`)||!!e.querySelector(`:scope > td > .skeleton`),y=class extends p{constructor(){super(),this._frame=0,this._headDirty=!0,this._rowsDirty=!0,this._frozenSig=null,this._natural=[],this._widths={},this._collapsed=/* @__PURE__ */ new Set,this._groupOrder=[],this._items=[],this._range=null,this._drag=null,this._userSized=!1,this._swallowClick=!1,this._mo=null,this._ro=null,this._fonts=null,this._onPointerDown=e=>this._startDrag(e),this._onKeyDown=e=>this._key(e),this._onClick=e=>this._click(e),this._onDblClick=e=>{let t=e.target.closest?.(m);t&&this.contains(t)&&this._reset(t.closest(`th`))},this._onScroll=()=>{this.hasAttribute(`virtual`)&&this._schedule()},this._onFonts=()=>{this._userSized||this._drag||this._frozenSig===null||!this.hasAttribute(`resizable`)||(this._frozenSig=null,this._schedule())}}connectedCallback(){this._widths=r(this.getAttribute(`view-key`)),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick,!0),this.addEventListener(`dblclick`,this._onDblClick),this.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._fonts=this.ownerDocument.fonts??null,this._fonts?.addEventListener(`loadingdone`,this._onFonts),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(e=>this._mutated(e)),this._mo.observe(this,{childList:!0,subtree:!0})),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._schedule()),this._ro.observe(this)),this._headDirty=!0,this._rowsDirty=!0,this._schedule()}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick,!0),this.removeEventListener(`dblclick`,this._onDblClick),this.removeEventListener(`scroll`,this._onScroll),this._fonts?.removeEventListener(`loadingdone`,this._onFonts),this._fonts=null,this._mo?.disconnect(),this._ro?.disconnect(),this._mo=null,this._ro=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this._drag=null}refresh(){this._headDirty=!0,this._rowsDirty=!0,this._run()}get _table(){return this.querySelector(`:scope > table`)}_headCells(e){let t=e.tHead?.rows[0];return t?[...t.cells]:[]}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._run()})}_mutated(e){for(let t of e){let e=t.target.nodeType===1?t.target:t.target.parentElement;e&&((e.closest(`thead`)||e===this._table||e===this)&&(this._headDirty=!0),(e.closest(`tbody, tfoot`)||e===this._table||e===this)&&(this._rowsDirty=!0))}this._schedule()}_run(){let e=this._table;if(!e)return;let t=this._headDirty,n=this._rowsDirty;this._headDirty=!1,this._rowsDirty=!1,n&&this.hasAttribute(`group-by`)&&this._group(e),this._pins(e,t||n),this.hasAttribute(`resizable`)&&(t&&this._handles(e),this._layout(e)),this.hasAttribute(`virtual`)&&this._virtual(e,t||n),this._mo?.takeRecords()}_pins(t,r){let i=this._headCells(t),o=i.map(e=>{let t=e.dataset.pin;return t===`start`||t===`end`?t:e.matches(g)?`lead`:null});if(!o.some(e=>e===`start`||e===`end`))return;let s=e(o);s.forEach((e,t)=>{e&&this._ro?.observe(i[t])});let c=e=>i[e].getBoundingClientRect().width,u=0;s.forEach((e,r)=>{e?.side===`start`&&(this._setVar(t,n(`start`,e.ordinal),u),u+=c(r))}),u=0;for(let e=s.length-1;e>=0;e--){let r=s[e];r?.side===`end`&&(this._setVar(t,n(`end`,r.ordinal),u),u+=c(e))}if(r)for(let e of t.rows)e.matches(`${h}, .wui-row-expanded`)||e.cells.length!==i.length||s.forEach((t,n)=>{if(!t)return;let r=e.cells[n];r.classList.contains(`wui-pin-${t.side}`)||r.classList.add(`wui-pin-${t.side}`),t.edge&&!r.classList.contains(`wui-pin-${t.side}-edge`)&&r.classList.add(`wui-pin-${t.side}-edge`);let i=a(t.side,t.ordinal);r.style.getPropertyValue(`--wui-pin-at`)!==i&&r.style.setProperty(l,i)})}_setVar(e,t,n){let r=`${Math.round(n*100)/100}px`;e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}_resizable(e){return e.map((t,n)=>n<e.length-1&&!t.matches(g))}_handles(e){let t=this._headCells(e),n=this._resizable(t);t.forEach((e,t)=>{if(!n[t]||e.querySelector(m))return;let r=e.ownerDocument.createElement(`span`);r.className=`wui-col-resize`,r.setAttribute(`role`,`separator`),r.setAttribute(`aria-orientation`,`vertical`),r.setAttribute(`aria-valuemin`,`48`),r.setAttribute(`aria-valuemax`,String(f)),r.setAttribute(`tabindex`,`0`);let i=e.textContent.trim();r.setAttribute(`aria-label`,d.resize(i)),i&&!e.hasAttribute(`aria-label`)&&e.setAttribute(`aria-label`,i),e.classList.add(`wui-col-resizable`),e.appendChild(r)})}_hasRows(e){for(let t of e.tBodies)for(let e of t.rows)if(!e.matches(h)&&!v(e))return!0;return!1}_signature(e){return e.map(e=>e.dataset.key||e.textContent.trim()).join(``)}_layout(e){let t=this._headCells(e),n=this._signature(t);t.length&&n!==this._frozenSig&&(this._hasRows(e)?this._freeze(e,t,n):this._applyRemembered(t))}_applyRemembered(e){for(let t of e){let e=t.dataset.key&&this._widths[t.dataset.key];e&&(t.style.width=`${e}px`);let n=t.querySelector(m);n&&this._handleValue(n,c(e||t.getBoundingClientRect().width))}}_freeze(e,t,n){e.style.tableLayout=``,e.style.width=``,e.removeAttribute(`data-wui-fixed`);for(let e of t)e.hasAttribute(`data-wui-width`)&&(e.style.width=``,e.removeAttribute(`data-wui-width`));this._natural=t.map(e=>e.getBoundingClientRect().width),t.forEach((e,n)=>{if(n===t.length-1||e.matches(g))return;let r=e.dataset.key&&this._widths[e.dataset.key];this._setWidth(e,r||this._natural[n])}),e.style.tableLayout=`fixed`,e.setAttribute(`data-wui-fixed`,``),this._frozenSig=n,this._fitTable(e,t)}_setWidth(e,t){let n=c(t);e.style.width=`${n}px`,e.setAttribute(`data-wui-width`,``);let r=e.querySelector(m);return r&&this._handleValue(r,n),n}_handleValue(e,t){e.setAttribute(`aria-valuenow`,String(t)),e.setAttribute(`aria-valuetext`,d.width(t))}_fitTable(e,t){let n=t.length-1,r=this._natural[n]||0;for(let e=0;e<n;e++)r+=Number.parseFloat(t[e].style.width)||this._natural[e]||0;e.style.width=`max(100%, ${Math.round(r)}px)`}_ensureFrozen(e){let t=this._headCells(e),n=this._signature(t);return n!==this._frozenSig&&this._freeze(e,t,n),t}_resizeTo(e,t,n){let r=this._table;if(!r)return;let i=this._ensureFrozen(r);this._userSized=!0,this._setWidth(e,t),this._fitTable(r,i),n&&this._remember(e),this._pins(r,!1)}_remember(e){let n=e.dataset.key;n&&(this._widths={...this._widths,[n]:Number.parseFloat(e.style.width)},t(this.getAttribute(`view-key`),this._widths))}_reset(e){let n=this._table;if(!e||!n)return;let r=this._ensureFrozen(n);this._userSized=!0;let i=e.dataset.key;if(i&&i in this._widths){let{[i]:e,...n}=this._widths;this._widths=n,t(this.getAttribute(`view-key`),this._widths)}this._setWidth(e,this._natural[r.indexOf(e)]||0),this._fitTable(n,r),this._pins(n,!1)}_rtl(){return getComputedStyle(this).direction===`rtl`}_startDrag(e){let t=e.target.closest?.(m);if(!t||!this.contains(t)||e.button!==0)return;e.preventDefault(),e.stopPropagation();let n=t.closest(`th`),r=this._table;if(!n||!r)return;this._ensureFrozen(r);let i={th:n,x:e.clientX,from:n.getBoundingClientRect().width,dir:this._rtl()?-1:1,moved:!1};this._drag=i,t.setPointerCapture?.(e.pointerId),t.classList.add(`is-dragging`);let a=e=>{let t=(e.clientX-i.x)*i.dir;Math.abs(t)>1&&(i.moved=!0),this._resizeTo(n,i.from+t,!1)},o=e=>{t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o),t.classList.remove(`is-dragging`),this._drag=null,e.type===`pointercancel`?this._resizeTo(n,i.from,!1):i.moved&&this._remember(n),this._swallowClick=!0,setTimeout(()=>{this._swallowClick=!1},0)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}_key(e){let t=e.target.closest?.(m);if(!t||!this.contains(t))return;let n=t.closest(`th`);if(e.key===`Enter`||e.key===` `){e.preventDefault(),e.stopPropagation();return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),this._reset(n);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault(),e.stopPropagation();let r=this._table;if(!r)return;this._ensureFrozen(r);let i=e.shiftKey?50:10,a=e.key===`ArrowRight`!==this._rtl(),o=Number.parseFloat(n.style.width)||n.getBoundingClientRect().width;this._resizeTo(n,o+(a?i:-i),!0)}_click(e){let t=!!e.target.closest?.(m);if(this._swallowClick||t){e.stopPropagation(),(t||this._swallowClick)&&e.preventDefault(),this._swallowClick=!1;return}if(!this.hasAttribute(`group-by`))return;let n=(e.target.closest?.(`.wui-group-toggle`))?.closest(`.wui-group-row`);if(!n||!this.contains(n))return;let r=n.dataset.groupKey;this._collapsed.has(r)?this._collapsed.delete(r):this._collapsed.add(r),this._showGroup(n,!this._collapsed.has(r));let i=this._table;i&&this.hasAttribute(`virtual`)&&(this._virtual(i,!0),this._mo?.takeRecords())}_group(e){let t=this.getAttribute(`group-by`),n=this._headCells(e),r=n.findIndex(e=>e.dataset.key===t);if(r<0)throw Error(`<wui-data-table group-by="${t}"> needs a header cell with data-key="${t}".`);let a=e.tBodies[0];if(!a)return;let o=[...a.rows].filter(e=>!e.matches(h));if(o.some(v))return;let c=this.ownerDocument,l=new Map([...a.querySelectorAll(`:scope > tr.wui-group-row`)].map(e=>[e.dataset.groupKey,e])),u=i(o,e=>e.dataset.group??e.cells[r]?.textContent.trim()??``,this._groupOrder);this._groupOrder=u.map(e=>e.key);let f=c.createDocumentFragment(),p=u.map(e=>{let t=l.get(e.key)??this._groupRow(c,e.key);return l.delete(e.key),t.querySelector(`.wui-group-cell`).colSpan=n.length,t.querySelector(`.wui-group-count`).textContent=s(e.items.length),t.querySelector(`.wui-group-rows`).textContent=`, ${d.rows(e.items.length)}`,f.append(t,...e.items),[t,e.key]});for(let e of l.values())e.remove();a.insertBefore(f,this._bottom?.parentNode===a?this._bottom:null);for(let[e,t]of p)this._showGroup(e,!this._collapsed.has(t))}_groupRow(e,t){let n=e.createElement(`tr`);n.className=`wui-group-row`,n.dataset.groupKey=t;let r=e.createElement(`th`);r.className=`wui-group-cell`,r.scope=`rowgroup`;let i=e.createElement(`button`);i.type=`button`,i.className=`wui-group-toggle`,i.innerHTML=_;let a=e.createElement(`span`);a.className=`wui-group-label`,a.textContent=t;let o=e.createElement(`span`);o.className=`wui-group-count`,o.setAttribute(`aria-hidden`,`true`);let s=e.createElement(`span`);return s.className=`visually-hidden wui-group-rows`,i.append(a,o,s),r.append(i),n.append(r),n}_showGroup(e,t){if(e){e.querySelector(`.wui-group-toggle`)?.setAttribute(`aria-expanded`,String(t));for(let n=e.nextElementSibling;n&&!n.matches(h);n=n.nextElementSibling)n.hidden=!t}}_spacer(e,t){if(t?.parentNode===e)return t;let n=e.ownerDocument,r=n.createElement(`tr`);return r.className=`wui-virtual-spacer`,r.setAttribute(`aria-hidden`,`true`),r.append(n.createElement(`td`)),r}_virtual(e,t){let n=e.tBodies[0];if(!n)return;if(t){this._top=this._spacer(n,this._top),this._bottom=this._spacer(n,this._bottom),n.firstElementChild!==this._top&&n.insertBefore(this._top,n.firstChild),n.lastElementChild!==this._bottom&&n.append(this._bottom);let t=Math.max(1,this._headCells(e).length);this._top.cells[0].colSpan=t,this._bottom.cells[0].colSpan=t,this._items=[...n.rows].filter(e=>!e.classList.contains(`wui-virtual-spacer`)&&!e.hidden),this._range=null,e.setAttribute(`aria-rowcount`,String(this._items.length+1)),e.tHead?.rows[0]?.setAttribute(`aria-rowindex`,`1`),this._items.forEach((e,t)=>{e.setAttribute(`aria-rowindex`,String(t+2))}),this._rowHeight>0||(this._rowHeight=this._measureRow(e))}let r=e.tHead?.getBoundingClientRect().height||0,i=u({scrollTop:this.scrollTop-r,viewport:this.clientHeight,rowHeight:this._rowHeight,count:this._items.length}),a=this._range;if(a&&a.start===i.start&&a.end===i.end)return;let o=a?Math.min(a.start,i.start):0,s=a?Math.max(a.end,i.end):this._items.length;for(let e=o;e<s;e++){let t=e<i.start||e>=i.end,n=this._items[e];n.classList.contains(`wui-virtual-off`)!==t&&n.classList.toggle(`wui-virtual-off`,t)}this._range=i,this._top.hidden=i.before===0,this._bottom.hidden=i.after===0,this._top.cells[0].style.height=`${i.before}px`,this._bottom.cells[0].style.height=`${i.after}px`}_measureRow(e){let t=this._items.find(e=>!e.classList.contains(`wui-group-row`)&&!e.classList.contains(`wui-virtual-off`))?.getBoundingClientRect().height;return t>0?t:e.classList.contains(`wui-table-compact`)?o.compact:e.classList.contains(`wui-table-cozy`)?o.cozy:o.comfortable}};export{y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./calendarMath-BC2wGCD-.js";import{t}from"./elementBase-DV9IZZCu.js";import"./formatters-
|
|
1
|
+
import{o as e}from"./calendarMath-BC2wGCD-.js";import{t}from"./elementBase-DV9IZZCu.js";import"./formatters-Ba0CvsTs.js";import{l as n}from"./wuiHttp-DgnM7K2Q.js";var r=Object.freeze([`text`,`number`,`select`,`date`,`textarea`]),i=2e3,a=Object.freeze({edit:e=>`Edit ${e}: `,readOnly:e=>`${e}: `,saved:e=>`${e} saved.`,notSaved:(e,t)=>`${e} was not saved. ${t}`,failed:Object.freeze({forbidden:`You do not have permission to change this.`,client:`This could not be saved. Refresh the page and try again.`,validation:`This value was not accepted. Check it and try again.`,server:`Something went wrong on our side, so this was not saved. Try again in a moment.`,network:`Could not reach the server, so this was not saved. Check your connection and try again.`})});function o(t,{type:n=`text`,options:r,placeholder:i}={}){let a=t==null?``:String(t);if(a===``)return{text:i||`-`,empty:!0};if(n===`date`)return{text:e(a)||a,empty:!1};if(n===`select`){let e=r?.find(e=>String(e.value)===a);return{text:typeof e?.label==`string`?e.label:a,empty:!1}}return{text:a,empty:!1}}var s=`[data-wui-display]`,c=`[data-wui-value]`,l=`[data-wui-editor]`,u=`[data-wui-control]`,d=`[data-wui-error]`,f=`[data-wui-live]`,p=`[aria-expanded="true"]`,m=/* @__PURE__ */ new Set([`select`,`date`]),h=e=>typeof e?.message==`string`&&e.message?e.message:a.failed.server,g=class extends t{static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=this.querySelector(s),t=this.querySelector(l),n=this._control();e&&t&&n&&(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._focusControl(n),e.hidden=!0)}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_onClick(e){e.stopPropagation(),e.type===`click`&&!this._editing&&this.querySelector(s)?.contains(e.target)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(l)?.querySelector(p))}_onKeyDown(e){if(!this._editing){(e.key===`Enter`||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||m.has(t)||(t!==`textarea`||e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!m.has(this._type()))return;let t=this._control();t&&e.target===t&&queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let o=r?null:this._readShown();r||this._showValue(e),this._close();let s=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let c=this.getAttribute(`label`)||``;s.ok?(this.setAttribute(`value`,e),!r&&s.text&&this._showText(s.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),i),this._announce(a.saved(c)),this._fire(`wui:inline-edit:saved`,{value:e,previous:t})):(o&&this._restoreShown(o),s.kind===`session`||s.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(s.message),this._announce(a.notSaved(c,s.message)),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:s.kind,message:s.message})))}async _persist(e,t){if(t){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:h(e)}}}let r=this.getAttribute(`action`);if(!r)return{ok:!0};let i=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),o=await n(r,{method:`POST`,body:i});return o.ok?{ok:!0,text:o.html.trim()}:{ok:!1,kind:o.kind,message:o.message||a.failed[o.kind]||a.failed.server}}_close(){let e=this.querySelector(s),t=this.querySelector(l),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),t?.querySelector(p)?.click(),n&&e?.focus()}_focusControl(e){if(!m.has(this._type())){e.focus(),e.select?.();return}let t=e.querySelector(`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(t){if(t===``){this._showText(this.getAttribute(`placeholder`)||`-`,!0);return}let n=this._type(),r=t;if(n===`date`)r=e(t)||t;else if(n===`select`){let e=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(e=>e.getAttribute(`data-value`)===t);e&&(r=e.textContent.trim())}this._showText(r,!1)}_readShown(){let e=this.querySelector(c);return e?{html:e.innerHTML,empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(c);t&&(t.innerHTML=e.html,t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(c);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=this.querySelector(d),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(f);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){return this.querySelector(u)}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return r.includes(e)?e:`text`}};export{o as a,g as i,a as n,r,i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-DV9IZZCu.js";import{f as t}from"./formatters-
|
|
1
|
+
import{t as e}from"./elementBase-DV9IZZCu.js";import{f as t}from"./formatters-Ba0CvsTs.js";import{t as n}from"./iconGlyphs.g-gURMSeyB.js";var r=`a.wui-lightbox-item`,i=1,a=4,o=.5,s=2,c=50,l=6,u=300,d=300;function f(e){return Number.isFinite(e)?Math.min(a,Math.max(i,e)):i}function p(e,t,n,r){let i=(e,n)=>Math.max(0,(e*t-n)/2),a=i(r.width,n.width),o=i(r.height,n.height);return{x:Math.min(a,Math.max(-a,e.x)),y:Math.min(o,Math.max(-o,e.y))}}function m(e,t){return Math.abs(e)<c||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function h(e){let t=String(e??``).split(/[?#]/)[0].split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}function g(e,t,n={}){let r=document.createElement(e);r.className=t;for(let[e,t]of Object.entries(n))r.setAttribute(e,t);return r}function _(e,t,r){let i=g(`button`,`u-action wui-lightbox-btn ${r}`,{type:`button`,"aria-label":t,title:t});return i.style.setProperty(`--wui-action-size`,`40px`),i.innerHTML=n(e,{size:20}),i}var v=class extends e{static get observedAttributes(){return[`open-index`]}constructor(){super(),this._ui=null,this._index=0,this._zoom=i,this._pan={x:0,y:0},this._pointers=/* @__PURE__ */ new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._lockedOverflow=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target?.closest?.(r);if(!t||!this.contains(t))return;let n=this._links().indexOf(t);n<0||(e.preventDefault(),this.open(n))}}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||`Image viewer`}set label(e){this.setAttribute(`label`,String(e??``))}get layout(){return this.getAttribute(`layout`)===`single`?`single`:`gallery`}set layout(e){if(e===`single`)this.setAttribute(`layout`,`single`);else if(e===`gallery`||e===``)this.removeAttribute(`layout`);else throw Error(`<wui-lightbox> layout must be "gallery" or "single", received "${e}".`)}get isOpen(){return this._ui!==null}connectedCallback(){this.addEventListener(`click`,this._onClick),this._syncOpenIndex()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this._teardown()}attributeChangedCallback(){this.isConnected&&this._syncOpenIndex()}_syncOpenIndex(){let e=this.getAttribute(`open-index`);e===null?this.close():this.open(Number(e))}_links(){return[...this.querySelectorAll(r)]}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||h(t)}})}open(e=0){let t=this._items();return t.length?(this._ui||(this._returnTo=document.activeElement,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))),this._show(e,t),this._ui.close.focus(),!0):!1}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null,this._lockedOverflow!==null&&(document.documentElement.style.overflow=this._lockedOverflow,this._lockedOverflow=null))}_build(){let e=g(`div`,`wui-lightbox-overlay`,{role:`dialog`,"aria-modal":`true`,"aria-label":this.label,tabindex:`-1`}),t=g(`div`,`wui-lightbox-bar`),r=g(`span`,`wui-lightbox-count`,{"aria-live":`polite`}),i=g(`div`,`wui-lightbox-tools`),a=_(`zoom-out`,`Zoom out`,`wui-lightbox-zoom-out`),s=_(`zoom-in`,`Zoom in`,`wui-lightbox-zoom-in`),c=g(`a`,`u-action wui-lightbox-btn wui-lightbox-download`,{"aria-label":`Download`,title:`Download`});c.style.setProperty(`--wui-action-size`,`40px`),c.innerHTML=n(`download`,{size:20}),c.hidden=!this.download;let l=_(`x`,`Close`,`wui-lightbox-close`);i.append(a,s,c,l),t.append(r,i);let u=g(`div`,`wui-lightbox-stage`),d=_(`chevron-left`,`Previous image`,`wui-lightbox-nav wui-lightbox-prev`),f=_(`chevron-right`,`Next image`,`wui-lightbox-nav wui-lightbox-next`),p=g(`img`,`wui-lightbox-image`,{decoding:`async`,draggable:`false`,alt:``}),m=g(`p`,`wui-lightbox-status`,{role:`status`});u.append(p,m,d,f);let h=g(`p`,`wui-lightbox-caption`);e.append(t,u,h);let v={root:e,count:r,zoomOut:a,zoomIn:s,download:c,close:l,stage:u,prev:d,next:f,image:p,status:m,caption:h};this._ui=v,l.addEventListener(`click`,()=>this.close()),d.addEventListener(`click`,()=>this.step(-1)),f.addEventListener(`click`,()=>this.step(1)),a.addEventListener(`click`,()=>this._setZoom(this._zoom-o)),s.addEventListener(`click`,()=>this._setZoom(this._zoom+o)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),u.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),u.addEventListener(`pointermove`,e=>this._onPointerMove(e)),u.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),u.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),u.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),p.addEventListener(`load`,()=>{this._ui===v&&(m.textContent=``,u.removeAttribute(`aria-busy`),p.hidden=!1,this._applyTransform())}),p.addEventListener(`error`,()=>{this._ui===v&&(u.removeAttribute(`aria-busy`),p.hidden=!0,m.textContent=`This image can't be shown.`)}),this.append(e),this._lockedOverflow=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`}step(e){if(!this._ui||!e)return;let t=this._items();t.length<2||this._show((this._index+e+t.length)%t.length,t)}_show(e,n){let r=this._ui,a=Math.min(n.length-1,Math.max(0,Math.trunc(Number(e))||0)),o=n[a],s=a!==this._index||!r.image.getAttribute(`src`);if(this._index=a,this._zoom=i,this._pan={x:0,y:0},r.count.textContent=`${t(a+1,{decimals:0})} of ${t(n.length,{decimals:0})}`,r.caption.textContent=o.caption,r.caption.hidden=!o.caption,r.download.href=o.src,r.download.setAttribute(`download`,o.name),r.prev.hidden=r.next.hidden=n.length<2,r.stage.setAttribute(`aria-busy`,`true`),r.status.textContent=``,r.image.hidden=!1,r.image.alt=o.alt||o.caption,r.image.src=o.src,this._applyTransform(),this._syncZoomButtons(),n.length>1)for(let e of[n[(a+1)%n.length],n[(a-1+n.length)%n.length]])new Image().src=e.src;s&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:a}}))}_syncZoomButtons(){this._ui.zoomOut.disabled=this._zoom<=i,this._ui.zoomIn.disabled=this._zoom>=a;let e=document.activeElement;(e===this._ui.zoomOut||e===this._ui.zoomIn)&&e.disabled&&this._ui.close.focus()}_setZoom(e){this._ui&&(this._zoom=f(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._ui;return p(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._ui;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>i)}_onKeyDown(e){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this.close();else if(e.key===`Tab`)this._trapTab(e);else if(e.key===`ArrowLeft`||e.key===`ArrowRight`)e.preventDefault(),this.step(e.key===`ArrowRight`?1:-1);else if(e.key===`Home`||e.key===`End`){e.preventDefault();let t=this._items();this._show(e.key===`Home`?0:t.length-1,t)}else e.key===`+`||e.key===`=`?(e.preventDefault(),this._setZoom(this._zoom+o)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-o)):e.key===`0`&&(e.preventDefault(),this._setZoom(i))}_trapTab(e){let t=[...this._ui.root.querySelectorAll(`button, a[href]`)].filter(e=>!e.hidden&&!e.disabled);if(!t.length){e.preventDefault();return}let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||!this._ui.root.contains(i))?(e.preventDefault(),r.focus()):e.shiftKey||i!==r&&this._ui.root.contains(i)||(e.preventDefault(),n.focus())}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){if(!e.target.closest(`.wui-lightbox-nav`)){if(this._ui.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let[e,t]=[...this._pointers.values()];this._gesture={kind:`pinch`,distance:Math.hypot(e.x-t.x,e.y-t.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===this._ui.image,moved:!1})}}_onPointerMove(e){let t=this._gesture;if(t&&this._pointers.has(e.pointerId)){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let[e,n]=[...this._pointers.values()];this._setZoom(t.zoom*Math.hypot(e.x-n.x,e.y-n.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>l&&(t.moved=!0),this._zoom>i&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._ui.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,a=e.clientY-n.startY;n.moved?this._zoom===i&&this.step(m(r,a)):e.timeStamp-n.startTime>u||(n.onImage?e.timeStamp-this._lastTap<d?(this._lastTap=-1/0,this._setZoom(this._zoom>i?i:s)):this._lastTap=e.timeStamp:this.close())}};export{v as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./anchorOverlay-CBMAnDUt.js";import{t as r}from"./elementBase-DV9IZZCu.js";import{n as i,r as a,t as o}from"./fieldState-D-zQcXUS.js";import{f as s}from"./formatters-D1zbsEJJ.js";import{n as c}from"./listboxKeyNav-DMIvs9d6.js";import{l}from"./wuiHttp-DgnM7K2Q.js";var u=/^[A-Za-z0-9_.:-]{1,64}$/,d=/@(\\+)\[|@\[([^[\]\n]{1,100})\]\(([A-Za-z0-9_.:-]{1,64})\)/g,f=/@(\\*)\[/g;function p(e){return String(e??``).replace(/[[\]\r\n]+/g,` `).replace(/\s+/g,` `).trim().slice(0,100)}var m=e=>e.replace(f,(e,t)=>`@\\${t}[`);function h(e){let t=String(e??``),n=[],r=e=>{if(!e)return;let t=n[n.length-1];t&&`text`in t?t.text+=e:n.push({text:e})},i=0;for(let e of t.matchAll(d))r(t.slice(i,e.index)),e[1]===void 0?n.push({id:e[3],label:e[2]}):r(`@${e[1].slice(1)}[`),i=e.index+e[0].length;return r(t.slice(i)),n}function g(e){let t=``,n=[];for(let r of h(e)){if(`text`in r){t+=r.text;continue}let e=`@${r.label}`;n.push({start:t.length,end:t.length+e.length,id:r.id,label:r.label}),t+=e}return{text:t,mentions:n}}function _(e,t=[]){let n=String(e??``),r=[...t].sort((e,t)=>e.start-t.start),i=``,a=0;for(let e of r)e.start<a||n.slice(e.start,e.end)!==`@${e.label}`||!u.test(e.id)||(i+=m(n.slice(a,e.start)),i+=`@[${e.label}](${e.id})`,a=e.end);return i+m(n.slice(a))}function v(e){let t=[];for(let n of h(e))`id`in n&&!t.includes(n.id)&&t.push(n.id);return t}var y=8,b=40,x=Object.freeze({listName:`People`,searching:`Searching…`,noMatch:`No one matches`,found:e=>`${e===1?`1 person`:`${s(e,{decimals:0})} people`}. Up and down to choose, Enter to mention.`,mentioned:e=>`Mentioned ${e}.`}),S=`[data-wui-control]`,C=`[data-wui-field]`,w=`[data-wui-menu]`,T=`[data-wui-live]`,E=0,D=e=>e&&u.test(String(e.value??``))&&p(e.label)!==``;function O(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`input-sm`,n===`sm`),t.classList.toggle(`input-lg`,n===`lg`)}function k(e,t){t.readOnly=i(e)||e.hasAttribute(`loading`)}function A(e){let t=e.ownerDocument;e.id||=`wui-mention-${++E}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control textarea wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),k(e,n),O(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??x.listName),o.setAttribute(`data-wui-menu`,``),o.hidden=!0,e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var j=class extends r{static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._query=null,this._results=[],this._active=-1,this._timer=null,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this),this._reposition=()=>{this._isOpen()&&this._position()}}connectedCallback(){for(let e of[`people`,`loading`,`value`])if(Object.hasOwn(this,e)){let t=this[e];delete this[e],this[e]=t}if(this._wired)return;this._wired=!0,this.querySelector(S)||A(this);let e=this._control(),t=this.querySelector(C)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._menu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target.closest?.(`.wui-mention-option`);t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(k(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(k(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?O(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return _(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=/* @__PURE__ */ new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(D):[],(this._isOpen()||this._query!==null)&&this._refresh()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(S)}_menu(){return this.querySelector(w)}_load(e){let{text:t,mentions:n}=g(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(C);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._control(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e?.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||o(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,r=n.lastIndexOf(`@`,t-1);if(r<0||r>0&&!/[\s([{"'“‘]/.test(n[r-1]))return null;let i=n.slice(r+1,t);return i.length>40||/[\n@]/.test(i)||/^\s/.test(i)||/\s{2}/.test(i)||this._mentions.some(e=>r>=e.start&&r<e.end)?null:{start:r,end:t,text:i}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>p(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,a=await l(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this.loading=!1;return}let o=this.ownerDocument.createElement(`template`);o.innerHTML=a.html,this._peopleProp=[...o.content.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(D),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return!(!e||e.hidden)}_renderMenu(){let t=this._menu(),n=this._control();if(!t||!n||!this._query)return;this._syncState();let r=this.ownerDocument;if(t.replaceChildren(),this._results.forEach((e,n)=>{let i=r.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${t.id}-${n}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(n),e.src){let t=r.createElement(`img`);t.className=`wui-mention-option-photo`,t.src=e.src,t.alt=``,i.appendChild(t)}let a=r.createElement(`span`);a.className=`wui-mention-option-text`;let o=r.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=p(e.label),a.appendChild(o),e.description){let t=r.createElement(`span`);t.className=`wui-mention-option-description`,t.textContent=String(e.description),a.appendChild(t)}i.appendChild(a),t.appendChild(i)}),!this._results.length){let e=r.createElement(`div`);e.className=`wui-mention-empty`,e.textContent=this.loading?x.searching:`${x.noMatch} “${this._query.text}”`,t.appendChild(e)}let i=this._isOpen();t.hidden=!1,i||e(this,this._reposition),this._position(),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?x.found(this._results.length):`${x.noMatch}.`)}_syncState(){let e=this._control();e&&a(this,e)}_position(){n(this._control(),this._menu())}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();e&&!e.hidden&&(e.hidden=!0,e.replaceChildren()),this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`),t(this)}_setActive(e,{reveal:t=!0}={}){let n=this._menu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);c(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._control().setAttribute(`aria-activedescendant`,i.id)):this._control().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._control();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target.closest?.(`.wui-mention-option`);t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=p(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(x.mentioned(t))}_replace(e,t,n,r){let i=this._control(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(T);t&&(t.textContent=``,t.textContent=e)}};export{u as a,_ as c,j as i,v as l,y as n,p as o,x as r,g as s,b as t,h as u};
|
|
1
|
+
import{n as e,r as t,t as n}from"./anchorOverlay-CBMAnDUt.js";import{t as r}from"./elementBase-DV9IZZCu.js";import{n as i,r as a,t as o}from"./fieldState-D-zQcXUS.js";import{f as s}from"./formatters-Ba0CvsTs.js";import{n as c}from"./listboxKeyNav-DMIvs9d6.js";import{l}from"./wuiHttp-DgnM7K2Q.js";var u=/^[A-Za-z0-9_.:-]{1,64}$/,d=/@(\\+)\[|@\[([^[\]\n]{1,100})\]\(([A-Za-z0-9_.:-]{1,64})\)/g,f=/@(\\*)\[/g;function p(e){return String(e??``).replace(/[[\]\r\n]+/g,` `).replace(/\s+/g,` `).trim().slice(0,100)}var m=e=>e.replace(f,(e,t)=>`@\\${t}[`);function h(e){let t=String(e??``),n=[],r=e=>{if(!e)return;let t=n[n.length-1];t&&`text`in t?t.text+=e:n.push({text:e})},i=0;for(let e of t.matchAll(d))r(t.slice(i,e.index)),e[1]===void 0?n.push({id:e[3],label:e[2]}):r(`@${e[1].slice(1)}[`),i=e.index+e[0].length;return r(t.slice(i)),n}function g(e){let t=``,n=[];for(let r of h(e)){if(`text`in r){t+=r.text;continue}let e=`@${r.label}`;n.push({start:t.length,end:t.length+e.length,id:r.id,label:r.label}),t+=e}return{text:t,mentions:n}}function _(e,t=[]){let n=String(e??``),r=[...t].sort((e,t)=>e.start-t.start),i=``,a=0;for(let e of r)e.start<a||n.slice(e.start,e.end)!==`@${e.label}`||!u.test(e.id)||(i+=m(n.slice(a,e.start)),i+=`@[${e.label}](${e.id})`,a=e.end);return i+m(n.slice(a))}function v(e){let t=[];for(let n of h(e))`id`in n&&!t.includes(n.id)&&t.push(n.id);return t}var y=8,b=40,x=Object.freeze({listName:`People`,searching:`Searching…`,noMatch:`No one matches`,found:e=>`${e===1?`1 person`:`${s(e,{decimals:0})} people`}. Up and down to choose, Enter to mention.`,mentioned:e=>`Mentioned ${e}.`}),S=`[data-wui-control]`,C=`[data-wui-field]`,w=`[data-wui-menu]`,T=`[data-wui-live]`,E=0,D=e=>e&&u.test(String(e.value??``))&&p(e.label)!==``;function O(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`input-sm`,n===`sm`),t.classList.toggle(`input-lg`,n===`lg`)}function k(e,t){t.readOnly=i(e)||e.hasAttribute(`loading`)}function A(e){let t=e.ownerDocument;e.id||=`wui-mention-${++E}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control textarea wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),k(e,n),O(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??x.listName),o.setAttribute(`data-wui-menu`,``),o.hidden=!0,e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var j=class extends r{static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._query=null,this._results=[],this._active=-1,this._timer=null,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this),this._reposition=()=>{this._isOpen()&&this._position()}}connectedCallback(){for(let e of[`people`,`loading`,`value`])if(Object.hasOwn(this,e)){let t=this[e];delete this[e],this[e]=t}if(this._wired)return;this._wired=!0,this.querySelector(S)||A(this);let e=this._control(),t=this.querySelector(C)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._menu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target.closest?.(`.wui-mention-option`);t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(k(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(k(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?O(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return _(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=/* @__PURE__ */ new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(D):[],(this._isOpen()||this._query!==null)&&this._refresh()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(S)}_menu(){return this.querySelector(w)}_load(e){let{text:t,mentions:n}=g(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(C);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._control(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e?.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||o(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,r=n.lastIndexOf(`@`,t-1);if(r<0||r>0&&!/[\s([{"'“‘]/.test(n[r-1]))return null;let i=n.slice(r+1,t);return i.length>40||/[\n@]/.test(i)||/^\s/.test(i)||/\s{2}/.test(i)||this._mentions.some(e=>r>=e.start&&r<e.end)?null:{start:r,end:t,text:i}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>p(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,a=await l(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this.loading=!1;return}let o=this.ownerDocument.createElement(`template`);o.innerHTML=a.html,this._peopleProp=[...o.content.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(D),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return!(!e||e.hidden)}_renderMenu(){let t=this._menu(),n=this._control();if(!t||!n||!this._query)return;this._syncState();let r=this.ownerDocument;if(t.replaceChildren(),this._results.forEach((e,n)=>{let i=r.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${t.id}-${n}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(n),e.src){let t=r.createElement(`img`);t.className=`wui-mention-option-photo`,t.src=e.src,t.alt=``,i.appendChild(t)}let a=r.createElement(`span`);a.className=`wui-mention-option-text`;let o=r.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=p(e.label),a.appendChild(o),e.description){let t=r.createElement(`span`);t.className=`wui-mention-option-description`,t.textContent=String(e.description),a.appendChild(t)}i.appendChild(a),t.appendChild(i)}),!this._results.length){let e=r.createElement(`div`);e.className=`wui-mention-empty`,e.textContent=this.loading?x.searching:`${x.noMatch} “${this._query.text}”`,t.appendChild(e)}let i=this._isOpen();t.hidden=!1,i||e(this,this._reposition),this._position(),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?x.found(this._results.length):`${x.noMatch}.`)}_syncState(){let e=this._control();e&&a(this,e)}_position(){n(this._control(),this._menu())}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();e&&!e.hidden&&(e.hidden=!0,e.replaceChildren()),this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`),t(this)}_setActive(e,{reveal:t=!0}={}){let n=this._menu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);c(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._control().setAttribute(`aria-activedescendant`,i.id)):this._control().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._control();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target.closest?.(`.wui-mention-option`);t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=p(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(x.mentioned(t))}_replace(e,t,n,r){let i=this._control(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(T);t&&(t.textContent=``,t.textContent=e)}};export{u as a,_ as c,j as i,v as l,y as n,p as o,x as r,g as s,b as t,h as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-DV9IZZCu.js";import{c as t,i as n,n as r,s as i}from"./notificationDays-
|
|
1
|
+
import{t as e}from"./elementBase-DV9IZZCu.js";import{c as t,i as n,n as r,s as i}from"./notificationDays-dNQZGLlB.js";import{l as a}from"./wuiHttp-DgnM7K2Q.js";var o=`.wui-notification-center-trigger`,s=`.wui-notification-center-panel`,c=`.wui-notification-center-count`,l=`.wui-notification-center-live`,u=`.wui-notification-center-markall`,d=`.wui-notification-center-item`,f=`wui-notification-center-item-read`,p=`.wui-notification-center-unread-label`,m=`.app-tabs`,h=`.wui-notification-center-tabs [role='tablist']`,g=`.wui-notification-center-tabs [role='tab']`,_=`.wui-notification-center-empty`,v=class extends e{constructor(){super(),this._doc=null,this._unread=0,this._busy=!1,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onOutside=e=>{this.contains(e.target)||this.close()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}connectedCallback(){this._doc=this.ownerDocument,this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`mousedown`,this._onOutside),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen(),this.isOpen&&this._layoutTabs()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`mousedown`,this._onOutside),this.removeEventListener(`focusout`,this._onFocusOut),this._doc=null}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(this.setAttribute(`open`,``),this._syncOpen(),this._layoutTabs(),this.querySelector(s)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&this.querySelector(o)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(o)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${d}:not(.${f}):not([data-archived="true"])`).length}_click(e){let t=e.target.closest?.(g);if(t&&this.contains(t)){if(this.hasAttribute(`controlled`))return;this._pickTab(t);return}let n=e.target.closest?.(`${o}, ${u}, ${d}`);n&&this.contains(n)&&(n.matches(o)?this.toggle():this.hasAttribute(`controlled`)||(n.matches(u)?this._markAll():this._markItem(n)))}_key(e){if(e.key===`Escape`&&this.isOpen){e.preventDefault(),e.stopPropagation(),this.close({restoreFocus:!0});return}if(!this.isOpen||!this.querySelector(s)?.contains(e.target)||e.target.closest(m))return;let t={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`}[e.key];if(t===void 0)return;let n=[...this.querySelectorAll(d)].filter(e=>!e.closest(`[hidden]`));if(n.length===0)return;let r=n.indexOf(e.target.closest(d)),i;i=t===`first`?0:t===`last`?n.length-1:r===-1?t===1?0:n.length-1:Math.min(n.length-1,Math.max(0,r+t)),e.preventDefault(),n[i].focus()}_markItem(e){e.classList.contains(f)||(this._applyRead(e),e.dataset.archived!==`true`&&(this._unread=Math.max(0,this._unread-1)),this._render(),this._say(t(this._unread)),this._emitRead([e.dataset.id].filter(Boolean),!1))}async _markAll(){if(this._busy)return;let e=[...this.querySelectorAll(`${d}:not(.${f})`)];if(e.length===0&&this._unread===0)return;let t=e.map(e=>e.dataset.id).filter(Boolean),n=this.getAttribute(`read-action`);if(n){this._setBusy(!0);let e=new URLSearchParams;for(let n of t)e.append(`ids`,n);let i=await a(n,{method:`POST`,body:e});if(this._setBusy(!1),!i.ok){if(i.kind===`session`||i.kind===`aborted`)return;let e=i.message||r.failed[i.kind]||r.failed.server;this._say(e),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:i.kind,message:e}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(r.allRead),this._emitRead(t,!0)}_pickTab(e){let t=e.closest(h);if(t){for(let n of t.querySelectorAll(g)){let t=n===e;n.classList.toggle(`active`,t),n.setAttribute(`aria-selected`,t?`true`:`false`),n.setAttribute(`tabindex`,t?`0`:`-1`)}this._layoutTabs(),this._filterItems(e.dataset.key)}}_layoutTabs(){for(let e of this.querySelectorAll(h)){let t=e.querySelector(`.app-tab.active`);t&&(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.setAttribute(`data-wui-tabs`,``)}}_filterItems(e){let t=!1;for(let n of this.querySelectorAll(d)){let r=n.dataset.archived===`true`,i=n.classList.contains(f),a=e===`archived`?r:!r&&(e!==`unread`||!i);a&&(t=!0);let o=n.closest(`li`);o&&(o.hidden=!a)}for(let e of this.querySelectorAll(`.wui-notification-center-list section`))e.hidden=[...e.querySelectorAll(`li`)].every(e=>e.hidden);let n=this.querySelector(_);n&&(n.hidden=t)}_applyRead(e){e.classList.add(f),e.querySelector(p)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(u);t&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=this.querySelector(c);e&&(e.textContent=n(this._unread),e.hidden=this._unread===0),this.querySelector(o)?.setAttribute(`aria-label`,i(this.getAttribute(`label`)||r.label,this._unread));let t=this.querySelector(u);t&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(l);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{v as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-DV9IZZCu.js";import{g as t,l as n}from"./formatters-
|
|
1
|
+
import{t as e}from"./elementBase-DV9IZZCu.js";import{g as t,l as n}from"./formatters-Ba0CvsTs.js";var r=6e4,i=60*r,a=24*i,o=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function s(e,s=Date.now()){let c=t(e);if(!Number.isFinite(c))return`-`;let l=s-c,u=Math.abs(l);if(u>=7*a)return n(c);if(u<r)return`just now`;let[d,f]=u<i?[Math.floor(u/r),`minute`]:u<a?[Math.floor(u/i),`hour`]:[Math.floor(u/a),`day`];return l>0?`${o(d,f)} ago`:`in ${o(d,f)}`}function c(e){let r=t(e);return Number.isFinite(r)?`${n(r,{pattern:`datetime`})} IST`:`-`}var l=3e4,u=/* @__PURE__ */ new Set,d=null,f=()=>{if(!(typeof document<`u`&&document.hidden))for(let e of u)e.refresh()},p=e=>{u.add(e),u.size===1&&(d=setInterval(f,l),document.addEventListener(`visibilitychange`,f))},m=e=>{u.delete(e),u.size===0&&(clearInterval(d),d=null,document.removeEventListener(`visibilitychange`,f))},h=class extends e{constructor(){super(),this._observer=null}connectedCallback(){this.refresh(),p(this),this._observer=new MutationObserver(()=>this.refresh()),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`datetime`]})}disconnectedCallback(){m(this),this._observer?.disconnect(),this._observer=null}refresh(){let e=this.querySelector(`time[datetime]`);if(!e)return;let t=s(e.getAttribute(`datetime`));e.textContent!==t&&(e.textContent=t)}};export{s as n,c as r,h as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-DV9IZZCu.js";import{m as t}from"./formatters-
|
|
1
|
+
import{t as e}from"./elementBase-DV9IZZCu.js";import{m as t}from"./formatters-Ba0CvsTs.js";var n=/^[0-9]$/,r=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,i=class extends e{static get observedAttributes(){return[`value`,`format`,`unit`,`decimals`,`duration`]}constructor(){super(),this._connected=!1,this._signature=null,this._digits=[],this._reels=[],this._roll=null,this._onRollEnd=e=>{e.target.classList.contains(`wui-rolling-number-reel`)&&this.removeAttribute(`data-rolling`)}}connectedCallback(){this._connected=!0,this._roll=this.querySelector(`.wui-rolling-number-roll`),this._roll?.addEventListener(`transitionend`,this._onRollEnd),this._draw(!1)}disconnectedCallback(){this._connected=!1,this._roll?.removeEventListener(`transitionend`,this._onRollEnd)}attributeChangedCallback(){this._connected&&this._draw(!0)}_text(){let e=this.getAttribute(`value`),n=e===null||e.trim()===``?NaN:Number(e);if(!Number.isFinite(n))return null;let r=this.getAttribute(`decimals`);return t(n,{style:this.getAttribute(`format`)||`number`,unit:this.getAttribute(`unit`)||void 0,decimals:r===null||r===``?void 0:Number(r)})}_showText(e){let t=this.querySelector(`.wui-rolling-number-text`);t&&t.textContent!==e&&(t.firstChild?t.firstChild.nodeValue=e:t.append(e))}_clear(e){e.replaceChildren(),this.removeAttribute(`data-ready`),this._signature=null,this._digits=[],this._reels=[]}_draw(e){let t=this.querySelector(`.wui-rolling-number-roll`);if(!t)return;let i=this._text();if(i===null||(this._showText(i),r())){this._clear(t);return}this.toggleAttribute(`data-rolling`,e);let a=Number(this.getAttribute(`duration`));this.getAttribute(`duration`)&&Number.isFinite(a)&&a>=0?this.style.setProperty(`--wui-roll-duration`,`${a}ms`):this.style.removeProperty(`--wui-roll-duration`);let o=[...i],s=o.filter(e=>n.test(e)).map(Number),c=o.map(e=>n.test(e)?`#`:e).join(``);if(e&&c===this._signature){this._reels.forEach((e,t)=>{e.style.setProperty(`--wui-roll-digit`,String(s[t]))}),this._digits=s;return}let l=this._digits,u=[],d=[],f=0;for(let t of o){if(!n.test(t)){let e=document.createElement(`span`);e.className=`wui-rolling-number-char`,e.textContent=t,d.push(e);continue}let r=document.createElement(`span`);r.className=`wui-rolling-number-digit`;let i=document.createElement(`span`);i.className=`wui-rolling-number-reel`;for(let e=0;e<10;e+=1){let t=document.createElement(`span`);t.textContent=String(e),i.append(t)}let a=s.length-1-f,o=e?l[l.length-1-a]??0:s[f];i.style.setProperty(`--wui-roll-digit`,String(o)),r.append(i),d.push(r),u.push(i),f+=1}t.replaceChildren(...d),e&&(t.offsetWidth,u.forEach((e,t)=>{e.style.setProperty(`--wui-roll-digit`,String(s[t]))})),this._signature=c,this._digits=s,this._reels=u,this.setAttribute(`data-ready`,``)}};export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e}from"./formatters-
|
|
1
|
+
import{f as e}from"./formatters-Ba0CvsTs.js";var t=48,n=1200,r=10,i=50,a=[`start`,`end`],o=8,s={comfortable:54,cozy:48,compact:40},c={resize:e=>e?`Resize ${e} column`:`Resize column`,width:e=>`${e} pixels`,rows:t=>`${e(t,{decimals:0})} ${t===1?`row`:`rows`}`,saved:e=>e?`${e} saved.`:`Row saved.`,savedMany:t=>`${e(t,{decimals:0})} rows saved.`,notSaved:(e,t)=>`${e?`${e} was not saved.`:`Row was not saved.`}${t?` ${t}`:``}`},l=t=>e(t,{decimals:0}),u=e=>Math.min(n,Math.max(48,Math.round(Number(e)||0)));function d(e,t,n=[]){let r=new Map(n.map(e=>[e,[]]));return e.forEach((e,n)=>{let i=t(e,n);r.has(i)||r.set(i,[]),r.get(i).push(e)}),[...r].filter(([,e])=>e.length>0).map(([e,t])=>({key:e,items:t}))}function f({scrollTop:e,viewport:t,rowHeight:n,count:r,overscan:i=8}){let a=n>0?n:s.comfortable,o=Math.floor(Math.max(0,e)/a),c=Math.max(0,o-i);c-=c%2;let l=Math.min(r,o+Math.ceil(Math.max(0,t)/a)+i),u=Math.min(c,l);return{start:u,end:l,before:u*a,after:Math.max(0,r-l)*a}}var p=e=>`wui-widths:${e}`;function m(e){if(!e)return{};try{let t=JSON.parse(window.localStorage.getItem(p(e))||`{}`),n={};for(let[e,r]of Object.entries(t||{}))Number.isFinite(r)&&(n[e]=u(r));return n}catch{return{}}}function h(e,t){if(e)try{Object.keys(t).length?window.localStorage.setItem(p(e),JSON.stringify(t)):window.localStorage.removeItem(p(e))}catch{}}var g=(e,t)=>`--wui-pin-${e}-${t}`,_=`--wui-pin-at`,v=(e,t)=>`var(${g(e,t)}, 0px)`;function y(e){let t=e.map(()=>null),n=-1;e.forEach((e,t)=>{e===`start`&&(n=t)});let r=0;for(let i=0;i<=n;i++)(e[i]===`start`||e[i]===`lead`)&&(t[i]={side:`start`,ordinal:r++,edge:!1});n>=0&&(t[n].edge=!0);let i=-1;r=0;for(let n=e.length-1;n>=0;n--)e[n]===`end`&&(t[n]={side:`end`,ordinal:r++,edge:!1},i=n);return i>=0&&(t[i].edge=!0),t}var b=e=>e?`wui-pin-${e.side}${e.edge?` wui-pin-${e.side}-edge`:``}`:``,x=200,S=220,C=`cubic-bezier(0.22, 1, 0.36, 1)`,w=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,T=e=>e.getAttribute(`data-row-key`)??e;function E(e){let t=[...e];if(t.length>200)return null;let n=/* @__PURE__ */ new Map;for(let e of t)e.hidden||n.set(T(e),e.offsetTop);return n}function D(e,t){let n=[...e];if(!t||n.length>200||w())return 0;let r=0;for(let e of n){if(e.hidden||typeof e.animate!=`function`)continue;let n=t.get(T(e));if(n===void 0)continue;let i=n-e.offsetTop;Math.abs(i)<1||(e.animate([{transform:`translateY(${i}px)`},{transform:`translateY(0)`}],{duration:220,easing:C}),r++)}return r}function O(e,t){if(!e||!t)return!1;let n=new Set(t),r=new Set(e),i=e.filter(e=>n.has(e)),a=t.filter(e=>r.has(e));return i.some((e,t)=>e!==a[t])}var k=[`saving`,`error`],A=`data-wui-save-state`,j=`wui-row-save-error`,M=e=>e.querySelector(`:scope > .wui-name-cell`)??[...e.cells].find(e=>!e.matches(`.wui-select-cell, .wui-expand-cell`))??null;function N(e){let t=M(e);if(!t)return``;let n=t.querySelector(`.u-name`);if(n)return n.textContent.trim();let r=``;for(let e of t.childNodes)e.nodeType===1&&e.classList.contains(`wui-row-save-error`)||(r+=e.textContent);return r.replace(/\s+/g,` `).trim()}function P(e,t,n=``){if(t!==null&&!k.includes(t))throw Error(`A row's save state is ${k.join(` or `)} (or null to clear it), not "${t}".`);e.querySelector(`:scope > * > .${j}`)?.remove(),t===null?e.removeAttribute(A):e.setAttribute(A,t),t===`saving`?e.setAttribute(`aria-busy`,`true`):e.removeAttribute(`aria-busy`);let r=t===`error`&&n?M(e):null;if(r){let t=e.ownerDocument.createElement(`span`);t.className=j,t.textContent=n,r.append(t)}}function F(e,t){let n=[];if(!e)return n;for(let[r,i]of e){let e=t.get(r);i.state===`saving`&&e&&e.state!==`saving`&&n.push({label:e.label,ok:e.state!==`error`,message:e.message||``})}return n}function I(e){let t=e.filter(e=>e.ok),n=[];t.length===1?n.push(c.saved(t[0].label)):t.length>1&&n.push(c.savedMany(t.length));for(let t of e)t.ok||n.push(c.notSaved(t.label,t.message));return n.join(` `)}export{F as A,y as C,O as D,N as E,h as M,I as O,g as S,m as T,d as _,a,v as b,s as c,A as d,j as f,l as g,u as h,_ as i,f as j,P as k,x as l,o as m,t as n,r as o,k as p,c as r,i as s,n as t,S as u,M as v,D as w,b as x,E as y};
|