function wrapGUI(state, options) {
const root = document.createElement("div");
const gui = GUI(
state,
Object.assign(
{
root: root,
containerCSS: "max-width:600px",
theme: Object.assign({}, (options || {}).theme, {
fontFamily: "'Helvetica', sans-serif",
fontSize: "12px",
fontColor: "black",
controlBgColor: "white",
controlBorderRadius: "2px",
controlBorderColor: "#aaa",
fieldBgColor: "white",
fieldHoverColor: "#f8f8f8",
fieldActiveColor: "#ddd",
fieldBorderColor: "#ccc",
fieldHeight: 35,
sectionHeadingColor: "white",
sectionHeadingBgColor: "#005F87",
sectionHeadingHoverColor: "#005F87",
sectionHeadingBorderColor: "#005F87",
sectionHeadingHeight: 30,
visibilityFontColor: "#fff",
sliderThumbColor: "#005F87",
focusBorderColor: "#888"
})
},
options || {}
)
).$field.onChanges((e) => root.dispatchEvent(new CustomEvent("input")));
root.value = state;
const checkboxInputs = root.querySelectorAll(
'[class|="controlPanel"] input[type="checkbox" i]'
);
function handleInputChange(e) {
let target = e.target;
let label = document.querySelector(`label[for="${target.id}"]`);
label.textContent = `${target.checked ? "Enabled" : "Disabled"}`;
target.insertAdjacentElement("afterend", label);
}
checkboxInputs.forEach((input) => {
const label = document.createElement("label");
label.setAttribute("for", input.id);
label.innerText = `${input.checked ? "Enabled" : "Disabled"}`;
input.parentNode.insertBefore(label, input.parentNode.nextSibling);
input.addEventListener("change", (event) => {
const label = event.target.parentNode.querySelector("label");
label.textContent = event.target.checked ? "Enabled" : "Disabled";
});
});
return root;
}