ooxml-ui 0.19.0 → 0.21.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 (111) hide show
  1. package/README.md +82 -36
  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-5L3NYLAW.js → chunk-2X6QYQ3Q.js} +10 -1
  15. package/dist/{chunk-OAGGHX23.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-A3QNC6VS.js → chunk-HSJH6SUW.js} +41 -1
  20. package/dist/{chunk-GWAPPX66.js → chunk-HZ422LTR.js} +1 -49
  21. package/dist/chunk-UTLCJKYC.js +4527 -0
  22. package/dist/controls.d.ts +58 -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 +61 -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 +17 -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/menu-separator.d.ts +7 -0
  46. package/dist/notices/paste-options.d.ts +41 -0
  47. package/dist/notices/read-only-banner.d.ts +53 -0
  48. package/dist/notices/toasts.d.ts +40 -0
  49. package/dist/presence/presence.d.ts +53 -0
  50. package/dist/presence.d.ts +1 -31
  51. package/dist/presence.js +3 -3
  52. package/dist/ribbon/button.d.ts +60 -0
  53. package/dist/ribbon/gallery-styles.d.ts +2 -0
  54. package/dist/ribbon/gallery.d.ts +97 -0
  55. package/dist/ribbon/ribbon-group.d.ts +35 -0
  56. package/dist/{ribbon-section.d.ts → ribbon/ribbon-section.d.ts} +14 -1
  57. package/dist/ribbon/ribbon-stack.d.ts +10 -0
  58. package/dist/ribbon/ribbon-tabs.d.ts +82 -0
  59. package/dist/ribbon/ribbon-toggle.d.ts +49 -0
  60. package/dist/ribbon/ribbon-toolbar.d.ts +15 -0
  61. package/dist/ribbon/safe-svg.d.ts +1 -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 -207
  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-6DZC4M2H.js +0 -5562
  86. package/dist/chunk-DECL6RNI.js +0 -119
  87. package/dist/chunk-UYPH4ESZ.js +0 -78
  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/menu.d.ts +0 -15
  94. package/dist/print-preview.d.ts +0 -11
  95. package/dist/radio.d.ts +0 -1
  96. package/dist/ribbon-tabs.d.ts +0 -14
  97. package/dist/ribbon-toggle.d.ts +0 -1
  98. package/dist/ribbon.d.ts +0 -24
  99. package/dist/ruler.d.ts +0 -10
  100. package/dist/search-field.d.ts +0 -1
  101. package/dist/select-styles.d.ts +0 -6
  102. package/dist/select.d.ts +0 -19
  103. package/dist/status-bar-view.d.ts +0 -50
  104. package/dist/status-bar.d.ts +0 -19
  105. package/dist/tab-strip.d.ts +0 -20
  106. package/dist/title-bar-search.d.ts +0 -43
  107. package/dist/title-bar-strip.d.ts +0 -20
  108. package/dist/title-bar.d.ts +0 -49
  109. package/dist/zoom-slider.d.ts +0 -9
  110. /package/dist/{menu-model.d.ts → menu/menu-model.d.ts} +0 -0
  111. /package/dist/{smartart-svg.d.ts → smartart/smartart-svg.d.ts} +0 -0
