ooxml-ui 0.20.0 → 0.22.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.
Files changed (114) hide show
  1. package/README.md +47 -2
  2. package/dist/base.d.ts +118 -0
  3. package/dist/{account.d.ts → chrome/account-profile.d.ts} +0 -6
  4. package/dist/chrome/account.d.ts +17 -0
  5. package/dist/chrome/backstage.d.ts +78 -0
  6. package/dist/chrome/find-bar.d.ts +111 -0
  7. package/dist/chrome/print-preview.d.ts +39 -0
  8. package/dist/chrome/ruler.d.ts +43 -0
  9. package/dist/chrome/status-bar.d.ts +80 -0
  10. package/dist/chrome/status-item.d.ts +40 -0
  11. package/dist/chrome/tab-strip.d.ts +88 -0
  12. package/dist/chrome/title-bar-types.d.ts +75 -0
  13. package/dist/chrome/title-bar.d.ts +81 -0
  14. package/dist/{chunk-7XBKSYGM.js → chunk-2X6QYQ3Q.js} +10 -1
  15. package/dist/{chunk-4JQLQROF.js → chunk-3MDKXKKQ.js} +53 -65
  16. package/dist/chunk-5A4REH6T.js +259 -0
  17. package/dist/chunk-E47762NY.js +90 -0
  18. package/dist/chunk-HNGJI5EZ.js +834 -0
  19. package/dist/{chunk-G3LAGZEW.js → chunk-HSJH6SUW.js} +33 -1
  20. package/dist/{chunk-W5PYFBEZ.js → chunk-HZ422LTR.js} +1 -49
  21. package/dist/chunk-LKLZOPTO.js +4536 -0
  22. package/dist/controls.d.ts +56 -46
  23. package/dist/controls.js +5 -5
  24. package/dist/dialog/dialog-footer.d.ts +40 -0
  25. package/dist/dialog/dialog.d.ts +52 -0
  26. package/dist/{options.d.ts → dialog/options-dialog.d.ts} +46 -1
  27. package/dist/form/checkable.d.ts +49 -0
  28. package/dist/form/checkbox.d.ts +8 -0
  29. package/dist/form/radio.d.ts +68 -0
  30. package/dist/form/search-field.d.ts +54 -0
  31. package/dist/{select-menu.d.ts → form/select-menu.d.ts} +3 -13
  32. package/dist/form/select.d.ts +115 -0
  33. package/dist/form/switch.d.ts +11 -0
  34. package/dist/form/zoom-slider.d.ts +78 -0
  35. package/dist/glyph.d.ts +2 -0
  36. package/dist/icon.d.ts +19 -0
  37. package/dist/icons.d.ts +0 -3
  38. package/dist/icons.js +1 -3
  39. package/dist/index.d.ts +4 -1
  40. package/dist/index.js +16 -12
  41. package/dist/menu/command-search.d.ts +74 -0
  42. package/dist/menu/context-menu.d.ts +89 -0
  43. package/dist/menu/menu-button.d.ts +77 -0
  44. package/dist/menu/menu-item.d.ts +52 -0
  45. package/dist/{menu-model.d.ts → menu/menu-model.d.ts} +2 -0
  46. package/dist/menu/menu-separator.d.ts +7 -0
  47. package/dist/notices/paste-options.d.ts +41 -0
  48. package/dist/notices/read-only-banner.d.ts +53 -0
  49. package/dist/notices/toasts.d.ts +40 -0
  50. package/dist/presence/presence.d.ts +53 -0
  51. package/dist/presence.d.ts +1 -31
  52. package/dist/presence.js +3 -3
  53. package/dist/ribbon/button.d.ts +60 -0
  54. package/dist/ribbon/gallery-styles.d.ts +2 -0
  55. package/dist/ribbon/gallery.d.ts +97 -0
  56. package/dist/ribbon/ribbon-group.d.ts +35 -0
  57. package/dist/{ribbon-section.d.ts → ribbon/ribbon-section.d.ts} +14 -1
  58. package/dist/ribbon/ribbon-stack.d.ts +10 -0
  59. package/dist/ribbon/ribbon-tabs.d.ts +82 -0
  60. package/dist/ribbon/ribbon-toggle.d.ts +49 -0
  61. package/dist/ribbon/ribbon-toolbar.d.ts +15 -0
  62. package/dist/smartart/smartart.d.ts +43 -0
  63. package/dist/smartart.d.ts +1 -14
  64. package/dist/smartart.js +3 -3
  65. package/dist/styles.d.ts +1 -4
  66. package/dist/teams/app-rail.d.ts +29 -0
  67. package/dist/teams/avatar.d.ts +39 -0
  68. package/dist/teams/base.d.ts +17 -0
  69. package/dist/teams/call-controls.d.ts +61 -0
  70. package/dist/teams/call-grid.d.ts +33 -0
  71. package/dist/teams/channel-list.d.ts +40 -0
  72. package/dist/teams/chat-composer.d.ts +60 -0
  73. package/dist/teams/chat-list.d.ts +51 -0
  74. package/dist/teams/icons.d.ts +3 -0
  75. package/dist/teams/index.d.ts +14 -0
  76. package/dist/teams/prejoin.d.ts +40 -0
  77. package/dist/teams.js +5 -0
  78. package/dist/theme.js +2 -2
  79. package/dist/tokens.d.ts +245 -214
  80. package/package.json +12 -6
  81. package/dist/backstage.d.ts +0 -28
  82. package/dist/button.d.ts +0 -14
  83. package/dist/checkable.d.ts +0 -4
  84. package/dist/chrome-controls.d.ts +0 -52
  85. package/dist/chunk-24MMSCKW.js +0 -119
  86. package/dist/chunk-UEJ4F33J.js +0 -78
  87. package/dist/chunk-W7YI5DSJ.js +0 -5970
  88. package/dist/command-search.d.ts +0 -18
  89. package/dist/context-menu.d.ts +0 -20
  90. package/dist/dialog.d.ts +0 -13
  91. package/dist/document-notices.d.ts +0 -55
  92. package/dist/find-bar.d.ts +0 -15
  93. package/dist/gallery-styles.d.ts +0 -7
  94. package/dist/gallery-view.d.ts +0 -53
  95. package/dist/gallery.d.ts +0 -20
  96. package/dist/menu.d.ts +0 -15
  97. package/dist/print-preview.d.ts +0 -11
  98. package/dist/radio.d.ts +0 -1
  99. package/dist/ribbon-tabs.d.ts +0 -14
  100. package/dist/ribbon-toggle.d.ts +0 -1
  101. package/dist/ribbon.d.ts +0 -24
  102. package/dist/ruler.d.ts +0 -10
  103. package/dist/search-field.d.ts +0 -1
  104. package/dist/select-styles.d.ts +0 -6
  105. package/dist/select.d.ts +0 -19
  106. package/dist/status-bar-view.d.ts +0 -50
  107. package/dist/status-bar.d.ts +0 -19
  108. package/dist/tab-strip.d.ts +0 -20
  109. package/dist/title-bar-search.d.ts +0 -43
  110. package/dist/title-bar-strip.d.ts +0 -20
  111. package/dist/title-bar.d.ts +0 -49
  112. package/dist/zoom-slider.d.ts +0 -9
  113. /package/dist/{safe-svg.d.ts → ribbon/safe-svg.d.ts} +0 -0
  114. /package/dist/{smartart-svg.d.ts → smartart/smartart-svg.d.ts} +0 -0
