ooxml-ui 0.2.0 → 0.3.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 CHANGED
@@ -58,20 +58,22 @@ with an incompatible build of this package.
58
58
 
59
59
  ## Features: elements
60
60
 
61
- | Tag | Attributes / properties | Events (all bubble, composed) |
62
- | ---------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
63
- | `office-ui-button` | `label`, `icon`, `command`, `disabled`, `pressed`, `expanded`, `icon-only`, `variant="stacked"`, `keyshortcuts` | `office-command` `{ command }` |
64
- | `office-ui-checkbox`, `office-ui-switch` | `checked`, `disabled`, `value`, `aria-label`; form-associated | `input`, `change` |
65
- | `office-ui-select` | `options` `[{ value, label, disabled? }]`, `value`, `selectedIndex`, `disabled` | `input`, `change` |
66
- | `office-ui-ribbon-group` | `label`; default slot | none |
67
- | `office-ui-toolbar` | `aria-label`, `aria-orientation`; arrow-key focus movement | none |
68
- | `office-ui-dialog` | `open`, `heading`, `dismissible="false"`, `show()`, `close()`; slots default, `footer` | `office-dialog-close` `{ reason }` (cancelable) |
69
- | `office-ui-status-bar` / `-status-item` | `label`, `value`, `interactive`, `id` | `office-status-activate` `{ id }` |
70
- | `office-ui-zoom-slider` | `value` (percent), `min`, `max`, `step`, `disabled`, `fit` (fit button name), `label` | `input`, `change`; fit: `office-command` `{ command: 'zoom-fit' }` |
71
- | `office-ui-tab-strip` | `tabs` `[{ id, label, title? }]`, `selected`, `label`, `disabled` | `office-tab-select` `{ id }` (cancelable) |
72
- | `office-ui-presence` | `participants`, `max`, `label` | `office-presence-select` `{ id }` |
73
- | `office-ui-smartart` | `drawing` (core `DiagramDrawing`), `schemeColors`, `label` | `office-smartart-render` (render report) |
74
- | `office-ui-icon` | `name`, `label` | none |
61
+ | Tag | Attributes / properties | Events (all bubble, composed) |
62
+ | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
63
+ | `office-ui-button` | `label`, `icon`, `command`, `disabled`, `pressed`, `expanded`, `icon-only`, `variant="stacked"`, `keyshortcuts` | `office-command` `{ command }` |
64
+ | `office-ui-checkbox`, `office-ui-switch` | `checked`, `disabled`, `value`, `aria-label`; form-associated | `input`, `change` |
65
+ | `office-ui-select` | `options` `[{ value, label, disabled? }]`, `value`, `selectedIndex`, `disabled` | `input`, `change` |
66
+ | `office-ui-ribbon-group` | `label`, `launcher` (dialog launcher command), `launcher-disabled`; default slot | launcher: `office-command` `{ command }` |
67
+ | `office-ui-ribbon-stack` | `orientation="horizontal"`; default slot (three-row column of small commands by default) | none |
68
+ | `office-ui-menu-button` / `-menu-item` | button: `label`, `icon`, `command` (split button), `variant`, `disabled`, `keyshortcuts`; item: `command`, `label`, `icon`, `disabled`, `checked` | item choice: `office-command` `{ command }` |
69
+ | `office-ui-toolbar` | `aria-label`, `aria-orientation`; arrow-key focus movement | none |
70
+ | `office-ui-dialog` | `open`, `heading`, `dismissible="false"`, `show()`, `close()`; slots default, `footer` | `office-dialog-close` `{ reason }` (cancelable) |
71
+ | `office-ui-status-bar` / `-status-item` | `label`, `value`, `interactive`, `id` | `office-status-activate` `{ id }` |
72
+ | `office-ui-zoom-slider` | `value` (percent), `min`, `max`, `step`, `disabled`, `fit` (fit button name), `label` | `input`, `change`; fit: `office-command` `{ command: 'zoom-fit' }` |
73
+ | `office-ui-tab-strip` | `tabs` `[{ id, label, title? }]`, `selected`, `label`, `disabled` | `office-tab-select` `{ id }` (cancelable) |
74
+ | `office-ui-presence` | `participants`, `max`, `label` | `office-presence-select` `{ id }` |
75
+ | `office-ui-smartart` | `drawing` (core `DiagramDrawing`), `schemeColors`, `label` | `office-smartart-render` (render report) |
76
+ | `office-ui-icon` | `name`, `label` | none |
75
77
 
76
78
  Setting a property never emits an event; only user activation does. Controls honour
77
79
  `prefers-color-scheme`, `forced-colors: active` (system colours and a visible focus ring) and
