@hazem3500/palette 0.9.144 → 0.9.145

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.
@@ -4,10 +4,11 @@ type MenuAction = {
4
4
  icon: keyof typeof icons;
5
5
  onSelect: () => void;
6
6
  destructive?: boolean;
7
- /** Modified clicks (Shift/Cmd/Ctrl, incl. Shift+Enter) toggle this row instead of selecting it; the menu stays open. */
7
+ /** Modified clicks (Shift/Cmd/Ctrl, incl. Shift+Enter), or any click while `active()`, toggle this row instead of selecting it; the menu stays open. */
8
8
  toggle?: {
9
9
  pressed(): boolean;
10
10
  run(): void;
11
+ active(): boolean;
11
12
  };
12
13
  };
13
14
  export declare function actionMenu(label: string, actions: MenuAction[]): HTMLDetailsElement;
@@ -0,0 +1 @@
1
+ function e(e,t){let o=n("details","comment-menu"),i=n("summary","icon");i.setAttribute("aria-label",e),i.setAttribute("aria-haspopup","menu"),i.setAttribute("aria-expanded","false"),i.title=e,i.append(r("more"));let l=n("div","comment-menu-items");l.popover="manual",l.setAttribute("role","menu"),l.setAttribute("aria-label",e);let s=t.map(e=>{let t=a(e.label,t=>{e.toggle&&(t.shiftKey||t.metaKey||t.ctrlKey||e.toggle.active())?e.toggle.run():(o.open=!1,i.focus({preventScroll:!0}),e.onSelect())},"menu-action"+(e.destructive?" destructive":""),e.icon);return t.append(n("span","",e.label)),t.setAttribute("role",e.toggle?"menuitemcheckbox":"menuitem"),e.toggle&&t.setAttribute("aria-checked",String(e.toggle.pressed())),t.tabIndex=-1,l.append(t),t});return o.addEventListener("toggle",()=>{if(i.setAttribute("aria-expanded",String(o.open)),o.open){l.showPopover();let e=i.getBoundingClientRect();l.style.left=`${Math.max(8,Math.min(e.right-l.offsetWidth,innerWidth-l.offsetWidth-8))}px`,l.style.top=`${Math.max(8,Math.min(e.bottom+6,innerHeight-l.offsetHeight-8))}px`,(s.find(e=>"true"===e.getAttribute("aria-checked"))??s[0])?.focus({preventScroll:!0})}else l.hidePopover()}),o.addEventListener("keydown",e=>{if(!o.open)return;let t,n=s.indexOf(e.target);"ArrowDown"===e.key&&(t=(n+1)%s.length),"ArrowUp"===e.key&&(t=(n-1+s.length)%s.length),"Home"===e.key&&(t=0),"End"===e.key&&(t=s.length-1),void 0!==t&&(e.preventDefault(),s[t]?.focus()),"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),o.open=!1,i.focus({preventScroll:!0})),"Tab"===e.key&&(o.open=!1)}),o.append(i,l),o}function t(t,a,o,i){let l=e(t,a.map(([e,t])=>({label:t,icon:"check",onSelect:()=>i(e)})));l.classList.add("selection-menu");let s=l.querySelector("summary");return s.className="selection-trigger",s.replaceChildren(n("span","selection-label",a.find(([e])=>e===o)?.[1]),r("chevron")),l.querySelectorAll("[role=menuitem]").forEach((e,t)=>{e.setAttribute("role","menuitemradio"),e.setAttribute("aria-checked",String(a[t][0]===o))}),l}import{E as n,F as r,G as a}from"./chunk-QFONAD5S.js";export{e as a,t as b};