@webority/ui-elements 0.181.0 → 0.181.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui-elements/calendar-views.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/dashboard-grid.global.js +1 -1
- package/dist/ui-elements/data-table.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +1 -1
- package/dist/ui-elements/date-time.global.js +1 -1
- package/dist/ui-elements/datepicker.global.js +1 -1
- package/dist/ui-elements/dock.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/dropdown.global.js +1 -1
- package/dist/ui-elements/entry-grid.global.js +1 -1
- package/dist/ui-elements/gantt.global.js +1 -1
- package/dist/ui-elements/glyphs.global.js +1 -1
- package/dist/ui-elements/hover-card.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/mini-calendar.global.js +1 -1
- package/dist/ui-elements/navigation-menu.global.js +1 -1
- package/dist/ui-elements/notification-center.global.js +1 -1
- package/dist/ui-elements/offline-banner.global.js +1 -1
- package/dist/ui-elements/onboarding-checklist.global.js +1 -1
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/otp.global.js +1 -1
- package/dist/ui-elements/overflow.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/popover.global.js +1 -1
- package/dist/ui-elements/rating.global.js +1 -1
- package/dist/ui-elements/record-pager.global.js +1 -1
- package/dist/ui-elements/relative-time.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +1 -1
- package/dist/ui-elements/select-recents.global.js +1 -1
- package/dist/ui-elements/select-search.global.js +1 -1
- package/dist/ui-elements/select-window.global.js +1 -1
- package/dist/ui-elements/server.global.js +1 -1
- package/dist/ui-elements/shell.global.js +1 -1
- package/dist/ui-elements/shortcuts.global.js +1 -1
- package/dist/ui-elements/show-more.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/table-export.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree-picker.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/truncate.global.js +1 -1
- package/dist/ui-elements/whats-new.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.181.
|
|
1
|
+
(function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.181.1`)throw Error(`[webority-ui] hover-card expects ui-elements 0.181.1 but the page loaded `+i+`.`);function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=300,u=150,d=`.wui-hover-card-trigger`,f=`.wui-hover-card-panel`,p=`a[href],button,input,select,textarea,[tabindex]`,m=0;function h(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}var g=class extends n.ElementBase{static get observedAttributes(){return[`open`]}constructor(){super(),c(this,`_doc`,void 0),c(this,`_timer`,void 0),c(this,`_described`,void 0),c(this,`_refocusing`,void 0),c(this,`_onOver`,void 0),c(this,`_onOut`,void 0),c(this,`_onFocusIn`,void 0),c(this,`_onFocusOut`,void 0),c(this,`_onKeyDown`,void 0),this._doc=null,this._timer=null,this._described=null,this._refocusing=!1,this._onOver=e=>{if(e.pointerType===`touch`||e.pointerType===`pen`)return;let t=this._zone(e.target);t===`panel`?this._clear():t===`trigger`&&this._schedule(!0)},this._onOut=e=>{e.pointerType!==`touch`&&e.pointerType!==`pen`&&this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onFocusIn=e=>{this._refocusing||(this._zone(e.target)===`trigger`?this._schedule(!0):this._zone(e.target)===`panel`&&this._clear())},this._onFocusOut=e=>{this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onKeyDown=e=>{if(e.key!==`Escape`||!this.isOpen||this.hasAttribute(`open`))return;e.preventDefault();let t=this._zone(this.ownerDocument.activeElement)===`panel`;this._clear(),this._setOpen(!1),t&&(this._refocusing=!0,this._anchor?.focus(),this._refocusing=!1)}}get isOpen(){let e=this._panel;return e!==null&&(0,r.isPopoverOpen)(e)}connectedCallback(){this._doc=this.ownerDocument,this.addEventListener(`pointerover`,this._onOver),this.addEventListener(`pointerout`,this._onOut),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen()}attributeChangedCallback(){this.isConnected&&this._syncOpen()}disconnectedCallback(){this._clear();let e=this._panel;e&&(0,r.closeAnchoredPopover)(e),this.removeEventListener(`pointerover`,this._onOver),this.removeEventListener(`pointerout`,this._onOut),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._doc=null}get _trigger(){return h(this,d)}get _panel(){return h(this,f)}get _anchor(){let e=this._trigger;return e?h(e,p)??e:null}_zone(e){if(!(e instanceof Node)||!this.contains(e))return null;let t=e instanceof Element?e:e.parentElement;return this._panel?.contains(t)?`panel`:this._trigger?.contains(t)?`trigger`:null}_delay(e,t){let n=Number(this.getAttribute(e));return this.hasAttribute(e)&&Number.isFinite(n)&&n>=0?n:t}_clear(){this._timer!==null&&clearTimeout(this._timer),this._timer=null}_syncOpen(){this._clear(),this._setOpen(this.hasAttribute(`open`))}_schedule(e){if(!e&&this.hasAttribute(`open`)||(this._clear(),this.isOpen===e))return;let t=e?this._delay(`open-delay`,l):this._delay(`close-delay`,u);this._timer=setTimeout(()=>{this._timer=null,this._setOpen(e)},t)}_setOpen(e){let t=this._panel;if(!t||this.isOpen===e)return;if(!e){(0,r.closeAnchoredPopover)(t);return}let n=this._trigger;if(!n)throw Error(`wui-hover-card: panel without a trigger`);(0,r.openAnchoredPopover)(n,t,{mode:`manual`,clampHeight:!0,keepOffscreen:this.hasAttribute(`open`),onClosed:()=>this._closed()}),this._doc?.addEventListener(`keydown`,this._onKeyDown,!0),this._describe(t),this.dispatchEvent(new CustomEvent(`wui:hover-card:open`,{bubbles:!0}))}_closed(){this._doc?.removeEventListener(`keydown`,this._onKeyDown,!0),this._described?.removeAttribute(`aria-describedby`),this._described=null,this.dispatchEvent(new CustomEvent(`wui:hover-card:close`,{bubbles:!0}))}_describe(e){let t=this._anchor;t&&(e.id||=`wui-hover-card-${++m}`,t.setAttribute(`aria-describedby`,e.id),this._described=t)}};(0,t.defineElement)(`wui-hover-card`,g),e.WuiHoverCard=g})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.nativeOverlay);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.181.0`)throw Error(`[webority-ui] image-crop expects ui-elements 0.181.0 but the page loaded `+o+`.`);var s=4096,c=[.92,.8,.65,.5],l=.8,u=8;function d(e){if(e==null||e===``||e===`free`)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)&&t>0?t:null}function f(e,t,n){if(!n)return{x:0,y:0,w:e,h:t};let r=e,i=r/n;return i>t&&(i=t,r=i*n),{x:(e-r)/2,y:(t-i)/2,w:r,h:i}}function p(e,t,n){return{...e,x:Math.min(Math.max(e.x,0),Math.max(t-e.w,0)),y:Math.min(Math.max(e.y,0),Math.max(n-e.h,0))}}function m(e,t,n,r,i){return p({...e,x:e.x+t,y:e.y+n},r,i)}function h(e,t){return Math.min(32,e,t)}function g(e,t){return t.w/e.w}function _(e,t){return Math.max(4,g(e,t))}function v(e,t,n,r,i){let a=Math.min(Math.max(n,1),_(e,t)),o=e.h/e.w,s=Math.min(r,i/o),c=Math.min(Math.max(h(r,i),h(r,i)/o),s),l=Math.min(Math.max(t.w/a,c),s),u=l*o,d=e.x+e.w/2,f=e.y+e.h/2;return p({x:d-l/2,y:f-u/2,w:l,h:u},r,i)}var y=[`nw`,`ne`,`sw`,`se`];function b(e,t,n,r,i,a){let o=h(i,a),s=t.endsWith(`w`),c=t.startsWith(`n`),l=s?e.x+e.w:e.x,u=c?e.y+e.h:e.y,d=Math.min(Math.max(n,0),i),f=Math.min(Math.max(r,0),a);return d=s?Math.min(d,l-o):Math.max(d,l+o),f=c?Math.min(f,u-o):Math.max(f,u+o),{x:Math.min(d,l),y:Math.min(f,u),w:Math.abs(d-l),h:Math.abs(f-u)}}function x(e,t=s){let n=Math.min(1,t/Math.max(e.w,e.h));return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function S(e,t){let n=t/Math.max(e.w,e.h);return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function C(e,t,n){return n%180==0?{w:e,h:t}:{w:t,h:e}}function w(e,t,n){return p({x:n-(e.y+e.h),y:e.x,w:e.h,h:e.w},n,t)}function T(e){return String(e||``).split(/[\s,]+/).map(Number).filter(e=>Number.isInteger(e)&&e>0)}var E=[`image/png`,`image/jpeg`,`image/webp`],D={"image/png":`.png`,"image/jpeg":`.jpg`,"image/webp":`.webp`};function O(e){let t=String(e||``).toLowerCase();return E.includes(t)?t:`image/png`}function k(e,t){let n=String(e||`image`),r=D[t];if(r===void 0)throw Error(`No file extension for ${t}`);return(t===`image/jpeg`?/\.jpe?g$/i.test(n):n.toLowerCase().endsWith(r))?n:`${n.replace(/\.[^./\\]+$/,``)||`image`}${r}`}async function A(e,{width:t,height:n,type:r,maxBytes:i}){let a=r,o=t,s=n,d=null;for(let t=0;t<=u;t++){let n=a===`image/png`?[void 0]:t===0?c:[c[1]];for(let t of n){if(d=await e(o,s,a,t),!d||(d.type&&d.type!==a&&(a=d.type),!(i>0)||d.size<=i))return d;if(a===`image/png`)break}o=Math.max(1,Math.round(o*l)),s=Math.max(1,Math.round(s*l))}return d}var j={bottomLeftLabel:`bottom left`,bottomRightLabel:`bottom right`,cropAreaText:`Crop area. Drag the frame or use the arrow keys to move it, and plus or minus to zoom.`,frameText:`Frame {width} by {height} pixels, {left} from the left, {top} from the top, zoom {zoom}%{turned}.`,resetCropLabel:`Reset the crop`,resetLabel:`Reset`,resizeCornerText:`Resize {corner} corner`,rotateClockwiseLabel:`Rotate 90 degrees clockwise`,rotateLabel:`Rotate`,topLeftLabel:`top left`,topRightLabel:`top right`,turnedText:`, turned {rotation} degrees`,zoomInLabel:`Zoom in`,zoomLabel:`Zoom`,zoomOutLabel:`Zoom out`};function M(e){"@babel/helpers - typeof";return M=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},M(e)}function N(e,t){if(M(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(M(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function P(e){var t=N(e,`string`);return M(t)==`symbol`?t:t+``}function F(e,t,n){return(t=P(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var I=.05,L=.2,R={w:320,h:240},z={nw:`topLeftLabel`,ne:`topRightLabel`,sw:`bottomLeftLabel`,se:`bottomRightLabel`},B=()=>(0,a.readText)(`imageCrop`,j),V=e=>{let t=z[e];return t?B()[t]:e};function H(e,t=!1){return(0,i.svgRoot)({width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,...t?{"stroke-linejoin":`round`}:{},"aria-hidden":`true`},e.map(e=>[`path`,{d:e}]))}var U=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function W(e){let[t,n]=[...e.values()];if(!t||!n)throw Error(`two pointers missing`);return[t,n]}function G(e,t){if(e===null)throw Error(`${t} missing`);return e}function K(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`${t} missing`);return r}function q(e){if(e===null)throw Error(`event target missing`);if(!(e instanceof Element))return null;let t=e.closest(`.wui-crop-handle`);return t instanceof HTMLElement?t:null}var J=class extends r.ElementBase{static get observedAttributes(){return[`src`,`aspect`,`round`,`rotatable`,`previews`]}constructor(){super(),F(this,`_rect`,void 0),F(this,`_base`,void 0),F(this,`_natural`,void 0),F(this,`_source`,void 0),F(this,`_rotation`,void 0),F(this,`_drag`,void 0),F(this,`_pointers`,void 0),F(this,`_pinch`,void 0),F(this,`_previewPending`,void 0),F(this,`_resizeObserver`,void 0),F(this,`_rendered`,void 0),F(this,`_stageEl`,void 0),F(this,`_imgEl`,void 0),F(this,`_frameEl`,void 0),F(this,`_sliderEl`,void 0),F(this,`_toolsEl`,void 0),F(this,`_previewBoxEl`,void 0),F(this,`_liveEl`,void 0),this._rect=null,this._base=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pointers=new Map,this._pinch=null,this._previewPending=!1,this._resizeObserver=null,this._stageEl=null,this._imgEl=null,this._frameEl=null,this._sliderEl=null,this._toolsEl=null,this._previewBoxEl=null,this._liveEl=null}get _stage(){return G(this._stageEl,`stage`)}get _img(){return G(this._imgEl,`image`)}get _frame(){return G(this._frameEl,`frame`)}get _slider(){return G(this._sliderEl,`zoom slider`)}get _tools(){return G(this._toolsEl,`tools`)}get _previewBox(){return G(this._previewBoxEl,`previews`)}get _live(){return G(this._liveEl,`live region`)}get src(){return this.getAttribute(`src`)||``}set src(e){e==null||e===``?this.removeAttribute(`src`):this.setAttribute(`src`,String(e))}get aspect(){return d(this.getAttribute(`aspect`))}set aspect(e){e==null||e===``?this.removeAttribute(`aspect`):this.setAttribute(`aspect`,String(e))}get round(){return this.hasAttribute(`round`)}set round(e){this.toggleAttribute(`round`,!!e)}get rotatable(){return this.hasAttribute(`rotatable`)}set rotatable(e){this.toggleAttribute(`rotatable`,!!e)}get previews(){return this.getAttribute(`previews`)||``}set previews(e){e==null||e===``?this.removeAttribute(`previews`):this.setAttribute(`previews`,Array.isArray(e)?e.join(` `):String(e))}get rect(){return this._rect?{...this._rect}:null}get rotation(){return this._rotation}set rotation(e){if(!this._rect)return;let t=(Math.round(Number(e)/90)*90%360+360)%360;if(!Number.isNaN(t))for(;this._rotation!==t;)this.rotate()}get zoom(){return this._rect?g(this._rect,G(this._base,`base frame`)):1}set zoom(e){if(!this._rect)return;let t=G(this._natural,`natural size`);this._rect=v(this._rect,G(this._base,`base frame`),Number(e)||1,t.w,t.h),this._paint(),this._announce()}connectedCallback(){this._rendered?this._observe():this.render()}disconnectedCallback(){this._resizeObserver?.disconnect(),this._resizeObserver=null}attributeChangedCallback(e){this._rendered&&(e===`src`?this._loadImage():e===`aspect`?(this._rebuildHandles(),this._resetRect()):e===`rotatable`?this._tools.hidden=!this.rotatable:e===`previews`?this._renderPreviews():this._applyRound())}render(){this.replaceChildren((0,n.make)(`div`,null,(0,n.make)(`div`,{class:`wui-crop-stage`,tabindex:`0`,role:`group`,"aria-label":B().cropAreaText},(0,n.make)(`img`,{class:`wui-crop-img`,alt:``,draggable:`false`}),(0,n.make)(`div`,{class:`wui-crop-frame`})),(0,n.make)(`div`,{class:`wui-crop-controls`},(0,n.make)(`button`,{type:`button`,class:`wui-crop-zoombtn`,"data-zoom":`out`,"aria-label":B().zoomOutLabel},H([`M5 12h14`])),(0,n.make)(`input`,{type:`range`,class:`form-range wui-crop-zoom`,min:1,max:4,step:`0.01`,value:1,"aria-label":B().zoomLabel}),(0,n.make)(`button`,{type:`button`,class:`wui-crop-zoombtn`,"data-zoom":`in`,"aria-label":B().zoomInLabel},H([`M5 12h14M12 5v14`]))),(0,n.make)(`div`,{class:`wui-crop-tools`,hidden:!0},(0,n.make)(`button`,{type:`button`,class:`wui-crop-toolbtn`,"data-crop-action":`rotate`,"aria-label":B().rotateClockwiseLabel},H([`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,`M21 3v5h-5`],!0),(0,n.make)(`span`,null,B().rotateLabel)),(0,n.make)(`button`,{type:`button`,class:`wui-crop-toolbtn`,"data-crop-action":`reset`,"aria-label":B().resetCropLabel},H([`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,`M3 3v5h5`],!0),(0,n.make)(`span`,null,B().resetLabel))),(0,n.make)(`div`,{class:`wui-crop-previews`,"aria-hidden":`true`,hidden:!0}),(0,n.make)(`div`,{class:`visually-hidden`,"data-wui-crop-live":!0,"aria-live":`polite`}))),this._stageEl=K(this,`.wui-crop-stage`,HTMLElement),this._imgEl=K(this,`.wui-crop-img`,HTMLImageElement),this._frameEl=K(this,`.wui-crop-frame`,HTMLElement),this._sliderEl=K(this,`.wui-crop-zoom`,HTMLInputElement),this._toolsEl=K(this,`.wui-crop-tools`,HTMLElement),this._previewBoxEl=K(this,`.wui-crop-previews`,HTMLElement),this._liveEl=K(this,`[data-wui-crop-live]`,HTMLElement),this._rendered=!0,this._tools.hidden=!this.rotatable,this._applyRound(),this._rebuildHandles(),this._renderPreviews(),this._wire(),this._observe(),this._loadImage()}_applyRound(){this._frame.classList.toggle(`wui-crop-frame--round`,this.round),this._previewBox.classList.toggle(`wui-crop-previews--round`,this.round)}_rebuildHandles(){for(let e of this._frame.querySelectorAll(`.wui-crop-handle`))e.remove();if(!this.aspect)for(let e of y){let t=document.createElement(`button`);t.type=`button`,t.className=`wui-crop-handle wui-crop-handle--${e}`,t.dataset.handle=e,t.setAttribute(`aria-label`,(0,a.fillText)(B().resizeCornerText,{corner:V(e)})),this._frame.appendChild(t)}}_renderPreviews(){let e=T(this.previews);this._previewBox.replaceChildren(),this._previewBox.hidden=e.length===0;for(let t of e){let e=document.createElement(`canvas`);e.className=`wui-crop-preview`,e.dataset.size=String(t),e.style.width=`${t}px`,e.style.height=`${t}px`,this._previewBox.appendChild(e)}this._schedulePreviews()}_loadImage(){this._rect=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pinch=null,this._pointers.clear();let e=this.src;this._img.hidden=!e,this._frame.hidden=!0,e&&(this._img.onload=()=>{this._source={w:this._img.naturalWidth,h:this._img.naturalHeight},this._natural={...this._source},this._resetRect(),this.dispatchEvent(new Event(`load`))},this._img.onerror=()=>{this._frame.hidden=!0,this.dispatchEvent(new Event(`error`))},this._img.src=e)}_resetRect(){this._natural&&(this._base=f(this._natural.w,this._natural.h,this.aspect),this._rect={...this._base},this._frame.hidden=!1,this._paint())}_observe(){typeof ResizeObserver>`u`||this._resizeObserver||(this._resizeObserver=new ResizeObserver(()=>this._paint()),this._resizeObserver.observe(this._stage))}_view(){let e=G(this._natural,`natural size`),t=this._stage.clientWidth||R.w,n=this._stage.clientHeight||R.h,r=Math.min(t/e.w,n/e.h),i=e.w*r,a=e.h*r;return{scale:r,left:(t-i)/2,top:(n-a)/2,iw:i,ih:a}}_paint(){if(!this._rect)return;let e=this._view(),t=this._rotation%180!=0,n=t?e.ih:e.iw,r=t?e.iw:e.ih;Object.assign(this._img.style,{left:`${e.left+(e.iw-n)/2}px`,top:`${e.top+(e.ih-r)/2}px`,width:`${n}px`,height:`${r}px`,transform:this._rotation?`rotate(${this._rotation}deg)`:``});let i=this._rect;Object.assign(this._frame.style,{left:`${e.left+i.x*e.scale}px`,top:`${e.top+i.y*e.scale}px`,width:`${i.w*e.scale}px`,height:`${i.h*e.scale}px`});let a=G(this._base,`base frame`),o=g(i,a),s=_(i,a);this._slider.max=String(s),this._slider.value=String(Math.min(Math.max(o,1),s)),this._slider.setAttribute(`aria-valuetext`,`${Math.round(o*100)}%`),this._schedulePreviews()}_schedulePreviews(){if(!this._rect||this._previewBox.hidden||this._previewPending)return;this._previewPending=!0;let e=()=>{this._previewPending=!1,this._drawPreviews()};typeof requestAnimationFrame==`function`?requestAnimationFrame(e):e()}_drawPreviews(){if(!this._rect)return;let e=G(this._natural,`natural size`),t=p(this._rect,e.w,e.h),n=typeof window<`u`&&window.devicePixelRatio||1;for(let e of this._previewBox.children){if(!(e instanceof HTMLCanvasElement))throw Error(`Preview box holds a non-canvas child`);let r=e,i=Number(r.dataset.size),a=Math.max(1,Math.round(i*t.h/t.w));r.style.width=`${i}px`,r.style.height=`${a}px`,r.width=Math.round(i*n),r.height=Math.round(a*n);let o=r.getContext(`2d`);o&&this._drawCrop(o,t,r.width,r.height)}}_drawCrop(e,t,n,r){if(!this._rotation){e.drawImage(this._img,t.x,t.y,t.w,t.h,0,0,n,r);return}let i=G(this._source,`source size`),a=G(this._natural,`natural size`);e.save(),e.scale(n/t.w,r/t.h),e.translate(-t.x,-t.y),e.translate(a.w/2,a.h/2),e.rotate(this._rotation*Math.PI/180),e.drawImage(this._img,-i.w/2,-i.h/2,i.w,i.h),e.restore()}_announce(){this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:this.rect}))}_say(){let e=G(this._rect,`frame`),t=this._rotation?(0,a.fillText)(B().turnedText,{rotation:this._rotation}):``,n=(0,a.fillText)(B().frameText,{width:Math.round(e.w),height:Math.round(e.h),left:Math.round(e.x),top:Math.round(e.y),zoom:Math.round(g(e,G(this._base,`base frame`))*100),turned:t});this._live.textContent=n===this._live.textContent?`${n} `:n}rotate(){if(!this._rect)return;let e=G(this._natural,`natural size`),t=w(this._rect,e.w,e.h);this._rotation=(this._rotation+90)%360;let n=G(this._source,`source size`);this._natural=C(n.w,n.h,this._rotation),this._base=f(this._natural.w,this._natural.h,this.aspect);let r=this.aspect;this._rect=r&&r!==1?{...this._base}:t,this._paint(),this._announce()}reset(){this._source&&(this._rotation=0,this._natural={...this._source},this._resetRect(),this._announce())}_wire(){let e=this._stage;e.addEventListener(`pointerdown`,t=>{if(!this._rect||t.button>0)return;if(this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),e.setPointerCapture?.(t.pointerId),this._pointers.size===2){let[e,n]=W(this._pointers);this._drag=null,this._pinch={distance:U(e,n)||1,zoom:this.zoom,done:!1},t.preventDefault();return}if(this._pinch)return;let n=q(t.target);this._drag={id:t.pointerId,corner:n?n.dataset.handle:null,x:t.clientX,y:t.clientY,start:{...this._rect}},n||e.focus(),t.preventDefault()}),e.addEventListener(`pointermove`,t=>{if(this._pointers.has(t.pointerId)&&this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this._pinch){if(this._pinch.done||this._pointers.size<2||!this._pointers.has(t.pointerId))return;let[e,n]=W(this._pointers),r=this._pinch.zoom*U(e,n)/this._pinch.distance,i=G(this._natural,`natural size`);this._rect=v(G(this._rect,`frame`),G(this._base,`base frame`),r,i.w,i.h),this._paint();return}let n=this._drag;if(!n||n.id!==t.pointerId)return;let r=this._view(),{w:i,h:a}=G(this._natural,`natural size`);if(n.corner){let o=e.getBoundingClientRect(),s=(t.clientX-o.left-e.clientLeft-r.left)/r.scale,c=(t.clientY-o.top-e.clientTop-r.top)/r.scale;this._rect=b(G(this._rect,`frame`),n.corner,s,c,i,a)}else this._rect=m(n.start,(t.clientX-n.x)/r.scale,(t.clientY-n.y)/r.scale,i,a);this._paint()});let t=t=>{if(this._pointers.delete(t.pointerId)&&e.releasePointerCapture?.(t.pointerId),this._pinch){!this._pinch.done&&this._pointers.size<2&&(this._pinch.done=!0,this._announce()),this._pointers.size===0&&(this._pinch=null);return}let n=this._drag;n&&n.id===t.pointerId&&(this._drag=null,this._announce())};e.addEventListener(`pointerup`,t),e.addEventListener(`pointercancel`,t),e.addEventListener(`keydown`,e=>this._onKey(e)),e.addEventListener(`wheel`,e=>{this._rect&&this.contains(document.activeElement)&&(e.preventDefault(),this.zoom*=e.deltaY<0?1.1:1/1.1)},{passive:!1});for(let e of[`input`,`change`])this._slider.addEventListener(e,e=>e.stopPropagation());this._slider.addEventListener(`input`,()=>{this.zoom=Number(this._slider.value)});for(let e of this.querySelectorAll(`.wui-crop-zoombtn`)){if(!(e instanceof HTMLButtonElement))throw Error(`zoom button missing`);e.addEventListener(`click`,()=>{this.zoom*=e.dataset.zoom===`in`?1.25:.8})}K(this,`[data-crop-action="rotate"]`,HTMLButtonElement).addEventListener(`click`,()=>this.rotate()),K(this,`[data-crop-action="reset"]`,HTMLButtonElement).addEventListener(`click`,()=>this.reset())}_onKey(e){if(!this._rect||e.altKey||e.ctrlKey||e.metaKey)return;let{w:t,h:n}=G(this._natural,`natural size`);if(e.key===`+`||e.key===`=`)this.zoom*=1.25,this._say();else if(e.key===`-`||e.key===`_`)this.zoom*=.8,this._say();else if((e.key===`r`||e.key===`R`)&&this.rotatable)this.rotate(),this._say();else if(e.key.startsWith(`Arrow`)){let r=e.shiftKey?L:I,i=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:0,a=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,o=q(e.target)?.dataset.handle;if(o){let e=this._rect,s=(o.endsWith(`w`)?e.x:e.x+e.w)+i*r*e.w,c=(o.startsWith(`n`)?e.y:e.y+e.h)+a*r*e.h;this._rect=b(e,o,s,c,t,n)}else this._rect=m(this._rect,i*r*this._rect.w,a*r*this._rect.h,t,n);this._paint(),this._announce(),this._say()}else return;e.preventDefault()}async toBlob({type:e,maxBytes:t=0,size:n=0}={}){if(!this._rect)return null;let r=O(e),i=G(this._natural,`natural size`),a=p(this._rect,i.w,i.h),{width:o,height:s}=n>0?S(a,n):x(a);return A((e,t,n,r)=>new Promise(i=>{let o=document.createElement(`canvas`);o.width=e,o.height=t;let s=o.getContext(`2d`);s?(n===`image/jpeg`&&(s.fillStyle=`#fff`,s.fillRect(0,0,e,t)),this._drawCrop(s,a,e,t),o.toBlob(i,n,r)):i(null)}),{width:o,height:s,type:r,maxBytes:t})}async toFile({name:e,type:t,maxBytes:n=0,size:r=0}={}){let i=await this.toBlob({type:t,maxBytes:n,size:r});return i?new File([i],k(e,i.type),{type:i.type}):null}};(0,t.defineElement)(`wui-image-crop`,J),e.WuiImageCrop=J})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.svgNodes,WeborityUiElementsInternal.modules.textStore);
|
|
1
|
+
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.181.1`)throw Error(`[webority-ui] image-crop expects ui-elements 0.181.1 but the page loaded `+o+`.`);var s=4096,c=[.92,.8,.65,.5],l=.8,u=8;function d(e){if(e==null||e===``||e===`free`)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)&&t>0?t:null}function f(e,t,n){if(!n)return{x:0,y:0,w:e,h:t};let r=e,i=r/n;return i>t&&(i=t,r=i*n),{x:(e-r)/2,y:(t-i)/2,w:r,h:i}}function p(e,t,n){return{...e,x:Math.min(Math.max(e.x,0),Math.max(t-e.w,0)),y:Math.min(Math.max(e.y,0),Math.max(n-e.h,0))}}function m(e,t,n,r,i){return p({...e,x:e.x+t,y:e.y+n},r,i)}function h(e,t){return Math.min(32,e,t)}function g(e,t){return t.w/e.w}function _(e,t){return Math.max(4,g(e,t))}function v(e,t,n,r,i){let a=Math.min(Math.max(n,1),_(e,t)),o=e.h/e.w,s=Math.min(r,i/o),c=Math.min(Math.max(h(r,i),h(r,i)/o),s),l=Math.min(Math.max(t.w/a,c),s),u=l*o,d=e.x+e.w/2,f=e.y+e.h/2;return p({x:d-l/2,y:f-u/2,w:l,h:u},r,i)}var y=[`nw`,`ne`,`sw`,`se`];function b(e,t,n,r,i,a){let o=h(i,a),s=t.endsWith(`w`),c=t.startsWith(`n`),l=s?e.x+e.w:e.x,u=c?e.y+e.h:e.y,d=Math.min(Math.max(n,0),i),f=Math.min(Math.max(r,0),a);return d=s?Math.min(d,l-o):Math.max(d,l+o),f=c?Math.min(f,u-o):Math.max(f,u+o),{x:Math.min(d,l),y:Math.min(f,u),w:Math.abs(d-l),h:Math.abs(f-u)}}function x(e,t=s){let n=Math.min(1,t/Math.max(e.w,e.h));return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function S(e,t){let n=t/Math.max(e.w,e.h);return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function C(e,t,n){return n%180==0?{w:e,h:t}:{w:t,h:e}}function w(e,t,n){return p({x:n-(e.y+e.h),y:e.x,w:e.h,h:e.w},n,t)}function T(e){return String(e||``).split(/[\s,]+/).map(Number).filter(e=>Number.isInteger(e)&&e>0)}var E=[`image/png`,`image/jpeg`,`image/webp`],D={"image/png":`.png`,"image/jpeg":`.jpg`,"image/webp":`.webp`};function O(e){let t=String(e||``).toLowerCase();return E.includes(t)?t:`image/png`}function k(e,t){let n=String(e||`image`),r=D[t];if(r===void 0)throw Error(`No file extension for ${t}`);return(t===`image/jpeg`?/\.jpe?g$/i.test(n):n.toLowerCase().endsWith(r))?n:`${n.replace(/\.[^./\\]+$/,``)||`image`}${r}`}async function A(e,{width:t,height:n,type:r,maxBytes:i}){let a=r,o=t,s=n,d=null;for(let t=0;t<=u;t++){let n=a===`image/png`?[void 0]:t===0?c:[c[1]];for(let t of n){if(d=await e(o,s,a,t),!d||(d.type&&d.type!==a&&(a=d.type),!(i>0)||d.size<=i))return d;if(a===`image/png`)break}o=Math.max(1,Math.round(o*l)),s=Math.max(1,Math.round(s*l))}return d}var j={bottomLeftLabel:`bottom left`,bottomRightLabel:`bottom right`,cropAreaText:`Crop area. Drag the frame or use the arrow keys to move it, and plus or minus to zoom.`,frameText:`Frame {width} by {height} pixels, {left} from the left, {top} from the top, zoom {zoom}%{turned}.`,resetCropLabel:`Reset the crop`,resetLabel:`Reset`,resizeCornerText:`Resize {corner} corner`,rotateClockwiseLabel:`Rotate 90 degrees clockwise`,rotateLabel:`Rotate`,topLeftLabel:`top left`,topRightLabel:`top right`,turnedText:`, turned {rotation} degrees`,zoomInLabel:`Zoom in`,zoomLabel:`Zoom`,zoomOutLabel:`Zoom out`};function M(e){"@babel/helpers - typeof";return M=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},M(e)}function N(e,t){if(M(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(M(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function P(e){var t=N(e,`string`);return M(t)==`symbol`?t:t+``}function F(e,t,n){return(t=P(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var I=.05,L=.2,R={w:320,h:240},z={nw:`topLeftLabel`,ne:`topRightLabel`,sw:`bottomLeftLabel`,se:`bottomRightLabel`},B=()=>(0,a.readText)(`imageCrop`,j),V=e=>{let t=z[e];return t?B()[t]:e};function H(e,t=!1){return(0,i.svgRoot)({width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,...t?{"stroke-linejoin":`round`}:{},"aria-hidden":`true`},e.map(e=>[`path`,{d:e}]))}var U=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function W(e){let[t,n]=[...e.values()];if(!t||!n)throw Error(`two pointers missing`);return[t,n]}function G(e,t){if(e===null)throw Error(`${t} missing`);return e}function K(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`${t} missing`);return r}function q(e){if(e===null)throw Error(`event target missing`);if(!(e instanceof Element))return null;let t=e.closest(`.wui-crop-handle`);return t instanceof HTMLElement?t:null}var J=class extends r.ElementBase{static get observedAttributes(){return[`src`,`aspect`,`round`,`rotatable`,`previews`]}constructor(){super(),F(this,`_rect`,void 0),F(this,`_base`,void 0),F(this,`_natural`,void 0),F(this,`_source`,void 0),F(this,`_rotation`,void 0),F(this,`_drag`,void 0),F(this,`_pointers`,void 0),F(this,`_pinch`,void 0),F(this,`_previewPending`,void 0),F(this,`_resizeObserver`,void 0),F(this,`_rendered`,void 0),F(this,`_stageEl`,void 0),F(this,`_imgEl`,void 0),F(this,`_frameEl`,void 0),F(this,`_sliderEl`,void 0),F(this,`_toolsEl`,void 0),F(this,`_previewBoxEl`,void 0),F(this,`_liveEl`,void 0),this._rect=null,this._base=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pointers=new Map,this._pinch=null,this._previewPending=!1,this._resizeObserver=null,this._stageEl=null,this._imgEl=null,this._frameEl=null,this._sliderEl=null,this._toolsEl=null,this._previewBoxEl=null,this._liveEl=null}get _stage(){return G(this._stageEl,`stage`)}get _img(){return G(this._imgEl,`image`)}get _frame(){return G(this._frameEl,`frame`)}get _slider(){return G(this._sliderEl,`zoom slider`)}get _tools(){return G(this._toolsEl,`tools`)}get _previewBox(){return G(this._previewBoxEl,`previews`)}get _live(){return G(this._liveEl,`live region`)}get src(){return this.getAttribute(`src`)||``}set src(e){e==null||e===``?this.removeAttribute(`src`):this.setAttribute(`src`,String(e))}get aspect(){return d(this.getAttribute(`aspect`))}set aspect(e){e==null||e===``?this.removeAttribute(`aspect`):this.setAttribute(`aspect`,String(e))}get round(){return this.hasAttribute(`round`)}set round(e){this.toggleAttribute(`round`,!!e)}get rotatable(){return this.hasAttribute(`rotatable`)}set rotatable(e){this.toggleAttribute(`rotatable`,!!e)}get previews(){return this.getAttribute(`previews`)||``}set previews(e){e==null||e===``?this.removeAttribute(`previews`):this.setAttribute(`previews`,Array.isArray(e)?e.join(` `):String(e))}get rect(){return this._rect?{...this._rect}:null}get rotation(){return this._rotation}set rotation(e){if(!this._rect)return;let t=(Math.round(Number(e)/90)*90%360+360)%360;if(!Number.isNaN(t))for(;this._rotation!==t;)this.rotate()}get zoom(){return this._rect?g(this._rect,G(this._base,`base frame`)):1}set zoom(e){if(!this._rect)return;let t=G(this._natural,`natural size`);this._rect=v(this._rect,G(this._base,`base frame`),Number(e)||1,t.w,t.h),this._paint(),this._announce()}connectedCallback(){this._rendered?this._observe():this.render()}disconnectedCallback(){this._resizeObserver?.disconnect(),this._resizeObserver=null}attributeChangedCallback(e){this._rendered&&(e===`src`?this._loadImage():e===`aspect`?(this._rebuildHandles(),this._resetRect()):e===`rotatable`?this._tools.hidden=!this.rotatable:e===`previews`?this._renderPreviews():this._applyRound())}render(){this.replaceChildren((0,n.make)(`div`,null,(0,n.make)(`div`,{class:`wui-crop-stage`,tabindex:`0`,role:`group`,"aria-label":B().cropAreaText},(0,n.make)(`img`,{class:`wui-crop-img`,alt:``,draggable:`false`}),(0,n.make)(`div`,{class:`wui-crop-frame`})),(0,n.make)(`div`,{class:`wui-crop-controls`},(0,n.make)(`button`,{type:`button`,class:`wui-crop-zoombtn`,"data-zoom":`out`,"aria-label":B().zoomOutLabel},H([`M5 12h14`])),(0,n.make)(`input`,{type:`range`,class:`form-range wui-crop-zoom`,min:1,max:4,step:`0.01`,value:1,"aria-label":B().zoomLabel}),(0,n.make)(`button`,{type:`button`,class:`wui-crop-zoombtn`,"data-zoom":`in`,"aria-label":B().zoomInLabel},H([`M5 12h14M12 5v14`]))),(0,n.make)(`div`,{class:`wui-crop-tools`,hidden:!0},(0,n.make)(`button`,{type:`button`,class:`wui-crop-toolbtn`,"data-crop-action":`rotate`,"aria-label":B().rotateClockwiseLabel},H([`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,`M21 3v5h-5`],!0),(0,n.make)(`span`,null,B().rotateLabel)),(0,n.make)(`button`,{type:`button`,class:`wui-crop-toolbtn`,"data-crop-action":`reset`,"aria-label":B().resetCropLabel},H([`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,`M3 3v5h5`],!0),(0,n.make)(`span`,null,B().resetLabel))),(0,n.make)(`div`,{class:`wui-crop-previews`,"aria-hidden":`true`,hidden:!0}),(0,n.make)(`div`,{class:`visually-hidden`,"data-wui-crop-live":!0,"aria-live":`polite`}))),this._stageEl=K(this,`.wui-crop-stage`,HTMLElement),this._imgEl=K(this,`.wui-crop-img`,HTMLImageElement),this._frameEl=K(this,`.wui-crop-frame`,HTMLElement),this._sliderEl=K(this,`.wui-crop-zoom`,HTMLInputElement),this._toolsEl=K(this,`.wui-crop-tools`,HTMLElement),this._previewBoxEl=K(this,`.wui-crop-previews`,HTMLElement),this._liveEl=K(this,`[data-wui-crop-live]`,HTMLElement),this._rendered=!0,this._tools.hidden=!this.rotatable,this._applyRound(),this._rebuildHandles(),this._renderPreviews(),this._wire(),this._observe(),this._loadImage()}_applyRound(){this._frame.classList.toggle(`wui-crop-frame--round`,this.round),this._previewBox.classList.toggle(`wui-crop-previews--round`,this.round)}_rebuildHandles(){for(let e of this._frame.querySelectorAll(`.wui-crop-handle`))e.remove();if(!this.aspect)for(let e of y){let t=document.createElement(`button`);t.type=`button`,t.className=`wui-crop-handle wui-crop-handle--${e}`,t.dataset.handle=e,t.setAttribute(`aria-label`,(0,a.fillText)(B().resizeCornerText,{corner:V(e)})),this._frame.appendChild(t)}}_renderPreviews(){let e=T(this.previews);this._previewBox.replaceChildren(),this._previewBox.hidden=e.length===0;for(let t of e){let e=document.createElement(`canvas`);e.className=`wui-crop-preview`,e.dataset.size=String(t),e.style.width=`${t}px`,e.style.height=`${t}px`,this._previewBox.appendChild(e)}this._schedulePreviews()}_loadImage(){this._rect=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pinch=null,this._pointers.clear();let e=this.src;this._img.hidden=!e,this._frame.hidden=!0,e&&(this._img.onload=()=>{this._source={w:this._img.naturalWidth,h:this._img.naturalHeight},this._natural={...this._source},this._resetRect(),this.dispatchEvent(new Event(`load`))},this._img.onerror=()=>{this._frame.hidden=!0,this.dispatchEvent(new Event(`error`))},this._img.src=e)}_resetRect(){this._natural&&(this._base=f(this._natural.w,this._natural.h,this.aspect),this._rect={...this._base},this._frame.hidden=!1,this._paint())}_observe(){typeof ResizeObserver>`u`||this._resizeObserver||(this._resizeObserver=new ResizeObserver(()=>this._paint()),this._resizeObserver.observe(this._stage))}_view(){let e=G(this._natural,`natural size`),t=this._stage.clientWidth||R.w,n=this._stage.clientHeight||R.h,r=Math.min(t/e.w,n/e.h),i=e.w*r,a=e.h*r;return{scale:r,left:(t-i)/2,top:(n-a)/2,iw:i,ih:a}}_paint(){if(!this._rect)return;let e=this._view(),t=this._rotation%180!=0,n=t?e.ih:e.iw,r=t?e.iw:e.ih;Object.assign(this._img.style,{left:`${e.left+(e.iw-n)/2}px`,top:`${e.top+(e.ih-r)/2}px`,width:`${n}px`,height:`${r}px`,transform:this._rotation?`rotate(${this._rotation}deg)`:``});let i=this._rect;Object.assign(this._frame.style,{left:`${e.left+i.x*e.scale}px`,top:`${e.top+i.y*e.scale}px`,width:`${i.w*e.scale}px`,height:`${i.h*e.scale}px`});let a=G(this._base,`base frame`),o=g(i,a),s=_(i,a);this._slider.max=String(s),this._slider.value=String(Math.min(Math.max(o,1),s)),this._slider.setAttribute(`aria-valuetext`,`${Math.round(o*100)}%`),this._schedulePreviews()}_schedulePreviews(){if(!this._rect||this._previewBox.hidden||this._previewPending)return;this._previewPending=!0;let e=()=>{this._previewPending=!1,this._drawPreviews()};typeof requestAnimationFrame==`function`?requestAnimationFrame(e):e()}_drawPreviews(){if(!this._rect)return;let e=G(this._natural,`natural size`),t=p(this._rect,e.w,e.h),n=typeof window<`u`&&window.devicePixelRatio||1;for(let e of this._previewBox.children){if(!(e instanceof HTMLCanvasElement))throw Error(`Preview box holds a non-canvas child`);let r=e,i=Number(r.dataset.size),a=Math.max(1,Math.round(i*t.h/t.w));r.style.width=`${i}px`,r.style.height=`${a}px`,r.width=Math.round(i*n),r.height=Math.round(a*n);let o=r.getContext(`2d`);o&&this._drawCrop(o,t,r.width,r.height)}}_drawCrop(e,t,n,r){if(!this._rotation){e.drawImage(this._img,t.x,t.y,t.w,t.h,0,0,n,r);return}let i=G(this._source,`source size`),a=G(this._natural,`natural size`);e.save(),e.scale(n/t.w,r/t.h),e.translate(-t.x,-t.y),e.translate(a.w/2,a.h/2),e.rotate(this._rotation*Math.PI/180),e.drawImage(this._img,-i.w/2,-i.h/2,i.w,i.h),e.restore()}_announce(){this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:this.rect}))}_say(){let e=G(this._rect,`frame`),t=this._rotation?(0,a.fillText)(B().turnedText,{rotation:this._rotation}):``,n=(0,a.fillText)(B().frameText,{width:Math.round(e.w),height:Math.round(e.h),left:Math.round(e.x),top:Math.round(e.y),zoom:Math.round(g(e,G(this._base,`base frame`))*100),turned:t});this._live.textContent=n===this._live.textContent?`${n} `:n}rotate(){if(!this._rect)return;let e=G(this._natural,`natural size`),t=w(this._rect,e.w,e.h);this._rotation=(this._rotation+90)%360;let n=G(this._source,`source size`);this._natural=C(n.w,n.h,this._rotation),this._base=f(this._natural.w,this._natural.h,this.aspect);let r=this.aspect;this._rect=r&&r!==1?{...this._base}:t,this._paint(),this._announce()}reset(){this._source&&(this._rotation=0,this._natural={...this._source},this._resetRect(),this._announce())}_wire(){let e=this._stage;e.addEventListener(`pointerdown`,t=>{if(!this._rect||t.button>0)return;if(this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),e.setPointerCapture?.(t.pointerId),this._pointers.size===2){let[e,n]=W(this._pointers);this._drag=null,this._pinch={distance:U(e,n)||1,zoom:this.zoom,done:!1},t.preventDefault();return}if(this._pinch)return;let n=q(t.target);this._drag={id:t.pointerId,corner:n?n.dataset.handle:null,x:t.clientX,y:t.clientY,start:{...this._rect}},n||e.focus(),t.preventDefault()}),e.addEventListener(`pointermove`,t=>{if(this._pointers.has(t.pointerId)&&this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this._pinch){if(this._pinch.done||this._pointers.size<2||!this._pointers.has(t.pointerId))return;let[e,n]=W(this._pointers),r=this._pinch.zoom*U(e,n)/this._pinch.distance,i=G(this._natural,`natural size`);this._rect=v(G(this._rect,`frame`),G(this._base,`base frame`),r,i.w,i.h),this._paint();return}let n=this._drag;if(!n||n.id!==t.pointerId)return;let r=this._view(),{w:i,h:a}=G(this._natural,`natural size`);if(n.corner){let o=e.getBoundingClientRect(),s=(t.clientX-o.left-e.clientLeft-r.left)/r.scale,c=(t.clientY-o.top-e.clientTop-r.top)/r.scale;this._rect=b(G(this._rect,`frame`),n.corner,s,c,i,a)}else this._rect=m(n.start,(t.clientX-n.x)/r.scale,(t.clientY-n.y)/r.scale,i,a);this._paint()});let t=t=>{if(this._pointers.delete(t.pointerId)&&e.releasePointerCapture?.(t.pointerId),this._pinch){!this._pinch.done&&this._pointers.size<2&&(this._pinch.done=!0,this._announce()),this._pointers.size===0&&(this._pinch=null);return}let n=this._drag;n&&n.id===t.pointerId&&(this._drag=null,this._announce())};e.addEventListener(`pointerup`,t),e.addEventListener(`pointercancel`,t),e.addEventListener(`keydown`,e=>this._onKey(e)),e.addEventListener(`wheel`,e=>{this._rect&&this.contains(document.activeElement)&&(e.preventDefault(),this.zoom*=e.deltaY<0?1.1:1/1.1)},{passive:!1});for(let e of[`input`,`change`])this._slider.addEventListener(e,e=>e.stopPropagation());this._slider.addEventListener(`input`,()=>{this.zoom=Number(this._slider.value)});for(let e of this.querySelectorAll(`.wui-crop-zoombtn`)){if(!(e instanceof HTMLButtonElement))throw Error(`zoom button missing`);e.addEventListener(`click`,()=>{this.zoom*=e.dataset.zoom===`in`?1.25:.8})}K(this,`[data-crop-action="rotate"]`,HTMLButtonElement).addEventListener(`click`,()=>this.rotate()),K(this,`[data-crop-action="reset"]`,HTMLButtonElement).addEventListener(`click`,()=>this.reset())}_onKey(e){if(!this._rect||e.altKey||e.ctrlKey||e.metaKey)return;let{w:t,h:n}=G(this._natural,`natural size`);if(e.key===`+`||e.key===`=`)this.zoom*=1.25,this._say();else if(e.key===`-`||e.key===`_`)this.zoom*=.8,this._say();else if((e.key===`r`||e.key===`R`)&&this.rotatable)this.rotate(),this._say();else if(e.key.startsWith(`Arrow`)){let r=e.shiftKey?L:I,i=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:0,a=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,o=q(e.target)?.dataset.handle;if(o){let e=this._rect,s=(o.endsWith(`w`)?e.x:e.x+e.w)+i*r*e.w,c=(o.startsWith(`n`)?e.y:e.y+e.h)+a*r*e.h;this._rect=b(e,o,s,c,t,n)}else this._rect=m(this._rect,i*r*this._rect.w,a*r*this._rect.h,t,n);this._paint(),this._announce(),this._say()}else return;e.preventDefault()}async toBlob({type:e,maxBytes:t=0,size:n=0}={}){if(!this._rect)return null;let r=O(e),i=G(this._natural,`natural size`),a=p(this._rect,i.w,i.h),{width:o,height:s}=n>0?S(a,n):x(a);return A((e,t,n,r)=>new Promise(i=>{let o=document.createElement(`canvas`);o.width=e,o.height=t;let s=o.getContext(`2d`);s?(n===`image/jpeg`&&(s.fillStyle=`#fff`,s.fillRect(0,0,e,t)),this._drawCrop(s,a,e,t),o.toBlob(i,n,r)):i(null)}),{width:o,height:s,type:r,maxBytes:t})}async toFile({name:e,type:t,maxBytes:n=0,size:r=0}={}){let i=await this.toBlob({type:t,maxBytes:n,size:r});return i?new File([i],k(e,i.type),{type:i.type}):null}};(0,t.defineElement)(`wui-image-crop`,J),e.WuiImageCrop=J})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.svgNodes,WeborityUiElementsInternal.modules.textStore);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var u=globalThis.WeborityUiElementsInternal?.version;if(u!==`0.181.0`)throw Error(`[webority-ui] inline-edit expects ui-elements 0.181.0 but the page loaded `+u+`.`);var d=Object.freeze([`none`,`indian`]),f=e=>d.some(t=>t===e),p=e=>`grouping must be one of ${d.join(` or `)}, not "${String(e)}".`;function m(e){let t=/^(-?)(\d*)(\.\d*)?$/.exec(e);if(!t)return e;let[,n=``,r=``,i=``]=t;return r.length<=3?e:`${n}${(r.slice(0,-3).match(/\d{1,2}(?=(\d{2})*$)/g)??[]).join(`,`)},${r.slice(-3)}${i}`}var h=Object.freeze([`text`,`number`,`select`,`date`,`textarea`]),g=2e3;function _(e,{type:t=`text`,options:i,placeholder:a,grouping:o=`none`}={}){if(!f(o))throw Error(p(o));let s=e==null?``:String(e);if(s===``)return{text:a||(0,r.emptyValueLabel)(),empty:!0};if(t===`date`)return{text:(0,n.fmt)(s)||s,empty:!1};if(t===`select`){let e=i?.find(e=>String(e.value)===s);return{text:typeof e?.label==`string`?e.label:s,empty:!1}}return t===`number`&&o===`indian`?{text:m(s),empty:!1}:{text:s,empty:!1}}var v={emptyTitle:`Nothing here yet`,errorTitle:`That didn't load`,failedOnce:`Failed 1 time`,failedTimes:`Failed {count} times`,loadingLabel:`Loading`,retryFailedTitle:`That still didn't load`,retryLabel:`Try again`},y={clientMessage:`This could not be saved. Refresh the page and try again.`,editText:`Edit {label}: `,forbiddenMessage:`You do not have permission to change this.`,networkMessage:`Could not reach the server, so this was not saved. Check your connection and try again.`,notSavedText:`{label} was not saved. {reason}`,readOnlyText:`{label}: `,savedText:`{label} saved.`,serverMessage:`Something went wrong on our side, so this was not saved. Try again in a moment.`,validationMessage:`This value was not accepted. Check it and try again.`};function b(e){"@babel/helpers - typeof";return b=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},b(e)}function x(e,t){if(b(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(b(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function S(e){var t=x(e,`string`);return b(t)==`symbol`?t:t+``}function C(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=()=>(0,c.readText)(`inlineEdit`,y),T=()=>(0,c.readText)(`asyncBlock`,v),E=e=>typeof e==`object`&&!!e&&`value`in e&&typeof e.value==`string`&&`label`in e&&typeof e.label==`string`;async function D(e){let t=await(0,s.wuiFetch)(new URL(e,window.location.href).href,{headers:{Accept:`application/json`}});if(!t.ok)throw Error(`Loading options answered ${t.kind}.`);let n=JSON.parse(t.html),r=Array.isArray(n)?n:[];if(!Array.isArray(n)||!r.every(E))throw Error(`Options must be a JSON array of { value, label } strings.`);return r.filter(E)}var O=e=>h.some(t=>t===e),k=`[data-wui-display]`,A=`[data-wui-value]`,j=`[data-wui-editor]`,M=`[data-wui-control]`,N=`[data-wui-error]`,P=`[data-wui-live]`,F=`[aria-expanded="true"]`,I=new Set([`select`,`date`]),L=e=>{let t=(typeof e==`object`||typeof e==`function`)&&e!==null&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:w().serverMessage},R=e=>e instanceof HTMLElement&&typeof(`value`in e?e.value:void 0)==`string`,z=(e,t)=>{let n=e?.querySelector(t)??null;return n instanceof HTMLElement?n:null},B=class extends i.ElementBase{static get observedAttributes(){return[`disabled`]}constructor(){super(),C(this,`_wired`,void 0),C(this,`_editing`,void 0),C(this,`_busy`,void 0),C(this,`_draft`,void 0),C(this,`_pressed`,void 0),C(this,`_popupOpen`,void 0),C(this,`_savedTimer`,void 0),C(this,`_optionsLoaded`,void 0),C(this,`_optionsLoading`,void 0),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._optionsLoaded=!1,this._optionsLoading=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._grouping(),this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=z(this,k),t=z(this,j),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._needsLoad()&&this._loadOptions(),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())}_needsLoad(){return this._type()===`select`&&this.hasAttribute(`load-url`)&&!this._optionsLoaded}_loadOptions(){let e=this.getAttribute(`load-url`),t=this._control();e&&t&&this._optionsLoading===null&&(this._setError(null),t.setAttribute(`disabled`,``),this.setAttribute(`aria-busy`,`true`),Object.assign(t,{options:[{value:``,label:T().loadingLabel}]}),this._optionsLoading=D(e).then(e=>{this._optionsLoading=null,this._optionsLoaded=!0,this._showRows(t,e)},()=>{this._optionsLoading=null,this._showLoadError()}))}_showRows(e,t){this.removeAttribute(`aria-busy`),e.removeAttribute(`disabled`),Object.assign(e,{options:t}),e.value=this._draft??this._value(),this._editing&&this._focusControl(e)}_showLoadError(){this.removeAttribute(`aria-busy`);let e=z(this,N);if(!e)return;let t=T(),n=document.createElement(`button`);n.type=`button`,n.setAttribute(`data-wui-retry`,``),n.textContent=t.retryLabel,n.addEventListener(`click`,()=>this._loadOptions()),e.replaceChildren(`${t.errorTitle} `,n),e.hidden=!1,this._announce(t.errorTitle)}_onClick(e){e.stopPropagation();let t=e.target instanceof Node?e.target:null;e.type===`click`&&!this._editing&&this.querySelector(k)?.contains(t)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(j)?.querySelector(F))}_onKeyDown(e){if(!this._editing){((0,a.isImeSafeEnter)(e)||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||I.has(t)||(t!==`textarea`||e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget instanceof Node?e.relatedTarget:null;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!I.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;if(this._optionsLoading!==null){this.cancel();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 i=r?null:this._readShown();r||this._showValue(e),this._close();let a=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let s=this.getAttribute(`label`)||``;a.ok?(this.setAttribute(`value`,e),!r&&a.text&&this._showText(a.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),g),this._announce((0,c.fillText)(w().savedText,{label:s})),this._fire(`wui:inline-edit:saved`,{value:e,previous:t}),a.result&&!(0,o.isRefreshOff)(this)&&await(0,o.refreshAfter)(a.result,{origin:this})):(i&&this._restoreShown(i),a.kind===`session`||a.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(a.message),this._announce((0,c.fillText)(w().notSavedText,{label:s,reason:a.message})),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:a.kind,message:a.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:L(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let r=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),i=await(0,s.wuiFetch)(n,{method:`POST`,body:r});if(i.ok)return{ok:!0,text:i.data===null?i.html.trim():``,result:i};let a={forbidden:w().forbiddenMessage,networkCheck:(0,c.readText)(`httpFailure`,l.HTTP_FAILURE_TEXT).networkCheckText,client:w().clientMessage,validation:w().validationMessage,server:w().serverMessage,network:w().networkMessage};return{ok:!1,kind:i.kind,message:i.message||a[i.kind]||w().serverMessage}}_close(){let e=z(this,k),t=z(this,j),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),z(t,F)?.click(),n&&e?.focus()}_focusControl(e){if(!I.has(this._type())){e.focus(),e.select?.();return}let t=z(e,`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(e){if(e===``){this._showText(this.getAttribute(`placeholder`)||(0,r.emptyValueLabel)(),!0);return}let t=this._type(),i=e;if(t===`date`)i=(0,n.fmt)(e)||e;else if(t===`select`){let t=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(t=>t.getAttribute(`data-value`)===e);t&&(i=(t.textContent??``).trim())}else t===`number`&&this._grouping()===`indian`&&(i=m(e));this._showText(i,!1)}_readShown(){let e=this.querySelector(A);return e?{nodes:[...e.childNodes].map(e=>e.cloneNode(!0)),empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(A);t&&(t.replaceChildren(...e.nodes),t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(A);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=z(this,N),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(P);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){let e=this.querySelector(M);return R(e)?e:null}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return O(e)?e:`text`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!f(e))throw Error(p(e));return e}};(0,t.defineElement)(`wui-inline-edit`,B),e.INLINE_EDIT_SAVED_MS=g,e.INLINE_EDIT_TYPES=h,e.WuiInlineEdit=B,e.inlineEditText=_})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.calendarMath,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.refreshAfter,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.httpFailureText);
|
|
1
|
+
(function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var u=globalThis.WeborityUiElementsInternal?.version;if(u!==`0.181.1`)throw Error(`[webority-ui] inline-edit expects ui-elements 0.181.1 but the page loaded `+u+`.`);var d=Object.freeze([`none`,`indian`]),f=e=>d.some(t=>t===e),p=e=>`grouping must be one of ${d.join(` or `)}, not "${String(e)}".`;function m(e){let t=/^(-?)(\d*)(\.\d*)?$/.exec(e);if(!t)return e;let[,n=``,r=``,i=``]=t;return r.length<=3?e:`${n}${(r.slice(0,-3).match(/\d{1,2}(?=(\d{2})*$)/g)??[]).join(`,`)},${r.slice(-3)}${i}`}var h=Object.freeze([`text`,`number`,`select`,`date`,`textarea`]),g=2e3;function _(e,{type:t=`text`,options:i,placeholder:a,grouping:o=`none`}={}){if(!f(o))throw Error(p(o));let s=e==null?``:String(e);if(s===``)return{text:a||(0,r.emptyValueLabel)(),empty:!0};if(t===`date`)return{text:(0,n.fmt)(s)||s,empty:!1};if(t===`select`){let e=i?.find(e=>String(e.value)===s);return{text:typeof e?.label==`string`?e.label:s,empty:!1}}return t===`number`&&o===`indian`?{text:m(s),empty:!1}:{text:s,empty:!1}}var v={emptyTitle:`Nothing here yet`,errorTitle:`That didn't load`,failedOnce:`Failed 1 time`,failedTimes:`Failed {count} times`,loadingLabel:`Loading`,retryFailedTitle:`That still didn't load`,retryLabel:`Try again`},y={clientMessage:`This could not be saved. Refresh the page and try again.`,editText:`Edit {label}: `,forbiddenMessage:`You do not have permission to change this.`,networkMessage:`Could not reach the server, so this was not saved. Check your connection and try again.`,notSavedText:`{label} was not saved. {reason}`,readOnlyText:`{label}: `,savedText:`{label} saved.`,serverMessage:`Something went wrong on our side, so this was not saved. Try again in a moment.`,validationMessage:`This value was not accepted. Check it and try again.`};function b(e){"@babel/helpers - typeof";return b=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},b(e)}function x(e,t){if(b(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(b(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function S(e){var t=x(e,`string`);return b(t)==`symbol`?t:t+``}function C(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=()=>(0,c.readText)(`inlineEdit`,y),T=()=>(0,c.readText)(`asyncBlock`,v),E=e=>typeof e==`object`&&!!e&&`value`in e&&typeof e.value==`string`&&`label`in e&&typeof e.label==`string`;async function D(e){let t=await(0,s.wuiFetch)(new URL(e,window.location.href).href,{headers:{Accept:`application/json`}});if(!t.ok)throw Error(`Loading options answered ${t.kind}.`);let n=JSON.parse(t.html),r=Array.isArray(n)?n:[];if(!Array.isArray(n)||!r.every(E))throw Error(`Options must be a JSON array of { value, label } strings.`);return r.filter(E)}var O=e=>h.some(t=>t===e),k=`[data-wui-display]`,A=`[data-wui-value]`,j=`[data-wui-editor]`,M=`[data-wui-control]`,N=`[data-wui-error]`,P=`[data-wui-live]`,F=`[aria-expanded="true"]`,I=new Set([`select`,`date`]),L=e=>{let t=(typeof e==`object`||typeof e==`function`)&&e!==null&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:w().serverMessage},R=e=>e instanceof HTMLElement&&typeof(`value`in e?e.value:void 0)==`string`,z=(e,t)=>{let n=e?.querySelector(t)??null;return n instanceof HTMLElement?n:null},B=class extends i.ElementBase{static get observedAttributes(){return[`disabled`]}constructor(){super(),C(this,`_wired`,void 0),C(this,`_editing`,void 0),C(this,`_busy`,void 0),C(this,`_draft`,void 0),C(this,`_pressed`,void 0),C(this,`_popupOpen`,void 0),C(this,`_savedTimer`,void 0),C(this,`_optionsLoaded`,void 0),C(this,`_optionsLoading`,void 0),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._optionsLoaded=!1,this._optionsLoading=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._grouping(),this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=z(this,k),t=z(this,j),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._needsLoad()&&this._loadOptions(),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())}_needsLoad(){return this._type()===`select`&&this.hasAttribute(`load-url`)&&!this._optionsLoaded}_loadOptions(){let e=this.getAttribute(`load-url`),t=this._control();e&&t&&this._optionsLoading===null&&(this._setError(null),t.setAttribute(`disabled`,``),this.setAttribute(`aria-busy`,`true`),Object.assign(t,{options:[{value:``,label:T().loadingLabel}]}),this._optionsLoading=D(e).then(e=>{this._optionsLoading=null,this._optionsLoaded=!0,this._showRows(t,e)},()=>{this._optionsLoading=null,this._showLoadError()}))}_showRows(e,t){this.removeAttribute(`aria-busy`),e.removeAttribute(`disabled`),Object.assign(e,{options:t}),e.value=this._draft??this._value(),this._editing&&this._focusControl(e)}_showLoadError(){this.removeAttribute(`aria-busy`);let e=z(this,N);if(!e)return;let t=T(),n=document.createElement(`button`);n.type=`button`,n.setAttribute(`data-wui-retry`,``),n.textContent=t.retryLabel,n.addEventListener(`click`,()=>this._loadOptions()),e.replaceChildren(`${t.errorTitle} `,n),e.hidden=!1,this._announce(t.errorTitle)}_onClick(e){e.stopPropagation();let t=e.target instanceof Node?e.target:null;e.type===`click`&&!this._editing&&this.querySelector(k)?.contains(t)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(j)?.querySelector(F))}_onKeyDown(e){if(!this._editing){((0,a.isImeSafeEnter)(e)||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||I.has(t)||(t!==`textarea`||e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget instanceof Node?e.relatedTarget:null;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!I.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;if(this._optionsLoading!==null){this.cancel();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 i=r?null:this._readShown();r||this._showValue(e),this._close();let a=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let s=this.getAttribute(`label`)||``;a.ok?(this.setAttribute(`value`,e),!r&&a.text&&this._showText(a.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),g),this._announce((0,c.fillText)(w().savedText,{label:s})),this._fire(`wui:inline-edit:saved`,{value:e,previous:t}),a.result&&!(0,o.isRefreshOff)(this)&&await(0,o.refreshAfter)(a.result,{origin:this})):(i&&this._restoreShown(i),a.kind===`session`||a.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(a.message),this._announce((0,c.fillText)(w().notSavedText,{label:s,reason:a.message})),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:a.kind,message:a.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:L(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let r=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),i=await(0,s.wuiFetch)(n,{method:`POST`,body:r});if(i.ok)return{ok:!0,text:i.data===null?i.html.trim():``,result:i};let a={forbidden:w().forbiddenMessage,networkCheck:(0,c.readText)(`httpFailure`,l.HTTP_FAILURE_TEXT).networkCheckText,client:w().clientMessage,validation:w().validationMessage,server:w().serverMessage,network:w().networkMessage};return{ok:!1,kind:i.kind,message:i.message||a[i.kind]||w().serverMessage}}_close(){let e=z(this,k),t=z(this,j),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),z(t,F)?.click(),n&&e?.focus()}_focusControl(e){if(!I.has(this._type())){e.focus(),e.select?.();return}let t=z(e,`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(e){if(e===``){this._showText(this.getAttribute(`placeholder`)||(0,r.emptyValueLabel)(),!0);return}let t=this._type(),i=e;if(t===`date`)i=(0,n.fmt)(e)||e;else if(t===`select`){let t=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(t=>t.getAttribute(`data-value`)===e);t&&(i=(t.textContent??``).trim())}else t===`number`&&this._grouping()===`indian`&&(i=m(e));this._showText(i,!1)}_readShown(){let e=this.querySelector(A);return e?{nodes:[...e.childNodes].map(e=>e.cloneNode(!0)),empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(A);t&&(t.replaceChildren(...e.nodes),t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(A);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=z(this,N),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(P);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){let e=this.querySelector(M);return R(e)?e:null}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return O(e)?e:`text`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!f(e))throw Error(p(e));return e}};(0,t.defineElement)(`wui-inline-edit`,B),e.INLINE_EDIT_SAVED_MS=g,e.INLINE_EDIT_TYPES=h,e.WuiInlineEdit=B,e.inlineEditText=_})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.calendarMath,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.refreshAfter,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.httpFailureText);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o,s,c,l,u){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var d=globalThis.WeborityUiElementsInternal?.version;if(d!==`0.181.0`)throw Error(`[webority-ui] kanban expects ui-elements 0.181.0 but the page loaded `+d+`.`);var f={ariaLabel:`Board`,busyMessage:`This card is still saving. Try again in a moment.`,cancelledText:`{card} was not moved.`,cardLabel:`Card`,clientMessage:`This card could not be moved. Refresh the board and try again.`,collapseLabel:`Collapse {title}`,columnsLabel:`Board columns`,dropHereText:`Drop here to move {card} to {column}.`,emptyText:`Nothing here`,expandLabel:`Expand {title}`,fewerLabel:`Show fewer`,forbiddenMessage:`You do not have permission to move this card.`,helpText:`Press Space to pick up the card. Use the Left and Right arrow keys to choose a column, then Space to drop it, or Escape to cancel.`,liftedText:`Picked up {card} in {column}. Use the Left and Right arrow keys to choose a column.`,loadFailedMessage:`More cards could not be loaded. Try again.`,loadMoreText:`Show more ({n})`,loadingLabel:`Loading…`,lockedText:`{card} cannot be moved.`,moreText:`Show {count} more`,movedText:`Moved {card} to {column}.`,movingText:`Moving {card} to {column}.`,networkMessage:`Could not reach the server, so the card went back. Check your connection and try again.`,overRefusedText:`{column}. {reason}`,overSourceText:`{column}, where the card started.`,overTextOne:`{column}, 1 card. Drop allowed.`,overTextOther:`{column}, {count} cards. Drop allowed.`,refusedText:`Cards in {from} cannot move to {to}.`,rolledBackText:`{card} went back to {column}.`,serverMessage:`Something went wrong on our side, so the card went back. Try again in a moment.`,swipeHintText:`Swipe sideways or tap a column`},p=Object.freeze([`neutral`,`primary`,`info`,`success`,`warning`,`danger`]),m=Object.freeze([`number`,`currency`,`compact`]),h=`wui-kanban:`,g=`(max-width: 767.98px)`,_=400,v=6,y=()=>(0,o.readText)(`kanban`,f),b=e=>typeof e==`object`&&!!e,ee=e=>{let t=b(e)?e.collapsed:void 0;return b(t)?Object.fromEntries(Object.entries(t).map(([e,t])=>[e,!!t])):{}};function x(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);if(!Number.isInteger(t)||t<1)throw TypeError(`Unsupported kanban visible limit "${String(e)}". Use a whole number of 1 or more.`);return t}function S(e,t,n,r){let i=new Set;if(t==null||n)return i;let a=0;for(let n of e)r.has(n)||(a<t?a++:i.add(n));return i}function C(e){let t=(e.getAttribute(`aria-label`)||e.textContent||``).replace(/\s+/g,` `).trim();return t.length>80?`${t.slice(0,79)}…`:t||e.getAttribute(`data-wui-card`)||y().cardLabel}function w(e){return e?`${h}${e}`:null}function T(e,t=globalThis.localStorage){let n=w(e);if(!n||!t)return{};try{return ee(JSON.parse(t.getItem(n)||`null`))}catch{return{}}}function te(e,t,n,r=globalThis.localStorage){let i=w(e);if(!i||!r)return;let a={...T(e,r),[String(t)]:!!n};try{r.setItem(i,JSON.stringify({collapsed:a}))}catch(e){if(!(e instanceof DOMException))throw e}}function E(e,t){if(!m.includes(e))throw TypeError(`Unsupported kanban summary format "${String(e)}". Use ${m.join(`, `)}.`);if(t!=null&&t!==``&&!(0,i.isMoneyUnit)(t))throw TypeError(`Unsupported kanban summary unit "${String(t)}". Use ${i.MONEY_UNITS.join(`, `)}.`);return e===`currency`?{style:`currency`,currency:`INR`,unit:t||`rupees`}:e===`compact`?{style:`compact`,currency:`INR`,unit:t||`rupees`}:{style:`number`,decimals:0}}function D(e){let t=0;for(let n of e){if(n==null||n===``)continue;let e=typeof n==`number`?n:Number(n);Number.isFinite(e)&&(t+=e)}return t}var O=()=>(0,o.readText)(`kanban`,f),ne=()=>({forbidden:O().forbiddenMessage,networkCheck:(0,o.readText)(`httpFailure`,u.HTTP_FAILURE_TEXT).networkCheckText,client:O().clientMessage,validation:O().clientMessage,server:O().serverMessage,network:O().networkMessage}),k=`[data-wui-column]`,A=`[data-wui-body]`,j=`[data-wui-card]`,M=`[data-wui-count]`,N=`[data-wui-summary]`,re=`[data-wui-empty]`,P=`[data-wui-drop-note]`,ie=`[data-wui-live]`,ae=`[data-wui-help]`,F=`[data-wui-switch]`,oe=`[data-wui-scroller]`,I=`[data-wui-collapse]`,L=`[data-wui-more]`,R=`data-wui-visible-limit`,z=`data-wui-overflow`,se=`input, select, textarea, [contenteditable=""], [contenteditable="true"], [data-wui-no-drag]`,B=`[data-wui-load-more]`,V=`data-wui-more-url`,ce=`data-wui-total`,H=`data-wui-unloaded`,U=48,W=16,le=160,G=e=>e.getAttribute(`data-wui-column`),K=e=>e.getAttribute(`data-wui-card`),q=e=>e instanceof HTMLElement&&!!e.hidden||e.hasAttribute(`hidden`),ue=e=>q(e)||e.hasAttribute(z),J=e=>e instanceof Element?e:null,de=e=>typeof e==`object`&&e&&`name`in e?e.name:void 0,fe=e=>typeof e==`object`&&e&&`message`in e?e.message:void 0,Y=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},X=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),Z=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Q=()=>window.WUI??null,$=(e,t)=>{e&&Q()?.toast(e,{variant:t})},pe=class extends r.ElementBase{constructor(){super(),this._wired=!1,this._filter=null,this._expanded=new Set,this._revealed=new Set,this._press=null,this._drag=null,this._kbd=null,this._suppressClick=!1,this._observer=null,this._refreshQueued=!1,this._scrollTimer=0,this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onPointerCancel=()=>this._endPointer(!1),this._onDocKeyDown=e=>{e.key===`Escape`&&this._drag&&(e.preventDefault(),this._endPointer(!1))},this._onScroll=()=>{clearTimeout(this._scrollTimer),this._scrollTimer=setTimeout(()=>this._syncSwitcherFromScroll(),80)},this.addEventListener(`pointerdown`,e=>this._pointerDown(e)),this.addEventListener(`keydown`,e=>this._keyDown(e)),this.addEventListener(`click`,e=>this._click(e),!0),this.addEventListener(`scroll`,e=>{e.target instanceof Element&&this._loadOnScroll(e.target)},!0),this.addEventListener(`dragstart`,e=>{J(e.target)?.closest(j)&&e.preventDefault()}),this.addEventListener(`touchmove`,e=>{this._drag&&e.preventDefault()},{passive:!1})}_controlled(){return this.hasAttribute(`controlled`)}connectedCallback(){if(!this._wired){this._wired=!0,this._scroller()?.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._restoreCollapsed();for(let e of this._allCards())this._prepareCard(e);if(typeof MutationObserver==`function`){this._observer=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e instanceof HTMLElement&&e.matches(j)&&this._prepareCard(e);this._queueRefresh()});for(let e of this.querySelectorAll(A))this._observer.observe(e,{childList:!0})}this.refresh()}}disconnectedCallback(){this._endPointer(!1),this._observer?.disconnect(),this._observer=null,this._scroller()?.removeEventListener(`scroll`,this._onScroll),clearTimeout(this._scrollTimer),this._wired=!1}setFilter(e){if(e!=null&&typeof e!=`function`)throw TypeError(`wui-kanban setFilter: pass a function or null.`);if(this._filter=e,!e)for(let e of this._allCards())e.hidden=!1;this.refresh()}refresh(){if(this._controlled())return;this._refreshQueued=!1;let e=this._summaryFormat();for(let t of this._columns()){let n=G(t),r=x(t.getAttribute(R)),a=[],s=[];for(let e of this._cardsIn(t))this._filter&&(e.hidden=this._filter(e)===!1),q(e)?e.removeAttribute(z):(a.push(e),s.push(e.getAttribute(`data-wui-value`)));let c=this._expanded.has(n),l=S(a.map(K),r,c,this._revealed);for(let e of a)e.toggleAttribute(z,l.has(K(e)));let u=this._unloadedIn(t),d=String(a.length+u);for(let e of this._countsOf(t))e.textContent!==d&&(e.textContent=d);let f=Y(t,re,HTMLElement);if(f&&(f.hidden=a.length>0),e){let n=t.querySelector(N);n&&(n.textContent=(0,i.formatValue)(D(s),e))}let p=Y(t,L,HTMLElement);if(p){p.hidden=r==null||(c?a.length<=r:l.size===0),p.setAttribute(`aria-expanded`,c?`true`:`false`);let e=c?O().fewerLabel:(0,o.fillText)(O().moreText,{count:l.size});p.textContent!==e&&(p.textContent=e)}let m=Y(t,B,HTMLButtonElement);if(m&&(m.hidden=u<=0,!t.hasAttribute(`data-wui-loading`))){m.disabled=!1;let e=(0,o.fillText)(O().loadMoreText,{n:u});m.textContent!==e&&(m.textContent=e)}}}moveCard(e,t,n){let r=this._cardByKey(e);if(!r)throw Error(`wui-kanban moveCard: no card "${String(e)}" on this board.`);if(!this._columnByKey(t))throw Error(`wui-kanban moveCard: no column "${String(t)}" on this board.`);return this._commit(r,t,n)}_columns(){return X(this,k,HTMLElement)}_columnByKey(e){return this._columns().find(t=>G(t)===e)||null}_columnOf(e){return Z(e,k,HTMLElement)}_titleOf(e){return(e.querySelector(`.wui-kanban-title`)?.textContent||G(e)||``).replace(/\s+/g,` `).trim()}_bodyOf(e){return Y(e,A,HTMLElement)}_cardsIn(e){let t=this._bodyOf(e);return t?[...t.children].filter(e=>e instanceof HTMLElement&&e.matches(j)):[]}_visibleCardsIn(e){return this._cardsIn(e).filter(e=>!ue(e))}_allCards(){return X(this,`${A} > ${j}`,HTMLElement)}_cardByKey(e){return this._allCards().find(t=>K(t)===e)||null}_countsOf(e){let t=G(e),n=[...this.querySelectorAll(F)].filter(e=>e.getAttribute(`data-wui-switch`)===t);return[...e.querySelectorAll(M),...n.flatMap(e=>[...e.querySelectorAll(M)])]}_scroller(){return Y(this,oe,HTMLElement)}_summaryFormat(){let e=this.getAttribute(`summary-format`);return e?E(e,this.getAttribute(`summary-unit`)):null}_queueRefresh(){this._refreshQueued||(this._refreshQueued=!0,queueMicrotask(()=>{this._refreshQueued&&this.refresh()}))}_prepareCard(e){let t=this.querySelector(ae);t?.id&&!e.hasAttribute(`aria-describedby`)&&e.setAttribute(`aria-describedby`,t.id),e.hasAttribute(`tabindex`)||(e.tabIndex=0)}_announce(e){let t=Y(this,ie,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t,n=!1){return this.dispatchEvent(new CustomEvent(e,{bubbles:!0,cancelable:n,detail:t}))}_canLift(e){let t=C(e),n=this.hasAttribute(`readonly`);return n||e.hasAttribute(`data-wui-locked`)?(this._announce((0,o.fillText)(O().lockedText,{card:t})),this._fire(`wui:kanban:locked`,{key:K(e),card:e,reason:n?`readonly`:`locked`},!0),!1):e.getAttribute(`aria-busy`)!==`true`||(this._announce(O().busyMessage),$(O().busyMessage,`info`),!1)}_check(e,t,n){if(t===n)return{ok:!1,source:!0,reason:null};let r=this._columnByKey(t),i=this._columnByKey(n),a=(0,o.fillText)(O().refusedText,{from:r?this._titleOf(r):String(t),to:i?this._titleOf(i):String(n)}),s=i?.getAttribute(`data-accept-from`),c=s?.split(/\s+/).filter(Boolean)??[];if(s!=null&&!c.includes(t))return{ok:!1,reason:a};if(typeof this.accept==`function`){let r=this.accept(e,t,n);if(r===!1)return{ok:!1,reason:a};if(typeof r==`string`&&r)return{ok:!1,reason:r}}return{ok:!0,reason:null}}_markTargets(e,t){let n=C(e),r=new Map;for(let i of this._columns()){let a=G(i),s=this._check(e,t,a);r.set(a,s),i.setAttribute(`data-wui-drop`,s.source?`source`:s.ok?`ok`:`refused`);let c=Y(i,P,HTMLElement);c&&!s.source&&(c.textContent=s.ok?(0,o.fillText)(O().dropHereText,{card:n,column:this._titleOf(i)}):s.reason,c.hidden=!1)}return r}_clearTargets(){for(let e of this._columns()){e.removeAttribute(`data-wui-drop`),e.removeAttribute(`data-wui-over`),e.removeAttribute(`data-wui-target`);let t=Y(e,P,HTMLElement);t&&(t.hidden=!0,t.textContent=``)}}async _commit(e,t,n){let r=this._columnOf(e);if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let i=G(r),a=this._columnByKey(t),s=C(e);if(i===t||!this._canLift(e))return!1;let c=this._check(e,i,t);if(!c.ok)return this._announce(c.reason),$(c.reason,`info`),!1;if(!a)throw Error(`wui-kanban: no column "${String(t)}" on this board.`);let u=this._cardsIn(a),d=Number.isInteger(n)?Math.max(0,Math.min(n??0,u.length)):u.length,f={key:K(e),card:e,from:i,to:t,index:d},p=e.contains(document.activeElement);if(this._controlled())return this._fire(`wui:kanban:move`,f),this._announce((0,o.fillText)(O().movedText,{card:s,column:this._titleOf(a)})),p&&this._refocusSoon(f.key),!0;if(!this._fire(`wui:kanban:move`,f,!0))return!1;let m=a.hasAttribute(R)&&!this._revealed.has(f.key);m&&this._revealed.add(f.key);let h={parent:e.parentNode,next:e.nextSibling,column:r,revealed:m},g=this._bodyOf(a);if(!g)throw Error(`wui-kanban: the target column has no body.`);g.insertBefore(e,u[d]||null),p&&this._focusMoved(e),this.refresh();let _=a.getAttribute(`data-wui-step`);if(_)return this._runStep(e,f,h,_,a.getAttribute(`data-wui-step-size`));let v=this.getAttribute(`move-url`);if(!v)return this._announce((0,o.fillText)(O().movedText,{card:s,column:this._titleOf(a)})),this._fire(`wui:kanban:moved`,{...f,result:null}),!0;this._lock(e,!0),this._announce((0,o.fillText)(O().movingText,{card:s,column:this._titleOf(a)}));let y=new URLSearchParams({card:String(f.key),from:String(i),to:String(t),index:String(d)}),b=await(0,l.wuiFetch)(v,{method:`POST`,body:y});if(this._lock(e,!1),b.kind===`session`)return!1;if(b.ok){let t=this._applyFragment(b.html)||e;return $(b.message,`success`),this._announce((0,o.fillText)(O().movedText,{card:C(t),column:this._titleOf(a)})),this._fire(`wui:kanban:moved`,{...f,card:t,result:b}),!0}return this._rollback(e,h),b.kind!==`aborted`&&$(b.message||ne()[b.kind]||O().serverMessage,`danger`),this._fire(`wui:kanban:failed`,{...f,kind:b.kind,status:b.status,message:b.message}),!1}async _runStep(e,t,n,r,i){let a=C(e),s=this._columnByKey(t.to),c=new URLSearchParams({card:String(t.key),from:String(t.from),to:String(t.to)}).toString(),u=r+(r.includes(`?`)?`&`:`?`)+c;this._lock(e,!0);let d;try{let t=window.WUI?.modal?.load;if(typeof t!=`function`)throw Error(`<wui-kanban> data-wui-step needs the Razor script webority-ui.js (WUI.modal.load).`);d=await(await t(u,{trigger:e,size:i||void 0})).closed}catch(r){return this._lock(e,!1),this._rollback(e,n),de(r)!==`AbortError`&&$(O().serverMessage,`danger`),this._fire(`wui:kanban:failed`,{...t,kind:`step`,status:0,message:fe(r)??null}),!1}if(d?.status!==`success`)return this._lock(e,!1),this._rollback(e,n),this._announce((0,o.fillText)(O().cancelledText,{card:a})),this._fire(`wui:kanban:failed`,{...t,kind:`dismissed`,status:0,message:null}),!1;let f=e,p=this.getAttribute(`card-url`);if(p){let n=await(0,l.wuiFetch)(`${p}${p.includes(`?`)?`&`:`?`}${new URLSearchParams({card:String(t.key)})}`);n.ok&&(f=this._applyFragment(n.html)||e)}if(this._lock(f,!1),!s)throw Error(`wui-kanban: no column "${String(t.to)}" on this board.`);return this._announce((0,o.fillText)(O().movedText,{card:C(f),column:this._titleOf(s)})),this._fire(`wui:kanban:moved`,{...t,card:f,result:d}),!0}_lock(e,t){t?(e.setAttribute(`aria-busy`,`true`),e.setAttribute(`data-wui-saving`,``)):(e.removeAttribute(`aria-busy`),e.removeAttribute(`data-wui-saving`))}_rollback(e,t){let n=e.contains(document.activeElement),r=t.next&&t.next.parentNode===t.parent?t.next:null;if(t.revealed&&this._revealed.delete(K(e)),!t.parent)throw Error(`wui-kanban: the card had no parent to go back to.`);t.parent.insertBefore(e,r),n&&e.focus(),this.refresh(),this._announce((0,o.fillText)(O().rolledBackText,{card:C(e),column:this._titleOf(t.column)}))}_applyFragment(e){if(!e)return null;let t=(0,c.parseServerHtml)(e);for(let e of t.querySelectorAll(`script`))(0,n.devWarn)(`[@webority/ui-elements] A kanban fragment carried a script tag; it was removed, not run.`),e.remove();let r=null;for(let e of X(t,j,HTMLElement)){if(e.closest(`template`))continue;let t=this._cardByKey(K(e));if(!t)continue;let n=t.contains(document.activeElement);t.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),t.hidden&&(e.hidden=!0),t.replaceWith(e),this._prepareCard(e),n&&e.focus(),r??=e}for(let e of X(t,`template[data-wui-kanban-summary]`,HTMLTemplateElement))this._columnByKey(e.getAttribute(`data-wui-kanban-summary`))?.querySelector(N)?.replaceChildren(e.content.cloneNode(!0));return this.refresh(),Q()?.refresh(),r}_refocusSoon(e){let t=()=>{let t=this._cardByKey(e);t&&this._focusMoved(t)};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}_focusMoved(e){e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`nearest`})}_pointerDown(e){if(e.button!==0||e.isPrimary===!1||this._drag||this._kbd)return;let t=J(e.target),n=t?Z(t,j,HTMLElement):null;if(!n||!this.contains(n)||t?.closest(se))return;let r={card:n,id:e.pointerId,x:e.clientX,y:e.clientY,type:e.pointerType,timer:0};this._press=r,e.pointerType===`touch`&&(r.timer=setTimeout(()=>{this._press===r&&this._startDrag(r,r.x,r.y)},400)),window.addEventListener(`pointermove`,this._onPointerMove),window.addEventListener(`pointerup`,this._onPointerUp),window.addEventListener(`pointercancel`,this._onPointerCancel)}_pointerMove(e){let t=this._press;if(t&&e.pointerId===t.id){if(!this._drag){if(!(Math.hypot(e.clientX-t.x,e.clientY-t.y)>6))return;if(t.type===`touch`){this._endPointer(!1);return}if(this._startDrag(t,e.clientX,e.clientY),!this._drag)return}this._dragTo(e.clientX,e.clientY)}}_pointerUp(e){this._press&&e.pointerId===this._press.id&&this._endPointer(!!this._drag)}_startDrag(e,t,n){let r=e.card;if(!this._canLift(r)){this._endPointer(!1);return}let i=this._columnOf(r);if(!i)throw Error(`wui-kanban: the card is not inside a column.`);let a=G(i),s=r.getBoundingClientRect(),c=r.cloneNode(!0);if(!(c instanceof HTMLElement))return;let l=c;for(let e of[l,...l.querySelectorAll(`[id]`)])e.removeAttribute(`id`);l.removeAttribute(`data-wui-card`),l.removeAttribute(`tabindex`),l.setAttribute(`aria-hidden`,`true`),l.classList.add(`wui-kanban-ghost`),l.style.width=`${s.width}px`,this.appendChild(l),r.setAttribute(`data-wui-dragging`,``),this.setAttribute(`data-wui-dragging`,``),this._drag={card:r,from:a,ghost:l,dx:t-s.left,dy:n-s.top,x:t,y:n,over:null,verdicts:this._markTargets(r,a)},this._announce((0,o.fillText)(O().liftedText,{card:C(r),column:this._titleOf(i)})),document.addEventListener(`keydown`,this._onDocKeyDown),this._dragTo(t,n)}_dragTo(e,t){let n=this._drag;if(!n)throw Error(`wui-kanban: no drag in progress.`);n.x=e,n.y=t,n.ghost.style.transform=`translate(${e-n.dx}px, ${t-n.dy}px)`;let r=this._columnAt(e,t);r!==n.over&&(n.over?.removeAttribute(`data-wui-over`),r?.setAttribute(`data-wui-over`,``),n.over=r),this._autoScroll(e,t,r)}_columnAt(e,t){for(let n of this._columns()){let r=n.getBoundingClientRect();if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom)return n}return null}_indexAt(e,t){let n=this._visibleCardsIn(e).filter(e=>e!==this._drag?.card).find(e=>{let n=e.getBoundingClientRect();return t<n.top+n.height/2}),r=this._cardsIn(e).filter(e=>e!==this._drag?.card);return n?r.indexOf(n):r.length}_autoScroll(e,t,n){let r=this._scroller();if(r){let t=r.getBoundingClientRect();t.width>0&&(e<t.left+U?r.scrollBy?.({left:-16}):e>t.right-U&&r.scrollBy?.({left:W}))}if(n&&this._scrollColumn(n,t))return;let i=window.innerHeight||0;i>0&&(t<U?window.scrollBy?.({top:-16}):t>i-U&&window.scrollBy?.({top:W}))}_scrollColumn(e,t){let n=this._bodyOf(e);if(!n||e.hasAttribute(`data-collapsed`)||n.scrollHeight<=n.clientHeight)return!1;let r=n.getBoundingClientRect();return t<r.top+U&&n.scrollTop>0?(n.scrollBy?.({top:-16}),!0):t>r.bottom-U&&n.scrollTop+n.clientHeight<n.scrollHeight-1&&(n.scrollBy?.({top:W}),!0)}_endPointer(e){let t=this._press,n=this._drag;if(t&&clearTimeout(t.timer||void 0),this._press=null,this._drag=null,window.removeEventListener(`pointermove`,this._onPointerMove),window.removeEventListener(`pointerup`,this._onPointerUp),window.removeEventListener(`pointercancel`,this._onPointerCancel),document.removeEventListener(`keydown`,this._onDocKeyDown),!n)return;n.ghost.remove(),n.card.removeAttribute(`data-wui-dragging`),this.removeAttribute(`data-wui-dragging`),this._suppressClick=!0,setTimeout(()=>{this._suppressClick=!1},0);let r=n.over;if(this._clearTargets(),!e||!r){this._announce((0,o.fillText)(O().cancelledText,{card:C(n.card)}));return}let i=G(r),a=n.verdicts.get(i);a?.source?this._announce((0,o.fillText)(O().cancelledText,{card:C(n.card)})):a?.ok?this._commit(n.card,i,this._indexAt(r,n.y)):(this._announce(a?.reason),$(a?.reason,`info`))}_click(e){let t=J(e.target);if(this._suppressClick&&t?.closest(j)){e.preventDefault(),e.stopPropagation(),this._suppressClick=!1;return}let n=t?.closest(I);if(n&&this.contains(n)){let e=Z(n,k,HTMLElement);e&&this._setCollapsed(e,!e.hasAttribute(`data-collapsed`),!0);return}let r=t?.closest(B);if(r&&this.contains(r)){this._controlled()||this._loadMore(Z(r,k,HTMLElement));return}let i=t?.closest(L);if(i&&this.contains(i)){this._controlled()||this._toggleMore(Z(i,k,HTMLElement));return}let a=t?.closest(F);a&&this.contains(a)&&this._showColumn(a.getAttribute(`data-wui-switch`))}_keyDown(e){let t=this._kbd;if(t){this._liftedKey(e,t);return}let n=e.target instanceof HTMLElement?e.target:null;if(!n?.matches(j)||!this.contains(n))return;let r=this._columnOf(n),i=(0,s.mirrorKey)(e.key,(0,s.isRtl)(this));switch(i){case` `:case`Spacebar`:{if(e.preventDefault(),!this._canLift(n))return;if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let t=G(r),i=this._columns();this._kbd={card:n,from:t,target:i.indexOf(r),verdicts:this._markTargets(n,t)},n.setAttribute(`data-wui-lifted`,``),this.setAttribute(`data-wui-dragging`,``),r.setAttribute(`data-wui-target`,``),this._announce((0,o.fillText)(O().liftedText,{card:C(n),column:this._titleOf(r)}));return}case`ArrowDown`:case`ArrowUp`:{if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let t=this._visibleCardsIn(r),i=t[t.indexOf(n)+(e.key===`ArrowDown`?1:-1)];i&&(e.preventDefault(),i.focus());return}case`ArrowLeft`:case`ArrowRight`:{let t=this._columns(),n=i===`ArrowRight`?1:-1;for(let i=(r?t.indexOf(r):-1)+n;i>=0&&i<t.length;i+=n){let n=t[i],r=n?this._visibleCardsIn(n)[0]:void 0;if(r&&n&&!n.hasAttribute(`data-collapsed`)){e.preventDefault(),r.focus();return}}return}}}_liftedKey(e,t){let n=this._columns(),r=(0,s.mirrorKey)(e.key,(0,s.isRtl)(this));switch(r){case`ArrowLeft`:case`ArrowRight`:{e.preventDefault();let i=t.target+(r===`ArrowRight`?1:-1);if(i<0||i>=n.length)return;n[t.target]?.removeAttribute(`data-wui-target`),t.target=i;let a=n[i];if(!a)return;a.setAttribute(`data-wui-target`,``),this._showColumn(G(a),!1);let s=t.verdicts.get(G(a));if(!s)throw Error(`wui-kanban: no verdict for the column.`);let c=this._titleOf(a);this._announce(s.source?(0,o.fillText)(O().overSourceText,{column:c}):s.ok?(0,o.pluralText)(O(),`overText`,this._cardsIn(a).filter(e=>!q(e)).length,{column:c}):(0,o.fillText)(O().overRefusedText,{column:c,reason:s.reason??``}));return}case` `:case`Spacebar`:case`Enter`:{e.preventDefault();let r=n[t.target];if(!r)throw Error(`wui-kanban: the lifted card has no target column.`);let i=G(r),a=t.verdicts.get(i);if(!a)throw Error(`wui-kanban: no verdict for the column.`);if(!a.source&&!a.ok){this._announce(a.reason);return}this._endKeyboard(),a.source?this._announce((0,o.fillText)(O().cancelledText,{card:C(t.card)})):this._commit(t.card,i);return}case`Escape`:case`Tab`:e.key===`Escape`&&e.preventDefault(),this._endKeyboard(),this._showColumn(t.from,!1),this._announce((0,o.fillText)(O().cancelledText,{card:C(t.card)}));return}}_endKeyboard(){let e=this._kbd;this._kbd=null,e&&(e.card.removeAttribute(`data-wui-lifted`),this.removeAttribute(`data-wui-dragging`),this._clearTargets())}_restoreCollapsed(){let e=T(this.getAttribute(`board-id`));for(let t of this._columns()){let n=G(t);t.hasAttribute(`data-collapsible`)&&(0,a.hasOwn)(e,String(n))&&this._setCollapsed(t,e[String(n)],!1)}}_setCollapsed(e,t,n){let r=G(e);e.toggleAttribute(`data-collapsed`,t);let i=this._titleOf(e);for(let n of e.querySelectorAll(I))n.setAttribute(`aria-expanded`,t?`false`:`true`),n.setAttribute(`aria-label`,t?(0,o.fillText)(O().expandLabel,{title:i}):(0,o.fillText)(O().collapseLabel,{title:i}));n&&(te(this.getAttribute(`board-id`),r,t),this._fire(`wui:kanban:collapse`,{column:r,collapsed:t}))}_toggleMore(e){if(!e)return;let t=G(e);if(this._expanded.delete(t))for(let t of this._cardsIn(e))this._revealed.delete(K(t));else this._expanded.add(t);this.refresh()}_unloadedIn(e){return e.hasAttribute(V)?(e.hasAttribute(H)||e.setAttribute(H,String(Math.max(0,Number(e.getAttribute(ce))-this._cardsIn(e).length))),Number(e.getAttribute(H))):0}async _loadMore(e){if(!e)throw Error(`wui-kanban: the load-more button is outside a column.`);let t=Number(e.getAttribute(H));if(e.hasAttribute(`data-wui-loading`)||!(t>0))return;e.setAttribute(`data-wui-loading`,``);let r=Y(e,B,HTMLButtonElement);r&&(r.disabled=!0,r.textContent=O().loadingLabel);let i=new URL(String(e.getAttribute(V)),document.baseURI);i.searchParams.set(`skip`,String(this._cardsIn(e).length));let a=0,o=!1;try{let n=await(0,l.wuiFetch)(i.toString());if(n.ok){let r=(0,c.parseServerHtml)(n.html),i=this._bodyOf(e);for(let e of[...r.children])if(e.matches(j)&&!this._cardByKey(K(e))){if(!i)throw Error(`wui-kanban: the column has no body.`);i.append(e),a++}let s=n.response?.headers.get(`Wui-Kanban-Remaining`)??``;e.setAttribute(H,String(/^\d+$/.test(s)?Number(s):Math.max(0,t-a))),o=!0}}catch(e){(0,n.devError)(`[@webority/ui-elements] A kanban column could not load its next cards.`,e)}e.removeAttribute(`data-wui-loading`),this.refresh(),o?this._fire(`wui:kanban:loaded`,{key:G(e),added:a}):$(O().loadFailedMessage,`danger`)}_loadOnScroll(e){if(this._controlled()||!e.matches(A))return;let t=Z(e,k,HTMLElement);t?.hasAttribute(V)&&e.scrollTop+e.clientHeight>=e.scrollHeight-le&&this._loadMore(t)}_isPhone(){return typeof matchMedia==`function`&&matchMedia(`(max-width: 767.98px)`).matches}_showColumn(e,t=!0){for(let t of this.querySelectorAll(F))t.getAttribute(`data-wui-switch`)===e?t.setAttribute(`aria-current`,`true`):t.removeAttribute(`aria-current`);let n=this._columnByKey(e),r=this._scroller();if(!n||!r||!t&&!this._isPhone())return;let i=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollTo?.({left:n.offsetLeft-r.offsetLeft,behavior:i?`auto`:`smooth`})}_syncSwitcherFromScroll(){let e=this._scroller();if(!e||!this._isPhone())return;let t=e.clientWidth||1,n=this._columns()[Math.round(e.scrollLeft/t)];if(n)for(let e of this.querySelectorAll(F))e.getAttribute(`data-wui-switch`)===G(n)?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`)}};(0,t.defineElement)(`wui-kanban`,pe),e.KANBAN_DRAG_THRESHOLD_PX=v,e.KANBAN_LONG_PRESS_MS=_,e.KANBAN_PHONE_QUERY=g,e.KANBAN_STORAGE_PREFIX=h,e.KANBAN_SUMMARY_FORMATS=m,e.KANBAN_TONES=p,e.WuiKanban=pe,e.kanbanCardLabel=C,e.kanbanOverflow=S,e.kanbanStorageKey=w,e.kanbanSummaryFormat=E,e.kanbanVisibleLimit=x,e.readKanbanCollapsed=T,e.sumKanbanValues=D,e.writeKanbanCollapsed=te})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.httpFailureText);
|
|
1
|
+
(function(e,t,n,r,i,a,o,s,c,l,u){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var d=globalThis.WeborityUiElementsInternal?.version;if(d!==`0.181.1`)throw Error(`[webority-ui] kanban expects ui-elements 0.181.1 but the page loaded `+d+`.`);var f={ariaLabel:`Board`,busyMessage:`This card is still saving. Try again in a moment.`,cancelledText:`{card} was not moved.`,cardLabel:`Card`,clientMessage:`This card could not be moved. Refresh the board and try again.`,collapseLabel:`Collapse {title}`,columnsLabel:`Board columns`,dropHereText:`Drop here to move {card} to {column}.`,emptyText:`Nothing here`,expandLabel:`Expand {title}`,fewerLabel:`Show fewer`,forbiddenMessage:`You do not have permission to move this card.`,helpText:`Press Space to pick up the card. Use the Left and Right arrow keys to choose a column, then Space to drop it, or Escape to cancel.`,liftedText:`Picked up {card} in {column}. Use the Left and Right arrow keys to choose a column.`,loadFailedMessage:`More cards could not be loaded. Try again.`,loadMoreText:`Show more ({n})`,loadingLabel:`Loading…`,lockedText:`{card} cannot be moved.`,moreText:`Show {count} more`,movedText:`Moved {card} to {column}.`,movingText:`Moving {card} to {column}.`,networkMessage:`Could not reach the server, so the card went back. Check your connection and try again.`,overRefusedText:`{column}. {reason}`,overSourceText:`{column}, where the card started.`,overTextOne:`{column}, 1 card. Drop allowed.`,overTextOther:`{column}, {count} cards. Drop allowed.`,refusedText:`Cards in {from} cannot move to {to}.`,rolledBackText:`{card} went back to {column}.`,serverMessage:`Something went wrong on our side, so the card went back. Try again in a moment.`,swipeHintText:`Swipe sideways or tap a column`},p=Object.freeze([`neutral`,`primary`,`info`,`success`,`warning`,`danger`]),m=Object.freeze([`number`,`currency`,`compact`]),h=`wui-kanban:`,g=`(max-width: 767.98px)`,_=400,v=6,y=()=>(0,o.readText)(`kanban`,f),b=e=>typeof e==`object`&&!!e,ee=e=>{let t=b(e)?e.collapsed:void 0;return b(t)?Object.fromEntries(Object.entries(t).map(([e,t])=>[e,!!t])):{}};function x(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);if(!Number.isInteger(t)||t<1)throw TypeError(`Unsupported kanban visible limit "${String(e)}". Use a whole number of 1 or more.`);return t}function S(e,t,n,r){let i=new Set;if(t==null||n)return i;let a=0;for(let n of e)r.has(n)||(a<t?a++:i.add(n));return i}function C(e){let t=(e.getAttribute(`aria-label`)||e.textContent||``).replace(/\s+/g,` `).trim();return t.length>80?`${t.slice(0,79)}…`:t||e.getAttribute(`data-wui-card`)||y().cardLabel}function w(e){return e?`${h}${e}`:null}function T(e,t=globalThis.localStorage){let n=w(e);if(!n||!t)return{};try{return ee(JSON.parse(t.getItem(n)||`null`))}catch{return{}}}function te(e,t,n,r=globalThis.localStorage){let i=w(e);if(!i||!r)return;let a={...T(e,r),[String(t)]:!!n};try{r.setItem(i,JSON.stringify({collapsed:a}))}catch(e){if(!(e instanceof DOMException))throw e}}function E(e,t){if(!m.includes(e))throw TypeError(`Unsupported kanban summary format "${String(e)}". Use ${m.join(`, `)}.`);if(t!=null&&t!==``&&!(0,i.isMoneyUnit)(t))throw TypeError(`Unsupported kanban summary unit "${String(t)}". Use ${i.MONEY_UNITS.join(`, `)}.`);return e===`currency`?{style:`currency`,currency:`INR`,unit:t||`rupees`}:e===`compact`?{style:`compact`,currency:`INR`,unit:t||`rupees`}:{style:`number`,decimals:0}}function D(e){let t=0;for(let n of e){if(n==null||n===``)continue;let e=typeof n==`number`?n:Number(n);Number.isFinite(e)&&(t+=e)}return t}var O=()=>(0,o.readText)(`kanban`,f),ne=()=>({forbidden:O().forbiddenMessage,networkCheck:(0,o.readText)(`httpFailure`,u.HTTP_FAILURE_TEXT).networkCheckText,client:O().clientMessage,validation:O().clientMessage,server:O().serverMessage,network:O().networkMessage}),k=`[data-wui-column]`,A=`[data-wui-body]`,j=`[data-wui-card]`,M=`[data-wui-count]`,N=`[data-wui-summary]`,re=`[data-wui-empty]`,P=`[data-wui-drop-note]`,ie=`[data-wui-live]`,ae=`[data-wui-help]`,F=`[data-wui-switch]`,oe=`[data-wui-scroller]`,I=`[data-wui-collapse]`,L=`[data-wui-more]`,R=`data-wui-visible-limit`,z=`data-wui-overflow`,se=`input, select, textarea, [contenteditable=""], [contenteditable="true"], [data-wui-no-drag]`,B=`[data-wui-load-more]`,V=`data-wui-more-url`,ce=`data-wui-total`,H=`data-wui-unloaded`,U=48,W=16,le=160,G=e=>e.getAttribute(`data-wui-column`),K=e=>e.getAttribute(`data-wui-card`),q=e=>e instanceof HTMLElement&&!!e.hidden||e.hasAttribute(`hidden`),ue=e=>q(e)||e.hasAttribute(z),J=e=>e instanceof Element?e:null,de=e=>typeof e==`object`&&e&&`name`in e?e.name:void 0,fe=e=>typeof e==`object`&&e&&`message`in e?e.message:void 0,Y=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},X=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),Z=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Q=()=>window.WUI??null,$=(e,t)=>{e&&Q()?.toast(e,{variant:t})},pe=class extends r.ElementBase{constructor(){super(),this._wired=!1,this._filter=null,this._expanded=new Set,this._revealed=new Set,this._press=null,this._drag=null,this._kbd=null,this._suppressClick=!1,this._observer=null,this._refreshQueued=!1,this._scrollTimer=0,this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onPointerCancel=()=>this._endPointer(!1),this._onDocKeyDown=e=>{e.key===`Escape`&&this._drag&&(e.preventDefault(),this._endPointer(!1))},this._onScroll=()=>{clearTimeout(this._scrollTimer),this._scrollTimer=setTimeout(()=>this._syncSwitcherFromScroll(),80)},this.addEventListener(`pointerdown`,e=>this._pointerDown(e)),this.addEventListener(`keydown`,e=>this._keyDown(e)),this.addEventListener(`click`,e=>this._click(e),!0),this.addEventListener(`scroll`,e=>{e.target instanceof Element&&this._loadOnScroll(e.target)},!0),this.addEventListener(`dragstart`,e=>{J(e.target)?.closest(j)&&e.preventDefault()}),this.addEventListener(`touchmove`,e=>{this._drag&&e.preventDefault()},{passive:!1})}_controlled(){return this.hasAttribute(`controlled`)}connectedCallback(){if(!this._wired){this._wired=!0,this._scroller()?.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._restoreCollapsed();for(let e of this._allCards())this._prepareCard(e);if(typeof MutationObserver==`function`){this._observer=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e instanceof HTMLElement&&e.matches(j)&&this._prepareCard(e);this._queueRefresh()});for(let e of this.querySelectorAll(A))this._observer.observe(e,{childList:!0})}this.refresh()}}disconnectedCallback(){this._endPointer(!1),this._observer?.disconnect(),this._observer=null,this._scroller()?.removeEventListener(`scroll`,this._onScroll),clearTimeout(this._scrollTimer),this._wired=!1}setFilter(e){if(e!=null&&typeof e!=`function`)throw TypeError(`wui-kanban setFilter: pass a function or null.`);if(this._filter=e,!e)for(let e of this._allCards())e.hidden=!1;this.refresh()}refresh(){if(this._controlled())return;this._refreshQueued=!1;let e=this._summaryFormat();for(let t of this._columns()){let n=G(t),r=x(t.getAttribute(R)),a=[],s=[];for(let e of this._cardsIn(t))this._filter&&(e.hidden=this._filter(e)===!1),q(e)?e.removeAttribute(z):(a.push(e),s.push(e.getAttribute(`data-wui-value`)));let c=this._expanded.has(n),l=S(a.map(K),r,c,this._revealed);for(let e of a)e.toggleAttribute(z,l.has(K(e)));let u=this._unloadedIn(t),d=String(a.length+u);for(let e of this._countsOf(t))e.textContent!==d&&(e.textContent=d);let f=Y(t,re,HTMLElement);if(f&&(f.hidden=a.length>0),e){let n=t.querySelector(N);n&&(n.textContent=(0,i.formatValue)(D(s),e))}let p=Y(t,L,HTMLElement);if(p){p.hidden=r==null||(c?a.length<=r:l.size===0),p.setAttribute(`aria-expanded`,c?`true`:`false`);let e=c?O().fewerLabel:(0,o.fillText)(O().moreText,{count:l.size});p.textContent!==e&&(p.textContent=e)}let m=Y(t,B,HTMLButtonElement);if(m&&(m.hidden=u<=0,!t.hasAttribute(`data-wui-loading`))){m.disabled=!1;let e=(0,o.fillText)(O().loadMoreText,{n:u});m.textContent!==e&&(m.textContent=e)}}}moveCard(e,t,n){let r=this._cardByKey(e);if(!r)throw Error(`wui-kanban moveCard: no card "${String(e)}" on this board.`);if(!this._columnByKey(t))throw Error(`wui-kanban moveCard: no column "${String(t)}" on this board.`);return this._commit(r,t,n)}_columns(){return X(this,k,HTMLElement)}_columnByKey(e){return this._columns().find(t=>G(t)===e)||null}_columnOf(e){return Z(e,k,HTMLElement)}_titleOf(e){return(e.querySelector(`.wui-kanban-title`)?.textContent||G(e)||``).replace(/\s+/g,` `).trim()}_bodyOf(e){return Y(e,A,HTMLElement)}_cardsIn(e){let t=this._bodyOf(e);return t?[...t.children].filter(e=>e instanceof HTMLElement&&e.matches(j)):[]}_visibleCardsIn(e){return this._cardsIn(e).filter(e=>!ue(e))}_allCards(){return X(this,`${A} > ${j}`,HTMLElement)}_cardByKey(e){return this._allCards().find(t=>K(t)===e)||null}_countsOf(e){let t=G(e),n=[...this.querySelectorAll(F)].filter(e=>e.getAttribute(`data-wui-switch`)===t);return[...e.querySelectorAll(M),...n.flatMap(e=>[...e.querySelectorAll(M)])]}_scroller(){return Y(this,oe,HTMLElement)}_summaryFormat(){let e=this.getAttribute(`summary-format`);return e?E(e,this.getAttribute(`summary-unit`)):null}_queueRefresh(){this._refreshQueued||(this._refreshQueued=!0,queueMicrotask(()=>{this._refreshQueued&&this.refresh()}))}_prepareCard(e){let t=this.querySelector(ae);t?.id&&!e.hasAttribute(`aria-describedby`)&&e.setAttribute(`aria-describedby`,t.id),e.hasAttribute(`tabindex`)||(e.tabIndex=0)}_announce(e){let t=Y(this,ie,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t,n=!1){return this.dispatchEvent(new CustomEvent(e,{bubbles:!0,cancelable:n,detail:t}))}_canLift(e){let t=C(e),n=this.hasAttribute(`readonly`);return n||e.hasAttribute(`data-wui-locked`)?(this._announce((0,o.fillText)(O().lockedText,{card:t})),this._fire(`wui:kanban:locked`,{key:K(e),card:e,reason:n?`readonly`:`locked`},!0),!1):e.getAttribute(`aria-busy`)!==`true`||(this._announce(O().busyMessage),$(O().busyMessage,`info`),!1)}_check(e,t,n){if(t===n)return{ok:!1,source:!0,reason:null};let r=this._columnByKey(t),i=this._columnByKey(n),a=(0,o.fillText)(O().refusedText,{from:r?this._titleOf(r):String(t),to:i?this._titleOf(i):String(n)}),s=i?.getAttribute(`data-accept-from`),c=s?.split(/\s+/).filter(Boolean)??[];if(s!=null&&!c.includes(t))return{ok:!1,reason:a};if(typeof this.accept==`function`){let r=this.accept(e,t,n);if(r===!1)return{ok:!1,reason:a};if(typeof r==`string`&&r)return{ok:!1,reason:r}}return{ok:!0,reason:null}}_markTargets(e,t){let n=C(e),r=new Map;for(let i of this._columns()){let a=G(i),s=this._check(e,t,a);r.set(a,s),i.setAttribute(`data-wui-drop`,s.source?`source`:s.ok?`ok`:`refused`);let c=Y(i,P,HTMLElement);c&&!s.source&&(c.textContent=s.ok?(0,o.fillText)(O().dropHereText,{card:n,column:this._titleOf(i)}):s.reason,c.hidden=!1)}return r}_clearTargets(){for(let e of this._columns()){e.removeAttribute(`data-wui-drop`),e.removeAttribute(`data-wui-over`),e.removeAttribute(`data-wui-target`);let t=Y(e,P,HTMLElement);t&&(t.hidden=!0,t.textContent=``)}}async _commit(e,t,n){let r=this._columnOf(e);if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let i=G(r),a=this._columnByKey(t),s=C(e);if(i===t||!this._canLift(e))return!1;let c=this._check(e,i,t);if(!c.ok)return this._announce(c.reason),$(c.reason,`info`),!1;if(!a)throw Error(`wui-kanban: no column "${String(t)}" on this board.`);let u=this._cardsIn(a),d=Number.isInteger(n)?Math.max(0,Math.min(n??0,u.length)):u.length,f={key:K(e),card:e,from:i,to:t,index:d},p=e.contains(document.activeElement);if(this._controlled())return this._fire(`wui:kanban:move`,f),this._announce((0,o.fillText)(O().movedText,{card:s,column:this._titleOf(a)})),p&&this._refocusSoon(f.key),!0;if(!this._fire(`wui:kanban:move`,f,!0))return!1;let m=a.hasAttribute(R)&&!this._revealed.has(f.key);m&&this._revealed.add(f.key);let h={parent:e.parentNode,next:e.nextSibling,column:r,revealed:m},g=this._bodyOf(a);if(!g)throw Error(`wui-kanban: the target column has no body.`);g.insertBefore(e,u[d]||null),p&&this._focusMoved(e),this.refresh();let _=a.getAttribute(`data-wui-step`);if(_)return this._runStep(e,f,h,_,a.getAttribute(`data-wui-step-size`));let v=this.getAttribute(`move-url`);if(!v)return this._announce((0,o.fillText)(O().movedText,{card:s,column:this._titleOf(a)})),this._fire(`wui:kanban:moved`,{...f,result:null}),!0;this._lock(e,!0),this._announce((0,o.fillText)(O().movingText,{card:s,column:this._titleOf(a)}));let y=new URLSearchParams({card:String(f.key),from:String(i),to:String(t),index:String(d)}),b=await(0,l.wuiFetch)(v,{method:`POST`,body:y});if(this._lock(e,!1),b.kind===`session`)return!1;if(b.ok){let t=this._applyFragment(b.html)||e;return $(b.message,`success`),this._announce((0,o.fillText)(O().movedText,{card:C(t),column:this._titleOf(a)})),this._fire(`wui:kanban:moved`,{...f,card:t,result:b}),!0}return this._rollback(e,h),b.kind!==`aborted`&&$(b.message||ne()[b.kind]||O().serverMessage,`danger`),this._fire(`wui:kanban:failed`,{...f,kind:b.kind,status:b.status,message:b.message}),!1}async _runStep(e,t,n,r,i){let a=C(e),s=this._columnByKey(t.to),c=new URLSearchParams({card:String(t.key),from:String(t.from),to:String(t.to)}).toString(),u=r+(r.includes(`?`)?`&`:`?`)+c;this._lock(e,!0);let d;try{let t=window.WUI?.modal?.load;if(typeof t!=`function`)throw Error(`<wui-kanban> data-wui-step needs the Razor script webority-ui.js (WUI.modal.load).`);d=await(await t(u,{trigger:e,size:i||void 0})).closed}catch(r){return this._lock(e,!1),this._rollback(e,n),de(r)!==`AbortError`&&$(O().serverMessage,`danger`),this._fire(`wui:kanban:failed`,{...t,kind:`step`,status:0,message:fe(r)??null}),!1}if(d?.status!==`success`)return this._lock(e,!1),this._rollback(e,n),this._announce((0,o.fillText)(O().cancelledText,{card:a})),this._fire(`wui:kanban:failed`,{...t,kind:`dismissed`,status:0,message:null}),!1;let f=e,p=this.getAttribute(`card-url`);if(p){let n=await(0,l.wuiFetch)(`${p}${p.includes(`?`)?`&`:`?`}${new URLSearchParams({card:String(t.key)})}`);n.ok&&(f=this._applyFragment(n.html)||e)}if(this._lock(f,!1),!s)throw Error(`wui-kanban: no column "${String(t.to)}" on this board.`);return this._announce((0,o.fillText)(O().movedText,{card:C(f),column:this._titleOf(s)})),this._fire(`wui:kanban:moved`,{...t,card:f,result:d}),!0}_lock(e,t){t?(e.setAttribute(`aria-busy`,`true`),e.setAttribute(`data-wui-saving`,``)):(e.removeAttribute(`aria-busy`),e.removeAttribute(`data-wui-saving`))}_rollback(e,t){let n=e.contains(document.activeElement),r=t.next&&t.next.parentNode===t.parent?t.next:null;if(t.revealed&&this._revealed.delete(K(e)),!t.parent)throw Error(`wui-kanban: the card had no parent to go back to.`);t.parent.insertBefore(e,r),n&&e.focus(),this.refresh(),this._announce((0,o.fillText)(O().rolledBackText,{card:C(e),column:this._titleOf(t.column)}))}_applyFragment(e){if(!e)return null;let t=(0,c.parseServerHtml)(e);for(let e of t.querySelectorAll(`script`))(0,n.devWarn)(`[@webority/ui-elements] A kanban fragment carried a script tag; it was removed, not run.`),e.remove();let r=null;for(let e of X(t,j,HTMLElement)){if(e.closest(`template`))continue;let t=this._cardByKey(K(e));if(!t)continue;let n=t.contains(document.activeElement);t.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),t.hidden&&(e.hidden=!0),t.replaceWith(e),this._prepareCard(e),n&&e.focus(),r??=e}for(let e of X(t,`template[data-wui-kanban-summary]`,HTMLTemplateElement))this._columnByKey(e.getAttribute(`data-wui-kanban-summary`))?.querySelector(N)?.replaceChildren(e.content.cloneNode(!0));return this.refresh(),Q()?.refresh(),r}_refocusSoon(e){let t=()=>{let t=this._cardByKey(e);t&&this._focusMoved(t)};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}_focusMoved(e){e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`nearest`})}_pointerDown(e){if(e.button!==0||e.isPrimary===!1||this._drag||this._kbd)return;let t=J(e.target),n=t?Z(t,j,HTMLElement):null;if(!n||!this.contains(n)||t?.closest(se))return;let r={card:n,id:e.pointerId,x:e.clientX,y:e.clientY,type:e.pointerType,timer:0};this._press=r,e.pointerType===`touch`&&(r.timer=setTimeout(()=>{this._press===r&&this._startDrag(r,r.x,r.y)},400)),window.addEventListener(`pointermove`,this._onPointerMove),window.addEventListener(`pointerup`,this._onPointerUp),window.addEventListener(`pointercancel`,this._onPointerCancel)}_pointerMove(e){let t=this._press;if(t&&e.pointerId===t.id){if(!this._drag){if(!(Math.hypot(e.clientX-t.x,e.clientY-t.y)>6))return;if(t.type===`touch`){this._endPointer(!1);return}if(this._startDrag(t,e.clientX,e.clientY),!this._drag)return}this._dragTo(e.clientX,e.clientY)}}_pointerUp(e){this._press&&e.pointerId===this._press.id&&this._endPointer(!!this._drag)}_startDrag(e,t,n){let r=e.card;if(!this._canLift(r)){this._endPointer(!1);return}let i=this._columnOf(r);if(!i)throw Error(`wui-kanban: the card is not inside a column.`);let a=G(i),s=r.getBoundingClientRect(),c=r.cloneNode(!0);if(!(c instanceof HTMLElement))return;let l=c;for(let e of[l,...l.querySelectorAll(`[id]`)])e.removeAttribute(`id`);l.removeAttribute(`data-wui-card`),l.removeAttribute(`tabindex`),l.setAttribute(`aria-hidden`,`true`),l.classList.add(`wui-kanban-ghost`),l.style.width=`${s.width}px`,this.appendChild(l),r.setAttribute(`data-wui-dragging`,``),this.setAttribute(`data-wui-dragging`,``),this._drag={card:r,from:a,ghost:l,dx:t-s.left,dy:n-s.top,x:t,y:n,over:null,verdicts:this._markTargets(r,a)},this._announce((0,o.fillText)(O().liftedText,{card:C(r),column:this._titleOf(i)})),document.addEventListener(`keydown`,this._onDocKeyDown),this._dragTo(t,n)}_dragTo(e,t){let n=this._drag;if(!n)throw Error(`wui-kanban: no drag in progress.`);n.x=e,n.y=t,n.ghost.style.transform=`translate(${e-n.dx}px, ${t-n.dy}px)`;let r=this._columnAt(e,t);r!==n.over&&(n.over?.removeAttribute(`data-wui-over`),r?.setAttribute(`data-wui-over`,``),n.over=r),this._autoScroll(e,t,r)}_columnAt(e,t){for(let n of this._columns()){let r=n.getBoundingClientRect();if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom)return n}return null}_indexAt(e,t){let n=this._visibleCardsIn(e).filter(e=>e!==this._drag?.card).find(e=>{let n=e.getBoundingClientRect();return t<n.top+n.height/2}),r=this._cardsIn(e).filter(e=>e!==this._drag?.card);return n?r.indexOf(n):r.length}_autoScroll(e,t,n){let r=this._scroller();if(r){let t=r.getBoundingClientRect();t.width>0&&(e<t.left+U?r.scrollBy?.({left:-16}):e>t.right-U&&r.scrollBy?.({left:W}))}if(n&&this._scrollColumn(n,t))return;let i=window.innerHeight||0;i>0&&(t<U?window.scrollBy?.({top:-16}):t>i-U&&window.scrollBy?.({top:W}))}_scrollColumn(e,t){let n=this._bodyOf(e);if(!n||e.hasAttribute(`data-collapsed`)||n.scrollHeight<=n.clientHeight)return!1;let r=n.getBoundingClientRect();return t<r.top+U&&n.scrollTop>0?(n.scrollBy?.({top:-16}),!0):t>r.bottom-U&&n.scrollTop+n.clientHeight<n.scrollHeight-1&&(n.scrollBy?.({top:W}),!0)}_endPointer(e){let t=this._press,n=this._drag;if(t&&clearTimeout(t.timer||void 0),this._press=null,this._drag=null,window.removeEventListener(`pointermove`,this._onPointerMove),window.removeEventListener(`pointerup`,this._onPointerUp),window.removeEventListener(`pointercancel`,this._onPointerCancel),document.removeEventListener(`keydown`,this._onDocKeyDown),!n)return;n.ghost.remove(),n.card.removeAttribute(`data-wui-dragging`),this.removeAttribute(`data-wui-dragging`),this._suppressClick=!0,setTimeout(()=>{this._suppressClick=!1},0);let r=n.over;if(this._clearTargets(),!e||!r){this._announce((0,o.fillText)(O().cancelledText,{card:C(n.card)}));return}let i=G(r),a=n.verdicts.get(i);a?.source?this._announce((0,o.fillText)(O().cancelledText,{card:C(n.card)})):a?.ok?this._commit(n.card,i,this._indexAt(r,n.y)):(this._announce(a?.reason),$(a?.reason,`info`))}_click(e){let t=J(e.target);if(this._suppressClick&&t?.closest(j)){e.preventDefault(),e.stopPropagation(),this._suppressClick=!1;return}let n=t?.closest(I);if(n&&this.contains(n)){let e=Z(n,k,HTMLElement);e&&this._setCollapsed(e,!e.hasAttribute(`data-collapsed`),!0);return}let r=t?.closest(B);if(r&&this.contains(r)){this._controlled()||this._loadMore(Z(r,k,HTMLElement));return}let i=t?.closest(L);if(i&&this.contains(i)){this._controlled()||this._toggleMore(Z(i,k,HTMLElement));return}let a=t?.closest(F);a&&this.contains(a)&&this._showColumn(a.getAttribute(`data-wui-switch`))}_keyDown(e){let t=this._kbd;if(t){this._liftedKey(e,t);return}let n=e.target instanceof HTMLElement?e.target:null;if(!n?.matches(j)||!this.contains(n))return;let r=this._columnOf(n),i=(0,s.mirrorKey)(e.key,(0,s.isRtl)(this));switch(i){case` `:case`Spacebar`:{if(e.preventDefault(),!this._canLift(n))return;if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let t=G(r),i=this._columns();this._kbd={card:n,from:t,target:i.indexOf(r),verdicts:this._markTargets(n,t)},n.setAttribute(`data-wui-lifted`,``),this.setAttribute(`data-wui-dragging`,``),r.setAttribute(`data-wui-target`,``),this._announce((0,o.fillText)(O().liftedText,{card:C(n),column:this._titleOf(r)}));return}case`ArrowDown`:case`ArrowUp`:{if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let t=this._visibleCardsIn(r),i=t[t.indexOf(n)+(e.key===`ArrowDown`?1:-1)];i&&(e.preventDefault(),i.focus());return}case`ArrowLeft`:case`ArrowRight`:{let t=this._columns(),n=i===`ArrowRight`?1:-1;for(let i=(r?t.indexOf(r):-1)+n;i>=0&&i<t.length;i+=n){let n=t[i],r=n?this._visibleCardsIn(n)[0]:void 0;if(r&&n&&!n.hasAttribute(`data-collapsed`)){e.preventDefault(),r.focus();return}}return}}}_liftedKey(e,t){let n=this._columns(),r=(0,s.mirrorKey)(e.key,(0,s.isRtl)(this));switch(r){case`ArrowLeft`:case`ArrowRight`:{e.preventDefault();let i=t.target+(r===`ArrowRight`?1:-1);if(i<0||i>=n.length)return;n[t.target]?.removeAttribute(`data-wui-target`),t.target=i;let a=n[i];if(!a)return;a.setAttribute(`data-wui-target`,``),this._showColumn(G(a),!1);let s=t.verdicts.get(G(a));if(!s)throw Error(`wui-kanban: no verdict for the column.`);let c=this._titleOf(a);this._announce(s.source?(0,o.fillText)(O().overSourceText,{column:c}):s.ok?(0,o.pluralText)(O(),`overText`,this._cardsIn(a).filter(e=>!q(e)).length,{column:c}):(0,o.fillText)(O().overRefusedText,{column:c,reason:s.reason??``}));return}case` `:case`Spacebar`:case`Enter`:{e.preventDefault();let r=n[t.target];if(!r)throw Error(`wui-kanban: the lifted card has no target column.`);let i=G(r),a=t.verdicts.get(i);if(!a)throw Error(`wui-kanban: no verdict for the column.`);if(!a.source&&!a.ok){this._announce(a.reason);return}this._endKeyboard(),a.source?this._announce((0,o.fillText)(O().cancelledText,{card:C(t.card)})):this._commit(t.card,i);return}case`Escape`:case`Tab`:e.key===`Escape`&&e.preventDefault(),this._endKeyboard(),this._showColumn(t.from,!1),this._announce((0,o.fillText)(O().cancelledText,{card:C(t.card)}));return}}_endKeyboard(){let e=this._kbd;this._kbd=null,e&&(e.card.removeAttribute(`data-wui-lifted`),this.removeAttribute(`data-wui-dragging`),this._clearTargets())}_restoreCollapsed(){let e=T(this.getAttribute(`board-id`));for(let t of this._columns()){let n=G(t);t.hasAttribute(`data-collapsible`)&&(0,a.hasOwn)(e,String(n))&&this._setCollapsed(t,e[String(n)],!1)}}_setCollapsed(e,t,n){let r=G(e);e.toggleAttribute(`data-collapsed`,t);let i=this._titleOf(e);for(let n of e.querySelectorAll(I))n.setAttribute(`aria-expanded`,t?`false`:`true`),n.setAttribute(`aria-label`,t?(0,o.fillText)(O().expandLabel,{title:i}):(0,o.fillText)(O().collapseLabel,{title:i}));n&&(te(this.getAttribute(`board-id`),r,t),this._fire(`wui:kanban:collapse`,{column:r,collapsed:t}))}_toggleMore(e){if(!e)return;let t=G(e);if(this._expanded.delete(t))for(let t of this._cardsIn(e))this._revealed.delete(K(t));else this._expanded.add(t);this.refresh()}_unloadedIn(e){return e.hasAttribute(V)?(e.hasAttribute(H)||e.setAttribute(H,String(Math.max(0,Number(e.getAttribute(ce))-this._cardsIn(e).length))),Number(e.getAttribute(H))):0}async _loadMore(e){if(!e)throw Error(`wui-kanban: the load-more button is outside a column.`);let t=Number(e.getAttribute(H));if(e.hasAttribute(`data-wui-loading`)||!(t>0))return;e.setAttribute(`data-wui-loading`,``);let r=Y(e,B,HTMLButtonElement);r&&(r.disabled=!0,r.textContent=O().loadingLabel);let i=new URL(String(e.getAttribute(V)),document.baseURI);i.searchParams.set(`skip`,String(this._cardsIn(e).length));let a=0,o=!1;try{let n=await(0,l.wuiFetch)(i.toString());if(n.ok){let r=(0,c.parseServerHtml)(n.html),i=this._bodyOf(e);for(let e of[...r.children])if(e.matches(j)&&!this._cardByKey(K(e))){if(!i)throw Error(`wui-kanban: the column has no body.`);i.append(e),a++}let s=n.response?.headers.get(`Wui-Kanban-Remaining`)??``;e.setAttribute(H,String(/^\d+$/.test(s)?Number(s):Math.max(0,t-a))),o=!0}}catch(e){(0,n.devError)(`[@webority/ui-elements] A kanban column could not load its next cards.`,e)}e.removeAttribute(`data-wui-loading`),this.refresh(),o?this._fire(`wui:kanban:loaded`,{key:G(e),added:a}):$(O().loadFailedMessage,`danger`)}_loadOnScroll(e){if(this._controlled()||!e.matches(A))return;let t=Z(e,k,HTMLElement);t?.hasAttribute(V)&&e.scrollTop+e.clientHeight>=e.scrollHeight-le&&this._loadMore(t)}_isPhone(){return typeof matchMedia==`function`&&matchMedia(`(max-width: 767.98px)`).matches}_showColumn(e,t=!0){for(let t of this.querySelectorAll(F))t.getAttribute(`data-wui-switch`)===e?t.setAttribute(`aria-current`,`true`):t.removeAttribute(`aria-current`);let n=this._columnByKey(e),r=this._scroller();if(!n||!r||!t&&!this._isPhone())return;let i=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollTo?.({left:n.offsetLeft-r.offsetLeft,behavior:i?`auto`:`smooth`})}_syncSwitcherFromScroll(){let e=this._scroller();if(!e||!this._isPhone())return;let t=e.clientWidth||1,n=this._columns()[Math.round(e.scrollLeft/t)];if(n)for(let e of this.querySelectorAll(F))e.getAttribute(`data-wui-switch`)===G(n)?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`)}};(0,t.defineElement)(`wui-kanban`,pe),e.KANBAN_DRAG_THRESHOLD_PX=v,e.KANBAN_LONG_PRESS_MS=_,e.KANBAN_PHONE_QUERY=g,e.KANBAN_STORAGE_PREFIX=h,e.KANBAN_SUMMARY_FORMATS=m,e.KANBAN_TONES=p,e.WuiKanban=pe,e.kanbanCardLabel=C,e.kanbanOverflow=S,e.kanbanStorageKey=w,e.kanbanSummaryFormat=E,e.kanbanVisibleLimit=x,e.readKanbanCollapsed=T,e.sumKanbanValues=D,e.writeKanbanCollapsed=te})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.httpFailureText);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.181.
|
|
1
|
+
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.181.1`)throw Error(`[webority-ui] lead-popup expects ui-elements 0.181.1 but the page loaded `+o+`.`);var s={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-soft":`#E0E7FF`,"--color-primary-text":`#4F46E5`,"--color-on-primary":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-border-strong":`#C4CADA`,"--color-surface":`#FFFFFF`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-modal":`0px 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-modal":`1505`},c=e=>`var(${e}, ${s[e]})`,l=`
|
|
2
2
|
:host {
|
|
3
3
|
all: initial;
|
|
4
4
|
display: contents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=globalThis.WeborityUiElementsInternal?.version;if(l!==`0.181.0`)throw Error(`[webority-ui] lightbox expects ui-elements 0.181.0 but the page loaded `+l+`.`);var u={closeLabel:`Close`,countText:`{position} of {total}`,downloadLabel:`Download`,imageFailedMessage:`This image can't be shown.`,label:`Image viewer`,nextImageLabel:`Next image`,previousImageLabel:`Previous image`,zoomInLabel:`Zoom in`,zoomOutLabel:`Zoom out`};function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=`a.wui-lightbox-item`,g=1,_=4,v=.5,y=2,b=50,x=6,S=300,C=300;function w(e){return Number.isFinite(e)?Math.min(_,Math.max(g,e)):g}function T(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 E(e,t){return Math.abs(e)<b||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function D(e){let t=(String(e??``).split(/[?#]/)[0]??``).split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var O=()=>(0,c.readText)(`lightbox`,u);function k(e,t,r){let i=(0,n.make)(`button`,{class:`u-action wui-lightbox-btn ${r}`,type:`button`,"aria-label":t,title:t});i.style.setProperty(`--wui-action-size`,`40px`);let o=(0,a.glyphNode)(e,{size:20});return i.replaceChildren(...o?[o]:[]),i}var A=class extends r.ElementBase{static get observedAttributes(){return[`open-index`]}constructor(){super(),m(this,`_ui`,void 0),m(this,`_index`,void 0),m(this,`_zoom`,void 0),m(this,`_pan`,void 0),m(this,`_pointers`,void 0),m(this,`_gesture`,void 0),m(this,`_lastTap`,void 0),m(this,`_returnTo`,void 0),m(this,`_release`,void 0),m(this,`_onClick`,void 0),this._ui=null,this._index=0,this._zoom=g,this._pan={x:0,y:0},this._pointers=new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._release=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target,n=t instanceof Element?t.closest(h):null;if(!(n instanceof HTMLAnchorElement)||!this.contains(n))return;let r=this._links().indexOf(n);r<0||(e.preventDefault(),this.open(r))}}get _view(){if(!this._ui)throw Error(`<wui-lightbox> viewer is not open.`);return this._ui}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||O().label}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(h)].filter(e=>e instanceof HTMLAnchorElement)}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||D(t)}})}open(e=0){let t=this._items();if(!t.length)return!1;if(!this._ui){let t=document.activeElement;this._returnTo=t instanceof HTMLElement||t instanceof SVGElement?t:null,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))}return this._show(e,t),!0}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._release?.(),this._release=null,this._ui.root.open&&this._ui.root.close(),this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null)}_build(){let e=(0,n.make)(`dialog`,{class:`wui-lightbox-overlay`,role:`dialog`,"aria-label":this.label,tabindex:`-1`}),t=(0,n.make)(`div`,{class:`wui-lightbox-bar`}),r=(0,n.make)(`span`,{class:`wui-lightbox-count`,"aria-live":`polite`}),i=(0,n.make)(`div`,{class:`wui-lightbox-tools`}),s=k(`zoom-out`,O().zoomOutLabel,`wui-lightbox-zoom-out`),c=k(`zoom-in`,O().zoomInLabel,`wui-lightbox-zoom-in`),l=(0,n.make)(`a`,{class:`u-action wui-lightbox-btn wui-lightbox-download`,"aria-label":O().downloadLabel,title:O().downloadLabel});l.style.setProperty(`--wui-action-size`,`40px`);let u=(0,a.glyphNode)(`download`,{size:20});l.replaceChildren(...u?[u]:[]),l.hidden=!this.download;let d=k(`x`,O().closeLabel,`wui-lightbox-close`);i.append(s,c,l,d),t.append(r,i);let f=(0,n.make)(`div`,{class:`wui-lightbox-stage`}),p=k(`chevron-left`,O().previousImageLabel,`wui-lightbox-nav wui-lightbox-prev`),m=k(`chevron-right`,O().nextImageLabel,`wui-lightbox-nav wui-lightbox-next`),h=(0,n.make)(`img`,{class:`wui-lightbox-image`,decoding:`async`,draggable:`false`,alt:``}),g=(0,n.make)(`p`,{class:`wui-lightbox-status`,role:`status`});f.append(h,g,p,m);let _=(0,n.make)(`p`,{class:`wui-lightbox-caption`});e.append(t,f,_);let y={root:e,count:r,zoomOut:s,zoomIn:c,download:l,close:d,stage:f,prev:p,next:m,image:h,status:g,caption:_};this._ui=y,d.addEventListener(`click`,()=>this.close()),p.addEventListener(`click`,()=>this.step(-1)),m.addEventListener(`click`,()=>this.step(1)),s.addEventListener(`click`,()=>this._setZoom(this._zoom-v)),c.addEventListener(`click`,()=>this._setZoom(this._zoom+v)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),f.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),f.addEventListener(`pointermove`,e=>this._onPointerMove(e)),f.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),f.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),f.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),h.addEventListener(`load`,()=>{this._ui===y&&(g.textContent=``,f.removeAttribute(`aria-busy`),h.hidden=!1,this._applyTransform())}),h.addEventListener(`error`,()=>{this._ui===y&&(f.removeAttribute(`aria-busy`),h.hidden=!0,g.textContent=O().imageFailedMessage)}),this.append(e),this._release=(0,o.openModalDialog)(e,{escape:!0,backdrop:!1,focus:`panel`,onRequestClose:()=>this.close()})}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,t){let n=this._view,r=Math.min(t.length-1,Math.max(0,Math.trunc(Number(e))||0)),a=t[r];if(!a)throw Error(`<wui-lightbox> image missing.`);let o=r!==this._index||!n.image.getAttribute(`src`);if(this._index=r,this._zoom=g,this._pan={x:0,y:0},n.count.textContent=(0,c.fillText)(O().countText,{position:(0,i.formatNumber)(r+1,{decimals:0}),total:(0,i.formatNumber)(t.length,{decimals:0})}),n.caption.textContent=a.caption,n.caption.hidden=!a.caption,n.download.href=a.src,n.download.setAttribute(`download`,a.name),n.prev.hidden=n.next.hidden=t.length<2,n.stage.setAttribute(`aria-busy`,`true`),n.status.textContent=``,n.image.hidden=!1,n.image.alt=a.alt||a.caption,n.image.src=a.src,this._applyTransform(),this._syncZoomButtons(),t.length>1){let e=t[(r+1)%t.length],n=t[(r-1+t.length)%t.length];if(!e||!n)throw Error(`<wui-lightbox> neighbour image missing.`);for(let t of[e,n])new Image().src=t.src}o&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:r}}))}_syncZoomButtons(){let e=this._view;e.zoomOut.disabled=this._zoom<=g,e.zoomIn.disabled=this._zoom>=_;let t=document.activeElement;(t===e.zoomOut||t===e.zoomIn)&&t instanceof HTMLButtonElement&&t.disabled&&e.close.focus()}_setZoom(e){this._ui&&(this._zoom=w(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._view;return T(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._view;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>g)}_onKeyDown(e){let t=(0,s.mirrorKey)(e.key,(0,s.isRtl)(this));if(t===`ArrowLeft`||t===`ArrowRight`)e.preventDefault(),this.step(t===`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+v)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-v)):e.key===`0`&&(e.preventDefault(),this._setZoom(g))}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){let t=e.target;if(t instanceof Element&&t.closest(`.wui-lightbox-nav`))return;let n=this._view;if(n.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let e=[...this._pointers.values()],t=e[0],n=e[1];if(!t||!n)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._gesture={kind:`pinch`,distance:Math.hypot(t.x-n.x,t.y-n.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===n.image,moved:!1})}_onPointerMove(e){let t=this._gesture;if(t&&this._pointers.has(e.pointerId)){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let e=[...this._pointers.values()],n=e[0],r=e[1];if(!n||!r)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._setZoom(t.zoom*Math.hypot(n.x-r.x,n.y-r.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>x&&(t.moved=!0),this._zoom>g&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._view.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,i=e.clientY-n.startY;n.moved?this._zoom===g&&this.step(E(r,i)):e.timeStamp-n.startTime>S||(n.onImage?e.timeStamp-this._lastTap<C?(this._lastTap=-1/0,this._setZoom(this._zoom>g?g:y)):this._lastTap=e.timeStamp:this.close())}};(0,t.defineElement)(`wui-lightbox`,A),e.WuiLightbox=A})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore);
|
|
1
|
+
(function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=globalThis.WeborityUiElementsInternal?.version;if(l!==`0.181.1`)throw Error(`[webority-ui] lightbox expects ui-elements 0.181.1 but the page loaded `+l+`.`);var u={closeLabel:`Close`,countText:`{position} of {total}`,downloadLabel:`Download`,imageFailedMessage:`This image can't be shown.`,label:`Image viewer`,nextImageLabel:`Next image`,previousImageLabel:`Previous image`,zoomInLabel:`Zoom in`,zoomOutLabel:`Zoom out`};function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=`a.wui-lightbox-item`,g=1,_=4,v=.5,y=2,b=50,x=6,S=300,C=300;function w(e){return Number.isFinite(e)?Math.min(_,Math.max(g,e)):g}function T(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 E(e,t){return Math.abs(e)<b||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function D(e){let t=(String(e??``).split(/[?#]/)[0]??``).split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var O=()=>(0,c.readText)(`lightbox`,u);function k(e,t,r){let i=(0,n.make)(`button`,{class:`u-action wui-lightbox-btn ${r}`,type:`button`,"aria-label":t,title:t});i.style.setProperty(`--wui-action-size`,`40px`);let o=(0,a.glyphNode)(e,{size:20});return i.replaceChildren(...o?[o]:[]),i}var A=class extends r.ElementBase{static get observedAttributes(){return[`open-index`]}constructor(){super(),m(this,`_ui`,void 0),m(this,`_index`,void 0),m(this,`_zoom`,void 0),m(this,`_pan`,void 0),m(this,`_pointers`,void 0),m(this,`_gesture`,void 0),m(this,`_lastTap`,void 0),m(this,`_returnTo`,void 0),m(this,`_release`,void 0),m(this,`_onClick`,void 0),this._ui=null,this._index=0,this._zoom=g,this._pan={x:0,y:0},this._pointers=new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._release=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target,n=t instanceof Element?t.closest(h):null;if(!(n instanceof HTMLAnchorElement)||!this.contains(n))return;let r=this._links().indexOf(n);r<0||(e.preventDefault(),this.open(r))}}get _view(){if(!this._ui)throw Error(`<wui-lightbox> viewer is not open.`);return this._ui}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||O().label}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(h)].filter(e=>e instanceof HTMLAnchorElement)}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||D(t)}})}open(e=0){let t=this._items();if(!t.length)return!1;if(!this._ui){let t=document.activeElement;this._returnTo=t instanceof HTMLElement||t instanceof SVGElement?t:null,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))}return this._show(e,t),!0}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._release?.(),this._release=null,this._ui.root.open&&this._ui.root.close(),this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null)}_build(){let e=(0,n.make)(`dialog`,{class:`wui-lightbox-overlay`,role:`dialog`,"aria-label":this.label,tabindex:`-1`}),t=(0,n.make)(`div`,{class:`wui-lightbox-bar`}),r=(0,n.make)(`span`,{class:`wui-lightbox-count`,"aria-live":`polite`}),i=(0,n.make)(`div`,{class:`wui-lightbox-tools`}),s=k(`zoom-out`,O().zoomOutLabel,`wui-lightbox-zoom-out`),c=k(`zoom-in`,O().zoomInLabel,`wui-lightbox-zoom-in`),l=(0,n.make)(`a`,{class:`u-action wui-lightbox-btn wui-lightbox-download`,"aria-label":O().downloadLabel,title:O().downloadLabel});l.style.setProperty(`--wui-action-size`,`40px`);let u=(0,a.glyphNode)(`download`,{size:20});l.replaceChildren(...u?[u]:[]),l.hidden=!this.download;let d=k(`x`,O().closeLabel,`wui-lightbox-close`);i.append(s,c,l,d),t.append(r,i);let f=(0,n.make)(`div`,{class:`wui-lightbox-stage`}),p=k(`chevron-left`,O().previousImageLabel,`wui-lightbox-nav wui-lightbox-prev`),m=k(`chevron-right`,O().nextImageLabel,`wui-lightbox-nav wui-lightbox-next`),h=(0,n.make)(`img`,{class:`wui-lightbox-image`,decoding:`async`,draggable:`false`,alt:``}),g=(0,n.make)(`p`,{class:`wui-lightbox-status`,role:`status`});f.append(h,g,p,m);let _=(0,n.make)(`p`,{class:`wui-lightbox-caption`});e.append(t,f,_);let y={root:e,count:r,zoomOut:s,zoomIn:c,download:l,close:d,stage:f,prev:p,next:m,image:h,status:g,caption:_};this._ui=y,d.addEventListener(`click`,()=>this.close()),p.addEventListener(`click`,()=>this.step(-1)),m.addEventListener(`click`,()=>this.step(1)),s.addEventListener(`click`,()=>this._setZoom(this._zoom-v)),c.addEventListener(`click`,()=>this._setZoom(this._zoom+v)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),f.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),f.addEventListener(`pointermove`,e=>this._onPointerMove(e)),f.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),f.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),f.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),h.addEventListener(`load`,()=>{this._ui===y&&(g.textContent=``,f.removeAttribute(`aria-busy`),h.hidden=!1,this._applyTransform())}),h.addEventListener(`error`,()=>{this._ui===y&&(f.removeAttribute(`aria-busy`),h.hidden=!0,g.textContent=O().imageFailedMessage)}),this.append(e),this._release=(0,o.openModalDialog)(e,{escape:!0,backdrop:!1,focus:`panel`,onRequestClose:()=>this.close()})}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,t){let n=this._view,r=Math.min(t.length-1,Math.max(0,Math.trunc(Number(e))||0)),a=t[r];if(!a)throw Error(`<wui-lightbox> image missing.`);let o=r!==this._index||!n.image.getAttribute(`src`);if(this._index=r,this._zoom=g,this._pan={x:0,y:0},n.count.textContent=(0,c.fillText)(O().countText,{position:(0,i.formatNumber)(r+1,{decimals:0}),total:(0,i.formatNumber)(t.length,{decimals:0})}),n.caption.textContent=a.caption,n.caption.hidden=!a.caption,n.download.href=a.src,n.download.setAttribute(`download`,a.name),n.prev.hidden=n.next.hidden=t.length<2,n.stage.setAttribute(`aria-busy`,`true`),n.status.textContent=``,n.image.hidden=!1,n.image.alt=a.alt||a.caption,n.image.src=a.src,this._applyTransform(),this._syncZoomButtons(),t.length>1){let e=t[(r+1)%t.length],n=t[(r-1+t.length)%t.length];if(!e||!n)throw Error(`<wui-lightbox> neighbour image missing.`);for(let t of[e,n])new Image().src=t.src}o&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:r}}))}_syncZoomButtons(){let e=this._view;e.zoomOut.disabled=this._zoom<=g,e.zoomIn.disabled=this._zoom>=_;let t=document.activeElement;(t===e.zoomOut||t===e.zoomIn)&&t instanceof HTMLButtonElement&&t.disabled&&e.close.focus()}_setZoom(e){this._ui&&(this._zoom=w(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._view;return T(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._view;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>g)}_onKeyDown(e){let t=(0,s.mirrorKey)(e.key,(0,s.isRtl)(this));if(t===`ArrowLeft`||t===`ArrowRight`)e.preventDefault(),this.step(t===`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+v)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-v)):e.key===`0`&&(e.preventDefault(),this._setZoom(g))}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){let t=e.target;if(t instanceof Element&&t.closest(`.wui-lightbox-nav`))return;let n=this._view;if(n.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let e=[...this._pointers.values()],t=e[0],n=e[1];if(!t||!n)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._gesture={kind:`pinch`,distance:Math.hypot(t.x-n.x,t.y-n.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===n.image,moved:!1})}_onPointerMove(e){let t=this._gesture;if(t&&this._pointers.has(e.pointerId)){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let e=[...this._pointers.values()],n=e[0],r=e[1];if(!n||!r)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._setZoom(t.zoom*Math.hypot(n.x-r.x,n.y-r.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>x&&(t.moved=!0),this._zoom>g&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._view.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,i=e.clientY-n.startY;n.moved?this._zoom===g&&this.step(E(r,i)):e.timeStamp-n.startTime>S||(n.onImage?e.timeStamp-this._lastTap<C?(this._lastTap=-1/0,this._setZoom(this._zoom>g?g:y)):this._lastTap=e.timeStamp:this.close())}};(0,t.defineElement)(`wui-lightbox`,A),e.WuiLightbox=A})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.181.
|
|
1
|
+
(function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.181.1`)throw Error(`[webority-ui] markdown expects ui-elements 0.181.1 but the page loaded `+i+`.`);var a=/\[([^[\]\n]+)\](?!\()/g,o=new Set(`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`),s=/\[([^\]\n]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,c=/!\[([^\]\n]*)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,l=new RegExp(a.source,`y`),u=e=>/[\p{L}\p{N}]/u.test(e);function d(e,t){let n=0;for(let r=t-1;r>=0&&e.charAt(r)===`\\`;--r)n+=1;return n%2==1}function f(e,t,n){let r=n.length===1;for(let i=e.indexOf(n,t);i!==-1;i=e.indexOf(n,i+1)){let a=i>t&&!/\s/.test(e.charAt(t))&&!/\s/.test(e.charAt(i-1)),o=r&&(e.charAt(i+1)===n||e.charAt(i-1)===n),s=n===`_`&&u(e.charAt(i+n.length));if(a&&!o&&!s&&!d(e,i))return i}return-1}function p(e,t){let n=t?.isCitation,r=[],i=``,a=()=>{i&&=(r.push({type:`text`,text:i}),``)},d=0;for(;d<e.length;){let m=e.charAt(d),h=e.charAt(d+1);if(m===`\\`&&o.has(h)){i+=h,d+=2;continue}if(m==="`"){let t=e.indexOf("`",d+1);if(t>d+1){a(),r.push({type:`code`,text:e.slice(d+1,t)}),d=t+1;continue}}let g=m+h;if(g===`**`||g===`__`||g===`~~`){let n=f(e,d+2,g);if(n!==-1&&!(g===`__`&&u(e.charAt(d-1)))){a();let i=p(e.slice(d+2,n),t);g===`~~`?r.push({type:`strike`,children:i}):r.push({type:`strong`,children:i}),d=n+2;continue}i+=g,d+=2}else{if(m===`*`||m===`_`){let n=f(e,d+1,m);if(n!==-1&&!(m===`_`&&u(e.charAt(d-1)))){a(),r.push({type:`em`,children:p(e.slice(d+1,n),t)}),d=n+1;continue}}if(m===`[`){s.lastIndex=d;let t=s.exec(e);if(t){let e=t[1],n=t[2];if(e===void 0||n===void 0)throw Error(`The link pattern always captures its label and href`);a(),r.push({type:`link`,href:n,children:p(e)}),d+=t[0].length;continue}if(n){l.lastIndex=d;let t=l.exec(e);if(t){let e=t[1];if(e===void 0)throw Error(`The citation pattern always captures its inner text`);if(n(e)){a(),r.push({type:`citation`,text:e}),d+=t[0].length;continue}}}}if(m===`!`){c.lastIndex=d;let t=c.exec(e);if(t){let e=t[1];if(e===void 0)throw Error(`The image pattern always captures its alt text`);a(),r.push({type:`image`,children:p(e)}),d+=t[0].length;continue}}i+=m,d+=1}}return a(),r.map((e,t)=>({...e,key:t}))}var m=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,h=/^https?:/i,g=/^(mailto|tel):/i,ee=/^(?:\/(?![/\\])|#|\?|\.{1,2}\/)/,_=/^https:\/\/[^/?#@\\\s]+$/i,v=/^[a-z][a-z0-9+.-]*:/i;function y(e){if(typeof e!=`string`)return null;let t=e.endsWith(`/`)?e.slice(0,-1):e;return _.test(t)?t:null}function te(e,t,n,r,i){if(n&&(t===`page`||m.test(e))){let t=n(e);if(t!=null)return{kind:`app`,target:t}}if(t===`app`)return null;let a=i==null?null:y(i),o=a===null?e:ne(e,a);return o===null?null:ee.test(o)?{kind:`page`,href:o}:t===`page`&&!(h.test(o)&&r&&x(o,r))?null:h.test(o)?{kind:r&&x(o,r)?`page`:`web`,href:o}:g.test(o)?{kind:`contact`,href:o}:null}function ne(e,t){if(v.test(e))return e;if(e.startsWith(`//`))return`https:${e}`;if(e===``)return null;let n=e.indexOf(`#`),r=n<0?``:e.slice(n),i=n<0?e:e.slice(0,n),a=i.indexOf(`?`),o=a<0?i:i.slice(0,a),s=a<0?``:i.slice(a);return o===``?`${t}${s}${r}`:`${t}${b(o.startsWith(`/`)?o:`/${o}`)}${s}${r}`}function b(e){let t=e.split(`/`),n=[];return t.forEach((e,r)=>{let i=r===t.length-1;e===`.`?i&&n.push(``):e===`..`?(n.length>1&&n.pop(),i&&n.push(``)):n.push(e)}),n.join(`/`)}function x(e,t){if(e.slice(0,t.length).toLowerCase()!==t.toLowerCase())return!1;let n=e[t.length];return n===void 0||n===`/`||n===`?`||n===`#`}function S(e){return typeof e!=`string`||!e.startsWith(`/`)||e[1]===`/`||e[1]===`\\`?null:e}var C=/^\s*```/,re=/^\s*```\s*(\S*)/,w=/^\s{0,3}(#{1,6})\s+(.*?)(?:\s+#+)?\s*$/,T=/^\s*([-*_])(\s*\1){2,}\s*$/,E=/^(\s*)[-*+]\s+(.*)$/,D=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,O=/^\s*>\s?(.*)$/,ie=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,k=[1,2,3,4,5,6],A=e=>e.includes(`|`);function j(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function M(e,t){let n=e[t];if(n===void 0)throw Error(`startsTable was called past the last source line`);let r=e[t+1];return r!==void 0&&A(n)&&r.includes(`|`)&&ie.test(r)}function N(e,t){let n=e[t];if(n===void 0)throw Error(`startsBlock was called past the last source line`);return C.test(n)||O.test(n)||E.test(n)||D.test(n)||w.test(n)||T.test(n)||M(e,t)}function P(e){let t=e.replace(/\t/g,` `).length;return Math.min(Math.floor(t/2),4)}function F(e){let t=D.exec(e);if(t){let e=t[1],n=t[2],r=t[3];if(e===void 0||n===void 0||r===void 0)throw Error(`The ordered list pattern always captures its indent, number and text`);return{text:r,depth:P(e),ordered:!0,number:Number(n)}}let n=E.exec(e);if(n){let e=n[1],t=n[2];if(e===void 0||t===void 0)throw Error(`The bullet list pattern always captures its indent and text`);return{text:t,depth:P(e),ordered:!1,number:0}}return null}function I(e){let t=(e??``).replace(/\r\n?/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()){r+=1;continue}if(C.test(e)){let i=re.exec(e)?.[1]||null,a=[];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(C.test(e))break;a.push(e),r+=1}r+=1,n.push({type:`code`,text:a.join(`
|
|
4
4
|
`),language:i});continue}if(M(t,r)){let i=j(e),a=[];for(r+=2;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||!A(e))break;a.push(j(e)),r+=1}n.push({type:`table`,header:i,rows:a});continue}if(T.test(e)){n.push({type:`rule`}),r+=1;continue}let i=w.exec(e);if(i){let e=i[1],t=i[2];if(e===void 0||t===void 0)throw Error(`The heading pattern always captures its hashes and text`);let a=k[e.length-1];if(a===void 0)throw Error(`The heading pattern always captures one to six hashes`);n.push({type:`heading`,level:a,text:t}),r+=1;continue}if(O.test(e)){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);let i=O.exec(n);if(!i)break;let a=i[1];if(a===void 0)throw Error(`The quote pattern always captures its text`);e.push(a),r+=1}n.push({type:`quote`,lines:e});continue}let a=F(e);if(a){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);if(!n.trim())break;let i=F(n);if(i){if(i.depth===0&&i.ordered!==a.ordered)break;e.push(i)}else if(N(t,r))break;else{let t=e[e.length-1];if(t===void 0)throw Error(`A list continuation line follows a list with no item`);t.text+=` ${n.trim()}`}r+=1}n.push({type:`list`,ordered:a.ordered,start:a.ordered?a.number:1,items:e});continue}let o=[e];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||N(t,r))break;o.push(e),r+=1}n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}function L(e){"@babel/helpers - typeof";return L=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},L(e)}function R(e,t){if(L(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(L(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function z(e){var t=R(e,`string`);return L(t)==`symbol`?t:t+``}function B(e,t,n){return(t=z(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var V=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`],H=[`razor`,`cshtml`],U=[`app`,`web`,`page`],W=e=>e!==void 0&&U.includes(e);function G(e,t,n,r,i=null){let a=K(n,r).map((e,n)=>{let r=t[n],i=r?.sig===e.sig?r.nodes:null;return{sig:e.sig,nodes:i??e.build()}}),o=new Set(a.flatMap(e=>e.nodes));for(let e of t)for(let t of e.nodes)o.has(t)||t.parentNode?.removeChild(t);let s=i;for(let t of a.flatMap(e=>e.nodes))(t.parentNode!==e||t.previousSibling!==s)&&e.insertBefore(t,s?s.nextSibling:e.firstChild),s=t;return a}function K(e,t){let n={links:W(t.links)?t.links:`web`,headings:t.headings===`text`?`text`:`outline`,resolveLink:t.resolveLink,isCitation:t.isCitation,figureText:typeof t.figureText==`function`?t.figureText:void 0,base:typeof t.base==`string`?t.base:void 0},r=t.resolverGeneration??0;return I(e).map(e=>({sig:`${JSON.stringify(e)}|${n.links}|${n.headings}|${n.base??``}|${r}`,build:()=>J(n,e)}))}var q=class extends r.ElementBase{static get observedAttributes(){return[`links`,`headings`,`base`]}constructor(){super(),B(this,`_drawn`,void 0),B(this,`_blocks`,void 0),B(this,`_observer`,void 0),B(this,`_connected`,void 0),B(this,`_resolveLink`,void 0),B(this,`_isCitation`,void 0),B(this,`_resolverGeneration`,void 0),B(this,`_figureText`,void 0),this._drawn=[],this._blocks=[],this._observer=null,this._connected=!1,this._resolveLink=void 0,this._isCitation=void 0,this._resolverGeneration=0,this._figureText=void 0}connectedCallback(){this._connected=!0,this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._drawn.some(t=>t.contains(e.target)))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._connected=!1,this._observer?.disconnect(),this._observer=null}get resolveLink(){return this._resolveLink}set resolveLink(e){this._resolveLink=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get base(){return this.getAttribute(`base`)??void 0}set base(e){e==null?this.removeAttribute(`base`):this.setAttribute(`base`,String(e))}get isCitation(){return this._isCitation}set isCitation(e){this._isCitation=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get figureText(){return this._figureText}set figureText(e){this._figureText=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}attributeChangedCallback(e,t,n){t!==n&&this._connected&&this._render()}_source(){return Array.from(this.children).find(e=>e.tagName===`PRE`&&e.classList.contains(`wui-markdown-source`))}_render(){let e=this._source();e&&(this._blocks=G(this,this._blocks,e.textContent??``,{links:this.getAttribute(`links`)??void 0,headings:this.getAttribute(`headings`)??void 0,base:this.getAttribute(`base`)??void 0,resolveLink:this._resolveLink,isCitation:this._isCitation,figureText:this._figureText,resolverGeneration:this._resolverGeneration},e),this._drawn=this._blocks.flatMap(e=>e.nodes),e.hidden=!0,this._observer?.takeRecords())}};function J(e,t){switch(t.type){case`paragraph`:return[(0,n.make)(`p`,null,...Y(e,t.lines))];case`heading`:return[ae(e,t)];case`list`:return oe(e,t.items);case`table`:return[se(e,t)];case`code`:return[le(t)];case`quote`:return[(0,n.make)(`blockquote`,null,...Y(e,t.lines))];case`rule`:return[(0,n.make)(`hr`)];default:return[]}}function Y(e,t){let r=[];return t.forEach((t,i)=>{i>0&&r.push((0,n.make)(`br`)),r.push(...Z(e,t))}),r}function ae(e,t){let r=Z(e,t.text);return e.headings===`text`?(0,n.make)(`p`,{class:`fw-semibold`},...r):(0,n.make)(`h2`,null,...r)}function oe(e,t){let n=[];for(let r=0;r<t.length;){let i=X(e,t,r);n.push(i.list),r=i.next}return n}function X(e,t,r){let i=t[r];if(!i)throw Error(`List run starts past its items.`);let{depth:a,ordered:o,number:s}=i,c=(0,n.make)(o?`ol`:`ul`,o&&s!==1?{start:s}:null),l=null,u=r,d=t[u];for(;d&&d.depth>=a;){if(d.depth===a)l=(0,n.make)(`li`,null,...Z(e,d.text)),c.append(l),u+=1;else{let n=X(e,t,u);if(!l)throw Error(`Nested list has no item before it.`);l.append(n.list),u=n.next}d=t[u]}return{list:c,next:u}}function se(e,t){let r=t.header.map(t=>(0,n.make)(`th`,{scope:`col`},...Z(e,t))),i=t.rows.map(r=>(0,n.make)(`tr`,null,...t.header.map((t,i)=>(0,n.make)(`td`,null,...Z(e,r[i]??``))))),a=(0,n.make)(`table`,{class:`table`},(0,n.make)(`thead`,null,(0,n.make)(`tr`,null,...r)),(0,n.make)(`tbody`,null,...i));return(0,n.make)(`div`,{class:`table-responsive`},a)}function ce(e){return e===null?`text`:H.includes(e.toLowerCase())?`razor`:V.includes(e)?e:`text`}function le(e){let t=(0,n.make)(`code`,null,e.text),r=(0,n.make)(`pre`,{class:`wui-code-source`},t);return(0,n.make)(`wui-code-block`,{class:`wui-code-block`,language:ce(e.language)},r)}function Z(e,t){return Q(e,p(t,{isCitation:e.isCitation}))}function Q(e,t){return t.flatMap(t=>ue(e,t))}function ue(e,t){switch(t.type){case`code`:return[(0,n.make)(`code`,null,t.text)];case`strong`:return[(0,n.make)(`strong`,null,...Q(e,t.children))];case`em`:return[(0,n.make)(`em`,null,...Q(e,t.children))];case`strike`:return[(0,n.make)(`del`,null,...Q(e,t.children))];case`image`:return[document.createTextNode(`[`),...Q(e,t.children),document.createTextNode(`]`)];case`link`:return fe(e,t);case`citation`:return[me(t.text)];case`text`:return e.figureText?pe(e.figureText,t.text):[document.createTextNode(t.text)];default:return[document.createTextNode(de(t))]}}function de(e){let t=e;return typeof t==`object`&&t&&`text`in t?String(t.text):`undefined`}function fe(e,t){let n=Q(e,t.children),r=te(t.href,e.links,e.resolveLink,globalThis.location?.origin,e.base);if(!r)return n;if(r.kind===`app`){let e=S(r.target);return e?[$(e,n,!1)]:n}return[$(r.href,n,r.kind===`web`)]}function pe(e,t){return e(t).map(e=>e.kind===`sub`||e.kind===`sup`?(0,n.make)(e.kind,null,e.text):document.createTextNode(e.text))}function me(e){let t=(0,n.make)(`span`,{class:`chip-label`},e),r=(0,n.make)(`button`,{type:`button`,class:`chip-body`,"aria-label":e},t);return r.addEventListener(`click`,()=>{r.dispatchEvent(new CustomEvent(`wui-markdown-citation`,{bubbles:!0,detail:{citation:e}}))}),(0,n.make)(`span`,{class:`chip primary chip-outline chip-sm chip-clickable wui-markdown-citation`,"data-wui":`AppChip`},r)}function $(e,t,r){let i=(0,n.make)(`span`,{class:`wui-link__label`},...t);return(0,n.make)(`a`,{class:`wui-link wui-link--static`,"data-wui":`AppLink`,href:e,target:r?`_blank`:void 0,rel:r?`noopener noreferrer`:void 0},i)}(0,t.defineElement)(`wui-markdown`,q),e.WuiMarkdown=q})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.181.
|
|
1
|
+
(function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.181.1`)throw Error(`[webority-ui] mini-calendar expects ui-elements 0.181.1 but the page loaded `+i+`.`);function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=`.wui-mini-calendar-day`,u=`.wui-mini-calendar-nav`,d=864e5,f=/^\d{4}-\d{2}$/,p=new Map([[`ArrowLeft`,-1],[`ArrowRight`,1],[`ArrowUp`,-7],[`ArrowDown`,7]]),m=e=>Date.UTC(Number(e.slice(0,4)),Number(e.slice(5,7))-1,Number(e.slice(8,10)))/d,h=e=>new Date(e*d).toISOString().slice(0,10),g=(e,t)=>{let n=new Date(Date.UTC(Number(e.slice(0,4)),Number(e.slice(5,7))-1+t,1));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,`0`)}`},_=(e,t)=>{let n=new Date(Date.UTC(Number(t.slice(0,4)),Number(t.slice(5,7)),0)).getUTCDate();return`${t}-${String(Math.min(Number(e.slice(8,10)),n)).padStart(2,`0`)}`},v=class extends r.ElementBase{constructor(){super(),c(this,`_pending`,null),c(this,`_onClick`,void 0),c(this,`_onKeyDown`,void 0),c(this,`_onFocusIn`,()=>this._sync()),c(this,`_observer`,void 0),this._onClick=e=>{let t=(0,n.closestOf)(e.target,l);if(t instanceof HTMLButtonElement){this._pick(t.dataset.date??``);return}let r=(0,n.closestOf)(e.target,u);if(!(r instanceof HTMLButtonElement))return;let i=Number(r.dataset.nav);if(i!==-1&&i!==1)throw Error(`wui-mini-calendar: data-nav must be -1 or 1.`);this._pending=null,this._changeMonth(g(this._month(),i))},this._onKeyDown=e=>this._key(e),this._observer=new MutationObserver(()=>this._sync())}connectedCallback(){this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusin`,this._onFocusIn),this._observer.observe(this,{childList:!0,subtree:!0}),this._sync()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusin`,this._onFocusIn),this._observer.disconnect()}_key(e){let t=(0,n.closestOf)(e.target,l);if(!(t instanceof HTMLButtonElement))return;let r=t.dataset.date??``,i=this._days(),a=Math.floor(i.indexOf(t)/7)*7,o=e.key;if(o===`PageUp`||o===`PageDown`){e.preventDefault(),this._page(r,o===`PageUp`?-1:1);return}if(o===`Home`||o===`End`){e.preventDefault(),(o===`Home`?i[a]:i[Math.min(a+6,i.length-1)])?.focus();return}let s=p.get(o);s!==void 0&&(e.preventDefault(),this._goTo(h(m(r)+s)))}_pick(e){if(!e)throw Error(`wui-mini-calendar: a day button has no data-date.`);this._pending=null;for(let t of this._days()){let n=t.dataset.date===e;t.classList.toggle(`is-selected`,n),n?t.setAttribute(`aria-pressed`,`true`):t.removeAttribute(`aria-pressed`)}this._sync(),this.dispatchEvent(new CustomEvent(`wui-mini-calendar:select`,{bubbles:!0,detail:{value:e}}))}_goTo(e){let t=this._dayAt(e);t?t.focus():(this._pending=e,this._changeMonth(e.slice(0,7)))}_page(e,t){let n=g(e.slice(0,7),t);this._pending=_(e,n),this._changeMonth(n)}_changeMonth(e){this.dispatchEvent(new CustomEvent(`wui-mini-calendar:navigate`,{bubbles:!0,detail:{month:e}}))}_month(){let e=this.dataset.month??``;if(!f.test(e))throw Error(`wui-mini-calendar: data-month must be YYYY-MM.`);return e}_dayAt(e){return this.querySelector(`${l}[data-date="${e}"]`)}_days(){return[...this.querySelectorAll(l)]}_sync(){let e=this._days();if(this._pending!==null){let e=this._dayAt(this._pending);e&&(this._pending=null,e.focus())}let t=e.find(e=>e===document.activeElement)??e.find(e=>e.getAttribute(`aria-pressed`)===`true`)??e.find(e=>e.getAttribute(`aria-current`)===`date`)??e.find(e=>!e.classList.contains(`is-outside`))??e[0];for(let n of e)n.tabIndex=n===t?0:-1}};(0,t.defineElement)(`wui-mini-calendar`,v),e.WuiMiniCalendar=v})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.181.
|
|
1
|
+
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.181.1`)throw Error(`[webority-ui] navigation-menu expects ui-elements 0.181.1 but the page loaded `+o+`.`);var s=`.wui-nav-menu-link`,c=`(max-width: 767.98px)`,l=`data-open`,u=e=>e instanceof Element?e:e instanceof Node?e.parentElement:null,d=e=>[...e].filter(e=>e instanceof HTMLElement),f=e=>{let t=e.children[0];if(!(t instanceof HTMLElement))throw Error(`Navigation entry has no control.`);return t},p=e=>{let t=e.children[1];return t instanceof HTMLElement?t:null},m=(e,t,n)=>{let r=e[t];if(r===void 0)throw Error(n);return r},h=class extends r.ElementBase{constructor(){super(),this._onClick=e=>this._handleClick(e),this._onKeyDown=e=>this._handleKeyDown(e),this._onFocusOut=e=>{let t=this._openItem(),n=e.relatedTarget;t&&n instanceof Node&&!t.contains(n)&&this._set(t,!1)},this._onPointerDown=()=>{this._pressedOpen=this._openItem()},this._onModeChange=()=>{let e=this._openItem();e&&this._set(e,!1)},this._onOutsidePress=e=>{let t=this._openItem();t&&!e.composedPath().includes(t)&&this._set(t,!1)},this._pressedOpen=null,this._media=null}connectedCallback(){this._teardown(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this._media=window.matchMedia(c),this._media.addEventListener(`change`,this._onModeChange)}disconnectedCallback(){this._teardown()}open(e){let t=this._items().find(t=>{let n=t.children[0];return n instanceof HTMLElement&&this._isTrigger(n)&&n.dataset.key===e});t&&this._set(t,!0)}close(e=!1){let t=this._openItem();t&&(this._set(t,!1),e&&f(t).focus({preventScroll:!0}))}_items(){return d(this.querySelectorAll(`.wui-nav-menu-item`))}_openItem(){return this._items().find(e=>{let t=p(e);return t!==null&&this._isOpen(t)})??null}_isOpen(e){return e.hasAttribute(l)||(0,i.isPopoverOpen)(e)}_isTrigger(e){return!!e?.classList.contains(`wui-nav-menu-trigger`)}_entries(){return this._items().map(f)}_links(e){let t=p(e);return t?d(t.querySelectorAll(s)):[]}_set(e,t){let n=p(e);if(!n)return;let r=f(e);if(t){let t=this._openItem();if(t&&t!==e&&this._set(t,!1),this._isOpen(n))return;r.setAttribute(`aria-expanded`,`true`),window.matchMedia(c).matches?(n.setAttribute(l,``),document.addEventListener(`pointerdown`,this._onOutsidePress,!0)):(0,i.openAnchoredPopover)(r,n,{mode:`auto`,below:!0,flipAlign:!0,onClosed:()=>this._settle(e)}),this._emit(r,!0)}else n.removeAttribute(l),document.removeEventListener(`pointerdown`,this._onOutsidePress,!0),(0,i.isPopoverOpen)(n)&&(0,i.closeAnchoredPopover)(n),this._settle(e)}_settle(e){let t=f(e);t.getAttribute(`aria-expanded`)!==`false`&&(t.setAttribute(`aria-expanded`,`false`),this._emit(t,!1))}_emit(e,t){this.dispatchEvent(new CustomEvent(`wui-navigation-menu:toggle`,{bubbles:!0,detail:{key:e.dataset.key??null,open:t}}))}_handleClick(e){let t=this._pressedOpen;this._pressedOpen=null;let r=u(e.target),i=r?.closest(`.wui-nav-menu-trigger`);if(i&&this.contains(i)){let e=(0,n.must)(i.parentElement,`Navigation trigger has no entry.`),r=(0,n.must)(p(e),`Navigation entry has no panel.`),a=t===e||this._isOpen(r);this._set(e,!a);return}let a=r?.closest(s);a&&this.contains(a)&&this.close()}_handleKeyDown(e){if(this._pressedOpen=null,e.altKey||e.ctrlKey||e.metaKey)return;let t=u(e.target)?.closest(`.wui-nav-menu-trigger, .wui-nav-menu-toplink, .wui-nav-menu-link`);if(!(t instanceof HTMLElement)||!this.contains(t))return;let r=this._openItem();if(e.key===`Escape`){if(!r||!p(r)?.hasAttribute(l))return;e.preventDefault(),e.stopPropagation();let n=r.contains(t);this._set(r,!1),n&&f(r).focus({preventScroll:!0});return}if(t.matches(s)){this._linkKey(e,t);return}let i=this._entries(),o=i.indexOf(t),c=(0,a.mirrorKey)(e.key,(0,a.isRtl)(this));if(c===`ArrowRight`||c===`ArrowLeft`||c===`Home`||c===`End`){e.preventDefault();let t=c===`Home`?0:c===`End`?i.length-1:(o+(c===`ArrowRight`?1:-1)+i.length)%i.length;r&&this._set(r,!1),m(i,t,`Navigation has no entry to focus.`).focus({preventScroll:!0})}else if(e.key===`ArrowDown`&&this._isTrigger(t)){e.preventDefault();let r=(0,n.must)(t.parentElement,`Navigation trigger has no entry.`);this._set(r,!0),m(this._links(r),0,`Navigation panel has no link to focus.`).focus({preventScroll:!0})}}_linkKey(e,t){let r=(0,n.must)(t.closest(`.wui-nav-menu-item`),`Navigation link has no entry.`),i=this._links(r),a=i.indexOf(t);e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),m(i,(a+(e.key===`ArrowDown`?1:-1)+i.length)%i.length,`Navigation panel has no link to focus.`).focus({preventScroll:!0})):e.key===`Home`?(e.preventDefault(),m(i,0,`Navigation panel has no link to focus.`).focus({preventScroll:!0})):e.key===`End`&&(e.preventDefault(),m(i,i.length-1,`Navigation panel has no link to focus.`).focus({preventScroll:!0}))}_teardown(){for(let e of this._items()){let t=p(e);if(!t)continue;let n=t.hasAttribute(l);t.removeAttribute(l),(0,i.closeAnchoredPopover)(t),n&&this._settle(e)}this._media?.removeEventListener(`change`,this._onModeChange),this._media=null,document.removeEventListener(`pointerdown`,this._onOutsidePress,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`pointerdown`,this._onPointerDown,!0)}};(0,t.defineElement)(`wui-navigation-menu`,h),e.WuiNavigationMenu=h})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o,s,c,l,u){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var d=globalThis.WeborityUiElementsInternal?.version;if(d!==`0.181.
|
|
1
|
+
(function(e,t,n,r,i,a,o,s,c,l,u){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var d=globalThis.WeborityUiElementsInternal?.version;if(d!==`0.181.1`)throw Error(`[webority-ui] notification-center expects ui-elements 0.181.1 but the page loaded `+d+`.`);var f=()=>(0,c.readText)(`notificationCentre`,u.NOTIFICATION_CENTRE_TEXT),p=`.wui-notification-center-trigger`,m=`.wui-notification-center-panel`,h=`.wui-notification-center-count`,g=`.wui-notification-center-live`,_=`.wui-notification-center-markall`,v=`.wui-notification-center-item`,y=`wui-notification-center-item-read`,b=`.wui-notification-center-unread-label`,x=`.app-tabs`,S=`.wui-notification-center-tabs [role='tablist']`,C=`.wui-notification-center-tabs [role='tab']`,w=`.wui-notification-center-empty`,T=`.wui-notification-center-retry`,E=`.wui-notification-center-earlier`,D=`(max-width: 767.98px)`,O={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`},k=e=>!!e,A=()=>({forbidden:f().forbiddenMessage,networkCheck:(0,c.readText)(`httpFailure`,l.HTTP_FAILURE_TEXT).networkCheckText,client:f().clientMessage,validation:f().clientMessage,server:f().serverMessage,network:f().networkMessage}),j=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},M=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),N=class extends r.ElementBase{constructor(){super(),this._unread=0,this._busy=!1,this._sheet=!1,this._awaitChildren=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onToggle=e=>{e.type===`toggle`&&`newState`in e&&e.newState===`closed`&&this._closedByBrowser()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}static get observedAttributes(){return[`open`]}connectedCallback(){this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`toggle`,this._onToggle,!0),this.isOpen&&(j(this,m)===null||j(this,p)===null)?(this._awaitChildren=new MutationObserver(()=>this._finishAwaitedOpen()),this._awaitChildren.observe(this,{childList:!0})):(this._syncOpen(),this.isOpen&&this._showPanel())}disconnectedCallback(){this._disarmAwait(),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`toggle`,this._onToggle,!0);let e=j(this,m);e&&(0,a.closeAnchoredPopover)(e)}attributeChangedCallback(e,t,n){e===`open`&&t!==n&&(this._awaitChildren?n===null&&this._disarmAwait():this.isConnected&&(n===null?this._hidePanel():this._showPanel()))}_finishAwaitedOpen(){j(this,m)!==null&&j(this,p)!==null&&(this._disarmAwait(),this._syncOpen(),this._showPanel())}_disarmAwait(){this._awaitChildren?.disconnect(),this._awaitChildren=null}_showPanel(){let e=(0,n.must)(j(this,m),`<wui-notification-center> needs its panel to open.`),t=(0,n.must)(j(this,p),`<wui-notification-center> needs its trigger to open.`);(0,a.isPopoverOpen)(e)||(this._sheet=window.matchMedia(D).matches,this._sheet?(0,a.setPopoverOpen)(e,!0):(0,a.openAnchoredPopover)(t,e,{mode:`auto`,onClosed:()=>this._closedByBrowser()}),(0,a.isPopoverOpen)(e)&&this._layoutTabs())}_hidePanel(){let e=j(this,m);e&&(0,a.isPopoverOpen)(e)&&(this._sheet?(0,a.setPopoverOpen)(e,!1):(0,a.closeAnchoredPopover)(e))}_closedByBrowser(){if(!this.isConnected||!this.hasAttribute(`open`))return;let e=j(this,m);this.close({restoreFocus:e?.contains(this.ownerDocument.activeElement)??!1})}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||((0,n.must)(j(this,m),`<wui-notification-center> needs its panel to open.`),(0,n.must)(j(this,p),`<wui-notification-center> needs its trigger to open.`),this.setAttribute(`open`,``),this._syncOpen(),j(this,m)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&j(this,p)?.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(p)?.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(`${v}:not(.${y}):not([data-archived="true"])`).length}_click(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(C);if(n instanceof HTMLElement&&this.contains(n)){if(this.hasAttribute(`controlled`))return;this._pickTab(n);return}let r=t.closest(T);if(r instanceof HTMLElement&&this.contains(r)){if(this.hasAttribute(`controlled`))return;this._emitRetry();return}let i=t.closest(`${p}, ${_}, ${v}`);i instanceof HTMLElement&&this.contains(i)&&(i.matches(p)?this.toggle():this.hasAttribute(`controlled`)||(i.matches(_)?this._markAll():this._markItem(i)))}_key(e){if(!this.isOpen)return;let t=e.target;if(!(t instanceof Element))throw Error(`Keyboard event target is not an element.`);if(!this.querySelector(m)?.contains(t)||t.closest(x))return;let n=O[e.key];if(n===void 0)return;let r=M(this,v).filter(i.isDrawn);if(r.length===0)return;let a=t.closest(v),o=a instanceof HTMLElement?r.indexOf(a):-1,s;s=n===`first`?0:n===`last`?r.length-1:o===-1?n===1?0:r.length-1:Math.min(r.length-1,Math.max(0,o+n)),e.preventDefault(),r[s]?.focus()}_markItem(e){e.classList.contains(y)||(this._applyRead(e),e.dataset.archived!==`true`&&(this._unread=Math.max(0,this._unread-1)),this._render(),this._say((0,o.notificationUnreadAnnouncement)(this._unread)),this._emitRead([e.dataset.id].filter(k),!1))}async _markAll(){if(this._busy)return;let e=M(this,`${v}:not(.${y})`);if(e.length===0&&this._unread===0)return;let t=e.map(e=>e.dataset.id).filter(k),n=this.getAttribute(`read-action`);if(n){this._setBusy(!0);let e=new URLSearchParams;for(let n of t)e.append(`ids`,n);let r=await(0,s.wuiFetch)(n,{method:`POST`,body:e});if(this._setBusy(!1),!r.ok){if(r.kind===`session`||r.kind===`aborted`)return;let e=r.kind,t=r.message||A()[e]||f().serverMessage;this._say(t),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:e,message:t}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(f().allReadText),this._emitRead(t,!0)}_pickTab(e){let t=e.closest(S);if(t instanceof HTMLElement){for(let n of M(t,C)){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 M(this,S)){let t=j(e,`.app-tab.active`);t&&(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.setAttribute(`data-wui-tabs`,``)}}_filterItems(e){let t=!1;for(let n of M(this,v)){let r=n.dataset.archived===`true`,i=n.classList.contains(y),a=e===`archived`?r:!r&&(e!==`unread`||!i);a&&(t=!0);let o=n.closest(`li`);o&&(o.hidden=!a)}for(let e of M(this,`.wui-notification-center-list section`))e.hidden=[...e.querySelectorAll(`li`)].every(e=>e.hidden);let n=j(this,w);n&&(n.hidden=t);for(let t of M(this,E))t.hidden=e!==`unread`}_applyRead(e){e.classList.add(y),e.querySelector(b)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(_);t instanceof HTMLButtonElement&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=j(this,h);e&&(e.textContent=(0,o.notificationCountText)(this._unread),e.hidden=this._unread===0),this.querySelector(p)?.setAttribute(`aria-label`,(0,o.notificationTriggerLabel)(this.getAttribute(`label`)||f().label,this._unread));let t=this.querySelector(_);t instanceof HTMLButtonElement&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(g);t&&(t.textContent=e)}_emitRetry(){this.dispatchEvent(new CustomEvent(`wui:notification-center:retry`,{bubbles:!0}))}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};(0,t.defineElement)(`wui-notification-center`,N),e.WuiNotificationCenter=N})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.isDrawn,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.notificationDays,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.httpFailureText,WeborityUiElementsInternal.modules.notificationCentreText);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.181.
|
|
1
|
+
(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.181.1`)throw Error(`[webority-ui] offline-banner expects ui-elements 0.181.1 but the page loaded `+r+`.`);function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=4e3,l=`wui:offline-banner:check-again`,u=class extends n.ElementBase{static get observedAttributes(){return[`offline`]}constructor(){super(),s(this,`_offline`,void 0),s(this,`_timer`,void 0),s(this,`_onBrowser`,void 0),s(this,`_onClick`,void 0),this._offline=!1,this._timer=null,this._onBrowser=()=>this._sync(),this._onClick=e=>{e.target instanceof Element&&e.target.closest(`.wui-offline-banner-check`)&&this.dispatchEvent(new CustomEvent(l,{bubbles:!0}))}}connectedCallback(){window.addEventListener(`online`,this._onBrowser),window.addEventListener(`offline`,this._onBrowser),this.addEventListener(`click`,this._onClick),this._sync()}disconnectedCallback(){window.removeEventListener(`online`,this._onBrowser),window.removeEventListener(`offline`,this._onBrowser),this.removeEventListener(`click`,this._onClick),this._clearTimer()}attributeChangedCallback(e,t,n){this.isConnected&&this._sync()}_sync(){let e=this.getAttribute(`offline`),t=e===null?!navigator.onLine:e===`true`,n=this._offline;this._offline=t,t?(this._clearTimer(),this._show(`offline`)):n?(this._show(`back`),this._timer=setTimeout(()=>this._hide(),c)):this._timer===null&&this._hide()}_show(e){this.setAttribute(`data-state`,e),this.hidden=!1}_hide(){this.removeAttribute(`data-state`),this.hidden=!0}_clearTimer(){this._timer!==null&&(clearTimeout(this._timer),this._timer=null)}};(0,t.defineElement)(`wui-offline-banner`,u),e.WuiOfflineBanner=u})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.181.
|
|
1
|
+
(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.181.1`)throw Error(`[webority-ui] onboarding-checklist expects ui-elements 0.181.1 but the page loaded `+r+`.`);var i=`.wui-onboarding-card`,a=`.wui-onboarding-steps`,o=`.wui-onboarding-toggle`,s=`.wui-onboarding-dismiss`,c=`.wui-onboarding-restore`,l=`wui-onboarding:`,u=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},d=class extends n.ElementBase{constructor(){super(),this._onClick=e=>{let t=e.target instanceof Element?e.target:null;t&&(t.closest(s)?this.dismiss():t.closest(c)?this.restore():t.closest(o)&&this.toggle())}}connectedCallback(){this.addEventListener(`click`,this._onClick),this._stored()===`dismissed`&&this._setDismissed(!0)}disconnectedCallback(){this.removeEventListener(`click`,this._onClick)}get dismissed(){return u(this,i)?.hidden===!0}get collapsed(){return u(this,a)?.hidden===!0}dismiss(){this.dismissed||(this._setDismissed(!0),this._store(`dismissed`),u(this,c)?.focus(),this.dispatchEvent(new CustomEvent(`wui:onboarding:dismiss`,{bubbles:!0})))}restore(){this.dismissed&&(this._setDismissed(!1),this._store(null),u(this,o)?.focus(),this.dispatchEvent(new CustomEvent(`wui:onboarding:restore`,{bubbles:!0})))}toggle(){let e=u(this,a);if(!e)return;let t=!e.hidden;e.hidden=t,this.querySelector(o)?.setAttribute(`aria-expanded`,String(!t)),this.dispatchEvent(new CustomEvent(`wui:onboarding:collapse`,{bubbles:!0,detail:{collapsed:t}}))}_setDismissed(e){let t=u(this,i),n=u(this,c);t&&(t.hidden=e),n&&(n.hidden=!e)}_key(){let e=this.getAttribute(`storage-key`);return e?l+e:null}_stored(){let e=this._key();if(!e)return null;try{return window.localStorage.getItem(e)}catch{return null}}_store(e){let t=this._key();if(t)try{e?window.localStorage.setItem(t,e):window.localStorage.removeItem(t)}catch(e){if(!(e instanceof DOMException))throw e}}};(0,t.defineElement)(`wui-onboarding-checklist`,d),e.WuiOnboardingChecklist=d})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase);
|