@@ -28,7 +28,41 @@ var BUILT_IN = {
28
28
  fitPage: "M6.5 6.5h7v7h-7ZM2.5 6V2.5H6M14 2.5h3.5V6M17.5 14v3.5H14M6 17.5H2.5V14",
29
29
  pageWidth: "M5.5 3.5h9v13h-9ZM1.5 10h17M4 8l-2.5 2L4 12M16 8l2.5 2-2.5 2",
30
30
  zoomIn: "M3 8.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0M13 13l4 4M6 8.5h5M8.5 6v5",
31
- zoomOut: "M3 8.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0M13 13l4 4M6 8.5h5"
31
+ zoomOut: "M3 8.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0M13 13l4 4M6 8.5h5",
32
+ cut: "M7 3l7 10M13 3 6 13M3 15.5a2 2 0 1 0 4 0 2 2 0 1 0-4 0M13 15.5a2 2 0 1 0 4 0 2 2 0 1 0-4 0",
33
+ paste: "M7 3.5h6v2.5H7ZM7 4.5H4.5v13h11v-13H13",
34
+ formatPainter: "M4 3h10v4H4ZM14 5h2.5v4.5H9.5V12M8.5 12h2v5h-2Z",
35
+ bold: "M6 3.5h4.5a3 3 0 0 1 0 6H6ZM6 9.5h5.5a3.5 3.5 0 0 1 0 7H6Z",
36
+ italic: "M9 3.5h6M5 16.5h6M12 3.5 8 16.5",
37
+ underline: "M6 3v6a4 4 0 0 0 8 0V3M5 17h10",
38
+ strikethrough: "M3.5 10h13M13.5 5.5C13 4.3 11.7 3.5 10 3.5c-2 0-3.5 1-3.5 2.6 0 1.4 1.2 2.2 3.5 2.8M6.5 13.8c.5 1.6 1.9 2.7 3.8 2.7 2 0 3.5-1.1 3.5-2.8",
39
+ fontColor: "M5.5 13 10 3l4.5 10M7.2 9.3h5.6M3 17h14",
40
+ growFont: "M2.5 16 6.5 6l4 10M4 12.3h5M13 8.5l2-3 2 3M15 5.5V12",
41
+ shrinkFont: "M2.5 16 6.5 6l4 10M4 12.3h5M13 9l2 3 2-3M15 12V5.5",
42
+ changeCase: "M2 15 5.5 5 9 15M3.2 11.7h4.6M15.5 9.5v5.5M15.5 12.2a2.3 2.3 0 1 1-4.6 0 2.3 2.3 0 1 1 4.6 0",
43
+ alignLeft: "M3 4.5h14M3 8.5h9M3 12.5h14M3 16.5h9",
44
+ alignCenter: "M3 4.5h14M5.5 8.5h9M3 12.5h14M5.5 16.5h9",
45
+ alignRight: "M3 4.5h14M8 8.5h9M3 12.5h14M8 16.5h9",
46
+ justify: "M3 4.5h14M3 8.5h14M3 12.5h14M3 16.5h14",
47
+ alignTop: "M3 3.5h14M6 7h8M6 10.5h8",
48
+ alignMiddle: "M3 10h2M15 10h2M6 6.5h8M6 13.5h8M6 10h8",
49
+ alignBottom: "M3 16.5h14M6 9.5h8M6 13h8",
50
+ bullets: "M8 5h9M8 10h9M8 15h9M3.5 5h1M3.5 10h1M3.5 15h1",
51
+ indentIncrease: "M3 4h14M9 8h8M9 12h8M3 16h14M3 7.5 6 10l-3 2.5",
52
+ indentDecrease: "M3 4h14M9 8h8M9 12h8M3 16h14M6 7.5 3 10l3 2.5",
53
+ fill: "M3.5 10 9 4.5l6 6L9.5 16ZM9 4.5 7 2.5M16.5 12.5s1.5 2 1.5 3a1.5 1.5 0 0 1-3 0c0-1 1.5-3 1.5-3",
54
+ line: "M3.5 16.5 16.5 3.5",
55
+ effects: "M10 2.5l1.9 4.6 4.6 1.9-4.6 1.9L10 15.5l-1.9-4.6L3.5 9l4.6-1.9Z",
56
+ quickStyles: "M10 3a7 7 0 1 0 0 14c1 0 1.5-.7 1.5-1.5S11 14 11 13s.8-1.5 2-1.5h2a2 2 0 0 0 2-2A7 7 0 0 0 10 3ZM6.5 9.5h.1M8.5 6.2h.1M12.5 6.5h.1",
57
+ bringToFront: "M7.5 7.5h9v9h-9ZM12.5 7.5v-4h-9v9h4",
58
+ sendToBack: "M3.5 3.5h9v9h-9ZM12.5 7.5h4v9h-9v-4",
59
+ group: "M3 3h5v5H3ZM12 12h5v5h-5ZM2 2h1M17 2h1M2 18h1M17 18h1",
60
+ alignObjects: "M3 2.5v15M6 5h8v4H6ZM6 11h11v4H6Z",
61
+ position: "M10 2.5v15M2.5 10h15M7.5 5 10 2.5 12.5 5M7.5 15l2.5 2.5 2.5-2.5M5 7.5 2.5 10 5 12.5M15 7.5l2.5 2.5-2.5 2.5",
62
+ connector: "M3.5 15.5h5v-11h8M14.5 2.5l2 2-2 2M2.5 13.5v4",
63
+ textBox: "M3 3h14v14H3ZM6.5 6.5h7M10 6.5v7",
64
+ ruler: "M2 7h16v6H2ZM5 7v3M8 7v2M11 7v3M14 7v2",
65
+ launcher: "M5 15 15 5M9 5h6v6"
32
66
  };
