ooxml-ui 0.14.0 → 0.16.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.
@@ -1,4 +1,4 @@
1
- import { TOUCH, tok } from './chunk-BDJW2KDI.js';
1
+ import { TOUCH, tok } from './chunk-4MT4OIAJ.js';
2
2
 
3
3
  // src/registry.ts
4
4
  var CONTRACT_REVISION = 1;
@@ -1,4 +1,4 @@
1
- import { definer, attachStyles, controlCss } from './chunk-3BHP4IFP.js';
1
+ import { definer, attachStyles, controlCss } from './chunk-NDEB6EBU.js';
2
2
 
3
3
  // src/icons.ts
4
4
  var registry = /* @__PURE__ */ new Map();
@@ -1,5 +1,5 @@
1
- import { definer, attachStyles, controlCss, emit } from './chunk-3BHP4IFP.js';
2
- import { tok } from './chunk-BDJW2KDI.js';
1
+ import { definer, attachStyles, controlCss, emit } from './chunk-NDEB6EBU.js';
2
+ import { tok } from './chunk-4MT4OIAJ.js';
3
3
 
4
4
  // src/presence.ts
5
5
  function participantsFromAwareness(states, selfId) {
@@ -1,10 +1,20 @@
1
1
  /** A `role="separator"` rule between groups of menu items. */
2
2
  export declare const defineMenuSeparator: import("./registry.js").Definer;
3
3
  /**
4
- * Right-click menu of `office-ui-menu-item` and `office-ui-menu-separator` children (Office's
5
- * shape and text context menus). `openAt(x, y)` shows it at client coordinates in the popover
6
- * top layer, kept inside the viewport; `close()` hides it. Arrow keys, Home and End move between
7
- * enabled items; Escape and Tab close and return focus to the element that was focused. Choosing
8
- * an item closes the menu and its `office-command` bubbles to the host. `label` names the menu.
4
+ * Office's right-click menu, in two modes sharing keyboard, type-ahead and dismissal:
5
+ *
6
+ * - **Children** (self-managed): `office-ui-menu-item` and `office-ui-menu-separator` children.
7
+ * `openAt(x, y)` shows it in the popover top layer, kept inside the viewport; `close()` hides it.
8
+ * Choosing an item closes the menu and its `office-command` bubbles to the host.
9
+ * - **Controlled** (moved from pptx-viewer `pptx-ui-context-menu`): set `state`
10
+ * (`{ x, y, label, items: [{ id, label, separatorBefore?, heading?, danger?, disabled?,
11
+ * checked?, icon? }], markers?, zIndex?, autoFocus? }`). The host is the fixed box at the
12
+ * pointer, clamped into the window. It emits `office-menu-request` `{ id }` when a row is chosen
13
+ * and `office-menu-close` `{ reason: 'escape' | 'outside' | 'tab' }` when dismissed, and never
14
+ * closes itself: the host removes it or clears its items. While open it takes focus on the first
15
+ * enabled row and returns focus to the opener when it goes away, unless something else took it.
16
+ *
17
+ * Arrow keys, Home, End and type-ahead (repeating a letter cycles) move between enabled rows.
18
+ * Static `requestEvent`, `closeEvent` and `markerPattern` let a product keep its published names.
9
19
  */
10
20
  export declare const defineContextMenu: import("./registry.js").Definer;
@@ -35,6 +35,7 @@ export type { OfficeFindInputEvent, OfficeFindStepEvent } from './find-bar.js';
35
35
  export type { OfficePrintPreviewPageEvent } from './print-preview.js';
36
36
  export type { OfficeRibbonSelectEvent } from './ribbon-tabs.js';
37
37
  export { rulerDivisions } from './ruler.js';
38
+ export { clampFlyoutPosition, EMPTY_MENU_STATE, nextEnabledIndex, typeAheadIndex, type FlyoutPositionInput, type OfficeMenuCloseReason, type OfficeMenuItem, type OfficeMenuState, } from './menu-model.js';
38
39
  export { OFFICE_TOAST_VISIBLE_LIMIT, type OfficeDialogFooterAction, type OfficeDialogFooterState, type OfficeDialogFooterVariant, type OfficeToast, type OfficeToastsState, } from './chrome-controls.js';
39
40
  export type { OfficePasteOption, OfficePasteOptionsState, OfficeReadOnlyBannerIntent, OfficeReadOnlyBannerState, } from './document-notices.js';
40
41
  export { clearOfficeProfile, DEFAULT_OFFICE_PROFILE, OFFICE_AVATAR_SWATCHES, OFFICE_PROFILE_STORAGE_KEY, profileInitials, readOfficeProfile, sanitizeOfficeProfile, writeOfficeProfile, type OfficeProfile, type OfficeProfileChangeEvent, } from './account.js';
package/dist/controls.js CHANGED
@@ -1,5 +1,5 @@
1
- export { CONTROL_DEFINERS, DEFAULT_OFFICE_PROFILE, OFFICE_AVATAR_SWATCHES, OFFICE_PROFILE_STORAGE_KEY, OFFICE_TOAST_VISIBLE_LIMIT, attachKeyTips, clampOptionNumber, clearOfficeProfile, defineAccount, defineBackstage, defineButton, defineCheckbox, defineCommandSearch, defineContextMenu, defineDialog, defineDialogFooter, defineFindBar, defineMenuButton, defineMenuItem, defineMenuSeparator, defineOptionsDialog, definePasteOptions, definePrintPreview, defineRadio, defineReadOnlyBanner, defineRibbon, defineRibbonGroup, defineRibbonStack, defineRibbonToggle, defineRuler, defineSearchField, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToasts, defineToolbar, defineZoomSlider, profileInitials, readOfficeProfile, registerControls, rulerDivisions, sanitizeOfficeProfile, writeOfficeProfile } from './chunk-EWNLGZPX.js';
2
- export { defineIcon } from './chunk-WNSUNQIY.js';
3
- import './chunk-WKLVWPI7.js';
4
- import './chunk-3BHP4IFP.js';
5
- import './chunk-BDJW2KDI.js';
1
+ export { CONTROL_DEFINERS, DEFAULT_OFFICE_PROFILE, EMPTY_MENU_STATE, OFFICE_AVATAR_SWATCHES, OFFICE_PROFILE_STORAGE_KEY, OFFICE_TOAST_VISIBLE_LIMIT, attachKeyTips, clampFlyoutPosition, clampOptionNumber, clearOfficeProfile, defineAccount, defineBackstage, defineButton, defineCheckbox, defineCommandSearch, defineContextMenu, defineDialog, defineDialogFooter, defineFindBar, defineMenuButton, defineMenuItem, defineMenuSeparator, defineOptionsDialog, definePasteOptions, definePrintPreview, defineRadio, defineReadOnlyBanner, defineRibbon, defineRibbonGroup, defineRibbonStack, defineRibbonToggle, defineRuler, defineSearchField, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToasts, defineToolbar, defineZoomSlider, nextEnabledIndex, profileInitials, readOfficeProfile, registerControls, rulerDivisions, sanitizeOfficeProfile, typeAheadIndex, writeOfficeProfile } from './chunk-G2ZIAXOV.js';
2
+ export { defineIcon } from './chunk-VUXNXH4Q.js';
3
+ import './chunk-VYF7LGXZ.js';
4
+ import './chunk-NDEB6EBU.js';
5
+ import './chunk-4MT4OIAJ.js';
package/dist/icons.js CHANGED
@@ -1,3 +1,3 @@
1
- export { ICON_CSS, createIconSvg, defineIcon, getIcon, listIcons, paintIcon, registerIcon } from './chunk-WNSUNQIY.js';
2
- import './chunk-3BHP4IFP.js';
3
- import './chunk-BDJW2KDI.js';
1
+ export { ICON_CSS, createIconSvg, defineIcon, getIcon, listIcons, paintIcon, registerIcon } from './chunk-VUXNXH4Q.js';
2
+ import './chunk-NDEB6EBU.js';
3
+ import './chunk-4MT4OIAJ.js';
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
- import { installOfficeUiTheme } from './chunk-7CCQN3VM.js';
2
- export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme } from './chunk-7CCQN3VM.js';
3
- import { registerControls } from './chunk-EWNLGZPX.js';
4
- export { CONTROL_DEFINERS, DEFAULT_OFFICE_PROFILE, OFFICE_AVATAR_SWATCHES, OFFICE_PROFILE_STORAGE_KEY, OFFICE_TOAST_VISIBLE_LIMIT, attachKeyTips, clampOptionNumber, clearOfficeProfile, defineAccount, defineBackstage, defineButton, defineCheckbox, defineCommandSearch, defineContextMenu, defineDialog, defineDialogFooter, defineFindBar, defineMenuButton, defineMenuItem, defineMenuSeparator, defineOptionsDialog, definePasteOptions, definePrintPreview, defineRadio, defineReadOnlyBanner, defineRibbon, defineRibbonGroup, defineRibbonStack, defineRibbonToggle, defineRuler, defineSearchField, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToasts, defineToolbar, defineZoomSlider, profileInitials, readOfficeProfile, registerControls, rulerDivisions, sanitizeOfficeProfile, writeOfficeProfile } from './chunk-EWNLGZPX.js';
5
- export { ICON_CSS, createIconSvg, defineIcon, getIcon, listIcons, paintIcon, registerIcon } from './chunk-WNSUNQIY.js';
6
- import { definePresence } from './chunk-WKLVWPI7.js';
7
- export { definePresence, initialsOf, participantsFromAwareness } from './chunk-WKLVWPI7.js';
8
- import { defineSmartArt } from './chunk-4WUYOQRL.js';
9
- export { defineSmartArt, renderDiagramDrawing } from './chunk-4WUYOQRL.js';
10
- export { CONTRACT_REVISION } from './chunk-3BHP4IFP.js';
11
- export { COMPACT, FOCUS_RING, OFFICE_TOKENS, TOUCH, tok } from './chunk-BDJW2KDI.js';
1
+ import { installOfficeUiTheme } from './chunk-F4TM7U4P.js';
2
+ export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme } from './chunk-F4TM7U4P.js';
3
+ import { registerControls } from './chunk-G2ZIAXOV.js';
4
+ export { CONTROL_DEFINERS, DEFAULT_OFFICE_PROFILE, EMPTY_MENU_STATE, OFFICE_AVATAR_SWATCHES, OFFICE_PROFILE_STORAGE_KEY, OFFICE_TOAST_VISIBLE_LIMIT, attachKeyTips, clampFlyoutPosition, clampOptionNumber, clearOfficeProfile, defineAccount, defineBackstage, defineButton, defineCheckbox, defineCommandSearch, defineContextMenu, defineDialog, defineDialogFooter, defineFindBar, defineMenuButton, defineMenuItem, defineMenuSeparator, defineOptionsDialog, definePasteOptions, definePrintPreview, defineRadio, defineReadOnlyBanner, defineRibbon, defineRibbonGroup, defineRibbonStack, defineRibbonToggle, defineRuler, defineSearchField, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineToasts, defineToolbar, defineZoomSlider, nextEnabledIndex, profileInitials, readOfficeProfile, registerControls, rulerDivisions, sanitizeOfficeProfile, typeAheadIndex, writeOfficeProfile } from './chunk-G2ZIAXOV.js';
5
+ export { ICON_CSS, createIconSvg, defineIcon, getIcon, listIcons, paintIcon, registerIcon } from './chunk-VUXNXH4Q.js';
6
+ import { definePresence } from './chunk-VYF7LGXZ.js';
7
+ export { definePresence, initialsOf, participantsFromAwareness } from './chunk-VYF7LGXZ.js';
8
+ import { defineSmartArt } from './chunk-A46H2JBV.js';
9
+ export { defineSmartArt, renderDiagramDrawing } from './chunk-A46H2JBV.js';
10
+ export { CONTRACT_REVISION } from './chunk-NDEB6EBU.js';
11
+ export { COMPACT, FOCUS_RING, OFFICE_TOKENS, TOUCH, tok } from './chunk-4MT4OIAJ.js';
12
12
 
