@webority/ui-elements 0.179.0 → 0.181.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/README.md +10 -0
  2. package/THIRD-PARTY-NOTICES.txt +3 -3
  3. package/dist/WuiCalendarViews-Dg9yRY1I.js +1 -0
  4. package/dist/{WuiCommandPalette-u1XD5WMv.js → WuiCommandPalette-CpmlKjzH.js} +2 -2
  5. package/dist/{WuiCommentThread-e5t7HceL.js → WuiCommentThread-Cp7AVHvt.js} +1 -1
  6. package/dist/WuiDashboardGrid-DFpX8Vx0.js +1 -0
  7. package/dist/WuiDataTable-CSgcwxU5.js +1 -0
  8. package/dist/WuiDatePicker-CRqjwyf2.js +1 -0
  9. package/dist/WuiDateRange-BBm_Q69p.js +1 -0
  10. package/dist/WuiEntryGrid-Z69-1YBh.js +3 -0
  11. package/dist/WuiGantt-DvmVKJX2.js +1 -0
  12. package/dist/WuiInlineEdit-JT83k3Nk.js +1 -0
  13. package/dist/WuiMentionInput-DPCCSQRZ.js +1 -0
  14. package/dist/WuiMiniCalendar-BhUTIGwe.js +1 -0
  15. package/dist/WuiNotificationCenter-D5bBM8Lp.js +1 -0
  16. package/dist/WuiOfflineBanner-DGTFCtyM.js +1 -0
  17. package/dist/{WuiPhone--w-taM5Q.js → WuiPhone-B5ZLabTY.js} +1 -1
  18. package/dist/{WuiSavedViews-BR6ZHd9Y.js → WuiSavedViews-CH7IvwgZ.js} +1 -1
  19. package/dist/WuiSelect-DIW_WXH7.js +1 -0
  20. package/dist/WuiTimePicker-BKFPf8Fn.js +1 -0
  21. package/dist/{WuiTree-BjtuCasB.js → WuiTree-Db83Uztv.js} +1 -1
  22. package/dist/WuiWizardStep-BBkw94dD.js +1 -0
  23. package/dist/{chips-BdpsN50B.js → chips-paLEDoxn.js} +1 -1
  24. package/dist/commandPalette.g-DP-Zl8SU.js +1 -0
  25. package/dist/dashboardGrid.g-vkCZGw6G.js +1 -0
  26. package/dist/{dataTable-VB3nBucm.js → dataTable-C0q14bkP.js} +1 -1
  27. package/dist/{dataTable.g-DazoWWps.js → dataTable.g-1PsmN1Nj.js} +1 -1
  28. package/dist/drawerDiscard-D_LMpaFv.js +1 -0
  29. package/dist/elements/calendar-views.js +1 -0
  30. package/dist/elements/command-palette.js +1 -1
  31. package/dist/elements/comment-thread.js +1 -1
  32. package/dist/elements/dashboard-grid.js +1 -0
  33. package/dist/elements/data-table.js +1 -1
  34. package/dist/elements/date-range.js +1 -1
  35. package/dist/elements/datepicker.js +1 -1
  36. package/dist/elements/entry-grid.js +1 -1
  37. package/dist/elements/gantt.js +1 -1
  38. package/dist/elements/inline-edit.js +1 -1
  39. package/dist/elements/kanban.js +1 -1
  40. package/dist/elements/mention-input.js +1 -1
  41. package/dist/elements/mini-calendar.js +1 -0
  42. package/dist/elements/notification-center.js +1 -1
  43. package/dist/elements/offline-banner.js +1 -0
  44. package/dist/elements/phone.js +1 -1
  45. package/dist/elements/saved-views.js +1 -1
  46. package/dist/elements/select.js +1 -1
  47. package/dist/elements/timepicker.js +1 -1
  48. package/dist/elements/tree.js +1 -1
  49. package/dist/elements/wizard.js +1 -1
  50. package/dist/gantt.g-CWvMXwBR.js +1 -0
  51. package/dist/helpers.js +1 -1
  52. package/dist/initials-DKg3IeUa.js +1 -0
  53. package/dist/inlineEdit.g-DKIhYoPF.js +1 -0
  54. package/dist/{kanban-jQCTLG3Q.js → kanban-Dayig7ic.js} +1 -1
  55. package/dist/loader-DUCcKxjq.js +1 -0
  56. package/dist/{notificationCentre.g-UsAurkUz.js → notificationCentre.g-Cees-vKg.js} +1 -1
  57. package/dist/{notificationDays-wMr8rZko.js → notificationDays-B1R0RFAY.js} +1 -1
  58. package/dist/refreshAfter-DhYgWXmQ.js +1 -0
  59. package/dist/{search-Dl07KqWw.js → search-C46tnoPd.js} +1 -1
  60. package/dist/server.js +1 -1
  61. package/dist/shell.g-BhC11Oe3.js +1 -0
  62. package/dist/tableSelect-juA3KcQh.js +1 -0
  63. package/dist/tableSelect.g-DwI5_9Nw.js +1 -0
  64. package/dist/testing.js +1 -0
  65. package/dist/text/en.json +119 -10
  66. package/dist/text.js +1 -1
  67. package/dist/themeTransition-C5nAlClG.js +1 -0
  68. package/dist/toast.g-CJ8c0BNZ.js +1 -0
  69. package/dist/ui-calendar.global.js +1 -1
  70. package/dist/ui-calendar.js +1 -1
  71. package/dist/ui-chart.global.js +15 -15
  72. package/dist/ui-chart.js +2 -2
  73. package/dist/ui-elements/calendar-views.global.js +1 -0
  74. package/dist/ui-elements/carousel.global.js +1 -1
  75. package/dist/ui-elements/code-block.global.js +1 -1
  76. package/dist/ui-elements/command-palette.global.js +2 -2
  77. package/dist/ui-elements/comment-thread.global.js +1 -1
  78. package/dist/ui-elements/consent-banner.global.js +1 -1
  79. package/dist/ui-elements/context-menu.global.js +1 -1
  80. package/dist/ui-elements/dashboard-grid.global.js +1 -0
  81. package/dist/ui-elements/data-table.global.js +1 -1
  82. package/dist/ui-elements/date-range.global.js +1 -1
  83. package/dist/ui-elements/date-time.global.js +1 -1
  84. package/dist/ui-elements/datepicker.global.js +1 -1
  85. package/dist/ui-elements/dock.global.js +1 -1
  86. package/dist/ui-elements/drawer.global.js +1 -1
  87. package/dist/ui-elements/dropdown.global.js +1 -1
  88. package/dist/ui-elements/entry-grid.global.js +2 -2
  89. package/dist/ui-elements/gantt.global.js +1 -1
  90. package/dist/ui-elements/glyphs.global.js +1 -1
  91. package/dist/ui-elements/hover-card.global.js +1 -1
  92. package/dist/ui-elements/image-crop.global.js +1 -1
  93. package/dist/ui-elements/inline-edit.global.js +1 -1
  94. package/dist/ui-elements/kanban.global.js +1 -1
  95. package/dist/ui-elements/lead-popup.global.js +1 -1
  96. package/dist/ui-elements/lightbox.global.js +1 -1
  97. package/dist/ui-elements/markdown.global.js +1 -1
  98. package/dist/ui-elements/mini-calendar.global.js +1 -0
  99. package/dist/ui-elements/navigation-menu.global.js +1 -1
  100. package/dist/ui-elements/notification-center.global.js +1 -1
  101. package/dist/ui-elements/offline-banner.global.js +1 -0
  102. package/dist/ui-elements/onboarding-checklist.global.js +1 -1
  103. package/dist/ui-elements/org-tree.global.js +1 -1
  104. package/dist/ui-elements/otp.global.js +1 -1
  105. package/dist/ui-elements/overflow.global.js +1 -1
  106. package/dist/ui-elements/phone.global.js +1 -1
  107. package/dist/ui-elements/popover.global.js +1 -1
  108. package/dist/ui-elements/rating.global.js +1 -1
  109. package/dist/ui-elements/record-pager.global.js +1 -1
  110. package/dist/ui-elements/relative-time.global.js +1 -1
  111. package/dist/ui-elements/saved-views.global.js +1 -1
  112. package/dist/ui-elements/select-chips.global.js +1 -1
  113. package/dist/ui-elements/select-recents.global.js +1 -1
  114. package/dist/ui-elements/select-search.global.js +1 -1
  115. package/dist/ui-elements/select-window.global.js +1 -1
  116. package/dist/ui-elements/server.global.js +1 -0
  117. package/dist/ui-elements/shell.global.js +1 -0
  118. package/dist/ui-elements/shortcuts.global.js +1 -1
  119. package/dist/ui-elements/show-more.global.js +1 -1
  120. package/dist/ui-elements/slider.global.js +1 -1
  121. package/dist/ui-elements/sortable.global.js +1 -1
  122. package/dist/ui-elements/status-icon.global.js +1 -1
  123. package/dist/ui-elements/table-export.global.js +1 -1
  124. package/dist/ui-elements/timepicker.global.js +1 -1
  125. package/dist/ui-elements/tour.global.js +1 -1
  126. package/dist/ui-elements/tree-picker.global.js +1 -1
  127. package/dist/ui-elements/tree.global.js +1 -1
  128. package/dist/ui-elements/truncate.global.js +1 -1
  129. package/dist/ui-elements/whats-new.global.js +1 -1
  130. package/dist/ui-elements/wizard.global.js +1 -1
  131. package/dist/ui-elements.global.js +1 -1
  132. package/dist/ui-elements.js +1 -1
  133. package/dist/ui-file-viewer.global.js +1 -1
  134. package/dist/ui-file-viewer.js +1 -1
  135. package/dist/wizard.g-UKG1dMs_.js +1 -0
  136. package/dist/wuiHttp-8CYWEbRz.js +1 -0
  137. package/package.json +25 -5
  138. package/types/WuiCalendar.d.ts +9 -1
  139. package/types/WuiCalendarViews.d.ts +34 -0
  140. package/types/WuiDashboardGrid.d.ts +35 -0
  141. package/types/WuiDataTable.d.ts +1 -0
  142. package/types/WuiEntryGrid.d.ts +4 -0
  143. package/types/WuiFileViewer.d.ts +7 -0
  144. package/types/WuiGantt.d.ts +6 -1
  145. package/types/WuiInlineEdit.d.ts +2 -1
  146. package/types/WuiMiniCalendar.d.ts +27 -0
  147. package/types/WuiNotificationCenter.d.ts +1 -0
  148. package/types/WuiOfflineBanner.d.ts +35 -0
  149. package/types/WuiSelect.d.ts +1 -0
  150. package/types/WuiTimePicker.d.ts +1 -0
  151. package/types/WuiWizard.d.ts +13 -0
  152. package/types/calendarAdapter.d.ts +9 -0
  153. package/types/calendarModel.d.ts +11 -0
  154. package/types/chartSpec.d.ts +3 -0
  155. package/types/dataTable.d.ts +10 -1
  156. package/types/elements/calendar-views.d.ts +2 -0
  157. package/types/elements/dashboard-grid.d.ts +1 -0
  158. package/types/elements/mini-calendar.d.ts +2 -0
  159. package/types/elements/offline-banner.d.ts +2 -0
  160. package/types/ganttLayout.d.ts +41 -7
  161. package/types/ganttTypes.d.ts +15 -0
  162. package/types/global/chunkChecks.d.ts +1 -0
  163. package/types/global/chunks.d.ts +4 -0
  164. package/types/global/core.d.ts +3 -2
  165. package/types/global/glyphs.d.ts +2 -0
  166. package/types/global/loader.d.ts +9 -2
  167. package/types/global/parts/server.d.ts +1 -0
  168. package/types/global/parts/shell.d.ts +1 -0
  169. package/types/global/server.d.ts +18 -0
  170. package/types/global/serverGuard.d.ts +2 -0
  171. package/types/global/shared.d.ts +22 -0
  172. package/types/global/tableExport.d.ts +2 -0
  173. package/types/globals.d.ts +8 -0
  174. package/types/helpers.d.ts +2 -1
  175. package/types/index.d.ts +5 -1
  176. package/types/razor-js/modules/api.d.ts +10 -5
  177. package/types/razor-js/modules/serverBridge.d.ts +1 -0
  178. package/types/razor-js/modules/stickyStack.d.ts +1 -0
  179. package/types/razor-js/webority-ui.d.ts +4 -1
  180. package/types/select/list.d.ts +2 -0
  181. package/types/server/behaviours.d.ts +6 -0
  182. package/types/server/core.d.ts +10 -0
  183. package/types/server/flash.d.ts +16 -0
  184. package/types/server/flashToasts.d.ts +2 -0
  185. package/types/server/index.d.ts +2 -10
  186. package/types/server/postError.d.ts +17 -0
  187. package/types/server/refreshAfter.d.ts +45 -0
  188. package/types/server/regions.d.ts +5 -0
  189. package/types/server/serverActions.d.ts +18 -10
  190. package/types/server/serverMessage.d.ts +5 -0
  191. package/types/server/serverTable.d.ts +0 -2
  192. package/types/server/serverTableRegistry.d.ts +7 -0
  193. package/types/server/shellParts.d.ts +1 -3
  194. package/types/server/shellRegistry.d.ts +7 -0
  195. package/types/server/toastAction.d.ts +7 -3
  196. package/types/server/wuiHost.d.ts +1 -0
  197. package/types/server/wuiHttp.d.ts +9 -2
  198. package/types/stickyStack.d.ts +6 -0
  199. package/types/tableSelect.d.ts +10 -0
  200. package/types/testing.d.ts +4 -0
  201. package/types/text/web/agenda.g.d.ts +7 -0
  202. package/types/text/web/asyncBlock.g.d.ts +3 -0
  203. package/types/text/web/calendar.g.d.ts +2 -0
  204. package/types/text/web/catalogue.g.d.ts +20 -0
  205. package/types/text/web/changeList.g.d.ts +5 -0
  206. package/types/text/web/chart.g.d.ts +1 -0
  207. package/types/text/web/commandPalette.g.d.ts +1 -0
  208. package/types/text/web/dashboardGrid.g.d.ts +18 -0
  209. package/types/text/web/dashboardHeader.g.d.ts +6 -0
  210. package/types/text/web/dataTable.g.d.ts +4 -0
  211. package/types/text/web/entryGrid.g.d.ts +2 -0
  212. package/types/text/web/formActions.g.d.ts +9 -0
  213. package/types/text/web/gantt.g.d.ts +2 -0
  214. package/types/text/web/index.g.d.ts +10 -0
  215. package/types/text/web/kpiTile.g.d.ts +1 -0
  216. package/types/text/web/miniCalendar.g.d.ts +4 -0
  217. package/types/text/web/notificationCentre.g.d.ts +4 -0
  218. package/types/text/web/offlineBanner.g.d.ts +8 -0
  219. package/types/text/web/queueBundle.g.d.ts +11 -0
  220. package/types/text/web/resultBlock.g.d.ts +6 -0
  221. package/types/text/web/routeError.g.d.ts +14 -0
  222. package/types/text/web/settingRow.g.d.ts +10 -0
  223. package/types/text/web/shell.g.d.ts +0 -7
  224. package/types/text/web/tableSelect.g.d.ts +1 -0
  225. package/types/text/web/unsavedChanges.g.d.ts +1 -0
  226. package/types/text/web/wizard.g.d.ts +6 -0
  227. package/types/toastTypes.d.ts +1 -1
  228. package/dist/WuiDataTable-Ble3hl5L.js +0 -1
  229. package/dist/WuiDatePicker-3D33rzH4.js +0 -1
  230. package/dist/WuiDateRange-BnEJ2WpL.js +0 -1
  231. package/dist/WuiEntryGrid-DkW0tIDy.js +0 -3
  232. package/dist/WuiGantt-BqNhYIr6.js +0 -1
  233. package/dist/WuiInlineEdit-D7AuEv1R.js +0 -1
  234. package/dist/WuiMentionInput-DPpEVL2s.js +0 -1
  235. package/dist/WuiNotificationCenter-DuvGrqwr.js +0 -1
  236. package/dist/WuiSelect-CNff3FNi.js +0 -1
  237. package/dist/WuiTimePicker-DYLFaWDc.js +0 -1
  238. package/dist/WuiWizardStep-gFtuUzsL.js +0 -1
  239. package/dist/commandPalette.g-DFWnCufa.js +0 -1
  240. package/dist/drawerDiscard-APy8TZxi.js +0 -1
  241. package/dist/gantt.g-TdTxeruW.js +0 -1
  242. package/dist/initials-Qb6ITcri.js +0 -1
  243. package/dist/inlineEdit.g-DLDVospu.js +0 -1
  244. package/dist/loader-A38-PdcB.js +0 -1
  245. package/dist/shell.g-C2Ht5xl2.js +0 -1
  246. package/dist/tableSelect.g-Bmd-ExRE.js +0 -1
  247. package/dist/themeTransition-TF0BqM20.js +0 -1
  248. package/dist/wizard.g-DOZSBUc5.js +0 -1
  249. package/dist/wuiHttp-Cw7V8u2w.js +0 -1
package/README.md CHANGED
@@ -33,6 +33,16 @@ element classes. Any other helper is imported from the module that owns it.
33
33
 
34
34
  Component catalogue: <https://ui-react.webority.dev>
35
35
 
36
+ ## Testing in jsdom
37
+
38
+ jsdom has no `showPopover` and no `showModal`, so an element test that opens a popover or a modal needs these doubles. Import the installers from `@webority/ui-elements/testing` in the test setup file, and they apply to every test that file runs:
39
+
40
+ ```ts
41
+ installNativeOverlayFakes();
42
+ installNativeEscape();
43
+ installNativeModalFocus();
44
+ ```
45
+
36
46
  ## Authoring a `<wui-*>` element
37
47
 
38
48
  Rules learned from defects, not from style preference.
@@ -340,9 +340,9 @@ MIT License. Copyright (c) 2021 Adam Shaw
340
340
  Preact, bundled into the calendar through FullCalendar. https://preactjs.com
341
341
  MIT License. Copyright (c) 2015-present Jason Miller
342
342
  ================================================================================
343
- Bootstrap (bootstrap.bundle.min.js, which includes Popper), built from its sources without the Dropdown module and shipped in the Webority.Ui.Razor
344
- package as js/bootstrap.bundle.min.js. https://getbootstrap.com
345
- MIT License. Copyright (c) 2011-2024 The Bootstrap Authors; Popper: Copyright (c) 2019 Federico Zivolo
343
+ Bootstrap (bootstrap.bundle.min.js), built from its sources with the Alert and Tab plugins only and shipped in the Webority.Ui.Razor
344
+ package as js/bootstrap.bundle.min.js, and its compiled CSS inside css/webority-theme.css. https://getbootstrap.com
345
+ MIT License. Copyright (c) 2011-2026 The Bootstrap Authors
346
346
  ================================================================================
347
347
  Each of the above is licensed under the MIT License:
348
348
 
