ooxml-ui 0.24.0 → 0.25.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/chrome/title-bar.d.ts +2 -2
- package/dist/{chunk-2X6QYQ3Q.js → chunk-PAPKST6W.js} +35 -1
- package/dist/{chunk-FWZIVXAV.js → chunk-SXCANAX7.js} +23 -2
- package/dist/controls.js +1 -1
- package/dist/index.js +4 -4
- package/dist/ribbon/ribbon-tabs.d.ts +8 -1
- package/dist/theme-bridge.d.ts +25 -0
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +1 -1
- package/package.json +2 -2
|
@@ -4,8 +4,8 @@ import { type OfficeTitleBarCommand, type OfficeTitleBarPlacement, type OfficeTi
|
|
|
4
4
|
export * from './title-bar-types.js';
|
|
5
5
|
/**
|
|
6
6
|
* `<office-ui-title-bar>`: Office's title bar above the ribbon (app mark, AutoSave, Quick
|
|
7
|
-
* Access Toolbar, file name and status, centred command search, `collaboration` and
|
|
8
|
-
* slots). Controlled: set `state` (`OfficeTitleBarState`, every string translated); the bar
|
|
7
|
+
* Access Toolbar, file name and status, centred command search, `actions`, `collaboration` and
|
|
8
|
+
* `account` slots). Controlled: set `state` (`OfficeTitleBarState`, every string translated); the bar
|
|
9
9
|
* owns no effects. `placement="belowRibbon"` renders only the Quick Access row and hides
|
|
10
10
|
* itself (`data-empty`) while that row is empty. Events (bubbling, composed; static names let a
|
|
11
11
|
* product subclass keep its published ones): `office-autosave-toggle`, `office-command`
|
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
import { OFFICE_TOKENS, TOUCH } from './chunk-HSJH6SUW.js';
|
|
2
2
|
|
|
3
|
+
// src/theme-bridge.ts
|
|
4
|
+
var SHADCN_NAMES = [
|
|
5
|
+
["--office-foreground", "foreground"],
|
|
6
|
+
["--office-muted-foreground", "muted-foreground"],
|
|
7
|
+
["--office-background", "background"],
|
|
8
|
+
["--office-surface", "card"],
|
|
9
|
+
["--office-selected", "accent"],
|
|
10
|
+
["--office-border", "border"],
|
|
11
|
+
["--office-accent", "primary"],
|
|
12
|
+
["--office-accent-foreground", "primary-foreground"],
|
|
13
|
+
["--office-ring", "ring"],
|
|
14
|
+
["--office-popover", "popover"],
|
|
15
|
+
// Popover text falls back to the plain foreground, as it does in the shadcn themes.
|
|
16
|
+
["--office-popover-foreground", "popover-foreground", "foreground"],
|
|
17
|
+
["--office-danger", "destructive"],
|
|
18
|
+
["--office-danger-foreground", "destructive-foreground"]
|
|
19
|
+
];
|
|
20
|
+
function themeBridge(selector, map) {
|
|
21
|
+
const lines = Object.entries(map).filter(([, value]) => value).map(([name, value]) => ` ${name}: ${value};`);
|
|
22
|
+
return `${selector} {
|
|
23
|
+
${lines.join("\n")}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
}
|
|
27
|
+
function shadcnBridge(selector, prefix, options = {}) {
|
|
28
|
+
const map = {};
|
|
29
|
+
for (const [token, name, fallbackName] of SHADCN_NAMES) {
|
|
30
|
+
const fallback = options.fallbacks?.[name];
|
|
31
|
+
const inner = fallbackName ? `var(${prefix}${fallbackName})` : fallback;
|
|
32
|
+
map[token] = `var(${prefix}${name}${inner ? `, ${inner}` : ""})`;
|
|
33
|
+
}
|
|
34
|
+
return themeBridge(selector, { ...map, ...options.extra });
|
|
35
|
+
}
|
|
36
|
+
|
|
3
37
|
// src/theme.ts
|
|
4
38
|
var THEME_STYLE_ID = "office-ui-theme";
|
|
5
39
|
var DARK = `
|
|
@@ -67,4 +101,4 @@ function installOfficeUiTheme(doc = globalThis.document) {
|
|
|
67
101
|
return true;
|
|
68
102
|
}
|
|
69
103
|
|
|
70
|
-
export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme };
|
|
104
|
+
export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme, shadcnBridge, themeBridge };
|
|
@@ -1085,7 +1085,9 @@ var OfficeUiRibbon = class extends OfficeElement {
|
|
|
1085
1085
|
this.tabs = [];
|
|
1086
1086
|
}
|
|
1087
1087
|
get selected() {
|
|
1088
|
-
|
|
1088
|
+
const shown = this.shown();
|
|
1089
|
+
const chosen = shown.find((panel) => panel.dataset.ribbonTab === this.chosen);
|
|
1090
|
+
return chosen?.dataset.ribbonTab ?? shown[0]?.dataset.ribbonTab ?? "";
|
|
1089
1091
|
}
|
|
1090
1092
|
set selected(tab) {
|
|
1091
1093
|
this.chosen = tab;
|
|
@@ -1105,9 +1107,13 @@ var OfficeUiRibbon = class extends OfficeElement {
|
|
|
1105
1107
|
(child) => child instanceof HTMLElement && !!child.dataset.ribbonTab
|
|
1106
1108
|
);
|
|
1107
1109
|
}
|
|
1110
|
+
/** The panels that have a tab: those not marked `data-tab-hidden`. */
|
|
1111
|
+
shown() {
|
|
1112
|
+
return this.panels().filter((panel) => panel.dataset.tabHidden === void 0);
|
|
1113
|
+
}
|
|
1108
1114
|
/** Read the tabs off the panels (on connection and whenever the slotted panels change). */
|
|
1109
1115
|
build() {
|
|
1110
|
-
this.tabs = this.
|
|
1116
|
+
this.tabs = this.shown().map((panel) => {
|
|
1111
1117
|
const id = panel.dataset.ribbonTab;
|
|
1112
1118
|
panel.setAttribute("role", "tabpanel");
|
|
1113
1119
|
panel.setAttribute("aria-label", panel.dataset.label ?? id);
|
|
@@ -1140,9 +1146,23 @@ var OfficeUiRibbon = class extends OfficeElement {
|
|
|
1140
1146
|
this.choose(next.dataset.tab);
|
|
1141
1147
|
this.focusTab();
|
|
1142
1148
|
}
|
|
1149
|
+
/** Rebuild the tab row when a panel's label or visibility flag changes. */
|
|
1150
|
+
watcher;
|
|
1143
1151
|
connectedCallback() {
|
|
1144
1152
|
this.build();
|
|
1145
1153
|
super.connectedCallback();
|
|
1154
|
+
const Observer = this.ownerDocument.defaultView?.MutationObserver;
|
|
1155
|
+
this.watcher = Observer ? new Observer(() => this.build()) : void 0;
|
|
1156
|
+
this.watcher?.observe(this, {
|
|
1157
|
+
attributes: true,
|
|
1158
|
+
subtree: true,
|
|
1159
|
+
attributeFilter: ["data-tab-hidden", "data-label"]
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
disconnectedCallback() {
|
|
1163
|
+
super.disconnectedCallback();
|
|
1164
|
+
this.watcher?.disconnect();
|
|
1165
|
+
this.watcher = void 0;
|
|
1146
1166
|
}
|
|
1147
1167
|
/** Exactly one panel shows. */
|
|
1148
1168
|
updated() {
|
|
@@ -4232,6 +4252,7 @@ var OfficeUiTitleBar = class extends OfficeElement {
|
|
|
4232
4252
|
</span>
|
|
4233
4253
|
${this.searchBox()}
|
|
4234
4254
|
<div class="end">
|
|
4255
|
+
<slot name="actions"></slot>
|
|
4235
4256
|
<slot name="collaboration"></slot>
|
|
4236
4257
|
<slot name="account"></slot>
|
|
4237
4258
|
</div>
|
package/dist/controls.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CONTROL_DEFINERS, DEFAULT_OFFICE_PROFILE, EMPTY_MENU_STATE, OFFICE_AVATAR_SWATCHES, OFFICE_PROFILE_STORAGE_KEY, OFFICE_TITLE_BAR_SEARCH_LIMIT, OFFICE_TOAST_VISIBLE_LIMIT, attachKeyTips, clampFlyoutPosition, clampOptionNumber, clearOfficeProfile, defineAccount, defineBackstage, defineButton, defineCheckbox, defineCommandSearch, defineContextMenu, defineDialog, defineDialogFooter, defineFindBar, defineGallery, defineIcon, defineMenuButton, defineMenuItem, defineMenuSeparator, defineOptionsDialog, definePasteOptions, definePrintPreview, defineRadio, defineReadOnlyBanner, defineRibbon, defineRibbonGroup, defineRibbonSection, defineRibbonStack, defineRibbonToggle, defineRuler, defineSearchField, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineTitleBar, defineToasts, defineToolbar, defineZoomSlider, nextEnabledIndex, parseSvgPreview, profileInitials, readOfficeProfile, registerControls, rulerDivisions, sanitizeOfficeProfile, typeAheadIndex, writeOfficeProfile } from './chunk-
|
|
1
|
+
export { CONTROL_DEFINERS, DEFAULT_OFFICE_PROFILE, EMPTY_MENU_STATE, OFFICE_AVATAR_SWATCHES, OFFICE_PROFILE_STORAGE_KEY, OFFICE_TITLE_BAR_SEARCH_LIMIT, OFFICE_TOAST_VISIBLE_LIMIT, attachKeyTips, clampFlyoutPosition, clampOptionNumber, clearOfficeProfile, defineAccount, defineBackstage, defineButton, defineCheckbox, defineCommandSearch, defineContextMenu, defineDialog, defineDialogFooter, defineFindBar, defineGallery, defineIcon, defineMenuButton, defineMenuItem, defineMenuSeparator, defineOptionsDialog, definePasteOptions, definePrintPreview, defineRadio, defineReadOnlyBanner, defineRibbon, defineRibbonGroup, defineRibbonSection, defineRibbonStack, defineRibbonToggle, defineRuler, defineSearchField, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineTitleBar, defineToasts, defineToolbar, defineZoomSlider, nextEnabledIndex, parseSvgPreview, profileInitials, readOfficeProfile, registerControls, rulerDivisions, sanitizeOfficeProfile, typeAheadIndex, writeOfficeProfile } from './chunk-SXCANAX7.js';
|
|
2
2
|
import './chunk-HZ422LTR.js';
|
|
3
3
|
import './chunk-XQWRKHC2.js';
|
|
4
4
|
import './chunk-PCZJV6HQ.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { installOfficeUiTheme } from './chunk-
|
|
2
|
-
export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme } from './chunk-
|
|
3
|
-
import { registerControls } from './chunk-
|
|
4
|
-
export { CONTROL_DEFINERS, DEFAULT_OFFICE_PROFILE, EMPTY_MENU_STATE, OFFICE_AVATAR_SWATCHES, OFFICE_PROFILE_STORAGE_KEY, OFFICE_TITLE_BAR_SEARCH_LIMIT, OFFICE_TOAST_VISIBLE_LIMIT, attachKeyTips, clampFlyoutPosition, clampOptionNumber, clearOfficeProfile, defineAccount, defineBackstage, defineButton, defineCheckbox, defineCommandSearch, defineContextMenu, defineDialog, defineDialogFooter, defineFindBar, defineGallery, defineIcon, defineMenuButton, defineMenuItem, defineMenuSeparator, defineOptionsDialog, definePasteOptions, definePrintPreview, defineRadio, defineReadOnlyBanner, defineRibbon, defineRibbonGroup, defineRibbonSection, defineRibbonStack, defineRibbonToggle, defineRuler, defineSearchField, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineTitleBar, defineToasts, defineToolbar, defineZoomSlider, glyph, nextEnabledIndex, parseSvgPreview, profileInitials, readOfficeProfile, registerControls, rulerDivisions, sanitizeOfficeProfile, typeAheadIndex, writeOfficeProfile } from './chunk-
|
|
1
|
+
import { installOfficeUiTheme } from './chunk-PAPKST6W.js';
|
|
2
|
+
export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme, shadcnBridge, themeBridge } from './chunk-PAPKST6W.js';
|
|
3
|
+
import { registerControls } from './chunk-SXCANAX7.js';
|
|
4
|
+
export { CONTROL_DEFINERS, DEFAULT_OFFICE_PROFILE, EMPTY_MENU_STATE, OFFICE_AVATAR_SWATCHES, OFFICE_PROFILE_STORAGE_KEY, OFFICE_TITLE_BAR_SEARCH_LIMIT, OFFICE_TOAST_VISIBLE_LIMIT, attachKeyTips, clampFlyoutPosition, clampOptionNumber, clearOfficeProfile, defineAccount, defineBackstage, defineButton, defineCheckbox, defineCommandSearch, defineContextMenu, defineDialog, defineDialogFooter, defineFindBar, defineGallery, defineIcon, defineMenuButton, defineMenuItem, defineMenuSeparator, defineOptionsDialog, definePasteOptions, definePrintPreview, defineRadio, defineReadOnlyBanner, defineRibbon, defineRibbonGroup, defineRibbonSection, defineRibbonStack, defineRibbonToggle, defineRuler, defineSearchField, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineTabStrip, defineTitleBar, defineToasts, defineToolbar, defineZoomSlider, glyph, nextEnabledIndex, parseSvgPreview, profileInitials, readOfficeProfile, registerControls, rulerDivisions, sanitizeOfficeProfile, typeAheadIndex, writeOfficeProfile } from './chunk-SXCANAX7.js';
|
|
5
5
|
import { defineSmartArt } from './chunk-RVZAYXTI.js';
|
|
6
6
|
export { OfficeUiSmartArt, defineSmartArt, renderDiagramDrawing } from './chunk-RVZAYXTI.js';
|
|
7
7
|
import { TEAMS_TAGS, registerTeams } from './chunk-TCBUC6BI.js';
|
|
@@ -15,7 +15,9 @@ interface RibbonTab {
|
|
|
15
15
|
* optionally `data-tab-keytip`; the element builds the tabs from them, keeps exactly one panel
|
|
16
16
|
* visible and moves between tabs with the arrow keys, Home and End. Slots: `quick-access`,
|
|
17
17
|
* `search`, `end`. Attributes: `selected`, `label` (tab list name), `file-label` (default "File"),
|
|
18
|
-
* `no-file`, `file-expanded`, `file-keytip`.
|
|
18
|
+
* `no-file`, `file-expanded`, `file-keytip`. A panel with `data-tab-hidden` keeps its content but has
|
|
19
|
+
* no tab (a contextual tab, or one a customisation removed); if it was selected, the first
|
|
20
|
+
* remaining tab takes over. Events: `office-ribbon-select` `{ tab }`
|
|
19
21
|
* (cancelable) and `office-ribbon-file` when File is activated.
|
|
20
22
|
*/
|
|
21
23
|
export declare class OfficeUiRibbon extends OfficeElement {
|
|
@@ -68,12 +70,17 @@ export declare class OfficeUiRibbon extends OfficeElement {
|
|
|
68
70
|
/** Focus the selected tab. */
|
|
69
71
|
focusTab(): void;
|
|
70
72
|
private panels;
|
|
73
|
+
/** The panels that have a tab: those not marked `data-tab-hidden`. */
|
|
74
|
+
private shown;
|
|
71
75
|
/** Read the tabs off the panels (on connection and whenever the slotted panels change). */
|
|
72
76
|
private build;
|
|
73
77
|
private choose;
|
|
74
78
|
private onTabClick;
|
|
75
79
|
private onKey;
|
|
80
|
+
/** Rebuild the tab row when a panel's label or visibility flag changes. */
|
|
81
|
+
private watcher;
|
|
76
82
|
connectedCallback(): void;
|
|
83
|
+
disconnectedCallback(): void;
|
|
77
84
|
/** Exactly one panel shows. */
|
|
78
85
|
protected updated(): void;
|
|
79
86
|
protected render(): import("lit").TemplateResult<1>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { OfficeToken } from './tokens.js';
|
|
2
|
+
/**
|
|
3
|
+
* Feeds the `--office-*` tokens from a product's own theme, so the shared elements follow it.
|
|
4
|
+
* Products (docx, xlsx, pptx, visio) already name their theme after shadcn/ui
|
|
5
|
+
* (`--<prefix>foreground`, `--<prefix>muted-foreground`, ...); `shadcnBridge('--dve-')` is the
|
|
6
|
+
* whole bridge for such a product. `themeBridge` takes any mapping for the rest.
|
|
7
|
+
*
|
|
8
|
+
* The CSS is declared on the selector you give (usually `:host` inside a shadow root, or the
|
|
9
|
+
* product's root element), not on `:root`: a product's colours often resolve where they are read,
|
|
10
|
+
* so a nested theme, a dark scheme or a host override keeps working. Pure strings, no DOM.
|
|
11
|
+
*/
|
|
12
|
+
export type ThemeBridgeMap = Partial<Record<OfficeToken, string>>;
|
|
13
|
+
/** `selector { --office-x: value; ... }` for a mapping; entries without a value are skipped. */
|
|
14
|
+
export declare function themeBridge(selector: string, map: ThemeBridgeMap): string;
|
|
15
|
+
export interface ShadcnBridgeOptions {
|
|
16
|
+
/** Extra or overriding `--office-*` values, for example `{ '--office-font': '...' }`. */
|
|
17
|
+
extra?: ThemeBridgeMap;
|
|
18
|
+
/** A literal each theme variable falls back to when the product does not define it. */
|
|
19
|
+
fallbacks?: Partial<Record<string, string>>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The bridge for a product whose theme variables are `<prefix><shadcn-name>`
|
|
23
|
+
* (`prefix` includes the dashes, for example `'--dve-'` or `'--pptx-'`).
|
|
24
|
+
*/
|
|
25
|
+
export declare function shadcnBridge(selector: string, prefix: string, options?: ShadcnBridgeOptions): string;
|
package/dist/theme.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { shadcnBridge, themeBridge, type ShadcnBridgeOptions, type ThemeBridgeMap, } from './theme-bridge.js';
|
|
1
2
|
export { COMPACT, FOCUS_RING, OFFICE_TOKENS, tok, TOUCH, type OfficeToken } from './tokens.js';
|
|
2
3
|
/**
|
|
3
4
|
* Theme-token foundation. Custom properties cross shadow boundaries, so one `<style>` in the
|
package/dist/theme.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme } from './chunk-
|
|
1
|
+
export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme, shadcnBridge, themeBridge } from './chunk-PAPKST6W.js';
|
|
2
2
|
export { COMPACT, FOCUS_RING, OFFICE_TOKENS, TOUCH, tok } from './chunk-HSJH6SUW.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ooxml-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.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",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"lit": "^3.3.3",
|
|
85
|
-
"ooxml-core": "^0.
|
|
85
|
+
"ooxml-core": "^0.17.0"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@types/jsdom": "^30.0.0",
|