@@ -0,0 +1,88 @@
1
+ import { type PropertyValues } from 'lit';
2
+ import { OfficeElement } from '../base.js';
3
+ export interface OfficeTab {
4
+ id: string;
5
+ label: string;
6
+ /** Tooltip; defaults to the label. */
7
+ title?: string;
8
+ }
9
+ export type OfficeTabSelectEvent = CustomEvent<{
10
+ id: string;
11
+ }>;
12
+ /**
13
+ * Bottom document tabs (Visio pages, Excel sheets). Set `tabs` (`OfficeTab[]`) and `selected`
14
+ * (a tab id). Labels are inserted as text. The previous/next buttons and arrow, Home and End
15
+ * keys move the selection; the tab list uses a roving tabindex. User selection emits
16
+ * `office-tab-select` `{ id }` (cancelable); setting properties never emits.
17
+ * Attributes: `label` (tab list name, default "Tabs"), `previous-label` and `next-label`
18
+ * (step button names, default "Previous" and "Next"), `disabled`, and `add-label` to show an
19
+ * add button after the tabs (Insert Page, New Sheet) that emits `office-command`
20
+ * `{ command: 'tab-add' }`; `add-disabled` and `add-title` disable and explain it.
21
+ */
22
+ export declare class OfficeUiTabStrip extends OfficeElement {
23
+ static styles: import("lit").CSSResult[];
24
+ static properties: {
25
+ selected: {
26
+ type: StringConstructor;
27
+ noAccessor: boolean;
28
+ };
29
+ label: {
30
+ type: StringConstructor;
31
+ };
32
+ previousLabel: {
33
+ attribute: string;
34
+ type: StringConstructor;
35
+ };
36
+ nextLabel: {
37
+ attribute: string;
38
+ type: StringConstructor;
39
+ };
40
+ addLabel: {
41
+ attribute: string;
42
+ type: StringConstructor;
43
+ };
44
+ addTitle: {
45
+ attribute: string;
46
+ type: StringConstructor;
47
+ };
48
+ addDisabled: {
49
+ type: BooleanConstructor;
50
+ reflect: true;
51
+ converter: {
52
+ fromAttribute: (value: string | null) => boolean;
53
+ toAttribute: (value: unknown) => string | null;
54
+ };
55
+ attribute: string;
56
+ };
57
+ disabled: {
58
+ type: BooleanConstructor;
59
+ reflect: true;
60
+ converter: {
61
+ fromAttribute: (value: string | null) => boolean;
62
+ toAttribute: (value: unknown) => string | null;
63
+ };
64
+ };
65
+ };
66
+ label: string | null;
67
+ previousLabel: string | null;
68
+ nextLabel: string | null;
69
+ addLabel: string | null;
70
+ addTitle: string | null;
71
+ addDisabled: boolean;
72
+ disabled: boolean;
73
+ private items;
74
+ private picked;
75
+ constructor();
76
+ get tabs(): OfficeTab[];
77
+ set tabs(value: readonly OfficeTab[]);
78
+ get selected(): string;
79
+ set selected(id: string | null);
80
+ private index;
81
+ private move;
82
+ private choose;
83
+ private onListClick;
84
+ private onKey;
85
+ protected updated(_changed: PropertyValues<this>): void;
86
+ protected render(): import("lit").TemplateResult<1>;
87
+ }
88
+ export declare const defineTabStrip: import("../registry.js").Definer;
@@ -0,0 +1,75 @@
1
+ export type OfficeTitleBarPlacement = 'titleBar' | 'belowRibbon';
2
+ export type OfficeTitleBarTone = 'idle' | 'saving' | 'error';
3
+ /** The AutoSave switch. The host owns the state; a change is only a request. */
4
+ export interface OfficeTitleBarAutosave {
5
+ enabled: boolean;
6
+ /** Default true. False renders the switch inert. */
7
+ available?: boolean | undefined;
8
+ /** "AutoSave". */
9
+ label: string;
10
+ /** "On" / "Off", shown after the switch. */
11
+ stateLabel: string;
12
+ /** Accessible name of the switch. */
13
+ toggleLabel: string;
14
+ /** ScreenTip of the switch; defaults to `toggleLabel`. */
15
+ title?: string | undefined;
16
+ }
17
+ /** One Quick Access Toolbar button; every string arrives translated from the host. */
18
+ export interface OfficeQuickAccessItem {
19
+ id: string;
20
+ /** Registered glyph name (see `registerIcon`). */
21
+ icon: string;
22
+ /** Accessible name, and the visible text when labels show. */
23
+ label: string;
24
+ /** ScreenTip; absent leaves the button without a `title`. */
25
+ title?: string | undefined;
26
+ disabled?: boolean | undefined;
27
+ }
28
+ /** One command the title-bar search can run. `category` shows on the right of its row. */
29
+ export interface OfficeTitleBarCommand {
30
+ id: string;
31
+ label: string;
32
+ category?: string | undefined;
33
+ }
34
+ /** The centred command search. Every string arrives translated from the host. */
35
+ export interface OfficeTitleBarSearch {
36
+ placeholder: string;
37
+ label: string;
38
+ /** Heading over the matches and the live-region text when there are some. */
39
+ heading: string;
40
+ /** Row and live-region text when nothing matches. */
41
+ empty: string;
42
+ /** Searched by label when `match` is absent. */
43
+ commands?: readonly OfficeTitleBarCommand[] | undefined;
44
+ /** Host ranking (synonyms, keywords); replaces the default label search. */
45
+ match?: ((query: string) => readonly OfficeTitleBarCommand[]) | undefined;
46
+ /** Text of the trailing "search the document" row; absent drops that row. */
47
+ content?: ((query: string) => string) | undefined;
48
+ /** Glyph of the content row; defaults to `search`. */
49
+ contentIcon?: string | undefined;
50
+ }
51
+ /** Detail of the search request: a chosen command, or a document search when `command` is absent. */
52
+ export interface OfficeTitleBarSearchDetail {
53
+ query: string;
54
+ command?: string;
55
+ }
56
+ /** Everything the bar shows, already translated. Absent parts are not rendered. */
57
+ export interface OfficeTitleBarState {
58
+ /** One or two letters in the product-coloured app mark; absent hides the mark. */
59
+ appMark?: string | undefined;
60
+ fileName: string;
61
+ /** Save-location or save-progress text after the name. */
62
+ status?: string | undefined;
63
+ tone?: OfficeTitleBarTone | undefined;
64
+ autosave?: OfficeTitleBarAutosave | undefined;
65
+ quickAccess?: {
66
+ label: string;
67
+ items: readonly OfficeQuickAccessItem[];
68
+ showLabels?: boolean | undefined;
69
+ } | undefined;
70
+ search?: OfficeTitleBarSearch | undefined;
71
+ }
72
+ /** The dropdown shows at most this many commands so it never outgrows its box. */
73
+ export declare const OFFICE_TITLE_BAR_SEARCH_LIMIT = 8;
74
+ /** The default search: commands whose label contains the query. */
75
+ export declare function matchTitleBarCommands(search: OfficeTitleBarSearch, query: string): readonly OfficeTitleBarCommand[];
@@ -0,0 +1,81 @@
1
+ import { type PropertyValues, type TemplateResult } from 'lit';
2
+ import { OfficeElement } from '../base.js';
3
+ import { type OfficeTitleBarCommand, type OfficeTitleBarPlacement, type OfficeTitleBarState } from './title-bar-types.js';
4
+ export * from './title-bar-types.js';
5
+ /**
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 `account`
8
+ * slots). Controlled: set `state` (`OfficeTitleBarState`, every string translated); the bar
9
+ * owns no effects. `placement="belowRibbon"` renders only the Quick Access row and hides
10
+ * itself (`data-empty`) while that row is empty. Events (bubbling, composed; static names let a
11
+ * product subclass keep its published ones): `office-autosave-toggle`, `office-command`
12
+ * `{ command }` from a Quick Access button and `office-command-search` `{ query, command? }`.
13
+ * Override `activate(id)` to route Quick Access buttons differently and `rendered()` to mirror
14
+ * state onto the host. Tokens: `--office-title-bar-*`. The search query stays local to the bar,
15
+ * so hosts never round-trip keystrokes; they receive one request per commit.
16
+ */
17
+ export declare class OfficeUiTitleBar extends OfficeElement {
18
+ static autosaveEvent: string;
19
+ static commandEvent: string;
20
+ static searchEvent: string;
21
+ /** Inner controls; a product subclass may use its own aliased tags. */
22
+ static switchTag: string;
23
+ static searchTag: string;
24
+ static styles: import("lit").CSSResult[];
25
+ static properties: {
26
+ placement: {
27
+ type: StringConstructor;
28
+ noAccessor: boolean;
29
+ };
30
+ stop: {
31
+ state: boolean;
32
+ };
33
+ found: {
34
+ state: boolean;
35
+ };
36
+ active: {
37
+ state: boolean;
38
+ };
39
+ resultsOpen: {
40
+ state: boolean;
41
+ };
42
+ live: {
43
+ state: boolean;
44
+ };
45
+ };
46
+ stop: string;
47
+ found: readonly OfficeTitleBarCommand[];
48
+ active: number;
49
+ resultsOpen: boolean;
50
+ live: string;
51
+ private model;
52
+ constructor();
53
+ get state(): OfficeTitleBarState;
54
+ set state(value: OfficeTitleBarState | null | undefined);
55
+ /** Read from the attribute, so a subclass that intercepts attribute changes still sees it. */
56
+ get placement(): OfficeTitleBarPlacement;
57
+ set placement(value: OfficeTitleBarPlacement);
58
+ /** The search field inside the bar, for hosts that move focus to it (Alt+Q). */
59
+ get searchField(): HTMLElement;
60
+ /** A Quick Access button was pressed; subclasses may route by id. */
61
+ activate(id: string): void;
62
+ /** Called after every render; subclasses mirror state onto the host here. */
63
+ rendered(): void;
64
+ private enabledButtons;
65
+ private onQatFocus;
66
+ private onQatKey;
67
+ private quickAccess;
68
+ private get query();
69
+ private openResults;
70
+ private closeResults;
71
+ private commit;
72
+ private onSearchKey;
73
+ private onSearchBlur;
74
+ private results;
75
+ private searchBox;
76
+ private autosave;
77
+ protected willUpdate(changed: PropertyValues<this>): void;
78
+ protected updated(): void;
79
+ protected render(): TemplateResult<1>;
80
+ }
81
+ export declare const defineTitleBar: import("../registry.js").Definer;
@@ -1,4 +1,4 @@
1
- import { OFFICE_TOKENS, TOUCH } from './chunk-G3LAGZEW.js';
1
+ import { OFFICE_TOKENS, TOUCH } from './chunk-HSJH6SUW.js';
2
2
 
