@muibook/components 16.0.0 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/mui-slide-frame/index.js +66 -57
- package/dist/esm/components/mui-slide-section/index.js +23 -0
- package/dist/esm/css/mui-brand.css +1 -1
- package/dist/esm/custom-elements.json +1250 -1262
- package/dist/esm/index.js +5 -4
- package/dist/types/components/mui-slide-frame/index.d.ts +1 -0
- package/dist/types/components/mui-slide-section/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +5 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import "../mui-heading/index.js";
|
|
2
2
|
import "../mui-body/index.js";
|
|
3
|
+
import "../mui-slide-section/index.js";
|
|
3
4
|
import "../mui-stack/vstack/index.js";
|
|
4
5
|
import "../mui-stack/hstack/index.js";
|
|
5
6
|
import "../mui-button/index.js";
|
|
6
7
|
import "../mui-icons/warning/index.js";
|
|
7
8
|
import "../mui-select/index.js";
|
|
8
|
-
class
|
|
9
|
+
class x extends HTMLElement {
|
|
9
10
|
constructor() {
|
|
10
|
-
super(), this.defaultSlot = null, this.headerSlot = null, this.headerAfterSlot = null, this.headerDescriptionSlot = null, this.footerSlot = null, this.footerAfterSlot = null, this.footerDescriptionSlot = null, this.notesSlot = null, this.stageEl = null, this.
|
|
11
|
+
super(), this.defaultSlot = null, this.headerSlot = null, this.headerAfterSlot = null, this.headerDescriptionSlot = null, this.footerSlot = null, this.footerAfterSlot = null, this.footerDescriptionSlot = null, this.notesSlot = null, this.stageEl = null, this.activeSectionEl = null, this.nativeFullscreenActive = !1, this.onSlotChange = () => this.syncSections(), this.onChromeSlotChange = () => this.syncChromeState(), this.onKeyDown = (e) => this.handleArrowNavigation(e), this.onFullscreenChange = () => this.handleFullscreenChange(), this.onFullscreenError = () => this.handleFullscreenError(), this.onWindowResize = () => this.updateFullscreenSurfaceFit(), this.onDocumentKeyDown = (e) => {
|
|
11
12
|
const t = document.fullscreenElement === this;
|
|
12
13
|
if (e.key === "Escape" && this.hasAttribute("present") && !t) {
|
|
13
14
|
e.preventDefault(), this.resetPresentationState();
|
|
@@ -39,8 +40,8 @@ class C extends HTMLElement {
|
|
|
39
40
|
this.hasAttribute("ratio") || this.setAttribute("ratio", "16:9"), this.hasAttribute("padding") || this.setAttribute("padding", "medium"), this.hasAttribute("active-section") || this.setAttribute("active-section", "0"), this.hasAttribute("variant") || this.setAttribute("variant", "default"), this.hasAttribute("radius") || this.setAttribute("radius", "default"), this.render(), this.syncSections(), this.syncChromeState(), this.addEventListener("keydown", this.onKeyDown), document.addEventListener("keydown", this.onDocumentKeyDown), document.addEventListener("fullscreenchange", this.onFullscreenChange), document.addEventListener("fullscreenerror", this.onFullscreenError), window.addEventListener("resize", this.onWindowResize);
|
|
40
41
|
}
|
|
41
42
|
disconnectedCallback() {
|
|
42
|
-
var e, t, i, s,
|
|
43
|
-
(e = this.defaultSlot) == null || e.removeEventListener("slotchange", this.onSlotChange), (t = this.headerSlot) == null || t.removeEventListener("slotchange", this.onChromeSlotChange), (i = this.headerAfterSlot) == null || i.removeEventListener("slotchange", this.onChromeSlotChange), (s = this.headerDescriptionSlot) == null || s.removeEventListener("slotchange", this.onChromeSlotChange), (
|
|
43
|
+
var e, t, i, s, r, n, d, h;
|
|
44
|
+
(e = this.defaultSlot) == null || e.removeEventListener("slotchange", this.onSlotChange), (t = this.headerSlot) == null || t.removeEventListener("slotchange", this.onChromeSlotChange), (i = this.headerAfterSlot) == null || i.removeEventListener("slotchange", this.onChromeSlotChange), (s = this.headerDescriptionSlot) == null || s.removeEventListener("slotchange", this.onChromeSlotChange), (r = this.footerSlot) == null || r.removeEventListener("slotchange", this.onChromeSlotChange), (n = this.footerAfterSlot) == null || n.removeEventListener("slotchange", this.onChromeSlotChange), (d = this.footerDescriptionSlot) == null || d.removeEventListener("slotchange", this.onChromeSlotChange), (h = this.notesSlot) == null || h.removeEventListener("slotchange", this.onChromeSlotChange), this.removeEventListener("keydown", this.onKeyDown), document.removeEventListener("keydown", this.onDocumentKeyDown), document.removeEventListener("fullscreenchange", this.onFullscreenChange), document.removeEventListener("fullscreenerror", this.onFullscreenError), window.removeEventListener("resize", this.onWindowResize);
|
|
44
45
|
}
|
|
45
46
|
attributeChangedCallback(e, t, i) {
|
|
46
47
|
t !== i && (this.render(), this.syncSections(), this.syncChromeState());
|
|
@@ -71,8 +72,9 @@ class C extends HTMLElement {
|
|
|
71
72
|
this.nativeFullscreenActive = !1, this.removeAttribute("present"), this.removeAttribute("fullscreen"), this.syncChromeState();
|
|
72
73
|
}
|
|
73
74
|
getSections() {
|
|
74
|
-
var
|
|
75
|
-
|
|
75
|
+
var s;
|
|
76
|
+
const t = (((s = this.defaultSlot) == null ? void 0 : s.assignedElements({ flatten: !0 })) || []).filter((r) => !["header", "footer"].includes(r.getAttribute("slot") || "")), i = t.filter((r) => r.tagName.toLowerCase() === "mui-slide-section");
|
|
77
|
+
return i.length > 0 ? i : t;
|
|
76
78
|
}
|
|
77
79
|
getActiveSectionIndex() {
|
|
78
80
|
const e = this.getSections(), t = parseInt(this.getAttribute("active-section") || "0", 10);
|
|
@@ -105,22 +107,37 @@ class C extends HTMLElement {
|
|
|
105
107
|
})
|
|
106
108
|
);
|
|
107
109
|
}
|
|
110
|
+
createDefaultSection(e) {
|
|
111
|
+
const t = document.createElement("mui-slide-section"), i = document.createElement("mui-v-stack");
|
|
112
|
+
i.setAttribute("space", "var(--space-400)"), i.setAttribute("alignx", "center"), i.setAttribute("aligny", "center");
|
|
113
|
+
const s = document.createElement("mui-body");
|
|
114
|
+
return s.setAttribute("size", "large"), s.textContent = e, i.appendChild(s), t.appendChild(i), t;
|
|
115
|
+
}
|
|
108
116
|
addSection(e) {
|
|
109
|
-
const t =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.appendChild(t);
|
|
115
|
-
const i = this.getSections(), s = Math.max(0, i.length - 1);
|
|
116
|
-
this.setActiveSectionIndex(s), this.syncSections(), this.dispatchEvent(
|
|
117
|
+
const t = `Section ${(this.getSections().length + 1).toString()}`;
|
|
118
|
+
let i;
|
|
119
|
+
typeof e == "string" ? i = this.createDefaultSection(e) : e instanceof HTMLElement ? e.tagName.toLowerCase() === "mui-slide-section" ? i = e : (i = document.createElement("mui-slide-section"), i.appendChild(e)) : i = this.createDefaultSection(t), this.appendChild(i);
|
|
120
|
+
const s = this.getSections(), r = Math.max(0, s.length - 1);
|
|
121
|
+
this.setActiveSectionIndex(r), this.syncSections(), this.dispatchEvent(
|
|
117
122
|
new CustomEvent("section-add", {
|
|
118
|
-
detail: { index:
|
|
123
|
+
detail: { index: r, total: s.length },
|
|
119
124
|
bubbles: !0,
|
|
120
125
|
composed: !0
|
|
121
126
|
})
|
|
122
127
|
);
|
|
123
128
|
}
|
|
129
|
+
requestAddSection() {
|
|
130
|
+
const e = this.getSections().length, t = new CustomEvent("section-add-request", {
|
|
131
|
+
detail: {
|
|
132
|
+
index: e,
|
|
133
|
+
total: e + 1
|
|
134
|
+
},
|
|
135
|
+
bubbles: !0,
|
|
136
|
+
composed: !0,
|
|
137
|
+
cancelable: !0
|
|
138
|
+
});
|
|
139
|
+
this.dispatchEvent(t) && this.addSection(`Section ${(e + 1).toString()}`);
|
|
140
|
+
}
|
|
124
141
|
toggleNotes(e) {
|
|
125
142
|
const t = typeof e == "boolean" ? e : !this.hasAttribute("notes-open");
|
|
126
143
|
this.toggleAttribute("notes-open", t), this.dispatchEvent(
|
|
@@ -153,8 +170,8 @@ class C extends HTMLElement {
|
|
|
153
170
|
let t = this.getActiveSectionIndex();
|
|
154
171
|
this.activeSectionEl && e.includes(this.activeSectionEl) && (t = e.indexOf(this.activeSectionEl)), t = Math.max(0, Math.min(t, Math.max(0, e.length - 1))), (this.getAttribute("active-section") || "0") !== String(t) && this.setAttribute("active-section", String(t));
|
|
155
172
|
const i = this.hasAttribute("present") || e.length > 1;
|
|
156
|
-
e.forEach((s,
|
|
157
|
-
s.setAttribute("data-slide-section", ""),
|
|
173
|
+
e.forEach((s, r) => {
|
|
174
|
+
s.setAttribute("data-slide-section", ""), r === t ? (s.removeAttribute("slide-hidden"), s.setAttribute("slide-active", "")) : (s.removeAttribute("slide-active"), i ? s.setAttribute("slide-hidden", "") : s.removeAttribute("slide-hidden"));
|
|
158
175
|
}), this.activeSectionEl = e[t] ?? null, this.style.setProperty("--slide-frame-ratio", this.resolveRatio()), this.updateFullscreenSurfaceFit();
|
|
159
176
|
}
|
|
160
177
|
handleArrowNavigation(e) {
|
|
@@ -181,7 +198,7 @@ class C extends HTMLElement {
|
|
|
181
198
|
return !!(i && this.contains(i));
|
|
182
199
|
}
|
|
183
200
|
render() {
|
|
184
|
-
var n,
|
|
201
|
+
var r, n, d, h, w, p, v, f, c, b, S, y, u, l, g, m;
|
|
185
202
|
if (!this.shadowRoot) return;
|
|
186
203
|
const e = (this.getAttribute("title") || "").trim(), t = (this.getAttribute("footer-text") || "").trim(), i = this.escapeHtml(e), s = this.escapeHtml(t);
|
|
187
204
|
this.shadowRoot.innerHTML = /*html*/
|
|
@@ -459,59 +476,51 @@ class C extends HTMLElement {
|
|
|
459
476
|
</div>
|
|
460
477
|
<div class="notes"><mui-body variant="optional" size="x-small">Notes...</mui-body><slot name="notes"></slot></div>
|
|
461
478
|
</div>
|
|
462
|
-
`, this.defaultSlot = this.shadowRoot.querySelector("slot:not([name])"), (
|
|
479
|
+
`, this.defaultSlot = this.shadowRoot.querySelector("slot:not([name])"), (r = this.defaultSlot) == null || r.addEventListener("slotchange", this.onSlotChange), this.headerSlot = this.shadowRoot.querySelector('slot[name="header"]'), this.headerAfterSlot = this.shadowRoot.querySelector('slot[name="header-after"]'), this.headerDescriptionSlot = this.shadowRoot.querySelector('slot[name="header-description"]'), this.footerSlot = this.shadowRoot.querySelector('slot[name="footer"]'), this.footerAfterSlot = this.shadowRoot.querySelector('slot[name="footer-after"]'), this.notesSlot = this.shadowRoot.querySelector('slot[name="notes"]'), this.stageEl = this.shadowRoot.querySelector(".stage"), (n = this.headerSlot) == null || n.addEventListener("slotchange", this.onChromeSlotChange), (d = this.headerAfterSlot) == null || d.addEventListener("slotchange", this.onChromeSlotChange), (h = this.headerDescriptionSlot) == null || h.addEventListener("slotchange", this.onChromeSlotChange), (w = this.footerSlot) == null || w.addEventListener("slotchange", this.onChromeSlotChange), (p = this.footerAfterSlot) == null || p.addEventListener("slotchange", this.onChromeSlotChange), (v = this.footerDescriptionSlot) == null || v.addEventListener("slotchange", this.onChromeSlotChange), (f = this.notesSlot) == null || f.addEventListener("slotchange", this.onChromeSlotChange), this.style.setProperty("--slide-frame-ratio", this.resolveRatio()), (c = this.shadowRoot.querySelector("#notesActionBtn")) == null || c.addEventListener("click", () => {
|
|
463
480
|
this.toggleNotes();
|
|
464
|
-
}), (
|
|
465
|
-
this.
|
|
466
|
-
}), (
|
|
481
|
+
}), (b = this.shadowRoot.querySelector("#slideFrameAddSectionBtn")) == null || b.addEventListener("click", () => {
|
|
482
|
+
this.requestAddSection();
|
|
483
|
+
}), (S = this.shadowRoot.querySelector("#slideFramePrevSectionBtn")) == null || S.addEventListener("click", () => {
|
|
467
484
|
this.prevSection();
|
|
468
|
-
}), (
|
|
485
|
+
}), (y = this.shadowRoot.querySelector("#slideFrameNextSectionBtn")) == null || y.addEventListener("click", () => {
|
|
469
486
|
this.nextSection();
|
|
470
|
-
}), (
|
|
487
|
+
}), (u = this.shadowRoot.querySelector("#slideFrameToggleFullscreenBtn")) == null || u.addEventListener("click", () => {
|
|
471
488
|
if (this.hasAttribute("fullscreen") || document.fullscreenElement === this) {
|
|
472
489
|
this.resetPresentationState(), this.exitFullscreen();
|
|
473
490
|
return;
|
|
474
491
|
}
|
|
475
|
-
this.setAttribute("present", ""), this.setAttribute("fullscreen", ""), this.syncChromeState(), this.enterFullscreen().then((
|
|
476
|
-
|
|
492
|
+
this.setAttribute("present", ""), this.setAttribute("fullscreen", ""), this.syncChromeState(), this.enterFullscreen().then((a) => {
|
|
493
|
+
a && this.syncChromeState();
|
|
477
494
|
});
|
|
478
|
-
}), (
|
|
495
|
+
}), (l = this.shadowRoot.querySelector("#slideFrameExitPresentBtn")) == null || l.addEventListener("click", () => {
|
|
479
496
|
this.resetPresentationState(), this.exitFullscreen();
|
|
480
|
-
}), (
|
|
497
|
+
}), (g = this.shadowRoot.querySelector("#slideFrameToggleNotesBtn")) == null || g.addEventListener("click", () => {
|
|
481
498
|
this.toggleNotes();
|
|
482
|
-
}), (
|
|
483
|
-
var
|
|
484
|
-
const
|
|
485
|
-
this.setAttribute("ratio",
|
|
499
|
+
}), (m = this.shadowRoot.querySelector("#slideFrameRatioSelect")) == null || m.addEventListener("change", (o) => {
|
|
500
|
+
var A;
|
|
501
|
+
const a = o.currentTarget, E = (a == null ? void 0 : a.value) || ((A = a == null ? void 0 : a.getAttribute) == null ? void 0 : A.call(a, "value")) || "16:9";
|
|
502
|
+
this.setAttribute("ratio", E);
|
|
486
503
|
}), requestAnimationFrame(() => this.updateFullscreenSurfaceFit());
|
|
487
504
|
}
|
|
488
505
|
syncChromeState() {
|
|
489
506
|
if (!this.shadowRoot) return;
|
|
490
|
-
const e = (
|
|
491
|
-
(
|
|
492
|
-
), t = !!(this.getAttribute("title") || "").trim(), i = !!(this.getAttribute("footer-text") || "").trim(), s = this.hasAttribute("hide-header"),
|
|
493
|
-
if (
|
|
494
|
-
const
|
|
495
|
-
|
|
507
|
+
const e = (o) => ((o == null ? void 0 : o.assignedNodes({ flatten: !0 })) || []).some(
|
|
508
|
+
(a) => a.nodeType === Node.ELEMENT_NODE || (a.textContent || "").trim().length > 0
|
|
509
|
+
), t = !!(this.getAttribute("title") || "").trim(), i = !!(this.getAttribute("footer-text") || "").trim(), s = this.hasAttribute("hide-header"), r = this.hasAttribute("hide-footer"), n = !this.hasAttribute("hide-counter") && this.getSections().length > 0, d = !s && (t || e(this.headerSlot) || e(this.headerAfterSlot) || e(this.headerDescriptionSlot)), h = !r && (i || e(this.footerSlot) || e(this.footerAfterSlot) || e(this.footerDescriptionSlot) || n || this.hasAttribute("present") || this.hasAttribute("fullscreen")), w = e(this.notesSlot), p = this.hasAttribute("notes-open"), v = this.shadowRoot.querySelector("#headerRegion"), f = this.shadowRoot.querySelector("#footerRegion"), c = this.shadowRoot.querySelector("#footerCounter"), b = this.shadowRoot.querySelector("#slideFrameExitPresentBtn"), S = this.shadowRoot.querySelector("#slideFrameToggleFullscreenBtn"), y = this.shadowRoot.querySelector(".present-controls"), u = this.shadowRoot.querySelector("#slideFrameAddSectionBtn"), l = this.shadowRoot.querySelector("#slideFrameAddSectionRule"), g = Math.max(this.getSections().length, 1), m = this.getActiveSectionIndex() + 1;
|
|
510
|
+
if (y) {
|
|
511
|
+
const o = this.hasAttribute("fullscreen") || document.fullscreenElement === this;
|
|
512
|
+
y.hidden = o;
|
|
496
513
|
}
|
|
497
514
|
if (u) {
|
|
498
|
-
const
|
|
499
|
-
u.hidden = !
|
|
515
|
+
const o = this.hasAttribute("allow-add-section");
|
|
516
|
+
u.hidden = !o, u.style.display = o ? "" : "none", l && (l.hidden = !o), l && (l.style.display = o ? "" : "none");
|
|
500
517
|
}
|
|
501
|
-
if (
|
|
502
|
-
|
|
503
|
-
const
|
|
504
|
-
|
|
518
|
+
if (c) {
|
|
519
|
+
c.hidden = !n;
|
|
520
|
+
const o = Math.min(m, g), a = String(g).length;
|
|
521
|
+
c.style.setProperty("--slide-frame-counter-digits", String(a)), c.setAttribute("aria-label", `Section ${o} of ${g}`), c.innerHTML = `Section <span class="counter-value">${o}</span>/<span class="counter-value">${g}</span>`;
|
|
505
522
|
}
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
handlePointerDown(e) {
|
|
509
|
-
this.pointerStartX = e.clientX, this.pointerStartY = e.clientY;
|
|
510
|
-
}
|
|
511
|
-
handlePointerUp(e) {
|
|
512
|
-
if (this.pointerStartX == null || this.pointerStartY == null || this.getSections().length < 2) return;
|
|
513
|
-
const t = e.clientX - this.pointerStartX, i = e.clientY - this.pointerStartY;
|
|
514
|
-
this.pointerStartX = null, this.pointerStartY = null, !(Math.abs(t) < 40 || Math.abs(t) <= Math.abs(i)) && (t < 0 ? this.nextSection() : this.prevSection());
|
|
523
|
+
b && (b.hidden = !this.hasAttribute("fullscreen")), S && (S.textContent = this.hasAttribute("fullscreen") ? "Exit Fullscreen" : "Full Screen"), v && (v.hidden = !d), f && (f.hidden = !h), this.toggleAttribute("has-header", d), this.toggleAttribute("has-footer", h), this.toggleAttribute("has-notes", w), this.toggleAttribute("notes-visible", p), this.toggleAttribute("has-chrome", d || h || p), this.updateFullscreenSurfaceFit();
|
|
515
524
|
}
|
|
516
525
|
handleFullscreenChange() {
|
|
517
526
|
const e = document.fullscreenElement === this, t = this.hasAttribute("fullscreen");
|
|
@@ -544,12 +553,12 @@ class C extends HTMLElement {
|
|
|
544
553
|
}
|
|
545
554
|
const t = this.shadowRoot.querySelector(".frame"), i = this.shadowRoot.querySelector(".present-controls"), s = this.shadowRoot.querySelector(".notes");
|
|
546
555
|
if (!t) return;
|
|
547
|
-
const
|
|
548
|
-
let m,
|
|
549
|
-
|
|
556
|
+
const r = t.getBoundingClientRect(), n = getComputedStyle(t), d = parseFloat(n.paddingTop || "0") || 0, h = parseFloat(n.paddingBottom || "0") || 0, w = parseFloat(n.paddingLeft || "0") || 0, p = parseFloat(n.paddingRight || "0") || 0, v = parseFloat(n.rowGap || n.gap || "0") || 0, f = i && getComputedStyle(i).display !== "none" ? i.getBoundingClientRect().height : 0, c = s && getComputedStyle(s).display !== "none" ? s.getBoundingClientRect().height : 0, b = [f > 0, !0, c > 0].filter(Boolean).length, S = Math.max(0, b - 1), y = Math.max(0, r.width - w - p), u = Math.max(0, r.height - d - h - f - c - v * S), l = this.resolveRatioParts(), g = this.hasAttribute("fullscreen") || document.fullscreenElement === this;
|
|
557
|
+
let m, o;
|
|
558
|
+
g ? (o = u, m = o * (l.width / l.height)) : (m = y, o = m * (l.height / l.width), o > u && (o = u, m = o * (l.width / l.height))), this.stageEl.style.width = `${Math.max(0, Math.floor(m))}px`, this.stageEl.style.height = `${Math.max(0, Math.floor(o))}px`;
|
|
550
559
|
}
|
|
551
560
|
escapeHtml(e) {
|
|
552
561
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
553
562
|
}
|
|
554
563
|
}
|
|
555
|
-
customElements.get("mui-slide-frame") || customElements.define("mui-slide-frame",
|
|
564
|
+
customElements.get("mui-slide-frame") || customElements.define("mui-slide-frame", x);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class e extends HTMLElement {
|
|
2
|
+
constructor() {
|
|
3
|
+
super(), this.attachShadow({ mode: "open" });
|
|
4
|
+
}
|
|
5
|
+
connectedCallback() {
|
|
6
|
+
this.render();
|
|
7
|
+
}
|
|
8
|
+
render() {
|
|
9
|
+
this.shadowRoot && (this.shadowRoot.innerHTML = /*html*/
|
|
10
|
+
`
|
|
11
|
+
<style>
|
|
12
|
+
:host {
|
|
13
|
+
display: block;
|
|
14
|
+
width: 100%;
|
|
15
|
+
min-width: 0;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
19
|
+
<slot></slot>
|
|
20
|
+
`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
customElements.get("mui-slide-section") || customElements.define("mui-slide-section", e);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/* ================================================================================================== */
|
|
3
|
-
/* Don't edit directly • Generated on Sat, 28 Feb 2026
|
|
3
|
+
/* Don't edit directly • Generated on Sat, 28 Feb 2026 05:07:44 GMT • muibook.com */
|
|
4
4
|
/* ================================================================================================== */
|
|
5
5
|
|
|
6
6
|
/* ================================================================================================== */
|