33
67
  for (const [name, d] of Object.entries(BUILT_IN)) registry.set(name, { d });
34
68
  function registerIcon(name, icon) {
@@ -1,4 +1,4 @@
1
- import { createIconSvg, paintIcon, defineIcon } from './chunk-Y4YIYNUZ.js';
1
+ import { createIconSvg, paintIcon, defineIcon } from './chunk-PCSUQPMC.js';
2
2
  import { definer, attachStyles, controlCss, emit } from './chunk-EY266IK3.js';
3
3
 
4
4
  // src/button.ts
@@ -353,6 +353,286 @@ var defineDialog = definer("office-ui-dialog", () => {
353
353
  return OfficeUiDialog;
354
354
  });
355
355
 
356
+ // src/menu.ts
357
+ var BUTTON_CSS = `
358
+ :host { display: inline-flex; vertical-align: middle; }
359
+ .wrap { display: inline-flex; align-items: stretch; border: 1px solid transparent; border-radius: var(--office-radius, 4px); }
360
+ :host([variant="stacked"]) .wrap { flex-direction: column; }
361
+ button { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
362
+ min-width: var(--office-target-size, 28px); min-height: var(--office-target-size, 28px); padding: 0 6px;
363
+ border: 0; border-radius: var(--office-radius, 4px); background: transparent; color: var(--office-foreground, #1f2937);
364
+ font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; }
365
+ :host([variant="stacked"]) .main { flex-direction: column; padding: 4px 6px 0; }
366
+ :host([variant="stacked"]) .caret { min-height: 16px; padding: 0 6px 2px; }
367
+ :host([variant="stacked"]:not([command])) .main { padding-bottom: 0; }
368
+ .wrap:hover:not(.disabled) { border-color: var(--office-border, #d1d5db); }
369
+ button:hover:not(:disabled) { background: var(--office-surface, #f3f4f6); }
370
+ button:focus-visible { outline: 2px solid var(--office-ring, #2563eb); outline-offset: -2px; }
371
+ button:disabled { opacity: .5; cursor: not-allowed; }
372
+ button[aria-expanded="true"] { background: var(--office-surface, #f3f4f6); }
373
+ .caret svg { width: 12px; height: 12px; }
374
+ svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5;
375
+ stroke-linecap: round; stroke-linejoin: round; }
376
+ svg:not([data-painted]) { display: none; }
377
+ .panel { position: fixed; inset: auto; margin: 0; min-width: 180px; padding: 4px; box-sizing: border-box;
378
+ background: var(--office-background, #fff); color: var(--office-foreground, #1f2937);
379
+ border: 1px solid var(--office-border, #d1d5db); border-radius: var(--office-radius, 4px);
380
+ box-shadow: 0 8px 24px rgb(0 0 0 / 18%); }
381
+ .panel[hidden] { display: none; }
382
+ @media (forced-colors: active) {
383
+ button { color: ButtonText; } button:disabled { color: GrayText; }
384
+ .panel { border-color: CanvasText; background: Canvas; color: CanvasText; }
385
+ }
386
+ `;
387
+ var ITEM_CSS = `
388
+ :host { display: block; }
389
+ :host([hidden]) { display: none; }
390
+ button { box-sizing: border-box; display: flex; align-items: center; gap: 8px; width: 100%;
391
+ min-height: var(--office-target-size, 28px); padding: 0 10px 0 8px; border: 0; border-radius: 3px;
392
+ background: transparent; color: inherit; font: inherit; font-size: 12px; text-align: start; cursor: pointer; }
393
+ button:hover:not(:disabled), button:focus-visible { background: var(--office-surface, #f3f4f6); outline: none; }
394
+ button:disabled { opacity: .5; cursor: not-allowed; }
395
+ .check { width: 14px; text-align: center; }
396
+ svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5;
397
+ stroke-linecap: round; stroke-linejoin: round; }
398
+ svg:not([data-painted]) { visibility: hidden; }
399
+ @media (forced-colors: active) { button:focus-visible { background: Highlight; color: HighlightText; } }
400
+ `;
401
+ var ENABLED_ITEMS = "office-ui-menu-item:not([disabled]):not([hidden])";
402
+ var defineMenuItem = definer("office-ui-menu-item", () => {
403
+ class OfficeUiMenuItem extends HTMLElement {
404
+ static observedAttributes = ["label", "icon", "command", "disabled", "checked", "title"];
405
+ button;
406
+ svg;
407
+ text;
408
+ mark;
409
+ constructor() {
410
+ super();
411
+ const doc = this.ownerDocument;
412
+ const root = this.attachShadow({ mode: "open", delegatesFocus: true });
413
+ attachStyles(root, controlCss(ITEM_CSS));
414
+ this.button = doc.createElement("button");
415
+ this.button.type = "button";
416
+ this.button.tabIndex = -1;
417
+ this.mark = doc.createElement("span");
418
+ this.mark.className = "check";
419
+ this.mark.setAttribute("aria-hidden", "true");
420
+ this.svg = createIconSvg(doc);
421
+ this.text = doc.createElement("span");
422
+ this.button.append(this.mark, this.svg, this.text);
423
+ root.append(this.button);
424
+ this.button.addEventListener("click", () => {
425
+ const command = this.getAttribute("command");
426
+ if (!this.button.disabled && command) emit(this, "office-command", { command });
427
+ });
428
+ }
429
+ connectedCallback() {
430
+ this.sync();
431
+ }
432
+ attributeChangedCallback() {
433
+ this.sync();
434
+ }
435
+ get disabled() {
436
+ return this.hasAttribute("disabled");
437
+ }
438
+ set disabled(value) {
439
+ this.toggleAttribute("disabled", Boolean(value));
440
+ }
441
+ /** Focus the menuitem itself, so arrow navigation never depends on delegatesFocus. */
442
+ focus(options) {
443
+ this.button.focus(options);
444
+ }
445
+ sync() {
446
+ const checked = this.getAttribute("checked");
447
+ this.button.setAttribute("role", checked === null ? "menuitem" : "menuitemcheckbox");
448
+ if (checked === null) this.button.removeAttribute("aria-checked");
449
+ else this.button.setAttribute("aria-checked", String(checked !== "false"));
450
+ this.mark.textContent = checked !== null && checked !== "false" ? "\u2713" : "";
451
+ this.text.textContent = this.getAttribute("label") ?? "";
452
+ this.button.title = this.getAttribute("title") ?? "";
453
+ this.button.disabled = this.disabled;
454
+ if (paintIcon(this.svg, this.getAttribute("icon"))) this.svg.setAttribute("data-painted", "");
455
+ else this.svg.removeAttribute("data-painted");
456
+ }
457
+ }
458
+ return OfficeUiMenuItem;
459
+ });
460
+ var defineMenuButton = definer("office-ui-menu-button", () => {
461
+ class OfficeUiMenuButton extends HTMLElement {
462
+ static observedAttributes = ["label", "icon", "command", "disabled", "title", "keyshortcuts"];
463
+ wrap;
464
+ main;
465
+ caret;
466
+ svg;
467
+ text;
468
+ panel;
469
+ outside;
470
+ constructor() {
471
+ super();
472
+ const doc = this.ownerDocument;
473
+ const root = this.attachShadow({ mode: "open" });
474
+ attachStyles(root, controlCss(BUTTON_CSS));
475
+ this.wrap = doc.createElement("div");
476
+ this.wrap.className = "wrap";
477
+ this.main = doc.createElement("button");
478
+ this.main.type = "button";
479
+ this.main.className = "main";
480
+ this.main.setAttribute("part", "button");
481
+ this.svg = createIconSvg(doc);
482
+ this.text = doc.createElement("span");
483
+ this.main.append(this.svg, this.text);
484
+ this.caret = doc.createElement("button");
485
+ this.caret.type = "button";
486
+ this.caret.className = "caret";
487
+ this.caret.setAttribute("aria-haspopup", "menu");
488
+ this.caret.setAttribute("aria-expanded", "false");
489
+ const chevron = createIconSvg(doc);
490
+ paintIcon(chevron, "chevronDown");
491
+ chevron.setAttribute("data-painted", "");
492
+ this.caret.append(chevron);
493
+ this.panel = doc.createElement("div");
494
+ this.panel.className = "panel";
495
+ this.panel.setAttribute("role", "menu");
496
+ if (typeof this.panel.showPopover === "function")
497
+ this.panel.setAttribute("popover", "auto");
498
+ else this.panel.hidden = true;
499
+ this.panel.append(doc.createElement("slot"));
500
+ this.wrap.append(this.main, this.caret);
501
+ root.append(this.wrap, this.panel);
502
+ this.main.addEventListener("click", () => {
503
+ const command = this.getAttribute("command");
504
+ if (this.disabled) return;
505
+ if (command) emit(this, "office-command", { command });
506
+ else this.toggle();
507
+ });
508
+ this.caret.addEventListener("click", () => {
509
+ if (!this.disabled) this.toggle();
510
+ });
511
+ for (const trigger of [this.main, this.caret])
512
+ trigger.addEventListener("keydown", (event) => {
513
+ if (event.key === "ArrowDown" && !this.disabled) {
514
+ event.preventDefault();
515
+ this.show(0);
516
+ }
517
+ });
518
+ this.panel.addEventListener("toggle", (event) => {
519
+ if (event.newState === "closed") this.closed();
520
+ });
521
+ this.panel.addEventListener("keydown", (event) => this.onMenuKey(event));
522
+ this.addEventListener("office-command", (event) => {
523
+ if (event.target !== this) this.hide(true);
524
+ });
525
+ }
526
+ connectedCallback() {
527
+ this.sync();
528
+ }
529
+ disconnectedCallback() {
530
+ this.hide(false);
531
+ }
532
+ attributeChangedCallback() {
533
+ this.sync();
534
+ }
535
+ get disabled() {
536
+ return this.hasAttribute("disabled");
537
+ }
538
+ set disabled(value) {
539
+ this.toggleAttribute("disabled", Boolean(value));
540
+ }
541
+ get open() {
542
+ return this.caret.getAttribute("aria-expanded") === "true";
543
+ }
544
+ items() {
545
+ return [...this.querySelectorAll(ENABLED_ITEMS)];
546
+ }
547
+ toggle() {
548
+ if (this.open) this.hide(true);
549
+ else this.show(0);
550
+ }
551
+ show(focusIndex) {
552
+ const anchor = this.wrap.getBoundingClientRect();
553
+ this.panel.style.left = `${Math.round(anchor.left)}px`;
554
+ this.panel.style.top = `${Math.round(anchor.bottom + 2)}px`;
555
+ if (this.panel.hasAttribute("popover")) this.panel.showPopover?.();
556
+ else {
557
+ this.panel.hidden = false;
558
+ this.outside = (event) => {
559
+ if (!event.composedPath().includes(this)) this.hide(false);
560
+ };
561
+ this.ownerDocument.addEventListener("pointerdown", this.outside, true);
562
+ }
563
+ this.setExpanded(true);
564
+ this.items()[focusIndex]?.focus();
565
+ }
566
+ hide(restoreFocus) {
567
+ if (!this.open) return;
568
+ if (this.panel.hasAttribute("popover")) {
569
+ try {
570
+ this.panel.hidePopover?.();
571
+ } catch {
572
+ }
573
+ }
574
+ this.closed();
575
+ if (restoreFocus) (this.getAttribute("command") ? this.caret : this.main).focus();
576
+ }
577
+ closed() {
578
+ if (!this.panel.hasAttribute("popover")) this.panel.hidden = true;
579
+ if (this.outside) this.ownerDocument.removeEventListener("pointerdown", this.outside, true);
580
+ this.outside = void 0;
581
+ this.setExpanded(false);
582
+ }
583
+ setExpanded(open) {
584
+ this.caret.setAttribute("aria-expanded", String(open));
585
+ if (this.hasAttribute("command")) this.main.removeAttribute("aria-expanded");
586
+ else this.main.setAttribute("aria-expanded", String(open));
587
+ }
588
+ onMenuKey(event) {
589
+ const items = this.items();
590
+ const from = items.findIndex(
591
+ (item) => item === event.target || item.contains(event.target)
592
+ );
593
+ const move = (index) => {
594
+ event.preventDefault();
595
+ items[(index + items.length) % items.length]?.focus();
596
+ };
597
+ if (event.key === "ArrowDown") move(from + 1);
598
+ else if (event.key === "ArrowUp") move(from - 1);
599
+ else if (event.key === "Home") move(0);
600
+ else if (event.key === "End") move(items.length - 1);
601
+ else if (event.key === "Escape") {
602
+ event.preventDefault();
603
+ this.hide(true);
604
+ } else if (event.key === "Tab") this.hide(false);
605
+ }
606
+ sync() {
607
+ const label = this.getAttribute("label") ?? "";
608
+ const split = this.hasAttribute("command");
609
+ this.text.textContent = label;
610
+ const title = this.getAttribute("title") ?? label;
611
+ this.main.title = title;
612
+ this.caret.title = split ? `${label} options` : title;
613
+ this.caret.setAttribute("aria-label", split ? `${label} options` : label);
614
+ if (split) {
615
+ this.main.removeAttribute("aria-haspopup");
616
+ this.main.removeAttribute("aria-expanded");
617
+ this.caret.tabIndex = 0;
618
+ } else {
619
+ this.main.setAttribute("aria-haspopup", "menu");
620
+ this.main.setAttribute("aria-expanded", String(this.open));
621
+ this.caret.tabIndex = -1;
622
+ }
623
+ const shortcuts = this.getAttribute("keyshortcuts");
624
+ if (shortcuts) this.main.setAttribute("aria-keyshortcuts", shortcuts);
625
+ else this.main.removeAttribute("aria-keyshortcuts");
626
+ this.main.disabled = this.caret.disabled = this.disabled;
627
+ this.wrap.classList.toggle("disabled", this.disabled);
628
+ if (this.disabled) this.hide(false);
629
+ if (paintIcon(this.svg, this.getAttribute("icon"))) this.svg.setAttribute("data-painted", "");
630
+ else this.svg.removeAttribute("data-painted");
631
+ }
632
+ }
633
+ return OfficeUiMenuButton;
634
+ });
635
+
356
636
  // src/ribbon.ts
357
637
  var GROUP_CSS = `
358
638
  :host { display: inline-flex; flex: none; align-self: stretch; }
@@ -362,14 +642,25 @@ var GROUP_CSS = `
362
642
  :host(:last-child) .group { border-inline-end: 0; }
363
643
  .row { display: flex; align-items: flex-start; gap: 4px; }
364
644
  ::slotted(*) { flex-shrink: 0; }
365
- .caption { padding-top: 2px; color: var(--office-muted-foreground, #6b7280); font-size: 10px;
645
+ .foot { position: relative; display: flex; justify-content: center; padding-top: 2px; }
646
+ .caption { color: var(--office-muted-foreground, #6b7280); font-size: 10px;
366
647
  line-height: 12px; text-align: center; white-space: nowrap; }
648
+ .launcher { position: absolute; inset-inline-end: -6px; bottom: -1px; display: inline-grid; place-items: center;
649
+ width: 16px; height: 14px; padding: 0; border: 0; border-radius: 2px; background: transparent;
650
+ color: var(--office-muted-foreground, #6b7280); cursor: pointer; }
651
+ .launcher:hover:not(:disabled) { background: var(--office-surface, #f3f4f6); }
652
+ .launcher:focus-visible { outline: 2px solid var(--office-ring, #2563eb); }
653
+ .launcher:disabled { opacity: .45; cursor: not-allowed; }
654
+ .launcher[hidden] { display: none; }
655
+ .launcher svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.6;
656
+ stroke-linecap: round; stroke-linejoin: round; }
367
657
  @media (forced-colors: active) { .group { border-inline-end-color: CanvasText; } .caption { color: CanvasText; } }
368
658
  `;
369
659
  var defineRibbonGroup = definer("office-ui-ribbon-group", () => {
370
660
  class OfficeUiRibbonGroup extends HTMLElement {
371
- static observedAttributes = ["label"];
661
+ static observedAttributes = ["label", "launcher", "launcher-disabled"];
372
662
  caption;
663
+ launcher;
373
664
  constructor() {
374
665
  super();
375
666
  const doc = this.ownerDocument;
@@ -382,7 +673,20 @@ var defineRibbonGroup = definer("office-ui-ribbon-group", () => {
382
673
  row.append(doc.createElement("slot"));
383
674
  this.caption = doc.createElement("span");
384
675
  this.caption.className = "caption";
385
- group.append(row, this.caption);
676
+ this.launcher = doc.createElement("button");
677
+ this.launcher.type = "button";
678
+ this.launcher.className = "launcher";
679
+ const glyph = createIconSvg(doc);
680
+ paintIcon(glyph, "launcher");
681
+ this.launcher.append(glyph);
682
+ this.launcher.addEventListener("click", () => {
683
+ const command = this.getAttribute("launcher");
684
+ if (command && !this.launcher.disabled) emit(this, "office-command", { command });
685
+ });
686
+ const foot = doc.createElement("div");
687
+ foot.className = "foot";
688
+ foot.append(this.caption, this.launcher);
689
+ group.append(row, foot);
386
690
  root.append(group);
387
691
  }
388
692
  connectedCallback() {
@@ -396,6 +700,10 @@ var defineRibbonGroup = definer("office-ui-ribbon-group", () => {
396
700
  const label = this.getAttribute("label") ?? "";
397
701
  this.caption.textContent = label;
398
702
  this.setAttribute("aria-label", label);
703
+ this.launcher.hidden = !this.getAttribute("launcher");
704
+ this.launcher.disabled = this.hasAttribute("launcher-disabled");
705
+ this.launcher.setAttribute("aria-label", `${label} options`);
706
+ this.launcher.title = `${label} options`;
399
707
  }
400
708
  }
401
709
  return OfficeUiRibbonGroup;
@@ -405,7 +713,24 @@ var TOOLBAR_CSS = `
405
713
  background: var(--office-surface, #f3f4f6); border-bottom: 1px solid var(--office-border, #d1d5db); }
406
714
  @media (forced-colors: active) { :host { border-bottom-color: CanvasText; background: Canvas; } }
407
715
  `;
408
- var ITEM = "office-ui-button, office-ui-select, office-ui-checkbox, office-ui-switch";
716
+ var STACK_CSS = `
717
+ :host { display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: flex-start;
718
+ gap: 1px; align-self: stretch; }
719
+ :host([orientation="horizontal"]) { flex-direction: row; align-items: center; gap: 2px; align-self: auto; }
720
+ ::slotted(*) { flex-shrink: 0; }
721
+ `;
722
+ var defineRibbonStack = definer("office-ui-ribbon-stack", () => {
723
+ class OfficeUiRibbonStack extends HTMLElement {
724
+ constructor() {
725
+ super();
726
+ const root = this.attachShadow({ mode: "open" });
727
+ attachStyles(root, controlCss(STACK_CSS));
728
+ root.append(this.ownerDocument.createElement("slot"));
729
+ }
730
+ }
731
+ return OfficeUiRibbonStack;
732
+ });
733
+ var ITEM = "office-ui-button, office-ui-menu-button, office-ui-select, office-ui-checkbox, office-ui-switch";
409
734
  var defineToolbar = definer("office-ui-toolbar", () => {
410
735
  class OfficeUiToolbar extends HTMLElement {
411
736
  constructor() {
@@ -664,7 +989,7 @@ var defineStatusBar = definer("office-ui-status-bar", () => {
664
989
  }
665
990
  return OfficeUiStatusBar;
666
991
  });
667
- var ITEM_CSS = `
992
+ var ITEM_CSS2 = `
668
993
  :host { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
669
994
  .label { color: var(--office-muted-foreground, #6b7280); }
670
995
  button { all: unset; display: inline-flex; gap: 4px; align-items: center; cursor: pointer; padding: 0 4px;
@@ -680,7 +1005,7 @@ var defineStatusItem = definer("office-ui-status-item", () => {
680
1005
  constructor() {
681
1006
  super();
682
1007
  this.root = this.attachShadow({ mode: "open", delegatesFocus: true });
683
- attachStyles(this.root, controlCss(ITEM_CSS));
1008
+ attachStyles(this.root, controlCss(ITEM_CSS2));
684
1009
  }
685
1010
  connectedCallback() {
686
1011
  this.render();
@@ -1033,6 +1358,9 @@ var CONTROL_DEFINERS = [
1033
1358
  defineSwitch,
1034
1359
  defineSelect,
1035
1360
  defineRibbonGroup,
1361
+ defineRibbonStack,
1362
+ defineMenuItem,
1363
+ defineMenuButton,
1036
1364
  defineToolbar,
1037
1365
  defineDialog,
1038
1366
  defineStatusBar,
@@ -1044,4 +1372,4 @@ function registerControls(registry) {
1044
1372
  for (const define of CONTROL_DEFINERS) define(registry);
1045
1373
  }
1046
1374
 
1047
- export { CONTROL_DEFINERS, defineButton, defineCheckbox, defineDialog, defineRibbonGroup, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToolbar, defineZoomSlider, registerControls };
1375
+ export { CONTROL_DEFINERS, defineButton, defineCheckbox, defineDialog, defineMenuButton, defineMenuItem, defineRibbonGroup, defineRibbonStack, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToolbar, defineZoomSlider, registerControls };
@@ -2,18 +2,19 @@ import { defineButton } from './button.js';
2
2
  import { defineCheckbox, defineSwitch } from './checkable.js';
3
3
  import { defineDialog } from './dialog.js';
4
4
  import { defineIcon } from './icons.js';
5
- import { defineRibbonGroup, defineToolbar } from './ribbon.js';
5
+ import { defineMenuButton, defineMenuItem } from './menu.js';
6
+ import { defineRibbonGroup, defineRibbonStack, defineToolbar } from './ribbon.js';
6
7
  import { defineSelect } from './select.js';
7
8
  import { defineStatusBar, defineStatusItem } from './status-bar.js';
8
9
  import { defineTabStrip } from './tab-strip.js';
9
10
  import { defineZoomSlider } from './zoom-slider.js';
10
- export { defineButton, defineCheckbox, defineDialog, defineIcon, defineRibbonGroup, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToolbar, defineZoomSlider, };
11
+ export { defineButton, defineCheckbox, defineDialog, defineIcon, defineMenuButton, defineMenuItem, defineRibbonGroup, defineRibbonStack, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToolbar, defineZoomSlider, };
11
12
  export type { OfficeCommandEvent } from './button.js';
12
13
  export type { OfficeDialogCloseEvent, OfficeDialogCloseReason } from './dialog.js';
13
14
  export type { OfficeSelectOption } from './select.js';
14
15
  export type { OfficeStatusActivateEvent } from './status-bar.js';
15
16
  export type { OfficeTab, OfficeTabSelectEvent } from './tab-strip.js';
16
17
  /** Every control of this entry. */
17
- export declare const CONTROL_DEFINERS: readonly [import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer];
18
+ export declare const CONTROL_DEFINERS: readonly [import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer, import("./registry.js").Definer];
18
19
  /** Idempotent, SSR-safe (no-op without a DOM). */
19
20
  export declare function registerControls(registry?: CustomElementRegistry): void;
package/dist/controls.js CHANGED
@@ -1,3 +1,3 @@
1
- export { CONTROL_DEFINERS, defineButton, defineCheckbox, defineDialog, defineRibbonGroup, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToolbar, defineZoomSlider, registerControls } from './chunk-Q2FH3CZQ.js';
2
- export { defineIcon } from './chunk-Y4YIYNUZ.js';
1
+ export { CONTROL_DEFINERS, defineButton, defineCheckbox, defineDialog, defineMenuButton, defineMenuItem, defineRibbonGroup, defineRibbonStack, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToolbar, defineZoomSlider, registerControls } from './chunk-TVZ4V4CX.js';
2
+ export { defineIcon } from './chunk-PCSUQPMC.js';
3
3
  import './chunk-EY266IK3.js';
package/dist/icons.js CHANGED
@@ -1,2 +1,2 @@
1
- export { ICON_CSS, createIconSvg, defineIcon, getIcon, listIcons, paintIcon, registerIcon } from './chunk-Y4YIYNUZ.js';
1
+ export { ICON_CSS, createIconSvg, defineIcon, getIcon, listIcons, paintIcon, registerIcon } from './chunk-PCSUQPMC.js';
2
2
  import './chunk-EY266IK3.js';
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export * from './smartart.js';
5
5
  export * from './theme.js';
6
6
  export { CONTRACT_REVISION, type Definer } from './registry.js';
7
7
  /** Every ooxml-ui tag this package defines, in registration order. */
8
- export declare const OFFICE_UI_TAGS: readonly ["office-ui-icon", "office-ui-button", "office-ui-checkbox", "office-ui-switch", "office-ui-select", "office-ui-ribbon-group", "office-ui-toolbar", "office-ui-dialog", "office-ui-status-bar", "office-ui-status-item", "office-ui-zoom-slider", "office-ui-tab-strip", "office-ui-presence", "office-ui-smartart"];
8
+ export declare const OFFICE_UI_TAGS: readonly ["office-ui-icon", "office-ui-button", "office-ui-checkbox", "office-ui-switch", "office-ui-select", "office-ui-ribbon-group", "office-ui-ribbon-stack", "office-ui-menu-item", "office-ui-menu-button", "office-ui-toolbar", "office-ui-dialog", "office-ui-status-bar", "office-ui-status-item", "office-ui-zoom-slider", "office-ui-tab-strip", "office-ui-presence", "office-ui-smartart"];
9
9
  /**
10
10
  * Install the theme tokens and define every element. Idempotent and safe to call from every
11
11
  * viewer binding; a no-op where there is no DOM (SSR).
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
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-Q2FH3CZQ.js';
4
- export { CONTROL_DEFINERS, defineButton, defineCheckbox, defineDialog, defineRibbonGroup, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToolbar, defineZoomSlider, registerControls } from './chunk-Q2FH3CZQ.js';
5
- export { ICON_CSS, createIconSvg, defineIcon, getIcon, listIcons, paintIcon, registerIcon } from './chunk-Y4YIYNUZ.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';
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';
8
8
  import { defineSmartArt } from './chunk-KJV76AB7.js';
@@ -17,6 +17,9 @@ var OFFICE_UI_TAGS = [
17
17
  "office-ui-switch",
18
18
  "office-ui-select",
19
19
  "office-ui-ribbon-group",
20
+ "office-ui-ribbon-stack",
21
+ "office-ui-menu-item",
22
+ "office-ui-menu-button",
20
23
  "office-ui-toolbar",
21
24
  "office-ui-dialog",
22
25
  "office-ui-status-bar",
package/dist/menu.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * One menu entry: `command`, `label`, `icon`, `disabled`, `checked` (renders a
3
+ * `menuitemcheckbox`), `title`. Activation emits `office-command` `{ command }`.
4
+ */
5
+ export declare const defineMenuItem: import("./registry.js").Definer;
6
+ /**
7
+ * Dropdown command with a menu of `office-ui-menu-item` children (Office's Find, Layers,
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"`,
10
+ * `disabled`, `title`, `keyshortcuts`. The menu uses the top layer (`popover`) so ribbon
11
+ * overflow never clips it. Keyboard: Enter, Space or ArrowDown open; arrows, Home and End move;
12
+ * Escape and Tab close; focus returns to the trigger. Choosing an item closes the menu; its
13
+ * `office-command` bubbles to the host.
14
+ */
15
+ export declare const defineMenuButton: import("./registry.js").Definer;
package/dist/ribbon.d.ts CHANGED
@@ -1,5 +1,14 @@
1
- /** Labelled group of ribbon commands: `role="group"`, `label` attribute is caption and name. */
1
+ /**
2
+ * Labelled group of ribbon commands: `role="group"`, `label` attribute is caption and name.
3
+ * `launcher="<command>"` adds Office's corner dialog launcher, which emits `office-command`
4
+ * `{ command }`; `launcher-disabled` disables it.
5
+ */
2
6
  export declare const defineRibbonGroup: import("./registry.js").Definer;
7
+ /**
8
+ * Layout for small ribbon commands: a column (Office's three-row stack of Cut, Copy and Format
9
+ * Painter) or, with `orientation="horizontal"`, a row (Bold, Italic, Underline). Not a group.
10
+ */
11
+ export declare const defineRibbonStack: import("./registry.js").Definer;
3
12
  /**
4
13
  * `role="toolbar"` container. Left/Right/Home/End move focus between enabled direct or
5
14
  * group-nested controls (Up/Down instead when `aria-orientation="vertical"`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ooxml-ui",
3
- "version": "0.2.0",
3
+ "version": "0.3.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",