@muibook/components 14.0.0 → 14.0.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.
- package/dist/esm/components/mui-prompt/index.js +138 -117
- package/dist/esm/css/mui-brand.css +1 -1
- package/dist/esm/custom-elements.json +1838 -1800
- package/package.json +1 -1
|
@@ -18,10 +18,10 @@ import "../mui-rule/index.js";
|
|
|
18
18
|
import "../mui-prompt-toggle/index.js";
|
|
19
19
|
class k extends HTMLElement {
|
|
20
20
|
constructor() {
|
|
21
|
-
super(), this.triggerEl = null, this.previewShellEl = null, this.previewRowEl = null, this.previewSlotEl = null, this.previewResizeObserver = null, this.fanAnimations = /* @__PURE__ */ new Map(), this.pendingColorFade = !1, this.lastDebugPayload = '{"event":"idle"}', this.enforceActionVariants = () => {
|
|
21
|
+
super(), this.triggerEl = null, this.previewShellEl = null, this.previewRowEl = null, this.previewSlotEl = null, this.previewResizeObserver = null, this.fanAnimations = /* @__PURE__ */ new Map(), this.pendingColorFade = !1, this.lastDebugPayload = '{"event":"idle"}', this.lightDomObserver = null, this.onActionsSlotChange = () => this.updateActionsLayout(), this.enforceActionVariants = () => {
|
|
22
22
|
if (!this.shadowRoot) return;
|
|
23
|
-
const e = Array.from(this.shadowRoot.querySelectorAll('slot[name="actions"], slot[name="actions-trigger"], slot[name="actions-right"]')), o = (r,
|
|
24
|
-
if (!
|
|
23
|
+
const e = Array.from(this.shadowRoot.querySelectorAll('slot[name="actions"], slot[name="actions-trigger"], slot[name="actions-right"]')), o = (r, a) => {
|
|
24
|
+
if (!a || r.tagName.toLowerCase() !== "mui-button") return;
|
|
25
25
|
if (r.hasAttribute("icon-only")) {
|
|
26
26
|
r.style.marginRight = "var(--space-025)";
|
|
27
27
|
return;
|
|
@@ -29,16 +29,16 @@ class k extends HTMLElement {
|
|
|
29
29
|
r.style.marginRight === "var(--space-025)" && (r.style.marginRight = "");
|
|
30
30
|
};
|
|
31
31
|
e.forEach((r) => {
|
|
32
|
-
const
|
|
33
|
-
r.assignedElements({ flatten: !0 }).forEach((
|
|
34
|
-
[
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
c.setAttribute("variant", "tertiary"), o(c,
|
|
32
|
+
const a = r.name === "actions";
|
|
33
|
+
r.assignedElements({ flatten: !0 }).forEach((s) => {
|
|
34
|
+
[s, ...Array.from(s.querySelectorAll("*"))].forEach((c) => {
|
|
35
|
+
const d = c.tagName.toLowerCase();
|
|
36
|
+
if (d === "mui-button") {
|
|
37
|
+
c.setAttribute("variant", "tertiary"), o(c, a);
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
h instanceof HTMLElement && h.tagName.toLowerCase() === "mui-button" && (h.setAttribute("variant", "tertiary"), o(h,
|
|
40
|
+
d === "mui-dropdown" && c.querySelectorAll('[slot="action"]').forEach((h) => {
|
|
41
|
+
h instanceof HTMLElement && h.tagName.toLowerCase() === "mui-button" && (h.setAttribute("variant", "tertiary"), o(h, a));
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
});
|
|
@@ -48,18 +48,18 @@ class k extends HTMLElement {
|
|
|
48
48
|
}, this.onPaste = (t) => {
|
|
49
49
|
const e = t, o = e.clipboardData;
|
|
50
50
|
if (!o) return;
|
|
51
|
-
const r = Array.from(o.files || []),
|
|
52
|
-
if (!g && !
|
|
51
|
+
const r = Array.from(o.files || []), a = o.getData("text/plain") || "", i = a.trim(), s = i.length > 0, l = s ? this.detectMediaUrl(i) : null, c = this.getAttribute("preview-overflow-to-preview") !== "false", d = this.getAttribute("preview-threshold-chars"), p = Number.isFinite(Number.parseInt(d || "", 10)) ? Math.max(1, Number.parseInt(d || "", 10)) : 220, h = s ? this.detectBadge(i) : "", u = h !== "" && h !== "Insightful", b = c && s && (!!(l != null && l.url) || i.length >= p || u), g = r.length > 0;
|
|
52
|
+
if (!g && !s) return;
|
|
53
53
|
(g || b) && e.preventDefault();
|
|
54
|
-
const v = r.map((
|
|
55
|
-
kind:
|
|
56
|
-
mimeType:
|
|
57
|
-
file:
|
|
58
|
-
fileName:
|
|
59
|
-
size:
|
|
60
|
-
badge:
|
|
61
|
-
preview:
|
|
62
|
-
value:
|
|
54
|
+
const v = r.map((m) => ({
|
|
55
|
+
kind: m.type.startsWith("image/") ? "image" : m.type.startsWith("video/") ? "video" : m.type.startsWith("audio/") ? "audio" : "file",
|
|
56
|
+
mimeType: m.type || "",
|
|
57
|
+
file: m,
|
|
58
|
+
fileName: m.name || "",
|
|
59
|
+
size: m.size || 0,
|
|
60
|
+
badge: m.type.startsWith("image/") ? "IMG" : m.type.startsWith("video/") ? "VIDEO" : m.type.startsWith("audio/") ? "MUSIC" : "FILE",
|
|
61
|
+
preview: m.name || "Pasted file",
|
|
62
|
+
value: m.name || ""
|
|
63
63
|
}));
|
|
64
64
|
b && i && (l != null && l.url ? v.unshift({
|
|
65
65
|
kind: l.kind === "image" ? "image" : "text",
|
|
@@ -72,11 +72,11 @@ class k extends HTMLElement {
|
|
|
72
72
|
mimeType: "text/plain",
|
|
73
73
|
badge: this.detectBadge(i),
|
|
74
74
|
preview: i.slice(0, 260),
|
|
75
|
-
value:
|
|
75
|
+
value: a
|
|
76
76
|
})), this.emitPromptItems({
|
|
77
77
|
source: "paste",
|
|
78
78
|
items: v,
|
|
79
|
-
text:
|
|
79
|
+
text: a || "",
|
|
80
80
|
textBadge: (l == null ? void 0 : l.badge) || h,
|
|
81
81
|
overflowed: b,
|
|
82
82
|
thresholdChars: p
|
|
@@ -116,27 +116,27 @@ class k extends HTMLElement {
|
|
|
116
116
|
const e = t.composedPath();
|
|
117
117
|
if (e.some((i) => {
|
|
118
118
|
if (!(i instanceof HTMLElement)) return !1;
|
|
119
|
-
const
|
|
120
|
-
return
|
|
119
|
+
const s = i.tagName.toLowerCase();
|
|
120
|
+
return s === "textarea" || s === "input" || i.isContentEditable;
|
|
121
121
|
})) return;
|
|
122
122
|
if (e.find((i) => {
|
|
123
|
-
var
|
|
124
|
-
return i instanceof HTMLElement && ((
|
|
123
|
+
var s;
|
|
124
|
+
return i instanceof HTMLElement && ((s = i.hasAttribute) == null ? void 0 : s.call(i, "context-close"));
|
|
125
125
|
})) {
|
|
126
126
|
this.setContextMode("icon", "dismiss"), this.updateActionsLayout();
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
129
|
e.find(
|
|
130
130
|
(i) => {
|
|
131
|
-
var
|
|
132
|
-
return i instanceof HTMLElement && (((
|
|
131
|
+
var s, l;
|
|
132
|
+
return i instanceof HTMLElement && (((s = i.hasAttribute) == null ? void 0 : s.call(i, "context-toggle")) || ((l = i.getAttribute) == null ? void 0 : l.call(i, "slot")) === "toggle");
|
|
133
133
|
}
|
|
134
134
|
) && (this.setContextMode("chip", "click"), this.updateActionsLayout());
|
|
135
135
|
}, this.onContextChipDismiss = (t) => {
|
|
136
136
|
t.composedPath().find(
|
|
137
137
|
(r) => {
|
|
138
|
-
var
|
|
139
|
-
return r instanceof HTMLElement && (((
|
|
138
|
+
var a, i, s;
|
|
139
|
+
return r instanceof HTMLElement && (((a = r.hasAttribute) == null ? void 0 : a.call(r, "context-active")) || ((i = r.hasAttribute) == null ? void 0 : i.call(r, "context-chip")) || ((s = r.hasAttribute) == null ? void 0 : s.call(r, "context-spinner")));
|
|
140
140
|
}
|
|
141
141
|
) && (this.setContextMode("icon", "dismiss"), this.updateActionsLayout());
|
|
142
142
|
}, this.toggleFanOpen = () => {
|
|
@@ -183,17 +183,17 @@ class k extends HTMLElement {
|
|
|
183
183
|
}
|
|
184
184
|
setDebugState(t, e) {
|
|
185
185
|
if (!this.shadowRoot) return;
|
|
186
|
-
const o = this.shadowRoot.querySelector(".debug-region"), r = this.shadowRoot.querySelector("#promptDebugStatus"),
|
|
187
|
-
if (!o || !r || !
|
|
186
|
+
const o = this.shadowRoot.querySelector(".debug-region"), r = this.shadowRoot.querySelector("#promptDebugStatus"), a = this.shadowRoot.querySelector("#promptDebugPayload");
|
|
187
|
+
if (!o || !r || !a) return;
|
|
188
188
|
const i = this.hasAttribute("debug");
|
|
189
|
-
o.toggleAttribute("hidden", !i), i && (r.textContent = t, e && (this.lastDebugPayload = JSON.stringify(e)),
|
|
189
|
+
o.toggleAttribute("hidden", !i), i && (r.textContent = t, e && (this.lastDebugPayload = JSON.stringify(e)), a.textContent = this.lastDebugPayload);
|
|
190
190
|
}
|
|
191
191
|
emitPromptItems({
|
|
192
192
|
items: t,
|
|
193
193
|
text: e,
|
|
194
194
|
textBadge: o,
|
|
195
195
|
overflowed: r,
|
|
196
|
-
thresholdChars:
|
|
196
|
+
thresholdChars: a,
|
|
197
197
|
source: i
|
|
198
198
|
}) {
|
|
199
199
|
this.dispatchEvent(
|
|
@@ -204,7 +204,7 @@ class k extends HTMLElement {
|
|
|
204
204
|
text: e,
|
|
205
205
|
textBadge: o,
|
|
206
206
|
overflowed: r,
|
|
207
|
-
thresholdChars:
|
|
207
|
+
thresholdChars: a,
|
|
208
208
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
209
209
|
},
|
|
210
210
|
bubbles: !0,
|
|
@@ -240,12 +240,12 @@ class k extends HTMLElement {
|
|
|
240
240
|
)
|
|
241
241
|
).flatMap((r) => r.assignedElements({ flatten: !0 })).forEach((r) => {
|
|
242
242
|
[r, ...Array.from(r.querySelectorAll("*"))].forEach((i) => {
|
|
243
|
-
const l = i.tagName.toLowerCase() === "mui-prompt-toggle", c = i.hasAttribute("context-toggle"),
|
|
243
|
+
const l = i.tagName.toLowerCase() === "mui-prompt-toggle", c = i.hasAttribute("context-toggle"), d = i.hasAttribute("context-active") || i.hasAttribute("context-close") || i.hasAttribute("context-chip") || i.hasAttribute("context-spinner");
|
|
244
244
|
if (l) {
|
|
245
245
|
i.setAttribute("mode", t);
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
|
-
if (c ||
|
|
248
|
+
if (c || d) {
|
|
249
249
|
i.hasAttribute("context-chip") && i.tagName.toLowerCase() === "mui-chip" && !i.hasAttribute("variant") && i.setAttribute("variant", "ghost");
|
|
250
250
|
const p = c ? t === "icon" : t === "chip";
|
|
251
251
|
i.toggleAttribute("hidden", !p), i.style.display = p ? "inline-flex" : "none";
|
|
@@ -253,12 +253,25 @@ class k extends HTMLElement {
|
|
|
253
253
|
});
|
|
254
254
|
});
|
|
255
255
|
}
|
|
256
|
+
hasTruthyFlagAttribute(t) {
|
|
257
|
+
const e = this.getAttribute(t);
|
|
258
|
+
return e !== null && e !== "false";
|
|
259
|
+
}
|
|
260
|
+
shouldUseFanModeByActions() {
|
|
261
|
+
if (!this.shadowRoot) return !1;
|
|
262
|
+
const t = this.shadowRoot.querySelector('slot[name="actions"]');
|
|
263
|
+
return t ? t.assignedElements({ flatten: !0 }).filter(
|
|
264
|
+
(o) => !o.hasAttribute("hidden")
|
|
265
|
+
).length > 0 : !1;
|
|
266
|
+
}
|
|
267
|
+
isFanModeEnabled() {
|
|
268
|
+
return this.hasTruthyFlagAttribute("actions-fan") ? !0 : this.shouldUseFanModeByActions();
|
|
269
|
+
}
|
|
256
270
|
ensureFanMode() {
|
|
257
|
-
this.hasAttribute("fan-open") && !this.hasAttribute("actions-fan") && this.setAttribute("actions-fan", "");
|
|
258
271
|
}
|
|
259
272
|
connectedCallback() {
|
|
260
273
|
var e;
|
|
261
|
-
this.hasAttribute("context-mode") || this.setAttribute("context-mode", "icon"), this.ensureFanMode(), this.render(), this.bindEvents(), this.updateActionsLayout();
|
|
274
|
+
this.hasAttribute("context-mode") || this.setAttribute("context-mode", "icon"), this.ensureFanMode(), this.render(), this.bindEvents(), this.updateActionsLayout(), queueMicrotask(() => this.updateActionsLayout()), requestAnimationFrame(() => this.updateActionsLayout()), requestAnimationFrame(() => requestAnimationFrame(() => this.updateActionsLayout()));
|
|
262
275
|
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector("textarea");
|
|
263
276
|
t && (this.syncTextareaHeight(t), requestAnimationFrame(() => this.syncTextareaHeight(t)));
|
|
264
277
|
}
|
|
@@ -273,9 +286,9 @@ class k extends HTMLElement {
|
|
|
273
286
|
return;
|
|
274
287
|
}
|
|
275
288
|
if (t === "context-mode") {
|
|
276
|
-
const
|
|
277
|
-
if (o !==
|
|
278
|
-
this.setAttribute("context-mode",
|
|
289
|
+
const a = this.normalizeContextMode(o);
|
|
290
|
+
if (o !== a) {
|
|
291
|
+
this.setAttribute("context-mode", a);
|
|
279
292
|
return;
|
|
280
293
|
}
|
|
281
294
|
this.syncContextModeUI(), this.updateActionsLayout();
|
|
@@ -421,9 +434,9 @@ class k extends HTMLElement {
|
|
|
421
434
|
t == null || t.focus();
|
|
422
435
|
}
|
|
423
436
|
syncTextareaHeight(t) {
|
|
424
|
-
const o = Number.parseInt(this.getAttribute("rows") || String(3), 10) || 3, r = Math.max(o + 6, 10),
|
|
437
|
+
const o = Number.parseInt(this.getAttribute("rows") || String(3), 10) || 3, r = Math.max(o + 6, 10), a = getComputedStyle(t), s = (Number.parseFloat(a.fontSize) || 16) * 1.55, l = Number.parseFloat(a.paddingTop) || 0, c = Number.parseFloat(a.paddingBottom) || 0, d = Number.parseFloat(a.borderTopWidth) || 0, p = Number.parseFloat(a.borderBottomWidth) || 0, h = l + c + d + p, u = 3 * s + h, b = r * s + h;
|
|
425
438
|
t.style.height = "auto";
|
|
426
|
-
const g = t.scrollHeight, v = Math.max(
|
|
439
|
+
const g = t.scrollHeight, v = Math.max(u, Math.min(g, b));
|
|
427
440
|
t.style.height = `${Math.ceil(v)}px`, t.style.overflowY = g > b ? "auto" : "hidden";
|
|
428
441
|
}
|
|
429
442
|
detectBadge(t) {
|
|
@@ -463,14 +476,14 @@ class k extends HTMLElement {
|
|
|
463
476
|
const o = e.match(/https?:\/\/[^\s]+/i), r = ((o == null ? void 0 : o[0]) || e).trim();
|
|
464
477
|
if (!/^https?:\/\//i.test(r)) return null;
|
|
465
478
|
try {
|
|
466
|
-
const
|
|
479
|
+
const a = new URL(r), i = a.pathname.toLowerCase(), s = a.hostname.toLowerCase();
|
|
467
480
|
if (/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/.test(i))
|
|
468
481
|
return { url: r, kind: "image", badge: "IMG", mimeType: "image/*" };
|
|
469
|
-
if (
|
|
482
|
+
if (s === "youtu.be" || s.endsWith("youtube.com") || s.endsWith("youtube-nocookie.com"))
|
|
470
483
|
return { url: r, kind: "video", badge: "VIDEO", mimeType: "video/*" };
|
|
471
|
-
if (
|
|
484
|
+
if (s.endsWith("vimeo.com") || s.endsWith("twitch.tv"))
|
|
472
485
|
return { url: r, kind: "video", badge: "VIDEO", mimeType: "video/*" };
|
|
473
|
-
if (
|
|
486
|
+
if (s.endsWith("soundcloud.com") || s.endsWith("spotify.com") || s.endsWith("bandcamp.com") || s.endsWith("mixcloud.com"))
|
|
474
487
|
return { url: r, kind: "audio", badge: "MUSIC", mimeType: "audio/*" };
|
|
475
488
|
if (/\.(mp4|webm|mov|m4v|ogv)$/.test(i))
|
|
476
489
|
return { url: r, kind: "video", badge: "VIDEO", mimeType: "video/*" };
|
|
@@ -482,18 +495,24 @@ class k extends HTMLElement {
|
|
|
482
495
|
return null;
|
|
483
496
|
}
|
|
484
497
|
bindEvents() {
|
|
498
|
+
var i;
|
|
485
499
|
if (!this.shadowRoot) return;
|
|
486
500
|
this.unbindEvents();
|
|
487
501
|
const t = this.shadowRoot.querySelector("textarea");
|
|
488
502
|
t == null || t.addEventListener("input", this.onInput), t == null || t.addEventListener("keydown", this.onKeyDown), t == null || t.addEventListener("paste", this.onPaste), t == null || t.addEventListener("focus", this.onTextareaFocus);
|
|
489
|
-
const e = this.shadowRoot.querySelector('slot[name="actions"]'), o = this.shadowRoot.querySelector('slot[name="actions-trigger"]'), r = this.shadowRoot.querySelector('slot[name="actions-right"]'),
|
|
490
|
-
e == null || e.addEventListener("slotchange",
|
|
503
|
+
const e = this.shadowRoot.querySelector('slot[name="actions"]'), o = this.shadowRoot.querySelector('slot[name="actions-trigger"]'), r = this.shadowRoot.querySelector('slot[name="actions-right"]'), a = this.shadowRoot.querySelector("#promptDefaultSubmitAction");
|
|
504
|
+
e == null || e.addEventListener("slotchange", this.onActionsSlotChange), o == null || o.addEventListener("slotchange", this.onActionsSlotChange), r == null || r.addEventListener("slotchange", this.onActionsSlotChange), typeof MutationObserver < "u" && ((i = this.lightDomObserver) == null || i.disconnect(), this.lightDomObserver = new MutationObserver(() => this.updateActionsLayout()), this.lightDomObserver.observe(this, {
|
|
505
|
+
childList: !0,
|
|
506
|
+
subtree: !0,
|
|
507
|
+
attributes: !0,
|
|
508
|
+
attributeFilter: ["slot", "hidden"]
|
|
509
|
+
})), a == null || a.addEventListener("click", this.onDefaultSubmitClick), this.addEventListener("prompt-preview-open", this.onPreviewOpen), this.addEventListener("click", this.onContextToggleClick), this.addEventListener("dismiss", this.onContextChipDismiss), this.syncErrorVisibility(), this.bindPreviewOverflow(), this.bindActionTrigger(), this.syncLoadingState();
|
|
491
510
|
}
|
|
492
511
|
unbindEvents() {
|
|
493
|
-
var
|
|
512
|
+
var i, s, l, c;
|
|
494
513
|
if (!this.shadowRoot) return;
|
|
495
|
-
const t = this.shadowRoot.querySelector("textarea"), e = this.shadowRoot.querySelector("#promptDefaultSubmitAction");
|
|
496
|
-
t == null || t.removeEventListener("input", this.onInput), t == null || t.removeEventListener("keydown", this.onKeyDown), t == null || t.removeEventListener("paste", this.onPaste), t == null || t.removeEventListener("focus", this.onTextareaFocus),
|
|
514
|
+
const t = this.shadowRoot.querySelector("textarea"), e = this.shadowRoot.querySelector('slot[name="actions"]'), o = this.shadowRoot.querySelector('slot[name="actions-trigger"]'), r = this.shadowRoot.querySelector('slot[name="actions-right"]'), a = this.shadowRoot.querySelector("#promptDefaultSubmitAction");
|
|
515
|
+
t == null || t.removeEventListener("input", this.onInput), t == null || t.removeEventListener("keydown", this.onKeyDown), t == null || t.removeEventListener("paste", this.onPaste), t == null || t.removeEventListener("focus", this.onTextareaFocus), a == null || a.removeEventListener("click", this.onDefaultSubmitClick), e == null || e.removeEventListener("slotchange", this.onActionsSlotChange), o == null || o.removeEventListener("slotchange", this.onActionsSlotChange), r == null || r.removeEventListener("slotchange", this.onActionsSlotChange), this.removeEventListener("prompt-preview-open", this.onPreviewOpen), this.removeEventListener("click", this.onContextToggleClick), this.removeEventListener("dismiss", this.onContextChipDismiss), this.triggerEl && (this.triggerEl.removeEventListener("click", this.toggleFanOpen), this.triggerEl = null), (i = this.previewRowEl) == null || i.removeEventListener("scroll", this.onPreviewScroll), (s = this.previewSlotEl) == null || s.removeEventListener("slotchange", this.onPreviewSlotChange), (l = this.previewResizeObserver) == null || l.disconnect(), this.previewResizeObserver = null, (c = this.lightDomObserver) == null || c.disconnect(), this.lightDomObserver = null, this.previewShellEl = null, this.previewRowEl = null, this.previewSlotEl = null;
|
|
497
516
|
}
|
|
498
517
|
bindPreviewOverflow() {
|
|
499
518
|
var t, e;
|
|
@@ -515,59 +534,59 @@ class k extends HTMLElement {
|
|
|
515
534
|
var i;
|
|
516
535
|
const e = this.getAttribute("preview-loading"), o = (this.getAttribute("preview-loading-label") || "").trim(), r = t || ((i = this.previewSlotEl) == null ? void 0 : i.assignedElements({ flatten: !0 })) || [];
|
|
517
536
|
if (!e) {
|
|
518
|
-
r.forEach((
|
|
519
|
-
|
|
537
|
+
r.forEach((s) => {
|
|
538
|
+
s.tagName.toLowerCase() === "mui-prompt-preview" && s.removeAttribute("loading");
|
|
520
539
|
});
|
|
521
540
|
return;
|
|
522
541
|
}
|
|
523
|
-
const
|
|
524
|
-
r.forEach((
|
|
525
|
-
|
|
542
|
+
const a = e === "auto" ? this.hasAttribute("loading") : !0;
|
|
543
|
+
r.forEach((s) => {
|
|
544
|
+
s.tagName.toLowerCase() === "mui-prompt-preview" && (a ? s.setAttribute("loading", "") : s.removeAttribute("loading"), o && s.setAttribute("loading-label", o));
|
|
526
545
|
});
|
|
527
546
|
}
|
|
528
547
|
normalizePreviewDetail(t) {
|
|
529
|
-
const e = String(t.value || "").trim(), o = String(t.bgImage || "").trim(), r = String(t.badge || "").trim(),
|
|
548
|
+
const e = String(t.value || "").trim(), o = String(t.bgImage || "").trim(), r = String(t.badge || "").trim(), a = String(t.label || "Pasted Content"), i = String(t.imageTint || "").trim(), s = o ? "image" : e ? "code" : "text";
|
|
530
549
|
return {
|
|
531
550
|
id: String(t.id || ""),
|
|
532
551
|
value: e,
|
|
533
552
|
badge: r || (o ? "IMG" : this.detectBadge(e)),
|
|
534
|
-
label:
|
|
553
|
+
label: a,
|
|
535
554
|
bgImage: o,
|
|
536
555
|
imageTint: i,
|
|
537
|
-
type:
|
|
556
|
+
type: s
|
|
538
557
|
};
|
|
539
558
|
}
|
|
540
559
|
openInternalPreviewDialog(t) {
|
|
541
|
-
var
|
|
560
|
+
var n;
|
|
542
561
|
if (!this.shadowRoot) return;
|
|
543
|
-
const e = this.shadowRoot.querySelector("#promptAutoPreviewDialog"), o = this.shadowRoot.querySelector("#promptAutoPreviewTitle"), r = this.shadowRoot.querySelector("#promptAutoPreviewCode"),
|
|
544
|
-
if (!
|
|
562
|
+
const e = this.shadowRoot.querySelector("#promptAutoPreviewDialog"), o = this.shadowRoot.querySelector("#promptAutoPreviewTitle"), r = this.shadowRoot.querySelector("#promptAutoPreviewCode"), a = this.shadowRoot.querySelector("#promptAutoPreviewImage"), i = this.shadowRoot.querySelector("#promptAutoPreviewMedia"), s = this.shadowRoot.querySelector("#promptAutoPreviewMediaUrl"), l = this.normalizePreviewDetail(t), c = this.getAttribute("preview-dialog-title") || l.label, d = l.value, p = l.bgImage, h = l.badge, u = d ? this.detectMediaUrl(d) : null, b = !p && d.length > 0 && (h === "VIDEO" || h === "MUSIC"), g = !p && (!!(u && (u.kind === "video" || u.kind === "audio")) || b), v = p.length > 0, m = d.length > 0, y = (() => {
|
|
563
|
+
if (!u || u.kind !== "audio") return !1;
|
|
545
564
|
try {
|
|
546
|
-
const f = new URL(
|
|
565
|
+
const f = new URL(u.url);
|
|
547
566
|
return /\.(mp3|wav|m4a|aac|flac|ogg|oga)$/.test(f.pathname.toLowerCase());
|
|
548
567
|
} catch {
|
|
549
568
|
return !1;
|
|
550
569
|
}
|
|
551
|
-
})(),
|
|
552
|
-
if (!
|
|
570
|
+
})(), A = (() => {
|
|
571
|
+
if (!u || !y) return "";
|
|
553
572
|
try {
|
|
554
|
-
const
|
|
555
|
-
return
|
|
573
|
+
const S = new URL(u.url).pathname.split("/").filter(Boolean).pop() || "", w = decodeURIComponent(S), x = w.replace(/\.(mp3|wav|m4a|aac|flac|ogg|oga)$/i, "") || w || "Audio";
|
|
574
|
+
return x.charAt(0).toUpperCase() + x.slice(1);
|
|
556
575
|
} catch {
|
|
557
576
|
return "Audio";
|
|
558
577
|
}
|
|
559
578
|
})();
|
|
560
|
-
if (!(!v && !
|
|
561
|
-
if (this.setAttribute("preview-dialog-value",
|
|
562
|
-
|
|
563
|
-
else if (g &&
|
|
564
|
-
if (
|
|
565
|
-
const f =
|
|
566
|
-
|
|
567
|
-
}
|
|
568
|
-
i && (i.setAttribute("src",
|
|
569
|
-
} else b ? (
|
|
570
|
-
(
|
|
579
|
+
if (!(!v && !m && !g)) {
|
|
580
|
+
if (this.setAttribute("preview-dialog-value", d), this.setAttribute("preview-dialog-image", p), this.setAttribute("preview-dialog-type", h || (v ? "IMG" : "CODE")), o && (o.textContent = c), g ? e == null || e.setAttribute("content-max-height", "none") : e == null || e.removeAttribute("content-max-height"), v)
|
|
581
|
+
s && s.setAttribute("hidden", ""), a && (a.setAttribute("src", p), a.removeAttribute("hidden")), i && i.setAttribute("hidden", ""), r && r.setAttribute("hidden", "");
|
|
582
|
+
else if (g && u) {
|
|
583
|
+
if (s) {
|
|
584
|
+
const f = y;
|
|
585
|
+
s.textContent = f ? A : u.url, f ? (s.setAttribute("href", u.url), s.setAttribute("target", "_blank"), s.setAttribute("rel", "noopener noreferrer")) : (s.removeAttribute("href"), s.removeAttribute("target"), s.removeAttribute("rel")), s.toggleAttribute("hidden", !f);
|
|
586
|
+
}
|
|
587
|
+
i && (i.setAttribute("src", u.url), i.removeAttribute("type"), i.removeAttribute("prefer-native-controls"), i.removeAttribute("hidden")), r && r.setAttribute("hidden", ""), a && (a.removeAttribute("src"), a.setAttribute("hidden", ""));
|
|
588
|
+
} else b ? (s && (s.textContent = d, s.toggleAttribute("hidden", !0)), i && (i.setAttribute("src", d), i.setAttribute("type", h === "VIDEO" ? "video" : "audio"), i.removeAttribute("prefer-native-controls"), i.removeAttribute("hidden")), r && r.setAttribute("hidden", ""), a && (a.removeAttribute("src"), a.setAttribute("hidden", ""))) : (s && s.setAttribute("hidden", ""), r && (r.textContent = this.formatPreviewCode(d, h), r.removeAttribute("hidden")), i && (i.removeAttribute("src"), i.removeAttribute("prefer-native-controls"), i.setAttribute("hidden", "")), a && (a.removeAttribute("src"), a.setAttribute("hidden", "")));
|
|
589
|
+
(n = e == null ? void 0 : e.open) == null || n.call(e);
|
|
571
590
|
}
|
|
572
591
|
}
|
|
573
592
|
syncPreviewEdgeShadows() {
|
|
@@ -579,22 +598,22 @@ class k extends HTMLElement {
|
|
|
579
598
|
return t.tagName.toLowerCase() === "mui-prompt-toggle" || t.hasAttribute("context-toggle") ? !0 : !!t.querySelector("[context-toggle]");
|
|
580
599
|
}
|
|
581
600
|
bindActionTrigger() {
|
|
582
|
-
if (!this.shadowRoot || !this.
|
|
601
|
+
if (!this.shadowRoot || !this.isFanModeEnabled()) return;
|
|
583
602
|
const t = this.shadowRoot.querySelector('slot[name="actions"]'), e = this.shadowRoot.querySelector('slot[name="actions-trigger"]'), o = this.shadowRoot.querySelector("#promptDefaultActionsTrigger");
|
|
584
603
|
if (!t) return;
|
|
585
604
|
this.triggerEl && (this.triggerEl.removeEventListener("click", this.toggleFanOpen), this.triggerEl = null);
|
|
586
605
|
const r = ((e == null ? void 0 : e.assignedElements({ flatten: !0 })) || []).filter(
|
|
587
606
|
(c) => !c.hasAttribute("hidden")
|
|
588
|
-
),
|
|
607
|
+
), a = t.assignedElements({ flatten: !0 }).filter(
|
|
589
608
|
(c) => !c.hasAttribute("hidden")
|
|
590
609
|
);
|
|
591
|
-
if (!(
|
|
610
|
+
if (!(a.length > 0)) {
|
|
592
611
|
o && (o.setAttribute("hidden", ""), o.style.display = "none");
|
|
593
612
|
return;
|
|
594
613
|
}
|
|
595
|
-
const
|
|
596
|
-
o && (o.toggleAttribute("hidden",
|
|
597
|
-
const l =
|
|
614
|
+
const s = r.length === 0 && a.length === 1 && this.isContextOnlyAction(a[0]);
|
|
615
|
+
o && (o.toggleAttribute("hidden", s), o.style.display = s ? "none" : "inline-flex");
|
|
616
|
+
const l = s ? null : r.find((c) => c.hasAttribute("fan-trigger")) || r[0] || o || a.find((c) => c.hasAttribute("fan-trigger")) || a[0] || null;
|
|
598
617
|
l && (this.triggerEl = l, this.triggerEl.addEventListener("click", this.toggleFanOpen), this.syncTriggerIconState());
|
|
599
618
|
}
|
|
600
619
|
syncTriggerIconState() {
|
|
@@ -618,58 +637,60 @@ class k extends HTMLElement {
|
|
|
618
637
|
this.syncContextModeUI();
|
|
619
638
|
const t = this.shadowRoot.querySelector('slot[name="actions"]'), e = this.shadowRoot.querySelector('slot[name="actions-trigger"]'), o = this.shadowRoot.querySelector("#promptDefaultActionsTrigger"), r = this.shadowRoot.querySelector(".actions-separator");
|
|
620
639
|
if (!t) return;
|
|
621
|
-
const
|
|
640
|
+
const a = ((e == null ? void 0 : e.assignedElements({ flatten: !0 })) || []).filter(
|
|
622
641
|
(n) => !n.hasAttribute("hidden")
|
|
623
642
|
), i = t.assignedElements({ flatten: !0 }).filter(
|
|
624
643
|
(n) => !n.hasAttribute("hidden")
|
|
625
|
-
),
|
|
626
|
-
l && (l.style.display =
|
|
627
|
-
const c =
|
|
644
|
+
), s = i.length > 0, l = this.shadowRoot.querySelector(".actions-slot-left");
|
|
645
|
+
l && (l.style.display = s ? "inline-flex" : "none");
|
|
646
|
+
const c = a.length === 0 && i.length === 1 && this.isContextOnlyAction(i[0]);
|
|
628
647
|
if (o) {
|
|
629
|
-
const n = !
|
|
648
|
+
const n = !s || c;
|
|
630
649
|
o.toggleAttribute("hidden", n), o.style.display = n ? "none" : "inline-flex";
|
|
631
650
|
}
|
|
632
|
-
const
|
|
651
|
+
const d = c ? null : a.find((n) => n.hasAttribute("fan-trigger")) || a[0] || o || i.find((n) => n.hasAttribute("fan-trigger")) || i[0] || null, p = i.filter((n) => n !== d), h = d ? [d, ...p] : i, u = this.shadowRoot.querySelector('slot[name="actions-right"]'), b = (u == null ? void 0 : u.assignedElements({ flatten: !0 })) || [], g = p.length > 0;
|
|
652
|
+
this.toggleAttribute("has-actions", s), this.toggleAttribute("has-extra-actions", g);
|
|
653
|
+
const v = s || this.hasTruthyFlagAttribute("actions-fan"), m = this.hasAttribute("fan-open"), y = 100, A = "calc(var(--action-icon-only-size-medium) + var(--space-100))";
|
|
633
654
|
if (r) {
|
|
634
|
-
const n =
|
|
655
|
+
const n = v && m && g;
|
|
635
656
|
r.toggleAttribute("hidden", !n), r.style.display = n ? "inline-flex" : "none";
|
|
636
657
|
}
|
|
637
|
-
this.enforceActionVariants(), h.forEach((n,
|
|
638
|
-
n.style.transition = `transform ${
|
|
639
|
-
const
|
|
640
|
-
if (
|
|
658
|
+
this.enforceActionVariants(), h.forEach((n, f) => {
|
|
659
|
+
n.style.transition = `transform ${y}ms ease, opacity ${y}ms ease`, n.style.zIndex = "";
|
|
660
|
+
const S = this.fanAnimations.get(n);
|
|
661
|
+
if (S && (S.cancel(), this.fanAnimations.delete(n)), !v) {
|
|
641
662
|
this.setFanItemInert(n, !1), n.style.transitionDelay = "", n.style.transform = "", n.style.opacity = "", n.style.pointerEvents = "", n.style.filter = "";
|
|
642
663
|
return;
|
|
643
664
|
}
|
|
644
|
-
if (
|
|
665
|
+
if (f === 0) {
|
|
645
666
|
this.setFanItemInert(n, !1), n.style.transitionDelay = "", n.style.transform = "translateX(0)", n.style.opacity = "1", n.style.pointerEvents = "", n.style.filter = "";
|
|
646
667
|
return;
|
|
647
668
|
}
|
|
648
|
-
if (!
|
|
669
|
+
if (!m) {
|
|
649
670
|
this.setFanItemInert(n, !0), n.style.transitionDelay = "", n.style.transform = "translateX(0) scale(0.8)", n.style.opacity = "0", n.style.pointerEvents = "none", n.style.filter = "";
|
|
650
671
|
return;
|
|
651
672
|
}
|
|
652
|
-
const
|
|
653
|
-
n.style.transition = `opacity ${Math.max(120,
|
|
654
|
-
if (n.style.transform = `translateX(${
|
|
673
|
+
const w = `calc(${A} * -${f})`, x = f * 50;
|
|
674
|
+
n.style.transition = `opacity ${Math.max(120, y - 40)}ms ease, transform ${y}ms cubic-bezier(0.22, 1, 0.36, 1)`, n.style.transitionDelay = `${x}ms`, n.style.transform = "translateX(0) scale(0.92)", n.style.opacity = "0", n.style.pointerEvents = "none", n.style.filter = "", this.setFanItemInert(n, !0), requestAnimationFrame(() => {
|
|
675
|
+
if (n.style.transform = `translateX(${w})`, n.style.opacity = "1", window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
655
676
|
n.style.pointerEvents = "", this.setFanItemInert(n, !1);
|
|
656
677
|
return;
|
|
657
678
|
}
|
|
658
|
-
const
|
|
679
|
+
const E = n.animate(
|
|
659
680
|
[
|
|
660
681
|
{ transform: "translateX(0) scale(0.92)" },
|
|
661
|
-
{ transform: `translateX(${
|
|
662
|
-
{ transform: `translateX(calc(${
|
|
663
|
-
{ transform: `translateX(${
|
|
682
|
+
{ transform: `translateX(${w}) scale(1.03)`, offset: 0.68 },
|
|
683
|
+
{ transform: `translateX(calc(${w} - var(--space-050))) scale(0.99)`, offset: 0.86 },
|
|
684
|
+
{ transform: `translateX(${w}) scale(1)` }
|
|
664
685
|
],
|
|
665
686
|
{
|
|
666
|
-
duration:
|
|
687
|
+
duration: y + 180,
|
|
667
688
|
delay: x,
|
|
668
689
|
easing: "cubic-bezier(0.22, 1, 0.36, 1)",
|
|
669
690
|
fill: "forwards"
|
|
670
691
|
}
|
|
671
692
|
);
|
|
672
|
-
this.fanAnimations.set(n,
|
|
693
|
+
this.fanAnimations.set(n, E), E.finished.catch(() => {
|
|
673
694
|
}).finally(() => {
|
|
674
695
|
n.style.pointerEvents = "", this.setFanItemInert(n, !1);
|
|
675
696
|
});
|
|
@@ -680,7 +701,7 @@ class k extends HTMLElement {
|
|
|
680
701
|
}
|
|
681
702
|
render() {
|
|
682
703
|
if (!this.shadowRoot) return;
|
|
683
|
-
const t = this.getAttribute("placeholder") || "Reply to Mui...", e = this.getAttribute("value") || "", o = this.getAttribute("rows") || "3", r = this.hasAttribute("disabled"),
|
|
704
|
+
const t = this.getAttribute("placeholder") || "Reply to Mui...", e = this.getAttribute("value") || "", o = this.getAttribute("rows") || "3", r = this.hasAttribute("disabled"), a = this.getAttribute("preview-dialog-width") || "560px", i = this.getAttribute("color-top-start") || "", s = this.getAttribute("color-top-mid") || "", l = this.getAttribute("color-top-end") || "", c = this.getAttribute("color-top-accent") || "", p = (this.getAttribute("color-layout") || "default").toLowerCase() === "swap", h = p ? l || "var(--prompt-color-top-end, var(--green-500))" : i || "var(--prompt-color-top-start, var(--blue-500))", u = p ? c || "var(--prompt-color-top-accent, var(--orange-500))" : s || "var(--prompt-color-top-mid, var(--blue-500))", b = p ? i || "var(--prompt-color-top-start, var(--blue-500))" : l || "var(--prompt-color-top-end, var(--green-500))", g = p ? s || "var(--prompt-color-top-mid, var(--blue-500))" : c || "var(--prompt-color-top-accent, var(--orange-500))", v = this.getAttribute("aria-label"), m = this.getAttribute("aria-labelledby"), y = this.getAttribute("aria-describedby"), A = !v && !m ? "Prompt input" : "", n = (this.getAttribute("error-message") || "").trim(), f = n;
|
|
684
705
|
this.shadowRoot.innerHTML = /*html*/
|
|
685
706
|
`
|
|
686
707
|
<style>
|
|
@@ -688,7 +709,7 @@ class k extends HTMLElement {
|
|
|
688
709
|
display: block;
|
|
689
710
|
--prompt-action-radius: var(--chip-radius-small, var(--radius-400));
|
|
690
711
|
--_prompt-color-top-start-source: ${h};
|
|
691
|
-
--_prompt-color-top-mid-source: ${
|
|
712
|
+
--_prompt-color-top-mid-source: ${u};
|
|
692
713
|
--_prompt-color-top-end-source: ${b};
|
|
693
714
|
--_prompt-color-top-accent-source: ${g};
|
|
694
715
|
--_prompt-accent-primary: var(--prompt-accent-primary, var(--prompt-spectrum-start, var(--blue-500)));
|
|
@@ -1418,9 +1439,9 @@ class k extends HTMLElement {
|
|
|
1418
1439
|
rows="${o}"
|
|
1419
1440
|
placeholder="${t}"
|
|
1420
1441
|
${v ? `aria-label="${v.replace(/"/g, """)}"` : ""}
|
|
1421
|
-
${
|
|
1422
|
-
${
|
|
1423
|
-
${
|
|
1442
|
+
${m ? `aria-labelledby="${m.replace(/"/g, """)}"` : ""}
|
|
1443
|
+
${y ? `aria-describedby="${y.replace(/"/g, """)}"` : ""}
|
|
1444
|
+
${A ? `aria-label="${A}"` : ""}
|
|
1424
1445
|
${r ? "disabled" : ""}
|
|
1425
1446
|
>${e}</textarea>
|
|
1426
1447
|
</slot>
|
|
@@ -1455,7 +1476,7 @@ class k extends HTMLElement {
|
|
|
1455
1476
|
</div>
|
|
1456
1477
|
<div class="error-region" hidden>
|
|
1457
1478
|
|
|
1458
|
-
<mui-body size="x-small" variant="error" class="error-default" ${
|
|
1479
|
+
<mui-body size="x-small" variant="error" class="error-default" ${n ? "" : "hidden"}>
|
|
1459
1480
|
<mui-icon-attention slot="before"></mui-icon-attention>
|
|
1460
1481
|
<span class="error-text">${f}</span>
|
|
1461
1482
|
</mui-body>
|
|
@@ -1469,7 +1490,7 @@ class k extends HTMLElement {
|
|
|
1469
1490
|
|
|
1470
1491
|
<mui-dialog
|
|
1471
1492
|
id="promptAutoPreviewDialog"
|
|
1472
|
-
width="${
|
|
1493
|
+
width="${a}"
|
|
1473
1494
|
content-padding="none"
|
|
1474
1495
|
>
|
|
1475
1496
|
<mui-heading id="promptAutoPreviewTitle" slot="title" size="5">Pasted Content</mui-heading>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/* ================================================================================================== */
|
|
3
|
-
/* Don't edit directly • Generated on Fri, 27 Feb 2026
|
|
3
|
+
/* Don't edit directly • Generated on Fri, 27 Feb 2026 05:46:06 GMT • muibook.com */
|
|
4
4
|
/* ================================================================================================== */
|
|
5
5
|
|
|
6
6
|
/* ================================================================================================== */
|