@webority/ui-elements 0.173.1 → 0.174.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +1 -1
- package/dist/ui-elements/comment-thread.global.js +1 -1
- package/dist/ui-elements/consent-banner.global.js +1 -1
- package/dist/ui-elements/context-menu.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +1 -1
- package/dist/ui-elements/date-time.global.js +1 -1
- package/dist/ui-elements/datepicker.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/dropdown.global.js +1 -1
- package/dist/ui-elements/entry-grid.global.js +1 -1
- package/dist/ui-elements/gantt.global.js +1 -1
- package/dist/ui-elements/glyphs.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -1
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lead-popup.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +1 -1
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/popover.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +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/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/table-export.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree-picker.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=globalThis.WeborityUiElementsInternal?.version;if(p!==`0.173.1`)throw Error(`[webority-ui] datepicker expects ui-elements 0.173.1 but the page loaded `+p+`.`);var m=()=>(0,d.readText)(`datePicker`,f.DATE_PICKER_TEXT),h=e=>e-(e%10+10)%10-1,g=class extends i.ElementBase{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`disabled-weekdays`,`display-format`,`mode`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}_internals;_value;_defaultValue;_rendered;_viewY;_viewM;_mode;_focus;_gridFocus;_slide;_viewNavigated;_openFn;_closeFn;_onKeyBound;_closingQuietly;get _open(){return(0,r.must)(this._openFn,`open missing`)}get _close(){return(0,r.must)(this._closeFn,`close missing`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._gridFocus=null,this._slide=``}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`)this._syncInvalid();else if(this._rendered){if(e===`value`)this._value=n||``,this._syncFormValue(),this._syncTrigger();else if(e===`display-format`)this._syncTrigger();else if(e===`first-day`){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(0,l.isPopoverOpen)(e)&&this._renderView()}else this.render()}}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e instanceof HTMLButtonElement&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,(0,s.syncFormMirror)(this,this._value),this._syncTrigger()}_firstDay(){return(0,n.firstWeekday)(this)}_monthOnly(){return this.getAttribute(`mode`)===`month`}_yearOnly(){return this.getAttribute(`mode`)===`year`}_monthKey(e){return e&&this.hasAttribute(`value-as-date`)?e.slice(0,7):e}_monthStored(e){return this.hasAttribute(`value-as-date`)?`${e}-01`:e}_parts(e){if(this._yearOnly()){let t=(0,n.parseIsoYear)(e);return t?{y:t.y,m:0,d:1}:null}if(!this._monthOnly())return(0,n.parseIso)(e);let t=(0,n.parseIsoMonth)(this._monthKey(e));return t?{y:t.y,m:t.m,d:1}:null}_placeholder(){return this.getAttribute(`placeholder`)||(this._yearOnly()?m().yearPlaceholder:this._monthOnly()?m().monthPlaceholder:m().placeholder)}_label(e){let t=this.getAttribute(`display-format`);return this._yearOnly()?(0,n.fmtYear)(e,t):this._monthOnly()?(0,n.fmtMonth)(this._monthKey(e)||``,t):(0,n.fmt)(e,t)}render(){this._dropPanel(),this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this._placeholder(),t=this._parts(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),i=n===`sm`?` wui-input-sm`:n===`lg`?` wui-input-lg`:n===`xl`?` wui-input-xl`:``,o=this.getAttribute(`aria-label`),l=this.getAttribute(`aria-describedby`);this.replaceChildren((0,r.make)(`div`,{class:`datepicker`},(0,r.make)(`button`,{type:`button`,class:`input datepicker-trigger${i}${t?` has-value`:``}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)?!0:void 0,"aria-label":o,"aria-describedby":l},(0,r.make)(`span`,{"data-trigger-label":!0,class:t?``:`wui-select-placeholder`},t?this._label(this._value):e),(0,c.glyphNode)(`calendar-dots`)),(0,r.make)(`div`,{class:`datepicker-pop`,role:`dialog`,popover:`auto`}))),this._rendered=!0,(0,a.syncFieldState)(this,this.querySelector(`.datepicker-trigger`)),(0,s.syncFormMirror)(this,this._value),this._wire()}_syncFormValue(){(0,s.syncFormMirror)(this,this._value)}_syncTrigger(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!(t instanceof HTMLSpanElement))return;let n=this._parts(this._value);t.textContent=n?this._label(this._value):this._placeholder(),t.classList.toggle(`wui-select-placeholder`,!n),e?.classList.toggle(`has-value`,!!n),(0,a.syncFieldState)(this,e)}_limits(){if(this._yearOnly()){let e=(0,n.parseIsoYear)(this.getAttribute(`min`)),t=(0,n.parseIsoYear)(this.getAttribute(`max`)),r=e?e.y:-1/0,i=t?t.y:1/0;return{dayDisabled:()=>!0,monthDisabled:()=>!0,yearDisabled:e=>e<r||e>i}}if(this._monthOnly()){let e=(0,n.parseIsoMonth)(this._monthKey(this.getAttribute(`min`))),t=(0,n.parseIsoMonth)(this._monthKey(this.getAttribute(`max`))),r=e?e.y*12+e.m:-1/0,i=t?t.y*12+t.m:1/0,a=e?e.y:-1/0,o=t?t.y:1/0;return{dayDisabled:()=>!0,monthDisabled:(e,t)=>{let n=e*12+t;return n<r||n>i},yearDisabled:e=>e<a||e>o}}let e=(0,n.parseIso)(this.getAttribute(`min`)),t=(0,n.parseIso)(this.getAttribute(`max`)),r=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=t?new Date(t.y,t.m,t.d).getTime():1/0,a=new Set;for(let e of(this.getAttribute(`disabled-weekdays`)||``).split(`,`)){let t=e.trim();/^[0-6]$/.test(t)&&a.add(Number(t))}return{dayDisabled:(e,t,n)=>{let o=new Date(e,t,n),s=o.getTime();return s<r||s>i||a.has(o.getDay())},monthDisabled:(e,t)=>{let a=new Date(e,t,1).getTime();return new Date(e,t,(0,n.daysIn)(e,t)).getTime()<r||a>i},yearDisabled:e=>{let t=new Date(e,0,1).getTime();return new Date(e,11,31).getTime()<r||t>i}}}_dropPanel(){let e=this.querySelector(`.datepicker-pop`);if(e instanceof HTMLDivElement){this._closingQuietly=!0;try{(0,l.closeAnchoredPopover)(e)}finally{this._closingQuietly=!1}}}_renderView(){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(this._mode===`months`?e.replaceChildren(...this._monthsNodes()):this._mode===`years`?e.replaceChildren(...this._yearsNodes()):e.replaceChildren(...this._daysNodes()),this._focusActive())}_daysNodes(){let e=this._firstDay(),t=(new Date(this._viewY,this._viewM,1).getDay()-e+7)%7,i=(0,n.daysIn)(this._viewY,this._viewM),s=(0,n.parseIso)(this._value),l=new Date,{dayDisabled:u}=this._limits(),d=this._focus||s||{y:this._viewY,m:this._viewM,d:1},f=(e,t,i,a)=>{let o=(0,n.toIso)(e,t,i),c=s&&s.y===e&&s.m===t&&s.d===i,f=l.getFullYear()===e&&l.getMonth()===t&&l.getDate()===i,p=d.y===e&&d.m===t&&d.d===i,m=u(e,t,i),h=[`datepicker-day`,a?`is-outside`:``,f?`is-today`:``,c?`is-selected`:``].filter(Boolean).join(` `);return(0,r.make)(`button`,{type:`button`,class:h,"data-iso":o,role:`gridcell`,tabindex:p&&!m?`0`:`-1`,"aria-selected":c?`true`:void 0,disabled:m?!0:void 0,"aria-disabled":m?`true`:void 0},i)},p=[],h=(0,n.clampMonth)(this._viewY,this._viewM-1),g=(0,n.daysIn)(h.y,h.m);for(let e=t-1;e>=0;e--)p.push(f(h.y,h.m,g-e,!0));for(let e=1;e<=i;e++)p.push(f(this._viewY,this._viewM,e,!1));let _=(0,n.clampMonth)(this._viewY,this._viewM+1),v=(7-(t+i)%7)%7;for(let e=1;e<=v;e++)p.push(f(_.y,_.m,e,!0));let y=u(l.getFullYear(),l.getMonth(),l.getDate()),b=(0,a.isInert)(this)?null:(0,r.make)(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},m().clearLabel),x=Array.from({length:7},(t,n)=>(0,r.make)(`span`,null,(0,o.weekdayLabel)((n+e)%7,`min`)));return[(0,r.make)(`div`,{class:`datepicker-head`},(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`-1`,"aria-label":m().previousMonth},(0,c.glyphNode)(`chevron-left`)),(0,r.make)(`button`,{type:`button`,class:`datepicker-month`,"data-view":`months`,"aria-label":m().chooseMonthYearLabel},`${(0,o.monthLongLabel)(this._viewM)} ${this._viewY}`),(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`1`,"aria-label":m().nextMonth},(0,c.glyphNode)(`chevron-right`))),(0,r.make)(`div`,{class:`datepicker-weekdays`},...x),(0,r.make)(`div`,{class:`datepicker-grid${this._slide?` ${this._slide}`:``}`,role:`grid`},...p),(0,r.make)(`div`,{class:`datepicker-foot`},(0,r.make)(`button`,{type:`button`,class:`datepicker-link`,"data-today":!0,disabled:y?!0:void 0},m().todayLabel),b)]}_clearFoot(e){return!e||(0,a.isInert)(this)?[]:[(0,r.make)(`div`,{class:`datepicker-foot`},(0,r.make)(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},m().clearLabel))]}_monthsNodes(){let e=this._parts(this._value),t=new Date,{monthDisabled:n}=this._limits(),i=[];for(let a=0;a<12;a++){let s=e&&e.y===this._viewY&&e.m===a,c=t.getFullYear()===this._viewY&&t.getMonth()===a,l=n(this._viewY,a),u=[`datepicker-cell`,c?`is-today`:``,s?`is-selected`:``].filter(Boolean).join(` `);i.push((0,r.make)(`button`,{type:`button`,class:u,"data-month":a,tabindex:this._monthOnly()?this._viewY*12+a===this._gridFocus&&!l?0:-1:void 0,disabled:l?!0:void 0},(0,o.monthLabel)(a)))}return[(0,r.make)(`div`,{class:`datepicker-head`},(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`-1`,"aria-label":m().previousYearLabel},(0,c.glyphNode)(`chevron-left`)),(0,r.make)(`button`,{type:`button`,class:`datepicker-month`,"data-view":`years`,"aria-label":m().chooseYearLabel},this._viewY),(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`1`,"aria-label":m().nextYearLabel},(0,c.glyphNode)(`chevron-right`))),(0,r.make)(`div`,{class:`datepicker-cells`},...i),...this._clearFoot(this._monthOnly())]}_yearsNodes(){let e=this._parts(this._value),t=new Date().getFullYear(),{yearDisabled:n}=this._limits(),i=h(this._viewY),a=[];for(let o=0;o<12;o++){let s=i+o,c=e&&e.y===s,l=t===s,u=n(s),d=[`datepicker-cell`,l?`is-today`:``,c?`is-selected`:``].filter(Boolean).join(` `);a.push((0,r.make)(`button`,{type:`button`,class:d,"data-year":s,tabindex:this._yearOnly()?s===this._gridFocus&&!u?0:-1:void 0,disabled:u?!0:void 0},s))}return[(0,r.make)(`div`,{class:`datepicker-head`},(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`-1`,"aria-label":m().previousDecadeLabel},(0,c.glyphNode)(`chevron-left`)),(0,r.make)(`span`,{class:`datepicker-month`},`${i+1} to ${i+10}`),(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`1`,"aria-label":m().nextDecadeLabel},(0,c.glyphNode)(`chevron-right`))),(0,r.make)(`div`,{class:`datepicker-cells`},...a),...this._clearFoot(this._yearOnly())]}_gridKind(){if(this._monthOnly()){let{monthDisabled:e}=this._limits(),t=e=>e-Math.floor(e/12)*12;return{view:`months`,attr:`month`,per:12,page:12,lo:e=>e*12,unit:(e,t)=>e*12+t,cell:t,disabled:n=>e(Math.floor(n/12),t(n)),iso:e=>this._monthStored((0,n.toIsoMonth)(Math.floor(e/12),t(e)))}}if(this._yearOnly()){let{yearDisabled:e}=this._limits();return{view:`years`,attr:`year`,per:1,page:10,lo:h,unit:e=>e,cell:e=>e,disabled:e,iso:n.toIsoYear}}return null}_gridFocusCell(e){let t=e.lo(this._viewY),n=e=>e!==null&&e>=t&&e<t+12,r=this._parts(this._value),i=new Date,a=[r?e.unit(r.y,r.m):null,e.unit(i.getFullYear(),i.getMonth())];for(let t of a)if(n(t)&&!e.disabled(t))return t;for(let n=t;n<t+12;n++)if(!e.disabled(n))return n;return null}_syncGridFocus(){let e=this._gridKind();e&&(this._gridFocus=this._gridFocusCell(e))}_focusActive(){let e=this.querySelector(`.datepicker-pop`);if(!(e instanceof HTMLDivElement))return;let t=e.querySelector(`[tabindex="0"]`)||e.querySelector(`.is-selected`)||e.querySelector(`.datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)`);t instanceof HTMLElement&&e.contains(document.activeElement)&&t.focus()}_setFocus(e,t,r,i){let{y:a,m:o}=(0,n.clampMonth)(e,t);this._focus={y:a,m:o,d:r};let s=a!==this._viewY||o!==this._viewM;this._viewY=a,this._viewM=o,this._slide=s&&i||``,this._renderView(),this._slide=``;let c=this.querySelector(`.datepicker-day[data-iso="${(0,n.toIso)(a,o,r)}"]`);c instanceof HTMLButtonElement&&c.focus()}_seek(e,t,n,r){let{dayDisabled:i}=this._limits(),a=new Date(e,t,n);for(let e=0;e<400;e++,a.setDate(a.getDate()+r))if(!i(a.getFullYear(),a.getMonth(),a.getDate()))return new Date(a);return null}_onGridKey(e,t){let n=(e,n)=>{for(let r=0;r<100*t.per;r++,e+=n)if(!t.disabled(e))return e;return null},r=(e,t)=>{let r=n(t>0?e:e+11,t);return r!==null&&r>=e&&r<e+12?r:null},i=e=>{this._viewY=Math.floor(e/t.per),this._gridFocus=e,this._renderView();let n=this.querySelector(`.datepicker-cell[data-${t.attr}="${t.cell(e)}"]`);n instanceof HTMLButtonElement&&n.focus()},a=r=>{e.preventDefault();let a=t.lo(this._viewY),o=n((this._gridFocus??(r<0?a+12:a-1))+r,r<0?-1:1);o!==null&&i(o)};switch((0,u.mirrorKey)(e.key,(0,u.isRtl)(this))){case`ArrowLeft`:a(-1);break;case`ArrowRight`:a(1);break;case`ArrowUp`:a(-3);break;case`ArrowDown`:a(3);break;case`Home`:{e.preventDefault();let n=r(t.lo(this._viewY),1);n!==null&&i(n);break}case`End`:{e.preventDefault();let n=r(t.lo(this._viewY),-1);n!==null&&i(n);break}case`PageUp`:case`PageDown`:{e.preventDefault();let n=(this._gridFocus??t.lo(this._viewY))+(e.key===`PageUp`?-1:1)*t.page,a=t.disabled(n)?r(t.lo(Math.floor(n/t.per)),1):n;a!==null&&i(a);break}case`Enter`:case` `:{e.preventDefault();let n=this._gridFocus;n!==null&&!t.disabled(n)&&(this.value=t.iso(n),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());break}}}_onKey(e){let t=this._gridKind();if(t&&this._mode===t.view){this._onGridKey(e,t);return}if(this._mode!==`days`)return;let r=this._focus||(0,n.parseIso)(this._value)||{y:this._viewY,m:this._viewM,d:1},i=(e,t,n,r,i)=>{let a=this._seek(e,t,n,r);a&&this._setFocus(a.getFullYear(),a.getMonth(),a.getDate(),i)},a=(t,n,a=t<0?-1:1)=>{e.preventDefault(),i(r.y,r.m,r.d+t,a,n)};switch((0,u.mirrorKey)(e.key,(0,u.isRtl)(this))){case`ArrowLeft`:a(-1,`slide-prev`);break;case`ArrowRight`:a(1,`slide-next`);break;case`ArrowUp`:a(-7,`slide-prev`);break;case`ArrowDown`:a(7,`slide-next`);break;case`Home`:a(-((new Date(r.y,r.m,r.d).getDay()-this._firstDay()+7)%7),`slide-prev`,1);break;case`End`:a(6-(new Date(r.y,r.m,r.d).getDay()-this._firstDay()+7)%7,`slide-next`,-1);break;case`PageUp`:{e.preventDefault();let t=(0,n.clampMonth)(r.y,r.m-(e.shiftKey?12:1));i(t.y,t.m,Math.min(r.d,(0,n.daysIn)(t.y,t.m)),-1,`slide-prev`);break}case`PageDown`:{e.preventDefault();let t=(0,n.clampMonth)(r.y,r.m+(e.shiftKey?12:1));i(t.y,t.m,Math.min(r.d,(0,n.daysIn)(t.y,t.m)),1,`slide-next`);break}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(r.y,r.m,r.d)||(this.value=(0,n.toIso)(r.y,r.m,r.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return}}_wire(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`.datepicker-pop`),r=this.querySelector(`.datepicker`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let i=()=>(0,l.isPopoverOpen)(t),o=()=>{r?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this._closingQuietly||e.focus()};this._openFn=()=>{if((0,a.isInert)(this))return;let n=new Date,s=this._parts(this._value),c=this._gridKind();if(c)this._viewY=s?s.y:n.getFullYear(),this._mode=c.view,this._focus=null,this._gridFocus=this._gridFocusCell(c);else{(s||!this._viewNavigated)&&(this._viewY=n.getFullYear(),this._viewM=n.getMonth()),this._mode=`days`;let e=n.getFullYear()===this._viewY&&n.getMonth()===this._viewM,t=s&&s.y===this._viewY&&s.m===this._viewM;if(this._focus=t?s:{y:this._viewY,m:this._viewM,d:e?n.getDate():1},this._limits().dayDisabled(this._focus.y,this._focus.m,this._focus.d)){let e=this._focus,t=[1,-1].map(t=>this._seek(e.y,e.m,e.d,t)).find(t=>t&&t.getMonth()===e.m);t&&(this._focus={y:t.getFullYear(),m:t.getMonth(),d:t.getDate()})}}if(this._renderView(),(0,l.openAnchoredPopover)(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),!i())return;r?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`);let u=t.querySelector(`[tabindex="0"]`);u instanceof HTMLElement&&u.focus()},this._closeFn=()=>{(0,l.closeAnchoredPopover)(t)},e.addEventListener(`click`,()=>i()?this._close():this._open()),t.addEventListener(`click`,e=>{let t=e.target;if(!(t instanceof Element))throw Error(`click target is not an element`);let r=t.closest(`[data-nav]`);if(r instanceof HTMLElement){this._viewNavigated=!0,this._slide=Number(r.dataset.nav)<0?`slide-prev`:`slide-next`;let e=(0,n.clampMonth)(this._viewY,this._viewM+Number(r.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._focus={y:e.y,m:e.m,d:1},this._renderView(),this._slide=``;return}let i=t.closest(`[data-nav-year]`);if(i instanceof HTMLElement){this._viewY+=Number(i.dataset.navYear),this._syncGridFocus(),this._renderView();return}let a=t.closest(`[data-nav-decade]`);if(a instanceof HTMLElement){this._viewY+=Number(a.dataset.navDecade)*10,this._syncGridFocus(),this._renderView();return}let o=t.closest(`[data-view]`);if(o instanceof HTMLElement){this._mode=o.dataset.view,this._renderView();return}let s=t.closest(`[data-month]`);if(s instanceof HTMLButtonElement&&!s.disabled){if(this._monthOnly()){this.value=this._monthStored((0,n.toIsoMonth)(this._viewY,Number(s.dataset.month))),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewM=Number(s.dataset.month),this._mode=`days`,this._focus={y:this._viewY,m:this._viewM,d:1},this._renderView();return}let c=t.closest(`[data-year]`);if(c instanceof HTMLButtonElement&&!c.disabled){if(this._yearOnly()){this.value=(0,n.toIsoYear)(Number(c.dataset.year)),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewY=Number(c.dataset.year),this._mode=`months`,this._syncGridFocus(),this._renderView();return}if(t.closest(`[data-today]`)){let e=new Date;if(this._limits().dayDisabled(e.getFullYear(),e.getMonth(),e.getDate()))return;this.value=(0,n.toIso)(e.getFullYear(),e.getMonth(),e.getDate()),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}if(t.closest(`[data-clear]`)){this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}let l=t.closest(`.datepicker-day[data-iso]`);l instanceof HTMLButtonElement&&!l.disabled&&(this.value=l.dataset.iso,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{i()&&this._onKey(e)},t.addEventListener(`keydown`,this._onKeyBound),this._syncFormValue()}};(0,t.defineElement)(`wui-datepicker`,g),e.WuiDatePicker=g})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.calendarMath,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.datePickerText);
|
|
1
|
+
(function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=globalThis.WeborityUiElementsInternal?.version;if(p!==`0.174.0`)throw Error(`[webority-ui] datepicker expects ui-elements 0.174.0 but the page loaded `+p+`.`);var m=()=>(0,d.readText)(`datePicker`,f.DATE_PICKER_TEXT),h=e=>e-(e%10+10)%10-1,g=class extends i.ElementBase{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`disabled-weekdays`,`display-format`,`mode`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}_internals;_value;_defaultValue;_rendered;_viewY;_viewM;_mode;_focus;_gridFocus;_slide;_viewNavigated;_openFn;_closeFn;_onKeyBound;_closingQuietly;get _open(){return(0,r.must)(this._openFn,`open missing`)}get _close(){return(0,r.must)(this._closeFn,`close missing`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._gridFocus=null,this._slide=``}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`)this._syncInvalid();else if(this._rendered){if(e===`value`)this._value=n||``,this._syncFormValue(),this._syncTrigger();else if(e===`display-format`)this._syncTrigger();else if(e===`first-day`){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(0,l.isPopoverOpen)(e)&&this._renderView()}else this.render()}}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e instanceof HTMLButtonElement&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,(0,s.syncFormMirror)(this,this._value),this._syncTrigger()}_firstDay(){return(0,n.firstWeekday)(this)}_monthOnly(){return this.getAttribute(`mode`)===`month`}_yearOnly(){return this.getAttribute(`mode`)===`year`}_monthKey(e){return e&&this.hasAttribute(`value-as-date`)?e.slice(0,7):e}_monthStored(e){return this.hasAttribute(`value-as-date`)?`${e}-01`:e}_parts(e){if(this._yearOnly()){let t=(0,n.parseIsoYear)(e);return t?{y:t.y,m:0,d:1}:null}if(!this._monthOnly())return(0,n.parseIso)(e);let t=(0,n.parseIsoMonth)(this._monthKey(e));return t?{y:t.y,m:t.m,d:1}:null}_placeholder(){return this.getAttribute(`placeholder`)||(this._yearOnly()?m().yearPlaceholder:this._monthOnly()?m().monthPlaceholder:m().placeholder)}_label(e){let t=this.getAttribute(`display-format`);return this._yearOnly()?(0,n.fmtYear)(e,t):this._monthOnly()?(0,n.fmtMonth)(this._monthKey(e)||``,t):(0,n.fmt)(e,t)}render(){this._dropPanel(),this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this._placeholder(),t=this._parts(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),i=n===`sm`?` wui-input-sm`:n===`lg`?` wui-input-lg`:n===`xl`?` wui-input-xl`:``,o=this.getAttribute(`aria-label`),l=this.getAttribute(`aria-describedby`);this.replaceChildren((0,r.make)(`div`,{class:`datepicker`},(0,r.make)(`button`,{type:`button`,class:`input datepicker-trigger${i}${t?` has-value`:``}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)?!0:void 0,"aria-label":o,"aria-describedby":l},(0,r.make)(`span`,{"data-trigger-label":!0,class:t?``:`wui-select-placeholder`},t?this._label(this._value):e),(0,c.glyphNode)(`calendar-dots`)),(0,r.make)(`div`,{class:`datepicker-pop`,role:`dialog`,popover:`auto`}))),this._rendered=!0,(0,a.syncFieldState)(this,this.querySelector(`.datepicker-trigger`)),(0,s.syncFormMirror)(this,this._value),this._wire()}_syncFormValue(){(0,s.syncFormMirror)(this,this._value)}_syncTrigger(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!(t instanceof HTMLSpanElement))return;let n=this._parts(this._value);t.textContent=n?this._label(this._value):this._placeholder(),t.classList.toggle(`wui-select-placeholder`,!n),e?.classList.toggle(`has-value`,!!n),(0,a.syncFieldState)(this,e)}_limits(){if(this._yearOnly()){let e=(0,n.parseIsoYear)(this.getAttribute(`min`)),t=(0,n.parseIsoYear)(this.getAttribute(`max`)),r=e?e.y:-1/0,i=t?t.y:1/0;return{dayDisabled:()=>!0,monthDisabled:()=>!0,yearDisabled:e=>e<r||e>i}}if(this._monthOnly()){let e=(0,n.parseIsoMonth)(this._monthKey(this.getAttribute(`min`))),t=(0,n.parseIsoMonth)(this._monthKey(this.getAttribute(`max`))),r=e?e.y*12+e.m:-1/0,i=t?t.y*12+t.m:1/0,a=e?e.y:-1/0,o=t?t.y:1/0;return{dayDisabled:()=>!0,monthDisabled:(e,t)=>{let n=e*12+t;return n<r||n>i},yearDisabled:e=>e<a||e>o}}let e=(0,n.parseIso)(this.getAttribute(`min`)),t=(0,n.parseIso)(this.getAttribute(`max`)),r=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=t?new Date(t.y,t.m,t.d).getTime():1/0,a=new Set;for(let e of(this.getAttribute(`disabled-weekdays`)||``).split(`,`)){let t=e.trim();/^[0-6]$/.test(t)&&a.add(Number(t))}return{dayDisabled:(e,t,n)=>{let o=new Date(e,t,n),s=o.getTime();return s<r||s>i||a.has(o.getDay())},monthDisabled:(e,t)=>{let a=new Date(e,t,1).getTime();return new Date(e,t,(0,n.daysIn)(e,t)).getTime()<r||a>i},yearDisabled:e=>{let t=new Date(e,0,1).getTime();return new Date(e,11,31).getTime()<r||t>i}}}_dropPanel(){let e=this.querySelector(`.datepicker-pop`);if(e instanceof HTMLDivElement){this._closingQuietly=!0;try{(0,l.closeAnchoredPopover)(e)}finally{this._closingQuietly=!1}}}_renderView(){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(this._mode===`months`?e.replaceChildren(...this._monthsNodes()):this._mode===`years`?e.replaceChildren(...this._yearsNodes()):e.replaceChildren(...this._daysNodes()),this._focusActive())}_daysNodes(){let e=this._firstDay(),t=(new Date(this._viewY,this._viewM,1).getDay()-e+7)%7,i=(0,n.daysIn)(this._viewY,this._viewM),s=(0,n.parseIso)(this._value),l=new Date,{dayDisabled:u}=this._limits(),d=this._focus||s||{y:this._viewY,m:this._viewM,d:1},f=(e,t,i,a)=>{let o=(0,n.toIso)(e,t,i),c=s&&s.y===e&&s.m===t&&s.d===i,f=l.getFullYear()===e&&l.getMonth()===t&&l.getDate()===i,p=d.y===e&&d.m===t&&d.d===i,m=u(e,t,i),h=[`datepicker-day`,a?`is-outside`:``,f?`is-today`:``,c?`is-selected`:``].filter(Boolean).join(` `);return(0,r.make)(`button`,{type:`button`,class:h,"data-iso":o,role:`gridcell`,tabindex:p&&!m?`0`:`-1`,"aria-selected":c?`true`:void 0,disabled:m?!0:void 0,"aria-disabled":m?`true`:void 0},i)},p=[],h=(0,n.clampMonth)(this._viewY,this._viewM-1),g=(0,n.daysIn)(h.y,h.m);for(let e=t-1;e>=0;e--)p.push(f(h.y,h.m,g-e,!0));for(let e=1;e<=i;e++)p.push(f(this._viewY,this._viewM,e,!1));let _=(0,n.clampMonth)(this._viewY,this._viewM+1),v=(7-(t+i)%7)%7;for(let e=1;e<=v;e++)p.push(f(_.y,_.m,e,!0));let y=u(l.getFullYear(),l.getMonth(),l.getDate()),b=(0,a.isInert)(this)?null:(0,r.make)(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},m().clearLabel),x=Array.from({length:7},(t,n)=>(0,r.make)(`span`,null,(0,o.weekdayLabel)((n+e)%7,`min`)));return[(0,r.make)(`div`,{class:`datepicker-head`},(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`-1`,"aria-label":m().previousMonth},(0,c.glyphNode)(`chevron-left`)),(0,r.make)(`button`,{type:`button`,class:`datepicker-month`,"data-view":`months`,"aria-label":m().chooseMonthYearLabel},`${(0,o.monthLongLabel)(this._viewM)} ${this._viewY}`),(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`1`,"aria-label":m().nextMonth},(0,c.glyphNode)(`chevron-right`))),(0,r.make)(`div`,{class:`datepicker-weekdays`},...x),(0,r.make)(`div`,{class:`datepicker-grid${this._slide?` ${this._slide}`:``}`,role:`grid`},...p),(0,r.make)(`div`,{class:`datepicker-foot`},(0,r.make)(`button`,{type:`button`,class:`datepicker-link`,"data-today":!0,disabled:y?!0:void 0},m().todayLabel),b)]}_clearFoot(e){return!e||(0,a.isInert)(this)?[]:[(0,r.make)(`div`,{class:`datepicker-foot`},(0,r.make)(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},m().clearLabel))]}_monthsNodes(){let e=this._parts(this._value),t=new Date,{monthDisabled:n}=this._limits(),i=[];for(let a=0;a<12;a++){let s=e&&e.y===this._viewY&&e.m===a,c=t.getFullYear()===this._viewY&&t.getMonth()===a,l=n(this._viewY,a),u=[`datepicker-cell`,c?`is-today`:``,s?`is-selected`:``].filter(Boolean).join(` `);i.push((0,r.make)(`button`,{type:`button`,class:u,"data-month":a,tabindex:this._monthOnly()?this._viewY*12+a===this._gridFocus&&!l?0:-1:void 0,disabled:l?!0:void 0},(0,o.monthLabel)(a)))}return[(0,r.make)(`div`,{class:`datepicker-head`},(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`-1`,"aria-label":m().previousYearLabel},(0,c.glyphNode)(`chevron-left`)),(0,r.make)(`button`,{type:`button`,class:`datepicker-month`,"data-view":`years`,"aria-label":m().chooseYearLabel},this._viewY),(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`1`,"aria-label":m().nextYearLabel},(0,c.glyphNode)(`chevron-right`))),(0,r.make)(`div`,{class:`datepicker-cells`},...i),...this._clearFoot(this._monthOnly())]}_yearsNodes(){let e=this._parts(this._value),t=new Date().getFullYear(),{yearDisabled:n}=this._limits(),i=h(this._viewY),a=[];for(let o=0;o<12;o++){let s=i+o,c=e&&e.y===s,l=t===s,u=n(s),d=[`datepicker-cell`,l?`is-today`:``,c?`is-selected`:``].filter(Boolean).join(` `);a.push((0,r.make)(`button`,{type:`button`,class:d,"data-year":s,tabindex:this._yearOnly()?s===this._gridFocus&&!u?0:-1:void 0,disabled:u?!0:void 0},s))}return[(0,r.make)(`div`,{class:`datepicker-head`},(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`-1`,"aria-label":m().previousDecadeLabel},(0,c.glyphNode)(`chevron-left`)),(0,r.make)(`span`,{class:`datepicker-month`},`${i+1} to ${i+10}`),(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`1`,"aria-label":m().nextDecadeLabel},(0,c.glyphNode)(`chevron-right`))),(0,r.make)(`div`,{class:`datepicker-cells`},...a),...this._clearFoot(this._yearOnly())]}_gridKind(){if(this._monthOnly()){let{monthDisabled:e}=this._limits(),t=e=>e-Math.floor(e/12)*12;return{view:`months`,attr:`month`,per:12,page:12,lo:e=>e*12,unit:(e,t)=>e*12+t,cell:t,disabled:n=>e(Math.floor(n/12),t(n)),iso:e=>this._monthStored((0,n.toIsoMonth)(Math.floor(e/12),t(e)))}}if(this._yearOnly()){let{yearDisabled:e}=this._limits();return{view:`years`,attr:`year`,per:1,page:10,lo:h,unit:e=>e,cell:e=>e,disabled:e,iso:n.toIsoYear}}return null}_gridFocusCell(e){let t=e.lo(this._viewY),n=e=>e!==null&&e>=t&&e<t+12,r=this._parts(this._value),i=new Date,a=[r?e.unit(r.y,r.m):null,e.unit(i.getFullYear(),i.getMonth())];for(let t of a)if(n(t)&&!e.disabled(t))return t;for(let n=t;n<t+12;n++)if(!e.disabled(n))return n;return null}_syncGridFocus(){let e=this._gridKind();e&&(this._gridFocus=this._gridFocusCell(e))}_focusActive(){let e=this.querySelector(`.datepicker-pop`);if(!(e instanceof HTMLDivElement))return;let t=e.querySelector(`[tabindex="0"]`)||e.querySelector(`.is-selected`)||e.querySelector(`.datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)`);t instanceof HTMLElement&&e.contains(document.activeElement)&&t.focus()}_setFocus(e,t,r,i){let{y:a,m:o}=(0,n.clampMonth)(e,t);this._focus={y:a,m:o,d:r};let s=a!==this._viewY||o!==this._viewM;this._viewY=a,this._viewM=o,this._slide=s&&i||``,this._renderView(),this._slide=``;let c=this.querySelector(`.datepicker-day[data-iso="${(0,n.toIso)(a,o,r)}"]`);c instanceof HTMLButtonElement&&c.focus()}_seek(e,t,n,r){let{dayDisabled:i}=this._limits(),a=new Date(e,t,n);for(let e=0;e<400;e++,a.setDate(a.getDate()+r))if(!i(a.getFullYear(),a.getMonth(),a.getDate()))return new Date(a);return null}_onGridKey(e,t){let n=(e,n)=>{for(let r=0;r<100*t.per;r++,e+=n)if(!t.disabled(e))return e;return null},r=(e,t)=>{let r=n(t>0?e:e+11,t);return r!==null&&r>=e&&r<e+12?r:null},i=e=>{this._viewY=Math.floor(e/t.per),this._gridFocus=e,this._renderView();let n=this.querySelector(`.datepicker-cell[data-${t.attr}="${t.cell(e)}"]`);n instanceof HTMLButtonElement&&n.focus()},a=r=>{e.preventDefault();let a=t.lo(this._viewY),o=n((this._gridFocus??(r<0?a+12:a-1))+r,r<0?-1:1);o!==null&&i(o)};switch((0,u.mirrorKey)(e.key,(0,u.isRtl)(this))){case`ArrowLeft`:a(-1);break;case`ArrowRight`:a(1);break;case`ArrowUp`:a(-3);break;case`ArrowDown`:a(3);break;case`Home`:{e.preventDefault();let n=r(t.lo(this._viewY),1);n!==null&&i(n);break}case`End`:{e.preventDefault();let n=r(t.lo(this._viewY),-1);n!==null&&i(n);break}case`PageUp`:case`PageDown`:{e.preventDefault();let n=(this._gridFocus??t.lo(this._viewY))+(e.key===`PageUp`?-1:1)*t.page,a=t.disabled(n)?r(t.lo(Math.floor(n/t.per)),1):n;a!==null&&i(a);break}case`Enter`:case` `:{e.preventDefault();let n=this._gridFocus;n!==null&&!t.disabled(n)&&(this.value=t.iso(n),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());break}}}_onKey(e){let t=this._gridKind();if(t&&this._mode===t.view){this._onGridKey(e,t);return}if(this._mode!==`days`)return;let r=this._focus||(0,n.parseIso)(this._value)||{y:this._viewY,m:this._viewM,d:1},i=(e,t,n,r,i)=>{let a=this._seek(e,t,n,r);a&&this._setFocus(a.getFullYear(),a.getMonth(),a.getDate(),i)},a=(t,n,a=t<0?-1:1)=>{e.preventDefault(),i(r.y,r.m,r.d+t,a,n)};switch((0,u.mirrorKey)(e.key,(0,u.isRtl)(this))){case`ArrowLeft`:a(-1,`slide-prev`);break;case`ArrowRight`:a(1,`slide-next`);break;case`ArrowUp`:a(-7,`slide-prev`);break;case`ArrowDown`:a(7,`slide-next`);break;case`Home`:a(-((new Date(r.y,r.m,r.d).getDay()-this._firstDay()+7)%7),`slide-prev`,1);break;case`End`:a(6-(new Date(r.y,r.m,r.d).getDay()-this._firstDay()+7)%7,`slide-next`,-1);break;case`PageUp`:{e.preventDefault();let t=(0,n.clampMonth)(r.y,r.m-(e.shiftKey?12:1));i(t.y,t.m,Math.min(r.d,(0,n.daysIn)(t.y,t.m)),-1,`slide-prev`);break}case`PageDown`:{e.preventDefault();let t=(0,n.clampMonth)(r.y,r.m+(e.shiftKey?12:1));i(t.y,t.m,Math.min(r.d,(0,n.daysIn)(t.y,t.m)),1,`slide-next`);break}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(r.y,r.m,r.d)||(this.value=(0,n.toIso)(r.y,r.m,r.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return}}_wire(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`.datepicker-pop`),r=this.querySelector(`.datepicker`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let i=()=>(0,l.isPopoverOpen)(t),o=()=>{r?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this._closingQuietly||e.focus()};this._openFn=()=>{if((0,a.isInert)(this))return;let n=new Date,s=this._parts(this._value),c=this._gridKind();if(c)this._viewY=s?s.y:n.getFullYear(),this._mode=c.view,this._focus=null,this._gridFocus=this._gridFocusCell(c);else{(s||!this._viewNavigated)&&(this._viewY=n.getFullYear(),this._viewM=n.getMonth()),this._mode=`days`;let e=n.getFullYear()===this._viewY&&n.getMonth()===this._viewM,t=s&&s.y===this._viewY&&s.m===this._viewM;if(this._focus=t?s:{y:this._viewY,m:this._viewM,d:e?n.getDate():1},this._limits().dayDisabled(this._focus.y,this._focus.m,this._focus.d)){let e=this._focus,t=[1,-1].map(t=>this._seek(e.y,e.m,e.d,t)).find(t=>t&&t.getMonth()===e.m);t&&(this._focus={y:t.getFullYear(),m:t.getMonth(),d:t.getDate()})}}if(this._renderView(),(0,l.openAnchoredPopover)(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),!i())return;r?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`);let u=t.querySelector(`[tabindex="0"]`);u instanceof HTMLElement&&u.focus()},this._closeFn=()=>{(0,l.closeAnchoredPopover)(t)},e.addEventListener(`click`,()=>i()?this._close():this._open()),t.addEventListener(`click`,e=>{let t=e.target;if(!(t instanceof Element))throw Error(`click target is not an element`);let r=t.closest(`[data-nav]`);if(r instanceof HTMLElement){this._viewNavigated=!0,this._slide=Number(r.dataset.nav)<0?`slide-prev`:`slide-next`;let e=(0,n.clampMonth)(this._viewY,this._viewM+Number(r.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._focus={y:e.y,m:e.m,d:1},this._renderView(),this._slide=``;return}let i=t.closest(`[data-nav-year]`);if(i instanceof HTMLElement){this._viewY+=Number(i.dataset.navYear),this._syncGridFocus(),this._renderView();return}let a=t.closest(`[data-nav-decade]`);if(a instanceof HTMLElement){this._viewY+=Number(a.dataset.navDecade)*10,this._syncGridFocus(),this._renderView();return}let o=t.closest(`[data-view]`);if(o instanceof HTMLElement){this._mode=o.dataset.view,this._renderView();return}let s=t.closest(`[data-month]`);if(s instanceof HTMLButtonElement&&!s.disabled){if(this._monthOnly()){this.value=this._monthStored((0,n.toIsoMonth)(this._viewY,Number(s.dataset.month))),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewM=Number(s.dataset.month),this._mode=`days`,this._focus={y:this._viewY,m:this._viewM,d:1},this._renderView();return}let c=t.closest(`[data-year]`);if(c instanceof HTMLButtonElement&&!c.disabled){if(this._yearOnly()){this.value=(0,n.toIsoYear)(Number(c.dataset.year)),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewY=Number(c.dataset.year),this._mode=`months`,this._syncGridFocus(),this._renderView();return}if(t.closest(`[data-today]`)){let e=new Date;if(this._limits().dayDisabled(e.getFullYear(),e.getMonth(),e.getDate()))return;this.value=(0,n.toIso)(e.getFullYear(),e.getMonth(),e.getDate()),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}if(t.closest(`[data-clear]`)){this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}let l=t.closest(`.datepicker-day[data-iso]`);l instanceof HTMLButtonElement&&!l.disabled&&(this.value=l.dataset.iso,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{i()&&this._onKey(e)},t.addEventListener(`keydown`,this._onKeyBound),this._syncFormValue()}};(0,t.defineElement)(`wui-datepicker`,g),e.WuiDatePicker=g})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.calendarMath,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.datePickerText);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.
|
|
1
|
+
(function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.174.0`)throw Error(`[webority-ui] drawer expects ui-elements 0.174.0 but the page loaded `+s+`.`);var c=[50,90],l=10,u=100;function d(e,t=c){let n=Array.isArray(e)?e:String(e??``).split(`,`),r=[];for(let e of n){if(typeof e==`string`&&e.trim()===``)return t;let n=Number(e);if(!Number.isFinite(n)||n<l||n>u)return t;r.includes(n)||r.push(n)}return r.length?r.sort((e,t)=>e-t):t}function f(e){let{points:t,index:n,visible:r,velocity:i,canDismiss:a}=e,o=a?-1:0;if(Math.abs(i)>=.5)return i>0?Math.max(n-1,o):Math.min(n+1,t.length-1);let s=t[0];if(a&&s!==void 0&&r<s/2)return-1;let c=0;for(let e=1;e<t.length;e++){let n=t[e],i=t[c];if(n===void 0||i===void 0)throw Error(`snap point missing`);Math.abs(n-r)<Math.abs(i-r)&&(c=e)}return c}var p=()=>(0,a.readText)(`drawer`,o.DRAWER_TEXT),m=`(max-width: 767.98px)`,h=4;function g(e,t){let n=e[t];if(n===void 0)throw RangeError(`no snap point at ${t}`);return n}var _=class extends r.ElementBase{_doc;_media;_shown;_trigger;_returnTo;_release;_snap;_drag;_onMedia;_onPointerDown;_onPointerMove;_onPointerUp;_onKeyDown;_onTransitionEnd;_settled;static get observedAttributes(){return[`open`,`snap-points`,`no-sheet`]}constructor(){super(),this._doc=null,this._media=null,this._shown=!1,this._trigger=null,this._returnTo=null,this._release=null,this._snap=0,this._drag=null,this._onMedia=()=>this._syncMode(),this._onPointerDown=e=>this._pointerDown(e),this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onKeyDown=e=>this._keyDown(e),this._onTransitionEnd=e=>{e.target===this._panel()&&e.propertyName===`transform`&&this.isOpen&&this._announce()},this._settled=!1}connectedCallback(){this._doc=this.ownerDocument,(0,i.wireOpenTriggers)(this._doc),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`transitionend`,this._onTransitionEnd),this._media=typeof matchMedia==`function`?matchMedia(m):null,this._media?.addEventListener?.(`change`,this._onMedia),this._syncMode(),this._applyPoints(),this.hasAttribute(`open`)&&this._open()}disconnectedCallback(){this._endDrag(),this._teardown(),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`transitionend`,this._onTransitionEnd),this._media?.removeEventListener?.(`change`,this._onMedia),this._media=null,this._doc=null}attributeChangedCallback(e){this._doc&&(e===`open`?this.hasAttribute(`open`)?this._open():this._close():e===`no-sheet`?this._syncMode():(this._snap=Math.min(this._snap,this._points().length-1),this._applyPoints()))}get isOpen(){return this.hasAttribute(`open`)}show(e){this._trigger=e??null,this.setAttribute(`open`,``)}hide(){this.removeAttribute(`open`)}_points(){return d(this.getAttribute(`snap-points`),c)}_sheet(){return!!this._media?.matches&&!this.hasAttribute(`no-sheet`)}_syncMode(){this.setAttribute(`data-mode`,this._sheet()?`sheet`:`side`)}_applyPoints(){let e=this._points();this._snap=Math.min(Math.max(this._snap,0),e.length-1),this.style.setProperty(`--wui-drawer-max`,String(e[e.length-1])),this.style.setProperty(`--wui-drawer-snap`,String(e[this._snap])),this.setAttribute(`data-snap`,String(this._snap));let t=this.querySelector(`.wui-drawer-handle`);if(!(t instanceof Element))return;let r=(0,n.must)(e[this._snap],`The drawer has no snap point to report.`);t.setAttribute(`aria-valuemin`,String(e[0])),t.setAttribute(`aria-valuemax`,String(e[e.length-1])),t.setAttribute(`aria-valuenow`,String(r)),t.setAttribute(`aria-valuetext`,(0,a.fillText)(p().screenText,{now:r}))}_setSnap(e){let t=this._points(),n=Math.min(Math.max(e,0),t.length-1),r=n!==this._snap;this._snap=n,this._applyPoints(),r&&this.dispatchEvent(new CustomEvent(`wui-drawer-snap`,{bubbles:!0,detail:{index:n,percent:t[n]}}))}_open(){if(this._shown)return;let e=this._dialog();this._shown=!0,this._settled=null;let t=Number.parseInt(this.getAttribute(`default-snap`)??`0`,10);this._snap=Number.isFinite(t)?t:0,this._syncMode(),this._applyPoints(),this.dispatchEvent(new CustomEvent(`wui-drawer-open`,{bubbles:!0,detail:{trigger:this._trigger}})),this._returnTo=this._trigger,this._trigger=null,this._release=(0,i.openModalDialog)(e,{escape:this._dismissible(),backdrop:this._dismissible(),focus:this._sheet()?`panel`:`first-control`,onRequestClose:e=>this._requestClose(e)}),this._settle()}_close(){if(!this._shown)return;this._endDrag(),this._shown=!1,this._settled=null;let e=this._release;this._release=null;let t=this._dialog();(0,i.closeModalDialog)(t).then(()=>{e?.(),(0,i.returnFocus)(this._returnTo,t),this._returnTo=null,this._announce()})}_teardown(){this._shown=!1;let e=this._release;this._release=null,e&&(e(),this._panel()?.close())}_settle(){(this._panel()?.getAnimations?.()??[]).length||this._announce()}_announce(){let e=this.isOpen;e!==this._settled&&(this._settled=e,this.dispatchEvent(new CustomEvent(e?`wui-drawer-opened`:`wui-drawer-closed`,{bubbles:!0})))}_document(){let e=this._doc;if(!e)throw TypeError(`wui-drawer is not connected`);return e}_panel(){let e=this.querySelector(`.wui-drawer-panel`);return e instanceof HTMLDialogElement?e:null}_dialog(){let e=this._panel();if(!e)throw TypeError(`wui-drawer has no dialog panel`);return e}_dismissible(){return!this.hasAttribute(`static`)&&!this.hasAttribute(`no-dismiss`)}_requestClose(e){let t=this.dispatchEvent(new CustomEvent(`wui-drawer-close`,{bubbles:!0,cancelable:!0,detail:{reason:e}}));return t&&this.hide(),t}_keyDown(e){e.target instanceof Element&&e.target.closest(`.wui-drawer-handle`)&&this._sheet()&&this._handleKey(e)}_handleKey(e){let t=this._points().length-1,n={ArrowUp:this._snap+1,ArrowDown:this._snap-1,Home:0,End:t};if(!(e.key in n))return;let r=n[e.key];r!==void 0&&(e.preventDefault(),this._setSnap(r))}_pointerDown(e){if(!this.isOpen||!this._sheet()||(e.button??0)!==0)return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[data-wui-drawer-grip]`);n instanceof HTMLElement&&!t.closest(`button`)&&(this._drag={grip:n,id:e.pointerId,startY:e.clientY,lastY:e.clientY,lastT:e.timeStamp,velocity:0,moved:!1},n.setPointerCapture?.(e.pointerId),n.addEventListener(`pointermove`,this._onPointerMove),n.addEventListener(`pointerup`,this._onPointerUp),n.addEventListener(`pointercancel`,this._onPointerUp))}_viewport(){let e=this._document().defaultView;if(!e)throw TypeError(`wui-drawer has no window`);return e.innerHeight}_pointerMove(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let n=e.clientY-t.startY;if(!t.moved&&Math.abs(n)<h)return;t.moved=!0,this.classList.add(`is-dragging`);let r=e.timeStamp-t.lastT;r>0&&(t.velocity=(e.clientY-t.lastY)/r),t.lastY=e.clientY,t.lastT=e.timeStamp;let i=this._points(),a=(g(i,i.length-1)-g(i,this._snap))/100*this._viewport();t.offset=Math.max(n,-a),this.style.setProperty(`--wui-drawer-drag`,`${t.offset}px`)}_pointerUp(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let{moved:n,velocity:r,offset:i=0}=t;if(this._endDrag(),!n)return;let a=this._points(),o=this._viewport(),s=(g(a,this._snap)/100*o-i)/(o/100),c=this._dismissible(),l=f({points:a,index:this._snap,visible:s,velocity:r,canDismiss:c});l>=0?this._setSnap(l):this._requestClose(`drag`)}_endDrag(){let e=this._drag;e&&(this._drag=null,e.grip.releasePointerCapture?.(e.id),e.grip.removeEventListener(`pointermove`,this._onPointerMove),e.grip.removeEventListener(`pointerup`,this._onPointerUp),e.grip.removeEventListener(`pointercancel`,this._onPointerUp),this.classList.remove(`is-dragging`),this.style.removeProperty(`--wui-drawer-drag`))}};(0,t.defineElement)(`wui-drawer`,_),e.WuiDrawer=_})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.drawerText);
|
|
@@ -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.
|
|
1
|
+
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.174.0`)throw Error(`[webority-ui] dropdown expects ui-elements 0.174.0 but the page loaded `+o+`.`);var s=`[data-wui-dropdown-trigger]`,c=`[data-wui-dropdown-menu]`,l=`.dropdown-item`,u=`[data-wui-keep-open]`,d=2,f=150,p=class extends n.ElementBase{_unbindKeys;_rect;_pendingFocus;_pressOpen;_settling;_settleTimer;_endSettle;_onSettleScroll;_onClick;_onPointerDown;_onKeyDown;_onScroll;_onResize;_onClosed;static get observedAttributes(){return[`open`,`align`]}constructor(){super(),this._unbindKeys=null,this._rect=null,this._pendingFocus=!1,this._pressOpen=null,this._settling=!1,this._settleTimer=null,this._endSettle=()=>this._stopSettling(),this._onSettleScroll=()=>this._armQuiet(),this._onClick=e=>this._click(e),this._onPointerDown=e=>{e.target instanceof Element&&e.target.closest(s)&&(this._pressOpen=this.isOpen)},this._onKeyDown=e=>this._key(e),this._onScroll=()=>this._scrolled(),this._onResize=()=>{this._request(!1,`resize`)},this._onClosed=()=>this._dismissed()}connectedCallback(){this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown,{capture:!0}),this.addEventListener(`keydown`,this._onKeyDown),this._trigger()?.setAttribute(`aria-expanded`,String(this.isOpen)),this.isOpen&&this._sync()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown,{capture:!0}),this.removeEventListener(`keydown`,this._onKeyDown),this._stop();let e=this._menu();e&&(0,a.closeAnchoredPopover)(e)}attributeChangedCallback(e){e===`open`&&this.isConnected&&this._sync()}get isOpen(){return this.hasAttribute(`open`)}show(){this.isOpen||this._request(!0,`trigger`)}hide(){this.isOpen&&this._request(!1,`trigger`)}_request(e,t){let n=this.dispatchEvent(new CustomEvent(`wui-dropdown-toggle`,{bubbles:!0,cancelable:!0,detail:{open:e,source:t}}));return n&&this._apply(e),n}_apply(e){e?this.setAttribute(`open`,``):this.removeAttribute(`open`)}_dismissed(){if(!this.isConnected||!this.isOpen)return;let e=this._menu()?.contains(this.ownerDocument.activeElement)??!1;this.dispatchEvent(new CustomEvent(`wui-dropdown-toggle`,{bubbles:!0,detail:{open:!1,source:`dismiss`}})),this.removeAttribute(`open`),e&&this._trigger()?.focus()}_sync(){let{trigger:e,menu:t}=this._markup();this.isOpen?this._open(e,t):this._close(e,t)}_open(e,t){(0,a.isPopoverOpen)(t)||(this._pendingFocus&&this._startSettling(),(0,a.openAnchoredPopover)(this._anchor(e),t,{mode:`auto`,alignEnd:this.getAttribute(`align`)===`end`,onClosed:this._onClosed,scrollSettling:()=>this._settling}),e.setAttribute(`aria-expanded`,`true`),this._rect=this._anchor(e).getBoundingClientRect(),this._unbindKeys=(0,i.bindMenuKeys)(t,{items:()=>this._rows(t)}),window.addEventListener(`scroll`,this._onScroll,{capture:!0,passive:!0}),window.addEventListener(`resize`,this._onResize),this._pendingFocus&&(this._pendingFocus=!1,queueMicrotask(()=>{this.isOpen&&(0,a.isPopoverOpen)(t)&&this._rows(t)[0]?.focus()})))}_close(e,t){this._pendingFocus=!1,this._stop(),e.setAttribute(`aria-expanded`,`false`),(0,a.closeAnchoredPopover)(t)}_stop(){this._stopSettling(),this._unbindKeys?.(),this._unbindKeys=null,window.removeEventListener(`scroll`,this._onScroll,{capture:!0}),window.removeEventListener(`resize`,this._onResize)}_startSettling(){this._settling=!0,this.ownerDocument.addEventListener(`scroll`,this._onSettleScroll,{capture:!0,passive:!0}),this.ownerDocument.addEventListener(`scrollend`,this._endSettle,{capture:!0}),this._armQuiet()}_armQuiet(){this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=setTimeout(this._endSettle,f)}_stopSettling(){if(this._settling&&(this._settling=!1,this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=null,this.ownerDocument.removeEventListener(`scroll`,this._onSettleScroll,{capture:!0}),this.ownerDocument.removeEventListener(`scrollend`,this._endSettle,{capture:!0}),this.isConnected)){let{trigger:e}=this._markup();this._rect=this._anchor(e).getBoundingClientRect()}}_scrolled(){if(this._settling)return;let{trigger:e}=this._markup(),t=this._anchor(e).getBoundingClientRect(),n=this._rect;(!n||Math.abs(t.top-n.top)>d||Math.abs(t.left-n.left)>d)&&this._request(!1,`scroll`)}_click(e){let t=e.target;if(!(t instanceof Element))return;let n=this._pressOpen;this._pressOpen=null;let r=t.closest(s);if(r&&this.contains(r)){if((n??this.isOpen)&&!this.isOpen)return;this._request(!this.isOpen,`trigger`);return}let i=this._menu(),a=t.closest(l);if(!i||!a||!i.contains(a)||a.getAttribute(`aria-disabled`)===`true`)return;let o=a.closest(u);o&&i.contains(o)||this.isOpen&&this._request(!1,`select`)}_key(e){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=e.target;if(t instanceof Element&&this._trigger()?.contains(t)){if(this.isOpen){let t=this._menu(),n=t?this._rows(t):[],r=e.key===`ArrowDown`?n[0]:n[n.length-1];if(!r)return;e.preventDefault(),r.focus()}else e.key===`ArrowDown`&&(e.preventDefault(),this._pendingFocus=!0,this._request(!0,`trigger`))}}_trigger(){return this.querySelector(s)}_anchor(e){return(e.closest(`[data-wui-overflow-hidden]`)?.closest(`wui-overflow`))?.querySelector(`:scope > .wui-overflow-more`)??e}_menu(){return this.querySelector(c)}_rows(e){return Array.from(e.querySelectorAll(l)).filter(r.isDrawn)}_markup(){let e=this._trigger(),t=this._menu();if(!e||!t)throw RangeError(`<wui-dropdown> needs a [data-wui-dropdown-trigger] control and a [data-wui-dropdown-menu] panel.`);return{trigger:e,menu:t}}};(0,t.defineElement)(`wui-dropdown`,p),e.WuiDropdown=p})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.isDrawn,WeborityUiElementsInternal.modules.menuKeyNav,WeborityUiElementsInternal.modules.nativeOverlay);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.
|
|
1
|
+
(function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.174.0`)throw Error(`[webority-ui] entry-grid expects ui-elements 0.174.0 but the page loaded `+i+`.`);var a=`tbody > tr.wui-entry-grid-row[data-row-key]`,o=`input, select, textarea, button, [tabindex]:not([tabindex="-1"])`,s=class extends r.ElementBase{_onKeyDown;_onFocusIn;_onClick;_pendingCell=null;_ready=!1;_onPointerDown=e=>{if(e.button!==0)return;let t=this._ownRow(e.target),r=t?.dataset.rowKey;if(!t||r===void 0||r===this.getAttribute(`active-row`))return;let i=(0,n.closestOf)(e.target,`td`),a=i?Array.from(t.children).indexOf(i):-1;this._pendingCell=a>=0?a:null,this._emit(`active`,{rowKey:r})};_onPaste=e=>{let t=this._ownRow(e.target),r=t?.dataset.rowKey,i=(0,n.closestOf)(e.target,`td[data-column-key]`)?.getAttribute(`data-column-key`);if(!t||r===void 0||!i)return;let a=e.clipboardData?.getData(`text/plain`)??``;if(!/[\t\r\n]/.test(a))return;let o=a.replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`);o[o.length-1]===``&&o.pop(),e.preventDefault(),this._emit(`paste`,{rowKey:r,columnKey:i,rows:o.map(e=>e.split(` `))})};constructor(){super(),this._onKeyDown=e=>this._keyDown(e),this._onFocusIn=e=>this._focusIn(e),this._onClick=e=>{this._owns((0,n.closestOf)(e.target,`.wui-entry-grid-add`))&&this._emit(`add`,{});let t=(0,n.closestOf)(e.target,`thead th[data-sortable]`),r=t?.getAttribute(`data-column-key`);this._owns(t)&&r&&this._emit(`sort`,{columnKey:r})}}static get observedAttributes(){return[`active-row`]}connectedCallback(){this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`paste`,this._onPaste),this._ready=!0}disconnectedCallback(){this._ready=!1,this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`paste`,this._onPaste)}attributeChangedCallback(e,t,n){t!==n&&this._ready&&queueMicrotask(()=>this._focusActiveRow())}_owns(e){return(0,n.closestOf)(e,`wui-entry-grid`)===this}_rows(){return[...this.querySelectorAll(a)].filter(e=>e instanceof HTMLElement&&this._owns(e))}_ownRow(e){let t=(0,n.closestOf)(e,a);return t instanceof HTMLElement&&this._owns(t)?t:null}_emit(e,t){this.dispatchEvent(new CustomEvent(`wui-entry-grid:${e}`,{detail:t,bubbles:!0,composed:!0}))}_focusActiveRow(){let e=this.getAttribute(`active-row`),t=this._pendingCell;if(this._pendingCell=null,!this.isConnected||!e)return;let n=this._rows().find(t=>t.dataset.rowKey===e);n&&!n.contains(this.ownerDocument.activeElement)&&((t===null?void 0:n.children[t])?.querySelector(o)??n.querySelector(o))?.focus()}_keyDown(e){if(e.defaultPrevented||e.isComposing||e.keyCode===229)return;let t=(0,n.closestOf)(e.target,`thead th[data-sortable]`),r=t?.getAttribute(`data-column-key`);if(this._owns(t)&&r&&(e.key===`Enter`||e.key===` `)){e.preventDefault(),this._emit(`sort`,{columnKey:r});return}let i=this._ownRow(e.target),a=i?.dataset.rowKey;if(!i||a===void 0)return;let o=e.target instanceof Element?e.target:null,s=e.ctrlKey||e.metaKey;if(e.ctrlKey&&e.key===`Delete`||e.metaKey&&e.key===`Backspace`){if(!this.hasAttribute(`removable`))return;e.preventDefault(),this._emit(`remove`,{rowKey:a})}else if(e.key===`Enter`){if(s||e.shiftKey||e.altKey||o?.closest(`textarea, button`)||o?.getAttribute(`aria-expanded`)===`true`)return;e.preventDefault(),this._emit(`commit`,{rowKey:a,move:`next`})}else if(s&&e.key.toLowerCase()===`s`)e.preventDefault(),this._emit(`commit`,{rowKey:a,move:`stay`});else if(e.key===`Escape`){if(o?.getAttribute(`aria-expanded`)===`true`)return;e.preventDefault(),this._emit(`discard`,{rowKey:a})}else if(s&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault();let t=this._rows(),r=t[t.indexOf(i)+(e.key===`ArrowUp`?-1:1)]?.dataset.rowKey;if(r!==void 0){let t=(0,n.closestOf)(e.target,`td`),a=t?Array.from(i.children).indexOf(t):-1;this._pendingCell=a>=0?a:null,this._emit(`active`,{rowKey:r})}}}_focusIn(e){let t=this._ownRow(e.target),r=t?.dataset.rowKey;t&&r!==void 0&&(e.target instanceof HTMLInputElement&&(0,n.closestOf)(e.target,`td[data-kind="number"]`)&&e.target.select(),r!==this.getAttribute(`active-row`)&&this._emit(`active`,{rowKey:r}))}};(0,t.defineElement)(`wui-entry-grid`,s),e.WuiEntryGrid=s})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase);
|
|
@@ -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.173.1`)throw Error(`[webority-ui] gantt expects ui-elements 0.173.1 but the page loaded `+d+`.`);var f=864e5,p={groupBarH:6,milestone:14,tierH:28,spanDays:{day:28,week:84},arrow:5,elbow:8},m={table:{rowH:36,groupH:32,barH:20,barTop:8,groupBarTop:13,ppd:{day:22,week:7.3,month:4.9}},lanes:{rowH:40,groupH:52,barH:26,barTop:7,groupBarTop:36,ppd:{day:39,week:13.2,month:9}}},h=4,g=6,_=8,v=90,y=170,b=6.7,x=16,ee=16,te=6,S=3.5,ne=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],re=new Set([`day`,`week`,`month`]),ie=new Set([`table`,`lanes`]),ae=new Set([`done`,`inProgress`,`atRisk`,`notStarted`]),oe=/^(\d{4})-(\d{2})-(\d{2})$/,se=new Intl.DateTimeFormat(`en-CA`,{timeZone:`Asia/Kolkata`,year:`numeric`,month:`2-digit`,day:`2-digit`}),C=class extends Error{},w=e=>ne[e]??``,T=e=>String(e).padStart(2,`0`),E=e=>{let t=oe.exec(e);if(!t)return null;let[,n=``,r=``,i=``]=t,a=Number(n),o=Number(r)-1,s=Number(i),c=new Date(0);return c.setUTCFullYear(a,o,s),c.getUTCFullYear()===a&&c.getUTCMonth()===o&&c.getUTCDate()===s?c.getTime():null};function D(e){let t=E(e);if(t===null)throw new C(`"${e}" is not a calendar day.`);return t}function O(e){let t=new Date(e);return`${T(t.getUTCDate())}-${w(t.getUTCMonth())}-${t.getUTCFullYear()}`}function ce(e){let t=new Date(e);return`${String(t.getUTCFullYear()).padStart(4,`0`)}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())}`}function le(e=Date.now()){let t=se.formatToParts(e),n=e=>{let n=t.find(t=>t.type===e);if(!n)throw Error(`The Asia/Kolkata date has no ${e} part.`);return n.value};return`${n(`year`)}-${n(`month`)}-${n(`day`)}`}var k=(e,t)=>{let n=new Date(e);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1)};function A(e,t){return e===`day`?t-8*f:e===`week`?j(`week`,t-21*f):k(t,-1)}function j(e,t){return e===`day`?t:e===`week`?t-(new Date(t).getUTCDay()+6)%7*f:k(t,0)}function M(e,t,n){return e===`month`?k(t,h/2*n):t+p.spanDays[e]/2*n*f}var N=(e,t,n)=>{let r=[],i=e;for(;i<t;){let e=Math.min(n(i),t);r.push({start:i,end:e}),i=e}return r},ue=e=>e+f,de=e=>e+7*f,P=e=>k(e,1),fe=e=>Date.UTC(new Date(e).getUTCFullYear()+1,0,1);function F(e,t,n){let r=m[e].ppd[t],i=t===`month`?k(n,h):n+p.spanDays[t]*f,a=(i-n)/f,o=e=>(e-n)/f*r,s=e=>({x:o(e.start),w:(e.end-e.start)/f*r}),c=t===`month`?N(n,i,fe).map(e=>({...s(e),label:String(new Date(e.start).getUTCFullYear())})):N(n,i,P).map(e=>{let t=s(e),n=new Date(e.start),r=w(n.getUTCMonth());return{...t,label:t.w<v?r:`${r} ${n.getUTCFullYear()}`}}),l=[];if(t===`day`)for(let e of N(n,i,ue)){let t=new Date(e.start),n=t.getUTCDay();l.push({...s(e),label:String(t.getUTCDate()),sub:`MTWTFSS`.charAt((n+6)%7),weekend:n===0||n===6})}else if(t===`week`)for(let e of N(n,i,de))l.push({...s(e),label:T(new Date(e.start).getUTCDate())});else for(let e of N(n,i,P))l.push({...s(e),label:w(new Date(e.start).getUTCMonth())});return{startMs:n,endMs:i,days:a,width:a*r,ppd:r,x:o,top:c,bottom:l,gridX:l.map(e=>e.x),weekendX:l.filter(e=>e.weekend===!0).map(e=>e.x)}}var I=(e,t)=>new C(`Gantt row "${e}": ${t}.`),L=(e,t,n)=>{let r=E(n);if(r===null)throw I(e,`${t} "${n}" is not a calendar day`);return r};function pe(e){if(e.layout!==void 0&&!ie.has(e.layout))throw new C(`Gantt layout "${e.layout}" is not table or lanes.`);if(e.zoom!==void 0&&!re.has(e.zoom))throw new C(`Gantt zoom "${e.zoom}" is not day, week or month.`);let t=new Set;for(let n of e.rows){if(t.has(n.key))throw I(n.key,`key is used by more than one row`);if(t.add(n.key),n.name.trim()===``)throw I(n.key,`name is empty`);if(n.end!==void 0&&n.start===void 0)throw I(n.key,`end is set without a start`);if(n.start!==void 0){let e=L(n.key,`start`,n.start);if(n.end!==void 0&&L(n.key,`end`,n.end)<e)throw I(n.key,`end "${n.end}" is before start "${n.start}"`)}if(n.progress!==void 0&&!(Number.isInteger(n.progress)&&n.progress>=0&&n.progress<=100))throw I(n.key,`progress ${n.progress} is not a whole number from 0 to 100`);if(n.status!==void 0&&!ae.has(n.status))throw I(n.key,`status "${n.status}" is not a known status`)}let n=new Map;for(let t of e.rows)n.set(t.key,t);for(let t of e.rows)for(let e of t.dependsOn??[]){if(e===t.key)throw I(t.key,`depends on itself`);if(!n.has(e))throw I(t.key,`depends on "${e}", which is no row`)}let r=new Map,i=e=>(r.set(e,`onPath`),{key:e,deps:n.get(e)?.dependsOn??[],next:0});for(let t of e.rows){if(r.has(t.key))continue;let e=[i(t.key)];for(;e.length>0;){let t=e[e.length-1];if(!t)break;let n=t.deps[t.next];if(n===void 0){r.set(t.key,`done`),e.pop();continue}t.next++;let a=r.get(n);if(a===`onPath`)throw I(n,`dependencies form a loop`);a===void 0&&e.push(i(n))}}}function me(e,t,n){return b*(e.length+String(t).length+4)+x<=n?`inside`:`after`}function he(e,t){let{arrow:n,elbow:r}=p;return{d:t.l-e.r>=ee?`M${e.r} ${e.y} H${e.r+r} V${t.y} H${t.l-n}`:`M${e.r} ${e.y} H${e.r+te} V${(e.y+t.y)/2} H${t.l-r} V${t.y} H${t.l-n}`,head:`${t.l-n},${t.y-S} ${t.l},${t.y} ${t.l-n},${t.y+S}`}}var R=(e,t,n,r,i)=>({row:e,kind:t,index:n,top:r,height:i,x:0,w:0,clippedLeft:!1,clippedRight:!1,hidden:!0});function ge(e,t){let n=m[t.layout],r=F(t.layout,t.zoom,t.fromMs),{ppd:i,width:a}=r,o=new Set(e.folded??[]),s=e.rows.map((e,t)=>({row:e,index:t,startMs:e.start===void 0?void 0:D(e.start),endEx:e.end===void 0?void 0:D(e.end)+f})),c=new Map;for(let e of s){let t=e.row.group;if(t===void 0)continue;let n=c.get(t)??{name:t,count:0,sum:0,n:0,emitted:!1};if(c.set(t,n),n.count++,e.startMs!==void 0){let t=e.endEx??e.startMs+864e5;n.startMs=n.startMs===void 0?e.startMs:Math.min(n.startMs,e.startMs),n.endMs=n.endMs===void 0?t:Math.max(n.endMs,t)}e.endEx!==void 0&&(n.sum+=e.row.progress??0,n.n++)}let l=[],u=new Map,d=0;for(let e of s){let{row:s,index:f}=e,m=s.group===void 0?void 0:c.get(s.group);if(m!==void 0&&!m.emitted){m.emitted=!0;let e=o.has(m.name),t=m.startMs!==void 0&&m.endMs!==void 0,i=m.startMs??r.startMs,c=m.endMs??r.startMs,u=r.x(i),p=r.x(c),h=t&&p>0&&u<a;l.push({row:s,kind:`group`,index:f,top:d,height:n.groupH,x:h?Math.max(u,0):0,w:h?Math.min(p,a)-Math.max(u,0):0,clippedLeft:h&&u<0,clippedRight:h&&p>a,hidden:!1,group:{name:m.name,count:m.count,percent:m.n>0?Math.round(m.sum/m.n):0,folded:e,startMs:i,endMs:c}}),d+=n.groupH}let h=s.group!==void 0&&o.has(s.group),v=e.endEx===void 0?`milestone`:`bar`;if(h){l.push(R(s,v,f,d,0));continue}let b=d;if(d+=n.rowH,e.startMs===void 0){l.push(R(s,v,f,b,n.rowH));continue}let x;if(e.endEx===void 0){let o=r.x(e.startMs)+i/2;x=o<-8||o>a+_?R(s,v,f,b,n.rowH):{row:s,kind:v,index:f,top:b,height:n.rowH,x:o,w:p.milestone,clippedLeft:!1,clippedRight:!1,hidden:!1,flip:t.layout===`lanes`&&o>a-y}}else{let i=r.x(e.startMs),o=Math.max(r.x(e.endEx)-i,g);if(i>=a||i+o<=0)x=R(s,v,f,b,n.rowH);else{let e=Math.max(i,0),r=Math.min(i+o,a),c=i<0,l=i+o>a;r-e<g&&(c?r=Math.min(g,a):e=Math.max(0,r-g)),x={row:s,kind:v,index:f,top:b,height:n.rowH,x:e,w:r-e,clippedLeft:c,clippedRight:l,hidden:!1},t.layout===`lanes`&&(x.place=me(s.name,s.progress??0,r-e))}}l.push(x),x.hidden||u.set(s.key,x)}let h=[];for(let e of l){if(e.kind===`group`||e.hidden)continue;let t=e.kind===`milestone`?e.x-_:e.x,r=new Set;for(let i of e.row.dependsOn??[]){let a=u.get(i);if(a===void 0||r.has(i))continue;r.add(i);let o=he({r:a.kind===`milestone`?a.x+_:a.x+a.w,y:a.top+n.rowH/2},{l:t,y:e.top+n.rowH/2});h.push({fromKey:i,toKey:e.row.key,d:o.d,head:o.head})}}return{layout:t.layout,geometry:n,axis:r,rows:l,height:d,today:{x:r.x(t.todayMs)+i/2,inWindow:t.todayMs>=r.startMs&&t.todayMs<r.endMs},arrows:h}}var _e=new Set([`pvt`,`private`,`ltd`,`limited`,`llp`,`llc`,`inc`,`corp`,`co`]),z=/\p{L}/u,ve=/\p{N}/u;function ye(e){let t=``,n=0;for(let r of e)r===`(`?(n+=1,t+=` `):r===`)`?(n=Math.max(0,n-1),t+=` `):n===0&&(t+=r);return t}function B(e,t,n){let r=e[t];if(r===void 0)throw Error(`initialsOf: the ${n} is missing`);return r}function V(e){return e.map(e=>{let t=e.toUpperCase();return Array.from(t).length===1?t:e}).join(``)}function be(e,t=2){let n=ye(String(e??``)).split(/\s+/),r=e=>n.map(t=>Array.from(t).filter(t=>e.test(t))).filter(e=>e.length>0),i=r(z).filter(e=>!_e.has(e.join(``).toLowerCase()));if(i.length===0&&!n.some(e=>z.test(e))&&(i=r(ve)),i.length===0)return``;let a=B(i,0,`first word`);if(i.length===1)return V(a.slice(0,t));let o=B(i,1,`second word`);return V([B(a,0,`first letter`),B(o,0,`second letter`)])}var xe=`data-wui-gantt-pick`,H=e=>`${e}px`,U=(e,t,n)=>{let r=(0,i.make)(`div`,{class:`wui-gantt-table-cell`},n);return r.setAttribute(`role`,t),r.dataset.col=e,r};function Se(e){let t=e.text,n=(0,i.make)(`div`,{class:`wui-gantt-table`});n.setAttribute(`role`,`table`),n.setAttribute(`aria-label`,e.title);let r=(0,i.make)(`div`);r.setAttribute(`role`,`rowgroup`);let a=(0,i.make)(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`head`,a.setAttribute(`role`,`row`),a.style.height=H(e.headHeight),a.append(U(`name`,`columnheader`,t.tableName),U(`owner`,`columnheader`,t.detailsOwner),U(`start`,`columnheader`,t.tableStart),U(`end`,`columnheader`,t.tableEnd),U(`done`,`columnheader`,t.detailsDone)),r.append(a);let l=(0,i.make)(`div`);l.setAttribute(`role`,`rowgroup`);for(let n of e.rows){if(n.height===0)continue;let r=n.row;if(n.kind===`group`){let r=n.group;if(!r)continue;let a=(0,i.make)(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`group`,a.dataset.wuiGanttGroup=r.name,a.setAttribute(`role`,`row`),a.style.height=H(n.height);let o=(0,i.make)(`div`,{class:`wui-gantt-table-cell wui-gantt-table-group`});o.setAttribute(`role`,`rowheader`);let u=(0,i.make)(`button`,{class:`wui-gantt-group-toggle`});u.type=`button`,u.setAttribute(`aria-expanded`,String(!r.folded)),u.setAttribute(`aria-label`,(0,c.fillText)(r.folded?t.unfoldLabel:t.foldLabel,{group:r.name})),u.setAttribute(e.focusAttr,`group:${r.name}`);let d=(0,s.glyphNode)(r.folded?`chevron-right`:`chevron-down`,{size:16});u.replaceChildren(...d?[d]:[]),o.append(u,(0,i.make)(`span`,null,r.name),(0,i.make)(`span`,null,(0,c.pluralText)(t,`groupSummary`,r.count,{percent:r.percent}))),a.append(o),l.append(a);continue}let a=(0,i.make)(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=r.end===void 0?`milestone`:`bar`,a.dataset.wuiGanttKey=r.key,a.dataset.wuiGanttPick=r.key,r.key===e.selected&&(a.dataset.selected=`true`),a.setAttribute(`role`,`row`),a.style.height=H(n.height);let u=U(`name`,`rowheader`,r.name);u.title=r.name;let d=U(`owner`,`cell`,``);r.owner&&(d.title=r.owner,d.replaceChildren(...[(0,o.avatarNode)({initials:be(r.owner)},`avatar-xs`)].filter(e=>e!==null)),d.append((0,i.make)(`span`,{class:`visually-hidden`},r.owner)));let f=U(`start`,`cell`,r.start===void 0?``:O(D(r.start))),p=U(`end`,`cell`,r.end===void 0?``:O(D(r.end))),m=U(`done`,`cell`,r.end===void 0?``:`${r.progress??0}%`);a.append(u,d,f,p,m),l.append(a)}let u=e.skeleton;for(let e=0;u&&e<u.rows;e+=1){let e=(0,i.make)(`div`,{class:`wui-gantt-table-row`});e.dataset.kind=`skeleton`,e.setAttribute(`role`,`row`),e.setAttribute(`aria-hidden`,`true`),e.style.height=H(u.rowHeight);let t=(0,i.make)(`span`,{class:`wui-gantt-skeleton`});t.style.height=H(u.barHeight),e.append(t),l.append(e)}return n.append(r,l),n}var Ce={addTaskLabel:`Add task`,barLabel:`{name}, {start} to {end}, {percent} percent, {status}`,barLabelAfter:`{label}, after {names}`,dayLabel:`Day`,detailsCloseLabel:`Close details`,detailsDates:`Dates`,detailsDone:`Done`,detailsOwner:`Owner`,detailsRange:`{start} to {end}`,detailsStartsAfter:`Starts after`,earlierLabel:`Earlier`,emptyText:`Add a task with a start and an end date and it is drawn here as a bar.`,emptyTitle:`No tasks on the plan yet`,errorText:`The plan did not load. Check your connection and try again.`,foldLabel:`Fold {group}`,groupSummaryOne:`{count} item, {percent}% done`,groupSummaryOther:`{count} items, {percent}% done`,helpText:`Use the Up and Down arrow keys to move between bars and the Left and Right keys to move along a row. Press Enter to open the details and Escape to close them.`,helpTextTable:`Use the Up and Down arrow keys to move between bars and the Left and Right keys to follow a dependency. Press Enter to choose a row and Escape to clear the choice.`,laterLabel:`Later`,legendLabel:`Key`,legendRemaining:`Lighter part of a bar is work still to do`,loadingText:`Loading plan`,milestoneBarLabel:`{name}, {date}, milestone, after {names}`,milestoneLabel:`Milestone`,monthLabel:`Month`,retryLabel:`Try again`,scaleLabel:`Time scale`,statusAtRisk:`At risk`,statusDone:`Done`,statusInProgress:`In progress`,statusNotStarted:`Not started`,summaryMilestonesOne:`{count} milestone`,summaryMilestonesOther:`{count} milestones`,summaryRange:`{from} to {to}`,summaryTasksOne:`{count} task`,summaryTasksOther:`{count} tasks`,tableEnd:`End`,tableName:`Task`,tableStart:`Start`,tableStatus:`Status`,todayLabel:`Today`,unfoldLabel:`Unfold {group}`,weekLabel:`Week`},W=()=>(0,c.readText)(`gantt`,Ce),we=`wui-gantt:zoom-change`,Te=`wui-gantt:from-change`,Ee=`wui-gantt:fold-change`,De=`wui-gantt:select`,Oe=`wui-gantt:add-task`,ke=`wui-gantt:retry`,G=`data-wui-gantt-focus`,K=`bar:`,q=`http://www.w3.org/2000/svg`,Ae=[`day`,`week`,`month`],J=3,je=16,Me=300,Ne=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`Escape`,`Enter`,` `],Pe=0,Y=e=>`${e}px`;function Fe(e){return typeof e==`object`&&!!e&&`rows`in e&&Array.isArray(e.rows)&&`title`in e&&typeof e.title==`string`}function X(e){let t=W();switch(e){case`done`:return t.statusDone;case`inProgress`:return t.statusInProgress;case`atRisk`:return t.statusAtRisk;case`notStarted`:return t.statusNotStarted;default:throw RangeError(`Unknown gantt status ${String(e)}.`)}}var Z=e=>e.progress??0,Q=e=>e.status??`notStarted`,Ie=(e,t)=>(e??[]).join(`\0`)===(t??[]).join(`\0`),$=class extends a.ElementBase{uid;_spec=null;_prev=null;_zoom=`week`;_fromMs=null;_folded=new Set;_selected=null;_controlled=!1;_awaitingSpec=!1;_connected=!1;_focusAfter=null;_resolved=null;_specRows=[];_card=null;_onClick;_onKeyDown;_onChange;constructor(){super(),Pe+=1,this.uid=`wui-gantt-${Pe}`,this._onClick=e=>this._handleClick(e),this._onKeyDown=e=>this._handleKeyDown(e),this._onChange=e=>this._handleChange(e)}get spec(){return this._spec}set spec(e){this._spec=e??null,this._connected&&this._draw()}connectedCallback(){if(Object.hasOwn(this,`spec`)){let e=this.spec;delete this.spec,this._spec=e??null}this._spec??=this._readScript(),this._spec==null&&!this.querySelector(`:scope > script[type='application/json']`)&&(this._awaitingSpec=!0,queueMicrotask(()=>{this._awaitingSpec=!1,this._connected&&this._draw()})),this.classList.add(`wui-gantt`),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`change`,this._onChange),this._connected=!0,this._draw()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`change`,this._onChange),this._card&&=((0,l.closeAnchoredPopover)(this._card),this._card.remove(),null),this._connected=!1}_readScript(){let e=this.querySelector(`:scope > script[type="application/json"]`);if(!(e instanceof HTMLScriptElement))return null;try{return JSON.parse(String(e.textContent))}catch(e){return(0,r.devError)(`[@webority/ui-elements] <wui-gantt> could not read its JSON spec:`,e instanceof Error?e.message:void 0),null}}_seed(e){let t=this._prev;this._controlled=e.controlled===!0;let n=e=>this._controlled||t===null||e;n(t?.zoom!==e.zoom)&&(this._zoom=e.zoom??`week`),n(t?.from!==e.from)&&(this._fromMs=e.from?D(e.from):null),n(!Ie(t?.folded,e.folded))&&(this._folded=new Set(e.folded??[])),n(t?.selected!==e.selected)&&(this._selected=e.selected??null),this._prev=e}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_setZoom(e){this._emit(we,{zoom:e}),this._controlled?this._syncRadios():(this._zoom=e,this._fromMs=this._fromMs===null?null:j(e,this._fromMs),this._draw())}_setFrom(e){this._emit(Te,{from:ce(e)}),this._controlled||(this._fromMs=e,this._draw())}_setFolded(e){let t=new Set(this._folded);t.delete(e)||t.add(e),this._emit(Ee,{folded:[...t]}),this._controlled||(this._folded=t,this._draw())}_setSelected(e){this._emit(De,{key:e}),this._focusAfter=`${K}${e??this._selected??``}`,this._controlled||(this._selected=e),this._draw()}_syncRadios(){for(let e of this.querySelectorAll(`.segmented-input`))e.checked=e.value===this._zoom}_handleChange(e){let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-gantt-scale .segmented-input`))return;let n=Ae.find(e=>e===t.value);n&&this._setZoom(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[${G}]`);if(n instanceof HTMLElement&&this.contains(n)){this._activate(n.getAttribute(G)??``,n);return}let r=t.closest(`[${xe}]`);if(!(r instanceof HTMLElement)||!this.contains(r))return;let i=r.getAttribute(`data-wui-gantt-pick`)??``;this._setSelected(i===this._selected?null:i)}_activate(e,t){let n=this._resolved;if(e.startsWith(K)){let t=e.slice(4);this._setSelected(t===this._selected?null:t)}else e.startsWith(`group:`)?this._setFolded(e.slice(6)):e===`close`?this._setSelected(null):e===`add`?this._emit(Oe):e===`retry`?this._emit(ke):n&&e===`nav:earlier`?this._setFrom(M(n.zoom,n.fromMs,-1)):n&&e===`nav:later`?this._setFrom(M(n.zoom,n.fromMs,1)):n&&e===`nav:today`?this._setFrom(A(n.zoom,n.todayMs)):e.startsWith(`zoom:`)&&t.click()}_bars(){return[...this.querySelectorAll(`.wui-gantt-lane [${G}^="${K}"]`)].filter(e=>e instanceof HTMLElement)}_focusBar(e){if(e){for(let t of this._bars())t.tabIndex=t===e?0:-1;e.focus()}}_barByKey(e){return e===void 0?void 0:this._bars().find(t=>t.dataset.wuiGanttKey===e)}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey||!Ne.includes(e.key))return;if(e.key===`Escape`){if(this._selected===null)return;e.preventDefault(),this._setSelected(null);return}let t=e.target;if(!(t instanceof HTMLElement)||!t.getAttribute(G)?.startsWith(K))return;let n=this._bars(),r=n.indexOf(t),i=t.dataset.wuiGanttKey,a=this._specRows.find(e=>e.key===i);switch(e.preventDefault(),(0,u.mirrorKey)(e.key,(0,u.isRtl)(this))){case`ArrowDown`:this._focusBar(n[r+1]);break;case`ArrowUp`:this._focusBar(n[r-1]);break;case`Home`:this._focusBar(n[0]);break;case`End`:this._focusBar(n.at(-1));break;case`ArrowLeft`:this._focusBar((a?.dependsOn??[]).map(e=>this._barByKey(e)).find(e=>e));break;case`ArrowRight`:this._focusBar(this._specRows.filter(e=>e.dependsOn?.includes(i??``)).map(e=>this._barByKey(e.key)).find(e=>e));break;default:this._activate(t.getAttribute(G)??``,t)}}_focusToken(){let e=document.activeElement;return e instanceof HTMLElement&&this.contains(e)?e.getAttribute(G):null}_draw(){if(this._card&&=((0,l.closeAnchoredPopover)(this._card),this._card.remove(),null),this._spec==null&&this._awaitingSpec)return;let e=this._focusAfter??this._focusToken();this._focusAfter=null;let t;try{t=this._compose()}catch(e){(0,r.devError)(`[@webority/ui-elements] <wui-gantt> could not draw its spec:`,e instanceof Error?e.message:void 0),this._resolved=null,this._specRows=[],this._card=null,this.dataset.state=`error`,this.removeAttribute(`aria-busy`),t=[this._stateBlock(`error`,W().errorText)]}if(this.replaceChildren(...t),this._card){let e=(0,i.must)(this._barByKey(this._selected??void 0),`selected gantt bar`);this.append(this._card),(0,l.openAnchoredPopover)(e,this._card,{mode:`manual`,side:`auto`,align:`start`,flipAlign:!0,gap:4,keepOffscreen:!0})}if(this._placeThumb(),e===null)return;let n=[...this.querySelectorAll(`[${G}]`)].find(t=>t.getAttribute(G)===e);n instanceof HTMLElement&&(e.startsWith(K)?this._focusBar(n):n.focus())}_compose(){let e=this._spec;if(!Fe(e))throw TypeError("<wui-gantt> has no spec: set the `spec` property or add a JSON script child.");this._seed(e),pe(e);let t=e.layout??`table`,n=m[t],r=W(),a=D(e.today??le()),o=this._zoom,s=j(o,this._fromMs??A(o,a)),c={layout:t,zoom:o,fromMs:s,todayMs:a};this._resolved=c,this._specRows=e.rows;let l=e.rows.some(e=>e.start!==void 0),u=(e.state??`ready`)===`ready`&&!l?`empty`:e.state??`ready`;this.dataset.state=u,this.dataset.zoom=o,this.dataset.layout=t,u===`loading`?this.setAttribute(`aria-busy`,`true`):this.removeAttribute(`aria-busy`);let d=u===`ready`?ge({...e,folded:[...this._folded],selected:this._selected},c):null,f=d?.axis??F(t,o,s),h=(0,i.make)(`div`,{class:`wui-gantt-lane`});h.style.width=Y(f.width),d?this._fillLane(h,e,d):u===`loading`&&(h.style.height=Y(J*n.rowH));let g=[];u===`loading`&&g.push(this._fillSkeleton(h,e,n)),u===`empty`&&g.push(this._emptyBlock(e)),u===`error`&&g.push(this._stateBlock(`error`,e.errorText||r.errorText));let _=this._head(f),v=(0,i.make)(`div`,{class:`wui-gantt-plot`});v.append(_,h);let y=(0,i.make)(`div`,{class:`wui-gantt-scroller`});if(t===`table`){let t=Se({title:e.title,rows:d?.rows??[],headHeight:2*p.tierH,selected:this._selected,text:r,focusAttr:G,skeleton:u===`loading`?{rows:J,rowHeight:n.rowH,barHeight:n.barH}:void 0});y.append(t,v)}else y.append(v);return[this._toolbar(e,u===`ready`),y,...g,this._legend(t)]}_toolbar(e,t){let n=(0,i.make)(`div`,{class:`wui-gantt-toolbar`});return t&&n.append((0,i.make)(`p`,{class:`wui-gantt-count`},this._countText(e.rows))),n.append(this._scale(),this._nav()),n}_countText(e){let t=W(),n=e.filter(e=>e.start!==void 0),r=n.filter(e=>e.end===void 0).length,i=1/0,a=-1/0;for(let e of n)i=Math.min(i,D(e.start??``)),a=Math.max(a,D(e.end??e.start??``));return[(0,c.pluralText)(t,`summaryTasks`,n.length-r),(0,c.pluralText)(t,`summaryMilestones`,r),(0,c.fillText)(t.summaryRange,{from:O(i),to:O(a)})].join(`, `)}_scale(){let e=W(),t=(0,i.make)(`div`,{class:`segmented segmented-sm wui-gantt-scale`});t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,e.scaleLabel),t.append(Object.assign((0,i.make)(`span`,{class:`segmented-thumb`}),{ariaHidden:`true`}));let n={day:e.dayLabel,week:e.weekLabel,month:e.monthLabel};for(let e of Ae){let r=(0,i.make)(`label`,{class:`segmented-option`}),a=(0,i.make)(`input`,{class:`segmented-input`});a.type=`radio`,a.name=`${this.uid}-scale`,a.value=e,a.checked=e===this._zoom,a.setAttribute(G,`zoom:${e}`),r.append(a,n[e]),t.append(r)}return t}_placeThumb(){let e=this.querySelector(`.wui-gantt-scale`),t=e?.querySelector(`.segmented-thumb`),n=e?.querySelector(`.segmented-option:has(.segmented-input:checked)`);e instanceof HTMLElement&&t instanceof HTMLElement&&n instanceof HTMLElement&&e.offsetWidth&&(t.style.width=Y(n.offsetWidth),t.style.transform=`translateX(${n.offsetLeft}px)`,t.style.opacity=`1`)}_nav(){let e=W(),t=(0,i.make)(`div`,{class:`wui-gantt-nav`}),r=(e,t,r)=>{let a=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`soft`,`sm`)});a.type=`button`,a.setAttribute(`aria-label`,t),a.setAttribute(G,e);let o=(0,s.glyphNode)(r,{size:16});return a.replaceChildren(...o?[o]:[]),a},a=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`soft`,`sm`)},e.todayLabel);return a.type=`button`,a.setAttribute(G,`nav:today`),t.append(r(`nav:earlier`,e.earlierLabel,`chevron-left`),r(`nav:later`,e.laterLabel,`chevron-right`),a),t}_head(e){let t=(0,i.make)(`div`,{class:`wui-gantt-head`});t.style.width=Y(e.width),t.setAttribute(`aria-hidden`,`true`);let n=(e,t)=>{let n=(0,i.make)(`div`,{class:`wui-gantt-tier ${t}`});for(let t of e){let e=(0,i.make)(`div`,{class:t.weekend?`wui-gantt-cell wui-gantt-cell-weekend`:`wui-gantt-cell`});e.style.left=Y(t.x),e.style.width=Y(t.w),t.sub&&e.append((0,i.make)(`small`,null,t.sub)),e.append(t.label),n.append(e)}return n};return t.append(n(e.top,`wui-gantt-tier-top`),n(e.bottom,`wui-gantt-tier-bottom`)),t}_legend(e){let t=W(),n=(0,i.make)(`div`,{class:`wui-gantt-legend`});n.setAttribute(`role`,`list`),n.setAttribute(`aria-label`,t.legendLabel);let r=(e,t)=>{let r=(0,i.make)(`span`,null);r.setAttribute(`role`,`listitem`),r.append(e,t),n.append(r)};for(let e of[`done`,`inProgress`,`atRisk`,`notStarted`]){let t=(0,i.make)(`span`,{class:`wui-gantt-swatch`});t.dataset.status=e,r(t,X(e))}let a=(0,i.make)(`span`,{class:`wui-gantt-swatch`});if(a.dataset.kind=`milestone`,r(a,t.milestoneLabel),e===`table`){let e=(0,i.make)(`span`,{class:`wui-gantt-legend-note`},t.legendRemaining);e.setAttribute(`role`,`listitem`),n.append(e)}return n}_stateBlock(e,t){let r=W(),a=(0,i.make)(`div`,{class:`wui-gantt-state`});if(e===`error`){a.setAttribute(`role`,`alert`),a.append((0,i.make)(`p`,null,t));let e=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`soft`,`sm`)},r.retryLabel);e.type=`button`,e.setAttribute(G,`retry`),a.append(e)}else a.append((0,i.make)(`p`,null,t));return a}_emptyBlock(e){let t=W(),r=(0,i.make)(`div`,{class:`wui-gantt-state`});if(r.append((0,i.make)(`p`,{class:`fw-semibold`},t.emptyTitle),(0,i.make)(`p`,null,e.emptyText||t.emptyText)),e.addTask){let e=(0,i.make)(`button`,{class:(0,n.buttonClass)(`primary`,`solid`,`sm`)},t.addTaskLabel);e.type=`button`,e.setAttribute(G,`add`),r.append(e)}return r}_fillSkeleton(e,t,n){let r=(0,i.make)(`div`,{class:`visually-hidden`},t.loadingText||W().loadingText);r.setAttribute(`role`,`status`);for(let t=0;t<J;t+=1){let r=(0,i.make)(`div`,{class:`wui-gantt-skeleton`});r.style.top=Y(t*n.rowH+n.barTop),r.style.left=Y(40+t*60),r.style.width=Y(240),r.style.height=Y(n.barH),r.setAttribute(`aria-hidden`,`true`),e.append(r)}return r}_fillLane(e,t,n){let r=W(),{axis:a}=n,o=n.layout===`table`;e.style.height=Y(n.height),e.setAttribute(`role`,`list`),e.setAttribute(`aria-label`,t.title);let s=(0,i.make)(`p`,{class:`visually-hidden`},o?r.helpTextTable:r.helpText);s.id=`${this.uid}-help`,e.setAttribute(`aria-describedby`,s.id);let c=(e,t,n,r,a)=>{let o=(0,i.make)(`div`,{class:e});return o.setAttribute(`aria-hidden`,`true`),o.style.left=Y(t),o.style.top=Y(n),o.style.width=Y(r),o.style.height=Y(a),o},l=[s];for(let e of n.rows){if(e.height===0)continue;let t=c(`wui-gantt-row`,0,e.top,a.width,e.height);o&&e.kind!==`group`&&e.row.key===this._selected&&(t.dataset.selected=`true`),l.push(t)}for(let e of a.weekendX)l.push(c(`wui-gantt-weekend`,e,0,a.ppd,n.height));for(let e of a.gridX)l.push(c(`wui-gantt-grid`,e,0,1,n.height));if(n.today.inWindow){l.push(c(`wui-gantt-today`,n.today.x-1,0,2,n.height));let e=(0,i.make)(`div`,{class:`wui-gantt-today-flag rounded-pill`},r.todayLabel);e.style.left=Y(n.today.x),l.push(e)}let u=new Map(t.rows.map(e=>[e.key,e]));for(let e of n.rows){if(e.hidden)continue;let t=(0,i.make)(`div`,{class:`wui-gantt-item`});t.setAttribute(`role`,`listitem`),t.style.display=`contents`,e.kind===`group`?this._drawGroup(t,e,n):e.kind===`milestone`?this._drawMilestone(t,e,u,n):this._drawBar(t,e,u,n),l.push(t)}l.push(this._deps(n)),this._card=o?null:this._details(n,u),e.append(...l);let d=e.querySelector(`[${G}^="${K}"]`);d instanceof HTMLElement&&(d.tabIndex=0)}_names(e,t){return(e.dependsOn??[]).map(e=>t.get(e)?.name??e).join(`, `)}_barSentence(e,t){let n=W(),r=this._names(e,t);if(e.end===void 0){let t=O(D(e.start??``));return r?(0,c.fillText)(n.milestoneBarLabel,{name:e.name,date:t,names:r}):`${e.name}, ${t}, ${n.milestoneLabel.toLowerCase()}`}let i=(0,c.fillText)(n.barLabel,{name:e.name,start:O(D(e.start??``)),end:O(D(e.end)),percent:Z(e),status:X(Q(e)).toLowerCase()});return r?(0,c.fillText)(n.barLabelAfter,{label:i,names:r}):i}_focusable(e,t,n,r){let a=(0,i.make)(`button`,{class:t});a.type=`button`;let o=this._barSentence(e,n);return a.setAttribute(`aria-label`,o),a.title=o,a.tabIndex=-1,a.dataset.status=Q(e),a.dataset.wuiGanttKey=e.key,a.setAttribute(G,`${K}${e.key}`),r?a.setAttribute(`aria-pressed`,String(this._selected===e.key)):a.setAttribute(`aria-expanded`,String(this._selected===e.key)),this._selected===e.key&&(a.dataset.selected=`true`),a}_afterLabel(e,t,n,r){let a=(0,i.make)(`span`,{class:`wui-gantt-label wui-gantt-label-surface`},e);return a.style.left=Y(t),a.style.top=Y(n),a.style.height=Y(r),a}_drawBar(e,t,n,r){let{row:a}=t,{geometry:o}=r,s=r.layout===`table`,c=this._focusable(a,`wui-gantt-bar rounded-2`,n,s),l=t.top+o.barTop;c.style.left=Y(t.x),c.style.width=Y(t.w),c.style.top=Y(l),c.style.height=Y(o.barH);let u=Z(a),d=(0,i.make)(`span`,{class:`wui-gantt-bar-progress`});if(d.style.width=`${u}%`,c.append(d),e.append(c),s)return;let f=`${a.name} ${u}%`;t.place===`inside`?c.append((0,i.make)(`span`,{class:`wui-gantt-bar-label`},f)):e.append(this._afterLabel(f,t.x+t.w+je,l,o.barH))}_drawMilestone(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=p.milestone/2,c=t.top+(a.rowH-p.milestone)/2,l=this._focusable(i,`wui-gantt-milestone`,n,o);if(l.style.left=Y(t.x-s),l.style.top=Y(c),l.style.width=Y(p.milestone),l.style.height=Y(p.milestone),e.append(l),o)return;let u=this._afterLabel(`${i.name}, ${O(D(i.start??``))}`,t.x+p.milestone,t.top+a.barTop,a.barH);t.flip&&(u.style.left=``,u.style.right=Y(r.axis.width-(t.x-p.milestone))),e.append(u)}_drawGroup(e,t,n){let r=W(),a=t.group;if(!a)return;if(n.layout===`lanes`){let n=(0,i.make)(`div`,{class:`wui-gantt-group wui-gantt-label wui-gantt-label-surface`});n.dataset.wuiGanttGroup=a.name,n.style.left=Y(8),n.style.top=Y(t.top+6);let o=(0,i.make)(`button`,{class:`wui-gantt-group-toggle`});o.type=`button`,o.setAttribute(`aria-expanded`,String(!a.folded)),o.setAttribute(`aria-label`,(0,c.fillText)(a.folded?r.unfoldLabel:r.foldLabel,{group:a.name})),o.setAttribute(G,`group:${a.name}`);let l=(0,s.glyphNode)(a.folded?`chevron-right`:`chevron-down`,{size:16});o.replaceChildren(...l?[l]:[]),n.append(o,(0,i.make)(`span`,null,a.name),(0,i.make)(`span`,null,(0,c.pluralText)(r,`groupSummary`,a.count,{percent:a.percent}))),e.append(n)}let o=(0,i.make)(`div`,{class:`wui-gantt-group-summary`});o.dataset.wuiGanttGroup=a.name,o.style.left=Y(t.x),o.style.width=Y(t.w),o.style.top=Y(t.top+n.geometry.groupBarTop),o.style.height=Y(p.groupBarH),e.append(o)}_deps(e){let t=document.createElementNS(q,`svg`);t.setAttribute(`class`,`wui-gantt-deps`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`width`,String(e.axis.width)),t.setAttribute(`height`,String(e.height));for(let n of e.arrows){let e=document.createElementNS(q,`path`);e.setAttribute(`d`,n.d),e.setAttribute(`fill`,`none`);let r=document.createElementNS(q,`polygon`);r.setAttribute(`points`,n.head),e.dataset.from=n.fromKey,e.dataset.to=n.toKey,t.append(e,r)}return t}_details(e,t){let r=this._selected,a=r===null?void 0:e.rows.find(e=>e.row.key===r&&e.kind!==`group`&&!e.hidden);if(!a)return null;let o=W(),{row:s}=a,l=(0,i.make)(`div`,{class:`wui-gantt-details`});l.setAttribute(`role`,`group`),l.setAttribute(`aria-label`,s.name),l.style.width=Y(Me);let u=(0,i.make)(`dl`),d=(e,t)=>{u.append((0,i.make)(`dt`,null,e),(0,i.make)(`dd`,null,t))},f=O(D(s.start??``));s.owner&&d(o.detailsOwner,s.owner),d(o.detailsDates,s.end===void 0?f:(0,c.fillText)(o.detailsRange,{start:f,end:O(D(s.end))})),s.end!==void 0&&d(o.detailsDone,`${Z(s)}%, ${X(Q(s))}`);let p=this._names(s,t);p&&d(o.detailsStartsAfter,p);let m=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`ghost`,`sm`)},o.detailsCloseLabel);return m.type=`button`,m.setAttribute(G,`close`),l.append((0,i.make)(`h3`,{class:`h6`},s.name),u,m),l}};(0,t.defineElement)(`wui-gantt`,$),e.WuiGantt=$})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.avatarNode,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl);
|
|
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.174.0`)throw Error(`[webority-ui] gantt expects ui-elements 0.174.0 but the page loaded `+d+`.`);var f=864e5,p={groupBarH:6,milestone:14,tierH:28,spanDays:{day:28,week:84},arrow:5,elbow:8},m={table:{rowH:36,groupH:32,barH:20,barTop:8,groupBarTop:13,ppd:{day:22,week:7.3,month:4.9}},lanes:{rowH:40,groupH:52,barH:26,barTop:7,groupBarTop:36,ppd:{day:39,week:13.2,month:9}}},h=4,g=6,_=8,v=90,y=170,b=6.7,x=16,ee=16,te=6,S=3.5,ne=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],re=new Set([`day`,`week`,`month`]),ie=new Set([`table`,`lanes`]),ae=new Set([`done`,`inProgress`,`atRisk`,`notStarted`]),oe=/^(\d{4})-(\d{2})-(\d{2})$/,se=new Intl.DateTimeFormat(`en-CA`,{timeZone:`Asia/Kolkata`,year:`numeric`,month:`2-digit`,day:`2-digit`}),C=class extends Error{},w=e=>ne[e]??``,T=e=>String(e).padStart(2,`0`),E=e=>{let t=oe.exec(e);if(!t)return null;let[,n=``,r=``,i=``]=t,a=Number(n),o=Number(r)-1,s=Number(i),c=new Date(0);return c.setUTCFullYear(a,o,s),c.getUTCFullYear()===a&&c.getUTCMonth()===o&&c.getUTCDate()===s?c.getTime():null};function D(e){let t=E(e);if(t===null)throw new C(`"${e}" is not a calendar day.`);return t}function O(e){let t=new Date(e);return`${T(t.getUTCDate())}-${w(t.getUTCMonth())}-${t.getUTCFullYear()}`}function ce(e){let t=new Date(e);return`${String(t.getUTCFullYear()).padStart(4,`0`)}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())}`}function le(e=Date.now()){let t=se.formatToParts(e),n=e=>{let n=t.find(t=>t.type===e);if(!n)throw Error(`The Asia/Kolkata date has no ${e} part.`);return n.value};return`${n(`year`)}-${n(`month`)}-${n(`day`)}`}var k=(e,t)=>{let n=new Date(e);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1)};function A(e,t){return e===`day`?t-8*f:e===`week`?j(`week`,t-21*f):k(t,-1)}function j(e,t){return e===`day`?t:e===`week`?t-(new Date(t).getUTCDay()+6)%7*f:k(t,0)}function M(e,t,n){return e===`month`?k(t,h/2*n):t+p.spanDays[e]/2*n*f}var N=(e,t,n)=>{let r=[],i=e;for(;i<t;){let e=Math.min(n(i),t);r.push({start:i,end:e}),i=e}return r},ue=e=>e+f,de=e=>e+7*f,P=e=>k(e,1),fe=e=>Date.UTC(new Date(e).getUTCFullYear()+1,0,1);function F(e,t,n){let r=m[e].ppd[t],i=t===`month`?k(n,h):n+p.spanDays[t]*f,a=(i-n)/f,o=e=>(e-n)/f*r,s=e=>({x:o(e.start),w:(e.end-e.start)/f*r}),c=t===`month`?N(n,i,fe).map(e=>({...s(e),label:String(new Date(e.start).getUTCFullYear())})):N(n,i,P).map(e=>{let t=s(e),n=new Date(e.start),r=w(n.getUTCMonth());return{...t,label:t.w<v?r:`${r} ${n.getUTCFullYear()}`}}),l=[];if(t===`day`)for(let e of N(n,i,ue)){let t=new Date(e.start),n=t.getUTCDay();l.push({...s(e),label:String(t.getUTCDate()),sub:`MTWTFSS`.charAt((n+6)%7),weekend:n===0||n===6})}else if(t===`week`)for(let e of N(n,i,de))l.push({...s(e),label:T(new Date(e.start).getUTCDate())});else for(let e of N(n,i,P))l.push({...s(e),label:w(new Date(e.start).getUTCMonth())});return{startMs:n,endMs:i,days:a,width:a*r,ppd:r,x:o,top:c,bottom:l,gridX:l.map(e=>e.x),weekendX:l.filter(e=>e.weekend===!0).map(e=>e.x)}}var I=(e,t)=>new C(`Gantt row "${e}": ${t}.`),L=(e,t,n)=>{let r=E(n);if(r===null)throw I(e,`${t} "${n}" is not a calendar day`);return r};function pe(e){if(e.layout!==void 0&&!ie.has(e.layout))throw new C(`Gantt layout "${e.layout}" is not table or lanes.`);if(e.zoom!==void 0&&!re.has(e.zoom))throw new C(`Gantt zoom "${e.zoom}" is not day, week or month.`);let t=new Set;for(let n of e.rows){if(t.has(n.key))throw I(n.key,`key is used by more than one row`);if(t.add(n.key),n.name.trim()===``)throw I(n.key,`name is empty`);if(n.end!==void 0&&n.start===void 0)throw I(n.key,`end is set without a start`);if(n.start!==void 0){let e=L(n.key,`start`,n.start);if(n.end!==void 0&&L(n.key,`end`,n.end)<e)throw I(n.key,`end "${n.end}" is before start "${n.start}"`)}if(n.progress!==void 0&&!(Number.isInteger(n.progress)&&n.progress>=0&&n.progress<=100))throw I(n.key,`progress ${n.progress} is not a whole number from 0 to 100`);if(n.status!==void 0&&!ae.has(n.status))throw I(n.key,`status "${n.status}" is not a known status`)}let n=new Map;for(let t of e.rows)n.set(t.key,t);for(let t of e.rows)for(let e of t.dependsOn??[]){if(e===t.key)throw I(t.key,`depends on itself`);if(!n.has(e))throw I(t.key,`depends on "${e}", which is no row`)}let r=new Map,i=e=>(r.set(e,`onPath`),{key:e,deps:n.get(e)?.dependsOn??[],next:0});for(let t of e.rows){if(r.has(t.key))continue;let e=[i(t.key)];for(;e.length>0;){let t=e[e.length-1];if(!t)break;let n=t.deps[t.next];if(n===void 0){r.set(t.key,`done`),e.pop();continue}t.next++;let a=r.get(n);if(a===`onPath`)throw I(n,`dependencies form a loop`);a===void 0&&e.push(i(n))}}}function me(e,t,n){return b*(e.length+String(t).length+4)+x<=n?`inside`:`after`}function he(e,t){let{arrow:n,elbow:r}=p;return{d:t.l-e.r>=ee?`M${e.r} ${e.y} H${e.r+r} V${t.y} H${t.l-n}`:`M${e.r} ${e.y} H${e.r+te} V${(e.y+t.y)/2} H${t.l-r} V${t.y} H${t.l-n}`,head:`${t.l-n},${t.y-S} ${t.l},${t.y} ${t.l-n},${t.y+S}`}}var R=(e,t,n,r,i)=>({row:e,kind:t,index:n,top:r,height:i,x:0,w:0,clippedLeft:!1,clippedRight:!1,hidden:!0});function ge(e,t){let n=m[t.layout],r=F(t.layout,t.zoom,t.fromMs),{ppd:i,width:a}=r,o=new Set(e.folded??[]),s=e.rows.map((e,t)=>({row:e,index:t,startMs:e.start===void 0?void 0:D(e.start),endEx:e.end===void 0?void 0:D(e.end)+f})),c=new Map;for(let e of s){let t=e.row.group;if(t===void 0)continue;let n=c.get(t)??{name:t,count:0,sum:0,n:0,emitted:!1};if(c.set(t,n),n.count++,e.startMs!==void 0){let t=e.endEx??e.startMs+864e5;n.startMs=n.startMs===void 0?e.startMs:Math.min(n.startMs,e.startMs),n.endMs=n.endMs===void 0?t:Math.max(n.endMs,t)}e.endEx!==void 0&&(n.sum+=e.row.progress??0,n.n++)}let l=[],u=new Map,d=0;for(let e of s){let{row:s,index:f}=e,m=s.group===void 0?void 0:c.get(s.group);if(m!==void 0&&!m.emitted){m.emitted=!0;let e=o.has(m.name),t=m.startMs!==void 0&&m.endMs!==void 0,i=m.startMs??r.startMs,c=m.endMs??r.startMs,u=r.x(i),p=r.x(c),h=t&&p>0&&u<a;l.push({row:s,kind:`group`,index:f,top:d,height:n.groupH,x:h?Math.max(u,0):0,w:h?Math.min(p,a)-Math.max(u,0):0,clippedLeft:h&&u<0,clippedRight:h&&p>a,hidden:!1,group:{name:m.name,count:m.count,percent:m.n>0?Math.round(m.sum/m.n):0,folded:e,startMs:i,endMs:c}}),d+=n.groupH}let h=s.group!==void 0&&o.has(s.group),v=e.endEx===void 0?`milestone`:`bar`;if(h){l.push(R(s,v,f,d,0));continue}let b=d;if(d+=n.rowH,e.startMs===void 0){l.push(R(s,v,f,b,n.rowH));continue}let x;if(e.endEx===void 0){let o=r.x(e.startMs)+i/2;x=o<-8||o>a+_?R(s,v,f,b,n.rowH):{row:s,kind:v,index:f,top:b,height:n.rowH,x:o,w:p.milestone,clippedLeft:!1,clippedRight:!1,hidden:!1,flip:t.layout===`lanes`&&o>a-y}}else{let i=r.x(e.startMs),o=Math.max(r.x(e.endEx)-i,g);if(i>=a||i+o<=0)x=R(s,v,f,b,n.rowH);else{let e=Math.max(i,0),r=Math.min(i+o,a),c=i<0,l=i+o>a;r-e<g&&(c?r=Math.min(g,a):e=Math.max(0,r-g)),x={row:s,kind:v,index:f,top:b,height:n.rowH,x:e,w:r-e,clippedLeft:c,clippedRight:l,hidden:!1},t.layout===`lanes`&&(x.place=me(s.name,s.progress??0,r-e))}}l.push(x),x.hidden||u.set(s.key,x)}let h=[];for(let e of l){if(e.kind===`group`||e.hidden)continue;let t=e.kind===`milestone`?e.x-_:e.x,r=new Set;for(let i of e.row.dependsOn??[]){let a=u.get(i);if(a===void 0||r.has(i))continue;r.add(i);let o=he({r:a.kind===`milestone`?a.x+_:a.x+a.w,y:a.top+n.rowH/2},{l:t,y:e.top+n.rowH/2});h.push({fromKey:i,toKey:e.row.key,d:o.d,head:o.head})}}return{layout:t.layout,geometry:n,axis:r,rows:l,height:d,today:{x:r.x(t.todayMs)+i/2,inWindow:t.todayMs>=r.startMs&&t.todayMs<r.endMs},arrows:h}}var _e=new Set([`pvt`,`private`,`ltd`,`limited`,`llp`,`llc`,`inc`,`corp`,`co`]),z=/\p{L}/u,ve=/\p{N}/u;function ye(e){let t=``,n=0;for(let r of e)r===`(`?(n+=1,t+=` `):r===`)`?(n=Math.max(0,n-1),t+=` `):n===0&&(t+=r);return t}function B(e,t,n){let r=e[t];if(r===void 0)throw Error(`initialsOf: the ${n} is missing`);return r}function V(e){return e.map(e=>{let t=e.toUpperCase();return Array.from(t).length===1?t:e}).join(``)}function be(e,t=2){let n=ye(String(e??``)).split(/\s+/),r=e=>n.map(t=>Array.from(t).filter(t=>e.test(t))).filter(e=>e.length>0),i=r(z).filter(e=>!_e.has(e.join(``).toLowerCase()));if(i.length===0&&!n.some(e=>z.test(e))&&(i=r(ve)),i.length===0)return``;let a=B(i,0,`first word`);if(i.length===1)return V(a.slice(0,t));let o=B(i,1,`second word`);return V([B(a,0,`first letter`),B(o,0,`second letter`)])}var xe=`data-wui-gantt-pick`,H=e=>`${e}px`,U=(e,t,n)=>{let r=(0,i.make)(`div`,{class:`wui-gantt-table-cell`},n);return r.setAttribute(`role`,t),r.dataset.col=e,r};function Se(e){let t=e.text,n=(0,i.make)(`div`,{class:`wui-gantt-table`});n.setAttribute(`role`,`table`),n.setAttribute(`aria-label`,e.title);let r=(0,i.make)(`div`);r.setAttribute(`role`,`rowgroup`);let a=(0,i.make)(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`head`,a.setAttribute(`role`,`row`),a.style.height=H(e.headHeight),a.append(U(`name`,`columnheader`,t.tableName),U(`owner`,`columnheader`,t.detailsOwner),U(`start`,`columnheader`,t.tableStart),U(`end`,`columnheader`,t.tableEnd),U(`done`,`columnheader`,t.detailsDone)),r.append(a);let l=(0,i.make)(`div`);l.setAttribute(`role`,`rowgroup`);for(let n of e.rows){if(n.height===0)continue;let r=n.row;if(n.kind===`group`){let r=n.group;if(!r)continue;let a=(0,i.make)(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`group`,a.dataset.wuiGanttGroup=r.name,a.setAttribute(`role`,`row`),a.style.height=H(n.height);let o=(0,i.make)(`div`,{class:`wui-gantt-table-cell wui-gantt-table-group`});o.setAttribute(`role`,`rowheader`);let u=(0,i.make)(`button`,{class:`wui-gantt-group-toggle`});u.type=`button`,u.setAttribute(`aria-expanded`,String(!r.folded)),u.setAttribute(`aria-label`,(0,c.fillText)(r.folded?t.unfoldLabel:t.foldLabel,{group:r.name})),u.setAttribute(e.focusAttr,`group:${r.name}`);let d=(0,s.glyphNode)(r.folded?`chevron-right`:`chevron-down`,{size:16});u.replaceChildren(...d?[d]:[]),o.append(u,(0,i.make)(`span`,null,r.name),(0,i.make)(`span`,null,(0,c.pluralText)(t,`groupSummary`,r.count,{percent:r.percent}))),a.append(o),l.append(a);continue}let a=(0,i.make)(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=r.end===void 0?`milestone`:`bar`,a.dataset.wuiGanttKey=r.key,a.dataset.wuiGanttPick=r.key,r.key===e.selected&&(a.dataset.selected=`true`),a.setAttribute(`role`,`row`),a.style.height=H(n.height);let u=U(`name`,`rowheader`,r.name);u.title=r.name;let d=U(`owner`,`cell`,``);r.owner&&(d.title=r.owner,d.replaceChildren(...[(0,o.avatarNode)({initials:be(r.owner)},`avatar-xs`)].filter(e=>e!==null)),d.append((0,i.make)(`span`,{class:`visually-hidden`},r.owner)));let f=U(`start`,`cell`,r.start===void 0?``:O(D(r.start))),p=U(`end`,`cell`,r.end===void 0?``:O(D(r.end))),m=U(`done`,`cell`,r.end===void 0?``:`${r.progress??0}%`);a.append(u,d,f,p,m),l.append(a)}let u=e.skeleton;for(let e=0;u&&e<u.rows;e+=1){let e=(0,i.make)(`div`,{class:`wui-gantt-table-row`});e.dataset.kind=`skeleton`,e.setAttribute(`role`,`row`),e.setAttribute(`aria-hidden`,`true`),e.style.height=H(u.rowHeight);let t=(0,i.make)(`span`,{class:`wui-gantt-skeleton`});t.style.height=H(u.barHeight),e.append(t),l.append(e)}return n.append(r,l),n}var Ce={addTaskLabel:`Add task`,barLabel:`{name}, {start} to {end}, {percent} percent, {status}`,barLabelAfter:`{label}, after {names}`,dayLabel:`Day`,detailsCloseLabel:`Close details`,detailsDates:`Dates`,detailsDone:`Done`,detailsOwner:`Owner`,detailsRange:`{start} to {end}`,detailsStartsAfter:`Starts after`,earlierLabel:`Earlier`,emptyText:`Add a task with a start and an end date and it is drawn here as a bar.`,emptyTitle:`No tasks on the plan yet`,errorText:`The plan did not load. Check your connection and try again.`,foldLabel:`Fold {group}`,groupSummaryOne:`{count} item, {percent}% done`,groupSummaryOther:`{count} items, {percent}% done`,helpText:`Use the Up and Down arrow keys to move between bars and the Left and Right keys to move along a row. Press Enter to open the details and Escape to close them.`,helpTextTable:`Use the Up and Down arrow keys to move between bars and the Left and Right keys to follow a dependency. Press Enter to choose a row and Escape to clear the choice.`,laterLabel:`Later`,legendLabel:`Key`,legendRemaining:`Lighter part of a bar is work still to do`,loadingText:`Loading plan`,milestoneBarLabel:`{name}, {date}, milestone, after {names}`,milestoneLabel:`Milestone`,monthLabel:`Month`,retryLabel:`Try again`,scaleLabel:`Time scale`,statusAtRisk:`At risk`,statusDone:`Done`,statusInProgress:`In progress`,statusNotStarted:`Not started`,summaryMilestonesOne:`{count} milestone`,summaryMilestonesOther:`{count} milestones`,summaryRange:`{from} to {to}`,summaryTasksOne:`{count} task`,summaryTasksOther:`{count} tasks`,tableEnd:`End`,tableName:`Task`,tableStart:`Start`,tableStatus:`Status`,todayLabel:`Today`,unfoldLabel:`Unfold {group}`,weekLabel:`Week`},W=()=>(0,c.readText)(`gantt`,Ce),we=`wui-gantt:zoom-change`,Te=`wui-gantt:from-change`,Ee=`wui-gantt:fold-change`,De=`wui-gantt:select`,Oe=`wui-gantt:add-task`,ke=`wui-gantt:retry`,G=`data-wui-gantt-focus`,K=`bar:`,q=`http://www.w3.org/2000/svg`,Ae=[`day`,`week`,`month`],J=3,je=16,Me=300,Ne=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`Escape`,`Enter`,` `],Pe=0,Y=e=>`${e}px`;function Fe(e){return typeof e==`object`&&!!e&&`rows`in e&&Array.isArray(e.rows)&&`title`in e&&typeof e.title==`string`}function X(e){let t=W();switch(e){case`done`:return t.statusDone;case`inProgress`:return t.statusInProgress;case`atRisk`:return t.statusAtRisk;case`notStarted`:return t.statusNotStarted;default:throw RangeError(`Unknown gantt status ${String(e)}.`)}}var Z=e=>e.progress??0,Q=e=>e.status??`notStarted`,Ie=(e,t)=>(e??[]).join(`\0`)===(t??[]).join(`\0`),$=class extends a.ElementBase{uid;_spec=null;_prev=null;_zoom=`week`;_fromMs=null;_folded=new Set;_selected=null;_controlled=!1;_awaitingSpec=!1;_connected=!1;_focusAfter=null;_resolved=null;_specRows=[];_card=null;_onClick;_onKeyDown;_onChange;constructor(){super(),Pe+=1,this.uid=`wui-gantt-${Pe}`,this._onClick=e=>this._handleClick(e),this._onKeyDown=e=>this._handleKeyDown(e),this._onChange=e=>this._handleChange(e)}get spec(){return this._spec}set spec(e){this._spec=e??null,this._connected&&this._draw()}connectedCallback(){if(Object.hasOwn(this,`spec`)){let e=this.spec;delete this.spec,this._spec=e??null}this._spec??=this._readScript(),this._spec==null&&!this.querySelector(`:scope > script[type='application/json']`)&&(this._awaitingSpec=!0,queueMicrotask(()=>{this._awaitingSpec=!1,this._connected&&this._draw()})),this.classList.add(`wui-gantt`),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`change`,this._onChange),this._connected=!0,this._draw()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`change`,this._onChange),this._card&&=((0,l.closeAnchoredPopover)(this._card),this._card.remove(),null),this._connected=!1}_readScript(){let e=this.querySelector(`:scope > script[type="application/json"]`);if(!(e instanceof HTMLScriptElement))return null;try{return JSON.parse(String(e.textContent))}catch(e){return(0,r.devError)(`[@webority/ui-elements] <wui-gantt> could not read its JSON spec:`,e instanceof Error?e.message:void 0),null}}_seed(e){let t=this._prev;this._controlled=e.controlled===!0;let n=e=>this._controlled||t===null||e;n(t?.zoom!==e.zoom)&&(this._zoom=e.zoom??`week`),n(t?.from!==e.from)&&(this._fromMs=e.from?D(e.from):null),n(!Ie(t?.folded,e.folded))&&(this._folded=new Set(e.folded??[])),n(t?.selected!==e.selected)&&(this._selected=e.selected??null),this._prev=e}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_setZoom(e){this._emit(we,{zoom:e}),this._controlled?this._syncRadios():(this._zoom=e,this._fromMs=this._fromMs===null?null:j(e,this._fromMs),this._draw())}_setFrom(e){this._emit(Te,{from:ce(e)}),this._controlled||(this._fromMs=e,this._draw())}_setFolded(e){let t=new Set(this._folded);t.delete(e)||t.add(e),this._emit(Ee,{folded:[...t]}),this._controlled||(this._folded=t,this._draw())}_setSelected(e){this._emit(De,{key:e}),this._focusAfter=`${K}${e??this._selected??``}`,this._controlled||(this._selected=e),this._draw()}_syncRadios(){for(let e of this.querySelectorAll(`.segmented-input`))e.checked=e.value===this._zoom}_handleChange(e){let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-gantt-scale .segmented-input`))return;let n=Ae.find(e=>e===t.value);n&&this._setZoom(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[${G}]`);if(n instanceof HTMLElement&&this.contains(n)){this._activate(n.getAttribute(G)??``,n);return}let r=t.closest(`[${xe}]`);if(!(r instanceof HTMLElement)||!this.contains(r))return;let i=r.getAttribute(`data-wui-gantt-pick`)??``;this._setSelected(i===this._selected?null:i)}_activate(e,t){let n=this._resolved;if(e.startsWith(K)){let t=e.slice(4);this._setSelected(t===this._selected?null:t)}else e.startsWith(`group:`)?this._setFolded(e.slice(6)):e===`close`?this._setSelected(null):e===`add`?this._emit(Oe):e===`retry`?this._emit(ke):n&&e===`nav:earlier`?this._setFrom(M(n.zoom,n.fromMs,-1)):n&&e===`nav:later`?this._setFrom(M(n.zoom,n.fromMs,1)):n&&e===`nav:today`?this._setFrom(A(n.zoom,n.todayMs)):e.startsWith(`zoom:`)&&t.click()}_bars(){return[...this.querySelectorAll(`.wui-gantt-lane [${G}^="${K}"]`)].filter(e=>e instanceof HTMLElement)}_focusBar(e){if(e){for(let t of this._bars())t.tabIndex=t===e?0:-1;e.focus()}}_barByKey(e){return e===void 0?void 0:this._bars().find(t=>t.dataset.wuiGanttKey===e)}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey||!Ne.includes(e.key))return;if(e.key===`Escape`){if(this._selected===null)return;e.preventDefault(),this._setSelected(null);return}let t=e.target;if(!(t instanceof HTMLElement)||!t.getAttribute(G)?.startsWith(K))return;let n=this._bars(),r=n.indexOf(t),i=t.dataset.wuiGanttKey,a=this._specRows.find(e=>e.key===i);switch(e.preventDefault(),(0,u.mirrorKey)(e.key,(0,u.isRtl)(this))){case`ArrowDown`:this._focusBar(n[r+1]);break;case`ArrowUp`:this._focusBar(n[r-1]);break;case`Home`:this._focusBar(n[0]);break;case`End`:this._focusBar(n.at(-1));break;case`ArrowLeft`:this._focusBar((a?.dependsOn??[]).map(e=>this._barByKey(e)).find(e=>e));break;case`ArrowRight`:this._focusBar(this._specRows.filter(e=>e.dependsOn?.includes(i??``)).map(e=>this._barByKey(e.key)).find(e=>e));break;default:this._activate(t.getAttribute(G)??``,t)}}_focusToken(){let e=document.activeElement;return e instanceof HTMLElement&&this.contains(e)?e.getAttribute(G):null}_draw(){if(this._card&&=((0,l.closeAnchoredPopover)(this._card),this._card.remove(),null),this._spec==null&&this._awaitingSpec)return;let e=this._focusAfter??this._focusToken();this._focusAfter=null;let t;try{t=this._compose()}catch(e){(0,r.devError)(`[@webority/ui-elements] <wui-gantt> could not draw its spec:`,e instanceof Error?e.message:void 0),this._resolved=null,this._specRows=[],this._card=null,this.dataset.state=`error`,this.removeAttribute(`aria-busy`),t=[this._stateBlock(`error`,W().errorText)]}if(this.replaceChildren(...t),this._card){let e=(0,i.must)(this._barByKey(this._selected??void 0),`selected gantt bar`);this.append(this._card),(0,l.openAnchoredPopover)(e,this._card,{mode:`manual`,side:`auto`,align:`start`,flipAlign:!0,gap:4,keepOffscreen:!0})}if(this._placeThumb(),e===null)return;let n=[...this.querySelectorAll(`[${G}]`)].find(t=>t.getAttribute(G)===e);n instanceof HTMLElement&&(e.startsWith(K)?this._focusBar(n):n.focus())}_compose(){let e=this._spec;if(!Fe(e))throw TypeError("<wui-gantt> has no spec: set the `spec` property or add a JSON script child.");this._seed(e),pe(e);let t=e.layout??`table`,n=m[t],r=W(),a=D(e.today??le()),o=this._zoom,s=j(o,this._fromMs??A(o,a)),c={layout:t,zoom:o,fromMs:s,todayMs:a};this._resolved=c,this._specRows=e.rows;let l=e.rows.some(e=>e.start!==void 0),u=(e.state??`ready`)===`ready`&&!l?`empty`:e.state??`ready`;this.dataset.state=u,this.dataset.zoom=o,this.dataset.layout=t,u===`loading`?this.setAttribute(`aria-busy`,`true`):this.removeAttribute(`aria-busy`);let d=u===`ready`?ge({...e,folded:[...this._folded],selected:this._selected},c):null,f=d?.axis??F(t,o,s),h=(0,i.make)(`div`,{class:`wui-gantt-lane`});h.style.width=Y(f.width),d?this._fillLane(h,e,d):u===`loading`&&(h.style.height=Y(J*n.rowH));let g=[];u===`loading`&&g.push(this._fillSkeleton(h,e,n)),u===`empty`&&g.push(this._emptyBlock(e)),u===`error`&&g.push(this._stateBlock(`error`,e.errorText||r.errorText));let _=this._head(f),v=(0,i.make)(`div`,{class:`wui-gantt-plot`});v.append(_,h);let y=(0,i.make)(`div`,{class:`wui-gantt-scroller`});if(t===`table`){let t=Se({title:e.title,rows:d?.rows??[],headHeight:2*p.tierH,selected:this._selected,text:r,focusAttr:G,skeleton:u===`loading`?{rows:J,rowHeight:n.rowH,barHeight:n.barH}:void 0});y.append(t,v)}else y.append(v);return[this._toolbar(e,u===`ready`),y,...g,this._legend(t)]}_toolbar(e,t){let n=(0,i.make)(`div`,{class:`wui-gantt-toolbar`});return t&&n.append((0,i.make)(`p`,{class:`wui-gantt-count`},this._countText(e.rows))),n.append(this._scale(),this._nav()),n}_countText(e){let t=W(),n=e.filter(e=>e.start!==void 0),r=n.filter(e=>e.end===void 0).length,i=1/0,a=-1/0;for(let e of n)i=Math.min(i,D(e.start??``)),a=Math.max(a,D(e.end??e.start??``));return[(0,c.pluralText)(t,`summaryTasks`,n.length-r),(0,c.pluralText)(t,`summaryMilestones`,r),(0,c.fillText)(t.summaryRange,{from:O(i),to:O(a)})].join(`, `)}_scale(){let e=W(),t=(0,i.make)(`div`,{class:`segmented segmented-sm wui-gantt-scale`});t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,e.scaleLabel),t.append(Object.assign((0,i.make)(`span`,{class:`segmented-thumb`}),{ariaHidden:`true`}));let n={day:e.dayLabel,week:e.weekLabel,month:e.monthLabel};for(let e of Ae){let r=(0,i.make)(`label`,{class:`segmented-option`}),a=(0,i.make)(`input`,{class:`segmented-input`});a.type=`radio`,a.name=`${this.uid}-scale`,a.value=e,a.checked=e===this._zoom,a.setAttribute(G,`zoom:${e}`),r.append(a,n[e]),t.append(r)}return t}_placeThumb(){let e=this.querySelector(`.wui-gantt-scale`),t=e?.querySelector(`.segmented-thumb`),n=e?.querySelector(`.segmented-option:has(.segmented-input:checked)`);e instanceof HTMLElement&&t instanceof HTMLElement&&n instanceof HTMLElement&&e.offsetWidth&&(t.style.width=Y(n.offsetWidth),t.style.transform=`translateX(${n.offsetLeft}px)`,t.style.opacity=`1`)}_nav(){let e=W(),t=(0,i.make)(`div`,{class:`wui-gantt-nav`}),r=(e,t,r)=>{let a=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`soft`,`sm`)});a.type=`button`,a.setAttribute(`aria-label`,t),a.setAttribute(G,e);let o=(0,s.glyphNode)(r,{size:16});return a.replaceChildren(...o?[o]:[]),a},a=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`soft`,`sm`)},e.todayLabel);return a.type=`button`,a.setAttribute(G,`nav:today`),t.append(r(`nav:earlier`,e.earlierLabel,`chevron-left`),r(`nav:later`,e.laterLabel,`chevron-right`),a),t}_head(e){let t=(0,i.make)(`div`,{class:`wui-gantt-head`});t.style.width=Y(e.width),t.setAttribute(`aria-hidden`,`true`);let n=(e,t)=>{let n=(0,i.make)(`div`,{class:`wui-gantt-tier ${t}`});for(let t of e){let e=(0,i.make)(`div`,{class:t.weekend?`wui-gantt-cell wui-gantt-cell-weekend`:`wui-gantt-cell`});e.style.left=Y(t.x),e.style.width=Y(t.w),t.sub&&e.append((0,i.make)(`small`,null,t.sub)),e.append(t.label),n.append(e)}return n};return t.append(n(e.top,`wui-gantt-tier-top`),n(e.bottom,`wui-gantt-tier-bottom`)),t}_legend(e){let t=W(),n=(0,i.make)(`div`,{class:`wui-gantt-legend`});n.setAttribute(`role`,`list`),n.setAttribute(`aria-label`,t.legendLabel);let r=(e,t)=>{let r=(0,i.make)(`span`,null);r.setAttribute(`role`,`listitem`),r.append(e,t),n.append(r)};for(let e of[`done`,`inProgress`,`atRisk`,`notStarted`]){let t=(0,i.make)(`span`,{class:`wui-gantt-swatch`});t.dataset.status=e,r(t,X(e))}let a=(0,i.make)(`span`,{class:`wui-gantt-swatch`});if(a.dataset.kind=`milestone`,r(a,t.milestoneLabel),e===`table`){let e=(0,i.make)(`span`,{class:`wui-gantt-legend-note`},t.legendRemaining);e.setAttribute(`role`,`listitem`),n.append(e)}return n}_stateBlock(e,t){let r=W(),a=(0,i.make)(`div`,{class:`wui-gantt-state`});if(e===`error`){a.setAttribute(`role`,`alert`),a.append((0,i.make)(`p`,null,t));let e=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`soft`,`sm`)},r.retryLabel);e.type=`button`,e.setAttribute(G,`retry`),a.append(e)}else a.append((0,i.make)(`p`,null,t));return a}_emptyBlock(e){let t=W(),r=(0,i.make)(`div`,{class:`wui-gantt-state`});if(r.append((0,i.make)(`p`,{class:`fw-semibold`},t.emptyTitle),(0,i.make)(`p`,null,e.emptyText||t.emptyText)),e.addTask){let e=(0,i.make)(`button`,{class:(0,n.buttonClass)(`primary`,`solid`,`sm`)},t.addTaskLabel);e.type=`button`,e.setAttribute(G,`add`),r.append(e)}return r}_fillSkeleton(e,t,n){let r=(0,i.make)(`div`,{class:`visually-hidden`},t.loadingText||W().loadingText);r.setAttribute(`role`,`status`);for(let t=0;t<J;t+=1){let r=(0,i.make)(`div`,{class:`wui-gantt-skeleton`});r.style.top=Y(t*n.rowH+n.barTop),r.style.left=Y(40+t*60),r.style.width=Y(240),r.style.height=Y(n.barH),r.setAttribute(`aria-hidden`,`true`),e.append(r)}return r}_fillLane(e,t,n){let r=W(),{axis:a}=n,o=n.layout===`table`;e.style.height=Y(n.height),e.setAttribute(`role`,`list`),e.setAttribute(`aria-label`,t.title);let s=(0,i.make)(`p`,{class:`visually-hidden`},o?r.helpTextTable:r.helpText);s.id=`${this.uid}-help`,e.setAttribute(`aria-describedby`,s.id);let c=(e,t,n,r,a)=>{let o=(0,i.make)(`div`,{class:e});return o.setAttribute(`aria-hidden`,`true`),o.style.left=Y(t),o.style.top=Y(n),o.style.width=Y(r),o.style.height=Y(a),o},l=[s];for(let e of n.rows){if(e.height===0)continue;let t=c(`wui-gantt-row`,0,e.top,a.width,e.height);o&&e.kind!==`group`&&e.row.key===this._selected&&(t.dataset.selected=`true`),l.push(t)}for(let e of a.weekendX)l.push(c(`wui-gantt-weekend`,e,0,a.ppd,n.height));for(let e of a.gridX)l.push(c(`wui-gantt-grid`,e,0,1,n.height));if(n.today.inWindow){l.push(c(`wui-gantt-today`,n.today.x-1,0,2,n.height));let e=(0,i.make)(`div`,{class:`wui-gantt-today-flag rounded-pill`},r.todayLabel);e.style.left=Y(n.today.x),l.push(e)}let u=new Map(t.rows.map(e=>[e.key,e]));for(let e of n.rows){if(e.hidden)continue;let t=(0,i.make)(`div`,{class:`wui-gantt-item`});t.setAttribute(`role`,`listitem`),t.style.display=`contents`,e.kind===`group`?this._drawGroup(t,e,n):e.kind===`milestone`?this._drawMilestone(t,e,u,n):this._drawBar(t,e,u,n),l.push(t)}l.push(this._deps(n)),this._card=o?null:this._details(n,u),e.append(...l);let d=e.querySelector(`[${G}^="${K}"]`);d instanceof HTMLElement&&(d.tabIndex=0)}_names(e,t){return(e.dependsOn??[]).map(e=>t.get(e)?.name??e).join(`, `)}_barSentence(e,t){let n=W(),r=this._names(e,t);if(e.end===void 0){let t=O(D(e.start??``));return r?(0,c.fillText)(n.milestoneBarLabel,{name:e.name,date:t,names:r}):`${e.name}, ${t}, ${n.milestoneLabel.toLowerCase()}`}let i=(0,c.fillText)(n.barLabel,{name:e.name,start:O(D(e.start??``)),end:O(D(e.end)),percent:Z(e),status:X(Q(e)).toLowerCase()});return r?(0,c.fillText)(n.barLabelAfter,{label:i,names:r}):i}_focusable(e,t,n,r){let a=(0,i.make)(`button`,{class:t});a.type=`button`;let o=this._barSentence(e,n);return a.setAttribute(`aria-label`,o),a.title=o,a.tabIndex=-1,a.dataset.status=Q(e),a.dataset.wuiGanttKey=e.key,a.setAttribute(G,`${K}${e.key}`),r?a.setAttribute(`aria-pressed`,String(this._selected===e.key)):a.setAttribute(`aria-expanded`,String(this._selected===e.key)),this._selected===e.key&&(a.dataset.selected=`true`),a}_afterLabel(e,t,n,r){let a=(0,i.make)(`span`,{class:`wui-gantt-label wui-gantt-label-surface`},e);return a.style.left=Y(t),a.style.top=Y(n),a.style.height=Y(r),a}_drawBar(e,t,n,r){let{row:a}=t,{geometry:o}=r,s=r.layout===`table`,c=this._focusable(a,`wui-gantt-bar rounded-2`,n,s),l=t.top+o.barTop;c.style.left=Y(t.x),c.style.width=Y(t.w),c.style.top=Y(l),c.style.height=Y(o.barH);let u=Z(a),d=(0,i.make)(`span`,{class:`wui-gantt-bar-progress`});if(d.style.width=`${u}%`,c.append(d),e.append(c),s)return;let f=`${a.name} ${u}%`;t.place===`inside`?c.append((0,i.make)(`span`,{class:`wui-gantt-bar-label`},f)):e.append(this._afterLabel(f,t.x+t.w+je,l,o.barH))}_drawMilestone(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=p.milestone/2,c=t.top+(a.rowH-p.milestone)/2,l=this._focusable(i,`wui-gantt-milestone`,n,o);if(l.style.left=Y(t.x-s),l.style.top=Y(c),l.style.width=Y(p.milestone),l.style.height=Y(p.milestone),e.append(l),o)return;let u=this._afterLabel(`${i.name}, ${O(D(i.start??``))}`,t.x+p.milestone,t.top+a.barTop,a.barH);t.flip&&(u.style.left=``,u.style.right=Y(r.axis.width-(t.x-p.milestone))),e.append(u)}_drawGroup(e,t,n){let r=W(),a=t.group;if(!a)return;if(n.layout===`lanes`){let n=(0,i.make)(`div`,{class:`wui-gantt-group wui-gantt-label wui-gantt-label-surface`});n.dataset.wuiGanttGroup=a.name,n.style.left=Y(8),n.style.top=Y(t.top+6);let o=(0,i.make)(`button`,{class:`wui-gantt-group-toggle`});o.type=`button`,o.setAttribute(`aria-expanded`,String(!a.folded)),o.setAttribute(`aria-label`,(0,c.fillText)(a.folded?r.unfoldLabel:r.foldLabel,{group:a.name})),o.setAttribute(G,`group:${a.name}`);let l=(0,s.glyphNode)(a.folded?`chevron-right`:`chevron-down`,{size:16});o.replaceChildren(...l?[l]:[]),n.append(o,(0,i.make)(`span`,null,a.name),(0,i.make)(`span`,null,(0,c.pluralText)(r,`groupSummary`,a.count,{percent:a.percent}))),e.append(n)}let o=(0,i.make)(`div`,{class:`wui-gantt-group-summary`});o.dataset.wuiGanttGroup=a.name,o.style.left=Y(t.x),o.style.width=Y(t.w),o.style.top=Y(t.top+n.geometry.groupBarTop),o.style.height=Y(p.groupBarH),e.append(o)}_deps(e){let t=document.createElementNS(q,`svg`);t.setAttribute(`class`,`wui-gantt-deps`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`width`,String(e.axis.width)),t.setAttribute(`height`,String(e.height));for(let n of e.arrows){let e=document.createElementNS(q,`path`);e.setAttribute(`d`,n.d),e.setAttribute(`fill`,`none`);let r=document.createElementNS(q,`polygon`);r.setAttribute(`points`,n.head),e.dataset.from=n.fromKey,e.dataset.to=n.toKey,t.append(e,r)}return t}_details(e,t){let r=this._selected,a=r===null?void 0:e.rows.find(e=>e.row.key===r&&e.kind!==`group`&&!e.hidden);if(!a)return null;let o=W(),{row:s}=a,l=(0,i.make)(`div`,{class:`wui-gantt-details`});l.setAttribute(`role`,`group`),l.setAttribute(`aria-label`,s.name),l.style.width=Y(Me);let u=(0,i.make)(`dl`),d=(e,t)=>{u.append((0,i.make)(`dt`,null,e),(0,i.make)(`dd`,null,t))},f=O(D(s.start??``));s.owner&&d(o.detailsOwner,s.owner),d(o.detailsDates,s.end===void 0?f:(0,c.fillText)(o.detailsRange,{start:f,end:O(D(s.end))})),s.end!==void 0&&d(o.detailsDone,`${Z(s)}%, ${X(Q(s))}`);let p=this._names(s,t);p&&d(o.detailsStartsAfter,p);let m=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`ghost`,`sm`)},o.detailsCloseLabel);return m.type=`button`,m.setAttribute(G,`close`),l.append((0,i.make)(`h3`,{class:`h6`},s.name),u,m),l}};(0,t.defineElement)(`wui-gantt`,$),e.WuiGantt=$})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.avatarNode,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl);
|