@webority/ui-elements 0.170.1 → 0.171.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/{WuiCodeBlock-DTckR_z3.js → WuiCodeBlock-Du-JZO3A.js} +1 -1
  2. package/dist/{WuiCommandPalette-CSzl5yGf.js → WuiCommandPalette-BKW0e-ho.js} +1 -1
  3. package/dist/{WuiCommentThread-RB100aB1.js → WuiCommentThread-DZEYOHsk.js} +1 -1
  4. package/dist/{WuiContextMenu-ClMVFeos.js → WuiContextMenu-DvYwIicr.js} +1 -1
  5. package/dist/{WuiDatePicker-u0oZ6fJj.js → WuiDatePicker-DxPethoe.js} +1 -1
  6. package/dist/{WuiDateRange-CtWUcQ-g.js → WuiDateRange-zPmNewOW.js} +1 -1
  7. package/dist/{WuiDrawer-n8WlVPq_.js → WuiDrawer-BMkPnEFz.js} +1 -1
  8. package/dist/{WuiDropdown-D2jEbCfv.js → WuiDropdown-B9WeT-gH.js} +1 -1
  9. package/dist/{WuiGantt-BsQUCR2U.js → WuiGantt-DaEgtdOU.js} +1 -1
  10. package/dist/{WuiHoverCard-DmApQa9R.js → WuiHoverCard-D6JBAqdW.js} +1 -1
  11. package/dist/{WuiLightbox-cm5eHcMK.js → WuiLightbox-BnLEEkj1.js} +1 -1
  12. package/dist/{WuiMentionInput-D7HC7U2Q.js → WuiMentionInput-DvKw8MXS.js} +1 -1
  13. package/dist/{WuiModal-DuBerYTv.js → WuiModal-DMGgOCBU.js} +1 -1
  14. package/dist/{WuiNavigationMenu-VG-ZJstT.js → WuiNavigationMenu-CfD0FWvt.js} +1 -1
  15. package/dist/{WuiNotificationCenter-hluDIzO8.js → WuiNotificationCenter-DgcJYPV3.js} +1 -1
  16. package/dist/{WuiPhone-C03OuI7-.js → WuiPhone-BFb_LjJa.js} +1 -1
  17. package/dist/{WuiPopover-BxQj74kE.js → WuiPopover-BYO_H-fk.js} +1 -1
  18. package/dist/{WuiSelect-DpZbgU4v.js → WuiSelect-iE3EVUWK.js} +1 -1
  19. package/dist/{WuiShortcuts-CSFOyAKI.js → WuiShortcuts-Crj8lFVz.js} +1 -1
  20. package/dist/WuiTimePicker-BsnPOYNw.js +9 -0
  21. package/dist/{WuiTour-Beop0n-H.js → WuiTour-C2CRQvS7.js} +1 -1
  22. package/dist/{WuiTree-DGclk55_.js → WuiTree-DGZSXgBh.js} +1 -1
  23. package/dist/{WuiTreePicker-CBhasmC5.js → WuiTreePicker-CkTfNUQx.js} +1 -1
  24. package/dist/{WuiWhatsNew-BtWJkzTv.js → WuiWhatsNew-DjnQWqlF.js} +1 -1
  25. package/dist/{WuiWizardStep-Ce6O_8oc.js → WuiWizardStep-CryQ5BlK.js} +1 -1
  26. package/dist/{avatarHtml-BtbN7cA5.js → avatarHtml-BWlA0cm-.js} +1 -1
  27. package/dist/{chips-IbfKMhVk.js → chips-B4ZNRO-h.js} +1 -1
  28. package/dist/drawerDiscard-B4OcoR8S.js +1 -0
  29. package/dist/elements/code-block.js +1 -1
  30. package/dist/elements/command-palette.js +1 -1
  31. package/dist/elements/comment-thread.js +1 -1
  32. package/dist/elements/context-menu.js +1 -1
  33. package/dist/elements/date-range.js +1 -1
  34. package/dist/elements/datepicker.js +1 -1
  35. package/dist/elements/drawer.js +1 -1
  36. package/dist/elements/dropdown.js +1 -1
  37. package/dist/elements/filter-popover.js +1 -1
  38. package/dist/elements/gantt.js +1 -1
  39. package/dist/elements/hover-card.js +1 -1
  40. package/dist/elements/lightbox.js +1 -1
  41. package/dist/elements/mention-input.js +1 -1
  42. package/dist/elements/modal.js +1 -1
  43. package/dist/elements/navigation-menu.js +1 -1
  44. package/dist/elements/notification-center.js +1 -1
  45. package/dist/elements/phone.js +1 -1
  46. package/dist/elements/popover.js +1 -1
  47. package/dist/elements/select.js +1 -1
  48. package/dist/elements/shortcuts.js +1 -1
  49. package/dist/elements/timepicker.js +1 -1
  50. package/dist/elements/tour.js +1 -1
  51. package/dist/elements/tree-picker.js +1 -1
  52. package/dist/elements/tree.js +1 -1
  53. package/dist/elements/whats-new.js +1 -1
  54. package/dist/elements/wizard.js +1 -1
  55. package/dist/fileViewer.g-D5lbrn8g.js +1 -0
  56. package/dist/{fileViewerImage-DT0a9KaL.js → fileViewerImage-uL9m83k1.js} +1 -1
  57. package/dist/{fileViewerMedia-BFNxdaYX.js → fileViewerMedia-cfmycjzl.js} +1 -1
  58. package/dist/{fileViewerPdf-Boo6uXQO.js → fileViewerPdf-BsSc-9fL.js} +1 -1
  59. package/dist/{filterPopover-BVBxgtc5.js → filterPopover-C_oDfQBg.js} +1 -1
  60. package/dist/helpers.js +1 -1
  61. package/dist/iconGlyphs.g-BUF97bUu.js +1 -0
  62. package/dist/nativeOverlay-DGady-wN.js +1 -0
  63. package/dist/{optionLabel-B2cU4Ax0.js → optionLabel-CWMhBkdO.js} +1 -1
  64. package/dist/{search-BVox4aaA.js → search-w5M6FzD9.js} +1 -1
  65. package/dist/server.js +1 -1
  66. package/dist/text/en.json +1 -0
  67. package/dist/text.js +1 -1
  68. package/dist/{themeTransition-CDB0Mx61.js → themeTransition-CA1qzCZk.js} +1 -1
  69. package/dist/timePicker.g-IEczeE48.js +1 -0
  70. package/dist/ui-elements/carousel.global.js +1 -1
  71. package/dist/ui-elements/code-block.global.js +1 -1
  72. package/dist/ui-elements/command-palette.global.js +1 -1
  73. package/dist/ui-elements/comment-thread.global.js +1 -1
  74. package/dist/ui-elements/consent-banner.global.js +1 -1
  75. package/dist/ui-elements/context-menu.global.js +1 -1
  76. package/dist/ui-elements/date-range.global.js +1 -1
  77. package/dist/ui-elements/drawer.global.js +1 -1
  78. package/dist/ui-elements/dropdown.global.js +1 -1
  79. package/dist/ui-elements/entry-grid.global.js +1 -1
  80. package/dist/ui-elements/gantt.global.js +1 -1
  81. package/dist/ui-elements/glyphs.global.js +1 -1
  82. package/dist/ui-elements/image-crop.global.js +1 -1
  83. package/dist/ui-elements/inline-edit.global.js +1 -1
  84. package/dist/ui-elements/kanban.global.js +1 -1
  85. package/dist/ui-elements/lead-popup.global.js +1 -1
  86. package/dist/ui-elements/lightbox.global.js +1 -1
  87. package/dist/ui-elements/markdown.global.js +1 -1
  88. package/dist/ui-elements/org-tree.global.js +1 -1
  89. package/dist/ui-elements/phone.global.js +1 -1
  90. package/dist/ui-elements/popover.global.js +1 -1
  91. package/dist/ui-elements/saved-views.global.js +1 -1
  92. package/dist/ui-elements/select-chips.global.js +1 -1
  93. package/dist/ui-elements/select-recents.global.js +1 -1
  94. package/dist/ui-elements/select-search.global.js +1 -1
  95. package/dist/ui-elements/select-window.global.js +1 -1
  96. package/dist/ui-elements/slider.global.js +1 -1
  97. package/dist/ui-elements/sortable.global.js +1 -1
  98. package/dist/ui-elements/status-icon.global.js +1 -1
  99. package/dist/ui-elements/timepicker.global.js +6 -6
  100. package/dist/ui-elements/tour.global.js +1 -1
  101. package/dist/ui-elements/tree-picker.global.js +1 -1
  102. package/dist/ui-elements/tree.global.js +1 -1
  103. package/dist/ui-elements/wizard.global.js +1 -1
  104. package/dist/ui-elements.global.js +8 -8
  105. package/dist/ui-elements.js +1 -1
  106. package/dist/ui-file-viewer.global.js +1 -1
  107. package/dist/ui-file-viewer.js +1 -1
  108. package/package.json +5 -5
  109. package/types/WuiTimePicker.d.ts +3 -1
  110. package/types/nativeOverlay.d.ts +1 -1
  111. package/types/server/remoteModal.d.ts +6 -2
  112. package/types/text/web/timePicker.g.d.ts +1 -0
  113. package/dist/WuiTimePicker-BxcImgm1.js +0 -9
  114. package/dist/drawerDiscard-CM6a_8-l.js +0 -1
  115. package/dist/fileViewer.g-DQ-YkF8l.js +0 -1
  116. package/dist/iconGlyphs.g-DxSJLQJ8.js +0 -1
  117. package/dist/nativeOverlay-D3VmY8qn.js +0 -1
  118. package/dist/timePicker.g-DM61i-ZE.js +0 -1
