@spfx-fast/sharepoint-ui 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/QUICKSTART.md +18 -0
- package/README.md +19 -24
- package/components.json +240 -5694
- package/dist/accordion.d.ts +11 -0
- package/dist/accordion.js +4 -0
- package/dist/alert.d.ts +3 -0
- package/dist/alert.js +4 -0
- package/dist/attachment-list.d.ts +15 -0
- package/dist/attachment-list.js +14 -0
- package/dist/avatar-group.d.ts +12 -0
- package/dist/avatar-group.js +7 -0
- package/dist/avatar.d.ts +6 -0
- package/dist/avatar.js +5 -0
- package/dist/badge.d.ts +3 -0
- package/dist/badge.js +4 -0
- package/dist/breadcrumb.d.ts +10 -0
- package/dist/breadcrumb.js +9 -0
- package/dist/button-group.d.ts +6 -0
- package/dist/button-group.js +4 -0
- package/dist/button.d.ts +3 -0
- package/dist/button.js +4 -0
- package/dist/card.d.ts +3 -0
- package/dist/card.js +4 -0
- package/dist/carousel.d.ts +11 -0
- package/dist/carousel.js +6 -0
- package/dist/checkbox.d.ts +3 -0
- package/dist/checkbox.js +4 -0
- package/dist/combobox.d.ts +9 -0
- package/dist/combobox.js +6 -0
- package/dist/command-bar.d.ts +6 -0
- package/dist/command-bar.js +4 -0
- package/dist/copy-button.d.ts +7 -0
- package/dist/copy-button.js +19 -0
- package/dist/data-grid.d.ts +25 -0
- package/dist/data-grid.js +39 -0
- package/dist/date-range-picker.d.ts +12 -0
- package/dist/date-range-picker.js +4 -0
- package/dist/dialog.d.ts +9 -0
- package/dist/dialog.js +21 -0
- package/dist/divider.d.ts +3 -0
- package/dist/divider.js +4 -0
- package/dist/drawer.d.ts +6 -0
- package/dist/drawer.js +5 -0
- package/dist/empty-state.d.ts +7 -0
- package/dist/empty-state.js +5 -0
- package/dist/field.d.ts +15 -0
- package/dist/field.js +11 -0
- package/dist/file-dropzone.d.ts +15 -0
- package/dist/file-dropzone.js +21 -0
- package/dist/filter-bar.d.ts +9 -0
- package/dist/filter-bar.js +9 -0
- package/dist/image.d.ts +5 -0
- package/dist/image.js +4 -0
- package/dist/index.d.ts +68 -76
- package/dist/index.js +60 -66
- package/dist/input.d.ts +3 -0
- package/dist/input.js +4 -0
- package/dist/label.d.ts +3 -0
- package/dist/label.js +4 -0
- package/dist/link.d.ts +3 -0
- package/dist/link.js +9 -0
- package/dist/list-view.d.ts +29 -0
- package/dist/list-view.js +14 -0
- package/dist/list.d.ts +6 -0
- package/dist/list.js +5 -0
- package/dist/lookup-picker.d.ts +12 -0
- package/dist/lookup-picker.js +4 -0
- package/dist/menu.d.ts +6 -0
- package/dist/menu.js +4 -0
- package/dist/nav.d.ts +12 -0
- package/dist/nav.js +4 -0
- package/dist/pagination.d.ts +11 -0
- package/dist/pagination.js +5 -0
- package/dist/person-picker.d.ts +13 -0
- package/dist/person-picker.js +4 -0
- package/dist/persona.d.ts +7 -0
- package/dist/persona.js +5 -0
- package/dist/popover.d.ts +6 -0
- package/dist/popover.js +4 -0
- package/dist/progress-bar.d.ts +5 -0
- package/dist/progress-bar.js +5 -0
- package/dist/radio-group.d.ts +6 -0
- package/dist/radio-group.js +4 -0
- package/dist/radio.d.ts +3 -0
- package/dist/radio.js +4 -0
- package/dist/rating.d.ts +8 -0
- package/dist/rating.js +5 -0
- package/dist/react.d.ts +1 -4583
- package/dist/react.js +1 -6837
- package/dist/select.d.ts +3 -0
- package/dist/select.js +4 -0
- package/dist/sharepoint-field.d.ts +18 -0
- package/dist/sharepoint-field.js +54 -0
- package/dist/skeleton.d.ts +6 -0
- package/dist/skeleton.js +9 -0
- package/dist/spinner.d.ts +5 -0
- package/dist/spinner.js +4 -0
- package/dist/swatch-picker.d.ts +17 -0
- package/dist/swatch-picker.js +11 -0
- package/dist/switch.d.ts +3 -0
- package/dist/switch.js +4 -0
- package/dist/table.d.ts +6 -0
- package/dist/table.js +4 -0
- package/dist/tabs.d.ts +14 -0
- package/dist/tabs.js +30 -0
- package/dist/tag-group.d.ts +6 -0
- package/dist/tag-group.js +4 -0
- package/dist/tag-picker.d.ts +12 -0
- package/dist/tag-picker.js +4 -0
- package/dist/tag.d.ts +7 -0
- package/dist/tag.js +5 -0
- package/dist/text.d.ts +5 -0
- package/dist/text.js +4 -0
- package/dist/textarea.d.ts +3 -0
- package/dist/textarea.js +4 -0
- package/dist/theme.d.ts +15 -167
- package/dist/theme.js +36 -162
- package/dist/toast.d.ts +9 -0
- package/dist/toast.js +12 -0
- package/dist/tree.d.ts +13 -0
- package/dist/tree.js +9 -0
- package/dist/view-card.d.ts +8 -0
- package/dist/view-card.js +4 -0
- package/dist/view-switcher.d.ts +13 -0
- package/dist/view-switcher.js +7 -0
- package/dist/virtual-list.d.ts +11 -0
- package/dist/virtual-list.js +25 -0
- package/measurements.json +365 -0
- package/package.json +19 -42
- package/src/theme.css +125 -0
- package/AGENTS.md +0 -211
- package/dist/appearance.d.ts +0 -6
- package/dist/appearance.js +0 -217
- package/dist/elements/accordion.d.ts +0 -9
- package/dist/elements/accordion.js +0 -338
- package/dist/elements/alert.d.ts +0 -2
- package/dist/elements/alert.js +0 -62
- package/dist/elements/avatar-group-primitives.d.ts +0 -3
- package/dist/elements/avatar-group-primitives.js +0 -189
- package/dist/elements/avatar-group.d.ts +0 -2
- package/dist/elements/avatar-group.js +0 -110
- package/dist/elements/avatar.d.ts +0 -4
- package/dist/elements/avatar.js +0 -251
- package/dist/elements/badge.d.ts +0 -8
- package/dist/elements/badge.js +0 -182
- package/dist/elements/breadcrumb.d.ts +0 -4
- package/dist/elements/breadcrumb.js +0 -233
- package/dist/elements/button-group.d.ts +0 -1
- package/dist/elements/button-group.js +0 -20
- package/dist/elements/button-variants.d.ts +0 -6
- package/dist/elements/button-variants.js +0 -339
- package/dist/elements/button.d.ts +0 -5
- package/dist/elements/button.js +0 -233
- package/dist/elements/card-primitives.d.ts +0 -3
- package/dist/elements/card-primitives.js +0 -83
- package/dist/elements/card.d.ts +0 -5
- package/dist/elements/card.js +0 -213
- package/dist/elements/carousel.d.ts +0 -92
- package/dist/elements/carousel.js +0 -1112
- package/dist/elements/color-picker.d.ts +0 -24
- package/dist/elements/color-picker.js +0 -1004
- package/dist/elements/combobox.d.ts +0 -1
- package/dist/elements/combobox.js +0 -1012
- package/dist/elements/data-grid-model.d.ts +0 -117
- package/dist/elements/data-grid-model.js +0 -294
- package/dist/elements/data-grid.d.ts +0 -29
- package/dist/elements/data-grid.js +0 -1567
- package/dist/elements/date-picker.d.ts +0 -1
- package/dist/elements/date-picker.js +0 -486
- package/dist/elements/dialog.d.ts +0 -23
- package/dist/elements/dialog.js +0 -409
- package/dist/elements/divider.d.ts +0 -2
- package/dist/elements/divider.js +0 -66
- package/dist/elements/drawer.d.ts +0 -3
- package/dist/elements/drawer.js +0 -308
- package/dist/elements/field-composition.d.ts +0 -26
- package/dist/elements/field-composition.js +0 -133
- package/dist/elements/field.d.ts +0 -1
- package/dist/elements/field.js +0 -67
- package/dist/elements/file-upload.d.ts +0 -6
- package/dist/elements/file-upload.js +0 -211
- package/dist/elements/floating-position.d.ts +0 -26
- package/dist/elements/floating-position.js +0 -39
- package/dist/elements/image.d.ts +0 -28
- package/dist/elements/image.js +0 -38
- package/dist/elements/info.d.ts +0 -9
- package/dist/elements/info.js +0 -102
- package/dist/elements/input.d.ts +0 -5
- package/dist/elements/input.js +0 -255
- package/dist/elements/label.d.ts +0 -15
- package/dist/elements/label.js +0 -56
- package/dist/elements/link.d.ts +0 -1
- package/dist/elements/link.js +0 -92
- package/dist/elements/list.d.ts +0 -19
- package/dist/elements/list.js +0 -297
- package/dist/elements/menu.d.ts +0 -33
- package/dist/elements/menu.js +0 -1103
- package/dist/elements/message-bar.d.ts +0 -10
- package/dist/elements/message-bar.js +0 -299
- package/dist/elements/nav.d.ts +0 -32
- package/dist/elements/nav.js +0 -791
- package/dist/elements/overflow.d.ts +0 -9
- package/dist/elements/overflow.js +0 -218
- package/dist/elements/persona.d.ts +0 -3
- package/dist/elements/persona.js +0 -125
- package/dist/elements/popover.d.ts +0 -77
- package/dist/elements/popover.js +0 -840
- package/dist/elements/progress-bar.d.ts +0 -4
- package/dist/elements/progress-bar.js +0 -82
- package/dist/elements/radio-group.d.ts +0 -1
- package/dist/elements/radio-group.js +0 -303
- package/dist/elements/rating-display.d.ts +0 -2
- package/dist/elements/rating-display.js +0 -125
- package/dist/elements/rating.d.ts +0 -2
- package/dist/elements/rating.js +0 -206
- package/dist/elements/rich-text-editor.d.ts +0 -18
- package/dist/elements/rich-text-editor.js +0 -508
- package/dist/elements/search.d.ts +0 -3
- package/dist/elements/search.js +0 -207
- package/dist/elements/select.d.ts +0 -6
- package/dist/elements/select.js +0 -291
- package/dist/elements/shared.d.ts +0 -19
- package/dist/elements/shared.js +0 -396
- package/dist/elements/skeleton.d.ts +0 -6
- package/dist/elements/skeleton.js +0 -91
- package/dist/elements/slider.d.ts +0 -1
- package/dist/elements/slider.js +0 -248
- package/dist/elements/spin-button.d.ts +0 -7
- package/dist/elements/spin-button.js +0 -499
- package/dist/elements/spinner.d.ts +0 -4
- package/dist/elements/spinner.js +0 -124
- package/dist/elements/swatch-picker.d.ts +0 -5
- package/dist/elements/swatch-picker.js +0 -363
- package/dist/elements/table.d.ts +0 -21
- package/dist/elements/table.js +0 -261
- package/dist/elements/tabs.d.ts +0 -1
- package/dist/elements/tabs.js +0 -276
- package/dist/elements/tag-picker.d.ts +0 -29
- package/dist/elements/tag-picker.js +0 -697
- package/dist/elements/tags.d.ts +0 -21
- package/dist/elements/tags.js +0 -421
- package/dist/elements/teaching-popover.d.ts +0 -32
- package/dist/elements/teaching-popover.js +0 -412
- package/dist/elements/text.d.ts +0 -9
- package/dist/elements/text.js +0 -75
- package/dist/elements/textarea.d.ts +0 -1
- package/dist/elements/textarea.js +0 -182
- package/dist/elements/toast.d.ts +0 -25
- package/dist/elements/toast.js +0 -337
- package/dist/elements/toaster.d.ts +0 -6
- package/dist/elements/toaster.js +0 -356
- package/dist/elements/toggle.d.ts +0 -2
- package/dist/elements/toggle.js +0 -246
- package/dist/elements/toolbar.d.ts +0 -12
- package/dist/elements/toolbar.js +0 -381
- package/dist/elements/tooltip.d.ts +0 -76
- package/dist/elements/tooltip.js +0 -510
- package/dist/elements/tree-model.d.ts +0 -19
- package/dist/elements/tree-model.js +0 -34
- package/dist/elements/tree.d.ts +0 -5
- package/dist/elements/tree.js +0 -273
- package/dist/elements/view-card.d.ts +0 -2
- package/dist/elements/view-card.js +0 -78
- package/dist/elements/virtual-list.d.ts +0 -41
- package/dist/elements/virtual-list.js +0 -369
- package/dist/elements.d.ts +0 -72
- package/dist/elements.js +0 -207
- package/dist/virtualizer-hooks.d.ts +0 -80
- package/dist/virtualizer-hooks.js +0 -253
- package/scripts/generate-token-index.mjs +0 -43
- package/scripts/sync-component-catalog-signatures.mjs +0 -55
- package/scripts/validate-component-catalog.mjs +0 -44
- package/skills/sharepoint-ui/SKILL.md +0 -12
- package/skills/sharepoint-ui/references/choosing-components.md +0 -20
- package/skills/sharepoint-ui/references/sharepoint-patterns.md +0 -17
- package/tokens.json +0 -3777
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type MessageBarIntent = "info" | "success" | "warning" | "error";
|
|
2
|
-
export type MessageBarPoliteness = "assertive" | "polite";
|
|
3
|
-
export type MessageBarShape = "square" | "rounded";
|
|
4
|
-
export type MessageBarLayout = "auto" | "singleline" | "multiline";
|
|
5
|
-
export type MessageBarGroupAnimation = "exit-only" | "both";
|
|
6
|
-
export declare function defineMessageBarActions(): void;
|
|
7
|
-
export declare function defineMessageBarBody(): void;
|
|
8
|
-
export declare function defineMessageBarTitle(): void;
|
|
9
|
-
export declare function defineMessageBarGroup(): void;
|
|
10
|
-
export declare function defineMessageBar(): void;
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import { base } from "./shared.js";
|
|
2
|
-
let messageBarTitleSequence = 0;
|
|
3
|
-
function definePart(tag, content, css, observed = []) {
|
|
4
|
-
if (customElements.get(tag))
|
|
5
|
-
return;
|
|
6
|
-
class SpuiMessageBarPart extends HTMLElement {
|
|
7
|
-
static observedAttributes = observed;
|
|
8
|
-
resizeObserver;
|
|
9
|
-
childObserver;
|
|
10
|
-
childRects = new WeakMap();
|
|
11
|
-
connectedCallback() {
|
|
12
|
-
if (!this.shadowRoot) {
|
|
13
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
14
|
-
const root = document.createElement("div");
|
|
15
|
-
root.part.add("root");
|
|
16
|
-
const fragment = document.createRange().createContextualFragment(content);
|
|
17
|
-
const style = document.createElement("style");
|
|
18
|
-
style.textContent = `${base}:host{display:block;min-width:0;font:inherit;color:inherit;line-height:inherit}${css}`;
|
|
19
|
-
shadow.append(style, root);
|
|
20
|
-
root.append(fragment);
|
|
21
|
-
}
|
|
22
|
-
this.sync();
|
|
23
|
-
if (tag.endsWith("-group"))
|
|
24
|
-
this.observeMessageBars();
|
|
25
|
-
}
|
|
26
|
-
disconnectedCallback() { this.resizeObserver?.disconnect(); this.childObserver?.disconnect(); }
|
|
27
|
-
attributeChangedCallback() { if (this.isConnected)
|
|
28
|
-
this.sync(); }
|
|
29
|
-
sync() {
|
|
30
|
-
if (tag.endsWith("-group")) {
|
|
31
|
-
this.setAttribute("role", "group");
|
|
32
|
-
this.dataset.animate = this.getAttribute("animate") === "both" ? "both" : "exit-only";
|
|
33
|
-
}
|
|
34
|
-
if (tag.endsWith("-actions")) {
|
|
35
|
-
const parent = this.closest("spui-message-bar");
|
|
36
|
-
const layout = parent?.dataset.layout ?? parent?.getAttribute("layout");
|
|
37
|
-
if (layout)
|
|
38
|
-
this.dataset.layout = layout;
|
|
39
|
-
else
|
|
40
|
-
delete this.dataset.layout;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
observeMessageBars() {
|
|
44
|
-
const view = this.ownerDocument.defaultView;
|
|
45
|
-
if (!view)
|
|
46
|
-
return;
|
|
47
|
-
const ResizeObserverConstructor = view.ResizeObserver;
|
|
48
|
-
if (ResizeObserverConstructor && !this.resizeObserver) {
|
|
49
|
-
this.resizeObserver = new ResizeObserverConstructor(entries => {
|
|
50
|
-
for (const entry of entries)
|
|
51
|
-
if (entry.target instanceof HTMLElement && entry.target.isConnected)
|
|
52
|
-
this.childRects.set(entry.target, entry.target.getBoundingClientRect());
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
const MutationObserverConstructor = view.MutationObserver;
|
|
56
|
-
if (MutationObserverConstructor) {
|
|
57
|
-
this.childObserver ??= new MutationObserverConstructor(records => {
|
|
58
|
-
for (const record of records) {
|
|
59
|
-
for (const node of record.addedNodes)
|
|
60
|
-
if (node instanceof HTMLElement && node.localName === "spui-message-bar" && !node.hasAttribute("data-spui-exiting")) {
|
|
61
|
-
if (node.isConnected) {
|
|
62
|
-
const rect = node.getBoundingClientRect();
|
|
63
|
-
if (rect.width && rect.height)
|
|
64
|
-
this.childRects.set(node, rect);
|
|
65
|
-
this.resizeObserver?.observe(node);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
for (const node of record.removedNodes)
|
|
69
|
-
if (node instanceof HTMLElement && node.localName === "spui-message-bar" && !node.hasAttribute("data-spui-exiting"))
|
|
70
|
-
this.animateExit(node);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
this.childObserver.observe(this, { childList: true });
|
|
74
|
-
}
|
|
75
|
-
for (const bar of this.querySelectorAll(":scope > spui-message-bar"))
|
|
76
|
-
this.resizeObserver?.observe(bar);
|
|
77
|
-
}
|
|
78
|
-
animateExit(bar) {
|
|
79
|
-
const view = this.ownerDocument.defaultView;
|
|
80
|
-
const rect = this.childRects.get(bar);
|
|
81
|
-
if (!view || !rect || this.getAttribute("animate") === "none")
|
|
82
|
-
return;
|
|
83
|
-
const groupRect = this.getBoundingClientRect();
|
|
84
|
-
const clone = bar.cloneNode(true);
|
|
85
|
-
clone.setAttribute("data-spui-exiting", "");
|
|
86
|
-
clone.setAttribute("aria-hidden", "true");
|
|
87
|
-
clone.inert = true;
|
|
88
|
-
clone.removeAttribute("id");
|
|
89
|
-
clone.querySelectorAll("[id], [data-testid]").forEach(node => { node.removeAttribute("id"); node.removeAttribute("data-testid"); });
|
|
90
|
-
Object.assign(clone.style, {
|
|
91
|
-
position: "absolute",
|
|
92
|
-
insetInlineStart: `${rect.left - groupRect.left - this.clientLeft + this.scrollLeft}px`,
|
|
93
|
-
top: `${rect.top - groupRect.top - this.clientTop + this.scrollTop}px`,
|
|
94
|
-
width: `${rect.width}px`,
|
|
95
|
-
height: `${rect.height}px`,
|
|
96
|
-
margin: "0",
|
|
97
|
-
pointerEvents: "none",
|
|
98
|
-
zIndex: "1",
|
|
99
|
-
});
|
|
100
|
-
clone.addEventListener("animationend", () => clone.remove(), { once: true });
|
|
101
|
-
this.append(clone);
|
|
102
|
-
view.setTimeout(() => clone.remove(), 300);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
customElements.define(tag, SpuiMessageBarPart);
|
|
106
|
-
}
|
|
107
|
-
export function defineMessageBarActions() {
|
|
108
|
-
definePart("spui-message-bar-actions", '<slot></slot><slot name="container-action"></slot>', ":host{display:flex;align-items:center;flex-wrap:wrap;gap:8px}:host([data-layout=multiline]){align-items:flex-start}slot[name=container-action]{margin-inline-start:auto}");
|
|
109
|
-
}
|
|
110
|
-
export function defineMessageBarBody() {
|
|
111
|
-
definePart("spui-message-bar-body", "<slot></slot>", ":host{line-height:1.45;min-width:0}");
|
|
112
|
-
}
|
|
113
|
-
export function defineMessageBarTitle() {
|
|
114
|
-
definePart("spui-message-bar-title", "<slot></slot>", ":host{display:inline;font-weight:600}");
|
|
115
|
-
}
|
|
116
|
-
export function defineMessageBarGroup() {
|
|
117
|
-
definePart("spui-message-bar-group", "<slot></slot>", ":host{position:relative;display:grid;gap:8px}:host([data-animate=both]) ::slotted(spui-message-bar:not([data-spui-exiting])){animation:spui-message-enter 160ms cubic-bezier(.2,0,0,1) both}::slotted(spui-message-bar[data-spui-exiting]){animation:spui-message-exit 250ms ease-in both}@keyframes spui-message-enter{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@keyframes spui-message-exit{to{opacity:0}}@media(prefers-reduced-motion:reduce){:host([data-animate=both]) ::slotted(spui-message-bar:not([data-spui-exiting])),::slotted(spui-message-bar[data-spui-exiting]){animation:none}}", ["animate"]);
|
|
118
|
-
}
|
|
119
|
-
export function defineMessageBar() {
|
|
120
|
-
if (customElements.get("spui-message-bar"))
|
|
121
|
-
return;
|
|
122
|
-
defineMessageBarActions();
|
|
123
|
-
defineMessageBarBody();
|
|
124
|
-
defineMessageBarTitle();
|
|
125
|
-
defineMessageBarGroup();
|
|
126
|
-
class SpuiMessageBar extends HTMLElement {
|
|
127
|
-
static observedAttributes = ["intent", "politeness", "shape", "layout"];
|
|
128
|
-
resizeObserver;
|
|
129
|
-
contentObserver;
|
|
130
|
-
reflowing = false;
|
|
131
|
-
singleLineWidth = Number.POSITIVE_INFINITY;
|
|
132
|
-
generatedTitleLabel;
|
|
133
|
-
lastAnnouncement;
|
|
134
|
-
connectedCallback() {
|
|
135
|
-
if (!this.shadowRoot) {
|
|
136
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
137
|
-
const content = document.createElement("div");
|
|
138
|
-
content.className = "content";
|
|
139
|
-
content.part.add("content");
|
|
140
|
-
const iconSlot = document.createElement("slot");
|
|
141
|
-
iconSlot.name = "icon";
|
|
142
|
-
const fallbackIcon = document.createElement("span");
|
|
143
|
-
fallbackIcon.className = "icon";
|
|
144
|
-
fallbackIcon.part.add("intent-icon");
|
|
145
|
-
fallbackIcon.setAttribute("aria-hidden", "true");
|
|
146
|
-
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
147
|
-
svg.setAttribute("viewBox", "0 0 20 20");
|
|
148
|
-
svg.setAttribute("width", "20");
|
|
149
|
-
svg.setAttribute("height", "20");
|
|
150
|
-
svg.setAttribute("fill", "none");
|
|
151
|
-
svg.setAttribute("stroke", "currentColor");
|
|
152
|
-
svg.setAttribute("stroke-width", "1.7");
|
|
153
|
-
svg.setAttribute("stroke-linecap", "round");
|
|
154
|
-
svg.setAttribute("stroke-linejoin", "round");
|
|
155
|
-
svg.setAttribute("focusable", "false");
|
|
156
|
-
fallbackIcon.append(svg);
|
|
157
|
-
iconSlot.append(fallbackIcon);
|
|
158
|
-
iconSlot.addEventListener("slotchange", () => this.syncIcon());
|
|
159
|
-
const childrenSlot = document.createElement("slot");
|
|
160
|
-
childrenSlot.addEventListener("slotchange", () => { this.updateLayout(); this.updateAnnouncement(); this.updateLabel(); });
|
|
161
|
-
content.append(iconSlot, childrenSlot);
|
|
162
|
-
const spacerSlot = document.createElement("slot");
|
|
163
|
-
spacerSlot.name = "bottom-reflow-spacer";
|
|
164
|
-
const spacer = document.createElement("div");
|
|
165
|
-
spacer.className = "reflow-spacer";
|
|
166
|
-
spacer.part.add("bottom-reflow-spacer");
|
|
167
|
-
spacer.setAttribute("aria-hidden", "true");
|
|
168
|
-
spacerSlot.append(spacer);
|
|
169
|
-
content.append(spacerSlot);
|
|
170
|
-
const liveRegion = document.createElement("span");
|
|
171
|
-
liveRegion.className = "announcement";
|
|
172
|
-
liveRegion.setAttribute("aria-live", "polite");
|
|
173
|
-
liveRegion.setAttribute("aria-atomic", "true");
|
|
174
|
-
const style = document.createElement("style");
|
|
175
|
-
style.textContent = `${base}:host{display:block;min-width:0;border:1px solid var(--spui-control-border,var(--spui-ui-stroke,var(--spui-semantic-body-divider,var(--colorNeutralStroke2,#edebe9))));border-radius:var(--spui-control-radius,4px);padding:12px 14px;background:var(--spui-ui-canvas,var(--colorNeutralBackground2,#f5f5f5));box-sizing:border-box;white-space:nowrap}:host([shape=rounded]){border-radius:var(--spui-card-radius,8px)}:host([shape=square]){border-radius:0}:host([intent=success]){background:var(--spui-success-surface,var(--spui-ui-success-surface,var(--spui-semantic-success-background,var(--colorPaletteGreenBackground1,#dff6dd))))}:host([intent=warning]){background:var(--spui-warning-surface,var(--spui-ui-warning-surface,var(--spui-semantic-warning-background,var(--colorPaletteYellowBackground1,#fff4ce))))}:host([intent=error]){background:var(--spui-danger-surface,var(--spui-ui-danger-surface,var(--spui-semantic-error-background,var(--colorPaletteRedBackground1,#fde7e9))))}.content{display:grid;grid-template-columns:auto minmax(0,1fr) auto;grid-template-rows:auto;grid-template-areas:'icon body actions';align-items:center;min-width:0;gap:0 12px;line-height:1.45}.content>slot:not([name]){display:contents}.content>slot[name=icon]{grid-area:icon;display:flex;align-items:center}.content>slot[name=bottom-reflow-spacer]{grid-area:spacer}.content ::slotted(spui-message-bar-title){grid-area:body}.content ::slotted(spui-message-bar-body){grid-area:body;min-width:0;white-space:inherit}.content ::slotted(spui-message-bar-actions){grid-area:actions;min-width:0}.icon,::slotted([slot=icon]){display:inline-flex;align-items:center;justify-content:center;flex:none;vertical-align:middle;margin-inline-end:8px;color:var(--spui-message-icon-color,var(--spui-ui-accent,#0f6cbd))}:host([intent=success]) .icon{color:var(--spui-ui-success,#107c10)}:host([intent=warning]) .icon{color:var(--spui-ui-warning,#835b00)}:host([intent=error]) .icon{color:var(--spui-ui-danger,#b10e1c)}:host([data-layout=multiline]){white-space:normal}:host([data-layout=multiline]) .content{grid-template-columns:auto minmax(0,1fr) auto;grid-template-rows:auto auto;grid-template-areas:'icon body actions' 'spacer spacer spacer';align-items:start;row-gap:8px}:host([data-layout=multiline]) .icon{margin-inline-end:0}.reflow-spacer,::slotted([slot=bottom-reflow-spacer]){display:none}:host([data-layout=multiline]) .reflow-spacer,:host([data-layout=multiline]) ::slotted([slot=bottom-reflow-spacer]){display:block;min-height:8px;margin-block-end:8px}:host([data-spui-appearance=glass]),:host-context([data-spui-appearance=glass]){backdrop-filter:var(--spui-card-backdrop,none);border-color:var(--spui-card-border,#ffffff80)}.announcement{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(forced-colors:active){:host{border-color:CanvasText;color:CanvasText;background:Canvas}.icon,::slotted([slot=icon]){color:CanvasText}}`;
|
|
176
|
-
shadow.append(style, content, liveRegion);
|
|
177
|
-
}
|
|
178
|
-
this.updateIntent();
|
|
179
|
-
this.updateLayout();
|
|
180
|
-
this.updateLabel();
|
|
181
|
-
this.updateAnnouncement();
|
|
182
|
-
this.observeLayout();
|
|
183
|
-
const MutationObserverConstructor = this.ownerDocument.defaultView?.MutationObserver;
|
|
184
|
-
if (MutationObserverConstructor) {
|
|
185
|
-
this.contentObserver ??= new MutationObserverConstructor(() => { this.updateLayout(); this.updateLabel(); this.updateAnnouncement(); });
|
|
186
|
-
this.contentObserver.observe(this, { childList: true, characterData: true, subtree: true });
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
disconnectedCallback() { this.resizeObserver?.disconnect(); this.contentObserver?.disconnect(); }
|
|
190
|
-
attributeChangedCallback() { if (this.isConnected) {
|
|
191
|
-
this.updateIntent();
|
|
192
|
-
this.updateLayout();
|
|
193
|
-
this.updateLabel();
|
|
194
|
-
this.observeLayout();
|
|
195
|
-
} }
|
|
196
|
-
observeLayout() {
|
|
197
|
-
this.resizeObserver?.disconnect();
|
|
198
|
-
const ResizeObserverConstructor = this.ownerDocument.defaultView?.ResizeObserver;
|
|
199
|
-
if ((this.getAttribute("layout") ?? "auto") !== "auto" || !ResizeObserverConstructor)
|
|
200
|
-
return;
|
|
201
|
-
this.resizeObserver = new ResizeObserverConstructor(() => this.updateLayout());
|
|
202
|
-
this.resizeObserver.observe(this);
|
|
203
|
-
}
|
|
204
|
-
updateLayout() {
|
|
205
|
-
const layout = this.getAttribute("layout") ?? "auto";
|
|
206
|
-
if (layout !== "auto")
|
|
207
|
-
this.reflowing = layout === "multiline";
|
|
208
|
-
else {
|
|
209
|
-
const width = this.getBoundingClientRect().width;
|
|
210
|
-
const scrollWidth = Math.max(this.scrollWidth, this.shadowRoot?.querySelector(".content")?.scrollWidth ?? 0);
|
|
211
|
-
if (this.reflowing) {
|
|
212
|
-
if (width >= this.singleLineWidth)
|
|
213
|
-
this.reflowing = false;
|
|
214
|
-
}
|
|
215
|
-
else if (width < scrollWidth) {
|
|
216
|
-
this.reflowing = true;
|
|
217
|
-
this.singleLineWidth = scrollWidth;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
const resolved = layout === "auto" ? this.reflowing ? "multiline" : "singleline" : layout;
|
|
221
|
-
if (this.dataset.layout !== resolved)
|
|
222
|
-
this.dataset.layout = resolved;
|
|
223
|
-
for (const actions of this.querySelectorAll("spui-message-bar-actions"))
|
|
224
|
-
actions.dataset.layout = resolved;
|
|
225
|
-
}
|
|
226
|
-
updateLabel() {
|
|
227
|
-
if (this.generatedTitleLabel && this.getAttribute("aria-labelledby") === this.generatedTitleLabel)
|
|
228
|
-
this.removeAttribute("aria-labelledby");
|
|
229
|
-
this.generatedTitleLabel = undefined;
|
|
230
|
-
if (this.hasAttribute("aria-label") || this.hasAttribute("aria-labelledby"))
|
|
231
|
-
return;
|
|
232
|
-
const title = this.querySelector("spui-message-bar-title");
|
|
233
|
-
if (!title)
|
|
234
|
-
return;
|
|
235
|
-
if (!title.id)
|
|
236
|
-
title.id = `spui-message-bar-title-${++messageBarTitleSequence}`;
|
|
237
|
-
this.generatedTitleLabel = title.id;
|
|
238
|
-
this.setAttribute("aria-labelledby", title.id);
|
|
239
|
-
}
|
|
240
|
-
updateAnnouncement() {
|
|
241
|
-
const liveRegion = this.shadowRoot?.querySelector(".announcement");
|
|
242
|
-
if (!liveRegion || this.hasAttribute("data-spui-exiting"))
|
|
243
|
-
return;
|
|
244
|
-
const body = this.querySelector("spui-message-bar-body")?.textContent ?? Array.from(this.childNodes).filter(node => !(node instanceof HTMLElement && ["spui-message-bar-title", "spui-message-bar-actions"].includes(node.localName))).map(node => node.textContent ?? "").join("");
|
|
245
|
-
const actions = this.querySelector("spui-message-bar-actions")?.textContent ?? "";
|
|
246
|
-
const message = [body?.trim(), actions.trim()].filter(Boolean).join(",");
|
|
247
|
-
if (message === this.lastAnnouncement)
|
|
248
|
-
return;
|
|
249
|
-
this.lastAnnouncement = message;
|
|
250
|
-
liveRegion.textContent = "";
|
|
251
|
-
queueMicrotask(() => { if (this.isConnected && liveRegion.isConnected)
|
|
252
|
-
liveRegion.textContent = message; });
|
|
253
|
-
}
|
|
254
|
-
syncIcon() {
|
|
255
|
-
const slot = this.shadowRoot?.querySelector('slot[name="icon"]');
|
|
256
|
-
const fallback = this.shadowRoot?.querySelector(".icon");
|
|
257
|
-
if (fallback) {
|
|
258
|
-
const intent = this.getAttribute("intent") ?? "info";
|
|
259
|
-
fallback.dataset.intent = intent;
|
|
260
|
-
const svg = fallback.querySelector("svg");
|
|
261
|
-
const paths = {
|
|
262
|
-
info: ["M10 2.5a7.5 7.5 0 1 0 0 15a7.5 7.5 0 0 0 0-15", "M10 9v4", "M10 6.4v.1"],
|
|
263
|
-
success: ["M10 2.5a7.5 7.5 0 1 0 0 15a7.5 7.5 0 0 0 0-15", "m6.2 10.2 2.5 2.5 5.2-5.2"],
|
|
264
|
-
warning: ["m10 2.5 8 14H2l8-14Z", "M10 7.5v4", "M10 14.4v.1"],
|
|
265
|
-
error: ["M6 2.5h8l3.5 7.5-3.5 7.5H6L2.5 10 6 2.5Z", "m7.5 7.5 5 5", "m12.5 7.5-5 5"]
|
|
266
|
-
};
|
|
267
|
-
if (svg) {
|
|
268
|
-
svg.replaceChildren();
|
|
269
|
-
for (const d of paths[intent] ?? paths.info) {
|
|
270
|
-
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
271
|
-
path.setAttribute("d", d);
|
|
272
|
-
svg.append(path);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
if (slot && fallback)
|
|
277
|
-
fallback.hidden = slot.assignedElements().length > 0;
|
|
278
|
-
}
|
|
279
|
-
updateIntent() {
|
|
280
|
-
const politeness = this.getAttribute("politeness");
|
|
281
|
-
const intent = this.getAttribute("intent") ?? "info";
|
|
282
|
-
if (!this.hasAttribute("role"))
|
|
283
|
-
this.setAttribute("role", "group");
|
|
284
|
-
const liveRegion = this.shadowRoot?.querySelector(".announcement");
|
|
285
|
-
liveRegion?.setAttribute("aria-live", politeness ?? (intent === "info" ? "polite" : "assertive"));
|
|
286
|
-
this.syncIcon();
|
|
287
|
-
for (const actions of this.querySelectorAll("spui-message-bar-actions")) {
|
|
288
|
-
const layout = this.getAttribute("layout");
|
|
289
|
-
if (layout)
|
|
290
|
-
actions.dataset.layout = layout;
|
|
291
|
-
else
|
|
292
|
-
delete actions.dataset.layout;
|
|
293
|
-
}
|
|
294
|
-
this.updateLabel();
|
|
295
|
-
this.updateAnnouncement();
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
customElements.define("spui-message-bar", SpuiMessageBar);
|
|
299
|
-
}
|
package/dist/elements/nav.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export type NavItemSelectData = {
|
|
2
|
-
value: string;
|
|
3
|
-
href: string | null;
|
|
4
|
-
label: string;
|
|
5
|
-
categoryValue?: string;
|
|
6
|
-
event: MouseEvent;
|
|
7
|
-
type: "click";
|
|
8
|
-
};
|
|
9
|
-
export type NavCategoryToggleData = {
|
|
10
|
-
value: string;
|
|
11
|
-
categoryValue?: string;
|
|
12
|
-
open: boolean;
|
|
13
|
-
openCategories: string[];
|
|
14
|
-
event: MouseEvent;
|
|
15
|
-
type: "click";
|
|
16
|
-
};
|
|
17
|
-
export declare function defineNav(): void;
|
|
18
|
-
export declare function defineNavItem(): void;
|
|
19
|
-
export declare function defineNavSubItem(): void;
|
|
20
|
-
export declare function defineAppItem(): void;
|
|
21
|
-
export declare function defineAppItemStatic(): void;
|
|
22
|
-
export declare function defineSplitNavItem(): void;
|
|
23
|
-
export declare function defineHamburger(): void;
|
|
24
|
-
export declare function defineNavDrawer(): void;
|
|
25
|
-
export declare function defineNavDrawerHeader(): void;
|
|
26
|
-
export declare function defineNavDrawerBody(): void;
|
|
27
|
-
export declare function defineNavDrawerFooter(): void;
|
|
28
|
-
export declare function defineNavCategory(): void;
|
|
29
|
-
export declare function defineNavCategoryItem(): void;
|
|
30
|
-
export declare function defineNavSubItemGroup(): void;
|
|
31
|
-
export declare function defineNavDivider(): void;
|
|
32
|
-
export declare function defineNavSectionHeader(): void;
|