@spfx-fast/sharepoint-ui 0.0.0-stage → 0.4.1

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 (156) hide show
  1. package/AGENTS.md +211 -0
  2. package/LICENSE +21 -0
  3. package/README.md +897 -2
  4. package/components.json +5811 -0
  5. package/dist/appearance.d.ts +6 -0
  6. package/dist/appearance.js +217 -0
  7. package/dist/elements/accordion.d.ts +9 -0
  8. package/dist/elements/accordion.js +338 -0
  9. package/dist/elements/alert.d.ts +2 -0
  10. package/dist/elements/alert.js +62 -0
  11. package/dist/elements/avatar-group-primitives.d.ts +3 -0
  12. package/dist/elements/avatar-group-primitives.js +189 -0
  13. package/dist/elements/avatar-group.d.ts +2 -0
  14. package/dist/elements/avatar-group.js +110 -0
  15. package/dist/elements/avatar.d.ts +4 -0
  16. package/dist/elements/avatar.js +251 -0
  17. package/dist/elements/badge.d.ts +8 -0
  18. package/dist/elements/badge.js +182 -0
  19. package/dist/elements/breadcrumb.d.ts +4 -0
  20. package/dist/elements/breadcrumb.js +233 -0
  21. package/dist/elements/button-group.d.ts +1 -0
  22. package/dist/elements/button-group.js +20 -0
  23. package/dist/elements/button-variants.d.ts +6 -0
  24. package/dist/elements/button-variants.js +339 -0
  25. package/dist/elements/button.d.ts +5 -0
  26. package/dist/elements/button.js +233 -0
  27. package/dist/elements/card-primitives.d.ts +3 -0
  28. package/dist/elements/card-primitives.js +83 -0
  29. package/dist/elements/card.d.ts +5 -0
  30. package/dist/elements/card.js +213 -0
  31. package/dist/elements/carousel.d.ts +92 -0
  32. package/dist/elements/carousel.js +1112 -0
  33. package/dist/elements/color-picker.d.ts +24 -0
  34. package/dist/elements/color-picker.js +1004 -0
  35. package/dist/elements/combobox.d.ts +1 -0
  36. package/dist/elements/combobox.js +1012 -0
  37. package/dist/elements/data-grid-model.d.ts +117 -0
  38. package/dist/elements/data-grid-model.js +294 -0
  39. package/dist/elements/data-grid.d.ts +29 -0
  40. package/dist/elements/data-grid.js +1567 -0
  41. package/dist/elements/date-picker.d.ts +1 -0
  42. package/dist/elements/date-picker.js +486 -0
  43. package/dist/elements/dialog.d.ts +23 -0
  44. package/dist/elements/dialog.js +409 -0
  45. package/dist/elements/divider.d.ts +2 -0
  46. package/dist/elements/divider.js +66 -0
  47. package/dist/elements/drawer.d.ts +3 -0
  48. package/dist/elements/drawer.js +308 -0
  49. package/dist/elements/field-composition.d.ts +26 -0
  50. package/dist/elements/field-composition.js +133 -0
  51. package/dist/elements/field.d.ts +1 -0
  52. package/dist/elements/field.js +67 -0
  53. package/dist/elements/file-upload.d.ts +6 -0
  54. package/dist/elements/file-upload.js +211 -0
  55. package/dist/elements/floating-position.d.ts +26 -0
  56. package/dist/elements/floating-position.js +39 -0
  57. package/dist/elements/image.d.ts +28 -0
  58. package/dist/elements/image.js +38 -0
  59. package/dist/elements/info.d.ts +9 -0
  60. package/dist/elements/info.js +102 -0
  61. package/dist/elements/input.d.ts +5 -0
  62. package/dist/elements/input.js +255 -0
  63. package/dist/elements/label.d.ts +15 -0
  64. package/dist/elements/label.js +56 -0
  65. package/dist/elements/link.d.ts +1 -0
  66. package/dist/elements/link.js +92 -0
  67. package/dist/elements/list.d.ts +19 -0
  68. package/dist/elements/list.js +297 -0
  69. package/dist/elements/menu.d.ts +33 -0
  70. package/dist/elements/menu.js +1103 -0
  71. package/dist/elements/message-bar.d.ts +10 -0
  72. package/dist/elements/message-bar.js +299 -0
  73. package/dist/elements/nav.d.ts +32 -0
  74. package/dist/elements/nav.js +791 -0
  75. package/dist/elements/overflow.d.ts +9 -0
  76. package/dist/elements/overflow.js +218 -0
  77. package/dist/elements/persona.d.ts +3 -0
  78. package/dist/elements/persona.js +125 -0
  79. package/dist/elements/popover.d.ts +77 -0
  80. package/dist/elements/popover.js +840 -0
  81. package/dist/elements/progress-bar.d.ts +4 -0
  82. package/dist/elements/progress-bar.js +82 -0
  83. package/dist/elements/radio-group.d.ts +1 -0
  84. package/dist/elements/radio-group.js +303 -0
  85. package/dist/elements/rating-display.d.ts +2 -0
  86. package/dist/elements/rating-display.js +125 -0
  87. package/dist/elements/rating.d.ts +2 -0
  88. package/dist/elements/rating.js +206 -0
  89. package/dist/elements/rich-text-editor.d.ts +18 -0
  90. package/dist/elements/rich-text-editor.js +508 -0
  91. package/dist/elements/search.d.ts +3 -0
  92. package/dist/elements/search.js +207 -0
  93. package/dist/elements/select.d.ts +6 -0
  94. package/dist/elements/select.js +291 -0
  95. package/dist/elements/shared.d.ts +19 -0
  96. package/dist/elements/shared.js +396 -0
  97. package/dist/elements/skeleton.d.ts +6 -0
  98. package/dist/elements/skeleton.js +91 -0
  99. package/dist/elements/slider.d.ts +1 -0
  100. package/dist/elements/slider.js +248 -0
  101. package/dist/elements/spin-button.d.ts +7 -0
  102. package/dist/elements/spin-button.js +499 -0
  103. package/dist/elements/spinner.d.ts +4 -0
  104. package/dist/elements/spinner.js +124 -0
  105. package/dist/elements/swatch-picker.d.ts +5 -0
  106. package/dist/elements/swatch-picker.js +363 -0
  107. package/dist/elements/table.d.ts +21 -0
  108. package/dist/elements/table.js +261 -0
  109. package/dist/elements/tabs.d.ts +1 -0
  110. package/dist/elements/tabs.js +276 -0
  111. package/dist/elements/tag-picker.d.ts +29 -0
  112. package/dist/elements/tag-picker.js +697 -0
  113. package/dist/elements/tags.d.ts +21 -0
  114. package/dist/elements/tags.js +421 -0
  115. package/dist/elements/teaching-popover.d.ts +32 -0
  116. package/dist/elements/teaching-popover.js +412 -0
  117. package/dist/elements/text.d.ts +9 -0
  118. package/dist/elements/text.js +75 -0
  119. package/dist/elements/textarea.d.ts +1 -0
  120. package/dist/elements/textarea.js +182 -0
  121. package/dist/elements/toast.d.ts +25 -0
  122. package/dist/elements/toast.js +337 -0
  123. package/dist/elements/toaster.d.ts +6 -0
  124. package/dist/elements/toaster.js +356 -0
  125. package/dist/elements/toggle.d.ts +2 -0
  126. package/dist/elements/toggle.js +246 -0
  127. package/dist/elements/toolbar.d.ts +12 -0
  128. package/dist/elements/toolbar.js +381 -0
  129. package/dist/elements/tooltip.d.ts +76 -0
  130. package/dist/elements/tooltip.js +510 -0
  131. package/dist/elements/tree-model.d.ts +19 -0
  132. package/dist/elements/tree-model.js +34 -0
  133. package/dist/elements/tree.d.ts +5 -0
  134. package/dist/elements/tree.js +273 -0
  135. package/dist/elements/view-card.d.ts +2 -0
  136. package/dist/elements/view-card.js +78 -0
  137. package/dist/elements/virtual-list.d.ts +41 -0
  138. package/dist/elements/virtual-list.js +369 -0
  139. package/dist/elements.d.ts +72 -0
  140. package/dist/elements.js +207 -0
  141. package/dist/index.d.ts +76 -0
  142. package/dist/index.js +66 -0
  143. package/dist/react.d.ts +4546 -0
  144. package/dist/react.js +6837 -0
  145. package/dist/theme.d.ts +169 -0
  146. package/dist/theme.js +167 -0
  147. package/dist/virtualizer-hooks.d.ts +80 -0
  148. package/dist/virtualizer-hooks.js +253 -0
  149. package/package.json +87 -4
  150. package/scripts/generate-token-index.mjs +43 -0
  151. package/scripts/sync-component-catalog-signatures.mjs +55 -0
  152. package/scripts/validate-component-catalog.mjs +44 -0
  153. package/skills/sharepoint-ui/SKILL.md +12 -0
  154. package/skills/sharepoint-ui/references/choosing-components.md +20 -0
  155. package/skills/sharepoint-ui/references/sharepoint-patterns.md +17 -0
  156. package/tokens.json +3777 -0
