@muibook/components 11.0.1 → 13.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-addon/index.js +41 -8
- package/dist/esm/components/mui-field/index.js +26 -9
- package/dist/esm/components/mui-hint/index.js +6 -6
- package/dist/esm/components/mui-image/index.js +89 -42
- package/dist/esm/components/mui-input/index.js +67 -27
- package/dist/esm/components/mui-prompt/index.js +87 -64
- package/dist/esm/components/mui-prompt-preview/index.js +43 -18
- package/dist/esm/components/mui-rule/index.js +7 -5
- package/dist/esm/components/mui-select/index.js +48 -15
- package/dist/esm/components/mui-skeleton/index.js +139 -0
- package/dist/esm/components/mui-slide-frame/index.js +410 -0
- package/dist/esm/components/mui-switch/index.js +72 -35
- package/dist/esm/components/mui-tabs/tab-bar/index.js +1 -1
- package/dist/esm/components/mui-textarea/index.js +40 -7
- package/dist/esm/css/mui-brand.css +1 -1
- package/dist/esm/css/mui-tokens.css +26 -0
- package/dist/esm/custom-elements.json +1573 -732
- package/dist/esm/index.js +6 -5
- package/dist/types/components/mui-prompt-preview/index.d.ts +1 -0
- package/dist/types/components/mui-slide-frame/index.d.ts +7 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +11 -11
- package/dist/esm/components/mui-markdown/index.js +0 -149
- package/dist/types/components/mui-agent-bubble/index.d.ts +0 -1
- package/dist/types/components/mui-agent-prompt/index.d.ts +0 -1
- package/dist/types/components/mui-markdown/doc.d.ts +0 -2
- package/dist/types/components/mui-markdown/index.d.ts +0 -1
- package/dist/types/components/mui-prompt-chip/index.d.ts +0 -1
- package/dist/types/components/mui-slat/accessory/index.d.ts +0 -1
- package/dist/types/tokens/js/mui-brand.d.ts +0 -140
- /package/dist/types/components/{mui-agent-bubble → mui-skeleton}/doc.d.ts +0 -0
- /package/dist/types/components/{mui-form-group-horizontal → mui-skeleton}/index.d.ts +0 -0
- /package/dist/types/components/{mui-agent-prompt → mui-slide-frame}/doc.d.ts +0 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
import "../mui-heading/index.js";
|
|
2
|
+
import "../mui-body/index.js";
|
|
3
|
+
import "../mui-stack/vstack/index.js";
|
|
4
|
+
import "../mui-stack/hstack/index.js";
|
|
5
|
+
import "../mui-button/index.js";
|
|
6
|
+
import "../mui-icons/warning/index.js";
|
|
7
|
+
import "../mui-dialog/index.js";
|
|
8
|
+
class x extends HTMLElement {
|
|
9
|
+
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.imageSlot = null, this.surfaceEl = null, this.pointerStartX = null, this.pointerStartY = null, this.onSlotChange = () => this.syncSections(), this.onChromeSlotChange = () => this.syncChromeState(), this.onSurfaceClick = (e) => this.handleSurfaceClick(e), this.onPointerDown = (e) => this.handlePointerDown(e), this.onPointerUp = (e) => this.handlePointerUp(e), this.onKeyDown = (e) => this.handleArrowNavigation(e), this.onDocumentKeyDown = (e) => {
|
|
11
|
+
this.shouldHandleGlobalKeys(e) && (this.isEditableTarget(e.target) || this.handleArrowNavigation(e));
|
|
12
|
+
}, this.attachShadow({ mode: "open" });
|
|
13
|
+
}
|
|
14
|
+
static get observedAttributes() {
|
|
15
|
+
return [
|
|
16
|
+
"ratio",
|
|
17
|
+
"ratio-width",
|
|
18
|
+
"ratio-height",
|
|
19
|
+
"present",
|
|
20
|
+
"active-section",
|
|
21
|
+
"padding",
|
|
22
|
+
"notes-open",
|
|
23
|
+
"variant",
|
|
24
|
+
"radius",
|
|
25
|
+
"title",
|
|
26
|
+
"footer-text",
|
|
27
|
+
"hide-counter",
|
|
28
|
+
"preview",
|
|
29
|
+
"lightbox",
|
|
30
|
+
"scroll"
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
connectedCallback() {
|
|
34
|
+
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);
|
|
35
|
+
}
|
|
36
|
+
disconnectedCallback() {
|
|
37
|
+
var e, t, i, o, s, r, a, l, h, d, n, c;
|
|
38
|
+
(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), (o = this.headerDescriptionSlot) == null || o.removeEventListener("slotchange", this.onChromeSlotChange), (s = this.footerSlot) == null || s.removeEventListener("slotchange", this.onChromeSlotChange), (r = this.footerAfterSlot) == null || r.removeEventListener("slotchange", this.onChromeSlotChange), (a = this.footerDescriptionSlot) == null || a.removeEventListener("slotchange", this.onChromeSlotChange), (l = this.notesSlot) == null || l.removeEventListener("slotchange", this.onChromeSlotChange), (h = this.imageSlot) == null || h.removeEventListener("slotchange", this.onChromeSlotChange), (d = this.surfaceEl) == null || d.removeEventListener("click", this.onSurfaceClick), (n = this.surfaceEl) == null || n.removeEventListener("pointerdown", this.onPointerDown), (c = this.surfaceEl) == null || c.removeEventListener("pointerup", this.onPointerUp), this.removeEventListener("keydown", this.onKeyDown), document.removeEventListener("keydown", this.onDocumentKeyDown);
|
|
39
|
+
}
|
|
40
|
+
attributeChangedCallback(e, t, i) {
|
|
41
|
+
t !== i && (this.render(), this.syncSections(), this.syncChromeState());
|
|
42
|
+
}
|
|
43
|
+
getSections() {
|
|
44
|
+
var t;
|
|
45
|
+
return (((t = this.defaultSlot) == null ? void 0 : t.assignedElements({ flatten: !0 })) || []).filter((i) => !["header", "footer"].includes(i.getAttribute("slot") || ""));
|
|
46
|
+
}
|
|
47
|
+
getActiveSectionIndex() {
|
|
48
|
+
const e = this.getSections(), t = parseInt(this.getAttribute("active-section") || "0", 10);
|
|
49
|
+
return !Number.isFinite(t) || e.length === 0 ? 0 : Math.max(0, Math.min(t, e.length - 1));
|
|
50
|
+
}
|
|
51
|
+
setActiveSectionIndex(e) {
|
|
52
|
+
this.setAttribute("active-section", String(e));
|
|
53
|
+
}
|
|
54
|
+
nextSection() {
|
|
55
|
+
const e = this.getSections();
|
|
56
|
+
if (e.length === 0) return;
|
|
57
|
+
const t = Math.min(this.getActiveSectionIndex() + 1, e.length - 1);
|
|
58
|
+
this.setActiveSectionIndex(t), this.dispatchEvent(
|
|
59
|
+
new CustomEvent("section-change", {
|
|
60
|
+
detail: { index: t, total: e.length },
|
|
61
|
+
bubbles: !0,
|
|
62
|
+
composed: !0
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
prevSection() {
|
|
67
|
+
const e = this.getSections();
|
|
68
|
+
if (e.length === 0) return;
|
|
69
|
+
const t = Math.max(this.getActiveSectionIndex() - 1, 0);
|
|
70
|
+
this.setActiveSectionIndex(t), this.dispatchEvent(
|
|
71
|
+
new CustomEvent("section-change", {
|
|
72
|
+
detail: { index: t, total: e.length },
|
|
73
|
+
bubbles: !0,
|
|
74
|
+
composed: !0
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
addSection(e) {
|
|
79
|
+
const t = document.createElement("div");
|
|
80
|
+
t.setAttribute("data-slide-section", ""), typeof e == "string" ? t.textContent = e : e instanceof HTMLElement && t.appendChild(e), this.appendChild(t);
|
|
81
|
+
const i = this.getSections(), o = Math.max(0, i.length - 1);
|
|
82
|
+
this.setActiveSectionIndex(o), this.syncSections(), this.dispatchEvent(
|
|
83
|
+
new CustomEvent("section-add", {
|
|
84
|
+
detail: { index: o, total: i.length },
|
|
85
|
+
bubbles: !0,
|
|
86
|
+
composed: !0
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
toggleNotes(e) {
|
|
91
|
+
const t = typeof e == "boolean" ? e : !this.hasAttribute("notes-open");
|
|
92
|
+
this.toggleAttribute("notes-open", t), this.dispatchEvent(
|
|
93
|
+
new CustomEvent("notes-toggle", {
|
|
94
|
+
detail: { open: t },
|
|
95
|
+
bubbles: !0,
|
|
96
|
+
composed: !0
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
resolveRatio() {
|
|
101
|
+
const e = (this.getAttribute("ratio") || "16:9").trim();
|
|
102
|
+
if (e === "custom") {
|
|
103
|
+
const i = parseFloat(this.getAttribute("ratio-width") || "16"), o = parseFloat(this.getAttribute("ratio-height") || "9");
|
|
104
|
+
return i > 0 && o > 0 ? `${i} / ${o}` : "16 / 9";
|
|
105
|
+
}
|
|
106
|
+
const t = e.split(":");
|
|
107
|
+
if (t.length === 2) {
|
|
108
|
+
const i = parseFloat(t[0]), o = parseFloat(t[1]);
|
|
109
|
+
if (i > 0 && o > 0) return `${i} / ${o}`;
|
|
110
|
+
}
|
|
111
|
+
return "16 / 9";
|
|
112
|
+
}
|
|
113
|
+
syncSections() {
|
|
114
|
+
if (!this.shadowRoot) return;
|
|
115
|
+
const e = this.getSections(), t = this.getActiveSectionIndex(), i = this.hasAttribute("present") || e.length > 1;
|
|
116
|
+
e.forEach((o, s) => {
|
|
117
|
+
o.setAttribute("data-slide-section", ""), s === t ? (o.removeAttribute("slide-hidden"), o.setAttribute("slide-active", "")) : (o.removeAttribute("slide-active"), i ? o.setAttribute("slide-hidden", "") : o.removeAttribute("slide-hidden"));
|
|
118
|
+
}), this.style.setProperty("--slide-frame-ratio", this.resolveRatio());
|
|
119
|
+
}
|
|
120
|
+
handleArrowNavigation(e) {
|
|
121
|
+
if (!(this.getSections().length < 2) && !e.defaultPrevented) {
|
|
122
|
+
if (e.key === "ArrowRight" || e.key === "ArrowDown") {
|
|
123
|
+
e.preventDefault(), this.nextSection();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
(e.key === "ArrowLeft" || e.key === "ArrowUp") && (e.preventDefault(), this.prevSection());
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
isEditableTarget(e) {
|
|
130
|
+
return e instanceof HTMLElement ? !!(e.closest("input, textarea, select") || e.isContentEditable) : !1;
|
|
131
|
+
}
|
|
132
|
+
shouldHandleGlobalKeys(e) {
|
|
133
|
+
const t = e.target instanceof Node ? e.target : null;
|
|
134
|
+
if (t && this.contains(t) || this.matches(":hover")) return !0;
|
|
135
|
+
const i = document.activeElement;
|
|
136
|
+
return !!(i && this.contains(i));
|
|
137
|
+
}
|
|
138
|
+
render() {
|
|
139
|
+
var s, r, a, l, h, d, n, c, g, u, m, f, v, p, b, S, w, y;
|
|
140
|
+
if (!this.shadowRoot) return;
|
|
141
|
+
const e = (this.getAttribute("title") || "").trim(), t = (this.getAttribute("footer-text") || "").trim(), i = this.escapeHtml(e), o = this.escapeHtml(t);
|
|
142
|
+
this.shadowRoot.innerHTML = /*html*/
|
|
143
|
+
`
|
|
144
|
+
<style>
|
|
145
|
+
:host {
|
|
146
|
+
display: block;
|
|
147
|
+
width: 100%;
|
|
148
|
+
--slide-frame-ratio: 16 / 9;
|
|
149
|
+
--slide-frame-padding-active: var(--slide-frame-padding-medium);
|
|
150
|
+
--slide-frame-leading-offset: var(--space-025);
|
|
151
|
+
--slide-frame-border-active: var(--border-thin);
|
|
152
|
+
--slide-frame-border-color-active: var(--slide-frame-border-color);
|
|
153
|
+
--slide-frame-background-active: var(--slide-frame-background);
|
|
154
|
+
--slide-frame-shadow-active: var(--slide-frame-shadow);
|
|
155
|
+
--slide-frame-radius-active: var(--slide-frame-radius);
|
|
156
|
+
}
|
|
157
|
+
:host([variant="plain"]) {
|
|
158
|
+
--slide-frame-border-active: none;
|
|
159
|
+
--slide-frame-border-color-active: transparent;
|
|
160
|
+
--slide-frame-background-active: transparent;
|
|
161
|
+
--slide-frame-shadow-active: none;
|
|
162
|
+
}
|
|
163
|
+
:host([variant="ghost"]) {
|
|
164
|
+
--slide-frame-border-active: none;
|
|
165
|
+
--slide-frame-border-color-active: transparent;
|
|
166
|
+
--slide-frame-background-active: var(--slide-frame-background-ghost);
|
|
167
|
+
--slide-frame-shadow-active: none;
|
|
168
|
+
}
|
|
169
|
+
:host([radius="none"]) { --slide-frame-radius-active: 0; }
|
|
170
|
+
:host([radius="small"]) { --slide-frame-radius-active: var(--slide-frame-radius-small); }
|
|
171
|
+
:host([radius="medium"]) { --slide-frame-radius-active: var(--slide-frame-radius-medium); }
|
|
172
|
+
:host([radius="large"]) { --slide-frame-radius-active: var(--slide-frame-radius-large); }
|
|
173
|
+
|
|
174
|
+
.frame {
|
|
175
|
+
display: grid;
|
|
176
|
+
width: 100%;
|
|
177
|
+
gap: 0;
|
|
178
|
+
padding: var(--space-400);
|
|
179
|
+
background: var(--surface-recessed-200);
|
|
180
|
+
box-sizing: border-box;
|
|
181
|
+
}
|
|
182
|
+
:host([has-chrome]) .frame {
|
|
183
|
+
gap: var(--slide-frame-gap, var(--space-300));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.surface {
|
|
187
|
+
position: relative;
|
|
188
|
+
width: 100%;
|
|
189
|
+
aspect-ratio: var(--slide-frame-ratio);
|
|
190
|
+
border: var(--slide-frame-border-active);
|
|
191
|
+
border-color: var(--slide-frame-border-color-active);
|
|
192
|
+
border-radius: var(--slide-frame-radius-active);
|
|
193
|
+
background: var(--slide-frame-background-active);
|
|
194
|
+
box-shadow: var(--slide-frame-shadow-active);
|
|
195
|
+
box-sizing: border-box;
|
|
196
|
+
padding: var(--slide-frame-padding-active);
|
|
197
|
+
overflow: hidden;
|
|
198
|
+
display: block;
|
|
199
|
+
}
|
|
200
|
+
:host([scroll]) .surface {
|
|
201
|
+
overflow: auto;
|
|
202
|
+
}
|
|
203
|
+
:host([preview]) .surface {
|
|
204
|
+
border-color: var(--slide-frame-preview-border-color, var(--text-color-warning));
|
|
205
|
+
box-shadow:
|
|
206
|
+
var(--slide-frame-shadow-active),
|
|
207
|
+
0 0 0 var(--stroke-size-100) color-mix(in srgb, var(--slide-frame-preview-border-color, var(--text-color-warning)) 45%, transparent);
|
|
208
|
+
}
|
|
209
|
+
.header,
|
|
210
|
+
.footer {
|
|
211
|
+
display: block;
|
|
212
|
+
}
|
|
213
|
+
.leading {
|
|
214
|
+
margin-inline: var(--slide-frame-leading-offset);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.leading_top {
|
|
218
|
+
margin-block-start: var(--space-050);
|
|
219
|
+
margin-block-end: var(--space-100);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.header-main,
|
|
223
|
+
.footer-main {
|
|
224
|
+
min-width: 0;
|
|
225
|
+
width: 100%;
|
|
226
|
+
}
|
|
227
|
+
.header-leading,
|
|
228
|
+
.footer-leading {
|
|
229
|
+
display: inline-flex;
|
|
230
|
+
align-items: center;
|
|
231
|
+
justify-content: flex-start;
|
|
232
|
+
gap: var(--space-200);
|
|
233
|
+
min-width: 0;
|
|
234
|
+
flex: 1 1 auto;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.header-title,
|
|
238
|
+
.footer-copy {
|
|
239
|
+
min-width: 0;
|
|
240
|
+
}
|
|
241
|
+
.header-description {
|
|
242
|
+
min-width: 0;
|
|
243
|
+
}
|
|
244
|
+
.header-after,
|
|
245
|
+
.footer-after {
|
|
246
|
+
justify-content: flex-end;
|
|
247
|
+
min-width: 0;
|
|
248
|
+
}
|
|
249
|
+
.footer-counter {
|
|
250
|
+
white-space: nowrap;
|
|
251
|
+
}
|
|
252
|
+
.notes {
|
|
253
|
+
display: none;
|
|
254
|
+
}
|
|
255
|
+
:host([notes-open]) .notes {
|
|
256
|
+
display: block;
|
|
257
|
+
padding: var(--space-400);
|
|
258
|
+
background: var(--surface-elevated-100);
|
|
259
|
+
border-radius: var(--radius-200);
|
|
260
|
+
|
|
261
|
+
}
|
|
262
|
+
:host([present]) .surface {
|
|
263
|
+
background: var(--slide-frame-background-present, var(--slide-frame-background-active));
|
|
264
|
+
}
|
|
265
|
+
.lightbox-image {
|
|
266
|
+
display: block;
|
|
267
|
+
width: 100%;
|
|
268
|
+
max-height: 75vh;
|
|
269
|
+
height: auto;
|
|
270
|
+
object-fit: contain;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.present-controls {
|
|
274
|
+
display: grid;
|
|
275
|
+
padding-bottom: var(--space-100);
|
|
276
|
+
border-bottom: var(--border-thin);
|
|
277
|
+
}
|
|
278
|
+
:host([present]) .present-controls {
|
|
279
|
+
display: none;
|
|
280
|
+
}
|
|
281
|
+
:host(:not([present])) #slideFrameTogglePresentBtn {
|
|
282
|
+
/* optional: style to indicate inactive state */
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
::slotted([data-slide-section][slide-hidden]) {
|
|
286
|
+
display: none !important;
|
|
287
|
+
}
|
|
288
|
+
</style>
|
|
289
|
+
<div class="frame">
|
|
290
|
+
<mui-grid col="1fr auto" class="present-controls" aligny="center">
|
|
291
|
+
<mui-h-stack space="var(--space-050)" aligny="center">
|
|
292
|
+
<mui-button id="slideFrameAddSectionBtn" variant="tertiary" size="x-small">Add Section</mui-button>
|
|
293
|
+
<mui-rule direction="vertical" length="var(--space-300)"></mui-rule>
|
|
294
|
+
<mui-button id="slideFrameTogglePresentBtn" variant="tertiary" size="x-small">Present Mode</mui-button>
|
|
295
|
+
<mui-rule direction="vertical" length="var(--space-300)"></mui-rule>
|
|
296
|
+
<mui-button id="slideFrameToggleNotesBtn" variant="tertiary" size="x-small">Notes</mui-button>
|
|
297
|
+
</mui-h-stack>
|
|
298
|
+
<mui-h-stack space="var(--space-050)" aligny="center">
|
|
299
|
+
<mui-button id="slideFramePrevSectionBtn" variant="tertiary" size="x-small"><mui-icon-left-chevron slot="before"></mui-icon-left-chevron>Previous</mui-button>
|
|
300
|
+
<mui-rule direction="vertical" length="var(--space-300)"></mui-rule>
|
|
301
|
+
<mui-button id="slideFrameNextSectionBtn" variant="tertiary" size="x-small">Next<mui-icon-right-chevron slot="after"></mui-icon-right-chevron></mui-button>
|
|
302
|
+
</mui-h-stack>
|
|
303
|
+
</mui-grid>
|
|
304
|
+
<div class="header" id="headerRegion">
|
|
305
|
+
<mui-v-stack class="leading leading_top" space="var(--space-100)" alignx="stretch" aligny="center">
|
|
306
|
+
<mui-h-stack class="header-main" alignx="space-between" aligny="center" space="var(--space-300)">
|
|
307
|
+
<div class="header-leading">
|
|
308
|
+
<mui-heading class="header-title" size="4" level="4" id="headerTitle"${i ? "" : " hidden"}>${i}</mui-heading>
|
|
309
|
+
<slot name="header"></slot>
|
|
310
|
+
</div>
|
|
311
|
+
<mui-h-stack class="header-after" alignx="end" aligny="center" space="var(--space-200)">
|
|
312
|
+
<slot name="header-after"></slot>
|
|
313
|
+
</mui-h-stack>
|
|
314
|
+
</mui-h-stack>
|
|
315
|
+
<mui-h-stack class="header-description" alignx="start" aligny="start" space="var(--space-200)">
|
|
316
|
+
<slot name="header-description"></slot>
|
|
317
|
+
</mui-h-stack>
|
|
318
|
+
</mui-v-stack>
|
|
319
|
+
</div>
|
|
320
|
+
<div class="surface" tabindex="0" role="region" aria-label="Slide frame">
|
|
321
|
+
<slot name="image"></slot>
|
|
322
|
+
<slot></slot>
|
|
323
|
+
</div>
|
|
324
|
+
<div class="notes"><mui-body variant="optional" size="x-small">Notes...</mui-body><slot name="notes"></slot></div>
|
|
325
|
+
<div class="footer" id="footerRegion">
|
|
326
|
+
<mui-v-stack class="leading leading_bottom" space="var(--space-400)">
|
|
327
|
+
<mui-h-stack class="footer-main" alignx="space-between" aligny="center" space="var(--space-300)">
|
|
328
|
+
<div class="footer-leading">
|
|
329
|
+
<mui-body class="footer-copy" size="small" id="footerText"${o ? "" : " hidden"}>${o}</mui-body>
|
|
330
|
+
<slot name="footer"></slot>
|
|
331
|
+
</div>
|
|
332
|
+
<mui-h-stack class="footer-after" alignx="end" aligny="center" space="var(--space-200)">
|
|
333
|
+
<mui-body class="footer-counter" id="footerCounter" size="x-small" variant="optional" hidden>Section 1/1</mui-body>
|
|
334
|
+
<slot name="footer-after"></slot>
|
|
335
|
+
</mui-h-stack>
|
|
336
|
+
</mui-h-stack>
|
|
337
|
+
</mui-v-stack>
|
|
338
|
+
</div>
|
|
339
|
+
</div>
|
|
340
|
+
<mui-dialog id="lightboxDialog" width="min(94vw, 1200px)" content-padding="none">
|
|
341
|
+
<mui-heading slot="title" size="5" level="3">Image Preview</mui-heading>
|
|
342
|
+
<img id="lightboxImage" class="lightbox-image" alt="Slide image preview" />
|
|
343
|
+
</mui-dialog>
|
|
344
|
+
`, this.defaultSlot = this.shadowRoot.querySelector("slot:not([name])"), (s = this.defaultSlot) == null || s.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.imageSlot = this.shadowRoot.querySelector('slot[name="image"]'), this.surfaceEl = this.shadowRoot.querySelector(".surface"), (r = this.headerSlot) == null || r.addEventListener("slotchange", this.onChromeSlotChange), (a = this.headerAfterSlot) == null || a.addEventListener("slotchange", this.onChromeSlotChange), (l = this.headerDescriptionSlot) == null || l.addEventListener("slotchange", this.onChromeSlotChange), (h = this.footerSlot) == null || h.addEventListener("slotchange", this.onChromeSlotChange), (d = this.footerAfterSlot) == null || d.addEventListener("slotchange", this.onChromeSlotChange), (n = this.footerDescriptionSlot) == null || n.addEventListener("slotchange", this.onChromeSlotChange), (c = this.notesSlot) == null || c.addEventListener("slotchange", this.onChromeSlotChange), (g = this.surfaceEl) == null || g.addEventListener("click", this.onSurfaceClick), (u = this.surfaceEl) == null || u.addEventListener("pointerdown", this.onPointerDown), (m = this.surfaceEl) == null || m.addEventListener("pointerup", this.onPointerUp), this.style.setProperty("--slide-frame-ratio", this.resolveRatio()), (f = this.shadowRoot.querySelector("#lightboxDialog")) == null || f.addEventListener("mui-dialog-close", () => {
|
|
345
|
+
this.dispatchEvent(new CustomEvent("lightbox-close", { bubbles: !0, composed: !0 }));
|
|
346
|
+
}), (v = this.shadowRoot.querySelector("#notesActionBtn")) == null || v.addEventListener("click", () => {
|
|
347
|
+
this.toggleNotes();
|
|
348
|
+
}), (p = this.shadowRoot.querySelector("#slideFrameAddSectionBtn")) == null || p.addEventListener("click", () => {
|
|
349
|
+
this.addSection(`Section ${(this.getSections().length + 1).toString()}: New`);
|
|
350
|
+
}), (b = this.shadowRoot.querySelector("#slideFramePrevSectionBtn")) == null || b.addEventListener("click", () => {
|
|
351
|
+
this.prevSection();
|
|
352
|
+
}), (S = this.shadowRoot.querySelector("#slideFrameNextSectionBtn")) == null || S.addEventListener("click", () => {
|
|
353
|
+
this.nextSection();
|
|
354
|
+
}), (w = this.shadowRoot.querySelector("#slideFrameTogglePresentBtn")) == null || w.addEventListener("click", () => {
|
|
355
|
+
this.toggleAttribute("present"), this.syncChromeState();
|
|
356
|
+
}), (y = this.shadowRoot.querySelector("#slideFrameToggleNotesBtn")) == null || y.addEventListener("click", () => {
|
|
357
|
+
this.toggleNotes();
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
syncChromeState() {
|
|
361
|
+
if (!this.shadowRoot) return;
|
|
362
|
+
const e = (u) => ((u == null ? void 0 : u.assignedNodes({ flatten: !0 })) || []).some(
|
|
363
|
+
(m) => m.nodeType === Node.ELEMENT_NODE || (m.textContent || "").trim().length > 0
|
|
364
|
+
), t = !!(this.getAttribute("title") || "").trim(), i = !!(this.getAttribute("footer-text") || "").trim(), o = !this.hasAttribute("hide-counter") && this.getSections().length > 0, s = t || e(this.headerSlot) || e(this.headerAfterSlot) || e(this.headerDescriptionSlot), r = i || e(this.footerSlot) || e(this.footerAfterSlot) || e(this.footerDescriptionSlot) || o, a = e(this.notesSlot), l = this.hasAttribute("notes-open"), h = this.shadowRoot.querySelector("#headerRegion"), d = this.shadowRoot.querySelector("#footerRegion"), n = this.shadowRoot.querySelector("#footerCounter"), c = Math.max(this.getSections().length, 1), g = this.getActiveSectionIndex() + 1;
|
|
365
|
+
n && (n.hidden = !o, n.textContent = `Section ${Math.min(g, c)}/${c}`), h && (h.hidden = !s), d && (d.hidden = !r), this.toggleAttribute("has-header", s), this.toggleAttribute("has-footer", r), this.toggleAttribute("has-notes", a), this.toggleAttribute("notes-visible", l), this.toggleAttribute("has-chrome", s || r || l);
|
|
366
|
+
}
|
|
367
|
+
handleSurfaceClick(e) {
|
|
368
|
+
if (!this.hasAttribute("lightbox") || !this.imageSlot) return;
|
|
369
|
+
const t = this.imageSlot.assignedElements({ flatten: !0 });
|
|
370
|
+
if (t.length === 0) return;
|
|
371
|
+
const i = e.composedPath();
|
|
372
|
+
if (!t.some((r) => i.includes(r))) return;
|
|
373
|
+
const s = this.resolveLightboxImage(i, t);
|
|
374
|
+
!s || !s.src || this.openLightbox(s.src, s.alt || "Slide image preview");
|
|
375
|
+
}
|
|
376
|
+
handlePointerDown(e) {
|
|
377
|
+
this.pointerStartX = e.clientX, this.pointerStartY = e.clientY;
|
|
378
|
+
}
|
|
379
|
+
handlePointerUp(e) {
|
|
380
|
+
if (this.pointerStartX == null || this.pointerStartY == null || this.getSections().length < 2) return;
|
|
381
|
+
const t = e.clientX - this.pointerStartX, i = e.clientY - this.pointerStartY;
|
|
382
|
+
this.pointerStartX = null, this.pointerStartY = null, !(Math.abs(t) < 40 || Math.abs(t) <= Math.abs(i)) && (t < 0 ? this.nextSection() : this.prevSection());
|
|
383
|
+
}
|
|
384
|
+
resolveLightboxImage(e, t) {
|
|
385
|
+
var o;
|
|
386
|
+
const i = e.find((s) => s instanceof HTMLImageElement);
|
|
387
|
+
if (i instanceof HTMLImageElement) return i;
|
|
388
|
+
for (const s of t) {
|
|
389
|
+
if (s instanceof HTMLImageElement) return s;
|
|
390
|
+
const r = (o = s.querySelector) == null ? void 0 : o.call(s, "img");
|
|
391
|
+
if (r instanceof HTMLImageElement) return r;
|
|
392
|
+
}
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
openLightbox(e, t) {
|
|
396
|
+
var s, r, a;
|
|
397
|
+
const i = (s = this.shadowRoot) == null ? void 0 : s.querySelector("#lightboxDialog"), o = (r = this.shadowRoot) == null ? void 0 : r.querySelector("#lightboxImage");
|
|
398
|
+
!i || !o || (o.src = e, o.alt = t, (a = i.open) == null || a.call(i), this.dispatchEvent(
|
|
399
|
+
new CustomEvent("lightbox-open", {
|
|
400
|
+
detail: { src: e, alt: t },
|
|
401
|
+
bubbles: !0,
|
|
402
|
+
composed: !0
|
|
403
|
+
})
|
|
404
|
+
));
|
|
405
|
+
}
|
|
406
|
+
escapeHtml(e) {
|
|
407
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
customElements.get("mui-slide-frame") || customElements.define("mui-slide-frame", x);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class n extends HTMLElement {
|
|
2
2
|
constructor() {
|
|
3
3
|
super(), this._checked = !1, this._checkbox = null, this.attachShadow({ mode: "open" }), this._checked = !1;
|
|
4
4
|
}
|
|
@@ -9,27 +9,28 @@ class o extends HTMLElement {
|
|
|
9
9
|
this._cleanupListeners();
|
|
10
10
|
}
|
|
11
11
|
static get observedAttributes() {
|
|
12
|
-
return ["label", "disabled", "checked"];
|
|
12
|
+
return ["label", "disabled", "checked", "size"];
|
|
13
13
|
}
|
|
14
|
-
attributeChangedCallback(
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
17
|
-
this._checkbox && (this._checkbox.disabled =
|
|
14
|
+
attributeChangedCallback(s, t, e) {
|
|
15
|
+
if (s === "checked" && t !== e && (this._checked = e !== null, this._checkbox && (this._checkbox.checked = this._checked, this._updateIcons())), s === "disabled" && t !== e) {
|
|
16
|
+
const i = e !== null;
|
|
17
|
+
this._checkbox && (this._checkbox.disabled = i, this._checkbox.setAttribute("aria-disabled", i.toString())), this._updateDisabledState();
|
|
18
18
|
}
|
|
19
|
+
s === "size" && t !== e && this._enforceIconSize();
|
|
19
20
|
}
|
|
20
21
|
get checked() {
|
|
21
22
|
return this._checked;
|
|
22
23
|
}
|
|
23
|
-
set checked(
|
|
24
|
-
const
|
|
25
|
-
this._checked !==
|
|
24
|
+
set checked(s) {
|
|
25
|
+
const t = !!s;
|
|
26
|
+
this._checked !== t && (this._checked = t, t ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._checkbox && (this._checkbox.checked = this._checked, this._checkbox.setAttribute("aria-checked", this._checked.toString()), this._updateIcons()));
|
|
26
27
|
}
|
|
27
28
|
_cleanupListeners() {
|
|
28
29
|
this._checkbox && this._changeHandler && this._checkbox.removeEventListener("change", this._changeHandler);
|
|
29
30
|
}
|
|
30
31
|
_updateDisabledState() {
|
|
31
|
-
var
|
|
32
|
-
this.hasAttribute("disabled") ? ((
|
|
32
|
+
var t, e, i, c;
|
|
33
|
+
this.hasAttribute("disabled") ? ((t = this._checkbox) == null || t.setAttribute("aria-disabled", "true"), (e = this._checkbox) == null || e.setAttribute("tabindex", "-1")) : ((i = this._checkbox) == null || i.removeAttribute("aria-disabled"), (c = this._checkbox) == null || c.removeAttribute("tabindex"));
|
|
33
34
|
}
|
|
34
35
|
_setupListener() {
|
|
35
36
|
this._checkbox && (this._cleanupListeners(), this._changeHandler = () => {
|
|
@@ -43,27 +44,32 @@ class o extends HTMLElement {
|
|
|
43
44
|
}, this._checkbox.addEventListener("change", this._changeHandler));
|
|
44
45
|
}
|
|
45
46
|
_enforceIconSize() {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
const s = this.shadowRoot.querySelector('slot[name="on-icon"]'), t = this.shadowRoot.querySelector('slot[name="off-icon"]'), e = this.getAttribute("size") || "large", c = {
|
|
48
|
+
"x-small": "xx-small",
|
|
49
|
+
small: "xx-small",
|
|
50
|
+
medium: "x-small",
|
|
51
|
+
large: "x-small"
|
|
52
|
+
}[e] || "x-small", a = (h) => {
|
|
53
|
+
if (!h) return;
|
|
54
|
+
const o = () => {
|
|
55
|
+
h.assignedElements().forEach((r) => {
|
|
56
|
+
r.tagName.toLowerCase().startsWith("mui-icon") && r.setAttribute("size", c);
|
|
51
57
|
});
|
|
52
58
|
};
|
|
53
|
-
|
|
59
|
+
h.addEventListener("slotchange", o), setTimeout(o, 0);
|
|
54
60
|
};
|
|
55
|
-
|
|
61
|
+
a(s), a(t);
|
|
56
62
|
}
|
|
57
63
|
_updateIcons() {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}),
|
|
62
|
-
|
|
64
|
+
const s = this.shadowRoot.querySelector('slot[name="on-icon"]'), t = this.shadowRoot.querySelector('slot[name="off-icon"]');
|
|
65
|
+
s && s.assignedElements().forEach((e) => {
|
|
66
|
+
e.style.display = this._checked ? "inline" : "none";
|
|
67
|
+
}), t && t.assignedElements().forEach((e) => {
|
|
68
|
+
e.style.display = this._checked ? "none" : "inline";
|
|
63
69
|
});
|
|
64
70
|
}
|
|
65
71
|
render() {
|
|
66
|
-
const
|
|
72
|
+
const s = this.getAttribute("label"), t = this.getAttribute("size") || "large", i = ["x-small", "small", "medium", "large"].includes(t) ? t : "large";
|
|
67
73
|
this.shadowRoot.innerHTML = /*html*/
|
|
68
74
|
`
|
|
69
75
|
<style>
|
|
@@ -72,8 +78,8 @@ class o extends HTMLElement {
|
|
|
72
78
|
.switch {
|
|
73
79
|
position: relative;
|
|
74
80
|
display: inline-block;
|
|
75
|
-
width: var(--switch-width);
|
|
76
|
-
height: var(--switch-height);
|
|
81
|
+
width: var(--_switch-width, var(--switch-width));
|
|
82
|
+
height: var(--_switch-height, var(--switch-height));
|
|
77
83
|
}
|
|
78
84
|
|
|
79
85
|
.switch input {
|
|
@@ -95,15 +101,15 @@ class o extends HTMLElement {
|
|
|
95
101
|
bottom: 0;
|
|
96
102
|
background-color: var(--switch-track-background);
|
|
97
103
|
transition: background-color var(--speed-200);
|
|
98
|
-
border-radius: var(--switch-height);
|
|
104
|
+
border-radius: var(--_switch-height, var(--switch-height));
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
.thumb {
|
|
102
108
|
position: absolute;
|
|
103
|
-
top: var(--switch-offset);
|
|
104
|
-
left: var(--switch-offset);
|
|
105
|
-
width: var(--switch-thumb-size);
|
|
106
|
-
height: var(--switch-thumb-size);
|
|
109
|
+
top: var(--_switch-offset, var(--switch-offset));
|
|
110
|
+
left: var(--_switch-offset, var(--switch-offset));
|
|
111
|
+
width: var(--_switch-thumb-size, var(--switch-thumb-size));
|
|
112
|
+
height: var(--_switch-thumb-size, var(--switch-thumb-size));
|
|
107
113
|
background-color: var(--switch-thumb-bg);
|
|
108
114
|
transition: transform var(--speed-200);
|
|
109
115
|
border-radius: 50%;
|
|
@@ -117,7 +123,38 @@ class o extends HTMLElement {
|
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
input:checked + .track .thumb {
|
|
120
|
-
transform: translateX(
|
|
126
|
+
transform: translateX(
|
|
127
|
+
calc(
|
|
128
|
+
var(--_switch-width, var(--switch-width)) -
|
|
129
|
+
var(--_switch-thumb-size, var(--switch-thumb-size)) -
|
|
130
|
+
(var(--_switch-offset, var(--switch-offset)) * 2)
|
|
131
|
+
)
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
:host([size="x-small"]) {
|
|
136
|
+
--_switch-offset: var(--stroke-size-100);
|
|
137
|
+
--_switch-thumb-size: calc(var(--action-icon-only-size-x-small) - var(--space-200));
|
|
138
|
+
--_switch-height: calc(var(--_switch-thumb-size) + (var(--_switch-offset) * 2));
|
|
139
|
+
--_switch-width: calc(var(--_switch-height) * 1.6);
|
|
140
|
+
}
|
|
141
|
+
:host([size="small"]) {
|
|
142
|
+
--_switch-offset: var(--stroke-size-100);
|
|
143
|
+
--_switch-thumb-size: calc(var(--action-icon-only-size-small) - var(--space-200));
|
|
144
|
+
--_switch-height: calc(var(--_switch-thumb-size) + (var(--_switch-offset) * 2));
|
|
145
|
+
--_switch-width: calc(var(--_switch-height) * 1.6);
|
|
146
|
+
}
|
|
147
|
+
:host([size="medium"]) {
|
|
148
|
+
--_switch-offset: var(--stroke-size-100);
|
|
149
|
+
--_switch-thumb-size: calc(var(--switch-thumb-size) - var(--space-100));
|
|
150
|
+
--_switch-height: calc(var(--_switch-thumb-size) + (var(--_switch-offset) * 2));
|
|
151
|
+
--_switch-width: calc(var(--_switch-height) * 1.6);
|
|
152
|
+
}
|
|
153
|
+
:host([size="large"]) {
|
|
154
|
+
--_switch-offset: var(--switch-offset);
|
|
155
|
+
--_switch-thumb-size: var(--switch-thumb-size);
|
|
156
|
+
--_switch-height: var(--switch-height);
|
|
157
|
+
--_switch-width: var(--switch-width);
|
|
121
158
|
}
|
|
122
159
|
|
|
123
160
|
::slotted([slot="on-icon"]),
|
|
@@ -140,7 +177,7 @@ class o extends HTMLElement {
|
|
|
140
177
|
type="checkbox"
|
|
141
178
|
role="switch"
|
|
142
179
|
aria-checked="${this._checked}"
|
|
143
|
-
${
|
|
180
|
+
${s ? `aria-label="${s}"` : ""}
|
|
144
181
|
>
|
|
145
182
|
<span class="track">
|
|
146
183
|
<span class="thumb">
|
|
@@ -149,7 +186,7 @@ class o extends HTMLElement {
|
|
|
149
186
|
</span>
|
|
150
187
|
</span>
|
|
151
188
|
</label>
|
|
152
|
-
|
|
189
|
+
`, this.setAttribute("size", i);
|
|
153
190
|
}
|
|
154
191
|
}
|
|
155
|
-
customElements.get("mui-switch") || customElements.define("mui-switch",
|
|
192
|
+
customElements.get("mui-switch") || customElements.define("mui-switch", n);
|