@@ -0,0 +1,80 @@
1
+ import { type TemplateResult } from 'lit';
2
+ import { OfficeElement } from '../base.js';
3
+ export type OfficeStatusActivateEvent = CustomEvent<{
4
+ id: string;
5
+ }>;
6
+ /** A text segment at the start of the bar (page count, words, language, save state). */
7
+ export interface OfficeStatusText {
8
+ id: string;
9
+ text: string;
10
+ title?: string | undefined;
11
+ tone?: 'idle' | 'saving' | 'error' | undefined;
12
+ /** Announce changes politely (a page counter). */
13
+ live?: boolean | undefined;
14
+ /** Hide on phone widths. */
15
+ narrowHide?: boolean | undefined;
16
+ }
17
+ /** A status-bar button (Notes, Comments, a view switch). `label` is its name and ScreenTip. */
18
+ export interface OfficeStatusButton {
19
+ id: string;
20
+ icon: string;
21
+ label: string;
22
+ /** Visible text after the glyph; hidden on phone widths. */
23
+ text?: string | undefined;
24
+ pressed?: boolean | undefined;
25
+ hidden?: boolean | undefined;
26
+ }
27
+ /** Everything the controlled bar shows, already translated. Absent parts are not rendered. */
28
+ export interface OfficeStatusBarState {
29
+ items?: readonly OfficeStatusText[] | undefined;
30
+ toggles?: readonly OfficeStatusButton[] | undefined;
31
+ /** The view switches (Normal, Sorter, Reading); hidden while empty, all hidden or `false`. */
32
+ views?: readonly OfficeStatusButton[] | false | undefined;
33
+ /** Zoom out, percentage (zoom to fit) and zoom in; emits `zoomOut`, `zoomFit`, `zoomIn`. */
34
+ zoom?: {
35
+ percent: number;
36
+ outLabel: string;
37
+ fitLabel: string;
38
+ inLabel: string;
39
+ /** Keeps the named buttons but hides the cluster. */
40
+ hidden?: boolean | undefined;
41
+ /** Glyphs; default `minus` and `plus`. */
42
+ outIcon?: string | undefined;
43
+ inIcon?: string | undefined;
44
+ } | undefined;
45
+ }
46
+ /**
47
+ * Status bar: `role="group"` named by its `label` attribute (default "Status"). Two ways to fill
48
+ * it. Composed: children, with `slot="end"` pushed to the trailing edge (zoom, view switches).
49
+ * Controlled: set `state` (`OfficeStatusBarState`: start texts, toggles, view switches and a zoom
50
+ * cluster, all translated); every button emits `office-status-activate` `{ id }` (static
51
+ * `activateEvent` lets a product subclass keep its published name). Slots stay available in
52
+ * controlled mode: the default after the texts, `collaboration` and `end` before the zoom. Keyed
53
+ * children are patched in place, so a focused button survives updates.
54
+ */
55
+ export declare class OfficeUiStatusBar extends OfficeElement {
56
+ static activateEvent: string;
57
+ static styles: import("lit").CSSResult[];
58
+ static properties: {
59
+ label: {
60
+ type: StringConstructor;
61
+ };
62
+ hasCollaboration: {
63
+ state: boolean;
64
+ };
65
+ };
66
+ label: string | null;
67
+ hasCollaboration: boolean;
68
+ private model;
69
+ constructor();
70
+ get state(): OfficeStatusBarState | undefined;
71
+ set state(value: OfficeStatusBarState | null | undefined);
72
+ private activate;
73
+ /** Keep native activation out of the host document's navigation shortcuts. */
74
+ private onKeydown;
75
+ protected willUpdate(): void;
76
+ private button;
77
+ private zoomStep;
78
+ protected render(): TemplateResult<1>;
79
+ }
80
+ export declare const defineStatusBar: import("../registry.js").Definer;
@@ -0,0 +1,40 @@
1
+ import { OfficeElement } from '../base.js';
2
+ /**
3
+ * One status entry: `label` and `value` attributes (textual, so assistive tech reads both).
4
+ * With the `interactive` attribute it renders a button and emits `office-status-activate`
5
+ * `{ id }` (`id` attribute) on click, Enter or Space; zoom or language pickers are examples.
6
+ */
7
+ export declare class OfficeUiStatusItem extends OfficeElement {
8
+ static shadowRootOptions: {
9
+ clonable?: boolean;
10
+ customElementRegistry?: CustomElementRegistry | null;
11
+ mode: ShadowRootMode;
12
+ serializable?: boolean;
13
+ slotAssignment?: SlotAssignmentMode;
14
+ delegatesFocus: boolean;
15
+ };
16
+ static styles: import("lit").CSSResult[];
17
+ static properties: {
18
+ label: {
19
+ type: StringConstructor;
20
+ };
21
+ value: {
22
+ type: StringConstructor;
23
+ reflect: boolean;
24
+ };
25
+ interactive: {
26
+ type: BooleanConstructor;
27
+ reflect: true;
28
+ converter: {
29
+ fromAttribute: (value: string | null) => boolean;
30
+ toAttribute: (value: unknown) => string | null;
31
+ };
32
+ };
33
+ };
34
+ label: string;
35
+ value: string;
36
+ interactive: boolean;
37
+ constructor();
38
+ protected render(): import("lit").TemplateResult<1>;
39
+ }
40
+ export declare const defineStatusItem: import("../registry.js").Definer;
@@ -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-A3QNC6VS.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-UYPH4ESZ.js';
2
- import { tok } from './chunk-A3QNC6VS.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 };