mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-25 15:55:18 +00:00
Support dataset when creating elements
Allow dialog to show element and override buttons
This commit is contained in:
parent
ebd7f9bf80
commit
357c0753f8
@ -8,14 +8,18 @@ export function $el(tag, propsOrChildren, children) {
|
||||
if (Array.isArray(propsOrChildren)) {
|
||||
element.append(...propsOrChildren);
|
||||
} else {
|
||||
const parent = propsOrChildren.parent;
|
||||
const { parent, $: cb, dataset, style } = propsOrChildren;
|
||||
delete propsOrChildren.parent;
|
||||
const cb = propsOrChildren.$;
|
||||
delete propsOrChildren.$;
|
||||
delete propsOrChildren.dataset;
|
||||
delete propsOrChildren.style;
|
||||
|
||||
if (propsOrChildren.style) {
|
||||
Object.assign(element.style, propsOrChildren.style);
|
||||
delete propsOrChildren.style;
|
||||
if (style) {
|
||||
Object.assign(element.style, style);
|
||||
}
|
||||
|
||||
if (dataset) {
|
||||
Object.assign(element.dataset, dataset);
|
||||
}
|
||||
|
||||
Object.assign(element, propsOrChildren);
|
||||
@ -76,7 +80,7 @@ function dragElement(dragEl, settings) {
|
||||
dragEl.style.left = newPosX + "px";
|
||||
dragEl.style.right = "unset";
|
||||
}
|
||||
|
||||
|
||||
dragEl.style.top = newPosY + "px";
|
||||
dragEl.style.bottom = "unset";
|
||||
|
||||
@ -145,7 +149,7 @@ function dragElement(dragEl, settings) {
|
||||
}
|
||||
|
||||
window.addEventListener("resize", () => {
|
||||
ensureInBounds();
|
||||
ensureInBounds();
|
||||
});
|
||||
|
||||
function closeDragElement() {
|
||||
@ -155,26 +159,33 @@ function dragElement(dragEl, settings) {
|
||||
}
|
||||
}
|
||||
|
||||
class ComfyDialog {
|
||||
export class ComfyDialog {
|
||||
constructor() {
|
||||
this.element = $el("div.comfy-modal", { parent: document.body }, [
|
||||
$el("div.comfy-modal-content", [
|
||||
$el("p", { $: (p) => (this.textElement = p) }),
|
||||
$el("button", {
|
||||
type: "button",
|
||||
textContent: "Close",
|
||||
onclick: () => this.close(),
|
||||
}),
|
||||
]),
|
||||
$el("div.comfy-modal-content", [$el("p", { $: (p) => (this.textElement = p) }), ...this.createButtons()]),
|
||||
]);
|
||||
}
|
||||
|
||||
createButtons() {
|
||||
return [
|
||||
$el("button", {
|
||||
type: "button",
|
||||
textContent: "Close",
|
||||
onclick: () => this.close(),
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
close() {
|
||||
this.element.style.display = "none";
|
||||
}
|
||||
|
||||
show(html) {
|
||||
this.textElement.innerHTML = html;
|
||||
if (typeof html === "string") {
|
||||
this.textElement.innerHTML = html;
|
||||
} else {
|
||||
this.textElement.replaceChildren(html);
|
||||
}
|
||||
this.element.style.display = "flex";
|
||||
}
|
||||
}
|
||||
@ -419,7 +430,7 @@ export class ComfyUI {
|
||||
type: "boolean",
|
||||
defaultValue: true,
|
||||
});
|
||||
|
||||
|
||||
const fileInput = $el("input", {
|
||||
type: "file",
|
||||
accept: ".json,image/png",
|
||||
|
Loading…
Reference in New Issue
Block a user