@webority/ui-elements 0.198.1 → 0.200.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/{WuiCarousel-UTqrn7Nx.js → WuiCarousel-CHgYsQLy.js} +1 -1
- package/dist/{WuiCodeBlock-BnRpTBm_.js → WuiCodeBlock-DjNv0Jzb.js} +1 -1
- package/dist/{WuiCommandPalette-BSWDxEPw.js → WuiCommandPalette-18xqK2S3.js} +1 -1
- package/dist/{WuiCommentThread-BGoAONw2.js → WuiCommentThread-KZ3bibV8.js} +1 -1
- package/dist/{WuiConsentBanner-B8D2lE8q.js → WuiConsentBanner-DhFgz2Mn.js} +1 -1
- package/dist/{WuiContextMenu-oKlQvt3V.js → WuiContextMenu-CEJS12YY.js} +1 -1
- package/dist/{WuiDashboardGrid-5rXZvTsm.js → WuiDashboardGrid-Cr3qsN_T.js} +1 -1
- package/dist/{WuiDataTable-D_9TWU-r.js → WuiDataTable-08HFWRjn.js} +1 -1
- package/dist/WuiDatePicker-_S1KRPAW.js +1 -0
- package/dist/WuiDateRange-tlkzGlT4.js +1 -0
- package/dist/WuiDateTime-BM_hQc8Y.js +1 -0
- package/dist/{WuiDrawer-Dj7lXuGm.js → WuiDrawer-BSFyJN4i.js} +1 -1
- package/dist/{WuiDropdown-6g074v1T.js → WuiDropdown-BRofo083.js} +1 -1
- package/dist/{WuiGantt-wx8VSXiZ.js → WuiGantt-DThIgEVR.js} +1 -1
- package/dist/{WuiHoverCard-DhJcIIM1.js → WuiHoverCard-B_plKt-t.js} +1 -1
- package/dist/{WuiImageCrop-Cl97BHN4.js → WuiImageCrop-CPBoKzox.js} +1 -1
- package/dist/WuiInlineEdit-8QIAUktT.js +1 -0
- package/dist/{WuiLeadPopup-tkt78XlW.js → WuiLeadPopup-CdGXuUdh.js} +1 -1
- package/dist/WuiLightbox-BbBHUwEH.js +1 -0
- package/dist/WuiMentionInput-CLf66bZv.js +1 -0
- package/dist/WuiModal-LgGTsIpb.js +1 -0
- package/dist/{WuiNavigationMenu-BvYLbEmA.js → WuiNavigationMenu-BebcHPiK.js} +1 -1
- package/dist/{WuiNotificationCenter-DWFg3H-C.js → WuiNotificationCenter-63IkQgw7.js} +1 -1
- package/dist/{WuiOrgTree-Be7gK2ls.js → WuiOrgTree-CTcLLmFi.js} +1 -1
- package/dist/{WuiOverflow-DCNivxjH.js → WuiOverflow-Czk6Er81.js} +1 -1
- package/dist/{WuiPhone-qw_6W3Q2.js → WuiPhone-CdpOXNyu.js} +1 -1
- package/dist/{WuiPopover-BvWKRNQY.js → WuiPopover-y07DZA1J.js} +1 -1
- package/dist/{WuiRecordPager-DLO5IWE9.js → WuiRecordPager-ByLruWFG.js} +1 -1
- package/dist/{WuiRelativeTime-BGeb8bNG.js → WuiRelativeTime-3cYKtfSP.js} +1 -1
- package/dist/{WuiSavedViews-NAZArw5y.js → WuiSavedViews-CQjUtOHV.js} +1 -1
- package/dist/{WuiSelect-DqHu2OW_.js → WuiSelect-Cbr_4yCe.js} +1 -1
- package/dist/{WuiShortcuts-CHOfUeFx.js → WuiShortcuts-BdMGawiV.js} +1 -1
- package/dist/{WuiShowMore-B73_umah.js → WuiShowMore-CG1offsP.js} +1 -1
- package/dist/{WuiSlider-BjzqYCFt.js → WuiSlider-DuPqp8Ru.js} +1 -1
- package/dist/{WuiSortable-DjhJiH0o.js → WuiSortable-6HHTncRn.js} +1 -1
- package/dist/{WuiTimePicker-Bl3GcIS_.js → WuiTimePicker-C6KHFFOx.js} +1 -1
- package/dist/WuiTour-CWy-OMxR.js +1 -0
- package/dist/{WuiTree-Qno7SM6z.js → WuiTree-BsT2thnb.js} +1 -1
- package/dist/{WuiTreePicker-DWCLntLz.js → WuiTreePicker-D4Ep2n3T.js} +1 -1
- package/dist/{WuiWhatsNew-Dm4Yl68x.js → WuiWhatsNew-naVvdes5.js} +1 -1
- package/dist/WuiWizardStep-CPGBX4U8.js +1 -0
- package/dist/{calendarMath-CeawKuZQ.js → calendarMath-D8B0i3XW.js} +1 -1
- package/dist/{chips-DCkeuEvb.js → chips-BMNFRLY4.js} +1 -1
- package/dist/{country-CX7Ok3Md.js → country-COqU5UPA.js} +1 -1
- package/dist/{customRule-vAOiOqYH.js → customRule-CYqAWNFg.js} +1 -1
- package/dist/{dataTable-D48Rwq1a.js → dataTable-CSP1x4ZA.js} +1 -1
- package/dist/{drawerDiscard-mFYviRfI.js → drawerDiscard-233UVlX5.js} +1 -1
- package/dist/elements/carousel.js +1 -1
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/command-palette.js +1 -1
- package/dist/elements/comment-thread.js +1 -1
- package/dist/elements/consent-banner.js +1 -1
- package/dist/elements/context-menu.js +1 -1
- package/dist/elements/dashboard-grid.js +1 -1
- package/dist/elements/data-table.js +1 -1
- package/dist/elements/date-range.js +1 -1
- package/dist/elements/date-time.js +1 -1
- package/dist/elements/datepicker.js +1 -1
- package/dist/elements/drawer.js +1 -1
- package/dist/elements/dropdown.js +1 -1
- package/dist/elements/filter-popover.js +1 -1
- package/dist/elements/gantt.js +1 -1
- package/dist/elements/hover-card.js +1 -1
- package/dist/elements/image-crop.js +1 -1
- package/dist/elements/inline-edit.js +1 -1
- package/dist/elements/kanban.js +1 -1
- package/dist/elements/lead-popup.js +1 -1
- package/dist/elements/lightbox.js +1 -1
- package/dist/elements/mention-input.js +1 -1
- package/dist/elements/modal.js +1 -1
- package/dist/elements/navigation-menu.js +1 -1
- package/dist/elements/notification-center.js +1 -1
- package/dist/elements/org-tree.js +1 -1
- package/dist/elements/overflow.js +1 -1
- package/dist/elements/phone.js +1 -1
- package/dist/elements/popover.js +1 -1
- package/dist/elements/record-pager.js +1 -1
- package/dist/elements/relative-time.js +1 -1
- package/dist/elements/saved-views.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/shortcuts.js +1 -1
- package/dist/elements/show-more.js +1 -1
- package/dist/elements/slider.js +1 -1
- package/dist/elements/sortable.js +1 -1
- package/dist/elements/timepicker.js +1 -1
- package/dist/elements/tour.js +1 -1
- package/dist/elements/tree-picker.js +1 -1
- package/dist/elements/tree.js +1 -1
- package/dist/elements/whats-new.js +1 -1
- package/dist/elements/wizard.js +1 -1
- package/dist/{filterPopover-DopUJ22D.js → filterPopover-Cv9IsBG3.js} +1 -1
- package/dist/formatters-lNUhNemK.js +1 -0
- package/dist/helpers.js +1 -1
- package/dist/{initials-DKg3IeUa.js → initials-CYUX7uHC.js} +1 -1
- package/dist/inlineEditText-BjHkrr4q.js +1 -0
- package/dist/kanban-C_u1_ctX.js +1 -0
- package/dist/{kanbanModel-BQWAC9vs.js → kanbanModel-zqkEKM2x.js} +1 -1
- package/dist/{loader-sSdQNOg6.js → loader-AIIVAlsd.js} +1 -1
- package/dist/{nativeOverlay-BHD2QV02.js → nativeOverlay-MOABXAAh.js} +1 -1
- package/dist/notificationDays-CO6i0_h3.js +1 -0
- package/dist/{recents-DTddcnaM.js → recents-C_0aUCxK.js} +1 -1
- package/dist/relativeTime-CBiAE0E5.js +1 -0
- package/dist/{search-OPWGeniZ.js → search-DenTt9we.js} +1 -1
- package/dist/server.js +1 -1
- package/dist/{shortcutKeys-CoZBxKsS.js → shortcutKeys-DO6ZWyN6.js} +1 -1
- package/dist/{tableSelect-B2lLTEj1.js → tableSelect-BrQSoqzs.js} +1 -1
- package/dist/text.js +1 -1
- package/dist/textStore-Cs1SGBoI.js +1 -0
- package/dist/{themeTransition-DowOV08f.js → themeTransition-DBd5lF43.js} +1 -1
- package/dist/ui-calendar.global.js +1 -1
- package/dist/ui-calendar.js +1 -1
- package/dist/ui-chart.global.js +15 -15
- package/dist/ui-chart.js +15 -15
- package/dist/ui-elements/calendar-views.global.js +1 -1
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +1 -1
- package/dist/ui-elements/comment-thread.global.js +1 -1
- package/dist/ui-elements/consent-banner.global.js +1 -1
- package/dist/ui-elements/context-menu.global.js +1 -1
- package/dist/ui-elements/dashboard-grid.global.js +1 -1
- package/dist/ui-elements/data-table.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +1 -1
- package/dist/ui-elements/date-time.global.js +1 -1
- package/dist/ui-elements/datepicker.global.js +1 -1
- package/dist/ui-elements/dock.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/dropdown.global.js +1 -1
- package/dist/ui-elements/entry-grid.global.js +1 -1
- package/dist/ui-elements/gantt.global.js +1 -1
- package/dist/ui-elements/glyphs-a.global.js +1 -1
- package/dist/ui-elements/glyphs-b.global.js +1 -1
- package/dist/ui-elements/glyphs-c.global.js +1 -1
- package/dist/ui-elements/glyphs-d.global.js +1 -1
- package/dist/ui-elements/glyphs-e.global.js +1 -1
- package/dist/ui-elements/glyphs-f.global.js +1 -1
- package/dist/ui-elements/glyphs-g.global.js +1 -1
- package/dist/ui-elements/glyphs-h.global.js +1 -1
- package/dist/ui-elements/glyphs-i.global.js +1 -1
- package/dist/ui-elements/glyphs-j.global.js +1 -1
- package/dist/ui-elements/glyphs-k.global.js +1 -1
- package/dist/ui-elements/glyphs-l.global.js +1 -1
- package/dist/ui-elements/glyphs-m.global.js +1 -1
- package/dist/ui-elements/glyphs-n.global.js +1 -1
- package/dist/ui-elements/glyphs-o.global.js +1 -1
- package/dist/ui-elements/glyphs-p.global.js +1 -1
- package/dist/ui-elements/glyphs-q.global.js +1 -1
- package/dist/ui-elements/glyphs-r.global.js +1 -1
- package/dist/ui-elements/glyphs-s.global.js +1 -1
- package/dist/ui-elements/glyphs-t.global.js +1 -1
- package/dist/ui-elements/glyphs-u.global.js +1 -1
- package/dist/ui-elements/glyphs-v.global.js +1 -1
- package/dist/ui-elements/glyphs-w.global.js +1 -1
- package/dist/ui-elements/glyphs-x.global.js +1 -1
- package/dist/ui-elements/glyphs-z.global.js +1 -1
- package/dist/ui-elements/glyphs.global.js +1 -1
- package/dist/ui-elements/hover-card.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -1
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lead-popup.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +1 -1
- package/dist/ui-elements/mini-calendar.global.js +1 -1
- package/dist/ui-elements/navigation-menu.global.js +1 -1
- package/dist/ui-elements/notification-center.global.js +1 -1
- package/dist/ui-elements/offline-banner.global.js +1 -1
- package/dist/ui-elements/onboarding-checklist.global.js +1 -1
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/otp.global.js +1 -1
- package/dist/ui-elements/overflow.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/popover.global.js +1 -1
- package/dist/ui-elements/rating.global.js +1 -1
- package/dist/ui-elements/record-pager.global.js +1 -1
- package/dist/ui-elements/relative-time.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +1 -1
- package/dist/ui-elements/select-recents.global.js +1 -1
- package/dist/ui-elements/select-search.global.js +1 -1
- package/dist/ui-elements/select-window.global.js +1 -1
- package/dist/ui-elements/server.global.js +1 -1
- package/dist/ui-elements/shell.global.js +1 -1
- package/dist/ui-elements/shortcuts.global.js +1 -1
- package/dist/ui-elements/show-more.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/table-export.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree-picker.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/truncate.global.js +1 -1
- package/dist/ui-elements/whats-new.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +1 -1
- package/dist/ui-elements.js +1 -1
- package/dist/ui-tour.global.js +1 -1
- package/dist/{zone-BR02ZkHF.js → zone-CIUYudtC.js} +1 -1
- package/dist/zone-VKarLPzU.js +1 -0
- package/package.json +5 -5
- package/types/WuiChart.d.ts +12 -6
- package/types/WuiModal.d.ts +1 -0
- package/types/chart.d.ts +0 -1
- package/types/chartAdapter.d.ts +12 -3
- package/types/chartSpec.d.ts +8 -3
- package/types/global/core.d.ts +2 -3
- package/types/global/shared.d.ts +1 -1
- package/types/helpers.d.ts +1 -3
- package/types/index.d.ts +0 -1
- package/types/kanbanModel.d.ts +3 -2
- package/types/nativeOverlay.d.ts +2 -2
- package/types/razor-js/modules/generatedScreens.d.ts +1 -0
- package/types/zone.d.ts +0 -18
- package/dist/WuiDatePicker-B77M2_E7.js +0 -1
- package/dist/WuiDateRange-BQ1GH9Mu.js +0 -1
- package/dist/WuiDateTime-NTZCa0dZ.js +0 -1
- package/dist/WuiInlineEdit-D0a_5oAM.js +0 -1
- package/dist/WuiLightbox-DFaHN2Fb.js +0 -1
- package/dist/WuiMentionInput-Dcm3F-e-.js +0 -1
- package/dist/WuiModal-DQbVJGUo.js +0 -1
- package/dist/WuiTour-BS7Jd1Tt.js +0 -1
- package/dist/WuiWizardStep-CSS4B8g4.js +0 -1
- package/dist/formatters-CXMylefd.js +0 -1
- package/dist/formatters.g-BNAu1PMe.js +0 -1
- package/dist/inlineEditText-B35MKEul.js +0 -1
- package/dist/kanban-BkovNHsk.js +0 -1
- package/dist/notificationDays-CZxUShyr.js +0 -1
- package/dist/relativeTime-wpijOw5j.js +0 -1
- package/dist/textStore-Dh5iyZSR.js +0 -1
- package/types/currency.d.ts +0 -6
- package/types/formatters.d.ts +0 -138
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{h as n,o as r,p as i,u as a}from"./nativeOverlay-
|
|
1
|
+
import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{h as n,o as r,p as i,u as a}from"./nativeOverlay-MOABXAAh.js";import{r as o,t as s}from"./textStore-Cs1SGBoI.js";import{t as c}from"./drawer.g-B-zYKBfQ.js";var l=[50,90],u=10,d=100;function f(e,t=l){let n=Array.isArray(e)?e:String(e??``).split(`,`),r=[];for(let e of n){if(typeof e==`string`&&e.trim()===``)return t;let n=Number(e);if(!Number.isFinite(n)||n<u||n>d)return t;r.includes(n)||r.push(n)}return r.length?r.sort((e,t)=>e-t):t}function p(e){let{points:t,index:n,visible:r,velocity:i,canDismiss:a}=e,o=a?-1:0;if(Math.abs(i)>=.5)return i>0?Math.max(n-1,o):Math.min(n+1,t.length-1);let s=t[0];if(a&&s!==void 0&&r<s/2)return-1;let c=0;for(let e=1;e<t.length;e++){let n=t[e],i=t[c];if(n===void 0||i===void 0)throw Error(`snap point missing`);Math.abs(n-r)<Math.abs(i-r)&&(c=e)}return c}var m=()=>o(`drawer`,c),h=`(max-width: 767.98px)`,g=4;function _(e,t){let n=e[t];if(n===void 0)throw RangeError(`no snap point at ${t}`);return n}var v=class extends t{_doc;_media;_shown;_trigger;_returnTo;_release;_snap;_drag;_onMedia;_onPointerDown;_onPointerMove;_onPointerUp;_onKeyDown;_onTransitionEnd;_settled;static get observedAttributes(){return[`open`,`snap-points`,`no-sheet`]}constructor(){super(),this._doc=null,this._media=null,this._shown=!1,this._trigger=null,this._returnTo=null,this._release=null,this._snap=0,this._drag=null,this._onMedia=()=>this._syncMode(),this._onPointerDown=e=>this._pointerDown(e),this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onKeyDown=e=>this._keyDown(e),this._onTransitionEnd=e=>{e.target===this._panel()&&e.propertyName===`transform`&&this.isOpen&&this._announce()},this._settled=!1}connectedCallback(){this._doc=this.ownerDocument,n(this._doc),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`transitionend`,this._onTransitionEnd),this._media=typeof matchMedia==`function`?matchMedia(h):null,this._media?.addEventListener?.(`change`,this._onMedia),this._syncMode(),this._applyPoints(),this.hasAttribute(`open`)&&this._open()}disconnectedCallback(){this._endDrag(),this._teardown(),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`transitionend`,this._onTransitionEnd),this._media?.removeEventListener?.(`change`,this._onMedia),this._media=null,this._doc=null}attributeChangedCallback(e){this._doc&&(e===`open`?this.hasAttribute(`open`)?this._open():this._close():e===`no-sheet`?this._syncMode():(this._snap=Math.min(this._snap,this._points().length-1),this._applyPoints()))}get isOpen(){return this.hasAttribute(`open`)}show(e){this._trigger=e??null,this.setAttribute(`open`,``)}hide(){this.removeAttribute(`open`)}_points(){return f(this.getAttribute(`snap-points`),l)}_sheet(){return!!this._media?.matches&&!this.hasAttribute(`no-sheet`)}_syncMode(){this.setAttribute(`data-mode`,this._sheet()?`sheet`:`side`)}_applyPoints(){let t=this._points();this._snap=Math.min(Math.max(this._snap,0),t.length-1),this.style.setProperty(`--wui-drawer-max`,String(t[t.length-1])),this.style.setProperty(`--wui-drawer-snap`,String(t[this._snap])),this.setAttribute(`data-snap`,String(this._snap));let n=this.querySelector(`.wui-drawer-handle`);if(!(n instanceof Element))return;let r=e(t[this._snap],`The drawer has no snap point to report.`);n.setAttribute(`aria-valuemin`,String(t[0])),n.setAttribute(`aria-valuemax`,String(t[t.length-1])),n.setAttribute(`aria-valuenow`,String(r)),n.setAttribute(`aria-valuetext`,s(m().screenText,{now:r}))}_setSnap(e){let t=this._points(),n=Math.min(Math.max(e,0),t.length-1),r=n!==this._snap;this._snap=n,this._applyPoints(),r&&this.dispatchEvent(new CustomEvent(`wui-drawer-snap`,{bubbles:!0,detail:{index:n,percent:t[n]}}))}_open(){if(this._shown)return;let e=this._dialog();this._shown=!0,this._settled=null;let t=Number.parseInt(this.getAttribute(`default-snap`)??`0`,10);this._snap=Number.isFinite(t)?t:0,this._syncMode(),this._applyPoints(),this.dispatchEvent(new CustomEvent(`wui-drawer-open`,{bubbles:!0,detail:{trigger:this._trigger}})),this._returnTo=this._trigger,this._trigger=null,this._release=a(e,{escape:this._dismissible(),backdrop:this._dismissible()?e:null,focus:this._sheet()?`panel`:`first-control`,onRequestClose:e=>this._requestClose(e)}),this._settle()}_close(){if(!this._shown)return;this._endDrag(),this._shown=!1,this._settled=null;let e=this._release;this._release=null;let t=this._dialog();r(t).then(()=>{e?.(),i(this._returnTo,t),this._returnTo=null,this._announce()})}_teardown(){this._shown=!1;let e=this._release;this._release=null,e&&(e(),this._panel()?.close())}_settle(){(this._panel()?.getAnimations?.()??[]).length||this._announce()}_announce(){let e=this.isOpen;e!==this._settled&&(this._settled=e,this.dispatchEvent(new CustomEvent(e?`wui-drawer-opened`:`wui-drawer-closed`,{bubbles:!0})))}_document(){let e=this._doc;if(!e)throw TypeError(`wui-drawer is not connected`);return e}_panel(){let e=this.querySelector(`.wui-drawer-panel`);return e instanceof HTMLDialogElement?e:null}_dialog(){let e=this._panel();if(!e)throw TypeError(`wui-drawer has no dialog panel`);return e}_dismissible(){return!this.hasAttribute(`static`)&&!this.hasAttribute(`no-dismiss`)}_requestClose(e){let t=this.dispatchEvent(new CustomEvent(`wui-drawer-close`,{bubbles:!0,cancelable:!0,detail:{reason:e}}));return t&&this.hide(),t}_keyDown(e){e.target instanceof Element&&e.target.closest(`.wui-drawer-handle`)&&this._sheet()&&this._handleKey(e)}_handleKey(e){let t=this._points().length-1,n={ArrowUp:this._snap+1,ArrowDown:this._snap-1,Home:0,End:t};if(!(e.key in n))return;let r=n[e.key];r!==void 0&&(e.preventDefault(),this._setSnap(r))}_pointerDown(e){if(!this.isOpen||!this._sheet()||(e.button??0)!==0)return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[data-wui-drawer-grip]`);n instanceof HTMLElement&&!t.closest(`button`)&&(this._drag={grip:n,id:e.pointerId,startY:e.clientY,lastY:e.clientY,lastT:e.timeStamp,velocity:0,moved:!1},n.setPointerCapture?.(e.pointerId),n.addEventListener(`pointermove`,this._onPointerMove),n.addEventListener(`pointerup`,this._onPointerUp),n.addEventListener(`pointercancel`,this._onPointerUp))}_viewport(){let e=this._document().defaultView;if(!e)throw TypeError(`wui-drawer has no window`);return e.innerHeight}_pointerMove(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let n=e.clientY-t.startY;if(!t.moved&&Math.abs(n)<g)return;t.moved=!0,this.classList.add(`is-dragging`);let r=e.timeStamp-t.lastT;r>0&&(t.velocity=(e.clientY-t.lastY)/r),t.lastY=e.clientY,t.lastT=e.timeStamp;let i=this._points(),a=(_(i,i.length-1)-_(i,this._snap))/100*this._viewport();t.offset=Math.max(n,-a),this.style.setProperty(`--wui-drawer-drag`,`${t.offset}px`)}_pointerUp(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let{moved:n,velocity:r,offset:i=0}=t;if(this._endDrag(),!n)return;let a=this._points(),o=this._viewport(),s=(_(a,this._snap)/100*o-i)/(o/100),c=this._dismissible(),l=p({points:a,index:this._snap,visible:s,velocity:r,canDismiss:c});l>=0?this._setSnap(l):this._requestClose(`drag`)}_endDrag(){let e=this._drag;e&&(this._drag=null,e.grip.releasePointerCapture?.(e.id),e.grip.removeEventListener(`pointermove`,this._onPointerMove),e.grip.removeEventListener(`pointerup`,this._onPointerUp),e.grip.removeEventListener(`pointercancel`,this._onPointerUp),this.classList.remove(`is-dragging`),this.style.removeProperty(`--wui-drawer-drag`))}};export{v as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{t}from"./isDrawn-BbF4phmB.js";import{t as n}from"./menuKeyNav-BCHtqitp.js";import{a as r,l as i,s as a}from"./nativeOverlay-
|
|
1
|
+
import{t as e}from"./elementBase-Cxeyx0tU.js";import{t}from"./isDrawn-BbF4phmB.js";import{t as n}from"./menuKeyNav-BCHtqitp.js";import{a as r,l as i,s as a}from"./nativeOverlay-MOABXAAh.js";var o=`[data-wui-dropdown-trigger]`,s=`[data-wui-dropdown-menu]`,c=`.dropdown-item`,l=`[data-wui-keep-open]`,u=2,d=150,f=class extends e{_unbindKeys;_rect;_pendingFocus;_pressOpen;_settling;_settleTimer;_endSettle;_onSettleScroll;_onClick;_onPointerDown;_onKeyDown;_onScroll;_onResize;_onClosed;static get observedAttributes(){return[`open`,`align`]}constructor(){super(),this._unbindKeys=null,this._rect=null,this._pendingFocus=!1,this._pressOpen=null,this._settling=!1,this._settleTimer=null,this._endSettle=()=>this._stopSettling(),this._onSettleScroll=()=>this._armQuiet(),this._onClick=e=>this._click(e),this._onPointerDown=e=>{e.target instanceof Element&&e.target.closest(o)&&(this._pressOpen=this.isOpen)},this._onKeyDown=e=>this._key(e),this._onScroll=()=>this._scrolled(),this._onResize=()=>{this._request(!1,`resize`)},this._onClosed=()=>this._dismissed()}connectedCallback(){this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown,{capture:!0}),this.addEventListener(`keydown`,this._onKeyDown),this._trigger()?.setAttribute(`aria-expanded`,String(this.isOpen)),this.isOpen&&this._sync()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown,{capture:!0}),this.removeEventListener(`keydown`,this._onKeyDown),this._stop();let e=this._menu();e&&r(e)}attributeChangedCallback(e){e===`open`&&this.isConnected&&this._sync()}get isOpen(){return this.hasAttribute(`open`)}show(){this.isOpen||this._request(!0,`trigger`)}hide(){this.isOpen&&this._request(!1,`trigger`)}_request(e,t){let n=this.dispatchEvent(new CustomEvent(`wui-dropdown-toggle`,{bubbles:!0,cancelable:!0,detail:{open:e,source:t}}));return n&&this._apply(e),n}_apply(e){e?this.setAttribute(`open`,``):this.removeAttribute(`open`)}_dismissed(){if(!this.isConnected||!this.isOpen)return;let e=this._menu()?.contains(this.ownerDocument.activeElement)??!1;this.dispatchEvent(new CustomEvent(`wui-dropdown-toggle`,{bubbles:!0,detail:{open:!1,source:`dismiss`}})),this.removeAttribute(`open`),e&&this._trigger()?.focus()}_sync(){let{trigger:e,menu:t}=this._markup();this.isOpen?this._open(e,t):this._close(e,t)}_open(e,t){a(t)||(this._pendingFocus&&this._startSettling(),i(this._anchor(e),t,{mode:`auto`,alignEnd:this.getAttribute(`align`)===`end`,onClosed:this._onClosed,scrollSettling:()=>this._settling}),e.setAttribute(`aria-expanded`,`true`),this._rect=this._anchor(e).getBoundingClientRect(),this._unbindKeys=n(t,{items:()=>this._rows(t)}),window.addEventListener(`scroll`,this._onScroll,{capture:!0,passive:!0}),window.addEventListener(`resize`,this._onResize),this._pendingFocus&&(this._pendingFocus=!1,queueMicrotask(()=>{this.isOpen&&a(t)&&this._rows(t)[0]?.focus()})))}_close(e,t){this._pendingFocus=!1,this._stop(),e.setAttribute(`aria-expanded`,`false`),r(t)}_stop(){this._stopSettling(),this._unbindKeys?.(),this._unbindKeys=null,window.removeEventListener(`scroll`,this._onScroll,{capture:!0}),window.removeEventListener(`resize`,this._onResize)}_startSettling(){this._settling=!0,this.ownerDocument.addEventListener(`scroll`,this._onSettleScroll,{capture:!0,passive:!0}),this.ownerDocument.addEventListener(`scrollend`,this._endSettle,{capture:!0}),this._armQuiet()}_armQuiet(){this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=setTimeout(this._endSettle,d)}_stopSettling(){if(this._settling&&(this._settling=!1,this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=null,this.ownerDocument.removeEventListener(`scroll`,this._onSettleScroll,{capture:!0}),this.ownerDocument.removeEventListener(`scrollend`,this._endSettle,{capture:!0}),this.isConnected)){let{trigger:e}=this._markup();this._rect=this._anchor(e).getBoundingClientRect()}}_scrolled(){if(this._settling)return;let{trigger:e}=this._markup(),t=this._anchor(e).getBoundingClientRect(),n=this._rect;(!n||Math.abs(t.top-n.top)>u||Math.abs(t.left-n.left)>u)&&this._request(!1,`scroll`)}_click(e){let t=e.target;if(!(t instanceof Element))return;let n=this._pressOpen;this._pressOpen=null;let r=t.closest(o);if(r&&this.contains(r)){if((n??this.isOpen)&&!this.isOpen)return;this._request(!this.isOpen,`trigger`);return}let i=this._menu(),a=t.closest(c);if(!i||!a||!i.contains(a)||a.getAttribute(`aria-disabled`)===`true`)return;let s=a.closest(l);s&&i.contains(s)||this.isOpen&&this._request(!1,`select`)}_key(e){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=e.target;if(t instanceof Element&&this._trigger()?.contains(t)){if(this.isOpen){let t=this._menu(),n=t?this._rows(t):[],r=e.key===`ArrowDown`?n[0]:n[n.length-1];if(!r)return;e.preventDefault(),r.focus()}else e.key===`ArrowDown`&&(e.preventDefault(),this._pendingFocus=!0,this._request(!0,`trigger`))}}_trigger(){return this.querySelector(o)}_anchor(e){return(e.closest(`[data-wui-overflow-hidden]`)?.closest(`wui-overflow`))?.querySelector(`:scope > .wui-overflow-more`)??e}_menu(){return this.querySelector(s)}_rows(e){return Array.from(e.querySelectorAll(c)).filter(t)}_markup(){let e=this._trigger(),t=this._menu();if(!e||!t)throw RangeError(`<wui-dropdown> needs a [data-wui-dropdown-trigger] control and a [data-wui-dropdown-menu] panel.`);return{trigger:e,menu:t}}};export{f as t};
|
|
@@ -1 +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-DRNDTVOs.js";import{n as x,r as S,t as C}from"./textStore-Dh5iyZSR.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};
|
|
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-CYUX7uHC.js";import{t as y}from"./avatarNode-BaEvz5Xr.js";import{t as b}from"./iconGlyphs.g-DRNDTVOs.js";import{n as x,r as S,t as C}from"./textStore-Cs1SGBoI.js";import{t as w}from"./hasOwn-CJsplJ62.js";import{a as T,l as E}from"./nativeOverlay-MOABXAAh.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{a as t,l as n,s as r}from"./nativeOverlay-
|
|
1
|
+
import{t as e}from"./elementBase-Cxeyx0tU.js";import{a as t,l as n,s as r}from"./nativeOverlay-MOABXAAh.js";var i=300,a=150,o=`.wui-hover-card-trigger`,s=`.wui-hover-card-panel`,c=`a[href],button,input,select,textarea,[tabindex]`,l=0;function u(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}var d=class extends e{_doc;_timer;_described;_refocusing;_onOver;_onOut;_onFocusIn;_onFocusOut;_onKeyDown;static get observedAttributes(){return[`open`]}constructor(){super(),this._doc=null,this._timer=null,this._described=null,this._refocusing=!1,this._onOver=e=>{if(e.pointerType===`touch`||e.pointerType===`pen`)return;let t=this._zone(e.target);t===`panel`?this._clear():t===`trigger`&&this._schedule(!0)},this._onOut=e=>{e.pointerType!==`touch`&&e.pointerType!==`pen`&&this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onFocusIn=e=>{this._refocusing||(this._zone(e.target)===`trigger`?this._schedule(!0):this._zone(e.target)===`panel`&&this._clear())},this._onFocusOut=e=>{this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onKeyDown=e=>{if(e.key!==`Escape`||!this.isOpen||this.hasAttribute(`open`))return;e.preventDefault();let t=this._zone(this.ownerDocument.activeElement)===`panel`;this._clear(),this._setOpen(!1),t&&(this._refocusing=!0,this._anchor?.focus(),this._refocusing=!1)}}get isOpen(){let e=this._panel;return e!==null&&r(e)}connectedCallback(){this._doc=this.ownerDocument,this.addEventListener(`pointerover`,this._onOver),this.addEventListener(`pointerout`,this._onOut),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen()}attributeChangedCallback(){this.isConnected&&this._syncOpen()}disconnectedCallback(){this._clear();let e=this._panel;e&&t(e),this.removeEventListener(`pointerover`,this._onOver),this.removeEventListener(`pointerout`,this._onOut),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._doc=null}get _trigger(){return u(this,o)}get _panel(){return u(this,s)}get _anchor(){let e=this._trigger;return e?u(e,c)??e:null}_zone(e){if(!(e instanceof Node)||!this.contains(e))return null;let t=e instanceof Element?e:e.parentElement;return this._panel?.contains(t)?`panel`:this._trigger?.contains(t)?`trigger`:null}_delay(e,t){let n=Number(this.getAttribute(e));return this.hasAttribute(e)&&Number.isFinite(n)&&n>=0?n:t}_clear(){this._timer!==null&&clearTimeout(this._timer),this._timer=null}_syncOpen(){this._clear(),this._setOpen(this.hasAttribute(`open`))}_schedule(e){if(!e&&this.hasAttribute(`open`)||(this._clear(),this.isOpen===e))return;let t=e?this._delay(`open-delay`,i):this._delay(`close-delay`,a);this._timer=setTimeout(()=>{this._timer=null,this._setOpen(e)},t)}_setOpen(e){let r=this._panel;if(!r||this.isOpen===e)return;if(!e){t(r);return}let i=this._trigger;if(!i)throw Error(`wui-hover-card: panel without a trigger`);n(i,r,{mode:`manual`,clampHeight:!0,keepOffscreen:this.hasAttribute(`open`),onClosed:()=>this._closed()}),this._doc?.addEventListener(`keydown`,this._onKeyDown,!0),this._describe(r),this.dispatchEvent(new CustomEvent(`wui:hover-card:open`,{bubbles:!0}))}_closed(){this._doc?.removeEventListener(`keydown`,this._onKeyDown,!0),this._described?.removeAttribute(`aria-describedby`),this._described=null,this.dispatchEvent(new CustomEvent(`wui:hover-card:close`,{bubbles:!0}))}_describe(e){let t=this._anchor;t&&(e.id||=`wui-hover-card-${++l}`,t.setAttribute(`aria-describedby`,e.id),this._described=t)}};export{d as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{n}from"./svgNodes-CaPMDvv7.js";import{r,t as i}from"./textStore-Dh5iyZSR.js";import{t as a}from"./imageCrop.g-BnbAeH2Q.js";var o=4096,s=[.92,.8,.65,.5],c=.8,l=8;function u(e){if(e==null||e===``||e===`free`)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)&&t>0?t:null}function d(e,t,n){if(!n)return{x:0,y:0,w:e,h:t};let r=e,i=r/n;return i>t&&(i=t,r=i*n),{x:(e-r)/2,y:(t-i)/2,w:r,h:i}}function f(e,t,n){return{...e,x:Math.min(Math.max(e.x,0),Math.max(t-e.w,0)),y:Math.min(Math.max(e.y,0),Math.max(n-e.h,0))}}function p(e,t,n,r,i){return f({...e,x:e.x+t,y:e.y+n},r,i)}function m(e,t){return Math.min(32,e,t)}function h(e,t){return t.w/e.w}function g(e,t){return Math.max(4,h(e,t))}function _(e,t,n,r,i){let a=Math.min(Math.max(n,1),g(e,t)),o=e.h/e.w,s=Math.min(r,i/o),c=Math.min(Math.max(m(r,i),m(r,i)/o),s),l=Math.min(Math.max(t.w/a,c),s),u=l*o,d=e.x+e.w/2,p=e.y+e.h/2;return f({x:d-l/2,y:p-u/2,w:l,h:u},r,i)}var v=[`nw`,`ne`,`sw`,`se`];function y(e,t,n,r,i,a){let o=m(i,a),s=t.endsWith(`w`),c=t.startsWith(`n`),l=s?e.x+e.w:e.x,u=c?e.y+e.h:e.y,d=Math.min(Math.max(n,0),i),f=Math.min(Math.max(r,0),a);return d=s?Math.min(d,l-o):Math.max(d,l+o),f=c?Math.min(f,u-o):Math.max(f,u+o),{x:Math.min(d,l),y:Math.min(f,u),w:Math.abs(d-l),h:Math.abs(f-u)}}function b(e,t=o){let n=Math.min(1,t/Math.max(e.w,e.h));return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function x(e,t){let n=t/Math.max(e.w,e.h);return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function S(e,t,n){return n%180==0?{w:e,h:t}:{w:t,h:e}}function C(e,t,n){return f({x:n-(e.y+e.h),y:e.x,w:e.h,h:e.w},n,t)}function w(e){return String(e||``).split(/[\s,]+/).map(Number).filter(e=>Number.isInteger(e)&&e>0)}var T=[`image/png`,`image/jpeg`,`image/webp`],E={"image/png":`.png`,"image/jpeg":`.jpg`,"image/webp":`.webp`};function D(e){let t=String(e||``).toLowerCase();return T.includes(t)?t:`image/png`}function O(e,t){let n=String(e||`image`),r=E[t];if(r===void 0)throw Error(`No file extension for ${t}`);return(t===`image/jpeg`?/\.jpe?g$/i.test(n):n.toLowerCase().endsWith(r))?n:`${n.replace(/\.[^./\\]+$/,``)||`image`}${r}`}async function k(e,{width:t,height:n,type:r,maxBytes:i}){let a=r,o=t,u=n,d=null;for(let t=0;t<=l;t++){let n=a===`image/png`?[void 0]:t===0?s:[s[1]];for(let t of n){if(d=await e(o,u,a,t),!d||(d.type&&d.type!==a&&(a=d.type),!(i>0)||d.size<=i))return d;if(a===`image/png`)break}o=Math.max(1,Math.round(o*c)),u=Math.max(1,Math.round(u*c))}return d}var A=.05,j=.2,M={w:320,h:240},N={nw:`topLeftLabel`,ne:`topRightLabel`,sw:`bottomLeftLabel`,se:`bottomRightLabel`},P=()=>r(`imageCrop`,a),F=e=>{let t=N[e];return t?P()[t]:e};function I(e,t=!1){return n({width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,...t?{"stroke-linejoin":`round`}:{},"aria-hidden":`true`},e.map(e=>[`path`,{d:e}]))}var L=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function R(e){let[t,n]=[...e.values()];if(!t||!n)throw Error(`two pointers missing`);return[t,n]}function z(e,t){if(e===null)throw Error(`${t} missing`);return e}function B(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`${t} missing`);return r}function V(e){if(e===null)throw Error(`event target missing`);if(!(e instanceof Element))return null;let t=e.closest(`.wui-crop-handle`);return t instanceof HTMLElement?t:null}var H=class extends t{_rect;_base;_natural;_source;_rotation;_drag;_pointers;_pinch;_previewPending;_resizeObserver;_rendered;_stageEl;_imgEl;_frameEl;_sliderEl;_toolsEl;_previewBoxEl;_liveEl;static get observedAttributes(){return[`src`,`aspect`,`round`,`rotatable`,`previews`]}constructor(){super(),this._rect=null,this._base=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pointers=/* @__PURE__ */ new Map,this._pinch=null,this._previewPending=!1,this._resizeObserver=null,this._stageEl=null,this._imgEl=null,this._frameEl=null,this._sliderEl=null,this._toolsEl=null,this._previewBoxEl=null,this._liveEl=null}get _stage(){return z(this._stageEl,`stage`)}get _img(){return z(this._imgEl,`image`)}get _frame(){return z(this._frameEl,`frame`)}get _slider(){return z(this._sliderEl,`zoom slider`)}get _tools(){return z(this._toolsEl,`tools`)}get _previewBox(){return z(this._previewBoxEl,`previews`)}get _live(){return z(this._liveEl,`live region`)}get src(){return this.getAttribute(`src`)||``}set src(e){e==null||e===``?this.removeAttribute(`src`):this.setAttribute(`src`,String(e))}get aspect(){return u(this.getAttribute(`aspect`))}set aspect(e){e==null||e===``?this.removeAttribute(`aspect`):this.setAttribute(`aspect`,String(e))}get round(){return this.hasAttribute(`round`)}set round(e){this.toggleAttribute(`round`,!!e)}get rotatable(){return this.hasAttribute(`rotatable`)}set rotatable(e){this.toggleAttribute(`rotatable`,!!e)}get previews(){return this.getAttribute(`previews`)||``}set previews(e){e==null||e===``?this.removeAttribute(`previews`):this.setAttribute(`previews`,Array.isArray(e)?e.join(` `):String(e))}get rect(){return this._rect?{...this._rect}:null}get rotation(){return this._rotation}set rotation(e){if(!this._rect)return;let t=(Math.round(Number(e)/90)*90%360+360)%360;if(!Number.isNaN(t))for(;this._rotation!==t;)this.rotate()}get zoom(){return this._rect?h(this._rect,z(this._base,`base frame`)):1}set zoom(e){if(!this._rect)return;let t=z(this._natural,`natural size`);this._rect=_(this._rect,z(this._base,`base frame`),Number(e)||1,t.w,t.h),this._paint(),this._announce()}connectedCallback(){this._rendered?this._observe():this.render()}disconnectedCallback(){this._resizeObserver?.disconnect(),this._resizeObserver=null}attributeChangedCallback(e){this._rendered&&(e===`src`?this._loadImage():e===`aspect`?(this._rebuildHandles(),this._resetRect()):e===`rotatable`?this._tools.hidden=!this.rotatable:e===`previews`?this._renderPreviews():this._applyRound())}render(){this.replaceChildren(e(`div`,null,e(`div`,{class:`wui-crop-stage`,tabindex:`0`,role:`group`,"aria-label":P().cropAreaText},e(`img`,{class:`wui-crop-img`,alt:``,draggable:`false`}),e(`div`,{class:`wui-crop-frame`})),e(`div`,{class:`wui-crop-controls`},e(`button`,{type:`button`,class:`wui-crop-zoombtn`,"data-zoom":`out`,"aria-label":P().zoomOutLabel},I([`M5 12h14`])),e(`input`,{type:`range`,class:`form-range wui-crop-zoom`,min:1,max:4,step:`0.01`,value:1,"aria-label":P().zoomLabel}),e(`button`,{type:`button`,class:`wui-crop-zoombtn`,"data-zoom":`in`,"aria-label":P().zoomInLabel},I([`M5 12h14M12 5v14`]))),e(`div`,{class:`wui-crop-tools`,hidden:!0},e(`button`,{type:`button`,class:`wui-crop-toolbtn`,"data-crop-action":`rotate`,"aria-label":P().rotateClockwiseLabel},I([`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,`M21 3v5h-5`],!0),e(`span`,null,P().rotateLabel)),e(`button`,{type:`button`,class:`wui-crop-toolbtn`,"data-crop-action":`reset`,"aria-label":P().resetCropLabel},I([`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,`M3 3v5h5`],!0),e(`span`,null,P().resetLabel))),e(`div`,{class:`wui-crop-previews`,"aria-hidden":`true`,hidden:!0}),e(`div`,{class:`visually-hidden`,"data-wui-crop-live":!0,"aria-live":`polite`}))),this._stageEl=B(this,`.wui-crop-stage`,HTMLElement),this._imgEl=B(this,`.wui-crop-img`,HTMLImageElement),this._frameEl=B(this,`.wui-crop-frame`,HTMLElement),this._sliderEl=B(this,`.wui-crop-zoom`,HTMLInputElement),this._toolsEl=B(this,`.wui-crop-tools`,HTMLElement),this._previewBoxEl=B(this,`.wui-crop-previews`,HTMLElement),this._liveEl=B(this,`[data-wui-crop-live]`,HTMLElement),this._rendered=!0,this._tools.hidden=!this.rotatable,this._applyRound(),this._rebuildHandles(),this._renderPreviews(),this._wire(),this._observe(),this._loadImage()}_applyRound(){this._frame.classList.toggle(`wui-crop-frame--round`,this.round),this._previewBox.classList.toggle(`wui-crop-previews--round`,this.round)}_rebuildHandles(){for(let e of this._frame.querySelectorAll(`.wui-crop-handle`))e.remove();if(!this.aspect)for(let e of v){let t=document.createElement(`button`);t.type=`button`,t.className=`wui-crop-handle wui-crop-handle--${e}`,t.dataset.handle=e,t.setAttribute(`aria-label`,i(P().resizeCornerText,{corner:F(e)})),this._frame.appendChild(t)}}_renderPreviews(){let e=w(this.previews);this._previewBox.replaceChildren(),this._previewBox.hidden=e.length===0;for(let t of e){let e=document.createElement(`canvas`);e.className=`wui-crop-preview`,e.dataset.size=String(t),e.style.width=`${t}px`,e.style.height=`${t}px`,this._previewBox.appendChild(e)}this._schedulePreviews()}_loadImage(){this._rect=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pinch=null,this._pointers.clear();let e=this.src;this._img.hidden=!e,this._frame.hidden=!0,e&&(this._img.onload=()=>{this._source={w:this._img.naturalWidth,h:this._img.naturalHeight},this._natural={...this._source},this._resetRect(),this.dispatchEvent(new Event(`load`))},this._img.onerror=()=>{this._frame.hidden=!0,this.dispatchEvent(new Event(`error`))},this._img.src=e)}_resetRect(){this._natural&&(this._base=d(this._natural.w,this._natural.h,this.aspect),this._rect={...this._base},this._frame.hidden=!1,this._paint())}_observe(){typeof ResizeObserver>`u`||this._resizeObserver||(this._resizeObserver=new ResizeObserver(()=>this._paint()),this._resizeObserver.observe(this._stage))}_view(){let e=z(this._natural,`natural size`),t=this._stage.clientWidth||M.w,n=this._stage.clientHeight||M.h,r=Math.min(t/e.w,n/e.h),i=e.w*r,a=e.h*r;return{scale:r,left:(t-i)/2,top:(n-a)/2,iw:i,ih:a}}_paint(){if(!this._rect)return;let e=this._view(),t=this._rotation%180!=0,n=t?e.ih:e.iw,r=t?e.iw:e.ih;Object.assign(this._img.style,{left:`${e.left+(e.iw-n)/2}px`,top:`${e.top+(e.ih-r)/2}px`,width:`${n}px`,height:`${r}px`,transform:this._rotation?`rotate(${this._rotation}deg)`:``});let i=this._rect;Object.assign(this._frame.style,{left:`${e.left+i.x*e.scale}px`,top:`${e.top+i.y*e.scale}px`,width:`${i.w*e.scale}px`,height:`${i.h*e.scale}px`});let a=z(this._base,`base frame`),o=h(i,a),s=g(i,a);this._slider.max=String(s),this._slider.value=String(Math.min(Math.max(o,1),s)),this._slider.setAttribute(`aria-valuetext`,`${Math.round(o*100)}%`),this._schedulePreviews()}_schedulePreviews(){if(!this._rect||this._previewBox.hidden||this._previewPending)return;this._previewPending=!0;let e=()=>{this._previewPending=!1,this._drawPreviews()};typeof requestAnimationFrame==`function`?requestAnimationFrame(e):e()}_drawPreviews(){if(!this._rect)return;let e=z(this._natural,`natural size`),t=f(this._rect,e.w,e.h),n=typeof window<`u`&&window.devicePixelRatio||1;for(let e of this._previewBox.children){if(!(e instanceof HTMLCanvasElement))throw Error(`Preview box holds a non-canvas child`);let r=e,i=Number(r.dataset.size),a=Math.max(1,Math.round(i*t.h/t.w));r.style.width=`${i}px`,r.style.height=`${a}px`,r.width=Math.round(i*n),r.height=Math.round(a*n);let o=r.getContext(`2d`);o&&this._drawCrop(o,t,r.width,r.height)}}_drawCrop(e,t,n,r){if(!this._rotation){e.drawImage(this._img,t.x,t.y,t.w,t.h,0,0,n,r);return}let i=z(this._source,`source size`),a=z(this._natural,`natural size`);e.save(),e.scale(n/t.w,r/t.h),e.translate(-t.x,-t.y),e.translate(a.w/2,a.h/2),e.rotate(this._rotation*Math.PI/180),e.drawImage(this._img,-i.w/2,-i.h/2,i.w,i.h),e.restore()}_announce(){this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:this.rect}))}_say(){let e=z(this._rect,`frame`),t=this._rotation?i(P().turnedText,{rotation:this._rotation}):``,n=i(P().frameText,{width:Math.round(e.w),height:Math.round(e.h),left:Math.round(e.x),top:Math.round(e.y),zoom:Math.round(h(e,z(this._base,`base frame`))*100),turned:t});this._live.textContent=n===this._live.textContent?`${n} `:n}rotate(){if(!this._rect)return;let e=z(this._natural,`natural size`),t=C(this._rect,e.w,e.h);this._rotation=(this._rotation+90)%360;let n=z(this._source,`source size`);this._natural=S(n.w,n.h,this._rotation),this._base=d(this._natural.w,this._natural.h,this.aspect);let r=this.aspect;this._rect=r&&r!==1?{...this._base}:t,this._paint(),this._announce()}reset(){this._source&&(this._rotation=0,this._natural={...this._source},this._resetRect(),this._announce())}_wire(){let e=this._stage;e.addEventListener(`pointerdown`,t=>{if(!this._rect||t.button>0)return;if(this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),e.setPointerCapture?.(t.pointerId),this._pointers.size===2){let[e,n]=R(this._pointers);this._drag=null,this._pinch={distance:L(e,n)||1,zoom:this.zoom,done:!1},t.preventDefault();return}if(this._pinch)return;let n=V(t.target);this._drag={id:t.pointerId,corner:n?n.dataset.handle:null,x:t.clientX,y:t.clientY,start:{...this._rect}},n||e.focus(),t.preventDefault()}),e.addEventListener(`pointermove`,t=>{if(this._pointers.has(t.pointerId)&&this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this._pinch){if(this._pinch.done||this._pointers.size<2||!this._pointers.has(t.pointerId))return;let[e,n]=R(this._pointers),r=this._pinch.zoom*L(e,n)/this._pinch.distance,i=z(this._natural,`natural size`);this._rect=_(z(this._rect,`frame`),z(this._base,`base frame`),r,i.w,i.h),this._paint();return}let n=this._drag;if(!n||n.id!==t.pointerId)return;let r=this._view(),{w:i,h:a}=z(this._natural,`natural size`);if(n.corner){let o=e.getBoundingClientRect(),s=(t.clientX-o.left-e.clientLeft-r.left)/r.scale,c=(t.clientY-o.top-e.clientTop-r.top)/r.scale;this._rect=y(z(this._rect,`frame`),n.corner,s,c,i,a)}else this._rect=p(n.start,(t.clientX-n.x)/r.scale,(t.clientY-n.y)/r.scale,i,a);this._paint()});let t=t=>{if(this._pointers.delete(t.pointerId)&&e.releasePointerCapture?.(t.pointerId),this._pinch){!this._pinch.done&&this._pointers.size<2&&(this._pinch.done=!0,this._announce()),this._pointers.size===0&&(this._pinch=null);return}let n=this._drag;n&&n.id===t.pointerId&&(this._drag=null,this._announce())};e.addEventListener(`pointerup`,t),e.addEventListener(`pointercancel`,t),e.addEventListener(`keydown`,e=>this._onKey(e)),e.addEventListener(`wheel`,e=>{this._rect&&this.contains(document.activeElement)&&(e.preventDefault(),this.zoom*=e.deltaY<0?1.1:1/1.1)},{passive:!1});for(let e of[`input`,`change`])this._slider.addEventListener(e,e=>e.stopPropagation());this._slider.addEventListener(`input`,()=>{this.zoom=Number(this._slider.value)});for(let e of this.querySelectorAll(`.wui-crop-zoombtn`)){if(!(e instanceof HTMLButtonElement))throw Error(`zoom button missing`);e.addEventListener(`click`,()=>{this.zoom*=e.dataset.zoom===`in`?1.25:.8})}B(this,`[data-crop-action="rotate"]`,HTMLButtonElement).addEventListener(`click`,()=>this.rotate()),B(this,`[data-crop-action="reset"]`,HTMLButtonElement).addEventListener(`click`,()=>this.reset())}_onKey(e){if(!this._rect||e.altKey||e.ctrlKey||e.metaKey)return;let{w:t,h:n}=z(this._natural,`natural size`);if(e.key===`+`||e.key===`=`)this.zoom*=1.25,this._say();else if(e.key===`-`||e.key===`_`)this.zoom*=.8,this._say();else if((e.key===`r`||e.key===`R`)&&this.rotatable)this.rotate(),this._say();else if(e.key.startsWith(`Arrow`)){let r=e.shiftKey?j:A,i=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:0,a=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,o=V(e.target)?.dataset.handle;if(o){let e=this._rect,s=(o.endsWith(`w`)?e.x:e.x+e.w)+i*r*e.w,c=(o.startsWith(`n`)?e.y:e.y+e.h)+a*r*e.h;this._rect=y(e,o,s,c,t,n)}else this._rect=p(this._rect,i*r*this._rect.w,a*r*this._rect.h,t,n);this._paint(),this._announce(),this._say()}else return;e.preventDefault()}async toBlob({type:e,maxBytes:t=0,size:n=0}={}){if(!this._rect)return null;let r=D(e),i=z(this._natural,`natural size`),a=f(this._rect,i.w,i.h),{width:o,height:s}=n>0?x(a,n):b(a);return k((e,t,n,r)=>new Promise(i=>{let o=document.createElement(`canvas`);o.width=e,o.height=t;let s=o.getContext(`2d`);s?(n===`image/jpeg`&&(s.fillStyle=`#fff`,s.fillRect(0,0,e,t)),this._drawCrop(s,a,e,t),o.toBlob(i,n,r)):i(null)}),{width:o,height:s,type:r,maxBytes:t})}async toFile({name:e,type:t,maxBytes:n=0,size:r=0}={}){let i=await this.toBlob({type:t,maxBytes:n,size:r});return i?new File([i],O(e,i.type),{type:i.type}):null}};export{H as t};
|
|
1
|
+
import{r as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{n}from"./svgNodes-CaPMDvv7.js";import{r,t as i}from"./textStore-Cs1SGBoI.js";import{t as a}from"./imageCrop.g-BnbAeH2Q.js";var o=4096,s=[.92,.8,.65,.5],c=.8,l=8;function u(e){if(e==null||e===``||e===`free`)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)&&t>0?t:null}function d(e,t,n){if(!n)return{x:0,y:0,w:e,h:t};let r=e,i=r/n;return i>t&&(i=t,r=i*n),{x:(e-r)/2,y:(t-i)/2,w:r,h:i}}function f(e,t,n){return{...e,x:Math.min(Math.max(e.x,0),Math.max(t-e.w,0)),y:Math.min(Math.max(e.y,0),Math.max(n-e.h,0))}}function p(e,t,n,r,i){return f({...e,x:e.x+t,y:e.y+n},r,i)}function m(e,t){return Math.min(32,e,t)}function h(e,t){return t.w/e.w}function g(e,t){return Math.max(4,h(e,t))}function _(e,t,n,r,i){let a=Math.min(Math.max(n,1),g(e,t)),o=e.h/e.w,s=Math.min(r,i/o),c=Math.min(Math.max(m(r,i),m(r,i)/o),s),l=Math.min(Math.max(t.w/a,c),s),u=l*o,d=e.x+e.w/2,p=e.y+e.h/2;return f({x:d-l/2,y:p-u/2,w:l,h:u},r,i)}var v=[`nw`,`ne`,`sw`,`se`];function y(e,t,n,r,i,a){let o=m(i,a),s=t.endsWith(`w`),c=t.startsWith(`n`),l=s?e.x+e.w:e.x,u=c?e.y+e.h:e.y,d=Math.min(Math.max(n,0),i),f=Math.min(Math.max(r,0),a);return d=s?Math.min(d,l-o):Math.max(d,l+o),f=c?Math.min(f,u-o):Math.max(f,u+o),{x:Math.min(d,l),y:Math.min(f,u),w:Math.abs(d-l),h:Math.abs(f-u)}}function b(e,t=o){let n=Math.min(1,t/Math.max(e.w,e.h));return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function x(e,t){let n=t/Math.max(e.w,e.h);return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function S(e,t,n){return n%180==0?{w:e,h:t}:{w:t,h:e}}function C(e,t,n){return f({x:n-(e.y+e.h),y:e.x,w:e.h,h:e.w},n,t)}function w(e){return String(e||``).split(/[\s,]+/).map(Number).filter(e=>Number.isInteger(e)&&e>0)}var T=[`image/png`,`image/jpeg`,`image/webp`],E={"image/png":`.png`,"image/jpeg":`.jpg`,"image/webp":`.webp`};function D(e){let t=String(e||``).toLowerCase();return T.includes(t)?t:`image/png`}function O(e,t){let n=String(e||`image`),r=E[t];if(r===void 0)throw Error(`No file extension for ${t}`);return(t===`image/jpeg`?/\.jpe?g$/i.test(n):n.toLowerCase().endsWith(r))?n:`${n.replace(/\.[^./\\]+$/,``)||`image`}${r}`}async function k(e,{width:t,height:n,type:r,maxBytes:i}){let a=r,o=t,u=n,d=null;for(let t=0;t<=l;t++){let n=a===`image/png`?[void 0]:t===0?s:[s[1]];for(let t of n){if(d=await e(o,u,a,t),!d||(d.type&&d.type!==a&&(a=d.type),!(i>0)||d.size<=i))return d;if(a===`image/png`)break}o=Math.max(1,Math.round(o*c)),u=Math.max(1,Math.round(u*c))}return d}var A=.05,j=.2,M={w:320,h:240},N={nw:`topLeftLabel`,ne:`topRightLabel`,sw:`bottomLeftLabel`,se:`bottomRightLabel`},P=()=>r(`imageCrop`,a),F=e=>{let t=N[e];return t?P()[t]:e};function I(e,t=!1){return n({width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,...t?{"stroke-linejoin":`round`}:{},"aria-hidden":`true`},e.map(e=>[`path`,{d:e}]))}var L=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function R(e){let[t,n]=[...e.values()];if(!t||!n)throw Error(`two pointers missing`);return[t,n]}function z(e,t){if(e===null)throw Error(`${t} missing`);return e}function B(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`${t} missing`);return r}function V(e){if(e===null)throw Error(`event target missing`);if(!(e instanceof Element))return null;let t=e.closest(`.wui-crop-handle`);return t instanceof HTMLElement?t:null}var H=class extends t{_rect;_base;_natural;_source;_rotation;_drag;_pointers;_pinch;_previewPending;_resizeObserver;_rendered;_stageEl;_imgEl;_frameEl;_sliderEl;_toolsEl;_previewBoxEl;_liveEl;static get observedAttributes(){return[`src`,`aspect`,`round`,`rotatable`,`previews`]}constructor(){super(),this._rect=null,this._base=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pointers=/* @__PURE__ */ new Map,this._pinch=null,this._previewPending=!1,this._resizeObserver=null,this._stageEl=null,this._imgEl=null,this._frameEl=null,this._sliderEl=null,this._toolsEl=null,this._previewBoxEl=null,this._liveEl=null}get _stage(){return z(this._stageEl,`stage`)}get _img(){return z(this._imgEl,`image`)}get _frame(){return z(this._frameEl,`frame`)}get _slider(){return z(this._sliderEl,`zoom slider`)}get _tools(){return z(this._toolsEl,`tools`)}get _previewBox(){return z(this._previewBoxEl,`previews`)}get _live(){return z(this._liveEl,`live region`)}get src(){return this.getAttribute(`src`)||``}set src(e){e==null||e===``?this.removeAttribute(`src`):this.setAttribute(`src`,String(e))}get aspect(){return u(this.getAttribute(`aspect`))}set aspect(e){e==null||e===``?this.removeAttribute(`aspect`):this.setAttribute(`aspect`,String(e))}get round(){return this.hasAttribute(`round`)}set round(e){this.toggleAttribute(`round`,!!e)}get rotatable(){return this.hasAttribute(`rotatable`)}set rotatable(e){this.toggleAttribute(`rotatable`,!!e)}get previews(){return this.getAttribute(`previews`)||``}set previews(e){e==null||e===``?this.removeAttribute(`previews`):this.setAttribute(`previews`,Array.isArray(e)?e.join(` `):String(e))}get rect(){return this._rect?{...this._rect}:null}get rotation(){return this._rotation}set rotation(e){if(!this._rect)return;let t=(Math.round(Number(e)/90)*90%360+360)%360;if(!Number.isNaN(t))for(;this._rotation!==t;)this.rotate()}get zoom(){return this._rect?h(this._rect,z(this._base,`base frame`)):1}set zoom(e){if(!this._rect)return;let t=z(this._natural,`natural size`);this._rect=_(this._rect,z(this._base,`base frame`),Number(e)||1,t.w,t.h),this._paint(),this._announce()}connectedCallback(){this._rendered?this._observe():this.render()}disconnectedCallback(){this._resizeObserver?.disconnect(),this._resizeObserver=null}attributeChangedCallback(e){this._rendered&&(e===`src`?this._loadImage():e===`aspect`?(this._rebuildHandles(),this._resetRect()):e===`rotatable`?this._tools.hidden=!this.rotatable:e===`previews`?this._renderPreviews():this._applyRound())}render(){this.replaceChildren(e(`div`,null,e(`div`,{class:`wui-crop-stage`,tabindex:`0`,role:`group`,"aria-label":P().cropAreaText},e(`img`,{class:`wui-crop-img`,alt:``,draggable:`false`}),e(`div`,{class:`wui-crop-frame`})),e(`div`,{class:`wui-crop-controls`},e(`button`,{type:`button`,class:`wui-crop-zoombtn`,"data-zoom":`out`,"aria-label":P().zoomOutLabel},I([`M5 12h14`])),e(`input`,{type:`range`,class:`form-range wui-crop-zoom`,min:1,max:4,step:`0.01`,value:1,"aria-label":P().zoomLabel}),e(`button`,{type:`button`,class:`wui-crop-zoombtn`,"data-zoom":`in`,"aria-label":P().zoomInLabel},I([`M5 12h14M12 5v14`]))),e(`div`,{class:`wui-crop-tools`,hidden:!0},e(`button`,{type:`button`,class:`wui-crop-toolbtn`,"data-crop-action":`rotate`,"aria-label":P().rotateClockwiseLabel},I([`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,`M21 3v5h-5`],!0),e(`span`,null,P().rotateLabel)),e(`button`,{type:`button`,class:`wui-crop-toolbtn`,"data-crop-action":`reset`,"aria-label":P().resetCropLabel},I([`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,`M3 3v5h5`],!0),e(`span`,null,P().resetLabel))),e(`div`,{class:`wui-crop-previews`,"aria-hidden":`true`,hidden:!0}),e(`div`,{class:`visually-hidden`,"data-wui-crop-live":!0,"aria-live":`polite`}))),this._stageEl=B(this,`.wui-crop-stage`,HTMLElement),this._imgEl=B(this,`.wui-crop-img`,HTMLImageElement),this._frameEl=B(this,`.wui-crop-frame`,HTMLElement),this._sliderEl=B(this,`.wui-crop-zoom`,HTMLInputElement),this._toolsEl=B(this,`.wui-crop-tools`,HTMLElement),this._previewBoxEl=B(this,`.wui-crop-previews`,HTMLElement),this._liveEl=B(this,`[data-wui-crop-live]`,HTMLElement),this._rendered=!0,this._tools.hidden=!this.rotatable,this._applyRound(),this._rebuildHandles(),this._renderPreviews(),this._wire(),this._observe(),this._loadImage()}_applyRound(){this._frame.classList.toggle(`wui-crop-frame--round`,this.round),this._previewBox.classList.toggle(`wui-crop-previews--round`,this.round)}_rebuildHandles(){for(let e of this._frame.querySelectorAll(`.wui-crop-handle`))e.remove();if(!this.aspect)for(let e of v){let t=document.createElement(`button`);t.type=`button`,t.className=`wui-crop-handle wui-crop-handle--${e}`,t.dataset.handle=e,t.setAttribute(`aria-label`,i(P().resizeCornerText,{corner:F(e)})),this._frame.appendChild(t)}}_renderPreviews(){let e=w(this.previews);this._previewBox.replaceChildren(),this._previewBox.hidden=e.length===0;for(let t of e){let e=document.createElement(`canvas`);e.className=`wui-crop-preview`,e.dataset.size=String(t),e.style.width=`${t}px`,e.style.height=`${t}px`,this._previewBox.appendChild(e)}this._schedulePreviews()}_loadImage(){this._rect=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pinch=null,this._pointers.clear();let e=this.src;this._img.hidden=!e,this._frame.hidden=!0,e&&(this._img.onload=()=>{this._source={w:this._img.naturalWidth,h:this._img.naturalHeight},this._natural={...this._source},this._resetRect(),this.dispatchEvent(new Event(`load`))},this._img.onerror=()=>{this._frame.hidden=!0,this.dispatchEvent(new Event(`error`))},this._img.src=e)}_resetRect(){this._natural&&(this._base=d(this._natural.w,this._natural.h,this.aspect),this._rect={...this._base},this._frame.hidden=!1,this._paint())}_observe(){typeof ResizeObserver>`u`||this._resizeObserver||(this._resizeObserver=new ResizeObserver(()=>this._paint()),this._resizeObserver.observe(this._stage))}_view(){let e=z(this._natural,`natural size`),t=this._stage.clientWidth||M.w,n=this._stage.clientHeight||M.h,r=Math.min(t/e.w,n/e.h),i=e.w*r,a=e.h*r;return{scale:r,left:(t-i)/2,top:(n-a)/2,iw:i,ih:a}}_paint(){if(!this._rect)return;let e=this._view(),t=this._rotation%180!=0,n=t?e.ih:e.iw,r=t?e.iw:e.ih;Object.assign(this._img.style,{left:`${e.left+(e.iw-n)/2}px`,top:`${e.top+(e.ih-r)/2}px`,width:`${n}px`,height:`${r}px`,transform:this._rotation?`rotate(${this._rotation}deg)`:``});let i=this._rect;Object.assign(this._frame.style,{left:`${e.left+i.x*e.scale}px`,top:`${e.top+i.y*e.scale}px`,width:`${i.w*e.scale}px`,height:`${i.h*e.scale}px`});let a=z(this._base,`base frame`),o=h(i,a),s=g(i,a);this._slider.max=String(s),this._slider.value=String(Math.min(Math.max(o,1),s)),this._slider.setAttribute(`aria-valuetext`,`${Math.round(o*100)}%`),this._schedulePreviews()}_schedulePreviews(){if(!this._rect||this._previewBox.hidden||this._previewPending)return;this._previewPending=!0;let e=()=>{this._previewPending=!1,this._drawPreviews()};typeof requestAnimationFrame==`function`?requestAnimationFrame(e):e()}_drawPreviews(){if(!this._rect)return;let e=z(this._natural,`natural size`),t=f(this._rect,e.w,e.h),n=typeof window<`u`&&window.devicePixelRatio||1;for(let e of this._previewBox.children){if(!(e instanceof HTMLCanvasElement))throw Error(`Preview box holds a non-canvas child`);let r=e,i=Number(r.dataset.size),a=Math.max(1,Math.round(i*t.h/t.w));r.style.width=`${i}px`,r.style.height=`${a}px`,r.width=Math.round(i*n),r.height=Math.round(a*n);let o=r.getContext(`2d`);o&&this._drawCrop(o,t,r.width,r.height)}}_drawCrop(e,t,n,r){if(!this._rotation){e.drawImage(this._img,t.x,t.y,t.w,t.h,0,0,n,r);return}let i=z(this._source,`source size`),a=z(this._natural,`natural size`);e.save(),e.scale(n/t.w,r/t.h),e.translate(-t.x,-t.y),e.translate(a.w/2,a.h/2),e.rotate(this._rotation*Math.PI/180),e.drawImage(this._img,-i.w/2,-i.h/2,i.w,i.h),e.restore()}_announce(){this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:this.rect}))}_say(){let e=z(this._rect,`frame`),t=this._rotation?i(P().turnedText,{rotation:this._rotation}):``,n=i(P().frameText,{width:Math.round(e.w),height:Math.round(e.h),left:Math.round(e.x),top:Math.round(e.y),zoom:Math.round(h(e,z(this._base,`base frame`))*100),turned:t});this._live.textContent=n===this._live.textContent?`${n} `:n}rotate(){if(!this._rect)return;let e=z(this._natural,`natural size`),t=C(this._rect,e.w,e.h);this._rotation=(this._rotation+90)%360;let n=z(this._source,`source size`);this._natural=S(n.w,n.h,this._rotation),this._base=d(this._natural.w,this._natural.h,this.aspect);let r=this.aspect;this._rect=r&&r!==1?{...this._base}:t,this._paint(),this._announce()}reset(){this._source&&(this._rotation=0,this._natural={...this._source},this._resetRect(),this._announce())}_wire(){let e=this._stage;e.addEventListener(`pointerdown`,t=>{if(!this._rect||t.button>0)return;if(this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),e.setPointerCapture?.(t.pointerId),this._pointers.size===2){let[e,n]=R(this._pointers);this._drag=null,this._pinch={distance:L(e,n)||1,zoom:this.zoom,done:!1},t.preventDefault();return}if(this._pinch)return;let n=V(t.target);this._drag={id:t.pointerId,corner:n?n.dataset.handle:null,x:t.clientX,y:t.clientY,start:{...this._rect}},n||e.focus(),t.preventDefault()}),e.addEventListener(`pointermove`,t=>{if(this._pointers.has(t.pointerId)&&this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this._pinch){if(this._pinch.done||this._pointers.size<2||!this._pointers.has(t.pointerId))return;let[e,n]=R(this._pointers),r=this._pinch.zoom*L(e,n)/this._pinch.distance,i=z(this._natural,`natural size`);this._rect=_(z(this._rect,`frame`),z(this._base,`base frame`),r,i.w,i.h),this._paint();return}let n=this._drag;if(!n||n.id!==t.pointerId)return;let r=this._view(),{w:i,h:a}=z(this._natural,`natural size`);if(n.corner){let o=e.getBoundingClientRect(),s=(t.clientX-o.left-e.clientLeft-r.left)/r.scale,c=(t.clientY-o.top-e.clientTop-r.top)/r.scale;this._rect=y(z(this._rect,`frame`),n.corner,s,c,i,a)}else this._rect=p(n.start,(t.clientX-n.x)/r.scale,(t.clientY-n.y)/r.scale,i,a);this._paint()});let t=t=>{if(this._pointers.delete(t.pointerId)&&e.releasePointerCapture?.(t.pointerId),this._pinch){!this._pinch.done&&this._pointers.size<2&&(this._pinch.done=!0,this._announce()),this._pointers.size===0&&(this._pinch=null);return}let n=this._drag;n&&n.id===t.pointerId&&(this._drag=null,this._announce())};e.addEventListener(`pointerup`,t),e.addEventListener(`pointercancel`,t),e.addEventListener(`keydown`,e=>this._onKey(e)),e.addEventListener(`wheel`,e=>{this._rect&&this.contains(document.activeElement)&&(e.preventDefault(),this.zoom*=e.deltaY<0?1.1:1/1.1)},{passive:!1});for(let e of[`input`,`change`])this._slider.addEventListener(e,e=>e.stopPropagation());this._slider.addEventListener(`input`,()=>{this.zoom=Number(this._slider.value)});for(let e of this.querySelectorAll(`.wui-crop-zoombtn`)){if(!(e instanceof HTMLButtonElement))throw Error(`zoom button missing`);e.addEventListener(`click`,()=>{this.zoom*=e.dataset.zoom===`in`?1.25:.8})}B(this,`[data-crop-action="rotate"]`,HTMLButtonElement).addEventListener(`click`,()=>this.rotate()),B(this,`[data-crop-action="reset"]`,HTMLButtonElement).addEventListener(`click`,()=>this.reset())}_onKey(e){if(!this._rect||e.altKey||e.ctrlKey||e.metaKey)return;let{w:t,h:n}=z(this._natural,`natural size`);if(e.key===`+`||e.key===`=`)this.zoom*=1.25,this._say();else if(e.key===`-`||e.key===`_`)this.zoom*=.8,this._say();else if((e.key===`r`||e.key===`R`)&&this.rotatable)this.rotate(),this._say();else if(e.key.startsWith(`Arrow`)){let r=e.shiftKey?j:A,i=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:0,a=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,o=V(e.target)?.dataset.handle;if(o){let e=this._rect,s=(o.endsWith(`w`)?e.x:e.x+e.w)+i*r*e.w,c=(o.startsWith(`n`)?e.y:e.y+e.h)+a*r*e.h;this._rect=y(e,o,s,c,t,n)}else this._rect=p(this._rect,i*r*this._rect.w,a*r*this._rect.h,t,n);this._paint(),this._announce(),this._say()}else return;e.preventDefault()}async toBlob({type:e,maxBytes:t=0,size:n=0}={}){if(!this._rect)return null;let r=D(e),i=z(this._natural,`natural size`),a=f(this._rect,i.w,i.h),{width:o,height:s}=n>0?x(a,n):b(a);return k((e,t,n,r)=>new Promise(i=>{let o=document.createElement(`canvas`);o.width=e,o.height=t;let s=o.getContext(`2d`);s?(n===`image/jpeg`&&(s.fillStyle=`#fff`,s.fillRect(0,0,e,t)),this._drawCrop(s,a,e,t),o.toBlob(i,n,r)):i(null)}),{width:o,height:s,type:r,maxBytes:t})}async toFile({name:e,type:t,maxBytes:n=0,size:r=0}={}){let i=await this.toBlob({type:t,maxBytes:n,size:r});return i?new File([i],O(e,i.type),{type:i.type}):null}};export{H as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./formatters-lNUhNemK.js";import{i as t}from"./calendarMath-D8B0i3XW.js";import{n,r,t as i}from"./digitGrouping-CCPI3HK3.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s,t as c}from"./inlineEditText-BjHkrr4q.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-Cs1SGBoI.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 a{_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(n){if(n===``){this._showText(this.getAttribute(`placeholder`)||e(),!0);return}let r=this._type(),a=n;if(r===`date`)a=t(n)||n;else if(r===`select`){let e=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(e=>e.getAttribute(`data-value`)===n);e&&(a=(e.textContent??``).trim())}else r===`number`&&this._grouping()===`indian`&&(a=i(n));this._showText(a,!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(!r(e))throw Error(n(e));return e}};export{N as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,t}from"./devWarn-DXdRWZs3.js";import{r as n}from"./dom-DMQu--xV.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{r as i,t as a}from"./textStore-
|
|
1
|
+
import{n as e,t}from"./devWarn-DXdRWZs3.js";import{r as n}from"./dom-DMQu--xV.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{r as i,t as a}from"./textStore-Cs1SGBoI.js";import{t as o}from"./leadPopup.g-BfMPz9nH.js";var s={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-soft":`#E0E7FF`,"--color-primary-text":`#4F46E5`,"--color-on-primary":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-border-strong":`#C4CADA`,"--color-surface":`#FFFFFF`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-modal":`0px 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-modal":`1505`},c=e=>`var(${e}, ${s[e]})`,l=`
|
|
2
2
|
:host {
|
|
3
3
|
all: initial;
|
|
4
4
|
display: contents;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./formatters-lNUhNemK.js";import{r as t}from"./dom-DMQu--xV.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{t as r}from"./iconGlyphs.g-DRNDTVOs.js";import{u as i}from"./nativeOverlay-MOABXAAh.js";import{n as a,t as o}from"./rtl-g7G8Bsib.js";import{r as s,t as c}from"./textStore-Cs1SGBoI.js";import{t as l}from"./lightbox.g-DDrycPou.js";var u=`a.wui-lightbox-item`,d=1,f=4,p=.5,m=2,h=50,g=6,_=300,v=300;function y(e){return Number.isFinite(e)?Math.min(f,Math.max(d,e)):d}function b(e,t,n,r){let i=(e,n)=>Math.max(0,(e*t-n)/2),a=i(r.width,n.width),o=i(r.height,n.height);return{x:Math.min(a,Math.max(-a,e.x)),y:Math.min(o,Math.max(-o,e.y))}}function x(e,t){return Math.abs(e)<h||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function S(e){let t=(String(e??``).split(/[?#]/)[0]??``).split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var C=()=>s(`lightbox`,l);function w(e,n,i){let a=t(`button`,{class:`u-action wui-lightbox-btn ${i}`,type:`button`,"aria-label":n,title:n});a.style.setProperty(`--wui-action-size`,`40px`);let o=r(e,{size:20});return a.replaceChildren(...o?[o]:[]),a}var T=class extends n{_ui;_index;_zoom;_pan;_pointers;_gesture;_lastTap;_returnTo;_release;_onClick;static get observedAttributes(){return[`open-index`]}constructor(){super(),this._ui=null,this._index=0,this._zoom=d,this._pan={x:0,y:0},this._pointers=/* @__PURE__ */ new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._release=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target,n=t instanceof Element?t.closest(u):null;if(!(n instanceof HTMLAnchorElement)||!this.contains(n))return;let r=this._links().indexOf(n);r<0||(e.preventDefault(),this.open(r))}}get _view(){if(!this._ui)throw Error(`<wui-lightbox> viewer is not open.`);return this._ui}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||C().label}set label(e){this.setAttribute(`label`,String(e??``))}get layout(){return this.getAttribute(`layout`)===`single`?`single`:`gallery`}set layout(e){if(e===`single`)this.setAttribute(`layout`,`single`);else if(e===`gallery`||e===``)this.removeAttribute(`layout`);else throw Error(`<wui-lightbox> layout must be "gallery" or "single", received "${e}".`)}get isOpen(){return this._ui!==null}connectedCallback(){this.addEventListener(`click`,this._onClick),this._syncOpenIndex()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this._teardown()}attributeChangedCallback(){this.isConnected&&this._syncOpenIndex()}_syncOpenIndex(){let e=this.getAttribute(`open-index`);e===null?this.close():this.open(Number(e))}_links(){return[...this.querySelectorAll(u)].filter(e=>e instanceof HTMLAnchorElement)}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||S(t)}})}open(e=0){let t=this._items();if(!t.length)return!1;if(!this._ui){let t=document.activeElement;this._returnTo=t instanceof HTMLElement||t instanceof SVGElement?t:null,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))}return this._show(e,t),!0}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._release?.(),this._release=null,this._ui.root.open&&this._ui.root.close(),this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null)}_build(){let e=t(`dialog`,{class:`wui-lightbox-overlay`,role:`dialog`,"aria-label":this.label,tabindex:`-1`}),n=t(`div`,{class:`wui-lightbox-bar`}),a=t(`span`,{class:`wui-lightbox-count`,"aria-live":`polite`}),o=t(`div`,{class:`wui-lightbox-tools`}),s=w(`zoom-out`,C().zoomOutLabel,`wui-lightbox-zoom-out`),c=w(`zoom-in`,C().zoomInLabel,`wui-lightbox-zoom-in`),l=t(`a`,{class:`u-action wui-lightbox-btn wui-lightbox-download`,"aria-label":C().downloadLabel,title:C().downloadLabel});l.style.setProperty(`--wui-action-size`,`40px`);let u=r(`download`,{size:20});l.replaceChildren(...u?[u]:[]),l.hidden=!this.download;let d=w(`x`,C().closeLabel,`wui-lightbox-close`);o.append(s,c,l,d),n.append(a,o);let f=t(`div`,{class:`wui-lightbox-stage`}),m=w(`chevron-left`,C().previousImageLabel,`wui-lightbox-nav wui-lightbox-prev`),h=w(`chevron-right`,C().nextImageLabel,`wui-lightbox-nav wui-lightbox-next`),g=t(`img`,{class:`wui-lightbox-image`,decoding:`async`,draggable:`false`,alt:``}),_=t(`p`,{class:`wui-lightbox-status`,role:`status`});f.append(g,_,m,h);let v=t(`p`,{class:`wui-lightbox-caption`});e.append(n,f,v);let y={root:e,count:a,zoomOut:s,zoomIn:c,download:l,close:d,stage:f,prev:m,next:h,image:g,status:_,caption:v};this._ui=y,d.addEventListener(`click`,()=>this.close()),m.addEventListener(`click`,()=>this.step(-1)),h.addEventListener(`click`,()=>this.step(1)),s.addEventListener(`click`,()=>this._setZoom(this._zoom-p)),c.addEventListener(`click`,()=>this._setZoom(this._zoom+p)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),f.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),f.addEventListener(`pointermove`,e=>this._onPointerMove(e)),f.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),f.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),f.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),g.addEventListener(`load`,()=>{this._ui===y&&(_.textContent=``,f.removeAttribute(`aria-busy`),g.hidden=!1,this._applyTransform())}),g.addEventListener(`error`,()=>{this._ui===y&&(f.removeAttribute(`aria-busy`),g.hidden=!0,_.textContent=C().imageFailedMessage)}),this.append(e),this._release=i(e,{escape:!0,backdrop:null,focus:`panel`,onRequestClose:()=>this.close()})}step(e){if(!this._ui||!e)return;let t=this._items();t.length<2||this._show((this._index+e+t.length)%t.length,t)}_show(t,n){let r=this._view,i=Math.min(n.length-1,Math.max(0,Math.trunc(Number(t))||0)),a=n[i];if(!a)throw Error(`<wui-lightbox> image missing.`);let o=i!==this._index||!r.image.getAttribute(`src`);if(this._index=i,this._zoom=d,this._pan={x:0,y:0},r.count.textContent=c(C().countText,{position:e(i+1,{decimals:0}),total:e(n.length,{decimals:0})}),r.caption.textContent=a.caption,r.caption.hidden=!a.caption,r.download.href=a.src,r.download.setAttribute(`download`,a.name),r.prev.hidden=r.next.hidden=n.length<2,r.stage.setAttribute(`aria-busy`,`true`),r.status.textContent=``,r.image.hidden=!1,r.image.alt=a.alt||a.caption,r.image.src=a.src,this._applyTransform(),this._syncZoomButtons(),n.length>1){let e=n[(i+1)%n.length],t=n[(i-1+n.length)%n.length];if(!e||!t)throw Error(`<wui-lightbox> neighbour image missing.`);for(let n of[e,t])new Image().src=n.src}o&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:i}}))}_syncZoomButtons(){let e=this._view;e.zoomOut.disabled=this._zoom<=d,e.zoomIn.disabled=this._zoom>=f;let t=document.activeElement;(t===e.zoomOut||t===e.zoomIn)&&t instanceof HTMLButtonElement&&t.disabled&&e.close.focus()}_setZoom(e){this._ui&&(this._zoom=y(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._view;return b(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._view;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>d)}_onKeyDown(e){let t=a(e.key,o(this));if(t===`ArrowLeft`||t===`ArrowRight`)e.preventDefault(),this.step(t===`ArrowRight`?1:-1);else if(e.key===`Home`||e.key===`End`){e.preventDefault();let t=this._items();this._show(e.key===`Home`?0:t.length-1,t)}else e.key===`+`||e.key===`=`?(e.preventDefault(),this._setZoom(this._zoom+p)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-p)):e.key===`0`&&(e.preventDefault(),this._setZoom(d))}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){let t=e.target;if(t instanceof Element&&t.closest(`.wui-lightbox-nav`))return;let n=this._view;if(n.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let e=[...this._pointers.values()],t=e[0],n=e[1];if(!t||!n)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._gesture={kind:`pinch`,distance:Math.hypot(t.x-n.x,t.y-n.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===n.image,moved:!1})}_onPointerMove(e){let t=this._gesture;if(t&&this._pointers.has(e.pointerId)){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let e=[...this._pointers.values()],n=e[0],r=e[1];if(!n||!r)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._setZoom(t.zoom*Math.hypot(n.x-r.x,n.y-r.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>g&&(t.moved=!0),this._zoom>d&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._view.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,i=e.clientY-n.startY;n.moved?this._zoom===d&&this.step(x(r,i)):e.timeStamp-n.startTime>_||(n.onImage?e.timeStamp-this._lastTap<v?(this._lastTap=-1/0,this._setZoom(this._zoom>d?d:m)):this._lastTap=e.timeStamp:this.close())}};export{T as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./formatters-lNUhNemK.js";import{t}from"./elementBase-Cxeyx0tU.js";import{n,r,t as i}from"./fieldState-D-zQcXUS.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-MOABXAAh.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-Cs1SGBoI.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,t){t.readOnly=n(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 t{_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||i(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,r=n.lastIndexOf(`@`,t-1);if(r<0||r>0&&!/[\s([{"'“‘]/.test(n.charAt(r-1)))return null;let a=n.slice(r+1,t);return a.length>40||/[\n@]/.test(a)||/^\s/.test(a)||/\s{2}/.test(a)||this._mentions.some(e=>r>=e.start&&r<e.end)?null:{start:r,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 t=this._menu(),n=this._control();if(!t||!n||!this._query)return;this._syncState();let r=this.ownerDocument;if(t.replaceChildren(),this._results.forEach((e,n)=>{let i=r.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${t.id}-${n}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(n),e.src){let t=r.createElement(`img`);t.className=`wui-mention-option-photo`,t.src=e.src,t.alt=``,i.appendChild(t)}let a=r.createElement(`span`);a.className=`wui-mention-option-text`;let o=r.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=l(e.label),a.appendChild(o),e.description){let t=r.createElement(`span`);t.className=`wui-mention-option-description`,t.textContent=String(e.description),a.appendChild(t)}i.appendChild(a),t.appendChild(i)}),!this._results.length){let e=r.createElement(`div`);e.className=`wui-mention-empty`,e.textContent=this.loading?C().searchingLabel:this._searchFailed?C().searchFailedMessage:`${C().noMatchLabel} “${this._query.text}”`,t.appendChild(e)}p(n,t,{mode:`manual`}),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?_(C(),`foundText`,this._results.length,{count:e(this._results.length,{decimals:0})}):this._searchFailed?C().searchFailedMessage:`${C().noMatchLabel}.`)}_syncState(){let e=this._control();e&&r(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"./elementBase-Cxeyx0tU.js";import{h as t,o as n,p as r,u as i}from"./nativeOverlay-MOABXAAh.js";var a=class extends e{_doc;_release;_opener;_returnTo;_session;_closing;_reopen;static get observedAttributes(){return[`open`,`static`,`no-escape`]}constructor(){super(),this._doc=null,this._release=null,this._opener=null,this._returnTo=null,this._session=0,this._closing=!1,this._reopen=!1}connectedCallback(){this._doc=this.ownerDocument,t(this._doc),this.hasAttribute(`open`)&&this._open()}disconnectedCallback(){this._session++,this._closing=!1,this._reopen=!1;let e=this.querySelector(`dialog`);this._release&&e instanceof HTMLDialogElement&&e.close(),this._releaseDialog(),this._opener=null,this._returnTo=null,this._doc=null}attributeChangedCallback(e){this._doc&&e===`open`&&(this.hasAttribute(`open`)?this._open():this._close())}get isOpen(){return this.hasAttribute(`open`)}show(e){e&&(this._opener=e),this.setAttribute(`open`,``)}hide(){this.removeAttribute(`open`)}_open(){if(this._closing){this._reopen=!0;return}if(this._release)return;let e=++this._session,t=this._opener;if(this._returnTo=t,this._opener=null,this.dispatchEvent(new CustomEvent(`wui-modal-open`,{bubbles:!0,detail:{trigger:t}})),!this.isOpen)return;let n=this._dialog();this._release=i(n,{escape:!this.hasAttribute(`no-escape`),backdrop:this.hasAttribute(`static`)?null:this._card(n),focus:`first-control`,onRequestClose:e=>this._requestClose(e)}),this._settle(e,n)}_close(){if(this._closing){this._reopen=!1;return}if(!this._release)return;this._closing=!0;let e=this._session,t=this._dialog();n(t).then(()=>{e===this._session&&(this._closing=!1,this._releaseDialog(),r(this._returnTo,t),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-modal-closed`,{bubbles:!0})),this._reopen&&(this._reopen=!1,this.isOpen&&this._open()))})}_settle(e,t){let n=t.getAnimations?.()??[];n.length?Promise.allSettled(n.map(e=>e.finished)).then(()=>{e===this._session&&this.isOpen&&this._announceOpened()}):this._announceOpened()}_announceOpened(){this.dispatchEvent(new CustomEvent(`wui-modal-opened`,{bubbles:!0}))}_requestClose(e){this.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:e}}))&&this.removeAttribute(`open`)}_releaseDialog(){let e=this._release;this._release=null,e?.()}_card(e){let t=e.querySelector(`.modal-content.wui-modal`);if(!(t instanceof HTMLElement))throw TypeError(`wui-modal has no .modal-content.wui-modal`);return t}_dialog(){let e=this.querySelector(`dialog`);if(!(e instanceof HTMLDialogElement))throw TypeError(`wui-modal has no <dialog>`);return e}};export{a as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{a as n,l as r,s as i}from"./nativeOverlay-
|
|
1
|
+
import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{a as n,l as r,s as i}from"./nativeOverlay-MOABXAAh.js";import{n as a,t as o}from"./rtl-g7G8Bsib.js";var s=`.wui-nav-menu-link`,c=`(max-width: 767.98px)`,l=`data-open`,u=e=>e instanceof Element?e:e instanceof Node?e.parentElement:null,d=e=>[...e].filter(e=>e instanceof HTMLElement),f=e=>{let t=e.children[0];if(!(t instanceof HTMLElement))throw Error(`Navigation entry has no control.`);return t},p=e=>{let t=e.children[1];return t instanceof HTMLElement?t:null},m=(e,t,n)=>{let r=e[t];if(r===void 0)throw Error(n);return r},h=class extends t{constructor(){super(),this._onClick=e=>this._handleClick(e),this._onKeyDown=e=>this._handleKeyDown(e),this._onFocusOut=e=>{if(this._vertical())return;let t=this._openItem(),n=e.relatedTarget;t&&n instanceof Node&&!t.contains(n)&&this._set(t,!1)},this._onPointerDown=()=>{this._pressedOpen=this._openItem()},this._onModeChange=()=>{if(this._vertical())return;let e=this._openItem();e&&this._set(e,!1)},this._onOutsidePress=e=>{let t=this._openItem();t&&!e.composedPath().includes(t)&&this._set(t,!1)},this._pressedOpen=null,this._media=null}connectedCallback(){this._teardown(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this._media=window.matchMedia(c),this._media.addEventListener(`change`,this._onModeChange)}disconnectedCallback(){this._teardown()}open(e){let t=this._items().find(t=>{let n=t.children[0];return n instanceof HTMLElement&&this._isTrigger(n)&&n.dataset.key===e});t&&this._set(t,!0)}close(e=!1){let t=this._openItem();t&&(this._set(t,!1),e&&f(t).focus({preventScroll:!0}))}_items(){return d(this.querySelectorAll(`.wui-nav-menu-item`))}_openItem(){return this._items().find(e=>{let t=p(e);return t!==null&&this._isOpen(t)})??null}_vertical(){return this.getAttribute(`orientation`)===`vertical`}_isOpen(e){return e.hasAttribute(l)||i(e)}_isTrigger(e){return!!e?.classList.contains(`wui-nav-menu-trigger`)}_entries(){return this._items().map(f)}_links(e){let t=p(e);return t?d(t.querySelectorAll(s)):[]}_set(e,t){let a=p(e);if(!a)return;let o=f(e);if(t){let t=this._openItem();if(t&&t!==e&&this._set(t,!1),this._isOpen(a))return;o.setAttribute(`aria-expanded`,`true`),this._vertical()?a.setAttribute(l,``):window.matchMedia(c).matches?(a.setAttribute(l,``),document.addEventListener(`pointerdown`,this._onOutsidePress,!0)):r(o,a,{mode:`auto`,below:!0,flipAlign:!0,onClosed:()=>this._settle(e)}),this._emit(o,!0)}else a.removeAttribute(l),document.removeEventListener(`pointerdown`,this._onOutsidePress,!0),i(a)&&n(a),this._settle(e)}_settle(e){let t=f(e);t.getAttribute(`aria-expanded`)!==`false`&&(t.setAttribute(`aria-expanded`,`false`),this._emit(t,!1))}_emit(e,t){this.dispatchEvent(new CustomEvent(`wui-navigation-menu:toggle`,{bubbles:!0,detail:{key:e.dataset.key??null,open:t}}))}_handleClick(t){let n=this._pressedOpen;this._pressedOpen=null;let r=u(t.target),i=r?.closest(`.wui-nav-menu-trigger`);if(i&&this.contains(i)){let t=e(i.parentElement,`Navigation trigger has no entry.`),r=e(p(t),`Navigation entry has no panel.`),a=n===t||this._isOpen(r);this._set(t,!a);return}let a=r?.closest(s);a&&this.contains(a)&&this.close()}_handleKeyDown(t){if(this._pressedOpen=null,t.altKey||t.ctrlKey||t.metaKey)return;let n=u(t.target)?.closest(`.wui-nav-menu-trigger, .wui-nav-menu-toplink, .wui-nav-menu-link`);if(!(n instanceof HTMLElement)||!this.contains(n))return;let r=this._openItem();if(t.key===`Escape`){if(!r||!p(r)?.hasAttribute(l))return;t.preventDefault(),t.stopPropagation();let e=r.contains(n);this._set(r,!1),e&&f(r).focus({preventScroll:!0});return}if(this._vertical()){this._verticalKey(t,n);return}if(n.matches(s)){this._linkKey(t,n);return}let i=this._entries(),c=i.indexOf(n),d=a(t.key,o(this));if(d===`ArrowRight`||d===`ArrowLeft`||d===`Home`||d===`End`){t.preventDefault();let e=d===`Home`?0:d===`End`?i.length-1:(c+(d===`ArrowRight`?1:-1)+i.length)%i.length;r&&this._set(r,!1),m(i,e,`Navigation has no entry to focus.`).focus({preventScroll:!0})}else if(t.key===`ArrowDown`&&this._isTrigger(n)){t.preventDefault();let r=e(n.parentElement,`Navigation trigger has no entry.`);this._set(r,!0),m(this._links(r),0,`Navigation panel has no link to focus.`).focus({preventScroll:!0})}}_verticalKey(e,t){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;e.preventDefault();let n=d(this.querySelectorAll(`.wui-nav-menu-trigger, .wui-nav-menu-toplink, .wui-nav-menu-panel[data-open] .wui-nav-menu-link`)),r=n.indexOf(t);m(n,e.key===`Home`?0:e.key===`End`?n.length-1:(r+(e.key===`ArrowDown`?1:-1)+n.length)%n.length,`Navigation has no control to focus.`).focus({preventScroll:!0})}_linkKey(t,n){let r=e(n.closest(`.wui-nav-menu-item`),`Navigation link has no entry.`),i=this._links(r),a=i.indexOf(n);t.key===`ArrowDown`||t.key===`ArrowUp`?(t.preventDefault(),m(i,(a+(t.key===`ArrowDown`?1:-1)+i.length)%i.length,`Navigation panel has no link to focus.`).focus({preventScroll:!0})):t.key===`Home`?(t.preventDefault(),m(i,0,`Navigation panel has no link to focus.`).focus({preventScroll:!0})):t.key===`End`&&(t.preventDefault(),m(i,i.length-1,`Navigation panel has no link to focus.`).focus({preventScroll:!0}))}_teardown(){for(let e of this._items()){let t=p(e);if(!t)continue;let r=t.hasAttribute(l);t.removeAttribute(l),n(t),r&&this._settle(e)}this._media?.removeEventListener(`change`,this._onModeChange),this._media=null,document.removeEventListener(`pointerdown`,this._onOutsidePress,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`pointerdown`,this._onPointerDown,!0)}};export{h as t};
|
|
@@ -1 +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-
|
|
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-MOABXAAh.js";import{o as s,r as c,s as l}from"./notificationDays-CO6i0_h3.js";import{m as u}from"./wuiHttp-8CYWEbRz.js";import{r as d}from"./textStore-Cs1SGBoI.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./devWarn-DXdRWZs3.js";import{t}from"./elementBase-Cxeyx0tU.js";import{n,t as r}from"./rtl-g7G8Bsib.js";import{r as i}from"./textStore-
|
|
1
|
+
import{t as e}from"./devWarn-DXdRWZs3.js";import{t}from"./elementBase-Cxeyx0tU.js";import{n,t as r}from"./rtl-g7G8Bsib.js";import{r as i}from"./textStore-Cs1SGBoI.js";import{t as a}from"./orgTree.g-CIg75quV.js";var o=`li[data-wui-org-node]`,s=`:scope > .wui-org-tree-node`,c=`:scope > .wui-org-tree-node > .wui-org-tree-text > .wui-org-tree-name`,l=`:scope > .wui-org-tree-children`,u=`:scope > .wui-org-tree-node > [data-wui-org-toggle]`,d=`[data-wui-org-toggle]`,f=`a, button, input, select, textarea`,p=`.wui-org-tree-overlay`,m=`[data-wui-org-search]`,h=`[data-wui-org-canvas]`,g=`[data-wui-org-live]`,_=`--wui-org-tree-print-scale`,v=718,y=1e3,b=150,x=()=>i(`orgTree`,a),S=e=>[...e.querySelectorAll(o)].filter(e=>e instanceof HTMLElement),C=e=>e.querySelector(c)?.textContent?.trim()??``,w=e=>e.getAttribute(`data-wui-org-node`),T=e=>e.getAttribute(`aria-expanded`)===`true`,E=class extends t{static get observedAttributes(){return[`selected`,`selectable`,`expand-label`,`collapse-label`,`search-results-text`,`search-empty-text`]}constructor(){super(),this._query=``,this._snapshot=null,this._observer=null,this._announceTimer=void 0,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>this._handleClick(e),this._onFocusIn=e=>this._handleFocusIn(e),this._onInput=e=>this._handleInput(e),this._onBeforePrint=()=>this._scaleForPrint(),this._onAfterPrint=()=>this.style.removeProperty(_)}connectedCallback(){this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`input`,this._onInput),window.addEventListener(`beforeprint`,this._onBeforePrint),window.addEventListener(`afterprint`,this._onAfterPrint);let t=this.querySelector(h);t?(this._observer=new MutationObserver(()=>{this._query&&this._applySearch(this._query)}),this._observer.observe(t,{childList:!0,subtree:!0})):e(`[@webority/ui-elements] <wui-org-tree> has no [data-wui-org-canvas]; render the tree markup inside it.`)}disconnectedCallback(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`input`,this._onInput),window.removeEventListener(`beforeprint`,this._onBeforePrint),window.removeEventListener(`afterprint`,this._onAfterPrint),this._observer?.disconnect(),this._observer=null,clearTimeout(this._announceTimer)}attributeChangedCallback(e){e===`selected`||e===`selectable`?this._applySelected():(e===`expand-label`||e===`collapse-label`)&&this._syncToggles()}get selected(){return this.getAttribute(`selected`)}set selected(e){e==null?this.removeAttribute(`selected`):this.setAttribute(`selected`,String(e))}get selectable(){return this.hasAttribute(`selectable`)}set selectable(e){this.toggleAttribute(`selectable`,!!e)}_items(){return S(this)}_hasChildren(e){return!!e.querySelector(l)}_isVisible(e){for(let t=e;t&&t!==this;t=t.parentElement)if(t.hasAttribute(`hidden`))return!1;return!0}_visibleItems(){return this._items().filter(e=>this._isVisible(e))}_parentItem(e){let t=e.parentElement?.closest(o);return t instanceof HTMLElement&&this.contains(t)?t:null}_visibleChildren(e){let t=e.querySelector(l);return t?[...t.children].filter(e=>e.matches(o)&&this._isVisible(e)):[]}_isVisibleItem(e){return e instanceof HTMLElement&&e.matches(o)&&this._isVisible(e)}_siblingItem(e,t){let n=e[t];for(;n&&!this._isVisibleItem(n);)n=n[t];return this._isVisibleItem(n)?n:null}_setRoving(e){for(let t of this._items())t.setAttribute(`tabindex`,t===e?`0`:`-1`)}_focusItem(e){e&&(this._setRoving(e),e.focus())}_toggleLabel(e,t){return(t?this.getAttribute(`collapse-label`)??x().collapseLabel:this.getAttribute(`expand-label`)??x().expandLabel).split(`{name}`).join(C(e))}_setExpanded(e,t){let n=e.querySelector(l);n instanceof HTMLElement&&(e.setAttribute(`aria-expanded`,String(t)),n.hidden=!t,e.querySelector(u)?.setAttribute(`aria-label`,this._toggleLabel(e,t)),!t&&n.contains(document.activeElement)&&this._focusItem(e))}_toggle(e){this._setExpanded(e,!T(e))}_syncToggles(){for(let e of this._items())this._hasChildren(e)&&this._setExpanded(e,T(e))}_applySelected(){for(let e of this._items())this.selectable?e.setAttribute(`aria-selected`,String(w(e)===this.selected)):e.removeAttribute(`aria-selected`)}_select(e){this.selectable&&(this.selected=w(e),this.dispatchEvent(new CustomEvent(`wui-org-tree:select`,{detail:{id:this.selected},bubbles:!0,composed:!0})))}_activate(e){this.selectable?this._select(e):this._hasChildren(e)&&this._toggle(e)}_handleFocusIn(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(o);n instanceof HTMLElement&&this.contains(n)&&this._setRoving(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(o);n instanceof HTMLElement&&this.contains(n)&&(this._setRoving(n),t.closest(d)?this._hasChildren(n)&&this._toggle(n):n.querySelector(s)?.contains(t)&&(t.closest(f)?.closest(p)||this._select(n)))}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=e.target;if(t instanceof HTMLElement&&t.matches(o)&&this.contains(t))switch(n(e.key,r(this))){case`ArrowDown`:if(e.preventDefault(),!this._hasChildren(t))return;T(t)||this._setExpanded(t,!0),this._focusItem(this._visibleChildren(t)[0]);return;case`ArrowUp`:e.preventDefault(),this._focusItem(this._parentItem(t));return;case`ArrowRight`:e.preventDefault(),this._focusItem(this._siblingItem(t,`nextElementSibling`));return;case`ArrowLeft`:e.preventDefault(),this._focusItem(this._siblingItem(t,`previousElementSibling`));return;case`Home`:e.preventDefault(),this._focusItem(this._visibleItems()[0]);return;case`End`:{e.preventDefault();let t=this._visibleItems();this._focusItem(t[t.length-1]);return}case`+`:case`=`:if(!this._hasChildren(t))return;e.preventDefault(),this._setExpanded(t,!0);return;case`-`:if(!this._hasChildren(t))return;e.preventDefault(),this._setExpanded(t,!1);return;case`Enter`:case` `:e.preventDefault(),this._activate(t);return}}_handleInput(e){let t=e.target;t instanceof HTMLInputElement&&t.matches(m)&&this._search(t.value.trim().toLowerCase())}_search(e){clearTimeout(this._announceTimer),e?(this._snapshot||=this._captureExpanded(),this._query=e,this._applySearch(e),this._announceTimer=window.setTimeout(()=>this._announce(this._resultText()),b)):(this._snapshot&&this._restore(this._snapshot),this._snapshot=null,this._query=``,this._announce(``))}_captureExpanded(){return new Map(this._items().filter(e=>this._hasChildren(e)).map(e=>[w(e),T(e)]))}_restore(e){for(let t of this._items()){t.hidden=!1,t.classList.remove(`wui-org-tree-match`);let n=w(t);e.has(n)&&this._setExpanded(t,e.get(n)??!1)}}_applySearch(e){let t=this._items(),n=new Set(t.filter(t=>C(t).toLowerCase().includes(e))),r=new Set(n);for(let e of n)for(let t=this._parentItem(e);t;t=this._parentItem(t))r.add(t),T(t)||this._setExpanded(t,!0);for(let e of t)e.classList.toggle(`wui-org-tree-match`,n.has(e)),e.hidden=!r.has(e);let i=t.filter(e=>r.has(e)),a=i[0];a&&!i.some(e=>e.getAttribute(`tabindex`)===`0`)&&this._setRoving(a)}_resultText(){let e=this._items().filter(e=>e.classList.contains(`wui-org-tree-match`)).length;return e===0?this.getAttribute(`search-empty-text`)??x().noResultsText:(this.getAttribute(`search-results-text`)??x().resultsText).split(`{count}`).join(String(e))}_announce(e){let t=this.querySelector(g);t&&(t.textContent=e)}_scaleForPrint(){let e=this.querySelector(h);if(!(e instanceof HTMLElement))return;let t=Math.min(1,v/e.scrollWidth,y/e.scrollHeight);this.style.setProperty(_,String(t))}};export{E as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./anchorOverlay-daGdh_91.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{r as i}from"./textStore-
|
|
1
|
+
import{n as e,r as t,t as n}from"./anchorOverlay-daGdh_91.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{r as i}from"./textStore-Cs1SGBoI.js";import{t as a}from"./overflow.g-BfcGEhwR.js";var o=`data-wui-overflow-hidden`,s=`[aria-selected="true"], .active`,c=`.chip-body, input, a[href], button:not(.chip-remove)`,l=()=>i(`overflow`,a),u=1,d=`data-wui-overflow-menu`,f=`[aria-haspopup], [data-wui-dropdown-trigger]`,p=0,m=e=>Number.parseFloat(e)||0,h=e=>e.nodeType===1,g=e=>{let t=e.getAttribute(`data-overflow-label`);if(t)return t;let n=[],r=e=>{for(let t of e.childNodes)if(t.nodeType===3){let e=t.textContent?.trim();e&&n.push(e)}else h(t)&&!t.matches(`svg, img, [aria-hidden='true'], [data-wui-dropdown-menu]`)&&r(t)};if(r(e),n.length)return n.join(` `);let i=_(e)??e;return i.getAttribute(`aria-label`)||e.getAttribute(`aria-label`)||i.title||e.title},_=e=>{if(e.matches(`button, a[href], label, input`))return e;let t=e.querySelector(c);return t instanceof HTMLElement?t:null},v=e=>{let t=_(e);return t?.matches(f)?t:null},y=class extends r{constructor(){super(),this._hiddenKey=``,this._ro=null,this._mo=null,this._observedList=null,this._doc=null,this._onDocDown=e=>{!this._menu.hidden&&!e.composedPath().includes(this)&&this._close(!1)}}connectedCallback(){this.classList.add(`wui-overflow`),this._build(),this._doc=this.ownerDocument,this._doc.addEventListener(`pointerdown`,this._onDocDown,!0),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this.layout()),this._ro.observe(this)),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(()=>this.layout()),this._watch()),this.layout()}disconnectedCallback(){this._ro?.disconnect(),this._mo?.disconnect(),this._ro=null,this._mo=null,this._observedList=null,this._doc?.removeEventListener(`pointerdown`,this._onDocDown,!0),this._doc=null,t(this)}static get observedAttributes(){return[`label`]}attributeChangedCallback(){let e=this._more?.firstChild;e&&(e.textContent=this._label())}_label(){return this.getAttribute(`label`)||l().label}_list(){let e=this.querySelector(`[data-wui-overflow-list]`);return e instanceof HTMLElement?e:null}_items(e){return[...e.children].filter(e=>!e.hasAttribute(`data-wui-overflow-skip`))}_build(){if(this._more)return;let e=`wui-overflow-menu-${++p}`,t=this.ownerDocument.createElement(`button`);t.type=`button`,t.className=`wui-overflow-more`,t.hidden=!0,t.setAttribute(`aria-haspopup`,`menu`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,e),t.append(this._label());let n=this.ownerDocument.createElement(`div`);n.className=`wui-overflow-menu`,n.id=e,n.setAttribute(`role`,`menu`),n.hidden=!0,this.append(t,n),this._more=t,this._menu=n,t.addEventListener(`click`,()=>this._menu.hidden?this._open(!1):this._close(!0)),t.addEventListener(`keydown`,e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),this._open(!0))}),n.addEventListener(`keydown`,e=>this._onMenuKey(e))}_watch(){let e=this._list();this._mo&&e!==this._observedList&&(this._mo.disconnect(),this._observedList=e,e&&this._mo.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`class`,`aria-selected`,`disabled`,`aria-disabled`,`data-overflow-label`]}))}layout(){let e=this._list();if(this._watch(),!e||!this._more)return;let t=this._items(e);for(let e of t)e.removeAttribute(o),e.removeAttribute(d);this._more.hidden=!0;let n=this.clientWidth,r=[];if(t.length&&n<=0&&this.getClientRects().length>0)r=t;else if(n>0&&t.length){let i=getComputedStyle(e),a=m(i.columnGap),o=m(i.paddingLeft)+m(i.paddingRight)+m(i.borderLeftWidth)+m(i.borderRightWidth),c=t.map(e=>e.offsetWidth);if(c.reduce((e,t)=>e+t,0)+a*(t.length-1)>n-o+u){this._more.hidden=!1;let e=n-o-this._more.offsetWidth-m(getComputedStyle(this).columnGap),i=this.hasAttribute(`keep`)?this.getAttribute(`keep`):s,l=/* @__PURE__ */ new Set,u=0,d=0,f=i?t.filter(e=>e.matches(i)):[];for(let n of f){let r=u+(c[t.indexOf(n)]??0)+(d?a:0);r>e||(l.add(n),u=r,d+=1)}for(let n=0;n<t.length;n+=1){let r=t[n];if(!r||l.has(r))continue;let i=u+(c[n]??0)+(d?a:0);if(i>e)break;l.add(r),u=i,d+=1}r=t.filter(e=>!l.has(e))}}for(let e of r)e.setAttribute(o,``),v(e)&&e.setAttribute(d,``);this._more.hidden=r.length===0,r.length?this._menu.hidden||this._fill(r):this._close(!1);let i=r.map(e=>t.indexOf(e)).join(`,`);i!==this._hiddenKey&&(this._hiddenKey=i,this.dispatchEvent(new CustomEvent(`wui-overflow-change`,{bubbles:!0,detail:{hidden:r.length}})))}_hiddenItems(){let e=this._list();return e?this._items(e).filter(e=>e.hasAttribute(o)):[]}_fill(e){this._menu.replaceChildren();for(let t of e){let e=this.ownerDocument.createElement(`button`);e.type=`button`,e.className=`wui-overflow-item`,e.tabIndex=-1;let n=t.querySelector(`input[type=checkbox], input[type=radio]`);n instanceof HTMLInputElement?(e.setAttribute(`role`,n.type===`radio`?`menuitemradio`:`menuitemcheckbox`),e.setAttribute(`aria-checked`,String(n.checked))):e.setAttribute(`role`,`menuitem`);let r=_(t),i=!r||`disabled`in r&&r.disabled||r.getAttribute(`aria-disabled`)===`true`||t.matches(`.disabled, [aria-disabled='true']`);i&&e.setAttribute(`aria-disabled`,`true`),e.textContent=g(t),e.addEventListener(`click`,()=>{i||r&&this._choose(t,r)}),this._menu.append(e)}}_choose(e,t){this._close(!1),t.click(),this.layout();let n=v(e)?.isConnected?e.querySelector(`.dropdown-item:not([aria-disabled='true'])`):null;if(n){n.focus();return}let r=!e.hasAttribute(o)&&e.matches(`button, a[href]`)?e:this._more;r.hidden||r.focus()}_open(t){let r=this._hiddenItems();if(!r.length)return;this._fill(r),this._menu.hidden=!1,this._more.setAttribute(`aria-expanded`,`true`);let i=()=>n(this._more,this._menu);if(i(),e(this,i),t){let e=this._menu.firstElementChild;e instanceof HTMLElement&&e.focus()}}_close(e){this._menu&&!this._menu.hidden&&(this._menu.hidden=!0,this._more.setAttribute(`aria-expanded`,`false`),t(this),e&&this._more.focus())}_onMenuKey(e){let t=[...this._menu.children].filter(e=>e instanceof HTMLElement),n=this.ownerDocument.activeElement,r=n instanceof HTMLElement?t.indexOf(n):-1,i=null;if(e.key===`ArrowDown`)i=t[(r+1)%t.length];else if(e.key===`ArrowUp`)i=t[(r-1+t.length)%t.length];else if(e.key===`Home`)i=t[0];else if(e.key===`End`)i=t[t.length-1];else if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close(!0);return}else if(e.key===`Tab`){this._close(!1);return}else return;e.preventDefault(),i?.focus()}};export{y as t};
|