@@ -0,0 +1,21 @@
1
+ export type TagAppearance = "filled" | "outline" | "brand";
2
+ export type TagShape = "rounded" | "circular";
3
+ export type TagSize = "extra-small" | "small" | "medium";
4
+ export type InteractionTagSelectData = {
5
+ value: string;
6
+ selected: boolean;
7
+ };
8
+ export type TagGroupSelectData = {
9
+ event: Event;
10
+ type: "click";
11
+ value: string;
12
+ selectedValues: string[];
13
+ };
14
+ export interface SharePointTagGroupElement extends HTMLElement {
15
+ selectedValues: string[];
16
+ }
17
+ export declare function defineTag(): void;
18
+ export declare function defineTagGroup(): void;
19
+ export declare function defineInteractionTagPrimary(): void;
20
+ export declare function defineInteractionTagSecondary(): void;
21
+ export declare function defineInteractionTag(): void;
@@ -0,0 +1,421 @@
1
+ import { base } from "./shared.js";
2
+ export function defineTag() {
3
+ if (customElements.get("spui-tag"))
4
+ return;
5
+ class SpuiTag extends HTMLElement {
6
+ static observedAttributes = ["dismissible", "dismiss-label", "label", "disabled", "selected"];
7
+ connectedCallback() {
8
+ if (!this.shadowRoot)
9
+ this.render();
10
+ this.updateDismissButton();
11
+ }
12
+ attributeChangedCallback() { if (this.isConnected)
13
+ this.updateDismissButton(); }
14
+ updateDismissButton() {
15
+ const root = this.shadowRoot;
16
+ if (!root)
17
+ return;
18
+ let button = root.querySelector("button");
19
+ if (!this.hasAttribute("dismissible")) {
20
+ button?.remove();
21
+ return;
22
+ }
23
+ if (!button) {
24
+ button = document.createElement("button");
25
+ button.type = "button";
26
+ button.className = "dismiss";
27
+ button.addEventListener("click", event => this.dispatchEvent(new CustomEvent("spui-dismiss", { detail: { value: this.getAttribute("value") ?? "", label: this.getAttribute("label") ?? this.textContent?.trim() ?? "", originalEvent: event }, bubbles: true, composed: true })));
28
+ const icon = document.createElement("slot");
29
+ icon.name = "dismiss-icon";
30
+ const fallback = document.createElement("span");
31
+ fallback.setAttribute("aria-hidden", "true");
32
+ fallback.textContent = "×";
33
+ icon.append(fallback);
34
+ button.append(icon);
35
+ root.append(button);
36
+ }
37
+ button.disabled = this.hasAttribute("disabled");
38
+ const primary = root.querySelector(".primary-text");
39
+ const primaryText = primary?.assignedNodes({ flatten: true }).map(node => node.textContent ?? "").join("").trim();
40
+ button.setAttribute("aria-label", `${this.getAttribute("dismiss-label") || "Remove"} ${this.getAttribute("label") || primaryText || this.textContent?.trim() || "tag"}`);
41
+ }
42
+ render() {
43
+ const shadow = this.attachShadow({ mode: "open" });
44
+ const style = document.createElement("style");
45
+ style.textContent = `${base}:host{box-sizing:border-box;display:inline-flex;align-items:center;gap:6px;max-width:100%;border:1px solid var(--spui-tag-border,var(--spui-base-stroke,var(--spui-ui-stroke,var(--spui-semantic-control-border,#8a8886))));border-radius:var(--spui-control-radius,4px);background:var(--spui-tag-background,color-mix(in srgb,var(--spui-base-accent,var(--spui-ui-accent,#0078d4)) 30%,var(--spui-base-surface,var(--spui-ui-surface,#fff))));color:var(--spui-tag-color,var(--spui-ui-text,var(--spui-semantic-body-text,#323130)));font-size:var(--spui-tag-font-size,13px);font-weight:500;line-height:1.25;white-space:nowrap}:host([size=extra-small]){min-height:18px;padding-block:1px;padding-inline:6px;font-size:10px}:host([size=small]){min-height:22px;padding-block:2px;padding-inline:7px;font-size:11px}:host(:not([size]),[size=medium]){min-height:28px;padding-block:4px;padding-inline:9px}:host([size=large]){min-height:34px;padding-block:6px;padding-inline:12px;font-size:14px}:host([shape=circular]){border-radius:999px}:host([appearance=outline]){background:var(--spui-base-surface,var(--spui-ui-surface,#fff))}:host([appearance=brand]){border-color:color-mix(in srgb,var(--spui-ui-accent,var(--spui-semantic-accent,#0078d4)) 64%,var(--spui-base-surface,var(--spui-ui-surface,#fff)));background:color-mix(in srgb,var(--spui-ui-accent,var(--spui-semantic-accent,#0078d4)) 42%,var(--spui-base-surface,var(--spui-ui-surface,#fff)))}:host([selected]){border-color:var(--spui-ui-accent,var(--spui-semantic-accent,#0078d4));background:color-mix(in srgb,var(--spui-ui-accent,var(--spui-semantic-accent,#0078d4)) 16%,var(--spui-ui-surface,#fff))}:host([disabled]){opacity:.55}.media,.icon{display:inline-flex;align-items:center;justify-content:center;flex:none}.text{display:grid;gap:2px;min-width:0}.label{min-width:0;overflow:hidden;text-overflow:ellipsis}.secondary{overflow:hidden;color:var(--spui-ui-muted,var(--spui-semantic-body-subtext,#616161));font-size:.9em;text-overflow:ellipsis}.dismiss{display:inline-grid;place-items:center;flex:none;width:20px;height:20px;margin-inline-end:-5px;padding:0;border:0;border-radius:50%;background:transparent;color:inherit;font-size:17px;line-height:1;cursor:pointer}.dismiss:hover{background:color-mix(in srgb,currentColor 12%,transparent)}.dismiss:focus-visible{outline:2px solid var(--spui-focus-ring,var(--spui-ui-accent,#0078d4));outline-offset:1px}.dismiss:disabled{cursor:not-allowed}.media[hidden],.icon[hidden],.secondary[hidden]{display:none}@media(forced-colors:active){:host{border-color:CanvasText}:host([selected]){outline:1px solid Highlight}.dismiss:focus-visible{outline-color:Highlight}}`;
46
+ style.textContent += `:host([color=success]){--spui-tag-tone:var(--spui-ui-success,#107c10)}:host([color=warning]){--spui-tag-tone:var(--spui-ui-warning,#835b00)}:host([color=danger]){--spui-tag-tone:var(--spui-ui-danger,#b10e1c)}:host([color=informative]){--spui-tag-tone:var(--spui-ui-info,var(--spui-ui-accent,#0078d4))}:host([color=success]),:host([color=warning]),:host([color=danger]),:host([color=informative]){--spui-tag-foreground:color-mix(in srgb,var(--spui-tag-tone) 40%,var(--spui-ui-text,#242424) 60%);color:var(--spui-tag-foreground);border-color:var(--spui-tag-foreground)}:host([color=success]:not([appearance=outline]):not([selected])),:host([color=warning]:not([appearance=outline]):not([selected])),:host([color=danger]:not([appearance=outline]):not([selected])),:host([color=informative]:not([appearance=outline]):not([selected])){background:color-mix(in srgb,var(--spui-tag-tone) 12%,var(--spui-base-surface,var(--spui-ui-surface,#fff)))}:host([color=success][appearance=brand]:not([selected])),:host([color=warning][appearance=brand]:not([selected])),:host([color=danger][appearance=brand]:not([selected])),:host([color=informative][appearance=brand]:not([selected])){background:color-mix(in srgb,var(--spui-tag-tone) 24%,var(--spui-base-surface,var(--spui-ui-surface,#fff)))}`;
47
+ style.textContent += `:host([selected][color=success]),:host([selected][color=warning]),:host([selected][color=danger]),:host([selected][color=informative]){color:var(--spui-selection-foreground,var(--spui-ui-text,#242424));border-color:var(--spui-selection-foreground,var(--spui-ui-text,#242424))}@media(forced-colors:active){:host([color=success]),:host([color=warning]),:host([color=danger]),:host([color=informative]){color:CanvasText;border-color:CanvasText;background:Canvas}:host([selected][color=success]),:host([selected][color=warning]),:host([selected][color=danger]),:host([selected][color=informative]){outline:1px solid Highlight}}`;
48
+ const media = document.createElement("span");
49
+ media.className = "media";
50
+ media.hidden = true;
51
+ const mediaSlot = document.createElement("slot");
52
+ mediaSlot.name = "media";
53
+ media.append(mediaSlot);
54
+ const icon = document.createElement("span");
55
+ icon.className = "icon";
56
+ icon.hidden = true;
57
+ const iconSlot = document.createElement("slot");
58
+ iconSlot.name = "icon";
59
+ icon.append(iconSlot);
60
+ const text = document.createElement("span");
61
+ text.className = "text";
62
+ const label = document.createElement("span");
63
+ label.className = "label";
64
+ label.part.add("label");
65
+ const primarySlot = document.createElement("slot");
66
+ primarySlot.name = "primary-text";
67
+ const defaultSlot = document.createElement("slot");
68
+ label.append(primarySlot);
69
+ primarySlot.append(defaultSlot);
70
+ const secondary = document.createElement("span");
71
+ secondary.className = "secondary";
72
+ secondary.hidden = true;
73
+ secondary.part.add("secondary-text");
74
+ const secondarySlot = document.createElement("slot");
75
+ secondarySlot.name = "secondary-text";
76
+ secondary.append(secondarySlot);
77
+ text.append(label, secondary);
78
+ for (const [slot, container] of [[mediaSlot, media], [iconSlot, icon], [secondarySlot, secondary]]) {
79
+ slot.addEventListener("slotchange", () => { container.hidden = !slot.assignedNodes({ flatten: true }).length; this.updateDismissButton(); });
80
+ }
81
+ primarySlot.addEventListener("slotchange", () => this.updateDismissButton());
82
+ defaultSlot.addEventListener("slotchange", () => this.updateDismissButton());
83
+ shadow.append(style, media, icon, text);
84
+ }
85
+ }
86
+ customElements.define("spui-tag", SpuiTag);
87
+ }
88
+ export function defineTagGroup() {
89
+ if (customElements.get("spui-tag-group"))
90
+ return;
91
+ class SpuiTagGroup extends HTMLElement {
92
+ static observedAttributes = ["orientation", "label", "selected-values", "default-selected-values", "disabled", "dismissible", "appearance", "size", "role"];
93
+ observer;
94
+ values = [];
95
+ controlled = false;
96
+ initialized = false;
97
+ syncing = false;
98
+ childBase = new WeakMap();
99
+ childApplied = new WeakMap();
100
+ get selectedValues() { return [...this.values]; }
101
+ set selectedValues(value) {
102
+ this.controlled = true;
103
+ this.values = Array.isArray(value) ? value.map(String) : [];
104
+ this.initialized = true;
105
+ this.sync();
106
+ }
107
+ connectedCallback() {
108
+ if (!this.shadowRoot)
109
+ this.render();
110
+ if (!this.hasAttribute("role"))
111
+ this.setAttribute("role", "toolbar");
112
+ if (!this.hasAttribute("aria-label") && this.hasAttribute("label"))
113
+ this.setAttribute("aria-label", this.getAttribute("label"));
114
+ if (!this.initialized) {
115
+ const defaults = this.readValues(this.getAttribute("default-selected-values"));
116
+ this.values = this.readValues(this.getAttribute("selected-values") ?? JSON.stringify(defaults));
117
+ this.controlled = this.hasAttribute("selected-values");
118
+ this.initialized = true;
119
+ }
120
+ this.addEventListener("spui-tag-select", this.onTagSelect);
121
+ this.addEventListener("spui-dismiss", this.onTagDismiss);
122
+ this.addEventListener("keydown", this.onKeyDown);
123
+ this.observer?.disconnect();
124
+ this.observer = new MutationObserver(() => this.sync());
125
+ this.observer.observe(this, { childList: true, subtree: true, attributes: true, attributeFilter: ["disabled", "dismissible", "appearance", "size", "selected", "value"] });
126
+ this.sync();
127
+ }
128
+ disconnectedCallback() {
129
+ this.observer?.disconnect();
130
+ this.removeEventListener("spui-tag-select", this.onTagSelect);
131
+ this.removeEventListener("spui-dismiss", this.onTagDismiss);
132
+ this.removeEventListener("keydown", this.onKeyDown);
133
+ }
134
+ attributeChangedCallback(name) {
135
+ if (!this.isConnected)
136
+ return;
137
+ if (name === "selected-values") {
138
+ this.controlled = this.hasAttribute("selected-values");
139
+ if (this.controlled)
140
+ this.values = this.readValues(this.getAttribute("selected-values"));
141
+ }
142
+ this.sync();
143
+ }
144
+ render() {
145
+ const shadow = this.attachShadow({ mode: "open" });
146
+ const style = document.createElement("style");
147
+ style.textContent = `${base}:host{display:flex;flex-wrap:wrap;align-items:center;gap:var(--spui-tag-group-gap,8px);min-width:0}:host([orientation=vertical]){flex-direction:column;align-items:stretch}:host(:focus-visible){outline:2px solid var(--spui-focus-ring,var(--spui-ui-accent,#0078d4));outline-offset:2px}@media(forced-colors:active){:host(:focus-visible){outline-color:Highlight}}`;
148
+ const slot = document.createElement("slot");
149
+ shadow.append(style, slot);
150
+ }
151
+ readValues(raw) {
152
+ if (!raw)
153
+ return [];
154
+ try {
155
+ const value = JSON.parse(raw);
156
+ return Array.isArray(value) ? value.map(String) : [];
157
+ }
158
+ catch {
159
+ return raw.split(",").map(value => value.trim()).filter(Boolean);
160
+ }
161
+ }
162
+ sync() {
163
+ if (!this.isConnected || this.syncing)
164
+ return;
165
+ this.syncing = true;
166
+ try {
167
+ if (this.hasAttribute("label") && !this.hasAttribute("aria-label"))
168
+ this.setAttribute("aria-label", this.getAttribute("label"));
169
+ this.setAttribute("aria-disabled", String(this.hasAttribute("disabled")));
170
+ const children = [...this.querySelectorAll("spui-tag,spui-interaction-tag")].filter(child => child.closest("spui-tag-group") === this);
171
+ const groupDefaults = ["disabled", "dismissible", "appearance", "size"];
172
+ for (const [index, child] of children.entries()) {
173
+ if (!child.hasAttribute("value"))
174
+ child.setAttribute("value", `spui-tag-group-${index + 1}`);
175
+ let baseState = this.childBase.get(child);
176
+ let applied = this.childApplied.get(child);
177
+ if (!baseState) {
178
+ baseState = Object.fromEntries([...groupDefaults, "selected"].map(name => [name, child.getAttribute(name)]));
179
+ this.childBase.set(child, baseState);
180
+ applied = {};
181
+ }
182
+ else {
183
+ for (const name of [...groupDefaults, "selected"])
184
+ if (child.getAttribute(name) !== applied?.[name])
185
+ baseState[name] = child.getAttribute(name);
186
+ }
187
+ const next = {};
188
+ for (const name of groupDefaults) {
189
+ let value = baseState[name] ?? null;
190
+ if (name === "disabled" && this.hasAttribute("disabled"))
191
+ value = "";
192
+ else if (name === "dismissible" && value === null && this.hasAttribute("dismissible"))
193
+ value = "";
194
+ else if (name === "appearance" && value === null)
195
+ value = this.getAttribute("appearance");
196
+ else if (name === "size" && value === null)
197
+ value = this.getAttribute("size");
198
+ next[name] = value;
199
+ }
200
+ const selected = (baseState.selected === "" || this.values.includes(child.getAttribute("value"))) ? "" : null;
201
+ next.selected = selected;
202
+ for (const name of [...groupDefaults, "selected"]) {
203
+ const value = next[name];
204
+ if (value === null) {
205
+ if (child.hasAttribute(name))
206
+ child.removeAttribute(name);
207
+ }
208
+ else if (child.getAttribute(name) !== value)
209
+ child.setAttribute(name, value);
210
+ }
211
+ this.childApplied.set(child, next);
212
+ }
213
+ }
214
+ finally {
215
+ this.syncing = false;
216
+ }
217
+ }
218
+ onTagSelect = (event) => {
219
+ if (this.hasAttribute("disabled") || event.defaultPrevented) {
220
+ event.preventDefault();
221
+ return;
222
+ }
223
+ const value = String(event.detail?.value ?? "");
224
+ const next = this.values.includes(value) ? this.values.filter(item => item !== value) : [...this.values, value];
225
+ if (!this.controlled)
226
+ this.values = next;
227
+ this.sync();
228
+ this.dispatchEvent(new CustomEvent("spui-selection-change", { bubbles: true, composed: true, detail: { event: event.detail?.originalEvent ?? event, type: "click", value, selectedValues: next } }));
229
+ };
230
+ onTagDismiss = (event) => {
231
+ if (this.hasAttribute("disabled")) {
232
+ event.preventDefault();
233
+ return;
234
+ }
235
+ this.dispatchEvent(new CustomEvent("spui-tag-dismiss", { bubbles: true, composed: true, detail: { value: String(event.detail?.value ?? ""), sourceEvent: event.detail?.originalEvent ?? event } }));
236
+ };
237
+ focusableItems() {
238
+ const result = [];
239
+ const visit = (root) => {
240
+ for (const node of root.querySelectorAll("button,a[href],[tabindex]")) {
241
+ if (!node.hasAttribute("disabled") && node.tabIndex >= 0 && node.getClientRects().length)
242
+ result.push(node);
243
+ }
244
+ for (const node of root.querySelectorAll("*")) {
245
+ if (node.shadowRoot)
246
+ visit(node.shadowRoot);
247
+ if (node instanceof HTMLSlotElement)
248
+ for (const assigned of node.assignedElements({ flatten: true }))
249
+ visit(assigned);
250
+ }
251
+ };
252
+ for (const child of this.querySelectorAll("spui-tag,spui-interaction-tag"))
253
+ if (child.closest("spui-tag-group") === this)
254
+ visit(child.shadowRoot ?? child);
255
+ return [...new Set(result)];
256
+ }
257
+ onKeyDown = (event) => {
258
+ const items = this.focusableItems();
259
+ if (!items.length)
260
+ return;
261
+ const active = event.composedPath().find((node) => node instanceof HTMLElement && items.includes(node));
262
+ const from = active ? items.indexOf(active) : -1;
263
+ let next = -1;
264
+ if (event.key === "Home")
265
+ next = 0;
266
+ else if (event.key === "End")
267
+ next = items.length - 1;
268
+ else if (event.key === "ArrowDown" || event.key === (getComputedStyle(this).direction === "rtl" ? "ArrowLeft" : "ArrowRight"))
269
+ next = (from + 1 + items.length) % items.length;
270
+ else if (event.key === "ArrowUp" || event.key === (getComputedStyle(this).direction === "rtl" ? "ArrowRight" : "ArrowLeft"))
271
+ next = (from - 1 + items.length) % items.length;
272
+ if (next >= 0) {
273
+ event.preventDefault();
274
+ items[next].focus();
275
+ }
276
+ };
277
+ }
278
+ customElements.define("spui-tag-group", SpuiTagGroup);
279
+ }
280
+ export function defineInteractionTagPrimary() {
281
+ if (customElements.get("spui-interaction-tag-primary"))
282
+ return;
283
+ class SpuiInteractionTagPrimary extends HTMLElement {
284
+ static observedAttributes = ["disabled", "selected", "has-secondary-action", "size"];
285
+ button;
286
+ connectedCallback() { if (!this.shadowRoot)
287
+ this.render(); this.sync(); }
288
+ attributeChangedCallback() { this.sync(); }
289
+ render() {
290
+ const shadow = this.attachShadow({ mode: "open", delegatesFocus: true });
291
+ const style = document.createElement("style");
292
+ style.textContent = `${base}:host{display:inline-flex;min-width:0}button{box-sizing:border-box;display:inline-flex;align-items:center;gap:6px;min-width:0;min-height:28px;padding:4px 10px;border:0;border-radius:inherit;background:transparent;color:inherit;font:inherit;text-align:start;cursor:pointer}button:hover{background:color-mix(in srgb,currentColor 8%,transparent)}button:focus-visible{position:relative;z-index:1;outline:2px solid var(--spui-focus-ring,var(--spui-ui-accent,var(--spui-semantic-focus-border,var(--colorStrokeFocus2,#0078d4))));outline-offset:1px}:host([disabled]) button{cursor:not-allowed}:host([has-secondary-action]) button{padding-inline-end:4px}:host([size=small]) button{min-height:22px;padding-block:2px}:host([size=extra-small]) button{min-height:18px;padding-block:1px;font-size:12px}.media:empty,.icon:empty,.secondary:empty{display:none}.media,.icon,.secondary{display:inline-flex;align-items:center;flex:none}.text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}button[aria-pressed=true]{font-weight:600}@media(forced-colors:active){button:focus-visible{outline-color:Highlight}}`;
293
+ const button = document.createElement("button");
294
+ button.type = "button";
295
+ button.part.add("button");
296
+ const media = document.createElement("span");
297
+ media.className = "media";
298
+ media.append(Object.assign(document.createElement("slot"), { name: "media" }));
299
+ const icon = document.createElement("span");
300
+ icon.className = "icon";
301
+ icon.append(Object.assign(document.createElement("slot"), { name: "icon" }));
302
+ const text = document.createElement("span");
303
+ text.className = "text";
304
+ const primaryText = document.createElement("slot");
305
+ primaryText.name = "primary-text";
306
+ primaryText.append(document.createElement("slot"));
307
+ text.append(primaryText);
308
+ const secondary = document.createElement("span");
309
+ secondary.className = "secondary";
310
+ secondary.append(Object.assign(document.createElement("slot"), { name: "secondary-text" }));
311
+ button.append(media, icon, text, secondary);
312
+ button.addEventListener("click", event => {
313
+ const owner = this.closest("spui-interaction-tag");
314
+ if (owner)
315
+ owner.dispatchEvent(new CustomEvent("spui-tag-select", { bubbles: true, composed: true, cancelable: true, detail: { value: owner.getAttribute("value") ?? "", selected: owner.hasAttribute("selected"), originalEvent: event } }));
316
+ });
317
+ this.button = button;
318
+ shadow.append(style, button);
319
+ }
320
+ sync() {
321
+ if (!this.button)
322
+ return;
323
+ this.button.disabled = this.hasAttribute("disabled");
324
+ if (this.hasAttribute("selected"))
325
+ this.button.setAttribute("aria-pressed", String(this.getAttribute("selected") !== "false"));
326
+ else
327
+ this.button.removeAttribute("aria-pressed");
328
+ }
329
+ }
330
+ customElements.define("spui-interaction-tag-primary", SpuiInteractionTagPrimary);
331
+ }
332
+ export function defineInteractionTagSecondary() {
333
+ if (customElements.get("spui-interaction-tag-secondary"))
334
+ return;
335
+ class SpuiInteractionTagSecondary extends HTMLElement {
336
+ static observedAttributes = ["disabled", "label", "remove-label"];
337
+ button;
338
+ connectedCallback() { if (!this.shadowRoot)
339
+ this.render(); this.sync(); }
340
+ attributeChangedCallback() { this.sync(); }
341
+ render() {
342
+ const shadow = this.attachShadow({ mode: "open", delegatesFocus: true });
343
+ const style = document.createElement("style");
344
+ style.textContent = `${base}:host{display:inline-flex;flex:none}button{display:grid;place-items:center;width:26px;min-height:28px;padding:0;border:0;border-radius:inherit;background:transparent;color:inherit;font:inherit;cursor:pointer}button:hover{background:color-mix(in srgb,currentColor 10%,transparent)}button:focus-visible{position:relative;z-index:1;outline:2px solid var(--spui-focus-ring,var(--spui-ui-accent,var(--spui-semantic-focus-border,var(--colorStrokeFocus2,#0078d4))));outline-offset:1px}:host([disabled]) button{cursor:not-allowed}.mark{font-size:17px;line-height:1}@media(forced-colors:active){button:focus-visible{outline-color:Highlight}}`;
345
+ const button = document.createElement("button");
346
+ button.type = "button";
347
+ button.part.add("button");
348
+ button.innerHTML = '<span class="mark" aria-hidden="true">×</span><slot></slot>';
349
+ button.addEventListener("click", event => {
350
+ const owner = this.closest("spui-interaction-tag");
351
+ if (owner)
352
+ owner.dispatchEvent(new CustomEvent("spui-dismiss", { bubbles: true, composed: true, cancelable: true, detail: { value: owner.getAttribute("value") ?? "", originalEvent: event } }));
353
+ });
354
+ this.button = button;
355
+ shadow.append(style, button);
356
+ }
357
+ sync() {
358
+ if (!this.button)
359
+ return;
360
+ this.button.disabled = this.hasAttribute("disabled");
361
+ const owner = this.closest("spui-interaction-tag");
362
+ const label = this.getAttribute("label") ?? `${this.getAttribute("remove-label") ?? "Remove"} ${owner?.getAttribute("label") ?? owner?.getAttribute("value") ?? "tag"}`;
363
+ this.button.setAttribute("aria-label", label);
364
+ }
365
+ }
366
+ customElements.define("spui-interaction-tag-secondary", SpuiInteractionTagSecondary);
367
+ }
368
+ export function defineInteractionTag() {
369
+ defineInteractionTagPrimary();
370
+ defineInteractionTagSecondary();
371
+ if (customElements.get("spui-interaction-tag"))
372
+ return;
373
+ class SpuiInteractionTag extends HTMLElement {
374
+ static observedAttributes = ["appearance", "disabled", "selected", "shape", "size", "value"];
375
+ observer;
376
+ connectedCallback() {
377
+ this.style.display ||= "inline-flex";
378
+ this.style.alignItems ||= "center";
379
+ this.style.maxWidth ||= "100%";
380
+ this.observer?.disconnect();
381
+ this.observer = new MutationObserver(() => this.sync());
382
+ this.observer.observe(this, { childList: true });
383
+ this.sync();
384
+ }
385
+ disconnectedCallback() { this.observer?.disconnect(); }
386
+ attributeChangedCallback() { this.sync(); }
387
+ sync() {
388
+ this.style.border ||= "1px solid var(--spui-tag-border,var(--spui-ui-stroke,var(--spui-semantic-body-divider,var(--colorNeutralStroke2,#8a8886))))";
389
+ this.style.borderRadius = this.getAttribute("shape") === "circular" ? "999px" : "var(--spui-control-radius,8px)";
390
+ this.style.background = this.getAttribute("appearance") === "outline" ? "var(--spui-ui-surface,var(--spui-semantic-card-background,var(--colorNeutralBackground1,#fff)))" : this.getAttribute("appearance") === "brand" ? "color-mix(in srgb,var(--spui-ui-accent,var(--spui-semantic-primary-button-background,var(--colorBrandBackground,#78716c))) 22%,var(--spui-ui-surface,var(--spui-semantic-card-background,var(--colorNeutralBackground1,#fff))))" : "color-mix(in srgb,var(--spui-ui-accent,var(--spui-semantic-primary-button-background,var(--colorBrandBackground,#78716c))) 12%,var(--spui-ui-surface,var(--spui-semantic-card-background,var(--colorNeutralBackground1,#fff))))";
391
+ this.style.color = "var(--spui-ui-text,var(--spui-semantic-body-text,var(--colorNeutralForeground1,inherit)))";
392
+ this.style.fontFamily = "var(--spui-font-family,inherit)";
393
+ this.toggleAttribute("data-selected", this.hasAttribute("selected"));
394
+ const primary = this.querySelector("spui-interaction-tag-primary");
395
+ const secondary = this.querySelector("spui-interaction-tag-secondary");
396
+ if (primary)
397
+ for (const name of ["disabled", "selected", "appearance", "shape", "size"]) {
398
+ if (this.hasAttribute(name))
399
+ primary.setAttribute(name, this.getAttribute(name));
400
+ else
401
+ primary.removeAttribute(name);
402
+ }
403
+ if (primary) {
404
+ const explicit = primary.hasAttribute("data-spui-explicit-has-secondary-action") || (primary.hasAttribute("has-secondary-action") && !primary.hasAttribute("data-spui-generated-has-secondary-action"));
405
+ if (secondary || explicit)
406
+ primary.setAttribute("has-secondary-action", "");
407
+ else
408
+ primary.removeAttribute("has-secondary-action");
409
+ primary.toggleAttribute("data-spui-generated-has-secondary-action", Boolean(secondary) && !explicit);
410
+ }
411
+ if (secondary)
412
+ for (const name of ["disabled", "appearance", "shape", "size"]) {
413
+ if (this.hasAttribute(name))
414
+ secondary.setAttribute(name, this.getAttribute(name));
415
+ else
416
+ secondary.removeAttribute(name);
417
+ }
418
+ }
419
+ }
420
+ customElements.define("spui-interaction-tag", SpuiInteractionTag);
421
+ }
@@ -0,0 +1,32 @@
1
+ export type TeachingPopoverAnnouncementFunction = (newValue: string) => string;
2
+ export type TeachingPopoverCarouselValueChangeType = "click" | "keydown" | "programmatic";
3
+ export type TeachingPopoverCarouselValueChangeDetail = {
4
+ value?: string;
5
+ event?: Event;
6
+ type: TeachingPopoverCarouselValueChangeType;
7
+ currentPage?: number;
8
+ totalPages?: number;
9
+ };
10
+ export type TeachingPopoverFinishDetail = {
11
+ value?: string;
12
+ event?: Event;
13
+ type: "click";
14
+ };
15
+ export type TeachingPopoverAnnouncementDetail = {
16
+ value: string;
17
+ message: string;
18
+ currentPage: number;
19
+ totalPages: number;
20
+ };
21
+ export interface SharePointTeachingPopoverCarouselElement extends HTMLElement {
22
+ value: string;
23
+ defaultValue: string;
24
+ announcement?: TeachingPopoverAnnouncementFunction;
25
+ }
26
+ declare global {
27
+ interface HTMLElementTagNameMap {
28
+ "spui-teaching-popover-carousel": SharePointTeachingPopoverCarouselElement;
29
+ }
30
+ }
31
+ /** Register the framework-neutral TeachingPopover and its composable guided-tour parts. */
32
+ export declare function defineTeachingPopover(): void;