@@ -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.170.1`)throw Error(`[webority-ui] context-menu expects ui-elements 0.170.1 but the page loaded `+s+`.`);var c=`[role="menuitem"]`,l=`.wui-context-menu-sub`,u=`input.wui-context-menu-search`,d=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,f=500,p=10,m=400,h=null,g=null,_=0;function v(e,t,n){let r=document.createElement(`span`);return r.setAttribute(`aria-hidden`,`true`),r.style.cssText=n?`position:absolute;left:${e+window.scrollX}px;top:${t+window.scrollY}px;width:0;height:0;`:`position:fixed;left:${e}px;top:${t}px;width:0;height:0;`,document.body.append(r),r}var y=new WeakMap;function b(e,t,n){let r=y.get(e);if(r){if(r.region===t||t.contains(r.region))return!1;r.cancel()}return y.set(e,{region:t,cancel:n}),!0}var x=e=>e instanceof Element?e:e instanceof Node?e.parentElement:null,S=e=>`focus`in e,C=e=>[...e.childNodes].filter(e=>e.nodeType===Node.TEXT_NODE||e instanceof Element&&!e.matches(`.wui-context-menu-hint, .wui-context-menu-tick`)).map(e=>e.textContent).join(``),w=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),T=e=>[...e.children].filter(e=>e instanceof HTMLElement),E=(e,t)=>{let n=e.children[t];if(!(n instanceof HTMLElement))throw Error(`a submenu holds its opener and then its panel`);return n},D=e=>E(e,0),O=e=>E(e,1),k=(e,t)=>{let n=e?.closest(t);return n instanceof HTMLElement?n:null},A=class extends n.ElementBase{_region;_origin;_returnFocus;_press;_swallowClick;_unbindKeys;_anchor;_closingByKey;_onContextMenu;_onContextMenuCapture;_onDocKeyDown;_onDocClick;_onPointerDown;_onPressMove;_onPressEnd;_onClickCapture;_onKeyDown;_onClick;_onInput;_onMouseMove;_onDismiss;_onPointerDownCapture;static get observedAttributes(){return[`disabled`,`open`]}constructor(){super(),this._region=null,this._origin=null,this._returnFocus=null,this._press=null,this._swallowClick=!1,this._unbindKeys=null,this._anchor=null,this._closingByKey=!1,this._onContextMenu=e=>this._handleContextMenu(e),this._onContextMenuCapture=e=>{this.isOpen&&!this._inPanel(e.target)&&!this._isKeyEcho()&&this.close()},this._onDocKeyDown=e=>this._handleDocKeyDown(e),this._onDocClick=e=>this._handleDocClick(e),this._onPointerDown=e=>this._handlePointerDown(e),this._onPressMove=e=>{this._press&&Math.hypot(e.clientX-this._press.x,e.clientY-this._press.y)>p&&this._cancelPress()},this._onPressEnd=()=>this._cancelPress(),this._onClickCapture=e=>{if(this._swallowClick&&this._region){if(!(e.target instanceof Node))throw Error(`a click target is always a node`);this._region.contains(e.target)&&(this._swallowClick=!1,e.preventDefault(),e.stopImmediatePropagation())}},this._onKeyDown=e=>{if(this.isOpen&&this._inPanel(e.target)){if(e.key===`Escape`){if(e.stopPropagation(),this.hasAttribute(`open`)&&k(x(e.target),`[role="menu"]`)===this._panel()){e.preventDefault(),this.close(!0);return}this._closingByKey=!0}this._handleMenuKey(e)}},this._onClick=e=>this._handleClick(e),this._onInput=e=>this._handleInput(e),this._onMouseMove=e=>{let t=k(x(e.target),c);t&&this._inPanel(t)&&!this._isDisabled(t)&&t!==document.activeElement&&t.focus({preventScroll:!0})},this._onDismiss=e=>{this.hasAttribute(`open`)||e.type===`scroll`&&this._inPanel(e.target)||this.close()},this._onPointerDownCapture=()=>{this._swallowClick=!1}}connectedCallback(){this._teardown(),document.addEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.addEventListener(`contextmenu`,this._onContextMenu),document.addEventListener(`keydown`,this._onDocKeyDown),document.addEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.addEventListener(`pointerdown`,this._onPointerDown),document.addEventListener(`click`,this._onClickCapture,!0),document.addEventListener(`click`,this._onDocClick),window.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick),this.addEventListener(`input`,this._onInput),this.addEventListener(`mousemove`,this._onMouseMove),this._syncOpen()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){e===`open`?this.isConnected&&this._syncOpen():this.disabled&&this.close()}get target(){return this.getAttribute(`target`)}set target(e){e==null||e===``?this.removeAttribute(`target`):this.setAttribute(`target`,String(e))}get disabled(){return this.hasAttribute(`disabled`)}set disabled(e){this.toggleAttribute(`disabled`,!!e)}get isOpen(){let e=this._panel();return!!e&&(0,o.isPopoverOpen)(e)}open(e,t,{region:n=this,origin:r=n,trigger:i=null,keyboard:s=!1}={}){let c=this._panel();if(!c)return!1;let l=new CustomEvent(`wui-context-menu:beforeopen`,{bubbles:!0,cancelable:!0,detail:{region:n,origin:r,trigger:i}});if(this.dispatchEvent(l),l.defaultPrevented)return!1;if(this._decorate(c),h&&h!==this&&h.close(!0),!this.isOpen){let e=document.activeElement;this._returnFocus=e&&e!==document.body&&!this._inPanel(e)&&S(e)?e:null}this._region=n,this._origin=r,g=null,h=this,this._unbindKeys?.(),this._unbindKeys=(0,a.bindMenuKeys)(c,{items:()=>this._menuRows()}),this._anchor?.remove();let u=this.hasAttribute(`open`);return this._anchor=v(e,t,u),(0,o.openAnchoredPopover)(this._anchor,c,{mode:u?`manual`:`auto`,keepOffscreen:u,clampHeight:!0,onClosed:()=>this._onPanelClosed()}),window.addEventListener(`scroll`,this._onDismiss,!0),window.addEventListener(`resize`,this._onDismiss),window.addEventListener(`blur`,this._onDismiss),queueMicrotask(()=>{(0,o.isPopoverOpen)(c)&&((s?this._rowsOf(c)[0]:null)??c).focus({preventScroll:!0})}),this.dispatchEvent(new CustomEvent(`wui-context-menu:open`,{bubbles:!0,detail:{region:n,origin:r,x:e,y:t}})),!0}_syncOpen(){if(!this.hasAttribute(`open`)){this.close(this._inPanel(document.activeElement));return}let e=this.target?document.querySelector(this.target):this,t=e&&this._regionRect(e);e&&t&&this.open(t.left,t.top,{region:e,origin:e})}_regionRect(e){if(e!==this)return e.getBoundingClientRect();let t=[...this.children].filter(e=>e!==this._panel()).map(e=>e.getBoundingClientRect());return t.length?{left:Math.min(...t.map(e=>e.left)),top:Math.min(...t.map(e=>e.top))}:null}close(e=!1){let t=this._panel();t&&(0,o.isPopoverOpen)(t)&&(e&&(this._closingByKey=!0),(0,o.closeAnchoredPopover)(t))}_finish(e){let t=this._panel();if(t)for(let e of w(t,l))this._setSub(e,!1);h===this&&(h=null),window.removeEventListener(`scroll`,this._onDismiss,!0),window.removeEventListener(`resize`,this._onDismiss),window.removeEventListener(`blur`,this._onDismiss),this._unbindKeys?.(),this._unbindKeys=null,this._anchor?.remove(),this._anchor=null;let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&n.focus({preventScroll:!0})}_onPanelClosed(){let e=this._panel();if(!e||(0,o.isPopoverOpen)(e))return;let t=this._closingByKey;this._closingByKey=!1,this._finish(t)}_menuRows(){let e=x(document.activeElement);if(!e||e.matches(u))return[];let t=k(e,`[role="menu"]`);return t?this._rowsOf(t):[]}_panel(){return T(this).find(e=>e.getAttribute(`role`)===`menu`)??null}_inPanel(e){return e instanceof Node&&!!this._panel()?.contains(e)}_rowsOf(e){return e?w(e,c).filter(t=>t.closest(`[role="menu"]`)===e&&!this._isDisabled(t)&&(0,i.isDrawn)(t)):[]}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_regionFor(e){let t=x(e);if(!t||this.disabled||!this._panel()||this._inPanel(t)||t.closest(d))return null;let n=this.target;return n?t.closest(n):this.contains(t)?this:null}_triggerFor(e){let t=x(e),n=this.getAttribute(`trigger`);if(!t||!n||this._inPanel(t))return null;let r=k(t,n),i=r&&this._regionFor(r);return r&&i?{trigger:r,region:i}:null}_isKeyEcho(){return g?.menu===this&&this.isOpen&&performance.now()-g.at<m}_handleContextMenu(e){if(this._inPanel(e.target)){e.preventDefault();return}if(e.defaultPrevented&&!y.has(e))return;let t=this._regionFor(e.target);t&&(this._isKeyEcho()?e.preventDefault():e.shiftKey||b(e,t,()=>this.close(!0))&&this.open(e.clientX,e.clientY,{region:t,origin:x(e.target)})&&e.preventDefault())}_handleDocKeyDown(e){if(e.defaultPrevented&&!y.has(e))return;if((0,r.isImeSafeEnter)(e)){let t=this._triggerFor(e.target);if(!t||!b(e,t.region,()=>this.close(!0)))return;e.preventDefault(),t.trigger.click();return}if(!(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey)||this._inPanel(e.target))return;let t=this._regionFor(e.target);if(!t||!b(e,t,()=>this.close(!0)))return;let n=x(e.target);if(!n)return;let i=n.getBoundingClientRect();this.open(i.left+Math.min(16,i.width/2),i.bottom,{region:t,origin:n,keyboard:!0})&&(e.preventDefault(),g={menu:this,at:performance.now()})}_handleDocClick(e){let t=this._triggerFor(e.target);if(!t||!b(e,t.region,()=>this.close(!0)))return;let n=t.trigger.getBoundingClientRect();this.open(n.left,n.bottom,{region:t.region,origin:t.trigger,trigger:t.trigger,keyboard:e.detail===0})}_handlePointerDown(e){if(e.pointerType!==`touch`)return;let t=this._regionFor(e.target);if(!t||!b(e,t,()=>this._cancelPress()))return;this._cancelPress();let{clientX:n,clientY:r}=e,i=x(e.target);this._press={x:n,y:r,timer:setTimeout(()=>{this._cancelPress(),this.open(n,r,{region:t,origin:i})&&(this._swallowClick=!0)},f)},document.addEventListener(`pointermove`,this._onPressMove,{passive:!0}),document.addEventListener(`pointerup`,this._onPressEnd),document.addEventListener(`pointercancel`,this._onPressEnd),window.addEventListener(`scroll`,this._onPressEnd,!0)}_cancelPress(){this._press&&(clearTimeout(this._press.timer),this._press=null,document.removeEventListener(`pointermove`,this._onPressMove),document.removeEventListener(`pointerup`,this._onPressEnd),document.removeEventListener(`pointercancel`,this._onPressEnd),window.removeEventListener(`scroll`,this._onPressEnd,!0))}_handleMenuKey(e){if(!this.isOpen)return;let t=x(e.target);if(!t)return;if(t.matches(u)){this._handleSearchKey(e,t);return}let n=k(t,`[role="menu"]`);if(!n)return;let i=k(t,c),a=n.matches(`.wui-context-menu-subpanel`)?n.parentElement:null;if(e.key===`Tab`)this.close(!0);else if(e.key===`ArrowRight`){let t=i&&this._subOf(i);if(!t)return;e.preventDefault(),this._openSub(t,!0)}else if(e.key===`ArrowLeft`){if(!a)return;e.preventDefault(),this._closeSubByKey(a)}else((0,r.isImeSafeEnter)(e)||e.key===` `)&&(e.preventDefault(),i?.click())}_handleSearchKey(e,t){let n=k(t,l);if(!n)return;let r=this._rowsOf(O(n));e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closeSubByKey(n)):e.key===`ArrowDown`?(e.preventDefault(),r[0]?.focus({preventScroll:!0})):e.key===`ArrowUp`?(e.preventDefault(),r[r.length-1]?.focus({preventScroll:!0})):e.key===`Tab`&&this.close(!0)}_subOf(e){return e.hasAttribute(`aria-haspopup`)&&e.parentElement?.matches(l)?e.parentElement:null}_openSub(e,t){let n=e.parentElement;if(!n)throw Error(`a submenu is always inside its menu panel`);for(let t of T(n))t!==e&&t.matches(l)&&this._closeSub(t);this._setSub(e,!0);let r=O(e).querySelector(`:scope > ${u}`),i=e.hasAttribute(`data-searchable`)&&r instanceof HTMLInputElement?r:null;i?(i.value=``,this._filter(e,``),i.focus({preventScroll:!0})):t&&this._rowsOf(O(e))[0]?.focus({preventScroll:!0})}_closeSub(e){for(let t of w(O(e),l))this._setSub(t,!1);this._setSub(e,!1)}_closeSubByKey(e){this._closeSub(e),D(e).focus({preventScroll:!0})}_setSub(e,t){let n=O(e);t?((0,o.openAnchoredPopover)(D(e),n,{mode:`auto`,beside:!0,onClosed:()=>this._onSubClosed(e)}),D(e).setAttribute(`aria-expanded`,String((0,o.isPopoverOpen)(n)))):(0,o.isPopoverOpen)(n)?(0,o.closeAnchoredPopover)(n):this._onSubClosed(e)}_onSubClosed(e){let t=O(e);if((0,o.isPopoverOpen)(t))return;let n=D(e);n.setAttribute(`aria-expanded`,`false`),t.removeAttribute(`data-side`);let r=this._closingByKey;this._closingByKey=!1,r&&n.focus({preventScroll:!0})}_filter(e,t){let n=t.trim().toLowerCase();for(let t of T(O(e)))t.tagName===`HR`?t.hidden=n!==``:t.matches(c)?t.hidden=n!==``&&!C(t).toLowerCase().includes(n):t.matches(l)&&(t.hidden=n!==``&&!C(D(t)).toLowerCase().includes(n))}_handleInput(e){let t=x(e.target)?.closest(u);if(!(t instanceof HTMLInputElement))return;let n=k(t,l);n?.hasAttribute(`data-searchable`)&&this._inPanel(n)&&this._filter(n,t.value)}_decorate(e){for(let t of w(e,c)){let e=t.getAttribute(`aria-checked`)===`true`,n=t.querySelector(`:scope > .wui-context-menu-tick`);if(e&&!n){let e=document.createElement(`span`);e.className=`wui-context-menu-tick`,e.setAttribute(`aria-hidden`,`true`),t.prepend(e)}else!e&&n&&n.remove();let r=t.querySelector(`:scope > .wui-context-menu-hint`),i=t.dataset.hint;if(i){let e=r??document.createElement(`span`);r||(e.className=`wui-context-menu-hint`,e.id=`wui-context-menu-hint-${++_}`,t.append(e)),e.textContent=i,t.setAttribute(`aria-describedby`,e.id)}else r&&(r.remove(),t.removeAttribute(`aria-describedby`))}}_handleClick(e){let t=k(x(e.target),c);if(!t||!this._inPanel(t))return;if(this._isDisabled(t)){e.preventDefault(),e.stopPropagation();return}let n=this._subOf(t);n?(e.preventDefault(),this._openSub(n,e.detail===0)):(this.close(!0),this.dispatchEvent(new CustomEvent(`wui-context-menu:select`,{bubbles:!0,detail:{key:t.dataset.key??null,item:t,region:this._region,origin:this._origin}})))}_teardown(){let e=this._panel();if(this._closingByKey=!1,e){for(let t of[...w(e,l)].reverse())(0,o.closeAnchoredPopover)(O(t));(0,o.closeAnchoredPopover)(e)}this._anchor&&this._finish(!1),this._cancelPress(),document.removeEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.removeEventListener(`contextmenu`,this._onContextMenu),document.removeEventListener(`keydown`,this._onDocKeyDown),document.removeEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.removeEventListener(`pointerdown`,this._onPointerDown),document.removeEventListener(`click`,this._onClickCapture,!0),document.removeEventListener(`click`,this._onDocClick),window.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`input`,this._onInput),this.removeEventListener(`mousemove`,this._onMouseMove)}};(0,t.defineElement)(`wui-context-menu`,A),e.WuiContextMenu=A})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.isDrawn,WeborityUiElementsInternal.modules.menuKeyNav,WeborityUiElementsInternal.modules.nativeOverlay);
1
+ (function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.171.1`)throw Error(`[webority-ui] context-menu expects ui-elements 0.171.1 but the page loaded `+s+`.`);var c=`[role="menuitem"]`,l=`.wui-context-menu-sub`,u=`input.wui-context-menu-search`,d=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,f=500,p=10,m=400,h=null,g=null,_=0;function v(e,t,n){let r=document.createElement(`span`);return r.setAttribute(`aria-hidden`,`true`),r.style.cssText=n?`position:absolute;left:${e+window.scrollX}px;top:${t+window.scrollY}px;width:0;height:0;`:`position:fixed;left:${e}px;top:${t}px;width:0;height:0;`,document.body.append(r),r}var y=new WeakMap;function b(e,t,n){let r=y.get(e);if(r){if(r.region===t||t.contains(r.region))return!1;r.cancel()}return y.set(e,{region:t,cancel:n}),!0}var x=e=>e instanceof Element?e:e instanceof Node?e.parentElement:null,S=e=>`focus`in e,C=e=>[...e.childNodes].filter(e=>e.nodeType===Node.TEXT_NODE||e instanceof Element&&!e.matches(`.wui-context-menu-hint, .wui-context-menu-tick`)).map(e=>e.textContent).join(``),w=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),T=e=>[...e.children].filter(e=>e instanceof HTMLElement),E=(e,t)=>{let n=e.children[t];if(!(n instanceof HTMLElement))throw Error(`a submenu holds its opener and then its panel`);return n},D=e=>E(e,0),O=e=>E(e,1),k=(e,t)=>{let n=e?.closest(t);return n instanceof HTMLElement?n:null},A=class extends n.ElementBase{_region;_origin;_returnFocus;_press;_swallowClick;_unbindKeys;_anchor;_closingByKey;_onContextMenu;_onContextMenuCapture;_onDocKeyDown;_onDocClick;_onPointerDown;_onPressMove;_onPressEnd;_onClickCapture;_onKeyDown;_onClick;_onInput;_onMouseMove;_onDismiss;_onPointerDownCapture;static get observedAttributes(){return[`disabled`,`open`]}constructor(){super(),this._region=null,this._origin=null,this._returnFocus=null,this._press=null,this._swallowClick=!1,this._unbindKeys=null,this._anchor=null,this._closingByKey=!1,this._onContextMenu=e=>this._handleContextMenu(e),this._onContextMenuCapture=e=>{this.isOpen&&!this._inPanel(e.target)&&!this._isKeyEcho()&&this.close()},this._onDocKeyDown=e=>this._handleDocKeyDown(e),this._onDocClick=e=>this._handleDocClick(e),this._onPointerDown=e=>this._handlePointerDown(e),this._onPressMove=e=>{this._press&&Math.hypot(e.clientX-this._press.x,e.clientY-this._press.y)>p&&this._cancelPress()},this._onPressEnd=()=>this._cancelPress(),this._onClickCapture=e=>{if(this._swallowClick&&this._region){if(!(e.target instanceof Node))throw Error(`a click target is always a node`);this._region.contains(e.target)&&(this._swallowClick=!1,e.preventDefault(),e.stopImmediatePropagation())}},this._onKeyDown=e=>{if(this.isOpen&&this._inPanel(e.target)){if(e.key===`Escape`){if(e.stopPropagation(),this.hasAttribute(`open`)&&k(x(e.target),`[role="menu"]`)===this._panel()){e.preventDefault(),this.close(!0);return}this._closingByKey=!0}this._handleMenuKey(e)}},this._onClick=e=>this._handleClick(e),this._onInput=e=>this._handleInput(e),this._onMouseMove=e=>{let t=k(x(e.target),c);t&&this._inPanel(t)&&!this._isDisabled(t)&&t!==document.activeElement&&t.focus({preventScroll:!0})},this._onDismiss=e=>{this.hasAttribute(`open`)||e.type===`scroll`&&this._inPanel(e.target)||this.close()},this._onPointerDownCapture=()=>{this._swallowClick=!1}}connectedCallback(){this._teardown(),document.addEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.addEventListener(`contextmenu`,this._onContextMenu),document.addEventListener(`keydown`,this._onDocKeyDown),document.addEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.addEventListener(`pointerdown`,this._onPointerDown),document.addEventListener(`click`,this._onClickCapture,!0),document.addEventListener(`click`,this._onDocClick),window.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick),this.addEventListener(`input`,this._onInput),this.addEventListener(`mousemove`,this._onMouseMove),this._syncOpen()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){e===`open`?this.isConnected&&this._syncOpen():this.disabled&&this.close()}get target(){return this.getAttribute(`target`)}set target(e){e==null||e===``?this.removeAttribute(`target`):this.setAttribute(`target`,String(e))}get disabled(){return this.hasAttribute(`disabled`)}set disabled(e){this.toggleAttribute(`disabled`,!!e)}get isOpen(){let e=this._panel();return!!e&&(0,o.isPopoverOpen)(e)}open(e,t,{region:n=this,origin:r=n,trigger:i=null,keyboard:s=!1}={}){let c=this._panel();if(!c)return!1;let l=new CustomEvent(`wui-context-menu:beforeopen`,{bubbles:!0,cancelable:!0,detail:{region:n,origin:r,trigger:i}});if(this.dispatchEvent(l),l.defaultPrevented)return!1;if(this._decorate(c),h&&h!==this&&h.close(!0),!this.isOpen){let e=document.activeElement;this._returnFocus=e&&e!==document.body&&!this._inPanel(e)&&S(e)?e:null}this._region=n,this._origin=r,g=null,h=this,this._unbindKeys?.(),this._unbindKeys=(0,a.bindMenuKeys)(c,{items:()=>this._menuRows()}),this._anchor?.remove();let u=this.hasAttribute(`open`);return this._anchor=v(e,t,u),(0,o.openAnchoredPopover)(this._anchor,c,{mode:u?`manual`:`auto`,keepOffscreen:u,clampHeight:!0,onClosed:()=>this._onPanelClosed()}),window.addEventListener(`scroll`,this._onDismiss,!0),window.addEventListener(`resize`,this._onDismiss),window.addEventListener(`blur`,this._onDismiss),queueMicrotask(()=>{(0,o.isPopoverOpen)(c)&&((s?this._rowsOf(c)[0]:null)??c).focus({preventScroll:!0})}),this.dispatchEvent(new CustomEvent(`wui-context-menu:open`,{bubbles:!0,detail:{region:n,origin:r,x:e,y:t}})),!0}_syncOpen(){if(!this.hasAttribute(`open`)){this.close(this._inPanel(document.activeElement));return}let e=this.target?document.querySelector(this.target):this,t=e&&this._regionRect(e);e&&t&&this.open(t.left,t.top,{region:e,origin:e})}_regionRect(e){if(e!==this)return e.getBoundingClientRect();let t=[...this.children].filter(e=>e!==this._panel()).map(e=>e.getBoundingClientRect());return t.length?{left:Math.min(...t.map(e=>e.left)),top:Math.min(...t.map(e=>e.top))}:null}close(e=!1){let t=this._panel();t&&(0,o.isPopoverOpen)(t)&&(e&&(this._closingByKey=!0),(0,o.closeAnchoredPopover)(t))}_finish(e){let t=this._panel();if(t)for(let e of w(t,l))this._setSub(e,!1);h===this&&(h=null),window.removeEventListener(`scroll`,this._onDismiss,!0),window.removeEventListener(`resize`,this._onDismiss),window.removeEventListener(`blur`,this._onDismiss),this._unbindKeys?.(),this._unbindKeys=null,this._anchor?.remove(),this._anchor=null;let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&n.focus({preventScroll:!0})}_onPanelClosed(){let e=this._panel();if(!e||(0,o.isPopoverOpen)(e))return;let t=this._closingByKey;this._closingByKey=!1,this._finish(t)}_menuRows(){let e=x(document.activeElement);if(!e||e.matches(u))return[];let t=k(e,`[role="menu"]`);return t?this._rowsOf(t):[]}_panel(){return T(this).find(e=>e.getAttribute(`role`)===`menu`)??null}_inPanel(e){return e instanceof Node&&!!this._panel()?.contains(e)}_rowsOf(e){return e?w(e,c).filter(t=>t.closest(`[role="menu"]`)===e&&!this._isDisabled(t)&&(0,i.isDrawn)(t)):[]}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_regionFor(e){let t=x(e);if(!t||this.disabled||!this._panel()||this._inPanel(t)||t.closest(d))return null;let n=this.target;return n?t.closest(n):this.contains(t)?this:null}_triggerFor(e){let t=x(e),n=this.getAttribute(`trigger`);if(!t||!n||this._inPanel(t))return null;let r=k(t,n),i=r&&this._regionFor(r);return r&&i?{trigger:r,region:i}:null}_isKeyEcho(){return g?.menu===this&&this.isOpen&&performance.now()-g.at<m}_handleContextMenu(e){if(this._inPanel(e.target)){e.preventDefault();return}if(e.defaultPrevented&&!y.has(e))return;let t=this._regionFor(e.target);t&&(this._isKeyEcho()?e.preventDefault():e.shiftKey||b(e,t,()=>this.close(!0))&&this.open(e.clientX,e.clientY,{region:t,origin:x(e.target)})&&e.preventDefault())}_handleDocKeyDown(e){if(e.defaultPrevented&&!y.has(e))return;if((0,r.isImeSafeEnter)(e)){let t=this._triggerFor(e.target);if(!t||!b(e,t.region,()=>this.close(!0)))return;e.preventDefault(),t.trigger.click();return}if(!(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey)||this._inPanel(e.target))return;let t=this._regionFor(e.target);if(!t||!b(e,t,()=>this.close(!0)))return;let n=x(e.target);if(!n)return;let i=n.getBoundingClientRect();this.open(i.left+Math.min(16,i.width/2),i.bottom,{region:t,origin:n,keyboard:!0})&&(e.preventDefault(),g={menu:this,at:performance.now()})}_handleDocClick(e){let t=this._triggerFor(e.target);if(!t||!b(e,t.region,()=>this.close(!0)))return;let n=t.trigger.getBoundingClientRect();this.open(n.left,n.bottom,{region:t.region,origin:t.trigger,trigger:t.trigger,keyboard:e.detail===0})}_handlePointerDown(e){if(e.pointerType!==`touch`)return;let t=this._regionFor(e.target);if(!t||!b(e,t,()=>this._cancelPress()))return;this._cancelPress();let{clientX:n,clientY:r}=e,i=x(e.target);this._press={x:n,y:r,timer:setTimeout(()=>{this._cancelPress(),this.open(n,r,{region:t,origin:i})&&(this._swallowClick=!0)},f)},document.addEventListener(`pointermove`,this._onPressMove,{passive:!0}),document.addEventListener(`pointerup`,this._onPressEnd),document.addEventListener(`pointercancel`,this._onPressEnd),window.addEventListener(`scroll`,this._onPressEnd,!0)}_cancelPress(){this._press&&(clearTimeout(this._press.timer),this._press=null,document.removeEventListener(`pointermove`,this._onPressMove),document.removeEventListener(`pointerup`,this._onPressEnd),document.removeEventListener(`pointercancel`,this._onPressEnd),window.removeEventListener(`scroll`,this._onPressEnd,!0))}_handleMenuKey(e){if(!this.isOpen)return;let t=x(e.target);if(!t)return;if(t.matches(u)){this._handleSearchKey(e,t);return}let n=k(t,`[role="menu"]`);if(!n)return;let i=k(t,c),a=n.matches(`.wui-context-menu-subpanel`)?n.parentElement:null;if(e.key===`Tab`)this.close(!0);else if(e.key===`ArrowRight`){let t=i&&this._subOf(i);if(!t)return;e.preventDefault(),this._openSub(t,!0)}else if(e.key===`ArrowLeft`){if(!a)return;e.preventDefault(),this._closeSubByKey(a)}else((0,r.isImeSafeEnter)(e)||e.key===` `)&&(e.preventDefault(),i?.click())}_handleSearchKey(e,t){let n=k(t,l);if(!n)return;let r=this._rowsOf(O(n));e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closeSubByKey(n)):e.key===`ArrowDown`?(e.preventDefault(),r[0]?.focus({preventScroll:!0})):e.key===`ArrowUp`?(e.preventDefault(),r[r.length-1]?.focus({preventScroll:!0})):e.key===`Tab`&&this.close(!0)}_subOf(e){return e.hasAttribute(`aria-haspopup`)&&e.parentElement?.matches(l)?e.parentElement:null}_openSub(e,t){let n=e.parentElement;if(!n)throw Error(`a submenu is always inside its menu panel`);for(let t of T(n))t!==e&&t.matches(l)&&this._closeSub(t);this._setSub(e,!0);let r=O(e).querySelector(`:scope > ${u}`),i=e.hasAttribute(`data-searchable`)&&r instanceof HTMLInputElement?r:null;i?(i.value=``,this._filter(e,``),i.focus({preventScroll:!0})):t&&this._rowsOf(O(e))[0]?.focus({preventScroll:!0})}_closeSub(e){for(let t of w(O(e),l))this._setSub(t,!1);this._setSub(e,!1)}_closeSubByKey(e){this._closeSub(e),D(e).focus({preventScroll:!0})}_setSub(e,t){let n=O(e);t?((0,o.openAnchoredPopover)(D(e),n,{mode:`auto`,beside:!0,onClosed:()=>this._onSubClosed(e)}),D(e).setAttribute(`aria-expanded`,String((0,o.isPopoverOpen)(n)))):(0,o.isPopoverOpen)(n)?(0,o.closeAnchoredPopover)(n):this._onSubClosed(e)}_onSubClosed(e){let t=O(e);if((0,o.isPopoverOpen)(t))return;let n=D(e);n.setAttribute(`aria-expanded`,`false`),t.removeAttribute(`data-side`);let r=this._closingByKey;this._closingByKey=!1,r&&n.focus({preventScroll:!0})}_filter(e,t){let n=t.trim().toLowerCase();for(let t of T(O(e)))t.tagName===`HR`?t.hidden=n!==``:t.matches(c)?t.hidden=n!==``&&!C(t).toLowerCase().includes(n):t.matches(l)&&(t.hidden=n!==``&&!C(D(t)).toLowerCase().includes(n))}_handleInput(e){let t=x(e.target)?.closest(u);if(!(t instanceof HTMLInputElement))return;let n=k(t,l);n?.hasAttribute(`data-searchable`)&&this._inPanel(n)&&this._filter(n,t.value)}_decorate(e){for(let t of w(e,c)){let e=t.getAttribute(`aria-checked`)===`true`,n=t.querySelector(`:scope > .wui-context-menu-tick`);if(e&&!n){let e=document.createElement(`span`);e.className=`wui-context-menu-tick`,e.setAttribute(`aria-hidden`,`true`),t.prepend(e)}else!e&&n&&n.remove();let r=t.querySelector(`:scope > .wui-context-menu-hint`),i=t.dataset.hint;if(i){let e=r??document.createElement(`span`);r||(e.className=`wui-context-menu-hint`,e.id=`wui-context-menu-hint-${++_}`,t.append(e)),e.textContent=i,t.setAttribute(`aria-describedby`,e.id)}else r&&(r.remove(),t.removeAttribute(`aria-describedby`))}}_handleClick(e){let t=k(x(e.target),c);if(!t||!this._inPanel(t))return;if(this._isDisabled(t)){e.preventDefault(),e.stopPropagation();return}let n=this._subOf(t);n?(e.preventDefault(),this._openSub(n,e.detail===0)):(this.close(!0),this.dispatchEvent(new CustomEvent(`wui-context-menu:select`,{bubbles:!0,detail:{key:t.dataset.key??null,item:t,region:this._region,origin:this._origin}})))}_teardown(){let e=this._panel();if(this._closingByKey=!1,e){for(let t of[...w(e,l)].reverse())(0,o.closeAnchoredPopover)(O(t));(0,o.closeAnchoredPopover)(e)}this._anchor&&this._finish(!1),this._cancelPress(),document.removeEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.removeEventListener(`contextmenu`,this._onContextMenu),document.removeEventListener(`keydown`,this._onDocKeyDown),document.removeEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.removeEventListener(`pointerdown`,this._onPointerDown),document.removeEventListener(`click`,this._onClickCapture,!0),document.removeEventListener(`click`,this._onDocClick),window.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`input`,this._onInput),this.removeEventListener(`mousemove`,this._onMouseMove)}};(0,t.defineElement)(`wui-context-menu`,A),e.WuiContextMenu=A})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.isDrawn,WeborityUiElementsInternal.modules.menuKeyNav,WeborityUiElementsInternal.modules.nativeOverlay);
@@ -1,4 +1,4 @@
1
- (function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=globalThis.WeborityUiElementsInternal?.version;if(f!==`0.170.1`)throw Error(`[webority-ui] date-range expects ui-elements 0.170.1 but the page loaded `+f+`.`);var p={clearLabel:`Clear`,endLabel:`End`,helpLabel:`More information`,last30DaysLabel:`Last 30 days`,last7DaysLabel:`Last 7 days`,lastMonthLabel:`Last month`,nextMonthLabel:`Next month`,optionalLabel:`(optional)`,pickEndDateLabel:`Pick an end date`,pickStartDateLabel:`Pick a start date`,placeholder:`Start to End`,previousMonthLabel:`Previous month`,quickRangesLabel:`Quick ranges`,rangeText:`{start} to {end}`,startLabel:`Start`,thisFinancialYearLabel:`This financial year`,thisMonthLabel:`This month`,todayLabel:`Today`,yesterdayLabel:`Yesterday`},m=4,h=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],g={today:`todayLabel`,yesterday:`yesterdayLabel`,last7Days:`last7DaysLabel`,last30Days:`last30DaysLabel`,thisMonth:`thisMonthLabel`,lastMonth:`lastMonthLabel`,thisFinancialYear:`thisFinancialYearLabel`},_=e=>String(e).padStart(2,`0`),v=e=>`${e.getUTCFullYear()}-${_(e.getUTCMonth()+1)}-${_(e.getUTCDate())}`;function y(e){return h.includes(e)}function b(e,t=new Date,{timeZone:r=a.IST_TIME_ZONE,financialYearStart:o=m}={}){if(!y(e))return null;let s=(0,n.parseIso)((0,a.todayIn)(r,t));if(!s)throw Error(`today missing`);let{y:c,m:l,d:u}=s,d=(e,t,n)=>v(new Date(Date.UTC(e,t,n))),f=(0,i.readText)(`dateRangePicker`,p)[g[e]];switch(e){case`today`:return{label:f,start:d(c,l,u),end:d(c,l,u)};case`yesterday`:return{label:f,start:d(c,l,u-1),end:d(c,l,u-1)};case`last7Days`:return{label:f,start:d(c,l,u-6),end:d(c,l,u)};case`last30Days`:return{label:f,start:d(c,l,u-29),end:d(c,l,u)};case`thisMonth`:return{label:f,start:d(c,l,1),end:d(c,l+1,0)};case`lastMonth`:return{label:f,start:d(c,l-1,1),end:d(c,l,0)};case`thisFinancialYear`:{let e=o-1,t=l>=e?c:c-1;return{label:f,start:d(t,e,1),end:d(t+1,e,0)}}default:return null}}function x(e){(0,r.devWarn)(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function S(e){return typeof e==`object`&&!!e}function C(e,t=new Date,r={}){let i=String(e??``).trim();if(!i)return[];let a;if(i.startsWith(`[`))try{a=JSON.parse(i)}catch{return x(`the attribute is not valid JSON`),[]}else a=i.split(`,`).map(e=>e.trim());let o=[];for(let e of a)if(typeof e==`string`){let n=b(e,t,r);n?o.push(n):x(`"${e}" is not one of ${h.join(`, `)}`)}else S(e)&&typeof e.label==`string`&&e.label&&typeof e.start==`string`&&typeof e.end==`string`&&(0,n.parseIso)(e.start)&&(0,n.parseIso)(e.end)?o.push({label:e.label,start:e.start,end:e.end}):x(`an item needs a label and ISO start and end dates, or a preset name`);return o}var w=()=>(0,i.readText)(`dateRangePicker`,p);function T(e){if(!(e.target instanceof Element))throw Error(`Expected the event target to be an element.`);return e.target}function E(e,t){return[...e.querySelectorAll(t)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`Expected every "${t}" to be an HTML element.`);return e})}var D=class extends o.ElementBase{static formAssociated=!0;_internals;_start;_end;_hover;_viewY;_viewM;get open(){return this.querySelector(`.daterange`)?.classList.contains(`open`)??!1}set open(e){e?!(0,s.isInert)(this)&&!this.open&&this._open?.():this.open&&this._close?.()}static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`time-zone`,`financial-year-start`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){e===`aria-invalid`?this._syncInvalid():this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){return(0,n.firstWeekday)(this)}_label(){let e=this.getAttribute(`placeholder`)||w().placeholder;return!this._start&&!this._end?{text:e,empty:!0}:{text:(0,i.fillText)(w().rangeText,{start:(0,n.fmt)(this._start)||w().startLabel,end:(0,n.fmt)(this._end)||w().endLabel}),empty:!1}}render(){this._dropPanel(),this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=(0,n.parseIso)(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),r=t===`sm`?` wui-input-sm`:t===`lg`?` wui-input-lg`:t===`xl`?` wui-input-xl`:``,{text:i,empty:a}=this._label(),o=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
1
+ (function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=globalThis.WeborityUiElementsInternal?.version;if(f!==`0.171.1`)throw Error(`[webority-ui] date-range expects ui-elements 0.171.1 but the page loaded `+f+`.`);var p={clearLabel:`Clear`,endLabel:`End`,helpLabel:`More information`,last30DaysLabel:`Last 30 days`,last7DaysLabel:`Last 7 days`,lastMonthLabel:`Last month`,nextMonthLabel:`Next month`,optionalLabel:`(optional)`,pickEndDateLabel:`Pick an end date`,pickStartDateLabel:`Pick a start date`,placeholder:`Start to End`,previousMonthLabel:`Previous month`,quickRangesLabel:`Quick ranges`,rangeText:`{start} to {end}`,startLabel:`Start`,thisFinancialYearLabel:`This financial year`,thisMonthLabel:`This month`,todayLabel:`Today`,yesterdayLabel:`Yesterday`},m=4,h=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],g={today:`todayLabel`,yesterday:`yesterdayLabel`,last7Days:`last7DaysLabel`,last30Days:`last30DaysLabel`,thisMonth:`thisMonthLabel`,lastMonth:`lastMonthLabel`,thisFinancialYear:`thisFinancialYearLabel`},_=e=>String(e).padStart(2,`0`),v=e=>`${e.getUTCFullYear()}-${_(e.getUTCMonth()+1)}-${_(e.getUTCDate())}`;function y(e){return h.includes(e)}function b(e,t=new Date,{timeZone:r=a.IST_TIME_ZONE,financialYearStart:o=m}={}){if(!y(e))return null;let s=(0,n.parseIso)((0,a.todayIn)(r,t));if(!s)throw Error(`today missing`);let{y:c,m:l,d:u}=s,d=(e,t,n)=>v(new Date(Date.UTC(e,t,n))),f=(0,i.readText)(`dateRangePicker`,p)[g[e]];switch(e){case`today`:return{label:f,start:d(c,l,u),end:d(c,l,u)};case`yesterday`:return{label:f,start:d(c,l,u-1),end:d(c,l,u-1)};case`last7Days`:return{label:f,start:d(c,l,u-6),end:d(c,l,u)};case`last30Days`:return{label:f,start:d(c,l,u-29),end:d(c,l,u)};case`thisMonth`:return{label:f,start:d(c,l,1),end:d(c,l+1,0)};case`lastMonth`:return{label:f,start:d(c,l-1,1),end:d(c,l,0)};case`thisFinancialYear`:{let e=o-1,t=l>=e?c:c-1;return{label:f,start:d(t,e,1),end:d(t+1,e,0)}}default:return null}}function x(e){(0,r.devWarn)(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function S(e){return typeof e==`object`&&!!e}function C(e,t=new Date,r={}){let i=String(e??``).trim();if(!i)return[];let a;if(i.startsWith(`[`))try{a=JSON.parse(i)}catch{return x(`the attribute is not valid JSON`),[]}else a=i.split(`,`).map(e=>e.trim());let o=[];for(let e of a)if(typeof e==`string`){let n=b(e,t,r);n?o.push(n):x(`"${e}" is not one of ${h.join(`, `)}`)}else S(e)&&typeof e.label==`string`&&e.label&&typeof e.start==`string`&&typeof e.end==`string`&&(0,n.parseIso)(e.start)&&(0,n.parseIso)(e.end)?o.push({label:e.label,start:e.start,end:e.end}):x(`an item needs a label and ISO start and end dates, or a preset name`);return o}var w=()=>(0,i.readText)(`dateRangePicker`,p);function T(e){if(!(e.target instanceof Element))throw Error(`Expected the event target to be an element.`);return e.target}function E(e,t){return[...e.querySelectorAll(t)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`Expected every "${t}" to be an HTML element.`);return e})}var D=class extends o.ElementBase{static formAssociated=!0;_internals;_start;_end;_hover;_viewY;_viewM;get open(){return this.querySelector(`.daterange`)?.classList.contains(`open`)??!1}set open(e){e?!(0,s.isInert)(this)&&!this.open&&this._open?.():this.open&&this._close?.()}static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`time-zone`,`financial-year-start`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){e===`aria-invalid`?this._syncInvalid():this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){return(0,n.firstWeekday)(this)}_label(){let e=this.getAttribute(`placeholder`)||w().placeholder;return!this._start&&!this._end?{text:e,empty:!0}:{text:(0,i.fillText)(w().rangeText,{start:(0,n.fmt)(this._start)||w().startLabel,end:(0,n.fmt)(this._end)||w().endLabel}),empty:!1}}render(){this._dropPanel(),this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=(0,n.parseIso)(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),r=t===`sm`?` wui-input-sm`:t===`lg`?` wui-input-lg`:t===`xl`?` wui-input-xl`:``,{text:i,empty:a}=this._label(),o=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
2
2
  <div class="daterange">
3
3
  <button type="button" class="input daterange-trigger${r}${a?``:` has-value`}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${o?` aria-label="${(0,d.escapeHtml)(o)}"`:``}${c?` aria-describedby="${(0,d.escapeHtml)(c)}"`:``}>
4
4
  <span data-range-label class="${a?`wui-select-placeholder`:``}">${(0,d.escapeHtml)(i)}</span>
@@ -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.170.1`)throw Error(`[webority-ui] drawer expects ui-elements 0.170.1 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
+ (function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.171.1`)throw Error(`[webority-ui] drawer expects ui-elements 0.171.1 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.170.1`)throw Error(`[webority-ui] dropdown expects ui-elements 0.170.1 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
+ (function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.171.1`)throw Error(`[webority-ui] dropdown expects ui-elements 0.171.1 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.170.1`)throw Error(`[webority-ui] entry-grid expects ui-elements 0.170.1 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,`
1
+ (function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.171.1`)throw Error(`[webority-ui] entry-grid expects ui-elements 0.171.1 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){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var u=globalThis.WeborityUiElementsInternal?.version;if(u!==`0.170.1`)throw Error(`[webority-ui] gantt expects ui-elements 0.170.1 but the page loaded `+u+`.`);var d=864e5,f={groupBarH:6,milestone:14,tierH:28,spanDays:{day:28,week:84},arrow:5,elbow:8},p={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}}},m=4,h=6,g=8,_=90,v=170,y=6.7,b=16,x=16,ee=6,S=3.5,te=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],ne=new Set([`day`,`week`,`month`]),re=new Set([`table`,`lanes`]),ie=new Set([`done`,`inProgress`,`atRisk`,`notStarted`]),ae=/^(\d{4})-(\d{2})-(\d{2})$/,oe=new Intl.DateTimeFormat(`en-CA`,{timeZone:`Asia/Kolkata`,year:`numeric`,month:`2-digit`,day:`2-digit`}),C=class extends Error{},w=e=>te[e]??``,T=e=>String(e).padStart(2,`0`),E=e=>{let t=ae.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 se(e){let t=new Date(e);return`${String(t.getUTCFullYear()).padStart(4,`0`)}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())}`}function ce(e=Date.now()){let t=oe.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 le(e,t){return e===`day`?t-8*d:e===`week`?A(`week`,t-21*d):k(t,-1)}function A(e,t){return e===`day`?t:e===`week`?t-(new Date(t).getUTCDay()+6)%7*d:k(t,0)}function j(e,t,n){return e===`month`?k(t,m/2*n):t+f.spanDays[e]/2*n*d}var M=(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+d,de=e=>e+7*d,fe=e=>k(e,1),pe=e=>Date.UTC(new Date(e).getUTCFullYear()+1,0,1);function me(e,t,n){let r=p[e].ppd[t],i=t===`month`?k(n,m):n+f.spanDays[t]*d,a=(i-n)/d,o=e=>(e-n)/d*r,s=e=>({x:o(e.start),w:(e.end-e.start)/d*r}),c=t===`month`?M(n,i,pe).map(e=>({...s(e),label:String(new Date(e.start).getUTCFullYear())})):M(n,i,fe).map(e=>{let t=s(e),n=new Date(e.start),r=w(n.getUTCMonth());return{...t,label:t.w<_?r:`${r} ${n.getUTCFullYear()}`}}),l=[];if(t===`day`)for(let e of M(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 M(n,i,de))l.push({...s(e),label:T(new Date(e.start).getUTCDate())});else for(let e of M(n,i,fe))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 N=(e,t)=>new C(`Gantt row "${e}": ${t}.`),P=(e,t,n)=>{let r=E(n);if(r===null)throw N(e,`${t} "${n}" is not a calendar day`);return r};function he(e){if(e.layout!==void 0&&!re.has(e.layout))throw new C(`Gantt layout "${e.layout}" is not table or lanes.`);if(e.zoom!==void 0&&!ne.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 N(n.key,`key is used by more than one row`);if(t.add(n.key),n.name.trim()===``)throw N(n.key,`name is empty`);if(n.end!==void 0&&n.start===void 0)throw N(n.key,`end is set without a start`);if(n.start!==void 0){let e=P(n.key,`start`,n.start);if(n.end!==void 0&&P(n.key,`end`,n.end)<e)throw N(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 N(n.key,`progress ${n.progress} is not a whole number from 0 to 100`);if(n.status!==void 0&&!ie.has(n.status))throw N(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 N(t.key,`depends on itself`);if(!n.has(e))throw N(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 N(n,`dependencies form a loop`);a===void 0&&e.push(i(n))}}}function ge(e,t,n){return y*(e.length+String(t).length+4)+b<=n?`inside`:`after`}function _e(e,t){let{arrow:n,elbow:r}=f;return{d:t.l-e.r>=x?`M${e.r} ${e.y} H${e.r+r} V${t.y} H${t.l-n}`:`M${e.r} ${e.y} H${e.r+ee} 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 F=(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 ve(e,t){let n=p[t.layout],r=me(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)+d})),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,m=0;for(let e of s){let{row:s,index:d}=e,p=s.group===void 0?void 0:c.get(s.group);if(p!==void 0&&!p.emitted){p.emitted=!0;let e=o.has(p.name),t=p.startMs!==void 0&&p.endMs!==void 0,i=p.startMs??r.startMs,c=p.endMs??r.startMs,u=r.x(i),f=r.x(c),h=t&&f>0&&u<a;l.push({row:s,kind:`group`,index:d,top:m,height:n.groupH,x:h?Math.max(u,0):0,w:h?Math.min(f,a)-Math.max(u,0):0,clippedLeft:h&&u<0,clippedRight:h&&f>a,hidden:!1,group:{name:p.name,count:p.count,percent:p.n>0?Math.round(p.sum/p.n):0,folded:e,startMs:i,endMs:c}}),m+=n.groupH}let _=s.group!==void 0&&o.has(s.group),y=e.endEx===void 0?`milestone`:`bar`;if(_){l.push(F(s,y,d,m,0));continue}let b=m;if(m+=n.rowH,e.startMs===void 0){l.push(F(s,y,d,b,n.rowH));continue}let x;if(e.endEx===void 0){let o=r.x(e.startMs)+i/2;x=o<-8||o>a+g?F(s,y,d,b,n.rowH):{row:s,kind:y,index:d,top:b,height:n.rowH,x:o,w:f.milestone,clippedLeft:!1,clippedRight:!1,hidden:!1,flip:t.layout===`lanes`&&o>a-v}}else{let i=r.x(e.startMs),o=Math.max(r.x(e.endEx)-i,h);if(i>=a||i+o<=0)x=F(s,y,d,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<h&&(c?r=Math.min(h,a):e=Math.max(0,r-h)),x={row:s,kind:y,index:d,top:b,height:n.rowH,x:e,w:r-e,clippedLeft:c,clippedRight:l,hidden:!1},t.layout===`lanes`&&(x.place=ge(s.name,s.progress??0,r-e))}}l.push(x),x.hidden||u.set(s.key,x)}let _=[];for(let e of l){if(e.kind===`group`||e.hidden)continue;let t=e.kind===`milestone`?e.x-g: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=_e({r:a.kind===`milestone`?a.x+g:a.x+a.w,y:a.top+n.rowH/2},{l:t,y:e.top+n.rowH/2});_.push({fromKey:i,toKey:e.row.key,d:o.d,head:o.head})}}return{layout:t.layout,geometry:n,axis:r,rows:l,height:m,today:{x:r.x(t.todayMs)+i/2,inWindow:t.todayMs>=r.startMs&&t.todayMs<r.endMs},arrows:_}}var ye=new Set([`pvt`,`private`,`ltd`,`limited`,`llp`,`llc`,`inc`,`corp`,`co`]),I=/\p{L}/u,be=/\p{N}/u;function xe(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 L(e,t,n){let r=e[t];if(r===void 0)throw Error(`initialsOf: the ${n} is missing`);return r}function R(e){return e.map(e=>{let t=e.toUpperCase();return Array.from(t).length===1?t:e}).join(``)}function Se(e,t=2){let n=xe(String(e??``)).split(/\s+/),r=e=>n.map(t=>Array.from(t).filter(t=>e.test(t))).filter(e=>e.length>0),i=r(I).filter(e=>!ye.has(e.join(``).toLowerCase()));if(i.length===0&&!n.some(e=>I.test(e))&&(i=r(be)),i.length===0)return``;let a=L(i,0,`first word`);if(i.length===1)return R(a.slice(0,t));let o=L(i,1,`second word`);return R([L(a,0,`first letter`),L(o,0,`second letter`)])}var Ce=`data-wui-gantt-pick`,z=(e,t,n)=>{let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.textContent=n),r},B=e=>`${e}px`,V=(e,t,n)=>{let r=z(`div`,`wui-gantt-table-cell`,n);return r.setAttribute(`role`,t),r.dataset.col=e,r};function we(e){let t=e.text,n=z(`div`,`wui-gantt-table`);n.setAttribute(`role`,`table`),n.setAttribute(`aria-label`,e.title);let r=z(`div`);r.setAttribute(`role`,`rowgroup`);let i=z(`div`,`wui-gantt-table-row`);i.dataset.kind=`head`,i.setAttribute(`role`,`row`),i.style.height=B(e.headHeight),i.append(V(`name`,`columnheader`,t.tableName),V(`owner`,`columnheader`,t.detailsOwner),V(`start`,`columnheader`,t.tableStart),V(`end`,`columnheader`,t.tableEnd),V(`done`,`columnheader`,t.detailsDone)),r.append(i);let a=z(`div`);a.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 i=z(`div`,`wui-gantt-table-row`);i.dataset.kind=`group`,i.dataset.wuiGanttGroup=r.name,i.setAttribute(`role`,`row`),i.style.height=B(n.height);let o=z(`div`,`wui-gantt-table-cell wui-gantt-table-group`);o.setAttribute(`role`,`rowheader`);let l=z(`button`,`wui-gantt-group-toggle`);l.type=`button`,l.setAttribute(`aria-expanded`,String(!r.folded)),l.setAttribute(`aria-label`,(0,c.fillText)(r.folded?t.unfoldLabel:t.foldLabel,{group:r.name})),l.setAttribute(e.focusAttr,`group:${r.name}`),l.innerHTML=(0,s.glyphSvg)(r.folded?`chevron-right`:`chevron-down`,{size:16}),o.append(l,z(`span`,null,r.name),z(`span`,null,(0,c.pluralText)(t,`groupSummary`,r.count,{percent:r.percent}))),i.append(o),a.append(i);continue}let i=z(`div`,`wui-gantt-table-row`);i.dataset.kind=r.end===void 0?`milestone`:`bar`,i.dataset.wuiGanttKey=r.key,i.dataset.wuiGanttPick=r.key,r.key===e.selected&&(i.dataset.selected=`true`),i.setAttribute(`role`,`row`),i.style.height=B(n.height);let l=V(`name`,`rowheader`,r.name);l.title=r.name;let u=V(`owner`,`cell`,``);r.owner&&(u.title=r.owner,u.innerHTML=(0,o.avatarHtml)({initials:Se(r.owner)},`avatar-xs`),u.append(z(`span`,`visually-hidden`,r.owner)));let d=V(`start`,`cell`,r.start===void 0?``:O(D(r.start))),f=V(`end`,`cell`,r.end===void 0?``:O(D(r.end))),p=V(`done`,`cell`,r.end===void 0?``:`${r.progress??0}%`);i.append(l,u,d,f,p),a.append(i)}let l=e.skeleton;for(let e=0;l&&e<l.rows;e+=1){let e=z(`div`,`wui-gantt-table-row`);e.dataset.kind=`skeleton`,e.setAttribute(`role`,`row`),e.setAttribute(`aria-hidden`,`true`),e.style.height=B(l.rowHeight);let t=z(`span`,`wui-gantt-skeleton`);t.style.height=B(l.barHeight),e.append(t),a.append(e)}return n.append(r,a),n}var Te={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`},H=()=>(0,c.readText)(`gantt`,Te),Ee=`wui-gantt:zoom-change`,De=`wui-gantt:from-change`,Oe=`wui-gantt:fold-change`,ke=`wui-gantt:select`,Ae=`wui-gantt:add-task`,je=`wui-gantt:retry`,U=`data-wui-gantt-focus`,W=`bar:`,G=`http://www.w3.org/2000/svg`,K=[`day`,`week`,`month`],q=3,Me=16,Ne=300,Pe=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`Escape`,`Enter`,` `],Fe=0,J=(e,t,n)=>{let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.textContent=n),r},Y=e=>`${e}px`;function Ie(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=H();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`,Le=(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(),Fe+=1,this.uid=`wui-gantt-${Fe}`,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(!Le(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(Ee,{zoom:e}),this._controlled?this._syncRadios():(this._zoom=e,this._fromMs=this._fromMs===null?null:A(e,this._fromMs),this._draw())}_setFrom(e){this._emit(De,{from:se(e)}),this._controlled||(this._fromMs=e,this._draw())}_setFolded(e){let t=new Set(this._folded);t.delete(e)||t.add(e),this._emit(Oe,{folded:[...t]}),this._controlled||(this._folded=t,this._draw())}_setSelected(e){this._emit(ke,{key:e}),this._focusAfter=`${W}${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=K.find(e=>e===t.value);n&&this._setZoom(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[${U}]`);if(n instanceof HTMLElement&&this.contains(n)){this._activate(n.getAttribute(U)??``,n);return}let r=t.closest(`[${Ce}]`);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(W)){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(Ae):e===`retry`?this._emit(je):n&&e===`nav:earlier`?this._setFrom(j(n.zoom,n.fromMs,-1)):n&&e===`nav:later`?this._setFrom(j(n.zoom,n.fromMs,1)):n&&e===`nav:today`?this._setFrom(le(n.zoom,n.todayMs)):e.startsWith(`zoom:`)&&t.click()}_bars(){return[...this.querySelectorAll(`.wui-gantt-lane [${U}^="${W}"]`)].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||!Pe.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(U)?.startsWith(W))return;let n=this._bars(),r=n.indexOf(t),i=t.dataset.wuiGanttKey,a=this._specRows.find(e=>e.key===i);switch(e.preventDefault(),e.key){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(U)??``,t)}}_focusToken(){let e=document.activeElement;return e instanceof HTMLElement&&this.contains(e)?e.getAttribute(U):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`,H().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(`[${U}]`)].find(t=>t.getAttribute(U)===e);n instanceof HTMLElement&&(e.startsWith(W)?this._focusBar(n):n.focus())}_compose(){let e=this._spec;if(!Ie(e))throw TypeError("<wui-gantt> has no spec: set the `spec` property or add a JSON script child.");this._seed(e),he(e);let t=e.layout??`table`,n=p[t],r=H(),i=D(e.today??ce()),a=this._zoom,o=A(a,this._fromMs??le(a,i)),s={layout:t,zoom:a,fromMs:o,todayMs:i};this._resolved=s,this._specRows=e.rows;let c=e.rows.some(e=>e.start!==void 0),l=(e.state??`ready`)===`ready`&&!c?`empty`:e.state??`ready`;this.dataset.state=l,this.dataset.zoom=a,this.dataset.layout=t,l===`loading`?this.setAttribute(`aria-busy`,`true`):this.removeAttribute(`aria-busy`);let u=l===`ready`?ve({...e,folded:[...this._folded],selected:this._selected},s):null,d=u?.axis??me(t,a,o),m=J(`div`,`wui-gantt-lane`);m.style.width=Y(d.width),u?this._fillLane(m,e,u):l===`loading`&&(m.style.height=Y(q*n.rowH));let h=[];l===`loading`&&h.push(this._fillSkeleton(m,e,n)),l===`empty`&&h.push(this._emptyBlock(e)),l===`error`&&h.push(this._stateBlock(`error`,e.errorText||r.errorText));let g=this._head(d),_=J(`div`,`wui-gantt-plot`);_.append(g,m);let v=J(`div`,`wui-gantt-scroller`);if(t===`table`){let t=we({title:e.title,rows:u?.rows??[],headHeight:2*f.tierH,selected:this._selected,text:r,focusAttr:U,skeleton:l===`loading`?{rows:q,rowHeight:n.rowH,barHeight:n.barH}:void 0});v.append(t,_)}else v.append(_);return[this._toolbar(e,l===`ready`),v,...h,this._legend(t)]}_toolbar(e,t){let n=J(`div`,`wui-gantt-toolbar`);return t&&n.append(J(`p`,`wui-gantt-count`,this._countText(e.rows))),n.append(this._scale(),this._nav()),n}_countText(e){let t=H(),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=H(),t=J(`div`,`segmented segmented-sm wui-gantt-scale`);t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,e.scaleLabel),t.append(Object.assign(J(`span`,`segmented-thumb`),{ariaHidden:`true`}));let n={day:e.dayLabel,week:e.weekLabel,month:e.monthLabel};for(let e of K){let r=J(`label`,`segmented-option`),i=J(`input`,`segmented-input`);i.type=`radio`,i.name=`${this.uid}-scale`,i.value=e,i.checked=e===this._zoom,i.setAttribute(U,`zoom:${e}`),r.append(i,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=H(),t=J(`div`,`wui-gantt-nav`),r=(e,t,r)=>{let i=J(`button`,(0,n.buttonClass)(`neutral`,`soft`,`sm`));return i.type=`button`,i.setAttribute(`aria-label`,t),i.setAttribute(U,e),i.innerHTML=(0,s.glyphSvg)(r,{size:16}),i},i=J(`button`,(0,n.buttonClass)(`neutral`,`soft`,`sm`),e.todayLabel);return i.type=`button`,i.setAttribute(U,`nav:today`),t.append(r(`nav:earlier`,e.earlierLabel,`chevron-left`),r(`nav:later`,e.laterLabel,`chevron-right`),i),t}_head(e){let t=J(`div`,`wui-gantt-head`);t.style.width=Y(e.width),t.setAttribute(`aria-hidden`,`true`);let n=(e,t)=>{let n=J(`div`,`wui-gantt-tier ${t}`);for(let t of e){let e=J(`div`,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(J(`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=H(),n=J(`div`,`wui-gantt-legend`);n.setAttribute(`role`,`list`),n.setAttribute(`aria-label`,t.legendLabel);let r=(e,t)=>{let r=J(`span`,null);r.setAttribute(`role`,`listitem`),r.append(e,t),n.append(r)};for(let e of[`done`,`inProgress`,`atRisk`,`notStarted`]){let t=J(`span`,`wui-gantt-swatch`);t.dataset.status=e,r(t,X(e))}let i=J(`span`,`wui-gantt-swatch`);if(i.dataset.kind=`milestone`,r(i,t.milestoneLabel),e===`table`){let e=J(`span`,`wui-gantt-legend-note`,t.legendRemaining);e.setAttribute(`role`,`listitem`),n.append(e)}return n}_stateBlock(e,t){let r=H(),i=J(`div`,`wui-gantt-state`);if(e===`error`){i.setAttribute(`role`,`alert`),i.append(J(`p`,null,t));let e=J(`button`,(0,n.buttonClass)(`neutral`,`soft`,`sm`),r.retryLabel);e.type=`button`,e.setAttribute(U,`retry`),i.append(e)}else i.append(J(`p`,null,t));return i}_emptyBlock(e){let t=H(),r=J(`div`,`wui-gantt-state`);if(r.append(J(`p`,`fw-semibold`,t.emptyTitle),J(`p`,null,e.emptyText||t.emptyText)),e.addTask){let e=J(`button`,(0,n.buttonClass)(`primary`,`solid`,`sm`),t.addTaskLabel);e.type=`button`,e.setAttribute(U,`add`),r.append(e)}return r}_fillSkeleton(e,t,n){let r=J(`div`,`visually-hidden`,t.loadingText||H().loadingText);r.setAttribute(`role`,`status`);for(let t=0;t<q;t+=1){let r=J(`div`,`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=H(),{axis:i}=n,a=n.layout===`table`;e.style.height=Y(n.height),e.setAttribute(`role`,`list`),e.setAttribute(`aria-label`,t.title);let o=J(`p`,`visually-hidden`,a?r.helpTextTable:r.helpText);o.id=`${this.uid}-help`,e.setAttribute(`aria-describedby`,o.id);let s=(e,t,n,r,i)=>{let a=J(`div`,e);return a.setAttribute(`aria-hidden`,`true`),a.style.left=Y(t),a.style.top=Y(n),a.style.width=Y(r),a.style.height=Y(i),a},c=[o];for(let e of n.rows){if(e.height===0)continue;let t=s(`wui-gantt-row`,0,e.top,i.width,e.height);a&&e.kind!==`group`&&e.row.key===this._selected&&(t.dataset.selected=`true`),c.push(t)}for(let e of i.weekendX)c.push(s(`wui-gantt-weekend`,e,0,i.ppd,n.height));for(let e of i.gridX)c.push(s(`wui-gantt-grid`,e,0,1,n.height));if(n.today.inWindow){c.push(s(`wui-gantt-today`,n.today.x-1,0,2,n.height));let e=J(`div`,`wui-gantt-today-flag rounded-pill`,r.todayLabel);e.style.left=Y(n.today.x),c.push(e)}let l=new Map(t.rows.map(e=>[e.key,e]));for(let e of n.rows){if(e.hidden)continue;let t=J(`div`,`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,l,n):this._drawBar(t,e,l,n),c.push(t)}c.push(this._deps(n)),this._card=a?null:this._details(n,l),e.append(...c);let u=e.querySelector(`[${U}^="${W}"]`);u instanceof HTMLElement&&(u.tabIndex=0)}_names(e,t){return(e.dependsOn??[]).map(e=>t.get(e)?.name??e).join(`, `)}_barSentence(e,t){let n=H(),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 i=J(`button`,t);i.type=`button`;let a=this._barSentence(e,n);return i.setAttribute(`aria-label`,a),i.title=a,i.tabIndex=-1,i.dataset.status=Q(e),i.dataset.wuiGanttKey=e.key,i.setAttribute(U,`${W}${e.key}`),r?i.setAttribute(`aria-pressed`,String(this._selected===e.key)):i.setAttribute(`aria-expanded`,String(this._selected===e.key)),this._selected===e.key&&(i.dataset.selected=`true`),i}_afterLabel(e,t,n,r){let i=J(`span`,`wui-gantt-label wui-gantt-label-surface`,e);return i.style.left=Y(t),i.style.top=Y(n),i.style.height=Y(r),i}_drawBar(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=this._focusable(i,`wui-gantt-bar rounded-2`,n,o),c=t.top+a.barTop;s.style.left=Y(t.x),s.style.width=Y(t.w),s.style.top=Y(c),s.style.height=Y(a.barH);let l=Z(i),u=J(`span`,`wui-gantt-bar-progress`);if(u.style.width=`${l}%`,s.append(u),e.append(s),o)return;let d=`${i.name} ${l}%`;t.place===`inside`?s.append(J(`span`,`wui-gantt-bar-label`,d)):e.append(this._afterLabel(d,t.x+t.w+Me,c,a.barH))}_drawMilestone(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=f.milestone/2,c=t.top+(a.rowH-f.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(f.milestone),l.style.height=Y(f.milestone),e.append(l),o)return;let u=this._afterLabel(`${i.name}, ${O(D(i.start??``))}`,t.x+f.milestone,t.top+a.barTop,a.barH);t.flip&&(u.style.left=``,u.style.right=Y(r.axis.width-(t.x-f.milestone))),e.append(u)}_drawGroup(e,t,n){let r=H(),i=t.group;if(!i)return;if(n.layout===`lanes`){let n=J(`div`,`wui-gantt-group wui-gantt-label wui-gantt-label-surface`);n.dataset.wuiGanttGroup=i.name,n.style.left=Y(8),n.style.top=Y(t.top+6);let a=J(`button`,`wui-gantt-group-toggle`);a.type=`button`,a.setAttribute(`aria-expanded`,String(!i.folded)),a.setAttribute(`aria-label`,(0,c.fillText)(i.folded?r.unfoldLabel:r.foldLabel,{group:i.name})),a.setAttribute(U,`group:${i.name}`),a.innerHTML=(0,s.glyphSvg)(i.folded?`chevron-right`:`chevron-down`,{size:16}),n.append(a,J(`span`,null,i.name),J(`span`,null,(0,c.pluralText)(r,`groupSummary`,i.count,{percent:i.percent}))),e.append(n)}let a=J(`div`,`wui-gantt-group-summary`);a.dataset.wuiGanttGroup=i.name,a.style.left=Y(t.x),a.style.width=Y(t.w),a.style.top=Y(t.top+n.geometry.groupBarTop),a.style.height=Y(f.groupBarH),e.append(a)}_deps(e){let t=document.createElementNS(G,`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(G,`path`);e.setAttribute(`d`,n.d),e.setAttribute(`fill`,`none`);let r=document.createElementNS(G,`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,i=r===null?void 0:e.rows.find(e=>e.row.key===r&&e.kind!==`group`&&!e.hidden);if(!i)return null;let a=H(),{row:o}=i,s=J(`div`,`wui-gantt-details`);s.setAttribute(`role`,`group`),s.setAttribute(`aria-label`,o.name),s.style.width=Y(Ne);let l=J(`dl`),u=(e,t)=>{l.append(J(`dt`,null,e),J(`dd`,null,t))},d=O(D(o.start??``));o.owner&&u(a.detailsOwner,o.owner),u(a.detailsDates,o.end===void 0?d:(0,c.fillText)(a.detailsRange,{start:d,end:O(D(o.end))})),o.end!==void 0&&u(a.detailsDone,`${Z(o)}%, ${X(Q(o))}`);let f=this._names(o,t);f&&u(a.detailsStartsAfter,f);let p=J(`button`,(0,n.buttonClass)(`neutral`,`ghost`,`sm`),a.detailsCloseLabel);return p.type=`button`,p.setAttribute(U,`close`),s.append(J(`h3`,`h6`,o.name),l,p),s}};(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.avatarHtml,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.nativeOverlay);
1
+ (function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var u=globalThis.WeborityUiElementsInternal?.version;if(u!==`0.171.1`)throw Error(`[webority-ui] gantt expects ui-elements 0.171.1 but the page loaded `+u+`.`);var d=864e5,f={groupBarH:6,milestone:14,tierH:28,spanDays:{day:28,week:84},arrow:5,elbow:8},p={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}}},m=4,h=6,g=8,_=90,v=170,y=6.7,b=16,x=16,ee=6,S=3.5,te=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],ne=new Set([`day`,`week`,`month`]),re=new Set([`table`,`lanes`]),ie=new Set([`done`,`inProgress`,`atRisk`,`notStarted`]),ae=/^(\d{4})-(\d{2})-(\d{2})$/,oe=new Intl.DateTimeFormat(`en-CA`,{timeZone:`Asia/Kolkata`,year:`numeric`,month:`2-digit`,day:`2-digit`}),C=class extends Error{},w=e=>te[e]??``,T=e=>String(e).padStart(2,`0`),E=e=>{let t=ae.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 se(e){let t=new Date(e);return`${String(t.getUTCFullYear()).padStart(4,`0`)}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())}`}function ce(e=Date.now()){let t=oe.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 le(e,t){return e===`day`?t-8*d:e===`week`?A(`week`,t-21*d):k(t,-1)}function A(e,t){return e===`day`?t:e===`week`?t-(new Date(t).getUTCDay()+6)%7*d:k(t,0)}function j(e,t,n){return e===`month`?k(t,m/2*n):t+f.spanDays[e]/2*n*d}var M=(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+d,de=e=>e+7*d,fe=e=>k(e,1),pe=e=>Date.UTC(new Date(e).getUTCFullYear()+1,0,1);function me(e,t,n){let r=p[e].ppd[t],i=t===`month`?k(n,m):n+f.spanDays[t]*d,a=(i-n)/d,o=e=>(e-n)/d*r,s=e=>({x:o(e.start),w:(e.end-e.start)/d*r}),c=t===`month`?M(n,i,pe).map(e=>({...s(e),label:String(new Date(e.start).getUTCFullYear())})):M(n,i,fe).map(e=>{let t=s(e),n=new Date(e.start),r=w(n.getUTCMonth());return{...t,label:t.w<_?r:`${r} ${n.getUTCFullYear()}`}}),l=[];if(t===`day`)for(let e of M(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 M(n,i,de))l.push({...s(e),label:T(new Date(e.start).getUTCDate())});else for(let e of M(n,i,fe))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 N=(e,t)=>new C(`Gantt row "${e}": ${t}.`),P=(e,t,n)=>{let r=E(n);if(r===null)throw N(e,`${t} "${n}" is not a calendar day`);return r};function he(e){if(e.layout!==void 0&&!re.has(e.layout))throw new C(`Gantt layout "${e.layout}" is not table or lanes.`);if(e.zoom!==void 0&&!ne.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 N(n.key,`key is used by more than one row`);if(t.add(n.key),n.name.trim()===``)throw N(n.key,`name is empty`);if(n.end!==void 0&&n.start===void 0)throw N(n.key,`end is set without a start`);if(n.start!==void 0){let e=P(n.key,`start`,n.start);if(n.end!==void 0&&P(n.key,`end`,n.end)<e)throw N(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 N(n.key,`progress ${n.progress} is not a whole number from 0 to 100`);if(n.status!==void 0&&!ie.has(n.status))throw N(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 N(t.key,`depends on itself`);if(!n.has(e))throw N(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 N(n,`dependencies form a loop`);a===void 0&&e.push(i(n))}}}function ge(e,t,n){return y*(e.length+String(t).length+4)+b<=n?`inside`:`after`}function _e(e,t){let{arrow:n,elbow:r}=f;return{d:t.l-e.r>=x?`M${e.r} ${e.y} H${e.r+r} V${t.y} H${t.l-n}`:`M${e.r} ${e.y} H${e.r+ee} 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 F=(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 ve(e,t){let n=p[t.layout],r=me(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)+d})),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,m=0;for(let e of s){let{row:s,index:d}=e,p=s.group===void 0?void 0:c.get(s.group);if(p!==void 0&&!p.emitted){p.emitted=!0;let e=o.has(p.name),t=p.startMs!==void 0&&p.endMs!==void 0,i=p.startMs??r.startMs,c=p.endMs??r.startMs,u=r.x(i),f=r.x(c),h=t&&f>0&&u<a;l.push({row:s,kind:`group`,index:d,top:m,height:n.groupH,x:h?Math.max(u,0):0,w:h?Math.min(f,a)-Math.max(u,0):0,clippedLeft:h&&u<0,clippedRight:h&&f>a,hidden:!1,group:{name:p.name,count:p.count,percent:p.n>0?Math.round(p.sum/p.n):0,folded:e,startMs:i,endMs:c}}),m+=n.groupH}let _=s.group!==void 0&&o.has(s.group),y=e.endEx===void 0?`milestone`:`bar`;if(_){l.push(F(s,y,d,m,0));continue}let b=m;if(m+=n.rowH,e.startMs===void 0){l.push(F(s,y,d,b,n.rowH));continue}let x;if(e.endEx===void 0){let o=r.x(e.startMs)+i/2;x=o<-8||o>a+g?F(s,y,d,b,n.rowH):{row:s,kind:y,index:d,top:b,height:n.rowH,x:o,w:f.milestone,clippedLeft:!1,clippedRight:!1,hidden:!1,flip:t.layout===`lanes`&&o>a-v}}else{let i=r.x(e.startMs),o=Math.max(r.x(e.endEx)-i,h);if(i>=a||i+o<=0)x=F(s,y,d,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<h&&(c?r=Math.min(h,a):e=Math.max(0,r-h)),x={row:s,kind:y,index:d,top:b,height:n.rowH,x:e,w:r-e,clippedLeft:c,clippedRight:l,hidden:!1},t.layout===`lanes`&&(x.place=ge(s.name,s.progress??0,r-e))}}l.push(x),x.hidden||u.set(s.key,x)}let _=[];for(let e of l){if(e.kind===`group`||e.hidden)continue;let t=e.kind===`milestone`?e.x-g: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=_e({r:a.kind===`milestone`?a.x+g:a.x+a.w,y:a.top+n.rowH/2},{l:t,y:e.top+n.rowH/2});_.push({fromKey:i,toKey:e.row.key,d:o.d,head:o.head})}}return{layout:t.layout,geometry:n,axis:r,rows:l,height:m,today:{x:r.x(t.todayMs)+i/2,inWindow:t.todayMs>=r.startMs&&t.todayMs<r.endMs},arrows:_}}var ye=new Set([`pvt`,`private`,`ltd`,`limited`,`llp`,`llc`,`inc`,`corp`,`co`]),I=/\p{L}/u,be=/\p{N}/u;function xe(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 L(e,t,n){let r=e[t];if(r===void 0)throw Error(`initialsOf: the ${n} is missing`);return r}function R(e){return e.map(e=>{let t=e.toUpperCase();return Array.from(t).length===1?t:e}).join(``)}function Se(e,t=2){let n=xe(String(e??``)).split(/\s+/),r=e=>n.map(t=>Array.from(t).filter(t=>e.test(t))).filter(e=>e.length>0),i=r(I).filter(e=>!ye.has(e.join(``).toLowerCase()));if(i.length===0&&!n.some(e=>I.test(e))&&(i=r(be)),i.length===0)return``;let a=L(i,0,`first word`);if(i.length===1)return R(a.slice(0,t));let o=L(i,1,`second word`);return R([L(a,0,`first letter`),L(o,0,`second letter`)])}var Ce=`data-wui-gantt-pick`,z=(e,t,n)=>{let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.textContent=n),r},B=e=>`${e}px`,V=(e,t,n)=>{let r=z(`div`,`wui-gantt-table-cell`,n);return r.setAttribute(`role`,t),r.dataset.col=e,r};function we(e){let t=e.text,n=z(`div`,`wui-gantt-table`);n.setAttribute(`role`,`table`),n.setAttribute(`aria-label`,e.title);let r=z(`div`);r.setAttribute(`role`,`rowgroup`);let i=z(`div`,`wui-gantt-table-row`);i.dataset.kind=`head`,i.setAttribute(`role`,`row`),i.style.height=B(e.headHeight),i.append(V(`name`,`columnheader`,t.tableName),V(`owner`,`columnheader`,t.detailsOwner),V(`start`,`columnheader`,t.tableStart),V(`end`,`columnheader`,t.tableEnd),V(`done`,`columnheader`,t.detailsDone)),r.append(i);let a=z(`div`);a.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 i=z(`div`,`wui-gantt-table-row`);i.dataset.kind=`group`,i.dataset.wuiGanttGroup=r.name,i.setAttribute(`role`,`row`),i.style.height=B(n.height);let o=z(`div`,`wui-gantt-table-cell wui-gantt-table-group`);o.setAttribute(`role`,`rowheader`);let l=z(`button`,`wui-gantt-group-toggle`);l.type=`button`,l.setAttribute(`aria-expanded`,String(!r.folded)),l.setAttribute(`aria-label`,(0,c.fillText)(r.folded?t.unfoldLabel:t.foldLabel,{group:r.name})),l.setAttribute(e.focusAttr,`group:${r.name}`),l.innerHTML=(0,s.glyphSvg)(r.folded?`chevron-right`:`chevron-down`,{size:16}),o.append(l,z(`span`,null,r.name),z(`span`,null,(0,c.pluralText)(t,`groupSummary`,r.count,{percent:r.percent}))),i.append(o),a.append(i);continue}let i=z(`div`,`wui-gantt-table-row`);i.dataset.kind=r.end===void 0?`milestone`:`bar`,i.dataset.wuiGanttKey=r.key,i.dataset.wuiGanttPick=r.key,r.key===e.selected&&(i.dataset.selected=`true`),i.setAttribute(`role`,`row`),i.style.height=B(n.height);let l=V(`name`,`rowheader`,r.name);l.title=r.name;let u=V(`owner`,`cell`,``);r.owner&&(u.title=r.owner,u.innerHTML=(0,o.avatarHtml)({initials:Se(r.owner)},`avatar-xs`),u.append(z(`span`,`visually-hidden`,r.owner)));let d=V(`start`,`cell`,r.start===void 0?``:O(D(r.start))),f=V(`end`,`cell`,r.end===void 0?``:O(D(r.end))),p=V(`done`,`cell`,r.end===void 0?``:`${r.progress??0}%`);i.append(l,u,d,f,p),a.append(i)}let l=e.skeleton;for(let e=0;l&&e<l.rows;e+=1){let e=z(`div`,`wui-gantt-table-row`);e.dataset.kind=`skeleton`,e.setAttribute(`role`,`row`),e.setAttribute(`aria-hidden`,`true`),e.style.height=B(l.rowHeight);let t=z(`span`,`wui-gantt-skeleton`);t.style.height=B(l.barHeight),e.append(t),a.append(e)}return n.append(r,a),n}var Te={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`},H=()=>(0,c.readText)(`gantt`,Te),Ee=`wui-gantt:zoom-change`,De=`wui-gantt:from-change`,Oe=`wui-gantt:fold-change`,ke=`wui-gantt:select`,Ae=`wui-gantt:add-task`,je=`wui-gantt:retry`,U=`data-wui-gantt-focus`,W=`bar:`,G=`http://www.w3.org/2000/svg`,K=[`day`,`week`,`month`],q=3,Me=16,Ne=300,Pe=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`Escape`,`Enter`,` `],Fe=0,J=(e,t,n)=>{let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.textContent=n),r},Y=e=>`${e}px`;function Ie(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=H();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`,Le=(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(),Fe+=1,this.uid=`wui-gantt-${Fe}`,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(!Le(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(Ee,{zoom:e}),this._controlled?this._syncRadios():(this._zoom=e,this._fromMs=this._fromMs===null?null:A(e,this._fromMs),this._draw())}_setFrom(e){this._emit(De,{from:se(e)}),this._controlled||(this._fromMs=e,this._draw())}_setFolded(e){let t=new Set(this._folded);t.delete(e)||t.add(e),this._emit(Oe,{folded:[...t]}),this._controlled||(this._folded=t,this._draw())}_setSelected(e){this._emit(ke,{key:e}),this._focusAfter=`${W}${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=K.find(e=>e===t.value);n&&this._setZoom(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[${U}]`);if(n instanceof HTMLElement&&this.contains(n)){this._activate(n.getAttribute(U)??``,n);return}let r=t.closest(`[${Ce}]`);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(W)){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(Ae):e===`retry`?this._emit(je):n&&e===`nav:earlier`?this._setFrom(j(n.zoom,n.fromMs,-1)):n&&e===`nav:later`?this._setFrom(j(n.zoom,n.fromMs,1)):n&&e===`nav:today`?this._setFrom(le(n.zoom,n.todayMs)):e.startsWith(`zoom:`)&&t.click()}_bars(){return[...this.querySelectorAll(`.wui-gantt-lane [${U}^="${W}"]`)].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||!Pe.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(U)?.startsWith(W))return;let n=this._bars(),r=n.indexOf(t),i=t.dataset.wuiGanttKey,a=this._specRows.find(e=>e.key===i);switch(e.preventDefault(),e.key){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(U)??``,t)}}_focusToken(){let e=document.activeElement;return e instanceof HTMLElement&&this.contains(e)?e.getAttribute(U):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`,H().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(`[${U}]`)].find(t=>t.getAttribute(U)===e);n instanceof HTMLElement&&(e.startsWith(W)?this._focusBar(n):n.focus())}_compose(){let e=this._spec;if(!Ie(e))throw TypeError("<wui-gantt> has no spec: set the `spec` property or add a JSON script child.");this._seed(e),he(e);let t=e.layout??`table`,n=p[t],r=H(),i=D(e.today??ce()),a=this._zoom,o=A(a,this._fromMs??le(a,i)),s={layout:t,zoom:a,fromMs:o,todayMs:i};this._resolved=s,this._specRows=e.rows;let c=e.rows.some(e=>e.start!==void 0),l=(e.state??`ready`)===`ready`&&!c?`empty`:e.state??`ready`;this.dataset.state=l,this.dataset.zoom=a,this.dataset.layout=t,l===`loading`?this.setAttribute(`aria-busy`,`true`):this.removeAttribute(`aria-busy`);let u=l===`ready`?ve({...e,folded:[...this._folded],selected:this._selected},s):null,d=u?.axis??me(t,a,o),m=J(`div`,`wui-gantt-lane`);m.style.width=Y(d.width),u?this._fillLane(m,e,u):l===`loading`&&(m.style.height=Y(q*n.rowH));let h=[];l===`loading`&&h.push(this._fillSkeleton(m,e,n)),l===`empty`&&h.push(this._emptyBlock(e)),l===`error`&&h.push(this._stateBlock(`error`,e.errorText||r.errorText));let g=this._head(d),_=J(`div`,`wui-gantt-plot`);_.append(g,m);let v=J(`div`,`wui-gantt-scroller`);if(t===`table`){let t=we({title:e.title,rows:u?.rows??[],headHeight:2*f.tierH,selected:this._selected,text:r,focusAttr:U,skeleton:l===`loading`?{rows:q,rowHeight:n.rowH,barHeight:n.barH}:void 0});v.append(t,_)}else v.append(_);return[this._toolbar(e,l===`ready`),v,...h,this._legend(t)]}_toolbar(e,t){let n=J(`div`,`wui-gantt-toolbar`);return t&&n.append(J(`p`,`wui-gantt-count`,this._countText(e.rows))),n.append(this._scale(),this._nav()),n}_countText(e){let t=H(),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=H(),t=J(`div`,`segmented segmented-sm wui-gantt-scale`);t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,e.scaleLabel),t.append(Object.assign(J(`span`,`segmented-thumb`),{ariaHidden:`true`}));let n={day:e.dayLabel,week:e.weekLabel,month:e.monthLabel};for(let e of K){let r=J(`label`,`segmented-option`),i=J(`input`,`segmented-input`);i.type=`radio`,i.name=`${this.uid}-scale`,i.value=e,i.checked=e===this._zoom,i.setAttribute(U,`zoom:${e}`),r.append(i,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=H(),t=J(`div`,`wui-gantt-nav`),r=(e,t,r)=>{let i=J(`button`,(0,n.buttonClass)(`neutral`,`soft`,`sm`));return i.type=`button`,i.setAttribute(`aria-label`,t),i.setAttribute(U,e),i.innerHTML=(0,s.glyphSvg)(r,{size:16}),i},i=J(`button`,(0,n.buttonClass)(`neutral`,`soft`,`sm`),e.todayLabel);return i.type=`button`,i.setAttribute(U,`nav:today`),t.append(r(`nav:earlier`,e.earlierLabel,`chevron-left`),r(`nav:later`,e.laterLabel,`chevron-right`),i),t}_head(e){let t=J(`div`,`wui-gantt-head`);t.style.width=Y(e.width),t.setAttribute(`aria-hidden`,`true`);let n=(e,t)=>{let n=J(`div`,`wui-gantt-tier ${t}`);for(let t of e){let e=J(`div`,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(J(`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=H(),n=J(`div`,`wui-gantt-legend`);n.setAttribute(`role`,`list`),n.setAttribute(`aria-label`,t.legendLabel);let r=(e,t)=>{let r=J(`span`,null);r.setAttribute(`role`,`listitem`),r.append(e,t),n.append(r)};for(let e of[`done`,`inProgress`,`atRisk`,`notStarted`]){let t=J(`span`,`wui-gantt-swatch`);t.dataset.status=e,r(t,X(e))}let i=J(`span`,`wui-gantt-swatch`);if(i.dataset.kind=`milestone`,r(i,t.milestoneLabel),e===`table`){let e=J(`span`,`wui-gantt-legend-note`,t.legendRemaining);e.setAttribute(`role`,`listitem`),n.append(e)}return n}_stateBlock(e,t){let r=H(),i=J(`div`,`wui-gantt-state`);if(e===`error`){i.setAttribute(`role`,`alert`),i.append(J(`p`,null,t));let e=J(`button`,(0,n.buttonClass)(`neutral`,`soft`,`sm`),r.retryLabel);e.type=`button`,e.setAttribute(U,`retry`),i.append(e)}else i.append(J(`p`,null,t));return i}_emptyBlock(e){let t=H(),r=J(`div`,`wui-gantt-state`);if(r.append(J(`p`,`fw-semibold`,t.emptyTitle),J(`p`,null,e.emptyText||t.emptyText)),e.addTask){let e=J(`button`,(0,n.buttonClass)(`primary`,`solid`,`sm`),t.addTaskLabel);e.type=`button`,e.setAttribute(U,`add`),r.append(e)}return r}_fillSkeleton(e,t,n){let r=J(`div`,`visually-hidden`,t.loadingText||H().loadingText);r.setAttribute(`role`,`status`);for(let t=0;t<q;t+=1){let r=J(`div`,`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=H(),{axis:i}=n,a=n.layout===`table`;e.style.height=Y(n.height),e.setAttribute(`role`,`list`),e.setAttribute(`aria-label`,t.title);let o=J(`p`,`visually-hidden`,a?r.helpTextTable:r.helpText);o.id=`${this.uid}-help`,e.setAttribute(`aria-describedby`,o.id);let s=(e,t,n,r,i)=>{let a=J(`div`,e);return a.setAttribute(`aria-hidden`,`true`),a.style.left=Y(t),a.style.top=Y(n),a.style.width=Y(r),a.style.height=Y(i),a},c=[o];for(let e of n.rows){if(e.height===0)continue;let t=s(`wui-gantt-row`,0,e.top,i.width,e.height);a&&e.kind!==`group`&&e.row.key===this._selected&&(t.dataset.selected=`true`),c.push(t)}for(let e of i.weekendX)c.push(s(`wui-gantt-weekend`,e,0,i.ppd,n.height));for(let e of i.gridX)c.push(s(`wui-gantt-grid`,e,0,1,n.height));if(n.today.inWindow){c.push(s(`wui-gantt-today`,n.today.x-1,0,2,n.height));let e=J(`div`,`wui-gantt-today-flag rounded-pill`,r.todayLabel);e.style.left=Y(n.today.x),c.push(e)}let l=new Map(t.rows.map(e=>[e.key,e]));for(let e of n.rows){if(e.hidden)continue;let t=J(`div`,`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,l,n):this._drawBar(t,e,l,n),c.push(t)}c.push(this._deps(n)),this._card=a?null:this._details(n,l),e.append(...c);let u=e.querySelector(`[${U}^="${W}"]`);u instanceof HTMLElement&&(u.tabIndex=0)}_names(e,t){return(e.dependsOn??[]).map(e=>t.get(e)?.name??e).join(`, `)}_barSentence(e,t){let n=H(),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 i=J(`button`,t);i.type=`button`;let a=this._barSentence(e,n);return i.setAttribute(`aria-label`,a),i.title=a,i.tabIndex=-1,i.dataset.status=Q(e),i.dataset.wuiGanttKey=e.key,i.setAttribute(U,`${W}${e.key}`),r?i.setAttribute(`aria-pressed`,String(this._selected===e.key)):i.setAttribute(`aria-expanded`,String(this._selected===e.key)),this._selected===e.key&&(i.dataset.selected=`true`),i}_afterLabel(e,t,n,r){let i=J(`span`,`wui-gantt-label wui-gantt-label-surface`,e);return i.style.left=Y(t),i.style.top=Y(n),i.style.height=Y(r),i}_drawBar(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=this._focusable(i,`wui-gantt-bar rounded-2`,n,o),c=t.top+a.barTop;s.style.left=Y(t.x),s.style.width=Y(t.w),s.style.top=Y(c),s.style.height=Y(a.barH);let l=Z(i),u=J(`span`,`wui-gantt-bar-progress`);if(u.style.width=`${l}%`,s.append(u),e.append(s),o)return;let d=`${i.name} ${l}%`;t.place===`inside`?s.append(J(`span`,`wui-gantt-bar-label`,d)):e.append(this._afterLabel(d,t.x+t.w+Me,c,a.barH))}_drawMilestone(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=f.milestone/2,c=t.top+(a.rowH-f.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(f.milestone),l.style.height=Y(f.milestone),e.append(l),o)return;let u=this._afterLabel(`${i.name}, ${O(D(i.start??``))}`,t.x+f.milestone,t.top+a.barTop,a.barH);t.flip&&(u.style.left=``,u.style.right=Y(r.axis.width-(t.x-f.milestone))),e.append(u)}_drawGroup(e,t,n){let r=H(),i=t.group;if(!i)return;if(n.layout===`lanes`){let n=J(`div`,`wui-gantt-group wui-gantt-label wui-gantt-label-surface`);n.dataset.wuiGanttGroup=i.name,n.style.left=Y(8),n.style.top=Y(t.top+6);let a=J(`button`,`wui-gantt-group-toggle`);a.type=`button`,a.setAttribute(`aria-expanded`,String(!i.folded)),a.setAttribute(`aria-label`,(0,c.fillText)(i.folded?r.unfoldLabel:r.foldLabel,{group:i.name})),a.setAttribute(U,`group:${i.name}`),a.innerHTML=(0,s.glyphSvg)(i.folded?`chevron-right`:`chevron-down`,{size:16}),n.append(a,J(`span`,null,i.name),J(`span`,null,(0,c.pluralText)(r,`groupSummary`,i.count,{percent:i.percent}))),e.append(n)}let a=J(`div`,`wui-gantt-group-summary`);a.dataset.wuiGanttGroup=i.name,a.style.left=Y(t.x),a.style.width=Y(t.w),a.style.top=Y(t.top+n.geometry.groupBarTop),a.style.height=Y(f.groupBarH),e.append(a)}_deps(e){let t=document.createElementNS(G,`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(G,`path`);e.setAttribute(`d`,n.d),e.setAttribute(`fill`,`none`);let r=document.createElementNS(G,`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,i=r===null?void 0:e.rows.find(e=>e.row.key===r&&e.kind!==`group`&&!e.hidden);if(!i)return null;let a=H(),{row:o}=i,s=J(`div`,`wui-gantt-details`);s.setAttribute(`role`,`group`),s.setAttribute(`aria-label`,o.name),s.style.width=Y(Ne);let l=J(`dl`),u=(e,t)=>{l.append(J(`dt`,null,e),J(`dd`,null,t))},d=O(D(o.start??``));o.owner&&u(a.detailsOwner,o.owner),u(a.detailsDates,o.end===void 0?d:(0,c.fillText)(a.detailsRange,{start:d,end:O(D(o.end))})),o.end!==void 0&&u(a.detailsDone,`${Z(o)}%, ${X(Q(o))}`);let f=this._names(o,t);f&&u(a.detailsStartsAfter,f);let p=J(`button`,(0,n.buttonClass)(`neutral`,`ghost`,`sm`),a.detailsCloseLabel);return p.type=`button`,p.setAttribute(U,`close`),s.append(J(`h3`,`h6`,o.name),l,p),s}};(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.avatarHtml,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.nativeOverlay);