@@ -0,0 +1 @@
1
+ import{t as e}from"./elementBase-Cxeyx0tU.js";var t=`#view=`,n=`wui-calendar-views:view-change`,r=`wui-calendar-views:period-change`,i=[`previous`,`next`,`today`],a=`.wui-cal-views-switch input[type='radio']`,o=class extends e{_onChange;_onClick;constructor(){super(),this._onChange=e=>this._choose(e),this._onClick=e=>this._step(e)}static get observedAttributes(){return[`view`]}connectedCallback(){if(this.addEventListener(`change`,this._onChange),this.addEventListener(`click`,this._onClick),!this.hasAttribute(`data-controlled`)){let e=s(this._views());e&&this.setAttribute(`view`,e)}if(!this.hasAttribute(`view`)){let e=this._views()[0];e&&this.setAttribute(`view`,e)}this._sync()}disconnectedCallback(){this.removeEventListener(`change`,this._onChange),this.removeEventListener(`click`,this._onClick)}attributeChangedCallback(){this._sync()}_views(){return Array.from(this.querySelectorAll(a),e=>e.value)}_sync(){let e=this.getAttribute(`view`)??``;for(let t of this.querySelectorAll(a))t.checked=t.value===e;for(let t of this.querySelectorAll(`:scope > .wui-cal-views-body[data-view]`))t.hidden=t.dataset.view!==e}_choose(e){let t=e.target;if(!(t instanceof HTMLInputElement)||t.type!==`radio`||!this.contains(t))return;let r=t.value;this.hasAttribute(`data-controlled`)||this.setAttribute(`view`,r),c(r),this.dispatchEvent(new CustomEvent(n,{bubbles:!0,detail:{view:r}})),this._sync()}_step(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`button[data-step]`),a=n?.getAttribute(`data-step`)??``;n&&this.contains(n)&&i.includes(a)&&this.dispatchEvent(new CustomEvent(r,{bubbles:!0,detail:{step:a}}))}};function s(e){if(!window.location.hash.startsWith(t))return null;let n=window.location.hash.slice(6);return e.includes(n)?n:null}function c(e){let t=new URL(window.location.href);t.hash=`view=${e}`,window.history.replaceState(window.history.state,``,t)}export{o as t};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{r as n}from"./textStore-DBplASiZ.js";import{t as r}from"./commandPalette.g-DFWnCufa.js";import{t as i}from"./textMatch-wdY7XLIc.js";var a=`[role="option"]`,o=()=>n(`commandPalette`,r),s=5,c=20,l=`.wui-cmd-back, [data-depth]`,u=`[data-group-tab]`,d=0;function f(e,t){if(!(e instanceof Element))return null;let n=e.closest(t);return n instanceof HTMLElement?n:null}var p=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},m=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),h=class extends t{_path;_group;_crumbSig;_modal;_recentsId;_onModalClosed;_activeId;_lastQuery;_lastIds;_userChose;_onKeyDown;_onClick;_onMouseDown;_onMouseMove;_onInput;static get observedAttributes(){return[`filter`,`group-filter`,`highlight`,`empty-text`,`path`,`root-label`,`recents-key`,`recents-limit`,`recents-label`]}constructor(){super(),this._path=[],this._group=null,this._crumbSig=null,this._modal=null,this._recentsId=`wui-cmd-recents-${++d}`,this._onModalClosed=()=>{this._setKeyboard(!1),this._reset(),this.hasAttribute(`path`)&&this._restart()},this._activeId=null,this._lastQuery=null,this._lastIds=null,this._userChose=!1,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=f(e.target,l);if(t&&this.contains(t)){let e=t.matches(`.wui-cmd-back`)?this._path.length-1:Number(t.dataset.depth);this._goTo(this._path.slice(0,e));return}let n=f(e.target,u);if(n&&this.contains(n)){this._pickGroup(n.dataset.groupTab||null);return}let r=this._optionFrom(e.target);r&&this._select(r)},this._onMouseDown=e=>{let t=f(e.target,l),n=f(e.target,u);(t&&this.contains(t)||n&&this.contains(n)||this._optionFrom(e.target,!0))&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&(this._setKeyboard(!1),this._userChose=!0,this._setActive(t,!1))},this._onInput=e=>{this.hasAttribute(`filter`)&&e.target===this._input()&&(this._group=null,this._applyFilter(),this.refresh())}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousedown`,this._onMouseDown),this.addEventListener(`mousemove`,this._onMouseMove),this.addEventListener(`input`,this._onInput),this._modal=this.closest(`wui-modal`),this._modal?.addEventListener(`wui-modal-closed`,this._onModalClosed),this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){this.isConnected&&(e===`path`&&this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh())}get filter(){return this.hasAttribute(`filter`)}set filter(e){this.toggleAttribute(`filter`,!!e)}get highlight(){return this.getAttribute(`highlight`)!==`false`}set highlight(e){this.setAttribute(`highlight`,e?`true`:`false`)}get emptyText(){return this.getAttribute(`empty-text`)??o().emptyText}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){this._renderRecents(),this._renderCrumbs(),this._syncTabs();let e=this._input(),t=e?e.value:``,n=t!==this._lastQuery;this._lastQuery=t;let r=this._selectableOptions(),i=r.map(e=>e.id).join(`
2
- `),a=i!==this._lastIds;this._lastIds=i;let o=!n&&(this._userChose||!a)?r.find(e=>e.id===this._activeId):null;o||(this._userChose=!1,this._setKeyboard(!1)),this._setActive(o??r[0]??null,n)}_input(){let e=this.querySelector(`[role="combobox"]`);return e instanceof HTMLInputElement?e:null}_optionFrom(e,t=!1){let n=f(e,a);return n&&this.contains(n)&&!this._isHidden(n)&&(t||!this._isDisabled(n))?n:null}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_isHidden(e){return e.hidden!==!1||(f(e,`[role="group"]`)?.hidden??!1)!==!1}_selectableOptions(){return m(this,a,HTMLElement).filter(e=>!this._isHidden(e)&&!this._isDisabled(e))}_setActive(e,t){this._activeId=e?e.id:null;for(let t of m(this,a,HTMLElement))t.setAttribute(`aria-selected`,t===e?`true`:`false`);let n=this._input();n&&(e?n.setAttribute(`aria-activedescendant`,e.id):n.removeAttribute(`aria-activedescendant`)),e&&t&&e.scrollIntoView({block:`nearest`})}_move(e){let t=this._selectableOptions();if(!t.length)return;let n=t.findIndex(e=>e.id===this._activeId),r=n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;this._userChose=!0,this._setKeyboard(!0),this._setActive(t[r]??null,!0)}_setKeyboard(e){this.toggleAttribute(`data-keyboard`,e)}_handleKeyDown(e){let t=this._input();if(t&&e.target===t){if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._move(e.key===`ArrowDown`?1:-1);else if(e.key===`Tab`&&this._groupActive()&&this._tabs().length)e.preventDefault(),this._cycleGroup(e.shiftKey?-1:1);else if(e.key===`Backspace`&&!e.isComposing&&this._path.length&&!t.value)e.preventDefault(),this._goTo(this._path.slice(0,-1));else if(e.key===`Enter`&&!e.isComposing){let t=this._selectableOptions().find(e=>e.id===this._activeId);if(!t)return;e.preventDefault(),this._select(t)}}}_select(e){this._remember(e),this.dispatchEvent(new CustomEvent(`wui-command-palette:select`,{bubbles:!0,cancelable:!0,detail:{key:e.dataset.key??null,groupKey:e.dataset.groupKey??null,id:e.id}}))&&(e.dataset.opens?this._open(e.dataset.opens):e.dataset.href&&this._navigate(e.dataset.href))}_open(e){let t=m(this,`.wui-cmd-page`,HTMLElement).find(t=>t.dataset.page===e);this._goTo([...this._path,{key:e,label:t?.dataset.label??e}])}_goTo(e){this._input()?.focus(),this.dispatchEvent(new CustomEvent(`wui-command-palette:navigate`,{bubbles:!0,cancelable:!0,detail:{path:e}}))&&(this._path=e,this._restart())}_tabs(){return m(this,u,HTMLElement)}_groupActive(){return this.hasAttribute(`group-filter`)&&this._path.length===0}_pickGroup(e){this._group=e,this._applyFilter(),this.refresh()}_cycleGroup(e){let t=this._tabs().map(e=>e.dataset.groupTab||null),n=Math.max(0,t.indexOf(this._group));this._pickGroup(t[(n+e+t.length)%t.length]??null)}_syncTabs(){if(!this.hasAttribute(`group-filter`))return;let e=p(this,`.wui-cmd-tabs`,HTMLElement);e&&(e.hidden=!this._groupActive());for(let e of this._tabs())e.setAttribute(`aria-selected`,String((e.dataset.groupTab||null)===this._group))}_restart(){this._group=null;let e=this._input();e&&(e.value=``),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}_reset(){this.hasAttribute(`path`)||(this._path=[],this._restart())}_readPath(){let e=this.getAttribute(`path`);if(e==null)return;let t=JSON.parse(e);this._path=Array.isArray(t)?t.filter(e=>e&&typeof e.key==`string`&&typeof e.label==`string`):[]}_renderCrumbs(){let e=p(this,`.wui-cmd-crumbs`,HTMLElement);if(!e)return;let t=this.getAttribute(`root-label`)??o().rootLabel,n=JSON.stringify([t,this._path]);if(e.hidden=this._path.length===0,n===this._crumbSig)return;this._crumbSig=n;let r=p(e,`.wui-cmd-trail`,HTMLElement);if(!r)return;let i=[t,...this._path.map(e=>e.label)];r.replaceChildren(...i.map((e,t)=>{let n=document.createElement(`li`),r=t===i.length-1,a=document.createElement(r?`span`:`button`);if(a.className=`wui-cmd-crumb`,a.textContent=e,r)a.setAttribute(`aria-current`,`page`);else{if(!(a instanceof HTMLButtonElement))throw Error(`breadcrumb button missing`);a.type=`button`,a.dataset.depth=String(t)}return n.append(a),n}))}_recentsHost(){return p(this,`.wui-cmd-recents`,HTMLElement)}_realOptions(){let e=this._recentsHost();return m(this,a,HTMLElement).filter(t=>!e?.contains(t))}_recentEntries(){let e=this.getAttribute(`recents-key`);if(!e)return[];let t;try{t=JSON.parse(globalThis.localStorage?.getItem(e)??`[]`)}catch{return[]}return Array.isArray(t)?t.filter(e=>e&&typeof e.g==`string`&&typeof e.k==`string`):[]}_recentsLimit(){let e=Number.parseInt(this.getAttribute(`recents-limit`)??``,10);return Number.isFinite(e)&&e>0?Math.min(e,c):s}_remember(e){let t=this.getAttribute(`recents-key`),{groupKey:n,key:r,opens:i}=e.dataset;if(!t||i||n==null||r==null)return;let a=[{g:n,k:r},...this._recentEntries().filter(e=>e.g!==n||e.k!==r)];try{globalThis.localStorage?.setItem(t,JSON.stringify(a.slice(0,this._recentsLimit())))}catch(e){if(!(e instanceof DOMException))throw e}}_renderRecents(){let e=this._recentsHost();if(!e)return;let t=this._input(),n=this._groupActive()?this._group:null,r=this._path.length===0&&!(t?.value??``).trim()?this._recentEntries().filter(e=>!n||e.g===n):[],i=this._realOptions(),a=[];for(let e of r){let t=i.find(t=>t.dataset.groupKey===e.g&&t.dataset.key===e.k);if(t&&!t.dataset.opens&&!this._isDisabled(t)&&a.push(t),a.length>=this._recentsLimit())break}if(!a.length){e.firstChild&&e.replaceChildren();return}let s=`${this._recentsId}-label`,c=document.createElement(`div`);c.className=`wui-cmd-group`,c.setAttribute(`role`,`group`),c.setAttribute(`aria-labelledby`,s);let l=document.createElement(`div`);l.className=`wui-cmd-group-label`,l.setAttribute(`role`,`presentation`),l.id=s,l.textContent=this.getAttribute(`recents-label`)??o().recentsLabel,c.append(l);for(let e of a){let t=e.cloneNode(!0);if(!(t instanceof HTMLElement))throw Error(`recent option copy is not an element`);t.id=`${this._recentsId}-${e.id}`,t.hidden=!1,t.removeAttribute(`aria-selected`),c.append(t)}e.replaceChildren(c)}_inScope(e,t){return!t||(f(e,`.wui-cmd-page`)?.dataset.page??null)===(this._path[this._path.length-1]?.key??null)}_navigate(e){window.location.assign(e)}_applyFilter(){let t=this._input(),n=(t?t.value:``).trim(),r=n.toLowerCase(),o=this.highlight,s=m(this,`.wui-cmd-page`,HTMLElement),c=s.length>0,l=this._path[this._path.length-1]?.key??null;for(let e of s)e.hidden=e.dataset.page!==l;let u=this._groupActive()?this._group:null,d=0;for(let t of this._realOptions()){let a=p(t,`.wui-cmd-item-label`,HTMLElement),s=t.dataset.label??a?.textContent??``,l=(t.dataset.keywords??``).split(/\s+/).filter(Boolean),f=!r||s.toLowerCase().includes(r)||l.some(e=>e.toLowerCase().includes(r)),m=this._inScope(t,c)&&(!u||t.dataset.groupKey===u)&&f;t.hidden=!m,m&&d++,a&&a.replaceChildren(...i(s,o?n:``).map(t=>t.match?e(`mark`,{class:`wui-cmd-mark`},t.text):t.text))}let f=this._recentsHost();for(let e of m(this,`[role="group"]`,HTMLElement))f?.contains(e)||(e.hidden=!m(e,a,HTMLElement).some(e=>!e.hidden));let h=p(this,`[role="listbox"]`,HTMLElement);h&&(h.hidden=d===0);let g=p(this,`.wui-cmd-empty`,HTMLElement);g&&(g.textContent=r&&d===0?this.emptyText:``)}_teardown(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousedown`,this._onMouseDown),this.removeEventListener(`mousemove`,this._onMouseMove),this.removeEventListener(`input`,this._onInput),this._modal?.removeEventListener(`wui-modal-closed`,this._onModalClosed),this._modal=null}};export{h as t};
1
+ import{r as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{r as n}from"./textStore-DBplASiZ.js";import{t as r}from"./commandPalette.g-DP-Zl8SU.js";import{t as i}from"./textMatch-wdY7XLIc.js";var a=`[role="option"]`,o=()=>n(`commandPalette`,r),s=5,c=20,l=`.wui-cmd-back, [data-depth]`,u=`[data-group-tab]`,d=`.wui-cmd-error-retry`,f=0;function p(e,t){if(!(e instanceof Element))return null;let n=e.closest(t);return n instanceof HTMLElement?n:null}var m=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},h=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),g=class extends t{_path;_group;_crumbSig;_modal;_recentsId;_onModalClosed;_activeId;_lastQuery;_lastIds;_userChose;_onKeyDown;_onClick;_onMouseDown;_onMouseMove;_onInput;static get observedAttributes(){return[`filter`,`group-filter`,`highlight`,`empty-text`,`path`,`root-label`,`recents-key`,`recents-limit`,`recents-label`]}constructor(){super(),this._path=[],this._group=null,this._crumbSig=null,this._modal=null,this._recentsId=`wui-cmd-recents-${++f}`,this._onModalClosed=()=>{this._setKeyboard(!1),this._reset(),this.hasAttribute(`path`)&&this._restart()},this._activeId=null,this._lastQuery=null,this._lastIds=null,this._userChose=!1,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=p(e.target,d);if(t&&this.contains(t)){this.dispatchEvent(new CustomEvent(`wui-command-palette:retry`,{bubbles:!0}));return}let n=p(e.target,l);if(n&&this.contains(n)){let e=n.matches(`.wui-cmd-back`)?this._path.length-1:Number(n.dataset.depth);this._goTo(this._path.slice(0,e));return}let r=p(e.target,u);if(r&&this.contains(r)){this._pickGroup(r.dataset.groupTab||null);return}let i=this._optionFrom(e.target);i&&this._select(i)},this._onMouseDown=e=>{let t=p(e.target,l),n=p(e.target,u);(t&&this.contains(t)||n&&this.contains(n)||this._optionFrom(e.target,!0))&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&(this._setKeyboard(!1),this._userChose=!0,this._setActive(t,!1))},this._onInput=e=>{this.hasAttribute(`filter`)&&e.target===this._input()&&(this._group=null,this._applyFilter(),this.refresh())}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousedown`,this._onMouseDown),this.addEventListener(`mousemove`,this._onMouseMove),this.addEventListener(`input`,this._onInput),this._modal=this.closest(`wui-modal`),this._modal?.addEventListener(`wui-modal-closed`,this._onModalClosed),this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){this.isConnected&&(e===`path`&&this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh())}get filter(){return this.hasAttribute(`filter`)}set filter(e){this.toggleAttribute(`filter`,!!e)}get highlight(){return this.getAttribute(`highlight`)!==`false`}set highlight(e){this.setAttribute(`highlight`,e?`true`:`false`)}get emptyText(){return this.getAttribute(`empty-text`)??o().emptyText}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){this._renderRecents(),this._renderCrumbs(),this._syncTabs();let e=this._input(),t=e?e.value:``,n=t!==this._lastQuery;this._lastQuery=t;let r=this._selectableOptions(),i=r.map(e=>e.id).join(`
2
+ `),a=i!==this._lastIds;this._lastIds=i;let o=!n&&(this._userChose||!a)?r.find(e=>e.id===this._activeId):null;o||(this._userChose=!1,this._setKeyboard(!1)),this._setActive(o??r[0]??null,n)}_input(){let e=this.querySelector(`[role="combobox"]`);return e instanceof HTMLInputElement?e:null}_optionFrom(e,t=!1){let n=p(e,a);return n&&this.contains(n)&&!this._isHidden(n)&&(t||!this._isDisabled(n))?n:null}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_isHidden(e){return e.hidden!==!1||(p(e,`[role="group"]`)?.hidden??!1)!==!1}_selectableOptions(){return h(this,a,HTMLElement).filter(e=>!this._isHidden(e)&&!this._isDisabled(e))}_setActive(e,t){this._activeId=e?e.id:null;for(let t of h(this,a,HTMLElement))t.setAttribute(`aria-selected`,t===e?`true`:`false`);let n=this._input();n&&(e?n.setAttribute(`aria-activedescendant`,e.id):n.removeAttribute(`aria-activedescendant`)),e&&t&&e.scrollIntoView({block:`nearest`})}_move(e){let t=this._selectableOptions();if(!t.length)return;let n=t.findIndex(e=>e.id===this._activeId),r=n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;this._userChose=!0,this._setKeyboard(!0),this._setActive(t[r]??null,!0)}_setKeyboard(e){this.toggleAttribute(`data-keyboard`,e)}_handleKeyDown(e){let t=this._input();if(t&&e.target===t){if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._move(e.key===`ArrowDown`?1:-1);else if(e.key===`Tab`&&this._groupActive()&&this._tabs().length)e.preventDefault(),this._cycleGroup(e.shiftKey?-1:1);else if(e.key===`Backspace`&&!e.isComposing&&this._path.length&&!t.value)e.preventDefault(),this._goTo(this._path.slice(0,-1));else if(e.key===`Enter`&&!e.isComposing){let t=this._selectableOptions().find(e=>e.id===this._activeId);if(!t)return;e.preventDefault(),this._select(t)}}}_select(e){this._remember(e),this.dispatchEvent(new CustomEvent(`wui-command-palette:select`,{bubbles:!0,cancelable:!0,detail:{key:e.dataset.key??null,groupKey:e.dataset.groupKey??null,id:e.id}}))&&(e.dataset.opens?this._open(e.dataset.opens):e.dataset.href&&this._navigate(e.dataset.href))}_open(e){let t=h(this,`.wui-cmd-page`,HTMLElement).find(t=>t.dataset.page===e);this._goTo([...this._path,{key:e,label:t?.dataset.label??e}])}_goTo(e){this._input()?.focus(),this.dispatchEvent(new CustomEvent(`wui-command-palette:navigate`,{bubbles:!0,cancelable:!0,detail:{path:e}}))&&(this._path=e,this._restart())}_tabs(){return h(this,u,HTMLElement)}_groupActive(){return this.hasAttribute(`group-filter`)&&this._path.length===0}_pickGroup(e){this._group=e,this._applyFilter(),this.refresh()}_cycleGroup(e){let t=this._tabs().map(e=>e.dataset.groupTab||null),n=Math.max(0,t.indexOf(this._group));this._pickGroup(t[(n+e+t.length)%t.length]??null)}_syncTabs(){if(!this.hasAttribute(`group-filter`))return;let e=m(this,`.wui-cmd-tabs`,HTMLElement);e&&(e.hidden=!this._groupActive());for(let e of this._tabs())e.setAttribute(`aria-selected`,String((e.dataset.groupTab||null)===this._group))}_restart(){this._group=null;let e=this._input();e&&(e.value=``),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}_reset(){this.hasAttribute(`path`)||(this._path=[],this._restart())}_readPath(){let e=this.getAttribute(`path`);if(e==null)return;let t=JSON.parse(e);this._path=Array.isArray(t)?t.filter(e=>e&&typeof e.key==`string`&&typeof e.label==`string`):[]}_renderCrumbs(){let e=m(this,`.wui-cmd-crumbs`,HTMLElement);if(!e)return;let t=this.getAttribute(`root-label`)??o().rootLabel,n=JSON.stringify([t,this._path]);if(e.hidden=this._path.length===0,n===this._crumbSig)return;this._crumbSig=n;let r=m(e,`.wui-cmd-trail`,HTMLElement);if(!r)return;let i=[t,...this._path.map(e=>e.label)];r.replaceChildren(...i.map((e,t)=>{let n=document.createElement(`li`),r=t===i.length-1,a=document.createElement(r?`span`:`button`);if(a.className=`wui-cmd-crumb`,a.textContent=e,r)a.setAttribute(`aria-current`,`page`);else{if(!(a instanceof HTMLButtonElement))throw Error(`breadcrumb button missing`);a.type=`button`,a.dataset.depth=String(t)}return n.append(a),n}))}_recentsHost(){return m(this,`.wui-cmd-recents`,HTMLElement)}_realOptions(){let e=this._recentsHost();return h(this,a,HTMLElement).filter(t=>!e?.contains(t))}_recentEntries(){let e=this.getAttribute(`recents-key`);if(!e)return[];let t;try{t=JSON.parse(globalThis.localStorage?.getItem(e)??`[]`)}catch{return[]}return Array.isArray(t)?t.filter(e=>e&&typeof e.g==`string`&&typeof e.k==`string`):[]}_recentsLimit(){let e=Number.parseInt(this.getAttribute(`recents-limit`)??``,10);return Number.isFinite(e)&&e>0?Math.min(e,c):s}_remember(e){let t=this.getAttribute(`recents-key`),{groupKey:n,key:r,opens:i}=e.dataset;if(!t||i||n==null||r==null)return;let a=[{g:n,k:r},...this._recentEntries().filter(e=>e.g!==n||e.k!==r)];try{globalThis.localStorage?.setItem(t,JSON.stringify(a.slice(0,this._recentsLimit())))}catch(e){if(!(e instanceof DOMException))throw e}}_renderRecents(){let e=this._recentsHost();if(!e)return;let t=this._input(),n=this._groupActive()?this._group:null,r=this._path.length===0&&!(t?.value??``).trim()?this._recentEntries().filter(e=>!n||e.g===n):[],i=this._realOptions(),a=[];for(let e of r){let t=i.find(t=>t.dataset.groupKey===e.g&&t.dataset.key===e.k);if(t&&!t.dataset.opens&&!this._isDisabled(t)&&a.push(t),a.length>=this._recentsLimit())break}if(!a.length){e.firstChild&&e.replaceChildren();return}let s=`${this._recentsId}-label`,c=document.createElement(`div`);c.className=`wui-cmd-group`,c.setAttribute(`role`,`group`),c.setAttribute(`aria-labelledby`,s);let l=document.createElement(`div`);l.className=`wui-cmd-group-label`,l.setAttribute(`role`,`presentation`),l.id=s,l.textContent=this.getAttribute(`recents-label`)??o().recentsLabel,c.append(l);for(let e of a){let t=e.cloneNode(!0);if(!(t instanceof HTMLElement))throw Error(`recent option copy is not an element`);t.id=`${this._recentsId}-${e.id}`,t.hidden=!1,t.removeAttribute(`aria-selected`),c.append(t)}e.replaceChildren(c)}_inScope(e,t){return!t||(p(e,`.wui-cmd-page`)?.dataset.page??null)===(this._path[this._path.length-1]?.key??null)}_navigate(e){window.location.assign(e)}_applyFilter(){let t=this._input(),n=(t?t.value:``).trim(),r=n.toLowerCase(),o=this.highlight,s=h(this,`.wui-cmd-page`,HTMLElement),c=s.length>0,l=this._path[this._path.length-1]?.key??null;for(let e of s)e.hidden=e.dataset.page!==l;let u=this._groupActive()?this._group:null,d=0;for(let t of this._realOptions()){let a=m(t,`.wui-cmd-item-label`,HTMLElement),s=t.dataset.label??a?.textContent??``,l=(t.dataset.keywords??``).split(/\s+/).filter(Boolean),f=!r||s.toLowerCase().includes(r)||l.some(e=>e.toLowerCase().includes(r)),p=this._inScope(t,c)&&(!u||t.dataset.groupKey===u)&&f;t.hidden=!p,p&&d++,a&&a.replaceChildren(...i(s,o?n:``).map(t=>t.match?e(`mark`,{class:`wui-cmd-mark`},t.text):t.text))}let f=this._recentsHost();for(let e of h(this,`[role="group"]`,HTMLElement))f?.contains(e)||(e.hidden=!h(e,a,HTMLElement).some(e=>!e.hidden));let p=m(this,`[role="listbox"]`,HTMLElement);p&&(p.hidden=d===0);let g=m(this,`.wui-cmd-empty`,HTMLElement);g&&(g.textContent=r&&d===0?this.emptyText:``)}_teardown(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousedown`,this._onMouseDown),this.removeEventListener(`mousemove`,this._onMouseMove),this.removeEventListener(`input`,this._onInput),this._modal?.removeEventListener(`wui-modal-closed`,this._onModalClosed),this._modal=null}};export{g as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{n}from"./commentText-NWsssKvj.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{t as i}from"./hasOwn-CJsplJ62.js";import{a,l as o,s}from"./nativeOverlay-BHD2QV02.js";import{n as c,t as l}from"./rtl-g7G8Bsib.js";import{t as u}from"./serverHtml-BC6tAyAl.js";import{m as d}from"./wuiHttp-Cw7V8u2w.js";import{r as f,t as p}from"./textStore-DBplASiZ.js";import{t as m}from"./commentThread.g-C7L18Tvy.js";import{t as h}from"./httpFailure.g-DjZzGxPj.js";import{r as g}from"./WuiMentionInput-DPpEVL2s.js";var _=`[data-wui-items]`,v=`[data-wui-picker]`,y=`[data-wui-composer]`,b=`[data-wui-comment]`,x=`[data-wui-live]`,S=()=>f(`commentThread`,m),C=e=>({forbidden:S().forbiddenMessage,networkCheck:f(`httpFailure`,h).networkCheckText,client:S().failedClientMessage,validation:S().validationMessage,server:S().failedServerMessage,network:f(`httpFailure`,h).networkText})[e],w=e=>({post:S().donePostText,reply:S().doneReplyText,edit:S().doneEditText,delete:S().doneDeleteText,react:``})[e],T=e=>{let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:S().failedServerMessage},E=e=>e instanceof Element?e:null,D=e=>`disabled`in e&&e.disabled===!0,O=(e,t)=>{if(e==null)throw Error(`${t} missing`);return e},k=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},A=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},j=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],M=class extends r{_wired;_busy;_peopleProp;_pickerFor;_openers;constructor(){super(),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this)}connectedCallback(){if(i(this,`people`)){let e=this.people;Reflect.deleteProperty(this,`people`),this.people=e}if(this._wired)return;this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey),customElements.upgrade(this);let e=k(this,`${y} wui-mention-input`,g);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:j(this,`:scope > [data-wui-people] > wui-option`,HTMLElement).map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_applyComposerPlaceholder(e){let t=this.getAttribute(`composer-placeholder`);e&&t!=null&&e.setAttribute(`placeholder`,t)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:n}_onClick(e){let t=A(E(e.target),`[data-wui-emoji]`,HTMLElement);if(t&&this.contains(t)&&!D(t)){let e=t.closest(v),n=e?this._pickerFor?.comment:t.closest(b);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=A(E(e.target),`[data-wui-action]`,HTMLElement);if(!n||!this.contains(n)||D(n))return;let r=n.closest(b);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:{let e=O(r,`comment`);this._send(`delete`,{commentId:e.getAttribute(`data-wui-comment`)},{comment:e,scope:e});break}case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(A(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=k(this,v,HTMLElement),n=E(e.target),r=c(e.key,l(this));if(this._pickerFor&&t?.contains(n)){let i=j(t,`[data-wui-emoji]`,HTMLElement),a=n instanceof HTMLElement?i.indexOf(n):-1;e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):r===`ArrowRight`||r===`ArrowLeft`?(e.preventDefault(),i[(a+(r===`ArrowRight`?1:-1)+i.length)%i.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let i=A(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement);if(i&&this.contains(i)){e.preventDefault(),e.stopPropagation(),this._closeSlot(i,!0);return}let a=A(n,`[data-wui-comment-confirm]`,HTMLElement);a&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(a.closest(b),!0))}_onSubmitKey(e){let t=k(A(E(e.target),`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement),`[data-wui-action="send"], [data-wui-action="post"]`,HTMLElement);t&&!D(t)&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=k(e,`:scope > [data-wui-reply]`,HTMLElement);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e?.querySelector(`.wui-comment-author`)?.textContent?.trim()||``;this._fillSlot(n,{label:p(S().replyToText,{author:r}),placeholder:S().replyPlaceholder,value:``,send:S().replyLabel,opener:t})}_openEditor(e,t){let n=k(e,`:scope > .wui-comment-row [data-wui-editor]`,HTMLElement);if(!n?.hidden)return;let r=k(O(n.parentElement,`comment row`),`:scope > [data-wui-text]`,HTMLElement);r&&(r.hidden=!0),this._fillSlot(n,{label:S().editCommentLabel,placeholder:``,value:e?.getAttribute(`data-value`)??``,send:S().saveLabel,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,s=o.createElement(`wui-mention-input`);s.className=`wui-mention-input`,s.setAttribute(`label`,t),n&&s.setAttribute(`placeholder`,n),s.setAttribute(`rows`,`2`),s.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`]){let t=this.getAttribute(e);t!=null&&s.setAttribute(e,t)}let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`solid`,`sm`,`send`,i),this._button(`primary`,`ghost`,`sm`,`cancel`,S().cancelLabel));let l=o.createElement(`div`);l.className=`wui-comment-error`,l.setAttribute(`data-wui-error`,``),l.hidden=!0,e.replaceChildren(s,c,l),this._handPeople(s),e.hidden=!1,this._openers??=/* @__PURE__ */ new WeakMap,this._openers.set(e,a),s.focus();let u=s.querySelector(`textarea`);u?.setSelectionRange(u.value.length,u.value.length)}_button(n,r,i,a,o){let s=this.ownerDocument.createElement(`button`);return s.type=`button`,s.className=e(n,r,i),s.dataset.wui=t,s.setAttribute(`data-wui-action`,a),s.textContent=o,s}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=k(e.parentElement,`:scope > [data-wui-text]`,HTMLElement);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=k(e,`:scope > .wui-comment-row`,HTMLElement),n=k(t,`[data-wui-comment-confirm]`,HTMLElement),r=k(t,`[data-wui-actions]`,HTMLElement);n&&(n.hidden=!1,r&&(r.hidden=!0),k(n,`[data-wui-action="cancel-delete"]`,HTMLElement)?.focus())}_closeConfirm(e,t){let n=k(e,`:scope > .wui-comment-row`,HTMLElement),r=k(n,`[data-wui-comment-confirm]`,HTMLElement),i=k(n,`[data-wui-actions]`,HTMLElement);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&k(i,`[data-wui-action="delete"]`,HTMLElement)?.focus()}_openPicker(e,t){let n=k(this,v,HTMLElement);n&&e&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:e,button:t},t.setAttribute(`aria-expanded`,`true`),o(t,n,{mode:`auto`,onClosed:()=>this._pickerClosed()}),k(n,`[data-wui-emoji]`,HTMLElement)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;let n=k(this,v,HTMLElement);n&&a(n),this._pickerClosed(),e&&t.button.isConnected&&t.button.focus()}_pickerClosed(){let e=k(this,v,HTMLElement),t=this._pickerFor;!t||e&&s(e)||(this._pickerFor=null,t.button.setAttribute(`aria-expanded`,`false`))}_react(e,t){t&&!this.hasAttribute(`no-reactions`)&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=A(e,`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,S().emptyBodyMessage),n?.focus();return}let i=t.closest(b);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:O(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:O(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??k(n,`:scope > .wui-comment-row`,HTMLElement)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>e instanceof HTMLButtonElement||e instanceof HTMLTextAreaElement).filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let s=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let c=t.commentId??null,l=t.parentId??null;s.ok?(s.html!=null&&this._swapItems(s.html),e===`post`?i?.querySelector(`wui-mention-input`)?.clear():i?.isConnected&&this._closeSlot(i,!1),e===`delete`&&n?.isConnected&&this._closeConfirm(n,!1),this._restoreFocus(e,t,i),w(e)&&this._announce(w(e)),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:c,parentId:l}}))):s.kind!==`session`&&s.kind!==`aborted`&&(this._showError(a.isConnected?a:this,s.message),this._announce(s.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:s.kind,message:s.message}})))}async _persist(e){if(this.hasAttribute(`controlled`)){if(typeof this.submit!=`function`)return{ok:!0,html:null};try{return await this.submit(e),{ok:!0,html:null}}catch(e){return{ok:!1,kind:`server`,message:T(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:S().failedClientMessage};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await d(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||C(r.kind)||S().failedServerMessage}}_swapItems(e){let t=k(this,_,HTMLElement);if(!t||!e.trim())return;let n=u(e),r=k(n,_,HTMLElement);t.replaceChildren(...r?r.childNodes:n.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!D(i))return;let a=e=>e?j(this,b,HTMLElement).find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>k(a(e),`:scope > .wui-comment-row`,HTMLElement),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=k(o(t.parentId),`[data-wui-action="reply"]`,HTMLElement);else if(e===`edit`)s=k(o(t.commentId),`[data-wui-action="edit"]`,HTMLElement);else if(e===`react`){let e=o(t.commentId);s=j(e,`button[data-wui-emoji]`,HTMLButtonElement).find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??k(e,`[data-wui-action="react-menu"]`,HTMLElement)}s??=k(this,`${y} textarea`,HTMLTextAreaElement),s?.focus()}_showError(e,t){let n=k(e,`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`,HTMLElement);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=k(this,`:scope > ${x}`,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}};export{M as t};
1
+ import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{n}from"./commentText-NWsssKvj.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{t as i}from"./hasOwn-CJsplJ62.js";import{a,l as o,s}from"./nativeOverlay-BHD2QV02.js";import{n as c,t as l}from"./rtl-g7G8Bsib.js";import{t as u}from"./serverHtml-BC6tAyAl.js";import{m as d}from"./wuiHttp-8CYWEbRz.js";import{r as f,t as p}from"./textStore-DBplASiZ.js";import{t as m}from"./commentThread.g-C7L18Tvy.js";import{t as h}from"./httpFailure.g-DjZzGxPj.js";import{r as g}from"./WuiMentionInput-DPCCSQRZ.js";var _=`[data-wui-items]`,v=`[data-wui-picker]`,y=`[data-wui-composer]`,b=`[data-wui-comment]`,x=`[data-wui-live]`,S=()=>f(`commentThread`,m),C=e=>({forbidden:S().forbiddenMessage,networkCheck:f(`httpFailure`,h).networkCheckText,client:S().failedClientMessage,validation:S().validationMessage,server:S().failedServerMessage,network:f(`httpFailure`,h).networkText})[e],w=e=>({post:S().donePostText,reply:S().doneReplyText,edit:S().doneEditText,delete:S().doneDeleteText,react:``})[e],T=e=>{let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:S().failedServerMessage},E=e=>e instanceof Element?e:null,D=e=>`disabled`in e&&e.disabled===!0,O=(e,t)=>{if(e==null)throw Error(`${t} missing`);return e},k=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},A=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},j=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],M=class extends r{_wired;_busy;_peopleProp;_pickerFor;_openers;constructor(){super(),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this)}connectedCallback(){if(i(this,`people`)){let e=this.people;Reflect.deleteProperty(this,`people`),this.people=e}if(this._wired)return;this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey),customElements.upgrade(this);let e=k(this,`${y} wui-mention-input`,g);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:j(this,`:scope > [data-wui-people] > wui-option`,HTMLElement).map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_applyComposerPlaceholder(e){let t=this.getAttribute(`composer-placeholder`);e&&t!=null&&e.setAttribute(`placeholder`,t)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:n}_onClick(e){let t=A(E(e.target),`[data-wui-emoji]`,HTMLElement);if(t&&this.contains(t)&&!D(t)){let e=t.closest(v),n=e?this._pickerFor?.comment:t.closest(b);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=A(E(e.target),`[data-wui-action]`,HTMLElement);if(!n||!this.contains(n)||D(n))return;let r=n.closest(b);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:{let e=O(r,`comment`);this._send(`delete`,{commentId:e.getAttribute(`data-wui-comment`)},{comment:e,scope:e});break}case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(A(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=k(this,v,HTMLElement),n=E(e.target),r=c(e.key,l(this));if(this._pickerFor&&t?.contains(n)){let i=j(t,`[data-wui-emoji]`,HTMLElement),a=n instanceof HTMLElement?i.indexOf(n):-1;e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):r===`ArrowRight`||r===`ArrowLeft`?(e.preventDefault(),i[(a+(r===`ArrowRight`?1:-1)+i.length)%i.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let i=A(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement);if(i&&this.contains(i)){e.preventDefault(),e.stopPropagation(),this._closeSlot(i,!0);return}let a=A(n,`[data-wui-comment-confirm]`,HTMLElement);a&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(a.closest(b),!0))}_onSubmitKey(e){let t=k(A(E(e.target),`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement),`[data-wui-action="send"], [data-wui-action="post"]`,HTMLElement);t&&!D(t)&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=k(e,`:scope > [data-wui-reply]`,HTMLElement);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e?.querySelector(`.wui-comment-author`)?.textContent?.trim()||``;this._fillSlot(n,{label:p(S().replyToText,{author:r}),placeholder:S().replyPlaceholder,value:``,send:S().replyLabel,opener:t})}_openEditor(e,t){let n=k(e,`:scope > .wui-comment-row [data-wui-editor]`,HTMLElement);if(!n?.hidden)return;let r=k(O(n.parentElement,`comment row`),`:scope > [data-wui-text]`,HTMLElement);r&&(r.hidden=!0),this._fillSlot(n,{label:S().editCommentLabel,placeholder:``,value:e?.getAttribute(`data-value`)??``,send:S().saveLabel,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,s=o.createElement(`wui-mention-input`);s.className=`wui-mention-input`,s.setAttribute(`label`,t),n&&s.setAttribute(`placeholder`,n),s.setAttribute(`rows`,`2`),s.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`]){let t=this.getAttribute(e);t!=null&&s.setAttribute(e,t)}let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`solid`,`sm`,`send`,i),this._button(`primary`,`ghost`,`sm`,`cancel`,S().cancelLabel));let l=o.createElement(`div`);l.className=`wui-comment-error`,l.setAttribute(`data-wui-error`,``),l.hidden=!0,e.replaceChildren(s,c,l),this._handPeople(s),e.hidden=!1,this._openers??=/* @__PURE__ */ new WeakMap,this._openers.set(e,a),s.focus();let u=s.querySelector(`textarea`);u?.setSelectionRange(u.value.length,u.value.length)}_button(n,r,i,a,o){let s=this.ownerDocument.createElement(`button`);return s.type=`button`,s.className=e(n,r,i),s.dataset.wui=t,s.setAttribute(`data-wui-action`,a),s.textContent=o,s}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=k(e.parentElement,`:scope > [data-wui-text]`,HTMLElement);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=k(e,`:scope > .wui-comment-row`,HTMLElement),n=k(t,`[data-wui-comment-confirm]`,HTMLElement),r=k(t,`[data-wui-actions]`,HTMLElement);n&&(n.hidden=!1,r&&(r.hidden=!0),k(n,`[data-wui-action="cancel-delete"]`,HTMLElement)?.focus())}_closeConfirm(e,t){let n=k(e,`:scope > .wui-comment-row`,HTMLElement),r=k(n,`[data-wui-comment-confirm]`,HTMLElement),i=k(n,`[data-wui-actions]`,HTMLElement);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&k(i,`[data-wui-action="delete"]`,HTMLElement)?.focus()}_openPicker(e,t){let n=k(this,v,HTMLElement);n&&e&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:e,button:t},t.setAttribute(`aria-expanded`,`true`),o(t,n,{mode:`auto`,onClosed:()=>this._pickerClosed()}),k(n,`[data-wui-emoji]`,HTMLElement)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;let n=k(this,v,HTMLElement);n&&a(n),this._pickerClosed(),e&&t.button.isConnected&&t.button.focus()}_pickerClosed(){let e=k(this,v,HTMLElement),t=this._pickerFor;!t||e&&s(e)||(this._pickerFor=null,t.button.setAttribute(`aria-expanded`,`false`))}_react(e,t){t&&!this.hasAttribute(`no-reactions`)&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=A(e,`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,S().emptyBodyMessage),n?.focus();return}let i=t.closest(b);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:O(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:O(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??k(n,`:scope > .wui-comment-row`,HTMLElement)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>e instanceof HTMLButtonElement||e instanceof HTMLTextAreaElement).filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let s=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let c=t.commentId??null,l=t.parentId??null;s.ok?(s.html!=null&&this._swapItems(s.html),e===`post`?i?.querySelector(`wui-mention-input`)?.clear():i?.isConnected&&this._closeSlot(i,!1),e===`delete`&&n?.isConnected&&this._closeConfirm(n,!1),this._restoreFocus(e,t,i),w(e)&&this._announce(w(e)),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:c,parentId:l}}))):s.kind!==`session`&&s.kind!==`aborted`&&(this._showError(a.isConnected?a:this,s.message),this._announce(s.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:s.kind,message:s.message}})))}async _persist(e){if(this.hasAttribute(`controlled`)){if(typeof this.submit!=`function`)return{ok:!0,html:null};try{return await this.submit(e),{ok:!0,html:null}}catch(e){return{ok:!1,kind:`server`,message:T(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:S().failedClientMessage};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await d(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||C(r.kind)||S().failedServerMessage}}_swapItems(e){let t=k(this,_,HTMLElement);if(!t||!e.trim())return;let n=u(e),r=k(n,_,HTMLElement);t.replaceChildren(...r?r.childNodes:n.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!D(i))return;let a=e=>e?j(this,b,HTMLElement).find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>k(a(e),`:scope > .wui-comment-row`,HTMLElement),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=k(o(t.parentId),`[data-wui-action="reply"]`,HTMLElement);else if(e===`edit`)s=k(o(t.commentId),`[data-wui-action="edit"]`,HTMLElement);else if(e===`react`){let e=o(t.commentId);s=j(e,`button[data-wui-emoji]`,HTMLButtonElement).find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??k(e,`[data-wui-action="react-menu"]`,HTMLElement)}s??=k(this,`${y} textarea`,HTMLTextAreaElement),s?.focus()}_showError(e,t){let n=k(e,`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`,HTMLElement);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=k(this,`:scope > ${x}`,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}};export{M as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./elementBase-Cxeyx0tU.js";import{r as t,t as n}from"./textStore-DBplASiZ.js";import{t as r}from"./dashboardGrid.g-vkCZGw6G.js";var i=`wui:layoutchange`,a=`wui:reset`,o=`wui-dashboard-cell`,s=`wui-dashboard-cell-tools`,c=`wui-dashboard-grid-bar`,l=`wui-dashboard-grid-menu`,u=`wui-dashboard-grid-live`,d=()=>t(`dashboardGrid`,r);function f(e){if(e.classList.contains(`wui-dashboard-cell-fifth`))return 5;for(let t of[3,4,6,8])if(e.classList.contains(`wui-dashboard-cell-${t}`))return t;return 12}function p(e){let t=document.createElement(`p`);return t.className=`wui-dashboard-grid-empty`,t.textContent=e,t}function m(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.className=n,r.dataset.wuiAction=t,r.textContent=e,r}var h=class extends e{tools=null;live=null;menu=null;add=null;observer=null;menuKey=null;focusId=null;connectedCallback(){this.hasAttribute(`editable`)&&(this.checkCells(),this.tools||this.build(),this.observer=new MutationObserver(()=>this.sync()),this.observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`]}),this.addEventListener(`click`,this.onClick),this.addEventListener(`keydown`,this.onKeydown))}disconnectedCallback(){this.observer?.disconnect(),this.observer=null,this.removeEventListener(`click`,this.onClick),this.removeEventListener(`keydown`,this.onKeydown)}cells(){return Array.from(this.children).filter(e=>e instanceof HTMLElement&&e.classList.contains(o))}checkCells(){for(let e of this.cells())if(!e.dataset.widgetId)throw Error(`<wui-dashboard-grid>: every cell needs a widget id (data-widget-id) when the grid is editable.`)}cellById(e){return this.cells().find(t=>t.dataset.widgetId===e)}titleFor(e){let t=this.cellById(e);return t?this.titleOf(t):e}titleOf(e){return e.dataset.wuiTitle??e.dataset.widgetId??``}build(){let e=d(),t=document.createElement(`div`);t.className=c,t.setAttribute(`role`,`toolbar`),t.setAttribute(`aria-label`,e.editLabel);let r=m(e.addLabel,`add`,`wui-dashboard-grid-add`);r.setAttribute(`aria-expanded`,`false`);let i=document.createElement(`div`);i.className=l,i.hidden=!0,t.append(r,i,m(e.resetLabel,`reset`,`wui-dashboard-grid-reset`));let a=document.createElement(`p`);a.className=u,a.setAttribute(`role`,`status`),a.setAttribute(`aria-live`,`polite`),this.prepend(t,a),this.tools=t,this.menu=i,this.add=r,this.live=a;for(let t of this.cells()){t.tabIndex=0;let r=this.titleOf(t),i=document.createElement(`div`);i.className=s,i.append(this.cellButton(n(e.earlierLabel,{title:r}),e.earlierText,`earlier`),this.cellButton(n(e.laterLabel,{title:r}),e.laterText,`later`),this.cellButton(n(e.hideLabel,{title:r}),e.hideText,`hide`)),t.prepend(i)}this.sync()}cellButton(e,t,n){let r=m(t,n,`wui-dashboard-cell-tool`);return r.setAttribute(`aria-label`,e),r}layout(){return this.cells().map(e=>({id:e.dataset.widgetId??``,span:f(e),hidden:e.hidden!==!1}))}sync(){if(!this.menu||!this.add)return;let e=this.cells().filter(e=>e.hidden),t=e.map(e=>e.dataset.widgetId??``).join(`\0`);if(t!==this.menuKey){this.menuKey=t;let r=d(),i=e.length===0?[p(r.addEmptyText)]:e.map(e=>{let t=this.titleOf(e),i=m(n(r.showLabel,{title:t}),`show`,`wui-dashboard-grid-show`);return i.dataset.widgetId=e.dataset.widgetId??``,i});this.menu.replaceChildren(...i)}if(this.focusId!==null){let e=this.cellById(this.focusId);this.focusId=null,e&&!e.hidden&&e.focus()}}commit(e,t,n){this.focusId=n,this.hasAttribute(`controlled`)||(this.apply(e),this.sync()),this.live&&(this.live.textContent=t),this.dispatchEvent(new CustomEvent(i,{bubbles:!0,detail:JSON.stringify(e)}))}apply(e){for(let t of e){let e=this.cellById(t.id);e&&(this.append(e),e.hidden=t.hidden)}}moveBy(e,t){let r=this.layout(),i=r.filter(e=>!e.hidden),a=i.findIndex(t=>t.id===e);if(a<0)return;let o=i[a],s=i[a+t];if(!o||!s)return;let c=r.indexOf(o),l=r.indexOf(s);[r[c],r[l]]=[s,o];let u=this.titleFor(e),f=a+t+1;this.commit(r,n(d().movedText,{title:u,position:f,count:i.length}),e)}setHidden(e,t){let r=this.layout(),i=r.find(t=>t.id===e);if(!i)return;i.hidden=t;let a=this.titleFor(e),o=d();if(t){this.commit(r,n(o.hiddenText,{title:a}),null);return}let s=r.filter(e=>!e.hidden),c=s.findIndex(t=>t.id===e)+1;this.commit(r,n(o.shownText,{title:a,position:c,count:s.length}),e)}reset(){this.live&&(this.live.textContent=d().resetText),this.dispatchEvent(new CustomEvent(a,{bubbles:!0}))}onClick=e=>{let t=e.target instanceof Element?e.target.closest(`button[data-wui-action]`):null;if(!(t instanceof HTMLButtonElement))return;let n=t.dataset.wuiAction;if(n===`reset`){this.reset();return}if(n===`add`){this.menu&&(this.menu.hidden=!this.menu.hidden),this.add?.setAttribute(`aria-expanded`,String(this.menu?.hidden===!1));return}if(n===`show`){this.setHidden(t.dataset.widgetId??``,!1);return}let r=t.closest(`.${o}`),i=r instanceof HTMLElement?r.dataset.widgetId:void 0;i&&(n===`earlier`&&this.moveBy(i,-1),n===`later`&&this.moveBy(i,1),n===`hide`&&this.setHidden(i,!0))};onKeydown=e=>{let t=e.target;if(!(t instanceof HTMLElement)||t.parentElement!==this||!t.classList.contains(o))return;let n=t.dataset.widgetId;if(!n)return;let r=null;(e.key===`ArrowLeft`||e.key===`ArrowUp`)&&(r=-1),(e.key===`ArrowRight`||e.key===`ArrowDown`)&&(r=1),r!==null&&(e.preventDefault(),this.moveBy(n,r))}};export{a as n,h as r,i as t};
@@ -0,0 +1 @@
1
+ import{D as e,F as t,I as n,L as r,O as i,S as a,T as o,_ as s,g as c,h as l,m as u,r as d,s as f,t as p,u as m,w as h,x as g}from"./dataTable-C0q14bkP.js";import{t as _}from"./dom-DMQu--xV.js";import{t as v}from"./elementBase-Cxeyx0tU.js";import{n as y}from"./imeSafeEnter-DeO_3lXy.js";import{t as b}from"./svgNodes-CyPS2oFH.js";import{o as x,s as S}from"./tableSelect-juA3KcQh.js";function C(){return import(`./tableExport-D1OdFVQj.js`).then(e=>e.r)}var w=`.wui-col-resize`,T=`.wui-group-row, .wui-virtual-spacer`,E=`.wui-select-cell, .wui-expand-cell`;function D(){return b({class:`wui-icon`,"data-icon":`chevron-down`,"data-wui":`AppIcon`,width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`},[[`path`,{stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":`10`,"stroke-width":`1.5`,d:`M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95`}]])}function O(e){if(e==null)throw TypeError(`Missing DOM node`);return e}function k(e,t){if(e instanceof t)return e;throw TypeError(`Missing DOM node`)}var A=e=>{let t=_(e,w);return t instanceof HTMLElement?t:null},j=e=>e.hasAttribute(`data-wui-skeleton`)||!!e.querySelector(`:scope > td > .skeleton`),M=class extends v{_frame;_headDirty;_rowsDirty;_frozenSig;_natural;_widths;_collapsed;_groupOrder;_items;_range;_drag;_userSized;_swallowClick;_mo;_ro;_fonts;_onPointerDown;_onKeyDown;_onClick;_onDblClick;_onScroll;_onFonts;_top=null;_bottom=null;_rowHeight=0;constructor(){super(),this._frame=0,this._headDirty=!0,this._rowsDirty=!0,this._frozenSig=null,this._natural=[],this._widths={},this._collapsed=/* @__PURE__ */ new Set,this._groupOrder=[],this._items=[],this._range=null,this._drag=null,this._userSized=!1,this._swallowClick=!1,this._mo=null,this._ro=null,this._fonts=null,this._onPointerDown=e=>this._startDrag(e),this._onKeyDown=e=>this._key(e),this._onClick=e=>this._click(e),this._onDblClick=e=>{let t=A(e.target);t&&this.contains(t)&&this._reset(t.closest(`th`))},this._onScroll=()=>{this.hasAttribute(`virtual`)&&this._schedule()},this._onFonts=()=>{this._userSized||this._drag||this._frozenSig===null||!this.hasAttribute(`resizable`)||(this._frozenSig=null,this._schedule())}}connectedCallback(){this._widths=e(this.getAttribute(`view-key`)),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick,!0),this.addEventListener(`dblclick`,this._onDblClick),this.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._fonts=this.ownerDocument.fonts??null,this._fonts?.addEventListener(`loadingdone`,this._onFonts),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(e=>this._mutated(e)),this._mo.observe(this,{childList:!0,subtree:!0})),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._schedule()),this._ro.observe(this)),this._headDirty=!0,this._rowsDirty=!0,this._paintSaves(),this._schedule()}_paintSaves(){this.querySelectorAll(`tbody > tr[data-wui-save-state]`).forEach(e=>{e instanceof HTMLTableRowElement&&g(e,e.getAttribute(m))})}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick,!0),this.removeEventListener(`dblclick`,this._onDblClick),this.removeEventListener(`scroll`,this._onScroll),this._fonts?.removeEventListener(`loadingdone`,this._onFonts),this._fonts=null,this._mo?.disconnect(),this._ro?.disconnect(),this._mo=null,this._ro=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this._drag=null}refresh(){this._headDirty=!0,this._rowsDirty=!0,this._run()}get _table(){let e=this.querySelector(`:scope > table`);return e instanceof HTMLTableElement?e:null}_headCells(e){let t=e.tHead?.rows[0];return t?[...t.cells]:[]}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._run()})}_mutated(e){for(let t of e){let e=t.target instanceof Element?t.target:t.target.parentElement;e&&((e.closest(`thead`)||e===this._table||e===this)&&(this._headDirty=!0),(e.closest(`tbody, tfoot`)||e===this._table||e===this)&&(this._rowsDirty=!0))}this._schedule()}_run(){let e=this._table;if(!e)return;let t=this._headDirty,n=this._rowsDirty;this._headDirty=!1,this._rowsDirty=!1,n&&this.hasAttribute(`group-by`)&&this._group(e),this._pins(e,t||n),this.hasAttribute(`resizable`)&&(t&&this._handles(e),this._layout(e)),this.hasAttribute(`virtual`)&&this._virtual(e,t||n),this._mo?.takeRecords()}_pins(e,t){let n=this._headCells(e),r=n.map(e=>{let t=e.dataset.pin;return t===`start`||t===`end`?t:e.matches(E)?`lead`:null});if(!r.some(e=>e===`start`||e===`end`))return;let i=o(r);i.forEach((e,t)=>{e&&this._ro?.observe(O(n[t]))});let s=e=>O(n[e]).getBoundingClientRect().width,c=0;i.forEach((t,n)=>{t?.side===`start`&&(this._setVar(e,h(`start`,t.ordinal),c),c+=s(n))}),c=0;for(let t=i.length-1;t>=0;t--){let n=i[t];n?.side===`end`&&(this._setVar(e,h(`end`,n.ordinal),c),c+=s(t))}if(t)for(let t of e.rows)t.matches(`${T}, .wui-row-expanded`)||t.cells.length!==n.length||i.forEach((e,n)=>{if(!e)return;let r=O(t.cells[n]);r.classList.contains(`wui-pin-${e.side}`)||r.classList.add(`wui-pin-${e.side}`),e.edge&&!r.classList.contains(`wui-pin-${e.side}-edge`)&&r.classList.add(`wui-pin-${e.side}-edge`);let i=a(e.side,e.ordinal);r.style.getPropertyValue(`--wui-pin-at`)!==i&&r.style.setProperty(d,i)})}_setVar(e,t,n){let r=`${Math.round(n*100)/100}px`;e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}_resizable(e){return e.map((t,n)=>n<e.length-1&&!t.matches(E))}_handles(e){let t=this._headCells(e),n=this._resizable(t);t.forEach((e,t)=>{if(!n[t]||e.querySelector(w))return;let r=e.ownerDocument.createElement(`span`);r.className=`wui-col-resize`,r.setAttribute(`role`,`separator`),r.setAttribute(`aria-orientation`,`vertical`),r.setAttribute(`aria-valuemin`,`48`),r.setAttribute(`aria-valuemax`,String(p)),r.setAttribute(`tabindex`,`0`);let a=(e.textContent??``).trim();r.setAttribute(`aria-label`,i(a)),a&&!e.hasAttribute(`aria-label`)&&e.setAttribute(`aria-label`,a),e.classList.add(`wui-col-resizable`),e.appendChild(r)})}_hasRows(e){for(let t of e.tBodies)for(let e of t.rows)if(!e.matches(T)&&!j(e))return!0;return!1}_signature(e){return e.map(e=>e.dataset.key||(e.textContent??``).trim()).join(``)}_layout(e){let t=this._headCells(e),n=this._signature(t);t.length&&n!==this._frozenSig&&(this._hasRows(e)?this._freeze(e,t,n):this._applyRemembered(t))}_applyRemembered(e){for(let t of e){let e=t.dataset.key&&this._widths[t.dataset.key];e&&(t.style.width=`${e}px`);let n=t.querySelector(w);n&&this._handleValue(n,u(e||t.getBoundingClientRect().width))}}_freeze(e,t,n){e.style.tableLayout=``,e.style.width=``,e.removeAttribute(`data-wui-fixed`);for(let e of t)e.hasAttribute(`data-wui-width`)&&(e.style.width=``,e.removeAttribute(`data-wui-width`));this._natural=t.map(e=>e.getBoundingClientRect().width),t.forEach((e,n)=>{if(n===t.length-1||e.matches(E))return;let r=e.dataset.key&&this._widths[e.dataset.key];this._setWidth(e,r||this._natural[n])}),e.style.tableLayout=`fixed`,e.setAttribute(`data-wui-fixed`,``),this._frozenSig=n,this._fitTable(e,t)}_setWidth(e,t){let n=u(t);e.style.width=`${n}px`,e.setAttribute(`data-wui-width`,``);let r=e.querySelector(w);return r&&this._handleValue(r,n),n}_handleValue(e,t){e.setAttribute(`aria-valuenow`,String(t)),e.setAttribute(`aria-valuetext`,n(t))}_fitTable(e,t){let n=t.length-1,r=this._natural[n]||0;for(let e=0;e<n;e++)r+=Number.parseFloat(O(t[e]).style.width)||this._natural[e]||0;e.style.width=`max(100%, ${Math.round(r)}px)`}_ensureFrozen(e){let t=this._headCells(e),n=this._signature(t);return n!==this._frozenSig&&this._freeze(e,t,n),t}_resizeTo(e,t,n){let r=this._table;if(!r)return;let i=this._ensureFrozen(r);this._userSized=!0,this._setWidth(e,t),this._fitTable(r,i),n&&this._remember(e),this._pins(r,!1)}_remember(e){let t=e.dataset.key;t&&(this._widths={...this._widths,[t]:Number.parseFloat(e.style.width)},r(this.getAttribute(`view-key`),this._widths))}_reset(e){let t=this._table;if(!e||!t)return;let n=this._ensureFrozen(t);this._userSized=!0;let i=e.dataset.key;if(i&&i in this._widths){let{[i]:e,...t}=this._widths;this._widths=t,r(this.getAttribute(`view-key`),this._widths)}this._setWidth(e,this._natural[n.indexOf(e)]||0),this._fitTable(t,n),this._pins(t,!1)}_rtl(){return getComputedStyle(this).direction===`rtl`}_startDrag(e){let t=A(e.target);if(!t||!this.contains(t)||e.button!==0)return;e.preventDefault(),e.stopPropagation();let n=t.closest(`th`),r=this._table;if(!n||!r)return;this._ensureFrozen(r);let i={th:n,x:e.clientX,from:n.getBoundingClientRect().width,dir:this._rtl()?-1:1,moved:!1};this._drag=i,t.setPointerCapture?.(e.pointerId),t.classList.add(`is-dragging`);let a=e=>{let t=(e.clientX-i.x)*i.dir;Math.abs(t)>1&&(i.moved=!0),this._resizeTo(n,i.from+t,!1)},o=e=>{t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o),t.classList.remove(`is-dragging`),this._drag=null,e.type===`pointercancel`?this._resizeTo(n,i.from,!1):i.moved&&this._remember(n),this._swallowClick=!0,setTimeout(()=>{this._swallowClick=!1},0)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}_key(e){let t=A(e.target);if(!t||!this.contains(t))return;let n=t.closest(`th`);if(y(e)||e.key===` `){e.preventDefault(),e.stopPropagation();return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),this._reset(n);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault(),e.stopPropagation();let r=this._table;if(!r)return;this._ensureFrozen(r);let i=O(n),a=e.shiftKey?50:10,o=e.key===`ArrowRight`!==this._rtl(),s=Number.parseFloat(i.style.width)||i.getBoundingClientRect().width;this._resizeTo(i,s+(o?a:-a),!0)}_click(e){let t=e.target instanceof Element&&e.target.closest(w)!==null;if(this._swallowClick||t){e.stopPropagation(),(t||this._swallowClick)&&e.preventDefault(),this._swallowClick=!1;return}let n=_(e.target,`[data-wui-table-export], [data-wui-density]`);if(n&&this.contains(n)){e.preventDefault(),n.hasAttribute(`data-wui-density`)?this._setDensity(n.getAttribute(`data-wui-density`)??``):this._export(n.getAttribute(`data-wui-table-export`)??``);return}if(!this.hasAttribute(`group-by`))return;let r=_(e.target,`.wui-group-toggle`)?.closest(`.wui-group-row`);if(!(r instanceof HTMLTableRowElement)||!this.contains(r))return;let i=r.dataset.groupKey;this._collapsed.has(i)?this._collapsed.delete(i):this._collapsed.add(i),this._showGroup(r,!this._collapsed.has(i));let a=this._table;a&&this.hasAttribute(`virtual`)&&(this._virtual(a,!0),this._mo?.takeRecords())}async _export(e){if(e!==`csv`&&e!==`xlsx`)return;let t=this.querySelector(`:scope > table`);if(!(t instanceof HTMLTableElement))return;let n=Array.from(t.tBodies[0]?.rows??[]).filter(e=>!e.hidden&&!e.matches(`.wui-group-row, .wui-virtual-spacer, .wui-row-expanded`)&&!j(e)),r=/* @__PURE__ */ new Set;for(let e of n)for(let[t,n]of Array.from(e.cells).entries())(n.matches(E)||n.querySelector(`.u-row-actions`))&&r.add(t);let i=e=>Array.from(e).filter((e,t)=>!r.has(t)).map(e=>{let t=e.cloneNode(!0);if(!(t instanceof Element))return``;for(let e of t.querySelectorAll(`.visually-hidden, .wui-col-resize, .infotip`))e.remove();return(t.textContent??``).replace(/\s+/g,` `).trim()}),a=i(t.tHead?.rows[0]?.cells??[]),o=n.map(e=>i(e.cells)),s=this.getAttribute(`export-name`)??`table`,{downloadTable:c,tableCsv:l,tableXlsx:u}=await C();e===`csv`?c([l(a,o)],`text/csv;charset=utf-8`,`${s}.csv`):c([u(a,o)],`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`${s}.xlsx`)}_setDensity(e){let t=this.querySelector(`:scope > table`);if(t instanceof HTMLTableElement){t.classList.remove(`wui-table-cozy`,`wui-table-compact`),(e===`cozy`||e===`compact`)&&t.classList.add(`wui-table-${e}`);for(let t of this.querySelectorAll(`[data-wui-density]`))t.setAttribute(`aria-pressed`,String(t.getAttribute(`data-wui-density`)===e))}}_group(e){let t=this.getAttribute(`group-by`),n=this._headCells(e),r=n.findIndex(e=>e.dataset.key===t);if(r<0)throw Error(`<wui-data-table group-by="${t}"> needs a header cell with data-key="${t}".`);let i=e.tBodies[0];if(!i)return;let a=[...i.rows].filter(e=>!e.matches(T));if(a.some(j))return;let o=this.ownerDocument,u=/* @__PURE__ */ new Map;for(let e of i.querySelectorAll(`:scope > tr.wui-group-row`))e instanceof HTMLTableRowElement&&u.set(e.dataset.groupKey,e);let d=this.closest(`[data-wui-server]`)?[]:this._groupOrder,f=c(a,e=>e.dataset.group??e.cells[r]?.textContent?.trim()??``,d);this._groupOrder=f.map(e=>e.key);let p=o.createDocumentFragment(),m=e.hasAttribute(`data-app-datatable-selectable`),h=f.map(e=>{let t=u.get(e.key)??this._groupRow(o,e.key);u.delete(e.key);let r=k(t.querySelector(`.wui-group-cell`),HTMLTableCellElement);return m&&!t.querySelector(`.wui-group-select`)&&t.insertBefore(x(o,e.key),r),r.colSpan=m?n.length-1:n.length,k(t.querySelector(`.wui-group-count`),HTMLElement).textContent=l(e.items.length),k(t.querySelector(`.wui-group-rows`),HTMLElement).textContent=`, ${s(e.items.length)}`,p.append(t,...e.items),[t,e.key]});for(let e of u.values())e.remove();i.insertBefore(p,this._bottom?.parentNode===i?this._bottom:null);for(let[e,t]of h)this._showGroup(e,!this._collapsed.has(t));m&&S(e)}_groupRow(e,t){let n=e.createElement(`tr`);n.className=`wui-group-row`,n.dataset.groupKey=t;let r=e.createElement(`th`);r.className=`wui-group-cell`,r.scope=`rowgroup`;let i=e.createElement(`button`);i.type=`button`,i.className=`wui-group-toggle`,i.replaceChildren(D());let a=e.createElement(`span`);a.className=`wui-group-label`,a.textContent=t;let o=e.createElement(`span`);o.className=`wui-group-count`,o.setAttribute(`aria-hidden`,`true`);let s=e.createElement(`span`);return s.className=`visually-hidden wui-group-rows`,i.append(a,o,s),r.append(i),n.append(r),n}_showGroup(e,t){if(e){e.querySelector(`.wui-group-toggle`)?.setAttribute(`aria-expanded`,String(t));for(let n=e.nextElementSibling;n&&!n.matches(T);n=n.nextElementSibling)n instanceof HTMLElement&&(n.hidden=!t)}}_spacer(e,t){if(t?.parentNode===e)return t;let n=e.ownerDocument,r=n.createElement(`tr`);return r.className=`wui-virtual-spacer`,r.setAttribute(`aria-hidden`,`true`),r.append(n.createElement(`td`)),r}_virtual(e,n){let r=e.tBodies[0];if(!r)return;if(n){this._top=this._spacer(r,this._top),this._bottom=this._spacer(r,this._bottom),r.firstElementChild!==this._top&&r.insertBefore(this._top,r.firstChild),r.lastElementChild!==this._bottom&&r.append(this._bottom);let t=Math.max(1,this._headCells(e).length);O(this._top.cells[0]).colSpan=t,O(this._bottom.cells[0]).colSpan=t,this._items=[...r.rows].filter(e=>!e.classList.contains(`wui-virtual-spacer`)&&!e.hidden),this._range=null,e.setAttribute(`aria-rowcount`,String(this._items.length+1)),e.tHead?.rows[0]?.setAttribute(`aria-rowindex`,`1`),this._items.forEach((e,t)=>{e.setAttribute(`aria-rowindex`,String(t+2))}),this._rowHeight>0||(this._rowHeight=this._measureRow(e))}let i=e.tHead?.getBoundingClientRect().height||0,a=t({scrollTop:this.scrollTop-i,viewport:this.clientHeight,rowHeight:this._rowHeight,count:this._items.length}),o=this._range;if(o&&o.start===a.start&&o.end===a.end)return;let s=o?Math.min(o.start,a.start):0,c=o?Math.max(o.end,a.end):this._items.length;for(let e=s;e<c;e++){let t=e<a.start||e>=a.end,n=O(this._items[e]);n.classList.contains(`wui-virtual-off`)!==t&&n.classList.toggle(`wui-virtual-off`,t)}this._range=a;let l=O(this._top),u=O(this._bottom);l.hidden=a.before===0,u.hidden=a.after===0,O(l.cells[0]).style.height=`${a.before}px`,O(u.cells[0]).style.height=`${a.after}px`}_measureRow(e){let t=this._items.find(e=>!e.classList.contains(`wui-group-row`)&&!e.classList.contains(`wui-virtual-off`))?.getBoundingClientRect().height??0;return t>0?t:e.classList.contains(`wui-table-compact`)?f.compact:e.classList.contains(`wui-table-cozy`)?f.cozy:f.comfortable}};export{M as t};
@@ -0,0 +1 @@
1
+ import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./calendarMath-CT99RyhR.js";import{i as f,r as p}from"./dom-DMQu--xV.js";import{t as m}from"./elementBase-Cxeyx0tU.js";import{r as h,t as g}from"./fieldState-D-zQcXUS.js";import{_,b as v,g as y}from"./formatters-DTW53DjY.js";import{t as b}from"./formMirror-9IpSgeZb.js";import{t as x}from"./iconGlyphs.g-a9FtjPXh.js";import{a as S,l as C,s as w}from"./nativeOverlay-BHD2QV02.js";import{n as T,t as E}from"./rtl-g7G8Bsib.js";import{r as D}from"./textStore-DBplASiZ.js";import{t as O}from"./datePicker.g-sGQE8c3n.js";var k=()=>D(`datePicker`,O),A=e=>e-(e%10+10)%10-1,j=class extends m{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`disabled-weekdays`,`display-format`,`mode`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}_internals;_value;_defaultValue;_rendered;_viewY;_viewM;_mode;_focus;_gridFocus;_slide;_viewNavigated;_openFn;_closeFn;_onKeyBound;_closingQuietly;get _open(){return f(this._openFn,`open missing`)}get _close(){return f(this._closeFn,`close missing`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._gridFocus=null,this._slide=``}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`)this._syncInvalid();else if(this._rendered){if(e===`value`)this._value=n||``,this._syncFormValue(),this._syncTrigger();else if(e===`display-format`)this._syncTrigger();else if(e===`first-day`){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&w(e)&&this._renderView()}else this.render()}}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e instanceof HTMLButtonElement&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,b(this,this._value),this._syncTrigger()}_firstDay(){return c(this)}_monthOnly(){return this.getAttribute(`mode`)===`month`}_yearOnly(){return this.getAttribute(`mode`)===`year`}_monthKey(e){return e&&this.hasAttribute(`value-as-date`)?e.slice(0,7):e}_monthStored(e){return this.hasAttribute(`value-as-date`)?`${e}-01`:e}_parts(e){if(this._yearOnly()){let t=a(e);return t?{y:t.y,m:0,d:1}:null}if(!this._monthOnly())return l(e);let n=t(this._monthKey(e));return n?{y:n.y,m:n.m,d:1}:null}_placeholder(){return this.getAttribute(`placeholder`)||(this._yearOnly()?k().yearPlaceholder:this._monthOnly()?k().monthPlaceholder:k().placeholder)}_label(t){let n=this.getAttribute(`display-format`);return this._yearOnly()?s(t,n):this._monthOnly()?e(this._monthKey(t)||``,n):i(t,n)}render(){this._dropPanel(),this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this._placeholder(),t=this._parts(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),r=n===`sm`?` wui-input-sm`:n===`lg`?` wui-input-lg`:n===`xl`?` wui-input-xl`:``,i=this.getAttribute(`aria-label`),a=this.getAttribute(`aria-describedby`);this.replaceChildren(p(`div`,{class:`datepicker`},p(`button`,{type:`button`,class:`input datepicker-trigger${r}${t?` has-value`:``}${this.classList.contains(`wui-input-underline`)?` wui-input-underline`:``}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)?!0:void 0,"aria-label":i,"aria-describedby":a},p(`span`,{"data-trigger-label":!0,class:t?``:`wui-select-placeholder`},t?this._label(this._value):e),x(`calendar-dots`)),p(`div`,{class:`datepicker-pop`,role:`dialog`,popover:`auto`}))),this._rendered=!0,h(this,this.querySelector(`.datepicker-trigger`)),b(this,this._value),this._wire()}_syncFormValue(){b(this,this._value)}_syncTrigger(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!(t instanceof HTMLSpanElement))return;let n=this._parts(this._value);t.textContent=n?this._label(this._value):this._placeholder(),t.classList.toggle(`wui-select-placeholder`,!n),e?.classList.toggle(`has-value`,!!n),e?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`)),h(this,e)}_limits(){if(this._yearOnly()){let e=a(this.getAttribute(`min`)),t=a(this.getAttribute(`max`)),n=e?e.y:-1/0,r=t?t.y:1/0;return{dayDisabled:()=>!0,monthDisabled:()=>!0,yearDisabled:e=>e<n||e>r}}if(this._monthOnly()){let e=t(this._monthKey(this.getAttribute(`min`))),n=t(this._monthKey(this.getAttribute(`max`))),r=e?e.y*12+e.m:-1/0,i=n?n.y*12+n.m:1/0,a=e?e.y:-1/0,o=n?n.y:1/0;return{dayDisabled:()=>!0,monthDisabled:(e,t)=>{let n=e*12+t;return n<r||n>i},yearDisabled:e=>e<a||e>o}}let e=l(this.getAttribute(`min`)),n=l(this.getAttribute(`max`)),r=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=n?new Date(n.y,n.m,n.d).getTime():1/0,s=/* @__PURE__ */ new Set;for(let e of(this.getAttribute(`disabled-weekdays`)||``).split(`,`)){let t=e.trim();/^[0-6]$/.test(t)&&s.add(Number(t))}return{dayDisabled:(e,t,n)=>{let a=new Date(e,t,n),o=a.getTime();return o<r||o>i||s.has(a.getDay())},monthDisabled:(e,t)=>{let n=new Date(e,t,1).getTime();return new Date(e,t,o(e,t)).getTime()<r||n>i},yearDisabled:e=>{let t=new Date(e,0,1).getTime();return new Date(e,11,31).getTime()<r||t>i}}}_dropPanel(){let e=this.querySelector(`.datepicker-pop`);if(e instanceof HTMLDivElement){this._closingQuietly=!0;try{S(e)}finally{this._closingQuietly=!1}}}_renderView(){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(this._mode===`months`?e.replaceChildren(...this._monthsNodes()):this._mode===`years`?e.replaceChildren(...this._yearsNodes()):e.replaceChildren(...this._daysNodes()),this._focusActive())}_daysNodes(){let e=this._firstDay(),t=(new Date(this._viewY,this._viewM,1).getDay()-e+7)%7,n=o(this._viewY,this._viewM),r=l(this._value),i=/* @__PURE__ */ new Date,{dayDisabled:a}=this._limits(),s=this._focus||r||{y:this._viewY,m:this._viewM,d:1},c=(e,t,n,o)=>{let c=d(e,t,n),l=r&&r.y===e&&r.m===t&&r.d===n,u=i.getFullYear()===e&&i.getMonth()===t&&i.getDate()===n,f=s.y===e&&s.m===t&&s.d===n,m=a(e,t,n),h=[`datepicker-day`,o?`is-outside`:``,u?`is-today`:``,l?`is-selected`:``].filter(Boolean).join(` `);return p(`button`,{type:`button`,class:h,"data-iso":c,role:`gridcell`,tabindex:f&&!m?`0`:`-1`,"aria-selected":l?`true`:void 0,disabled:m?!0:void 0,"aria-disabled":m?`true`:void 0},n)},f=[],m=u(this._viewY,this._viewM-1),h=o(m.y,m.m);for(let e=t-1;e>=0;e--)f.push(c(m.y,m.m,h-e,!0));for(let e=1;e<=n;e++)f.push(c(this._viewY,this._viewM,e,!1));let y=u(this._viewY,this._viewM+1),b=(7-(t+n)%7)%7;for(let e=1;e<=b;e++)f.push(c(y.y,y.m,e,!0));let S=a(i.getFullYear(),i.getMonth(),i.getDate()),C=g(this)?null:p(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},k().clearLabel),w=Array.from({length:7},(t,n)=>p(`span`,null,v((n+e)%7,`min`)));return[p(`div`,{class:`datepicker-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`-1`,"aria-label":k().previousMonth},x(`chevron-left`)),p(`button`,{type:`button`,class:`datepicker-month`,"data-view":`months`,"aria-label":k().chooseMonthYearLabel},`${_(this._viewM)} ${this._viewY}`),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`1`,"aria-label":k().nextMonth},x(`chevron-right`))),p(`div`,{class:`datepicker-weekdays`},...w),p(`div`,{class:`datepicker-grid${this._slide?` ${this._slide}`:``}`,role:`grid`},...f),p(`div`,{class:`datepicker-foot`},p(`button`,{type:`button`,class:`datepicker-link`,"data-today":!0,disabled:S?!0:void 0},k().todayLabel),C)]}_clearFoot(e){return!e||g(this)?[]:[p(`div`,{class:`datepicker-foot`},p(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},k().clearLabel))]}_monthsNodes(){let e=this._parts(this._value),t=/* @__PURE__ */ new Date,{monthDisabled:n}=this._limits(),r=[];for(let i=0;i<12;i++){let a=e&&e.y===this._viewY&&e.m===i,o=t.getFullYear()===this._viewY&&t.getMonth()===i,s=n(this._viewY,i),c=[`datepicker-cell`,o?`is-today`:``,a?`is-selected`:``].filter(Boolean).join(` `);r.push(p(`button`,{type:`button`,class:c,"data-month":i,tabindex:this._monthOnly()?this._viewY*12+i===this._gridFocus&&!s?0:-1:void 0,disabled:s?!0:void 0},y(i)))}return[p(`div`,{class:`datepicker-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`-1`,"aria-label":k().previousYearLabel},x(`chevron-left`)),p(`button`,{type:`button`,class:`datepicker-month`,"data-view":`years`,"aria-label":k().chooseYearLabel},this._viewY),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`1`,"aria-label":k().nextYearLabel},x(`chevron-right`))),p(`div`,{class:`datepicker-cells`},...r),...this._clearFoot(this._monthOnly())]}_yearsNodes(){let e=this._parts(this._value),t=(/* @__PURE__ */ new Date()).getFullYear(),{yearDisabled:n}=this._limits(),r=A(this._viewY),i=[];for(let a=0;a<12;a++){let o=r+a,s=e&&e.y===o,c=t===o,l=n(o),u=[`datepicker-cell`,c?`is-today`:``,s?`is-selected`:``].filter(Boolean).join(` `);i.push(p(`button`,{type:`button`,class:u,"data-year":o,tabindex:this._yearOnly()?o===this._gridFocus&&!l?0:-1:void 0,disabled:l?!0:void 0},o))}return[p(`div`,{class:`datepicker-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`-1`,"aria-label":k().previousDecadeLabel},x(`chevron-left`)),p(`span`,{class:`datepicker-month`},`${r+1} to ${r+10}`),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`1`,"aria-label":k().nextDecadeLabel},x(`chevron-right`))),p(`div`,{class:`datepicker-cells`},...i),...this._clearFoot(this._yearOnly())]}_gridKind(){if(this._monthOnly()){let{monthDisabled:e}=this._limits(),t=e=>e-Math.floor(e/12)*12;return{view:`months`,attr:`month`,per:12,page:12,lo:e=>e*12,unit:(e,t)=>e*12+t,cell:t,disabled:n=>e(Math.floor(n/12),t(n)),iso:e=>this._monthStored(n(Math.floor(e/12),t(e)))}}if(this._yearOnly()){let{yearDisabled:e}=this._limits();return{view:`years`,attr:`year`,per:1,page:10,lo:A,unit:e=>e,cell:e=>e,disabled:e,iso:r}}return null}_gridFocusCell(e){let t=e.lo(this._viewY),n=e=>e!==null&&e>=t&&e<t+12,r=this._parts(this._value),i=/* @__PURE__ */ new Date,a=[r?e.unit(r.y,r.m):null,e.unit(i.getFullYear(),i.getMonth())];for(let t of a)if(n(t)&&!e.disabled(t))return t;for(let n=t;n<t+12;n++)if(!e.disabled(n))return n;return null}_syncGridFocus(){let e=this._gridKind();e&&(this._gridFocus=this._gridFocusCell(e))}_focusActive(){let e=this.querySelector(`.datepicker-pop`);if(!(e instanceof HTMLDivElement))return;let t=e.querySelector(`[tabindex="0"]`)||e.querySelector(`.is-selected`)||e.querySelector(`.datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)`);t instanceof HTMLElement&&e.contains(document.activeElement)&&t.focus()}_setFocus(e,t,n,r){let{y:i,m:a}=u(e,t);this._focus={y:i,m:a,d:n};let o=i!==this._viewY||a!==this._viewM;this._viewY=i,this._viewM=a,this._slide=o&&r||``,this._renderView(),this._slide=``;let s=this.querySelector(`.datepicker-day[data-iso="${d(i,a,n)}"]`);s instanceof HTMLButtonElement&&s.focus()}_seek(e,t,n,r){let{dayDisabled:i}=this._limits(),a=new Date(e,t,n);for(let e=0;e<400;e++,a.setDate(a.getDate()+r))if(!i(a.getFullYear(),a.getMonth(),a.getDate()))return new Date(a);return null}_onGridKey(e,t){let n=(e,n)=>{for(let r=0;r<100*t.per;r++,e+=n)if(!t.disabled(e))return e;return null},r=(e,t)=>{let r=n(t>0?e:e+11,t);return r!==null&&r>=e&&r<e+12?r:null},i=e=>{this._viewY=Math.floor(e/t.per),this._gridFocus=e,this._renderView();let n=this.querySelector(`.datepicker-cell[data-${t.attr}="${t.cell(e)}"]`);n instanceof HTMLButtonElement&&n.focus()},a=r=>{e.preventDefault();let a=t.lo(this._viewY),o=n((this._gridFocus??(r<0?a+12:a-1))+r,r<0?-1:1);o!==null&&i(o)};switch(T(e.key,E(this))){case`ArrowLeft`:a(-1);break;case`ArrowRight`:a(1);break;case`ArrowUp`:a(-3);break;case`ArrowDown`:a(3);break;case`Home`:{e.preventDefault();let n=r(t.lo(this._viewY),1);n!==null&&i(n);break}case`End`:{e.preventDefault();let n=r(t.lo(this._viewY),-1);n!==null&&i(n);break}case`PageUp`:case`PageDown`:{e.preventDefault();let n=(this._gridFocus??t.lo(this._viewY))+(e.key===`PageUp`?-1:1)*t.page,a=t.disabled(n)?r(t.lo(Math.floor(n/t.per)),1):n;a!==null&&i(a);break}case`Enter`:case` `:{e.preventDefault();let n=this._gridFocus;n!==null&&!t.disabled(n)&&(this.value=t.iso(n),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());break}}}_onKey(e){let t=this._gridKind();if(t&&this._mode===t.view){this._onGridKey(e,t);return}if(this._mode!==`days`)return;let n=this._focus||l(this._value)||{y:this._viewY,m:this._viewM,d:1},r=(e,t,n,r,i)=>{let a=this._seek(e,t,n,r);a&&this._setFocus(a.getFullYear(),a.getMonth(),a.getDate(),i)},i=(t,i,a=t<0?-1:1)=>{e.preventDefault(),r(n.y,n.m,n.d+t,a,i)};switch(T(e.key,E(this))){case`ArrowLeft`:i(-1,`slide-prev`);break;case`ArrowRight`:i(1,`slide-next`);break;case`ArrowUp`:i(-7,`slide-prev`);break;case`ArrowDown`:i(7,`slide-next`);break;case`Home`:i(-((new Date(n.y,n.m,n.d).getDay()-this._firstDay()+7)%7),`slide-prev`,1);break;case`End`:i(6-(new Date(n.y,n.m,n.d).getDay()-this._firstDay()+7)%7,`slide-next`,-1);break;case`PageUp`:{e.preventDefault();let t=u(n.y,n.m-(e.shiftKey?12:1));r(t.y,t.m,Math.min(n.d,o(t.y,t.m)),-1,`slide-prev`);break}case`PageDown`:{e.preventDefault();let t=u(n.y,n.m+(e.shiftKey?12:1));r(t.y,t.m,Math.min(n.d,o(t.y,t.m)),1,`slide-next`);break}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(n.y,n.m,n.d)||(this.value=d(n.y,n.m,n.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return}}_wire(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`.datepicker-pop`),i=this.querySelector(`.datepicker`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let a=()=>w(t),o=()=>{i?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this._closingQuietly||e.focus()};this._openFn=()=>{if(g(this))return;let n=/* @__PURE__ */ new Date,r=this._parts(this._value),s=this._gridKind();if(s)this._viewY=r?r.y:n.getFullYear(),this._mode=s.view,this._focus=null,this._gridFocus=this._gridFocusCell(s);else{(r||!this._viewNavigated)&&(this._viewY=n.getFullYear(),this._viewM=n.getMonth()),this._mode=`days`;let e=n.getFullYear()===this._viewY&&n.getMonth()===this._viewM,t=r&&r.y===this._viewY&&r.m===this._viewM;if(this._focus=t?r:{y:this._viewY,m:this._viewM,d:e?n.getDate():1},this._limits().dayDisabled(this._focus.y,this._focus.m,this._focus.d)){let e=this._focus,t=[1,-1].map(t=>this._seek(e.y,e.m,e.d,t)).find(t=>t&&t.getMonth()===e.m);t&&(this._focus={y:t.getFullYear(),m:t.getMonth(),d:t.getDate()})}}if(this._renderView(),C(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),!a())return;i?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`);let c=t.querySelector(`[tabindex="0"]`);c instanceof HTMLElement&&c.focus()},this._closeFn=()=>{S(t)},e.addEventListener(`click`,()=>a()?this._close():this._open()),t.addEventListener(`click`,e=>{let t=e.target;if(!(t instanceof Element))throw Error(`click target is not an element`);let i=t.closest(`[data-nav]`);if(i instanceof HTMLElement){this._viewNavigated=!0,this._slide=Number(i.dataset.nav)<0?`slide-prev`:`slide-next`;let e=u(this._viewY,this._viewM+Number(i.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._focus={y:e.y,m:e.m,d:1},this._renderView(),this._slide=``;return}let a=t.closest(`[data-nav-year]`);if(a instanceof HTMLElement){this._viewY+=Number(a.dataset.navYear),this._syncGridFocus(),this._renderView();return}let o=t.closest(`[data-nav-decade]`);if(o instanceof HTMLElement){this._viewY+=Number(o.dataset.navDecade)*10,this._syncGridFocus(),this._renderView();return}let s=t.closest(`[data-view]`);if(s instanceof HTMLElement){this._mode=s.dataset.view,this._renderView();return}let c=t.closest(`[data-month]`);if(c instanceof HTMLButtonElement&&!c.disabled){if(this._monthOnly()){this.value=this._monthStored(n(this._viewY,Number(c.dataset.month))),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewM=Number(c.dataset.month),this._mode=`days`,this._focus={y:this._viewY,m:this._viewM,d:1},this._renderView();return}let l=t.closest(`[data-year]`);if(l instanceof HTMLButtonElement&&!l.disabled){if(this._yearOnly()){this.value=r(Number(l.dataset.year)),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewY=Number(l.dataset.year),this._mode=`months`,this._syncGridFocus(),this._renderView();return}if(t.closest(`[data-today]`)){let e=/* @__PURE__ */ new Date;if(this._limits().dayDisabled(e.getFullYear(),e.getMonth(),e.getDate()))return;this.value=d(e.getFullYear(),e.getMonth(),e.getDate()),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}if(t.closest(`[data-clear]`)){this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}let f=t.closest(`.datepicker-day[data-iso]`);f instanceof HTMLButtonElement&&!f.disabled&&(this.value=f.dataset.iso,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{a()&&this._onKey(e)},t.addEventListener(`keydown`,this._onKeyBound),this._syncFormValue()}};export{j as t};
@@ -0,0 +1 @@
1
+ import{i as e,n as t,r as n,s as r,t as i,u as a}from"./calendarMath-CT99RyhR.js";import{n as o}from"./devWarn-DXdRWZs3.js";import{r as s,t as c}from"./textStore-DBplASiZ.js";import{t as l}from"./dateRangePicker.g-Pnc37vgX.js";import{n as u,r as d,t as f}from"./zone-BR02ZkHF.js";import{r as p}from"./dom-DMQu--xV.js";import{t as m}from"./elementBase-Cxeyx0tU.js";import{r as h,t as g}from"./fieldState-D-zQcXUS.js";import{_,b as v}from"./formatters-DTW53DjY.js";import{t as y}from"./iconGlyphs.g-a9FtjPXh.js";import{a as b,l as x,s as S}from"./nativeOverlay-BHD2QV02.js";var C=4,w=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],T={today:`todayLabel`,yesterday:`yesterdayLabel`,last7Days:`last7DaysLabel`,last30Days:`last30DaysLabel`,thisMonth:`thisMonthLabel`,lastMonth:`lastMonthLabel`,thisFinancialYear:`thisFinancialYearLabel`},E=e=>String(e).padStart(2,`0`),D=e=>`${e.getUTCFullYear()}-${E(e.getUTCMonth()+1)}-${E(e.getUTCDate())}`;function O(e){return w.includes(e)}function k(e,t=/* @__PURE__ */ new Date,{timeZone:n=f,financialYearStart:i=C}={}){if(!O(e))return null;let a=r(d(n,t));if(!a)throw Error(`today missing`);let{y:o,m:c,d:u}=a,p=(e,t,n)=>D(new Date(Date.UTC(e,t,n))),m=s(`dateRangePicker`,l)[T[e]];switch(e){case`today`:return{label:m,start:p(o,c,u),end:p(o,c,u)};case`yesterday`:return{label:m,start:p(o,c,u-1),end:p(o,c,u-1)};case`last7Days`:return{label:m,start:p(o,c,u-6),end:p(o,c,u)};case`last30Days`:return{label:m,start:p(o,c,u-29),end:p(o,c,u)};case`thisMonth`:return{label:m,start:p(o,c,1),end:p(o,c+1,0)};case`lastMonth`:return{label:m,start:p(o,c-1,1),end:p(o,c,0)};case`thisFinancialYear`:{let e=i-1,t=c>=e?o:o-1;return{label:m,start:p(t,e,1),end:p(t+1,e,0)}}default:return null}}function A(e){o(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function j(e){return typeof e==`object`&&!!e}function M(e,t=/* @__PURE__ */ new Date,n={}){let i=String(e??``).trim();if(!i)return[];let a;if(i.startsWith(`[`))try{a=JSON.parse(i)}catch{return A(`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 r=k(e,t,n);r?o.push(r):A(`"${e}" is not one of ${w.join(`, `)}`)}else j(e)&&typeof e.label==`string`&&e.label&&typeof e.start==`string`&&typeof e.end==`string`&&r(e.start)&&r(e.end)?o.push({label:e.label,start:e.start,end:e.end}):A(`an item needs a label and ISO start and end dates, or a preset name`);return o}var N=()=>s(`dateRangePicker`,l);function P(e){if(!(e.target instanceof Element))throw Error(`Expected the event target to be an element.`);return e.target}function F(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 I=class extends m{static formAssociated=!0;_internals;_start;_end;_hover;_viewY;_viewM;get open(){return this.querySelector(`.daterange`)?.classList.contains(`open`)??!1}set open(e){e?!g(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 n(this)}_label(){let t=this.getAttribute(`placeholder`)||N().placeholder;return!this._start&&!this._end?{text:t,empty:!0}:{text:c(N().rangeText,{start:e(this._start)||N().startLabel,end:e(this._end)||N().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=r(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=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`),s=this.getAttribute(`aria-describedby`),c=p(`button`,{type:`button`,class:`input daterange-trigger${n}${a?``:` has-value`}${this.classList.contains(`wui-input-underline`)?` wui-input-underline`:``}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:null,disabled:this.hasAttribute(`disabled`),"aria-label":o||null,"aria-describedby":s||null},p(`span`,{"data-range-label":!0,class:a?`wui-select-placeholder`:``},i),y(`calendar`));this.replaceChildren(p(`div`,{class:`daterange`},c,p(`div`,{class:`daterange-pop`,role:`dialog`,popover:`auto`}))),h(this,this.querySelector(`.daterange-trigger`)),this._rendered=!0,this._syncMirrors(),this._wire()}formResetCallback(){this.value={start:this._defaultStart||``,end:this._defaultEnd||``}}_syncTrigger(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`[data-range-label]`);if(!t)return;let{text:n,empty:r}=this._label();t.textContent=n,t.classList.toggle(`wui-select-placeholder`,r),e?.classList.toggle(`has-value`,!r),e?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`))}_syncMirrors(){let e=this.getAttribute(`start-name`),t=this.getAttribute(`end-name`);this._mirror(`start`,e,this._start),this._mirror(`end`,t,this._end)}_mirror(e,t,n){if(!t)return;let r=this.querySelector(`input[type="hidden"][data-range-mirror="${e}"]`),i;r instanceof HTMLInputElement?i=r:(i=document.createElement(`input`),i.type=`hidden`,i.setAttribute(`data-range-mirror`,e),this.appendChild(i)),i.name=t,i.value=n||``,i.disabled=this.hasAttribute(`disabled`)}_limits(){let e=r(this.getAttribute(`min`)),t=r(this.getAttribute(`max`)),n=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=t?new Date(t.y,t.m,t.d).getTime():1/0;return(e,t,r)=>{let a=new Date(e,t,r).getTime();return a<n||a>i}}_monthHtml(e,n){let r=this._firstDay(),o=(new Date(e,n,1).getDay()-r+7)%7,s=t(e,n),c=this._limits(),l=Array.from({length:7},(e,t)=>p(`span`,null,v((t+r)%7,`min`))),u=(e,t,n,r)=>{let i=a(e,t,n),o=c(e,t,n),s=[`datepicker-day`,r?`is-outside`:``].filter(Boolean).join(` `);return p(`button`,{type:`button`,class:s,"data-iso":i,disabled:o},n)},d=[],f=i(e,n-1),m=t(f.y,f.m);for(let e=o-1;e>=0;e--)d.push(u(f.y,f.m,m-e,!0));for(let t=1;t<=s;t++)d.push(u(e,n,t,!1));let h=i(e,n+1),g=(7-(o+s)%7)%7;for(let e=1;e<=g;e++)d.push(u(h.y,h.m,e,!0));return p(`div`,{class:`daterange-cal`},p(`div`,{class:`datepicker-month-label`},`${_(n)} ${e}`),p(`div`,{class:`datepicker-weekdays`},...l),p(`div`,{class:`datepicker-grid`,role:`grid`},...d))}_presetOptions(){let e=this.getAttribute(`time-zone`),t=f;e!==null&&(u(e)?t=e:o(`[@webority/ui-elements] <wui-date-range> time-zone="${e}" is not a time zone this browser knows; India Standard Time is used.`));let n=this.getAttribute(`financial-year-start`),r=4;if(n!==null){let e=Number(n);Number.isInteger(e)&&e>=1&&e<=12?r=e:o(`[@webority/ui-elements] <wui-date-range> financial-year-start="${n}" must be a month number from 1 to 12; April (4) is used.`)}return{timeZone:t,financialYearStart:r}}_presetsHtml(){if(!this._presetList?.length)return null;let e=this._limits(),t=t=>{let n=r(t);if(!n)throw Error(`Expected a preset date, found "${t}".`);return e(n.y,n.m,n.d)},n=this._presetList.map((e,n)=>p(`button`,{type:`button`,class:`wui-daterange-preset`,"data-preset":n,disabled:t(e.start)||t(e.end)},e.label));return p(`div`,{class:`wui-daterange-presets`,role:`group`,"aria-label":N().quickRangesLabel},...n)}_renderView(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=i(this._viewY,this._viewM+1),n=this._presetsHtml(),r=[p(`div`,{class:`daterange-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":-1,"aria-label":N().previousMonthLabel},y(`chevron-left`)),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":1,"aria-label":N().nextMonthLabel},y(`chevron-right`))),p(`div`,{class:`daterange-cals`},this._monthHtml(this._viewY,this._viewM),this._monthHtml(t.y,t.m)),p(`div`,{class:`datepicker-foot`},p(`span`,{class:`daterange-hint`,"data-range-hint":!0}),p(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},N().clearLabel))];e.classList.toggle(`wui-daterange-pop--presets`,n!==null),e.replaceChildren(...n?[n,p(`div`,{class:`wui-daterange-main`},...r)]:r),this._paint()}_paint(){let t=this.querySelector(`.daterange-pop`);if(!t)return;let n=this._start?new Date(this._start).getTime():null,r=this._end;n&&!this._end&&this._hover&&new Date(this._hover).getTime()>=n&&(r=this._hover);let i=r?new Date(r).getTime():null;for(let e of F(t,`.datepicker-day[data-iso]`)){let t=new Date(e.dataset.iso??``).getTime(),r=n!=null&&t===n,a=i!=null&&t===i,o=n!=null&&i!=null&&t>n&&t<i;e.classList.toggle(`is-range-start`,r),e.classList.toggle(`is-range-end`,a),e.classList.toggle(`in-range`,o)}F(t,`[data-preset]`).forEach(e=>{let t=this._presetList?.[Number(e.dataset.preset)],n=!!t&&t.start===this._start&&t.end===this._end;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-pressed`,String(n))});let a=t.querySelector(`[data-range-hint]`);a&&(a.textContent=this._start?this._end?c(N().rangeText,{start:e(this._start),end:e(this._end)}):N().pickEndDateLabel:N().pickStartDateLabel)}_pick(e){!this._start||this._start&&this._end?(this._start=e,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint()):new Date(e).getTime()<new Date(this._start).getTime()?(this._start=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))):(this._end=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}_applyPreset({start:e,end:t}){this._start=e,this._end=t,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close()}_dropPanel(){let e=this.querySelector(`.daterange-pop`);e instanceof HTMLDivElement&&b(e)}_wire(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`.daterange-pop`),n=this.querySelector(`.daterange`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let a=()=>S(t),o=()=>{this._hover=``,n?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!1}}))};this._open=()=>{let i=r(this._start);if(i)this._viewY=i.y,this._viewM=i.m;else{let e=/* @__PURE__ */ new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._presetList=M(this.getAttribute(`presets`),/* @__PURE__ */ new Date,this._presetOptions()),this._renderView(),x(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),a()&&(n?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!0}})))},this._close=()=>{b(t)},e.addEventListener(`click`,()=>{a()?this._close():g(this)||this._open()}),t.addEventListener(`click`,e=>{let t=P(e),n=t.closest(`[data-nav]`);if(n instanceof HTMLElement){let e=i(this._viewY,this._viewM+Number(n.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._renderView();return}if(t.closest(`[data-clear]`)){this._start=``,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._renderView(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let r=t.closest(`[data-preset]`);if(r instanceof HTMLButtonElement&&!r.disabled){let e=this._presetList?.[Number(r.dataset.preset)];e&&this._applyPreset(e);return}let a=t.closest(`.datepicker-day[data-iso]`);if(a instanceof HTMLButtonElement&&!a.disabled){let e=a.dataset.iso;e!==void 0&&this._pick(e)}}),t.addEventListener(`mouseover`,e=>{let t=P(e).closest(`.datepicker-day[data-iso]`),n=t instanceof HTMLButtonElement?t.dataset.iso:void 0;n!==void 0&&this._start&&!this._end&&(this._hover=n,this._paint())}),this._syncMirrors()}};export{I as t};
@@ -0,0 +1,3 @@
1
+ import{t as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";var n=`tbody > tr.wui-entry-grid-row[data-row-key]`,r=`input, select, textarea, button, [tabindex]:not([tabindex="-1"])`,i=e=>[`dirty`,`saving`,`saved`,`failed`].find(t=>e.classList.contains(`wui-entry-grid-row-${t}`))??`clean`,a=class extends t{_onKeyDown;_onFocusIn;_onClick;_pendingCell=null;_ready=!1;_rowActionsObserver=new MutationObserver(()=>this._syncRowActions());_onMouseDown=t=>{this._owns(e(t.target,`td.wui-entry-grid__row-actions`))&&t.preventDefault()};_onPointerDown=t=>{if(t.button!==0)return;let n=this._ownRow(t.target),r=n?.dataset.rowKey;if(!n||r===void 0||r===this.getAttribute(`active-row`))return;let i=e(t.target,`td`),a=i?Array.from(n.children).indexOf(i):-1;this._pendingCell=a>=0?a:null,this._emit(`active`,{rowKey:r})};_onPaste=t=>{let n=this._ownRow(t.target),r=n?.dataset.rowKey,i=e(t.target,`td[data-column-key]`)?.getAttribute(`data-column-key`);if(!n||r===void 0||!i)return;let a=t.clipboardData?.getData(`text/plain`)??``;if(!/[\t\r\n]/.test(a))return;let o=a.replace(/\r\n/g,`
2
+ `).split(`
3
+ `);o[o.length-1]===``&&o.pop(),o.length<=1&&!(o[0]??``).includes(` `)||(t.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=t=>{this._owns(e(t.target,`.wui-entry-grid-add`))&&this._emit(`add`,{});let n=e(t.target,`.wui-entry-grid-save, .wui-entry-grid-cancel`);n&&this._owns(n)&&this._rowAction(n,t.target);let r=e(t.target,`thead th[data-sortable]`),i=r?.getAttribute(`data-column-key`);this._owns(r)&&i&&this._emit(`sort`,{columnKey:i})}}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.addEventListener(`mousedown`,this._onMouseDown),this.hasAttribute(`data-row-actions`)&&(this._rowActionsObserver.observe(this,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`class`]}),this._syncRowActions()),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),this.removeEventListener(`mousedown`,this._onMouseDown),this._rowActionsObserver.disconnect()}attributeChangedCallback(e,t,n){t!==n&&this._ready&&queueMicrotask(()=>this._focusActiveRow())}_owns(t){return e(t,`wui-entry-grid`)===this}_rows(){return[...this.querySelectorAll(n)].filter(e=>e instanceof HTMLElement&&this._owns(e))}_ownRow(t){let r=e(t,n);return r instanceof HTMLElement&&this._owns(r)?r: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(r)??n.querySelector(r))?.focus()}_rowAction(e,t){let n=this._ownRow(t),r=n?.dataset.rowKey;n&&r!==void 0&&(e instanceof HTMLButtonElement&&e.disabled||(r!==this.getAttribute(`active-row`)&&this._emit(`active`,{rowKey:r}),e.matches(`.wui-entry-grid-save`)?this._emit(`commit`,{rowKey:r,move:`stay`}):this._emit(`discard`,{rowKey:r})))}_syncRowActions(){if(!this.hasAttribute(`data-row-actions`))return;let e=this.querySelector(`template.wui-entry-grid-actions`);if(e)for(let t of this._rows()){let n=t.querySelector(`:scope > td.wui-entry-grid__row-actions`);if(!n)continue;let r=i(t);if(n.getAttribute(`data-row-actions-state`)!==r&&(n.replaceChildren(),n.setAttribute(`data-row-actions-state`,r),(r===`dirty`||r===`failed`||r===`saving`)&&(n.append(e.content.cloneNode(!0)),r===`saving`))){let e=n.querySelector(`.wui-entry-grid-save`);e&&(e.disabled=!0),n.querySelector(`.wui-entry-grid-cancel`)?.remove()}}}_keyDown(t){if(t.defaultPrevented||t.isComposing||t.keyCode===229)return;let n=e(t.target,`thead th[data-sortable]`),r=n?.getAttribute(`data-column-key`);if(this._owns(n)&&r&&(t.key===`Enter`||t.key===` `)){t.preventDefault(),this._emit(`sort`,{columnKey:r});return}let i=this._ownRow(t.target),a=i?.dataset.rowKey;if(!i||a===void 0)return;let o=t.target instanceof Element?t.target:null,s=t.ctrlKey||t.metaKey;if(t.ctrlKey&&t.key===`Delete`||t.metaKey&&t.key===`Backspace`){if(!this.hasAttribute(`removable`))return;t.preventDefault(),this._emit(`remove`,{rowKey:a})}else if(t.key===`Enter`){if(s||t.shiftKey||t.altKey||o?.closest(`textarea, button`)||o?.getAttribute(`aria-expanded`)===`true`)return;t.preventDefault(),this._emit(`commit`,{rowKey:a,move:`next`})}else if(s&&t.key.toLowerCase()===`s`)t.preventDefault(),this._emit(`commit`,{rowKey:a,move:`stay`});else if(t.key===`Escape`){if(o?.getAttribute(`aria-expanded`)===`true`)return;t.preventDefault(),this._emit(`discard`,{rowKey:a})}else if(s&&(t.key===`ArrowUp`||t.key===`ArrowDown`)){t.preventDefault();let n=this._rows(),r=n[n.indexOf(i)+(t.key===`ArrowUp`?-1:1)]?.dataset.rowKey;if(r!==void 0){let n=e(t.target,`td`),a=n?Array.from(i.children).indexOf(n):-1;this._pendingCell=a>=0?a:null,this._emit(`active`,{rowKey:r})}}}_focusIn(t){let n=this._ownRow(t.target),r=n?.dataset.rowKey;n&&r!==void 0&&(t.target instanceof HTMLInputElement&&e(t.target,`td[data-kind="number"]`)&&t.target.select(),r!==this.getAttribute(`active-row`)&&this._emit(`active`,{rowKey:r}))}};export{a as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./buttonClass-C8BRtTk8.js";import{t}from"./devWarn-DXdRWZs3.js";import{i as n,r}from"./dom-DMQu--xV.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{a,c as o,d as s,f as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,s as g,t as _,u as v}from"./initials-DKg3IeUa.js";import{t as y}from"./avatarNode-BaEvz5Xr.js";import{t as b}from"./iconGlyphs.g-a9FtjPXh.js";import{n as x,r as S,t as C}from"./textStore-DBplASiZ.js";import{t as w}from"./hasOwn-CJsplJ62.js";import{a as T,l as E}from"./nativeOverlay-BHD2QV02.js";import{n as D,t as O}from"./rtl-g7G8Bsib.js";import{t as k}from"./gantt.g-CWvMXwBR.js";var A=`data-wui-gantt-pick`,j=e=>`${e}px`,M=(e,t,n)=>{let i=r(`div`,{class:`wui-gantt-table-cell`},n);return i.setAttribute(`role`,t),i.dataset.col=e,i};function N(e){let t=e.text,n=r(`div`,{class:`wui-gantt-table`});n.setAttribute(`role`,`table`),n.setAttribute(`aria-label`,e.title);let i=r(`div`);i.setAttribute(`role`,`rowgroup`);let a=r(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`head`,a.setAttribute(`role`,`row`),a.style.height=j(e.headHeight),a.append(M(`name`,`columnheader`,t.tableName),M(`owner`,`columnheader`,t.detailsOwner),M(`start`,`columnheader`,t.tableStart),M(`end`,`columnheader`,t.tableEnd),M(`done`,`columnheader`,t.detailsDone)),i.append(a);let o=r(`div`);o.setAttribute(`role`,`rowgroup`);for(let n of e.rows){if(n.height===0)continue;let i=n.row;if(n.kind===`group`){let i=n.group;if(!i)continue;let a=r(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`group`,a.dataset.wuiGanttGroup=i.name,a.setAttribute(`role`,`row`),a.style.height=j(n.height);let s=r(`div`,{class:`wui-gantt-table-cell wui-gantt-table-group`});s.setAttribute(`role`,`rowheader`);let c=r(`button`,{class:`wui-gantt-group-toggle`});c.type=`button`,c.setAttribute(`aria-expanded`,String(!i.folded)),c.setAttribute(`aria-label`,C(i.folded?t.unfoldLabel:t.foldLabel,{group:i.name})),c.setAttribute(e.focusAttr,`group:${i.name}`);let l=b(i.folded?`chevron-right`:`chevron-down`,{size:16});c.replaceChildren(...l?[l]:[]),s.append(c,r(`span`,null,i.name),r(`span`,null,x(t,`groupSummary`,i.count,{percent:i.percent}))),a.append(s),o.append(a);continue}let a=r(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=i.end===void 0?`milestone`:`bar`,a.dataset.wuiGanttKey=i.key,a.dataset.wuiGanttPick=i.key,i.key===e.selected&&(a.dataset.selected=`true`),a.setAttribute(`role`,`row`),a.style.height=j(n.height);let s=M(`name`,`rowheader`,i.name);s.title=i.name;let c=M(`owner`,`cell`,``);i.owner&&(c.title=i.owner,c.replaceChildren(...[y({initials:_(i.owner)},`avatar-xs`)].filter(e=>e!==null)),c.append(r(`span`,{class:`visually-hidden`},i.owner)));let l=M(`start`,`cell`,i.start===void 0?``:m(v(i.start))),u=M(`end`,`cell`,i.end===void 0?``:m(v(i.end))),d=M(`done`,`cell`,i.end===void 0?``:`${i.progress??0}%`);a.append(s,c,l,u,d),o.append(a)}let s=e.skeleton;for(let e=0;s&&e<s.rows;e+=1){let e=r(`div`,{class:`wui-gantt-table-row`});e.dataset.kind=`skeleton`,e.setAttribute(`role`,`row`),e.setAttribute(`aria-hidden`,`true`),e.style.height=j(s.rowHeight);let t=r(`span`,{class:`wui-gantt-skeleton`});t.style.height=j(s.barHeight),e.append(t),o.append(e)}return n.append(i,o),n}var P=()=>S(`gantt`,k),F=`wui-gantt:zoom-change`,I=`wui-gantt:from-change`,L=`wui-gantt:fold-change`,R=`wui-gantt:select`,z=`wui-gantt:add-task`,B=`wui-gantt:retry`,V=`data-wui-gantt-focus`,H=`bar:`,U=`http://www.w3.org/2000/svg`,W=[`day`,`week`,`month`],G=3,K=16,q=300,J=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`Escape`,`Enter`,` `],Y=0,X=e=>`${e}px`;function ee(e){return typeof e==`object`&&!!e&&`rows`in e&&Array.isArray(e.rows)&&`title`in e&&typeof e.title==`string`}function Z(e){let t=P();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 Q=e=>e.progress??0,$=e=>e.status??`notStarted`,te=(e,t)=>(e??[]).join(`\0`)===(t??[]).join(`\0`),ne=class extends i{uid;_spec=null;_prev=null;_zoom=`week`;_fromMs=null;_folded=/* @__PURE__ */ new Set;_selected=null;_controlled=!1;_awaitingSpec=!1;_connected=!1;_focusAfter=null;_resolved=null;_specRows=[];_card=null;_onClick;_onKeyDown;_onChange;constructor(){super(),Y+=1,this.uid=`wui-gantt-${Y}`,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(w(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&&=(T(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 t(`[@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?v(e.from):null),n(!te(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(F,{zoom:e}),this._controlled?this._syncRadios():(this._zoom=e,this._fromMs=this._fromMs===null?null:c(e,this._fromMs),this._draw())}_setFrom(e){this._emit(I,{from:o(e)}),this._controlled||(this._fromMs=e,this._draw())}_setFolded(e){let t=new Set(this._folded);t.delete(e)||t.add(e),this._emit(L,{folded:[...t]}),this._controlled||(this._folded=t,this._draw())}_setSelected(e){this._emit(R,{key:e}),this._focusAfter=`${H}${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=W.find(e=>e===t.value);n&&this._setZoom(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[${V}]`);if(n instanceof HTMLElement&&this.contains(n)){this._activate(n.getAttribute(V)??``,n);return}let r=t.closest(`[${A}]`);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(H)){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(z):e===`retry`?this._emit(B):n&&e===`nav:earlier`?this._setFrom(s(n.zoom,n.fromMs,-1,n.weeks)):n&&e===`nav:later`?this._setFrom(s(n.zoom,n.fromMs,1,n.weeks)):n&&e===`nav:today`?this._setFrom(n.weeks===void 0?l(n.zoom,n.todayMs):c(n.zoom,n.todayMs)):e.startsWith(`zoom:`)&&t.click()}_bars(){return[...this.querySelectorAll(`.wui-gantt-lane [${V}^="${H}"]`)].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||!J.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(V)?.startsWith(H))return;let n=this._bars(),r=n.indexOf(t),i=t.dataset.wuiGanttKey,a=this._specRows.find(e=>e.key===i);switch(e.preventDefault(),D(e.key,O(this))){case`ArrowDown`:this._focusBar(n[r+1]);break;case`ArrowUp`:this._focusBar(n[r-1]);break;case`Home`:this._focusBar(n[0]);break;case`End`:this._focusBar(n[n.length-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(V)??``,t)}}_focusToken(){let e=document.activeElement;return e instanceof HTMLElement&&this.contains(e)?e.getAttribute(V):null}_draw(){if(this._card&&=(T(this._card),this._card.remove(),null),this._spec==null&&this._awaitingSpec)return;let e=this._focusAfter??this._focusToken();this._focusAfter=null;let r;try{r=this._compose()}catch(e){t(`[@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`),r=[this._stateBlock(`error`,P().errorText)]}if(this.replaceChildren(...r),this._card){let e=n(this._barByKey(this._selected??void 0),`selected gantt bar`);this.append(this._card),E(e,this._card,{mode:`manual`,side:`auto`,align:`start`,flipAlign:!0,gap:4,keepOffscreen:!0})}if(this._placeThumb(),e===null)return;let i=[...this.querySelectorAll(`[${V}]`)].find(t=>t.getAttribute(V)===e);i instanceof HTMLElement&&(e.startsWith(H)?this._focusBar(i):i.focus())}_compose(){let e=this._spec;if(!ee(e))throw TypeError("<wui-gantt> has no spec: set the `spec` property or add a JSON script child.");this._seed(e),f(e);let t=e.layout??`table`,n=u[t],i=P(),o=v(e.today??h()),s=this._zoom,m=s===`week`&&t===`lanes`?e.weeks:void 0,_=g(e.holidays),y=c(s,this._fromMs??(m===void 0?l(s,o):c(s,o))),b={layout:t,zoom:s,fromMs:y,todayMs:o,weeks:m,holidays:_};this._resolved=b,this._specRows=e.rows;let x=e.rows.some(e=>e.start!==void 0||e.bars!==void 0),S=(e.state??`ready`)===`ready`&&!x?`empty`:e.state??`ready`;this.dataset.state=S,this.dataset.zoom=s,this.dataset.layout=t,S===`loading`?this.setAttribute(`aria-busy`,`true`):this.removeAttribute(`aria-busy`);let C=S===`ready`?d({...e,folded:[...this._folded],selected:this._selected},b):null,w=C?.axis??a(t,s,y,{weeks:m,holidays:_}),T=r(`div`,{class:`wui-gantt-lane`});T.style.width=X(w.width),C?this._fillLane(T,e,C):S===`loading`&&(T.style.height=X(G*n.rowH));let E=[];S===`loading`&&E.push(this._fillSkeleton(T,e,n)),S===`empty`&&E.push(this._emptyBlock(e)),S===`error`&&E.push(this._stateBlock(`error`,e.errorText||i.errorText));let D=this._head(w),O=r(`div`,{class:`wui-gantt-plot`});O.append(D,T);let k=r(`div`,{class:`wui-gantt-scroller`});if(t===`table`){let t=N({title:e.title,rows:C?.rows??[],headHeight:2*p.tierH,selected:this._selected,text:i,focusAttr:V,skeleton:S===`loading`?{rows:G,rowHeight:n.rowH,barHeight:n.barH}:void 0});k.append(t,O)}else{let t=C?this._nameColumn(C,e):null;k.append(...t?[t]:[],O)}return[this._toolbar(e,S===`ready`),k,...E,this._legend(t)]}_nameColumn(e,t){let n=e.rows.filter(e=>e.kind===`lane`);if(e.count===null&&n.length===0)return null;let i=r(`div`,{class:`wui-gantt-names`});i.setAttribute(`aria-hidden`,`true`),i.style.paddingTop=X(2*p.tierH);let a=r(`div`,{class:`wui-gantt-names-rows`});a.style.height=X(e.height),e.count&&a.append(this._nameCell(e.count.top,e.count.height,t.countLabel||P().countLabel));for(let e of n)a.append(this._nameCell(e.top,e.height,e.row.name));return i.append(a),i}_nameCell(e,t,n){let i=r(`div`,{class:`wui-gantt-name`},n);return i.style.top=X(e),i.style.height=X(t),i}_countRow(e,t){let n=e.count,i=r(`div`,{class:`wui-gantt-counts`});return i.setAttribute(`role`,`listitem`),i.setAttribute(`aria-label`,t.countLabel||P().countLabel),i.style.top=X(n?.top??0),i.style.height=X(n?.height??0),i.style.width=X(e.axis.width),(n?.counts??[]).forEach((t,n)=>{if(t===0)return;let a=r(`span`,{class:`wui-gantt-count-cell`},String(t));a.style.left=X(e.axis.x(e.axis.startMs)+n*e.axis.ppd),a.style.width=X(e.axis.ppd),i.append(a)}),i}_drawLane(e,t,n){let i=P();e.setAttribute(`aria-label`,t.row.name);for(let a of t.clashes??[]){let o=r(`div`,{class:`wui-gantt-clash`},n.clashLabel||i.clashLabel);o.setAttribute(`aria-hidden`,`true`),o.style.left=X(a.x),o.style.top=X(t.top),o.style.width=X(a.w),o.style.height=X(t.height),e.append(o)}for(let n of t.bars??[]){if(n.hidden)continue;let t=r(`span`,{class:`wui-gantt-lane-bar`},n.label);t.dataset.tone=n.tone,n.half!==void 0&&(t.dataset.half=n.half),t.title=n.label,t.style.left=X(n.x),t.style.top=X(n.top),t.style.width=X(n.w),t.style.height=X(n.height),e.append(t)}}_toolbar(e,t){let n=r(`div`,{class:`wui-gantt-toolbar`});return t&&n.append(r(`p`,{class:`wui-gantt-count`},this._countText(e.rows))),n.append(this._scale(),this._nav()),n}_countText(e){let t=P(),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,v(e.start??``)),a=Math.max(a,v(e.end??e.start??``));return[x(t,`summaryTasks`,n.length-r),x(t,`summaryMilestones`,r),C(t.summaryRange,{from:m(i),to:m(a)})].join(`, `)}_scale(){let e=P(),t=r(`div`,{class:`segmented segmented-sm wui-gantt-scale`});t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,e.scaleLabel),t.append(Object.assign(r(`span`,{class:`segmented-thumb`}),{ariaHidden:`true`}));let n={day:e.dayLabel,week:e.weekLabel,month:e.monthLabel};for(let e of W){let i=r(`label`,{class:`segmented-option`}),a=r(`input`,{class:`segmented-input`});a.type=`radio`,a.name=`${this.uid}-scale`,a.value=e,a.checked=e===this._zoom,a.setAttribute(V,`zoom:${e}`),i.append(a,n[e]),t.append(i)}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=X(n.offsetWidth),t.style.transform=`translateX(${n.offsetLeft}px)`,t.style.opacity=`1`)}_nav(){let t=P(),n=r(`div`,{class:`wui-gantt-nav`}),i=(t,n,i)=>{let a=r(`button`,{class:e(`neutral`,`soft`,`sm`)});a.type=`button`,a.setAttribute(`aria-label`,n),a.setAttribute(V,t);let o=b(i,{size:16});return a.replaceChildren(...o?[o]:[]),a},a=r(`button`,{class:e(`neutral`,`soft`,`sm`)},t.todayLabel);return a.type=`button`,a.setAttribute(V,`nav:today`),n.append(i(`nav:earlier`,t.earlierLabel,`chevron-left`),i(`nav:later`,t.laterLabel,`chevron-right`),a),n}_head(e){let t=r(`div`,{class:`wui-gantt-head`});t.style.width=X(e.width),t.setAttribute(`aria-hidden`,`true`);let n=(e,t)=>{let n=r(`div`,{class:`wui-gantt-tier ${t}`});for(let t of e){let e=r(`div`,{class:t.weekend?`wui-gantt-cell wui-gantt-cell-weekend`:`wui-gantt-cell`});e.style.left=X(t.x),e.style.width=X(t.w),t.sub&&e.append(r(`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=P(),n=r(`div`,{class:`wui-gantt-legend`});n.setAttribute(`role`,`list`),n.setAttribute(`aria-label`,t.legendLabel);let i=(e,t)=>{let i=r(`span`,null);i.setAttribute(`role`,`listitem`),i.append(e,t),n.append(i)};for(let e of[`done`,`inProgress`,`atRisk`,`notStarted`]){let t=r(`span`,{class:`wui-gantt-swatch`});t.dataset.status=e,i(t,Z(e))}let a=r(`span`,{class:`wui-gantt-swatch`});if(a.dataset.kind=`milestone`,i(a,t.milestoneLabel),e===`table`){let e=r(`span`,{class:`wui-gantt-legend-note`},t.legendRemaining);e.setAttribute(`role`,`listitem`),n.append(e)}return n}_stateBlock(t,n){let i=P(),a=r(`div`,{class:`wui-gantt-state`});if(t===`error`){a.setAttribute(`role`,`alert`),a.append(r(`p`,null,n));let t=r(`button`,{class:e(`neutral`,`soft`,`sm`)},i.retryLabel);t.type=`button`,t.setAttribute(V,`retry`),a.append(t)}else a.append(r(`p`,null,n));return a}_emptyBlock(t){let n=P(),i=r(`div`,{class:`wui-gantt-state`});if(i.append(r(`p`,{class:`fw-semibold`},n.emptyTitle),r(`p`,null,t.emptyText||n.emptyText)),t.addTask){let t=r(`button`,{class:e(`primary`,`solid`,`sm`)},n.addTaskLabel);t.type=`button`,t.setAttribute(V,`add`),i.append(t)}return i}_fillSkeleton(e,t,n){let i=r(`div`,{class:`visually-hidden`},t.loadingText||P().loadingText);i.setAttribute(`role`,`status`);for(let t=0;t<G;t+=1){let i=r(`div`,{class:`wui-gantt-skeleton`});i.style.top=X(t*n.rowH+n.barTop),i.style.left=X(40+t*60),i.style.width=X(240),i.style.height=X(n.barH),i.setAttribute(`aria-hidden`,`true`),e.append(i)}return i}_fillLane(e,t,n){let i=P(),{axis:a}=n,o=n.layout===`table`;e.style.height=X(n.height),e.setAttribute(`role`,`list`),e.setAttribute(`aria-label`,t.title);let s=r(`p`,{class:`visually-hidden`},o?i.helpTextTable:i.helpText);s.id=`${this.uid}-help`,e.setAttribute(`aria-describedby`,s.id);let c=(e,t,n,i,a)=>{let o=r(`div`,{class:e});return o.setAttribute(`aria-hidden`,`true`),o.style.left=X(t),o.style.top=X(n),o.style.width=X(i),o.style.height=X(a),o},l=[s];for(let e of n.rows){if(e.height===0)continue;let t=c(`wui-gantt-row`,0,e.top,a.width,e.height);o&&e.kind!==`group`&&e.row.key===this._selected&&(t.dataset.selected=`true`),l.push(t)}for(let e of a.weekendX)l.push(c(`wui-gantt-weekend`,e,0,a.ppd,n.height));for(let e of a.gridX)l.push(c(`wui-gantt-grid`,e,0,1,n.height));if(n.today.inWindow){l.push(c(`wui-gantt-today`,n.today.x-1,0,2,n.height));let e=r(`div`,{class:`wui-gantt-today-flag rounded-pill`},i.todayLabel);e.style.left=X(n.today.x),l.push(e)}n.count&&l.push(this._countRow(n,t));let u=new Map(t.rows.map(e=>[e.key,e]));for(let e of n.rows){if(e.hidden)continue;let i=r(`div`,{class:`wui-gantt-item`});i.setAttribute(`role`,`listitem`),i.style.display=`contents`,e.kind===`group`?this._drawGroup(i,e,n):e.kind===`milestone`?this._drawMilestone(i,e,u,n):e.kind===`lane`?this._drawLane(i,e,t):this._drawBar(i,e,u,n),l.push(i)}l.push(this._deps(n)),this._card=o?null:this._details(n,u),e.append(...l);let d=e.querySelector(`[${V}^="${H}"]`);d instanceof HTMLElement&&(d.tabIndex=0)}_names(e,t){return(e.dependsOn??[]).map(e=>t.get(e)?.name??e).join(`, `)}_barSentence(e,t){let n=P(),r=this._names(e,t);if(e.end===void 0){let t=m(v(e.start??``));return r?C(n.milestoneBarLabel,{name:e.name,date:t,names:r}):`${e.name}, ${t}, ${n.milestoneLabel.toLowerCase()}`}let i=C(n.barLabel,{name:e.name,start:m(v(e.start??``)),end:m(v(e.end)),percent:Q(e),status:Z($(e)).toLowerCase()});return r?C(n.barLabelAfter,{label:i,names:r}):i}_focusable(e,t,n,i){let a=r(`button`,{class:t});a.type=`button`;let o=this._barSentence(e,n);return a.setAttribute(`aria-label`,o),a.title=o,a.tabIndex=-1,a.dataset.status=$(e),a.dataset.wuiGanttKey=e.key,a.setAttribute(V,`${H}${e.key}`),i?a.setAttribute(`aria-pressed`,String(this._selected===e.key)):a.setAttribute(`aria-expanded`,String(this._selected===e.key)),this._selected===e.key&&(a.dataset.selected=`true`),a}_afterLabel(e,t,n,i){let a=r(`span`,{class:`wui-gantt-label wui-gantt-label-surface`},e);return a.style.left=X(t),a.style.top=X(n),a.style.height=X(i),a}_drawBar(e,t,n,i){let{row:a}=t,{geometry:o}=i,s=i.layout===`table`,c=this._focusable(a,`wui-gantt-bar rounded-2`,n,s),l=t.top+o.barTop;c.style.left=X(t.x),c.style.width=X(t.w),c.style.top=X(l),c.style.height=X(o.barH);let u=Q(a),d=r(`span`,{class:`wui-gantt-bar-progress`});if(d.style.width=`${u}%`,c.append(d),e.append(c),s)return;let f=`${a.name} ${u}%`;t.place===`inside`?c.append(r(`span`,{class:`wui-gantt-bar-label`},f)):e.append(this._afterLabel(f,t.x+t.w+K,l,o.barH))}_drawMilestone(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=p.milestone/2,c=t.top+(a.rowH-p.milestone)/2,l=this._focusable(i,`wui-gantt-milestone`,n,o);if(l.style.left=X(t.x-s),l.style.top=X(c),l.style.width=X(p.milestone),l.style.height=X(p.milestone),e.append(l),o)return;let u=this._afterLabel(`${i.name}, ${m(v(i.start??``))}`,t.x+p.milestone,t.top+a.barTop,a.barH);t.flip&&(u.style.left=``,u.style.right=X(r.axis.width-(t.x-p.milestone))),e.append(u)}_drawGroup(e,t,n){let i=P(),a=t.group;if(!a)return;if(n.layout===`lanes`){let n=r(`div`,{class:`wui-gantt-group wui-gantt-label wui-gantt-label-surface`});n.dataset.wuiGanttGroup=a.name,n.style.left=X(8),n.style.top=X(t.top+6);let o=r(`button`,{class:`wui-gantt-group-toggle`});o.type=`button`,o.setAttribute(`aria-expanded`,String(!a.folded)),o.setAttribute(`aria-label`,C(a.folded?i.unfoldLabel:i.foldLabel,{group:a.name})),o.setAttribute(V,`group:${a.name}`);let s=b(a.folded?`chevron-right`:`chevron-down`,{size:16});o.replaceChildren(...s?[s]:[]),n.append(o,r(`span`,null,a.name),r(`span`,null,x(i,`groupSummary`,a.count,{percent:a.percent}))),e.append(n)}let o=r(`div`,{class:`wui-gantt-group-summary`});o.dataset.wuiGanttGroup=a.name,o.style.left=X(t.x),o.style.width=X(t.w),o.style.top=X(t.top+n.geometry.groupBarTop),o.style.height=X(p.groupBarH),e.append(o)}_deps(e){let t=document.createElementNS(U,`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(U,`path`);e.setAttribute(`d`,n.d),e.setAttribute(`fill`,`none`);let r=document.createElementNS(U,`polygon`);r.setAttribute(`points`,n.head),e.dataset.from=n.fromKey,e.dataset.to=n.toKey,t.append(e,r)}return t}_details(t,n){let i=this._selected,a=i===null?void 0:t.rows.find(e=>e.row.key===i&&(e.kind===`bar`||e.kind===`milestone`)&&!e.hidden);if(!a)return null;let o=P(),{row:s}=a,c=r(`div`,{class:`wui-gantt-details`});c.setAttribute(`role`,`group`),c.setAttribute(`aria-label`,s.name),c.style.width=X(q);let l=r(`dl`),u=(e,t)=>{l.append(r(`dt`,null,e),r(`dd`,null,t))},d=m(v(s.start??``));s.owner&&u(o.detailsOwner,s.owner),u(o.detailsDates,s.end===void 0?d:C(o.detailsRange,{start:d,end:m(v(s.end))})),s.end!==void 0&&u(o.detailsDone,`${Q(s)}%, ${Z($(s))}`);let f=this._names(s,n);f&&u(o.detailsStartsAfter,f);let p=r(`button`,{class:e(`neutral`,`ghost`,`sm`)},o.detailsCloseLabel);return p.type=`button`,p.setAttribute(V,`close`),c.append(r(`h3`,{class:`h6`},s.name),l,p),c}};export{ne as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./calendarMath-CT99RyhR.js";import{n as t,r as n,t as r}from"./digitGrouping-CCPI3HK3.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{o as a}from"./formatters-DTW53DjY.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s,t as c}from"./inlineEditText-DRBhMnam.js";import{c as l,i as u}from"./refreshAfter-DhYgWXmQ.js";import{m as d}from"./wuiHttp-8CYWEbRz.js";import{r as f,t as p}from"./textStore-DBplASiZ.js";import{n as m,t as h}from"./inlineEdit.g-DKIhYoPF.js";import{t as g}from"./httpFailure.g-DjZzGxPj.js";var _=()=>f(`inlineEdit`,h),v=()=>f(`asyncBlock`,m),y=e=>typeof e==`object`&&!!e&&`value`in e&&typeof e.value==`string`&&`label`in e&&typeof e.label==`string`;async function b(e){let t=await d(new URL(e,window.location.href).href,{headers:{Accept:`application/json`}});if(!t.ok)throw Error(`Loading options answered ${t.kind}.`);let n=JSON.parse(t.html),r=Array.isArray(n)?n:[];if(!Array.isArray(n)||!r.every(y))throw Error(`Options must be a JSON array of { value, label } strings.`);return r.filter(y)}var x=e=>s.some(t=>t===e),S=`[data-wui-display]`,C=`[data-wui-value]`,w=`[data-wui-editor]`,T=`[data-wui-control]`,E=`[data-wui-error]`,D=`[data-wui-live]`,O=`[aria-expanded="true"]`,k=/* @__PURE__ */ new Set([`select`,`date`]),A=e=>{let t=(typeof e==`object`||typeof e==`function`)&&e!==null&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:_().serverMessage},j=e=>e instanceof HTMLElement&&typeof(`value`in e?e.value:void 0)==`string`,M=(e,t)=>{let n=e?.querySelector(t)??null;return n instanceof HTMLElement?n:null},N=class extends i{_wired;_editing;_busy;_draft;_pressed;_popupOpen;_savedTimer;_optionsLoaded;_optionsLoading;static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._optionsLoaded=!1,this._optionsLoading=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this._grouping(),this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=M(this,S),t=M(this,w),n=this._control();e&&t&&n&&(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._needsLoad()&&this._loadOptions(),this._focusControl(n),e.hidden=!0)}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_needsLoad(){return this._type()===`select`&&this.hasAttribute(`load-url`)&&!this._optionsLoaded}_loadOptions(){let e=this.getAttribute(`load-url`),t=this._control();e&&t&&this._optionsLoading===null&&(this._setError(null),t.setAttribute(`disabled`,``),this.setAttribute(`aria-busy`,`true`),Object.assign(t,{options:[{value:``,label:v().loadingLabel}]}),this._optionsLoading=b(e).then(e=>{this._optionsLoading=null,this._optionsLoaded=!0,this._showRows(t,e)},()=>{this._optionsLoading=null,this._showLoadError()}))}_showRows(e,t){this.removeAttribute(`aria-busy`),e.removeAttribute(`disabled`),Object.assign(e,{options:t}),e.value=this._draft??this._value(),this._editing&&this._focusControl(e)}_showLoadError(){this.removeAttribute(`aria-busy`);let e=M(this,E);if(!e)return;let t=v(),n=document.createElement(`button`);n.type=`button`,n.setAttribute(`data-wui-retry`,``),n.textContent=t.retryLabel,n.addEventListener(`click`,()=>this._loadOptions()),e.replaceChildren(`${t.errorTitle} `,n),e.hidden=!1,this._announce(t.errorTitle)}_onClick(e){e.stopPropagation();let t=e.target instanceof Node?e.target:null;e.type===`click`&&!this._editing&&this.querySelector(S)?.contains(t)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(w)?.querySelector(O))}_onKeyDown(e){if(!this._editing){(o(e)||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||k.has(t)||(t!==`textarea`||e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget instanceof Node?e.relatedTarget:null;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!k.has(this._type()))return;let t=this._control();t&&e.target===t&&queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;if(this._optionsLoading!==null){this.cancel();return}let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let i=r?null:this._readShown();r||this._showValue(e),this._close();let a=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let o=this.getAttribute(`label`)||``;a.ok?(this.setAttribute(`value`,e),!r&&a.text&&this._showText(a.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),c),this._announce(p(_().savedText,{label:o})),this._fire(`wui:inline-edit:saved`,{value:e,previous:t}),a.result&&!u(this)&&await l(a.result,{origin:this})):(i&&this._restoreShown(i),a.kind===`session`||a.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(a.message),this._announce(p(_().notSavedText,{label:o,reason:a.message})),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:a.kind,message:a.message})))}async _persist(e,t){if(t){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:A(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let r=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),i=await d(n,{method:`POST`,body:r});if(i.ok)return{ok:!0,text:i.data===null?i.html.trim():``,result:i};let a={forbidden:_().forbiddenMessage,networkCheck:f(`httpFailure`,g).networkCheckText,client:_().clientMessage,validation:_().validationMessage,server:_().serverMessage,network:_().networkMessage};return{ok:!1,kind:i.kind,message:i.message||a[i.kind]||_().serverMessage}}_close(){let e=M(this,S),t=M(this,w),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),M(t,O)?.click(),n&&e?.focus()}_focusControl(e){if(!k.has(this._type())){e.focus(),e.select?.();return}let t=M(e,`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(t){if(t===``){this._showText(this.getAttribute(`placeholder`)||a(),!0);return}let n=this._type(),i=t;if(n===`date`)i=e(t)||t;else if(n===`select`){let e=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(e=>e.getAttribute(`data-value`)===t);e&&(i=(e.textContent??``).trim())}else n===`number`&&this._grouping()===`indian`&&(i=r(t));this._showText(i,!1)}_readShown(){let e=this.querySelector(C);return e?{nodes:[...e.childNodes].map(e=>e.cloneNode(!0)),empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(C);t&&(t.replaceChildren(...e.nodes),t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(C);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=M(this,E),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(D);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){let e=this.querySelector(T);return j(e)?e:null}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return x(e)?e:`text`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!n(e))throw Error(t(e));return e}};export{N as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t,r as n,t as r}from"./fieldState-D-zQcXUS.js";import{f as i}from"./formatters-DTW53DjY.js";import{t as a}from"./hasOwn-CJsplJ62.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s}from"./listboxKeyNav-CNso9shL.js";import{i as c,n as l,r as u,t as d}from"./mentionText-BJsw_opZ.js";import{a as f,l as p,s as m}from"./nativeOverlay-BHD2QV02.js";import{t as h}from"./serverHtml-BC6tAyAl.js";import{m as g}from"./wuiHttp-8CYWEbRz.js";import{n as _,r as v,t as y}from"./textStore-DBplASiZ.js";import{t as b}from"./mentionInput.g-DJo6d2Gm.js";var x=8,S=40,C=()=>v(`mentionInput`,b),w=`[data-wui-control]`,T=`[data-wui-field]`,E=`[data-wui-menu]`,D=`[data-wui-live]`,O=0,k=e=>!!(e&&d.test(String(e.value??``))&&l(e.label)!==``);function A(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`wui-input-sm`,n===`sm`),t.classList.toggle(`wui-input-lg`,n===`lg`),t.classList.toggle(`wui-input-xl`,n===`xl`)}function j(e,t){t.classList.toggle(`wui-input-underline`,e.classList.contains(`wui-input-underline`))}function M(e,n){n.readOnly=t(e)||e.hasAttribute(`loading`)}function N(e){let t=e.ownerDocument;e.id||=`wui-mention-${++O}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),M(e,n),A(e,n),j(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??C().listNameLabel),o.setAttribute(`data-wui-menu`,``),o.setAttribute(`popover`,`manual`),e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var P=class extends e{_wired;_pendingValue;_text;_mentions;_peopleProp;_declared;_loading;_searchFailed;_query;_results;_active;_timer;_searchSeq;_lastSearch;_abort;_onMenuDown;static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`class`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._searchFailed=!1,this._query=null,this._results=[],this._active=-1,this._timer=void 0,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this)}connectedCallback(){for(let e of[`people`,`loading`,`searchFailed`,`value`])if(a(this,e)){let t=Reflect.get(this,e);Reflect.deleteProperty(this,e),Reflect.set(this,e,t)}if(this._wired)return;this._wired=!0,this.querySelector(w)||N(this);let e=this._requireControl();j(this,e);let t=this.querySelector(T)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._requireMenu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(M(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(M(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?A(this,r):e===`class`?j(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return c(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=/* @__PURE__ */ new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(k):[],this._searchFailed=!1,(this._isOpen()||this._query!==null)&&this._refresh()}get searchFailed(){return this._searchFailed}set searchFailed(e){this._searchFailed=!!e,this._query!==null&&this._renderMenu()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(w)}_menu(){return this.querySelector(E)}_requireControl(){let e=this._control();if(!e)throw Error(`<wui-mention-input> has no text box.`);return e}_requireMenu(){let e=this._menu();if(!e)throw Error(`<wui-mention-input> has no people list.`);return e}_load(e){let{text:t,mentions:n}=u(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(T);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._requireControl(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e instanceof KeyboardEvent&&e.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||r(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,i=n.lastIndexOf(`@`,t-1);if(i<0||i>0&&!/[\s([{"'“‘]/.test(n.charAt(i-1)))return null;let a=n.slice(i+1,t);return a.length>40||/[\n@]/.test(a)||/^\s/.test(a)||/\s{2}/.test(a)||this._mentions.some(e=>i>=e.start&&i<e.end)?null:{start:i,end:t,text:a}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>l(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,a=await g(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this._searchFailed=!0,this.loading=!1,this._refresh();return}this._searchFailed=!1;let o=h(a.html);this._peopleProp=[...o.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(k),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return e!==null&&m(e)}_renderMenu(){let e=this._menu(),t=this._control();if(!e||!t||!this._query)return;this._syncState();let n=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,r)=>{let i=n.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${r}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(r),t.src){let e=n.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=n.createElement(`span`);a.className=`wui-mention-option-text`;let o=n.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=l(t.label),a.appendChild(o),t.description){let e=n.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=n.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this.loading?C().searchingLabel:this._searchFailed?C().searchFailedMessage:`${C().noMatchLabel} “${this._query.text}”`,e.appendChild(t)}p(t,e,{mode:`manual`}),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?_(C(),`foundText`,this._results.length,{count:i(this._results.length,{decimals:0})}):this._searchFailed?C().searchFailedMessage:`${C().noMatchLabel}.`)}_syncState(){let e=this._control();e&&n(this,e)}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();if(e){let t=m(e);f(e),t&&e.replaceChildren()}this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`)}_setActive(e,{reveal:t=!0}={}){let n=this._requireMenu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]??null:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);s(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._requireControl().setAttribute(`aria-activedescendant`,i.id)):this._requireControl().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((o(e)||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}o(e)&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._requireControl();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=l(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(y(C().mentioned,{label:t}))}_replace(e,t,n,r){let i=this._requireControl(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(D);t&&(t.textContent=``,t.textContent=e)}};export{x as n,P as r,S as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";var n=`.wui-mini-calendar-day`,r=`.wui-mini-calendar-nav`,i=864e5,a=/^\d{4}-\d{2}$/,o=/* @__PURE__ */ new Map([[`ArrowLeft`,-1],[`ArrowRight`,1],[`ArrowUp`,-7],[`ArrowDown`,7]]),s=e=>Date.UTC(Number(e.slice(0,4)),Number(e.slice(5,7))-1,Number(e.slice(8,10)))/i,c=e=>(/* @__PURE__ */ new Date(e*i)).toISOString().slice(0,10),l=(e,t)=>{let n=new Date(Date.UTC(Number(e.slice(0,4)),Number(e.slice(5,7))-1+t,1));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,`0`)}`},u=(e,t)=>{let n=new Date(Date.UTC(Number(t.slice(0,4)),Number(t.slice(5,7)),0)).getUTCDate();return`${t}-${String(Math.min(Number(e.slice(8,10)),n)).padStart(2,`0`)}`},d=class extends t{_pending=null;_onClick;_onKeyDown;_onFocusIn=()=>this._sync();_observer;constructor(){super(),this._onClick=t=>{let i=e(t.target,n);if(i instanceof HTMLButtonElement){this._pick(i.dataset.date??``);return}let a=e(t.target,r);if(!(a instanceof HTMLButtonElement))return;let o=Number(a.dataset.nav);if(o!==-1&&o!==1)throw Error(`wui-mini-calendar: data-nav must be -1 or 1.`);this._pending=null,this._changeMonth(l(this._month(),o))},this._onKeyDown=e=>this._key(e),this._observer=new MutationObserver(()=>this._sync())}connectedCallback(){this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusin`,this._onFocusIn),this._observer.observe(this,{childList:!0,subtree:!0}),this._sync()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusin`,this._onFocusIn),this._observer.disconnect()}_key(t){let r=e(t.target,n);if(!(r instanceof HTMLButtonElement))return;let i=r.dataset.date??``,a=this._days(),l=Math.floor(a.indexOf(r)/7)*7,u=t.key;if(u===`PageUp`||u===`PageDown`){t.preventDefault(),this._page(i,u===`PageUp`?-1:1);return}if(u===`Home`||u===`End`){t.preventDefault(),(u===`Home`?a[l]:a[Math.min(l+6,a.length-1)])?.focus();return}let d=o.get(u);d!==void 0&&(t.preventDefault(),this._goTo(c(s(i)+d)))}_pick(e){if(!e)throw Error(`wui-mini-calendar: a day button has no data-date.`);this._pending=null;for(let t of this._days()){let n=t.dataset.date===e;t.classList.toggle(`is-selected`,n),n?t.setAttribute(`aria-pressed`,`true`):t.removeAttribute(`aria-pressed`)}this._sync(),this.dispatchEvent(new CustomEvent(`wui-mini-calendar:select`,{bubbles:!0,detail:{value:e}}))}_goTo(e){let t=this._dayAt(e);t?t.focus():(this._pending=e,this._changeMonth(e.slice(0,7)))}_page(e,t){let n=l(e.slice(0,7),t);this._pending=u(e,n),this._changeMonth(n)}_changeMonth(e){this.dispatchEvent(new CustomEvent(`wui-mini-calendar:navigate`,{bubbles:!0,detail:{month:e}}))}_month(){let e=this.dataset.month??``;if(!a.test(e))throw Error(`wui-mini-calendar: data-month must be YYYY-MM.`);return e}_dayAt(e){return this.querySelector(`${n}[data-date="${e}"]`)}_days(){return[...this.querySelectorAll(n)]}_sync(){let e=this._days();if(this._pending!==null){let e=this._dayAt(this._pending);e&&(this._pending=null,e.focus())}let t=e.find(e=>e===document.activeElement)??e.find(e=>e.getAttribute(`aria-pressed`)===`true`)??e.find(e=>e.getAttribute(`aria-current`)===`date`)??e.find(e=>!e.classList.contains(`is-outside`))??e[0];for(let n of e)n.tabIndex=n===t?0:-1}};export{d as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{t as n}from"./isDrawn-BbF4phmB.js";import{a as r,l as i,m as a,s as o}from"./nativeOverlay-BHD2QV02.js";import{o as s,r as c,s as l}from"./notificationDays-B1R0RFAY.js";import{m as u}from"./wuiHttp-8CYWEbRz.js";import{r as d}from"./textStore-DBplASiZ.js";import{t as f}from"./httpFailure.g-DjZzGxPj.js";import{t as p}from"./notificationCentre.g-Cees-vKg.js";var m=()=>d(`notificationCentre`,p),h=`.wui-notification-center-trigger`,g=`.wui-notification-center-panel`,_=`.wui-notification-center-count`,v=`.wui-notification-center-live`,y=`.wui-notification-center-markall`,b=`.wui-notification-center-item`,x=`wui-notification-center-item-read`,S=`.wui-notification-center-unread-label`,C=`.app-tabs`,w=`.wui-notification-center-tabs [role='tablist']`,T=`.wui-notification-center-tabs [role='tab']`,E=`.wui-notification-center-empty`,D=`.wui-notification-center-retry`,O=`.wui-notification-center-earlier`,k=`(max-width: 767.98px)`,A={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`},j=e=>!!e,M=()=>({forbidden:m().forbiddenMessage,networkCheck:d(`httpFailure`,f).networkCheckText,client:m().clientMessage,validation:m().clientMessage,server:m().serverMessage,network:m().networkMessage}),N=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},P=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),F=class extends t{constructor(){super(),this._unread=0,this._busy=!1,this._sheet=!1,this._awaitChildren=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onToggle=e=>{e.type===`toggle`&&`newState`in e&&e.newState===`closed`&&this._closedByBrowser()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}static get observedAttributes(){return[`open`]}connectedCallback(){this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`toggle`,this._onToggle,!0),this.isOpen&&(N(this,g)===null||N(this,h)===null)?(this._awaitChildren=new MutationObserver(()=>this._finishAwaitedOpen()),this._awaitChildren.observe(this,{childList:!0})):(this._syncOpen(),this.isOpen&&this._showPanel())}disconnectedCallback(){this._disarmAwait(),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`toggle`,this._onToggle,!0);let e=N(this,g);e&&r(e)}attributeChangedCallback(e,t,n){e===`open`&&t!==n&&(this._awaitChildren?n===null&&this._disarmAwait():this.isConnected&&(n===null?this._hidePanel():this._showPanel()))}_finishAwaitedOpen(){N(this,g)!==null&&N(this,h)!==null&&(this._disarmAwait(),this._syncOpen(),this._showPanel())}_disarmAwait(){this._awaitChildren?.disconnect(),this._awaitChildren=null}_showPanel(){let t=e(N(this,g),`<wui-notification-center> needs its panel to open.`),n=e(N(this,h),`<wui-notification-center> needs its trigger to open.`);o(t)||(this._sheet=window.matchMedia(k).matches,this._sheet?a(t,!0):i(n,t,{mode:`auto`,onClosed:()=>this._closedByBrowser()}),o(t)&&this._layoutTabs())}_hidePanel(){let e=N(this,g);e&&o(e)&&(this._sheet?a(e,!1):r(e))}_closedByBrowser(){if(!this.isConnected||!this.hasAttribute(`open`))return;let e=N(this,g);this.close({restoreFocus:e?.contains(this.ownerDocument.activeElement)??!1})}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(e(N(this,g),`<wui-notification-center> needs its panel to open.`),e(N(this,h),`<wui-notification-center> needs its trigger to open.`),this.setAttribute(`open`,``),this._syncOpen(),N(this,g)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&N(this,h)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(h)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${b}:not(.${x}):not([data-archived="true"])`).length}_click(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(T);if(n instanceof HTMLElement&&this.contains(n)){if(this.hasAttribute(`controlled`))return;this._pickTab(n);return}let r=t.closest(D);if(r instanceof HTMLElement&&this.contains(r)){if(this.hasAttribute(`controlled`))return;this._emitRetry();return}let i=t.closest(`${h}, ${y}, ${b}`);i instanceof HTMLElement&&this.contains(i)&&(i.matches(h)?this.toggle():this.hasAttribute(`controlled`)||(i.matches(y)?this._markAll():this._markItem(i)))}_key(e){if(!this.isOpen)return;let t=e.target;if(!(t instanceof Element))throw Error(`Keyboard event target is not an element.`);if(!this.querySelector(g)?.contains(t)||t.closest(C))return;let r=A[e.key];if(r===void 0)return;let i=P(this,b).filter(n);if(i.length===0)return;let a=t.closest(b),o=a instanceof HTMLElement?i.indexOf(a):-1,s;s=r===`first`?0:r===`last`?i.length-1:o===-1?r===1?0:i.length-1:Math.min(i.length-1,Math.max(0,o+r)),e.preventDefault(),i[s]?.focus()}_markItem(e){e.classList.contains(x)||(this._applyRead(e),e.dataset.archived!==`true`&&(this._unread=Math.max(0,this._unread-1)),this._render(),this._say(l(this._unread)),this._emitRead([e.dataset.id].filter(j),!1))}async _markAll(){if(this._busy)return;let e=P(this,`${b}:not(.${x})`);if(e.length===0&&this._unread===0)return;let t=e.map(e=>e.dataset.id).filter(j),n=this.getAttribute(`read-action`);if(n){this._setBusy(!0);let e=new URLSearchParams;for(let n of t)e.append(`ids`,n);let r=await u(n,{method:`POST`,body:e});if(this._setBusy(!1),!r.ok){if(r.kind===`session`||r.kind===`aborted`)return;let e=r.kind,t=r.message||M()[e]||m().serverMessage;this._say(t),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:e,message:t}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(m().allReadText),this._emitRead(t,!0)}_pickTab(e){let t=e.closest(w);if(t instanceof HTMLElement){for(let n of P(t,T)){let t=n===e;n.classList.toggle(`active`,t),n.setAttribute(`aria-selected`,t?`true`:`false`),n.setAttribute(`tabindex`,t?`0`:`-1`)}this._layoutTabs(),this._filterItems(e.dataset.key)}}_layoutTabs(){for(let e of P(this,w)){let t=N(e,`.app-tab.active`);t&&(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.setAttribute(`data-wui-tabs`,``)}}_filterItems(e){let t=!1;for(let n of P(this,b)){let r=n.dataset.archived===`true`,i=n.classList.contains(x),a=e===`archived`?r:!r&&(e!==`unread`||!i);a&&(t=!0);let o=n.closest(`li`);o&&(o.hidden=!a)}for(let e of P(this,`.wui-notification-center-list section`))e.hidden=[...e.querySelectorAll(`li`)].every(e=>e.hidden);let n=N(this,E);n&&(n.hidden=t);for(let t of P(this,O))t.hidden=e!==`unread`}_applyRead(e){e.classList.add(x),e.querySelector(S)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(y);t instanceof HTMLButtonElement&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=N(this,_);e&&(e.textContent=c(this._unread),e.hidden=this._unread===0),this.querySelector(h)?.setAttribute(`aria-label`,s(this.getAttribute(`label`)||m().label,this._unread));let t=this.querySelector(y);t instanceof HTMLButtonElement&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(v);t&&(t.textContent=e)}_emitRetry(){this.dispatchEvent(new CustomEvent(`wui:notification-center:retry`,{bubbles:!0}))}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{F as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./elementBase-Cxeyx0tU.js";var t=4e3,n=`wui:offline-banner:check-again`,r=class extends e{_offline;_timer;_onBrowser;_onClick;static get observedAttributes(){return[`offline`]}constructor(){super(),this._offline=!1,this._timer=null,this._onBrowser=()=>this._sync(),this._onClick=e=>{e.target instanceof Element&&e.target.closest(`.wui-offline-banner-check`)&&this.dispatchEvent(new CustomEvent(n,{bubbles:!0}))}}connectedCallback(){window.addEventListener(`online`,this._onBrowser),window.addEventListener(`offline`,this._onBrowser),this.addEventListener(`click`,this._onClick),this._sync()}disconnectedCallback(){window.removeEventListener(`online`,this._onBrowser),window.removeEventListener(`offline`,this._onBrowser),this.removeEventListener(`click`,this._onClick),this._clearTimer()}attributeChangedCallback(e,t,n){this.isConnected&&this._sync()}_sync(){let e=this.getAttribute(`offline`),n=e===null?!navigator.onLine:e===`true`,r=this._offline;this._offline=n,n?(this._clearTimer(),this._show(`offline`)):r?(this._show(`back`),this._timer=setTimeout(()=>this._hide(),t)):this._timer===null&&this._hide()}_show(e){this.setAttribute(`data-state`,e),this.hidden=!1}_hide(){this.removeAttribute(`data-state`),this.hidden=!0}_clearTimer(){this._timer!==null&&(clearTimeout(this._timer),this._timer=null)}};export{r as t};