13
13
  // src/index.ts
14
14
  var OFFICE_UI_TAGS = [
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Menu data and the pure helpers both menu modes share. Moved from pptx-viewer
3
+ * (`web-components/context-menu-model.ts`, `render/flyout-position.ts`).
4
+ */
5
+ /** One row of a controlled menu. Hosts decide `id`, wording, gating and what activation does. */
6
+ export interface OfficeMenuItem {
7
+ /** Stable command id, echoed by the request event. */
8
+ id: string;
9
+ /** Translated visible label. */
10
+ label: string;
11
+ /** Draw a rule before this row. */
12
+ separatorBefore?: boolean;
13
+ /** Group heading shown before this row; the row and the ones after it join that group. */
14
+ heading?: string;
15
+ /** Destructive command (Delete): tinted. */
16
+ danger?: boolean;
17
+ /** Offered but unavailable: announced and drawn dim, skipped by the arrow keys. */
18
+ disabled?: boolean;
19
+ /** A toggle (Grid, Ruler) in this state; omitted for one-shot commands. */
20
+ checked?: boolean;
21
+ /** A registered icon drawn before the label. */
22
+ icon?: string;
23
+ }
24
+ /** Everything a controlled menu needs to draw. */
25
+ export interface OfficeMenuState {
26
+ /** Pointer position, in viewport pixels; the menu clamps itself into the window. */
27
+ x: number;
28
+ y: number;
29
+ /** Accessible name. */
30
+ label: string;
31
+ items: readonly OfficeMenuItem[];
32
+ /** Test-hook attributes copied onto the host (names matching the element's `markerPattern`). */
33
+ markers?: readonly string[];
34
+ /** Stacking order; the `--office-z-popover` token applies when omitted. */
35
+ zIndex?: number;
36
+ /** Move focus onto the first enabled command on open. Default true. */
37
+ autoFocus?: boolean;
38
+ }
39
+ export type OfficeMenuCloseReason = 'escape' | 'outside' | 'tab';
40
+ export declare const EMPTY_MENU_STATE: OfficeMenuState;
41
+ /** Index of the next enabled row from `from` in `step` direction, wrapping; -1 if none. */
42
+ export declare function nextEnabledIndex(items: readonly {
43
+ disabled?: boolean;
44
+ }[], from: number, step: 1 | -1): number;
45
+ /**
46
+ * Type-ahead target: the next enabled row after `from` whose label starts with `query`.
47
+ * Repeating one character cycles through the rows that start with it.
48
+ */
49
+ export declare function typeAheadIndex(items: readonly {
50
+ label: string;
51
+ disabled?: boolean;
52
+ }[], from: number, query: string): number;
53
+ /** Where a flyout wants to sit, how big it is, and what it must fit inside. */
54
+ export interface FlyoutPositionInput {
55
+ /** Anchor point in viewport coordinates (a pointer event's clientX/Y). */
56
+ x: number;
57
+ y: number;
58
+ /** Measured size; zero means "not measured yet". */
59
+ width: number;
60
+ height: number;
61
+ /** The box it must stay inside, normally the window's inner size. */
62
+ viewportWidth: number;
63
+ viewportHeight: number;
64
+ /** Gap kept from every edge, in px. Default 8. */
65
+ margin?: number;
66
+ }
67
+ /**
68
+ * The top-left corner keeping a pointer-anchored flyout fully on screen. Flips inwards at the
69
+ * right and bottom edges, as desktop menus do, and never returns a negative coordinate, so a
70
+ * flyout larger than the viewport stays reachable from the top.
71
+ */
72
+ export declare function clampFlyoutPosition(input: FlyoutPositionInput): {
73
+ left: number;
74
+ top: number;
75
+ };
package/dist/presence.js CHANGED
@@ -1,3 +1,3 @@
1
- export { definePresence, initialsOf, participantsFromAwareness } from './chunk-WKLVWPI7.js';
2
- import './chunk-3BHP4IFP.js';
3
- import './chunk-BDJW2KDI.js';
1
+ export { definePresence, initialsOf, participantsFromAwareness } from './chunk-VYF7LGXZ.js';
2
+ import './chunk-NDEB6EBU.js';
3
+ import './chunk-4MT4OIAJ.js';
package/dist/ribbon.d.ts CHANGED
@@ -1,7 +1,14 @@
1
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.
2
+ * Labelled group of ribbon commands: `role="group"`, `label` is the caption and name. `launcher`
3
+ * adds Office's corner dialog launcher (`launcher="<command>"` emits `office-command`
4
+ * `{ command }`; `launcher-label` names it; `launcher-disabled` disables it). For narrow windows
5
+ * an overflow controller sets `data-collapsed` (the group becomes one button showing `icon` and
6
+ * the label; activating it emits `office-ribbon-collapse-toggle`) and `data-open` (its commands
7
+ * open in a popup at `--office-ribbon-collapse-x/-y`). The group marks itself `data-compact-row`
8
+ * when every command is one line tall (they centre vertically) and `data-stack` when it holds only
9
+ * small drop-down galleries (`[mode="dropdown"]` without `data-command-large`), which stack in
10
+ * columns. Static `launcherEvent`/`collapseEvent` and `launcherDetail()` let a product subclass
11
+ * keep its published events.
5
12
  */