3
3
  // src/theme.ts
4
4
  var THEME_STYLE_ID = "office-ui-theme";
@@ -17,6 +17,15 @@ var DARK = `
17
17
  --office-notice-accent: #fbbf24;
18
18
  --office-info: #60a5fa;
19
19
  --office-warning: #f59e0b;
20
+ --office-teams-brand: #7f85f5;
21
+ --office-teams-brand-hover: #96a0ff;
22
+ --office-teams-brand-subtle: #2f2f4a;
23
+ --office-teams-rail: #141414;
24
+ --office-teams-panel: #1f1f1f;
25
+ --office-teams-bubble: #2d2d2d;
26
+ --office-teams-bubble-own: #2f2f4a;
27
+ --office-teams-divider: #3d3d3d;
28
+ --office-teams-text-subtle: #adadad;
20
29
  --office-shadow: 0 6px 20px rgb(0 0 0 / 45%);
21
30
  --office-shadow-lg: 0 10px 25px rgb(0 0 0 / 45%);`;
22
31
  var LIGHT = Object.entries(OFFICE_TOKENS).map(([name, value]) => ` ${name}: ${value};`).join("\n");
@@ -1,5 +1,5 @@
1
- import { definer, attachStyles, controlCss, emit } from './chunk-UEJ4F33J.js';
2
- import { tok } from './chunk-G3LAGZEW.js';
1
+ import { OfficeElement, controlStyles, definer } from './chunk-5A4REH6T.js';
2
+ import { html } from 'lit';
3
3
  import { normalizeHexColor } from 'ooxml-core/color';
