ooxml-ui 0.3.0 → 0.4.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.
@@ -459,7 +459,15 @@ var defineMenuItem = definer("office-ui-menu-item", () => {
459
459
  });
460
460
  var defineMenuButton = definer("office-ui-menu-button", () => {
461
461
  class OfficeUiMenuButton extends HTMLElement {
462
- static observedAttributes = ["label", "icon", "command", "disabled", "title", "keyshortcuts"];
462
+ static observedAttributes = [
463
+ "label",
464
+ "icon",
465
+ "command",
466
+ "disabled",
467
+ "title",
468
+ "keyshortcuts",
469
+ "icon-only"
470
+ ];
463
471
  wrap;
464
472
  main;
465
473
  caret;
@@ -561,8 +569,21 @@ var defineMenuButton = definer("office-ui-menu-button", () => {
561
569
  this.ownerDocument.addEventListener("pointerdown", this.outside, true);
562
570
  }
563
571
  this.setExpanded(true);
572
+ this.place(anchor);
564
573
  this.items()[focusIndex]?.focus();
565
574
  }
575
+ /** Keep the open menu inside the viewport: flip left of the trigger's right edge if needed. */
576
+ place(anchor) {
577
+ const view = this.ownerDocument.defaultView;
578
+ const width = this.panel.offsetWidth;
579
+ const height = this.panel.offsetHeight;
580
+ if (!view || !width) return;
581
+ const maxLeft = view.innerWidth - width - 4;
582
+ const left = anchor.left > maxLeft ? Math.max(4, anchor.right - width) : anchor.left;
583
+ const top = anchor.bottom + 2 + height > view.innerHeight && anchor.top - height - 2 > 0 ? anchor.top - height - 2 : anchor.bottom + 2;
584
+ this.panel.style.left = `${Math.round(Math.min(left, Math.max(4, maxLeft)))}px`;
585
+ this.panel.style.top = `${Math.round(top)}px`;
586
+ }
566
587
  hide(restoreFocus) {
567
588
  if (!this.open) return;
568
589
  if (this.panel.hasAttribute("popover")) {
@@ -606,11 +627,21 @@ var defineMenuButton = definer("office-ui-menu-button", () => {
606
627
  sync() {
607
628
  const label = this.getAttribute("label") ?? "";
608
629
  const split = this.hasAttribute("command");
630
+ const iconOnly = this.hasAttribute("icon-only");
609
631
  this.text.textContent = label;
632
+ this.text.hidden = iconOnly;
633
+ if (iconOnly) this.main.setAttribute("aria-label", label);
634
+ else this.main.removeAttribute("aria-label");
610
635
  const title = this.getAttribute("title") ?? label;
611
636
  this.main.title = title;
612
637
  this.caret.title = split ? `${label} options` : title;
613
- this.caret.setAttribute("aria-label", split ? `${label} options` : label);
638
+ if (split) {
639
+ this.caret.setAttribute("aria-label", `${label} options`);
640
+ this.caret.removeAttribute("aria-hidden");
641
+ } else {
642
+ this.caret.removeAttribute("aria-label");
643
+ this.caret.setAttribute("aria-hidden", "true");
644
+ }
614
645
  if (split) {
615
646
  this.main.removeAttribute("aria-haspopup");
616
647
  this.main.removeAttribute("aria-expanded");
package/dist/controls.js CHANGED
@@ -1,3 +1,3 @@
1
- export { CONTROL_DEFINERS, defineButton, defineCheckbox, defineDialog, defineMenuButton, defineMenuItem, defineRibbonGroup, defineRibbonStack, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToolbar, defineZoomSlider, registerControls } from './chunk-TVZ4V4CX.js';
1
+ export { CONTROL_DEFINERS, defineButton, defineCheckbox, defineDialog, defineMenuButton, defineMenuItem, defineRibbonGroup, defineRibbonStack, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToolbar, defineZoomSlider, registerControls } from './chunk-RYUUWQ7F.js';
2
2
  export { defineIcon } from './chunk-PCSUQPMC.js';
3
3
  import './chunk-EY266IK3.js';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { installOfficeUiTheme } from './chunk-H4KFVIGT.js';
2
2
  export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme } from './chunk-H4KFVIGT.js';
3
- import { registerControls } from './chunk-TVZ4V4CX.js';
4
- export { CONTROL_DEFINERS, defineButton, defineCheckbox, defineDialog, defineMenuButton, defineMenuItem, defineRibbonGroup, defineRibbonStack, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToolbar, defineZoomSlider, registerControls } from './chunk-TVZ4V4CX.js';
3
+ import { registerControls } from './chunk-RYUUWQ7F.js';
4
+ export { CONTROL_DEFINERS, defineButton, defineCheckbox, defineDialog, defineMenuButton, defineMenuItem, defineRibbonGroup, defineRibbonStack, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToolbar, defineZoomSlider, registerControls } from './chunk-RYUUWQ7F.js';
5
5
  export { ICON_CSS, createIconSvg, defineIcon, getIcon, listIcons, paintIcon, registerIcon } from './chunk-PCSUQPMC.js';
6
6
  import { definePresence } from './chunk-RLPL7Q6J.js';
7
7
  export { definePresence, initialsOf, participantsFromAwareness } from './chunk-RLPL7Q6J.js';
package/dist/menu.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare const defineMenuItem: import("./registry.js").Definer;
6
6
  /**
7
7
  * Dropdown command with a menu of `office-ui-menu-item` children (Office's Find, Layers,
8
8
  * Align). With a `command` attribute it is a split button: the main part emits that command
9
- * and the caret opens the menu. Attributes: `label`, `icon`, `command`, `variant="stacked"`,
9
+ * and the caret opens the menu. Attributes: `label`, `icon`, `command`, `variant="stacked"`, `icon-only`,
10
10
  * `disabled`, `title`, `keyshortcuts`. The menu uses the top layer (`popover`) so ribbon
11
11
  * overflow never clips it. Keyboard: Enter, Space or ArrowDown open; arrows, Home and End move;
12
12
  * Escape and Tab close; focus returns to the trigger. Choosing an item closes the menu; its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ooxml-ui",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Shared, format-neutral web components and styles for the Office viewers (Word, PowerPoint, Excel)",
5
5
  "keywords": [
6
6
  "custom-elements",