6
13
  export declare const defineRibbonGroup: import("./registry.js").Definer;
7
14
  /**
package/dist/smartart.js CHANGED
@@ -1,3 +1,3 @@
1
- export { defineSmartArt, renderDiagramDrawing } from './chunk-4WUYOQRL.js';
2
- import './chunk-3BHP4IFP.js';
3
- import './chunk-BDJW2KDI.js';
1
+ export { defineSmartArt, renderDiagramDrawing } from './chunk-A46H2JBV.js';
2
+ import './chunk-NDEB6EBU.js';
3
+ import './chunk-4MT4OIAJ.js';
package/dist/theme.js CHANGED
@@ -1,2 +1,2 @@
1
- export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme } from './chunk-7CCQN3VM.js';
2
- export { COMPACT, FOCUS_RING, OFFICE_TOKENS, TOUCH, tok } from './chunk-BDJW2KDI.js';
1
+ export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme } from './chunk-F4TM7U4P.js';
2
+ export { COMPACT, FOCUS_RING, OFFICE_TOKENS, TOUCH, tok } from './chunk-4MT4OIAJ.js';
package/dist/tokens.d.ts CHANGED
@@ -124,6 +124,28 @@ export declare const OFFICE_TOKENS: {
124
124
  readonly '--office-ribbon-tab-height': "35px";
125
125
  readonly '--office-ribbon-group-gap': "2px";
126
126
  readonly '--office-ribbon-group-height': "78px";
127
+ readonly '--office-ribbon-group-padding': "4px 8px 2px";
128
+ readonly '--office-ribbon-separator-inset': "0px";
129
+ readonly '--office-ribbon-separator': "color-mix(in srgb, var(--office-border, #d1d5db) 60%, transparent)";
130
+ readonly '--office-ribbon-caption-size': "10px";
131
+ readonly '--office-ribbon-caption-padding': "2px 0 0";
132
+ readonly '--office-launcher-inset-end': "-6px";
133
+ readonly '--office-launcher-inset-bottom': "-1px";
134
+ readonly '--office-ribbon-compact-row-max': "36px";
135
+ readonly '--office-ribbon-stack-max-height': "80px";
136
+ readonly '--office-ribbon-collapse-x': "8px";
137
+ readonly '--office-ribbon-collapse-y': "120px";
138
+ readonly '--office-command-icon-color': "currentColor";
139
+ readonly '--office-command-large-height': "66px";
140
+ readonly '--office-command-large-min-width': "48px";
141
+ readonly '--office-command-large-max-width': "80px";
142
+ readonly '--office-command-large-icon': "32px";
143
+ readonly '--office-command-small-icon': "16px";
144
+ readonly '--office-command-tall-height': "62px";
145
+ readonly '--office-command-tall-min-width': "40px";
146
+ readonly '--office-command-tall-icon': "30px";
147
+ readonly '--office-command-active': "color-mix(in srgb, var(--office-accent, #2563eb) 15%, transparent)";
148
+ readonly '--office-collapsed-group-min-width': "56px";
127
149
  readonly '--office-ribbon-caption-line-height': "12px";
128
150
  readonly '--office-ribbon-row-height': "22px";
129
151
  readonly '--office-ribbon-file-min-width': "52px";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ooxml-ui",
3
- "version": "0.14.0",
3
+ "version": "0.16.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",
@@ -35,27 +35,33 @@
35
35
  "exports": {
36
36
  ".": {
37
37
  "types": "./dist/index.d.ts",
38
- "import": "./dist/index.js"
38
+ "import": "./dist/index.js",
39
+ "default": "./dist/index.js"
39
40
  },
40
41
  "./theme": {
41
42
  "types": "./dist/theme.d.ts",
42
- "import": "./dist/theme.js"
43
+ "import": "./dist/theme.js",
44
+ "default": "./dist/theme.js"
43
45
  },
44
46
  "./icons": {
45
47
  "types": "./dist/icons.d.ts",
46
- "import": "./dist/icons.js"
48
+ "import": "./dist/icons.js",
49
+ "default": "./dist/icons.js"
47
50
  },
48
51
  "./controls": {
49
52
  "types": "./dist/controls.d.ts",
50
- "import": "./dist/controls.js"
53
+ "import": "./dist/controls.js",
54
+ "default": "./dist/controls.js"
51
55
  },
52
56
  "./presence": {
53
57
  "types": "./dist/presence.d.ts",
54
- "import": "./dist/presence.js"
58
+ "import": "./dist/presence.js",
59
+ "default": "./dist/presence.js"
55
60
  },
56
61
  "./smartart": {
57
62
  "types": "./dist/smartart.d.ts",
58
- "import": "./dist/smartart.js"
63
+ "import": "./dist/smartart.js",
64
+ "default": "./dist/smartart.js"
59
65
  },
60
66
  "./package.json": "./package.json"
61
67
  },