@webority/ui-elements 0.181.0 → 0.182.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/WuiContextMenu-oKlQvt3V.js +1 -0
- package/dist/elements/context-menu.js +1 -1
- package/dist/ui-chart.global.js +9 -9
- package/dist/ui-chart.js +2 -2
- package/dist/ui-elements/calendar-views.global.js +1 -1
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +1 -1
- package/dist/ui-elements/comment-thread.global.js +1 -1
- package/dist/ui-elements/consent-banner.global.js +1 -1
- package/dist/ui-elements/context-menu.global.js +1 -1
- package/dist/ui-elements/dashboard-grid.global.js +1 -1
- package/dist/ui-elements/data-table.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +1 -1
- package/dist/ui-elements/date-time.global.js +1 -1
- package/dist/ui-elements/datepicker.global.js +1 -1
- package/dist/ui-elements/dock.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/dropdown.global.js +1 -1
- package/dist/ui-elements/entry-grid.global.js +1 -1
- package/dist/ui-elements/gantt.global.js +1 -1
- package/dist/ui-elements/glyphs.global.js +1 -1
- package/dist/ui-elements/hover-card.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -1
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lead-popup.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +1 -1
- package/dist/ui-elements/mini-calendar.global.js +1 -1
- package/dist/ui-elements/navigation-menu.global.js +1 -1
- package/dist/ui-elements/notification-center.global.js +1 -1
- package/dist/ui-elements/offline-banner.global.js +1 -1
- package/dist/ui-elements/onboarding-checklist.global.js +1 -1
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/otp.global.js +1 -1
- package/dist/ui-elements/overflow.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/popover.global.js +1 -1
- package/dist/ui-elements/rating.global.js +1 -1
- package/dist/ui-elements/record-pager.global.js +1 -1
- package/dist/ui-elements/relative-time.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +1 -1
- package/dist/ui-elements/select-recents.global.js +1 -1
- package/dist/ui-elements/select-search.global.js +1 -1
- package/dist/ui-elements/select-window.global.js +1 -1
- package/dist/ui-elements/server.global.js +1 -1
- package/dist/ui-elements/shell.global.js +1 -1
- package/dist/ui-elements/shortcuts.global.js +1 -1
- package/dist/ui-elements/show-more.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/table-export.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree-picker.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/truncate.global.js +1 -1
- package/dist/ui-elements/whats-new.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +1 -1
- package/dist/ui-elements.js +1 -1
- package/package.json +5 -5
- package/types/WuiContextMenu.d.ts +8 -0
- package/types/chartSpec.d.ts +5 -0
- package/dist/WuiContextMenu-DEWYYFRG.js +0 -1
package/dist/ui-elements.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./elementBase-Cxeyx0tU.js";import{n as ee}from"./filterPopover-DskHFNLi.js";import{t}from"./kanban-Dayig7ic.js";import{n}from"./statusIcons-Cd3GJcBR.js";import{t as r}from"./WuiCalendarViews-Dg9yRY1I.js";import{t as i}from"./WuiCarousel-B0yPDH5I.js";import{t as te}from"./WuiCodeBlock-BWYZ1S70.js";import{t as a}from"./WuiCommandPalette-CpmlKjzH.js";import{t as o}from"./WuiCommentThread-Cp7AVHvt.js";import{t as s}from"./WuiConsentBanner-nTua-kEd.js";import{t as c}from"./WuiContextMenu-
|
|
1
|
+
import{n as e}from"./elementBase-Cxeyx0tU.js";import{n as ee}from"./filterPopover-DskHFNLi.js";import{t}from"./kanban-Dayig7ic.js";import{n}from"./statusIcons-Cd3GJcBR.js";import{t as r}from"./WuiCalendarViews-Dg9yRY1I.js";import{t as i}from"./WuiCarousel-B0yPDH5I.js";import{t as te}from"./WuiCodeBlock-BWYZ1S70.js";import{t as a}from"./WuiCommandPalette-CpmlKjzH.js";import{t as o}from"./WuiCommentThread-Cp7AVHvt.js";import{t as s}from"./WuiConsentBanner-nTua-kEd.js";import{t as c}from"./WuiContextMenu-oKlQvt3V.js";import{r as l}from"./WuiDashboardGrid-DFpX8Vx0.js";import{t as u}from"./WuiDataTable-CSgcwxU5.js";import{t as d}from"./WuiDatePicker-CRqjwyf2.js";import{t as f}from"./WuiDateRange-BBm_Q69p.js";import{t as p}from"./WuiDateTime-Vimu6grS.js";import{t as m}from"./WuiDock-2LGlbEFx.js";import{t as h}from"./WuiDrawer-BsY0fs_u.js";import{t as g}from"./WuiDropdown-6g074v1T.js";import{t as _}from"./WuiEntryGrid-Z69-1YBh.js";import{t as v}from"./WuiGantt-DvmVKJX2.js";import{t as y}from"./WuiHoverCard-DhJcIIM1.js";import{t as b}from"./WuiImageCrop-UakcSM2k.js";import{t as x}from"./WuiInlineEdit-JT83k3Nk.js";import{t as S}from"./WuiLeadPopup-DaYZ2zCJ.js";import{t as C}from"./WuiLightbox-DpHJAMO3.js";import{t as w}from"./WuiMarkdown-DRtGPxQX.js";import{r as T}from"./WuiMentionInput-DPCCSQRZ.js";import{t as E}from"./WuiMiniCalendar-BhUTIGwe.js";import{t as D}from"./WuiModal-DQbVJGUo.js";import{t as O}from"./WuiNavigationMenu-KdW7yuLn.js";import{t as k}from"./WuiNotificationCenter-D5bBM8Lp.js";import{t as A}from"./WuiOfflineBanner-DGTFCtyM.js";import{t as j}from"./WuiOnboardingChecklist-C-nllg2h.js";import{t as M}from"./WuiOrgTree-DWSk_LHd.js";import{t as N}from"./WuiOtp-Cc0formv.js";import{t as P}from"./WuiOverflow-fZKqdsr-.js";import{t as F}from"./WuiPhone-B5ZLabTY.js";import{t as I}from"./WuiPopover-BvWKRNQY.js";import{t as L}from"./WuiRating-DIQfif9x.js";import{t as R}from"./WuiRecordPager-BXoe4KfU.js";import{t as z}from"./WuiRelativeTime-CSg9vzfk.js";import{t as B}from"./WuiSavedViews-CH7IvwgZ.js";import{t as V}from"./WuiSelect-DIW_WXH7.js";import{t as H}from"./WuiShortcuts-CRCctX82.js";import{t as U}from"./WuiShowMore-BoYCrYYf.js";import{t as W}from"./WuiSlider-CK7_l_R5.js";import{t as G}from"./WuiSortable-x8Mg0tOv.js";import{t as K}from"./WuiTimePicker-BKFPf8Fn.js";import{t as q}from"./WuiTour-BgpMa8J5.js";import{t as J}from"./WuiTree-Db83Uztv.js";import{t as Y}from"./WuiTreePicker-DLddmEgG.js";import{t as X}from"./WuiTruncate-BB4i8wHE.js";import{n as Z,t as ne}from"./WuiWhatsNew-Dm4Yl68x.js";import{n as Q,t as $}from"./WuiWizardStep-BBkw94dD.js";import{c as re,f as ie,l as ae,m as oe,p as se,s as ce,u as le}from"./formatters-DTW53DjY.js";import{_ as ue,r as de}from"./themeTransition-C5nAlClG.js";import{t as fe}from"./drawerDiscard-D_LMpaFv.js";import{n as pe}from"./shortcutKeys-BMTWgV2g.js";function me(){ee(),e(`wui-select`,V),e(`wui-saved-views`,B),e(`wui-phone`,F),e(`wui-datepicker`,d),e(`wui-mini-calendar`,E),e(`wui-date-range`,f),e(`wui-date-time`,p),e(`wui-dock`,m),e(`wui-image-crop`,b),e(`wui-kanban`,t),e(`wui-dashboard-grid`,l),e(`wui-lead-popup`,S),e(`wui-inline-edit`,x),e(`wui-consent-banner`,s),e(`wui-slider`,W),e(`wui-sortable`,G),e(`wui-timepicker`,K),e(`wui-tour`,q),e(`wui-tree`,J),e(`wui-tree-picker`,Y),e(`wui-org-tree`,M),e(`wui-command-palette`,a),e(`wui-context-menu`,c),e(`wui-otp`,N),e(`wui-status-icon`,n),e(`wui-shortcuts`,H),e(`wui-record-pager`,R),e(`wui-carousel`,i),e(`wui-code-block`,te),e(`wui-markdown`,w),e(`wui-modal`,D),e(`wui-data-table`,u),e(`wui-drawer`,h),e(`wui-dropdown`,g),e(`wui-entry-grid`,_),e(`wui-gantt`,v),e(`wui-hover-card`,y),e(`wui-lightbox`,C),e(`wui-navigation-menu`,O),e(`wui-notification-center`,k),e(`wui-onboarding-checklist`,j),e(`wui-overflow`,P),e(`wui-popover`,I),e(`wui-rating`,L),e(`wui-relative-time`,z),e(`wui-show-more`,U),e(`wui-calendar-views`,r),e(`wui-truncate`,X),e(`wui-whats-new`,Z),e(`wui-offline-banner`,A),e(`wui-mention-input`,T),e(`wui-comment-thread`,o),e(`wui-wizard-step`,$),e(`wui-wizard`,Q)}me();export{fe as DISCARD_EVENT,ue as ROW_DROP_EVENT,pe as SHORTCUT_EVENT,de as THEME_CHANGE_EVENT,ne as WHATS_NEW_READ_EVENT,r as WuiCalendarViews,i as WuiCarousel,te as WuiCodeBlock,a as WuiCommandPalette,o as WuiCommentThread,s as WuiConsentBanner,c as WuiContextMenu,l as WuiDashboardGrid,u as WuiDataTable,d as WuiDatePicker,f as WuiDateRange,p as WuiDateTime,m as WuiDock,h as WuiDrawer,g as WuiDropdown,_ as WuiEntryGrid,v as WuiGantt,y as WuiHoverCard,b as WuiImageCrop,x as WuiInlineEdit,t as WuiKanban,S as WuiLeadPopup,C as WuiLightbox,w as WuiMarkdown,T as WuiMentionInput,E as WuiMiniCalendar,D as WuiModal,O as WuiNavigationMenu,k as WuiNotificationCenter,A as WuiOfflineBanner,j as WuiOnboardingChecklist,M as WuiOrgTree,N as WuiOtp,P as WuiOverflow,F as WuiPhone,I as WuiPopover,L as WuiRating,R as WuiRecordPager,z as WuiRelativeTime,B as WuiSavedViews,V as WuiSelect,H as WuiShortcuts,U as WuiShowMore,W as WuiSlider,G as WuiSortable,n as WuiStatusIcon,K as WuiTimePicker,q as WuiTour,J as WuiTree,Y as WuiTreePicker,X as WuiTruncate,Z as WuiWhatsNew,Q as WuiWizard,$ as WuiWizardStep,me as defineWeborityElements,ce as formatCompact,re as formatCurrency,ae as formatDate,le as formatDateTime,ie as formatNumber,se as formatPercent,oe as formatValue};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/ui-elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.182.0",
|
|
4
4
|
"description": "Webority framework-agnostic UI custom elements (<wui-*>): the single implementation of the interactive components, styled by @webority/theme. Used natively in Razor and wrapped by @webority/ui-react.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -295,10 +295,10 @@
|
|
|
295
295
|
"@tiptap/starter-kit": "3.31.4",
|
|
296
296
|
"@types/node": "25.6.0",
|
|
297
297
|
"@vitest/coverage-v8": "5.1.0",
|
|
298
|
-
"@webority/biome-config": "0.
|
|
299
|
-
"@webority/markdown-core": "0.
|
|
300
|
-
"@webority/theme": "0.
|
|
301
|
-
"@webority/web-core": "0.
|
|
298
|
+
"@webority/biome-config": "0.182.0",
|
|
299
|
+
"@webority/markdown-core": "0.182.0",
|
|
300
|
+
"@webority/theme": "0.182.0",
|
|
301
|
+
"@webority/web-core": "0.182.0",
|
|
302
302
|
"echarts": "6.1.0",
|
|
303
303
|
"jsdom": "30.1.1",
|
|
304
304
|
"libphonenumber-js": "^1.13.9",
|
|
@@ -49,6 +49,11 @@
|
|
|
49
49
|
* `region` is the matched target; `origin` is the element the user acted on inside it.
|
|
50
50
|
*/
|
|
51
51
|
import { ElementBase } from "./elementBase.ts";
|
|
52
|
+
type ScrollMark = {
|
|
53
|
+
x: number;
|
|
54
|
+
y: number;
|
|
55
|
+
scrollers: Map<Element, readonly [number, number]>;
|
|
56
|
+
};
|
|
52
57
|
export declare class WuiContextMenu extends ElementBase {
|
|
53
58
|
_region: Element | null;
|
|
54
59
|
_origin: Element | null;
|
|
@@ -57,8 +62,10 @@ export declare class WuiContextMenu extends ElementBase {
|
|
|
57
62
|
x: number;
|
|
58
63
|
y: number;
|
|
59
64
|
region: Element;
|
|
65
|
+
mark: ScrollMark;
|
|
60
66
|
timer: ReturnType<typeof setTimeout>;
|
|
61
67
|
} | null;
|
|
68
|
+
_scrollMark: ScrollMark | null;
|
|
62
69
|
_swallowClick: boolean;
|
|
63
70
|
_unbindKeys: (() => void) | null;
|
|
64
71
|
_anchor: HTMLElement | null;
|
|
@@ -141,3 +148,4 @@ export declare class WuiContextMenu extends ElementBase {
|
|
|
141
148
|
_handleClick(e: MouseEvent): void;
|
|
142
149
|
_teardown(): void;
|
|
143
150
|
}
|
|
151
|
+
export {};
|
package/types/chartSpec.d.ts
CHANGED
|
@@ -145,6 +145,8 @@ export type ChartSpec = {
|
|
|
145
145
|
renderer?: Renderer;
|
|
146
146
|
/** IANA zone dates are read and shown in (Asia/Kolkata when omitted). */
|
|
147
147
|
timeZone?: string;
|
|
148
|
+
/** Month 1 to 12 a year starts in for year labels; calendar years when omitted. */
|
|
149
|
+
financialYearStart?: number;
|
|
148
150
|
};
|
|
149
151
|
/** What normalizeSpec accepts: the valid shape, with every optional key a caller may pass. Anything else is warned and ignored. */
|
|
150
152
|
export type ChartInput = ChartSpec;
|
|
@@ -192,6 +194,7 @@ export type NormalizedSpec = {
|
|
|
192
194
|
loadingText: string;
|
|
193
195
|
renderer: Renderer;
|
|
194
196
|
timeZone: string;
|
|
197
|
+
financialYearStart: number;
|
|
195
198
|
otherIndex: number;
|
|
196
199
|
};
|
|
197
200
|
export type NormalizeResult = {
|
|
@@ -279,6 +282,8 @@ export declare function normalizeSpec(raw: unknown): NormalizeResult;
|
|
|
279
282
|
export declare function valueAt(spec: NormalizedSpec, seriesKey: string, index: number): number | null;
|
|
280
283
|
/** Whether any series has a number to plot: a ready spec without one is shown as empty. A gauge draws a missing value as "-". */
|
|
281
284
|
export declare function hasValues(spec: NormalizedSpec): boolean;
|
|
285
|
+
/** The year text of an instant in a zone: the calendar year, or with a start month the financial year ("FY 2026-27"). */
|
|
286
|
+
export declare function yearLabel(instant: number, timeZone: string, financialYearStart: number): string;
|
|
282
287
|
/** The x value of a row as text: a category as given (or through x.format), a time in the zone of the chart. */
|
|
283
288
|
export declare function xText(spec: NormalizedSpec, index: number): string;
|
|
284
289
|
/** Epoch ms of a time row's x value (NaN when it cannot be read). */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t}from"./imeSafeEnter-DeO_3lXy.js";import{t as n}from"./isDrawn-BbF4phmB.js";import{t as r}from"./menuKeyNav-BCHtqitp.js";import{a as i,l as a,s as o}from"./nativeOverlay-BHD2QV02.js";import{n as s,t as c}from"./rtl-g7G8Bsib.js";var l=`[role="menuitem"]`,u=`.wui-context-menu-sub`,d=`input.wui-context-menu-search`,f=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,p=500,m=10,h=400,g=null,_=null,v=0;function y(e,t,n){let r=document.createElement(`span`);return r.setAttribute(`aria-hidden`,`true`),r.style.cssText=n?`position:absolute;left:${e+window.scrollX}px;top:${t+window.scrollY}px;width:0;height:0;`:`position:fixed;left:${e}px;top:${t}px;width:0;height:0;`,document.body.append(r),r}var b=/* @__PURE__ */ new WeakMap;function x(e,t,n){let r=b.get(e);if(r){if(r.region===t||t.contains(r.region))return!1;r.cancel()}return b.set(e,{region:t,cancel:n}),!0}var S=e=>e instanceof Element?e:e instanceof Node?e.parentElement:null,C=e=>`focus`in e,w=e=>[...e.childNodes].filter(e=>e.nodeType===Node.TEXT_NODE||e instanceof Element&&!e.matches(`.wui-context-menu-hint, .wui-context-menu-tick`)).map(e=>e.textContent).join(``),T=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),E=e=>[...e.children].filter(e=>e instanceof HTMLElement),D=(e,t)=>{let n=e.children[t];if(!(n instanceof HTMLElement))throw Error(`a submenu holds its opener and then its panel`);return n},O=e=>D(e,0),k=e=>D(e,1),A=(e,t)=>{let n=e?.closest(t);return n instanceof HTMLElement?n:null};function j(e,t){return!(e instanceof Node)||e.contains(t)}var M=class extends e{_region;_origin;_returnFocus;_press;_swallowClick;_unbindKeys;_anchor;_closingByKey;_onContextMenu;_onContextMenuCapture;_onDocKeyDown;_onDocClick;_onPointerDown;_onPressMove;_onPressEnd;_onClickCapture;_onKeyDown;_onClick;_onInput;_onMouseMove;_onDismiss;_onPointerDownCapture;static get observedAttributes(){return[`disabled`,`open`]}constructor(){super(),this._region=null,this._origin=null,this._returnFocus=null,this._press=null,this._swallowClick=!1,this._unbindKeys=null,this._anchor=null,this._closingByKey=!1,this._onContextMenu=e=>this._handleContextMenu(e),this._onContextMenuCapture=e=>{this.isOpen&&!this._inPanel(e.target)&&!this._isKeyEcho()&&this.close()},this._onDocKeyDown=e=>this._handleDocKeyDown(e),this._onDocClick=e=>this._handleDocClick(e),this._onPointerDown=e=>this._handlePointerDown(e),this._onPressMove=e=>{this._press&&Math.hypot(e.clientX-this._press.x,e.clientY-this._press.y)>m&&this._cancelPress()},this._onPressEnd=e=>{(e.type!==`scroll`||!this._press||j(e.target,this._press.region))&&this._cancelPress()},this._onClickCapture=e=>{if(this._swallowClick&&this._region){if(!(e.target instanceof Node))throw Error(`a click target is always a node`);this._region.contains(e.target)&&(this._swallowClick=!1,e.preventDefault(),e.stopImmediatePropagation())}},this._onKeyDown=e=>{if(this.isOpen&&this._inPanel(e.target)){if(e.key===`Escape`){if(e.stopPropagation(),this.hasAttribute(`open`)&&A(S(e.target),`[role="menu"]`)===this._panel()){e.preventDefault(),this.close(!0);return}this._closingByKey=!0}this._handleMenuKey(e)}},this._onClick=e=>this._handleClick(e),this._onInput=e=>this._handleInput(e),this._onMouseMove=e=>{let t=A(S(e.target),l);t&&this._inPanel(t)&&!this._isDisabled(t)&&t!==document.activeElement&&t.focus({preventScroll:!0})},this._onDismiss=e=>{this.hasAttribute(`open`)||(e.type!==`scroll`||!this._inPanel(e.target)&&j(e.target,this._region??this))&&this.close()},this._onPointerDownCapture=()=>{this._swallowClick=!1}}connectedCallback(){this._teardown(),document.addEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.addEventListener(`contextmenu`,this._onContextMenu),document.addEventListener(`keydown`,this._onDocKeyDown),document.addEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.addEventListener(`pointerdown`,this._onPointerDown),document.addEventListener(`click`,this._onClickCapture,!0),document.addEventListener(`click`,this._onDocClick),window.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick),this.addEventListener(`input`,this._onInput),this.addEventListener(`mousemove`,this._onMouseMove),this._syncOpen()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){e===`open`?this.isConnected&&this._syncOpen():this.disabled&&this.close()}get target(){return this.getAttribute(`target`)}set target(e){e==null||e===``?this.removeAttribute(`target`):this.setAttribute(`target`,String(e))}get disabled(){return this.hasAttribute(`disabled`)}set disabled(e){this.toggleAttribute(`disabled`,!!e)}get isOpen(){let e=this._panel();return!!e&&o(e)}open(e,t,{region:n=this,origin:i=n,trigger:s=null,keyboard:c=!1}={}){let l=this._panel();if(!l)return!1;let u=new CustomEvent(`wui-context-menu:beforeopen`,{bubbles:!0,cancelable:!0,detail:{region:n,origin:i,trigger:s}});if(this.dispatchEvent(u),u.defaultPrevented)return!1;if(this._decorate(l),g&&g!==this&&g.close(!0),!this.isOpen){let e=document.activeElement;this._returnFocus=e&&e!==document.body&&!this._inPanel(e)&&C(e)?e:null}this._region=n,this._origin=i,_=null,g=this,this._unbindKeys?.(),this._unbindKeys=r(l,{items:()=>this._menuRows()}),this._anchor?.remove();let d=this.hasAttribute(`open`);return this._anchor=y(e,t,d),a(this._anchor,l,{mode:d?`manual`:`auto`,keepOffscreen:d,clampHeight:!0,onClosed:()=>this._onPanelClosed()}),window.addEventListener(`scroll`,this._onDismiss,!0),window.addEventListener(`resize`,this._onDismiss),window.addEventListener(`blur`,this._onDismiss),queueMicrotask(()=>{o(l)&&((c?this._rowsOf(l)[0]:null)??l).focus({preventScroll:!0})}),this.dispatchEvent(new CustomEvent(`wui-context-menu:open`,{bubbles:!0,detail:{region:n,origin:i,x:e,y:t}})),!0}_syncOpen(){if(!this.hasAttribute(`open`)){this.close(this._inPanel(document.activeElement));return}let e=this.target?document.querySelector(this.target):this,t=e&&this._regionRect(e);e&&t&&this.open(t.left,t.top,{region:e,origin:e})}_regionRect(e){if(e!==this)return e.getBoundingClientRect();let t=[...this.children].filter(e=>e!==this._panel()).map(e=>e.getBoundingClientRect());return t.length?{left:Math.min(...t.map(e=>e.left)),top:Math.min(...t.map(e=>e.top))}:null}close(e=!1){let t=this._panel();t&&o(t)&&(e&&(this._closingByKey=!0),i(t))}_finish(e){let t=this._panel();if(t)for(let e of T(t,u))this._setSub(e,!1);g===this&&(g=null),window.removeEventListener(`scroll`,this._onDismiss,!0),window.removeEventListener(`resize`,this._onDismiss),window.removeEventListener(`blur`,this._onDismiss),this._unbindKeys?.(),this._unbindKeys=null,this._anchor?.remove(),this._anchor=null;let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&n.focus({preventScroll:!0})}_onPanelClosed(){let e=this._panel();if(!e||o(e))return;let t=this._closingByKey;this._closingByKey=!1,this._finish(t)}_menuRows(){let e=S(document.activeElement);if(!e||e.matches(d))return[];let t=A(e,`[role="menu"]`);return t?this._rowsOf(t):[]}_panel(){return E(this).find(e=>e.getAttribute(`role`)===`menu`)??null}_inPanel(e){return e instanceof Node&&!!this._panel()?.contains(e)}_rowsOf(e){return e?T(e,l).filter(t=>t.closest(`[role="menu"]`)===e&&!this._isDisabled(t)&&n(t)):[]}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_regionFor(e){let t=S(e);if(!t||this.disabled||!this._panel()||this._inPanel(t)||t.closest(f))return null;let n=this.target;return n?t.closest(n):this.contains(t)?this:null}_triggerFor(e){let t=S(e),n=this.getAttribute(`trigger`);if(!t||!n||this._inPanel(t))return null;let r=A(t,n),i=r&&this._regionFor(r);return r&&i?{trigger:r,region:i}:null}_isKeyEcho(){return _?.menu===this&&this.isOpen&&performance.now()-_.at<h}_handleContextMenu(e){if(this._inPanel(e.target)){e.preventDefault();return}if(e.defaultPrevented&&!b.has(e))return;let t=this._regionFor(e.target);t&&(this._isKeyEcho()?e.preventDefault():e.shiftKey||x(e,t,()=>this.close(!0))&&this.open(e.clientX,e.clientY,{region:t,origin:S(e.target)})&&e.preventDefault())}_handleDocKeyDown(e){if(e.defaultPrevented&&!b.has(e))return;if(t(e)){let t=this._triggerFor(e.target);if(!t||!x(e,t.region,()=>this.close(!0)))return;e.preventDefault(),t.trigger.click();return}if(!(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey)||this._inPanel(e.target))return;let n=this._regionFor(e.target);if(!n||!x(e,n,()=>this.close(!0)))return;let r=S(e.target);if(!r)return;let i=r.getBoundingClientRect();this.open(i.left+Math.min(16,i.width/2),i.bottom,{region:n,origin:r,keyboard:!0})&&(e.preventDefault(),_={menu:this,at:performance.now()})}_handleDocClick(e){let t=this._triggerFor(e.target);if(!t||!x(e,t.region,()=>this.close(!0)))return;let n=t.trigger.getBoundingClientRect();this.open(n.left,n.bottom,{region:t.region,origin:t.trigger,trigger:t.trigger,keyboard:e.detail===0})}_handlePointerDown(e){if(e.pointerType!==`touch`)return;let t=this._regionFor(e.target);if(!t||!x(e,t,()=>this._cancelPress()))return;this._cancelPress();let{clientX:n,clientY:r}=e,i=S(e.target);this._press={x:n,y:r,region:t,timer:setTimeout(()=>{this._cancelPress(),this.open(n,r,{region:t,origin:i})&&(this._swallowClick=!0)},p)},document.addEventListener(`pointermove`,this._onPressMove,{passive:!0}),document.addEventListener(`pointerup`,this._onPressEnd),document.addEventListener(`pointercancel`,this._onPressEnd),window.addEventListener(`scroll`,this._onPressEnd,!0)}_cancelPress(){this._press&&(clearTimeout(this._press.timer),this._press=null,document.removeEventListener(`pointermove`,this._onPressMove),document.removeEventListener(`pointerup`,this._onPressEnd),document.removeEventListener(`pointercancel`,this._onPressEnd),window.removeEventListener(`scroll`,this._onPressEnd,!0))}_handleMenuKey(e){if(!this.isOpen)return;let n=S(e.target);if(!n)return;if(n.matches(d)){this._handleSearchKey(e,n);return}let r=A(n,`[role="menu"]`);if(!r)return;let i=A(n,l),a=r.matches(`.wui-context-menu-subpanel`)?r.parentElement:null,o=s(e.key,c(this));if(e.key===`Tab`)this.close(!0);else if(o===`ArrowRight`){let t=i&&this._subOf(i);if(!t)return;e.preventDefault(),this._openSub(t,!0)}else if(o===`ArrowLeft`){if(!a)return;e.preventDefault(),this._closeSubByKey(a)}else(t(e)||e.key===` `)&&(e.preventDefault(),i?.click())}_handleSearchKey(e,t){let n=A(t,u);if(!n)return;let r=this._rowsOf(k(n));e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closeSubByKey(n)):e.key===`ArrowDown`?(e.preventDefault(),r[0]?.focus({preventScroll:!0})):e.key===`ArrowUp`?(e.preventDefault(),r[r.length-1]?.focus({preventScroll:!0})):e.key===`Tab`&&this.close(!0)}_subOf(e){return e.hasAttribute(`aria-haspopup`)&&e.parentElement?.matches(u)?e.parentElement:null}_openSub(e,t){let n=e.parentElement;if(!n)throw Error(`a submenu is always inside its menu panel`);for(let t of E(n))t!==e&&t.matches(u)&&this._closeSub(t);this._setSub(e,!0);let r=k(e).querySelector(`:scope > ${d}`),i=e.hasAttribute(`data-searchable`)&&r instanceof HTMLInputElement?r:null;i?(i.value=``,this._filter(e,``),i.focus({preventScroll:!0})):t&&this._rowsOf(k(e))[0]?.focus({preventScroll:!0})}_closeSub(e){for(let t of T(k(e),u))this._setSub(t,!1);this._setSub(e,!1)}_closeSubByKey(e){this._closeSub(e),O(e).focus({preventScroll:!0})}_setSub(e,t){let n=k(e);t?(a(O(e),n,{mode:`auto`,beside:!0,onClosed:()=>this._onSubClosed(e)}),O(e).setAttribute(`aria-expanded`,String(o(n)))):o(n)?i(n):this._onSubClosed(e)}_onSubClosed(e){let t=k(e);if(o(t))return;let n=O(e);n.setAttribute(`aria-expanded`,`false`),t.removeAttribute(`data-side`);let r=this._closingByKey;this._closingByKey=!1,r&&n.focus({preventScroll:!0})}_filter(e,t){let n=t.trim().toLowerCase();for(let t of E(k(e)))t.tagName===`HR`?t.hidden=n!==``:t.matches(l)?t.hidden=n!==``&&!w(t).toLowerCase().includes(n):t.matches(u)&&(t.hidden=n!==``&&!w(O(t)).toLowerCase().includes(n))}_handleInput(e){let t=S(e.target)?.closest(d);if(!(t instanceof HTMLInputElement))return;let n=A(t,u);n?.hasAttribute(`data-searchable`)&&this._inPanel(n)&&this._filter(n,t.value)}_decorate(e){for(let t of T(e,l)){let e=t.getAttribute(`aria-checked`)===`true`,n=t.querySelector(`:scope > .wui-context-menu-tick`);if(e&&!n){let e=document.createElement(`span`);e.className=`wui-context-menu-tick`,e.setAttribute(`aria-hidden`,`true`),t.prepend(e)}else!e&&n&&n.remove();let r=t.querySelector(`:scope > .wui-context-menu-hint`),i=t.dataset.hint;if(i){let e=r??document.createElement(`span`);r||(e.className=`wui-context-menu-hint`,e.id=`wui-context-menu-hint-${++v}`,t.append(e)),e.textContent=i,t.setAttribute(`aria-describedby`,e.id)}else r&&(r.remove(),t.removeAttribute(`aria-describedby`))}}_handleClick(e){let t=A(S(e.target),l);if(!t||!this._inPanel(t))return;if(this._isDisabled(t)){e.preventDefault(),e.stopPropagation();return}let n=this._subOf(t);n?(e.preventDefault(),this._openSub(n,e.detail===0)):(this.close(!0),this.dispatchEvent(new CustomEvent(`wui-context-menu:select`,{bubbles:!0,detail:{key:t.dataset.key??null,item:t,region:this._region,origin:this._origin}})))}_teardown(){let e=this._panel();if(this._closingByKey=!1,e){for(let t of[...T(e,u)].reverse())i(k(t));i(e)}this._anchor&&this._finish(!1),this._cancelPress(),document.removeEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.removeEventListener(`contextmenu`,this._onContextMenu),document.removeEventListener(`keydown`,this._onDocKeyDown),document.removeEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.removeEventListener(`pointerdown`,this._onPointerDown),document.removeEventListener(`click`,this._onClickCapture,!0),document.removeEventListener(`click`,this._onDocClick),window.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`input`,this._onInput),this.removeEventListener(`mousemove`,this._onMouseMove)}};export{M as t};
|