4
4
 
5
5
  var SVG_NS = "http://www.w3.org/2000/svg";
@@ -152,71 +152,59 @@ function textElement(doc, shape, scheme) {
152
152
  return text;
153
153
  }
154
154
 
155
- // src/smartart.ts
156
- var CSS = `
157
- :host { display: block; }
158
- svg { display: block; width: 100%; height: auto; max-height: 100%; }
159
- text { font-family: ${tok("--office-font")}; pointer-events: none; }
160
- .empty { padding: ${tok("--office-space-2")}; font-size: ${tok("--office-font-size-sm")}; color: ${tok("--office-muted-foreground")}; }
161
- @media (forced-colors: active) { text { fill: CanvasText; } }
162
- `;
163
- var defineSmartArt = definer("office-ui-smartart", () => {
164
- class OfficeUiSmartArt extends HTMLElement {
165
- static observedAttributes = ["label"];
166
- model;
167
- scheme = {};
168
- lastReport;
169
- root;
170
- constructor() {
171
- super();
172
- this.root = this.attachShadow({ mode: "open" });
173
- attachStyles(this.root, controlCss(CSS));
174
- }
175
- connectedCallback() {
176
- this.render();
177
- }
178
- attributeChangedCallback() {
179
- this.render();
180
- }
181
- get drawing() {
182
- return this.model;
183
- }
184
- set drawing(next) {
185
- this.model = next;
186
- this.render();
187
- }
188
- get schemeColors() {
189
- return this.scheme;
190
- }
191
- set schemeColors(next) {
192
- this.scheme = next;
193
- this.render();
194
- }
195
- /** The report of the last render (undefined while empty). */
196
- get report() {
197
- return this.lastReport;
198
- }
199
- render() {
200
- const doc = this.ownerDocument;
201
- for (const el of this.root.querySelectorAll("svg, .empty")) el.remove();
202
- const label = this.getAttribute("label") ?? "Diagram";
203
- if (!this.model || this.model.shapes.length === 0) {
155
+ // raw-css:/home/runner/work/ooxml/ooxml/packages/ui/src/smartart/smartart.css?raw
156
+ var smartart_default = ":host {\n display: block;\n}\nsvg {\n display: block;\n width: 100%;\n height: auto;\n max-height: 100%;\n}\ntext {\n font-family: var(--office-font);\n pointer-events: none;\n}\n.empty {\n padding: var(--office-space-2);\n font-size: var(--office-font-size-sm);\n color: var(--office-muted-foreground);\n}\n@media (forced-colors: active) {\n text {\n fill: CanvasText;\n }\n}\n";
157
+
158
+ // src/smartart/smartart.ts
159
+ var OfficeUiSmartArt = class extends OfficeElement {
160
+ static styles = controlStyles(smartart_default);
161
+ static properties = {
162
+ drawing: { attribute: false },
163
+ schemeColors: { attribute: false },
164
+ label: { type: String }
165
+ };
166
+ figure;
167
+ lastReport;
168
+ constructor() {
169
+ super();
170
+ this.drawing = void 0;
171
+ this.schemeColors = {};
172
+ this.label = null;
173
+ }
174
+ /** The report of the last render (undefined while empty). */
175
+ get report() {
176
+ return this.lastReport;
177
+ }
178
+ /** The SVG is rebuilt only when the drawing or the scheme colours change. */
179
+ willUpdate(changed) {
180
+ if (changed.has("drawing") || changed.has("schemeColors")) {
181
+ if (!this.drawing || this.drawing.shapes.length === 0) {
182
+ this.figure = void 0;
204
183
  this.lastReport = void 0;
205
- const empty = doc.createElement("div");
206
- empty.className = "empty";
207
- empty.textContent = this.model ? "This diagram has no cached drawing to show." : "";
208
- this.root.append(empty);
209
- return;
184
+ } else {
185
+ const { svg, report } = renderDiagramDrawing(
186
+ this.ownerDocument,
187
+ this.drawing,
188
+ this.schemeColors
189
+ );
190
+ svg.setAttribute("role", "img");
191
+ this.figure = svg;
192
+ this.lastReport = report;
210
193
  }
211
- const { svg, report } = renderDiagramDrawing(doc, this.model, this.scheme);
212
- svg.setAttribute("role", "img");
213
- svg.setAttribute("aria-label", label);
214
- this.root.append(svg);
215
- this.lastReport = report;
216
- emit(this, "office-smartart-render", report);
217
194
  }
195
+ this.figure?.setAttribute("aria-label", this.label ?? "Diagram");
196
+ }
197
+ updated(changed) {
198
+ if (this.lastReport && (changed.has("drawing") || changed.has("schemeColors")))
199
+ this.fire("office-smartart-render", this.lastReport);
200
+ }
201
+ render() {
202
+ if (this.figure) return this.figure;
203
+ return html`<div class="empty"
204
+ >${this.drawing ? "This diagram has no cached drawing to show." : ""}</div
205
+ >`;
218
206
  }
219
- return OfficeUiSmartArt;
220
- });
207
+ };
208
+ var defineSmartArt = definer("office-ui-smartart", () => OfficeUiSmartArt);
221
209
 
222
- export { defineSmartArt, renderDiagramDrawing };
210
+ export { OfficeUiSmartArt, defineSmartArt, renderDiagramDrawing };
@@ -0,0 +1,259 @@
1
+ import { TOUCH, tok, OFFICE_TOKENS } from './chunk-HSJH6SUW.js';
2
+ import { unsafeCSS, LitElement } from 'lit';
3
+
4
+ // src/registry.ts
5
+ var CONTRACT_REVISION = 1;
6
+ var CONTRACT_KEY = /* @__PURE__ */ Symbol.for("office-ui.web-control-contract");
7
+ function assertContract(registry, tag) {
8
+ const revision = registry.get(tag)?.[CONTRACT_KEY];
9
+ if (revision !== void 0 && revision !== CONTRACT_REVISION) {
10
+ throw new Error(
11
+ `Incompatible ${tag} contract (${revision}; expected ${CONTRACT_REVISION}). Load one version of ooxml-ui per window.`
12
+ );
13
+ }
14
+ }
15
+ function defineOnce(registry, tag, make) {
16
+ assertContract(registry, tag);
17
+ if (registry.get(tag)) return;
18
+ const ctor = make();
19
+ Object.defineProperty(ctor, CONTRACT_KEY, { value: CONTRACT_REVISION });
20
+ registry.define(tag, ctor);
21
+ }
22
+ function browserRegistry() {
23
+ return typeof window === "undefined" ? void 0 : window.customElements;
24
+ }
25
+ function definer(tag, make) {
26
+ const define = (registry = browserRegistry()) => {
27
+ if (registry) defineOnce(registry, tag, make);
28
+ };
29
+ return Object.assign(define, { tag });
30
+ }
31
+ function emit(host, type, detail, cancelable = false) {
32
+ return host.dispatchEvent(
33
+ new CustomEvent(type, { detail, bubbles: true, composed: true, cancelable })
34
+ );
35
+ }
36
+ function present(value) {
37
+ return value === "" || Boolean(value);
38
+ }
39
+
40
+ // src/styles.ts
41
+ var COMMON_CONTROL_CSS = `
42
+ :host([hidden]) { display: none !important; }
43
+ @media ${TOUCH} {
44
+ :host { --office-target-size: ${tok("--office-target-size-touch")}; }
45
+ }
46
+ @media (forced-colors: active) {
47
+ :host(:focus-visible), :focus-visible { outline: ${tok("--office-focus-width")} solid Highlight; outline-offset: ${tok("--office-focus-offset")}; }
48
+ }
49
+ `;
50
+
51
+ // src/base.ts
52
+ function withTokens(css) {
53
+ return css.replace(
54
+ /var\((--office-[\w-]+)\)/g,
55
+ (whole, name) => name in OFFICE_TOKENS ? `var(${name}, ${OFFICE_TOKENS[name]})` : whole
56
+ );
57
+ }
58
+ var controlStyles = (...sheets) => [
59
+ unsafeCSS(COMMON_CONTROL_CSS),
60
+ ...sheets.map((sheet) => unsafeCSS(withTokens(sheet)))
61
+ ];
62
+ var flag = {
63
+ type: Boolean,
64
+ reflect: true,
65
+ converter: {
66
+ fromAttribute: (value) => value !== null,
67
+ toAttribute: (value) => present(value) ? "" : null
68
+ }
69
+ };
70
+ var readFlag = {
71
+ type: Boolean,
72
+ converter: {
73
+ fromAttribute: (value) => value !== null && value !== "false"
74
+ }
75
+ };
76
+ var triState = {
77
+ reflect: true,
78
+ converter: {
79
+ fromAttribute: (value) => value === null ? void 0 : value !== "false",
80
+ toAttribute: (value) => value === void 0 ? null : String(value)
81
+ }
82
+ };
83
+ var valueOn = {
84
+ type: String,
85
+ converter: { fromAttribute: (value) => value ?? "on" }
86
+ };
87
+ var OfficeElement = class extends LitElement {
88
+ static syncUpdates = true;
89
+ _rendering;
90
+ _ready;
91
+ constructor() {
92
+ super();
93
+ this.renderRoot = this.createRenderRoot();
94
+ this._ready = true;
95
+ if (this.constructor.syncUpdates)
96
+ queueMicrotask(() => {
97
+ if (this.isConnected) this.ensureRendered();
98
+ });
99
+ }
100
+ /**
101
+ * Render now if the element has never rendered; a no-op afterwards or while rendering. A
102
+ * disconnected element may be rendered here from inside a constructor (a subclass reading
103
+ * `shadowRoot`), and a constructor may not add host attributes, so while it renders its host
104
+ * writes are queued and applied before the next write or update, or on connection.
105
+ */
106
+ ensureRendered() {
107
+ if (!this._ready || this._rendering || this.hasUpdated || !this.isUpdatePending || !this.constructor.syncUpdates)
108
+ return;
109
+ this._deferring = !this.isConnected;
110
+ this._detachedRender ||= this._deferring;
111
+ try {
112
+ this.performUpdate();
113
+ } finally {
114
+ this._deferring = false;
115
+ }
116
+ }
117
+ _detachedRender;
118
+ /** True while a detached first render runs (inside a constructor, maybe): no children may be added. */
119
+ get detachedFirstRender() {
120
+ return this._deferring === true;
121
+ }
122
+ _queue;
123
+ _deferring;
124
+ /** Write to the host element: queued (and dropped) during a detached first render, else applied at once. */
125
+ hostWrite(write) {
126
+ if (this._deferring) (this._queue ??= []).push(write);
127
+ else {
128
+ this.flushHost();
129
+ write();
130
+ }
131
+ }
132
+ /**
133
+ * Forget the host writes a detached first render queued. They are stale by the time anything
134
+ * else happens (replaying one would fire an attribute change that overwrites a newer property),
135
+ * and the render that follows connecting recomputes every host write from the current state.
136
+ */
137
+ flushHost() {
138
+ this._queue = void 0;
139
+ }
140
+ setAttribute(name, value) {
141
+ this.hostWrite(() => super.setAttribute(name, value));
142
+ }
143
+ removeAttribute(name) {
144
+ this.hostWrite(() => super.removeAttribute(name));
145
+ }
146
+ toggleAttribute(name, force) {
147
+ if (!this._deferring) {
148
+ this.flushHost();
149
+ return super.toggleAttribute(name, force);
150
+ }
151
+ const on = force ?? !this.hasAttribute(name);
152
+ this.hostWrite(() => super.toggleAttribute(name, on));
153
+ return on;
154
+ }
155
+ /**
156
+ * Reflecting properties write their attribute as soon as they are set, even before the element
157
+ * connects (Lit alone reflects during an update). A `flag` property also stores a real
158
+ * boolean whatever it is given, so a framework writing `''` (the attribute idiom for
159
+ * "present") reads back `true`.
160
+ */
161
+ static createProperty(name, options = {}) {
162
+ if (!options.reflect || options.noAccessor || options.state)
163
+ return super.createProperty(name, options);
164
+ const quiet = { ...options, reflect: false };
165
+ super.createProperty(name, { ...quiet, noAccessor: true });
166
+ const store = Symbol(String(name));
167
+ const attribute = typeof options.attribute === "string" ? options.attribute : String(name).toLowerCase();
168
+ const isFlag = options.converter === flag.converter;
169
+ Object.defineProperty(this.prototype, name, {
170
+ configurable: true,
171
+ enumerable: true,
172
+ get() {
173
+ return this[store];
174
+ },
175
+ set(value) {
176
+ const old = this[store];
177
+ const next = isFlag ? present(value) : value;
178
+ this[store] = next;
179
+ const deferred = old === void 0;
180
+ if (!deferred) this.reflectAttribute(attribute, next, options);
181
+ this.requestUpdate(name, old, deferred ? options : quiet);
182
+ }
183
+ });
184
+ }
185
+ /**
186
+ * Attributes the element reads straight from the DOM, without a property of the same name: a
187
+ * product subclass reads them too, and a framework that assigns properties it finds (React 19)
188
+ * must write the attribute instead. Changing one redraws the element.
189
+ */
190
+ static watched = [];
191
+ static get observedAttributes() {
192
+ return [...super.observedAttributes, ...this.watched];
193
+ }
194
+ fromAttribute;
195
+ attributeChangedCallback(name, old, value) {
196
+ this.fromAttribute = name;
197
+ try {
198
+ super.attributeChangedCallback(name, old, value);
199
+ } finally {
200
+ this.fromAttribute = void 0;
201
+ }
202
+ if (this.constructor.watched.includes(name)) this.requestUpdate();
203
+ }
204
+ /** Write a property's value to its attribute now, unless the attribute is where it came from. */
205
+ reflectAttribute(attribute, value, options) {
206
+ if (this.fromAttribute === attribute) return;
207
+ const converter = options.converter;
208
+ const text = converter && typeof converter === "object" && converter.toAttribute ? converter.toAttribute(value, options.type) : options.type === Boolean ? value ? "" : null : value === null || value === void 0 ? null : String(value);
209
+ if (this.getAttribute(attribute) === text) return;
210
+ if (text === null || text === void 0) this.removeAttribute(attribute);
211
+ else this.setAttribute(attribute, String(text));
212
+ }
213
+ /** Dispatch a bubbling, composed event with `detail`. */
214
+ fire(type, detail, cancelable = false) {
215
+ return emit(this, type, detail, cancelable);
216
+ }
217
+ get immediate() {
218
+ return this.constructor.syncUpdates;
219
+ }
220
+ connectedCallback() {
221
+ this.flushHost();
222
+ super.connectedCallback();
223
+ if (this._detachedRender) {
224
+ this._detachedRender = false;
225
+ this.requestUpdate();
226
+ }
227
+ if (this.immediate && !this.hasUpdated && this.isUpdatePending) this.performUpdate();
228
+ }
229
+ performUpdate() {
230
+ if (!this._deferring) this.flushHost();
231
+ this._rendering = true;
232
+ try {
233
+ return super.performUpdate();
234
+ } finally {
235
+ this._rendering = false;
236
+ }
237
+ }
238
+ requestUpdate(name, oldValue, options) {
239
+ super.requestUpdate(name, oldValue, options);
240
+ if (this._ready && this.immediate && this.hasUpdated && !this._rendering && this.isUpdatePending)
241
+ this.performUpdate();
242
+ }
243
+ };
244
+ function inheritedShadowRoot() {
245
+ for (let proto = Object.getPrototypeOf(OfficeElement.prototype); proto; proto = Object.getPrototypeOf(proto)) {
246
+ const getter = Object.getOwnPropertyDescriptor(proto, "shadowRoot")?.get;
247
+ if (getter) return getter;
248
+ }
249
+ return void 0;
250
+ }
251
+ Object.defineProperty(OfficeElement.prototype, "shadowRoot", {
252
+ configurable: true,
253
+ get() {
254
+ this.ensureRendered();
255
+ return inheritedShadowRoot()?.call(this) ?? null;
256
+ }
257
+ });
258
+
259
+ export { CONTRACT_REVISION, OfficeElement, controlStyles, definer, flag, present, readFlag, triState, valueOn, withTokens };