mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 03:05:38 -05:00
[PYS-12] Format and lint
This commit is contained in:
@@ -9,46 +9,44 @@ export class PyInputBox extends BaseEvalElement {
|
||||
label: string;
|
||||
mount_name: string;
|
||||
constructor() {
|
||||
super();
|
||||
super();
|
||||
|
||||
if (this.hasAttribute('label')) {
|
||||
this.label = this.getAttribute('label');
|
||||
}
|
||||
if (this.hasAttribute('label')) {
|
||||
this.label = this.getAttribute('label');
|
||||
}
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
this.code = htmlDecode(this.innerHTML);
|
||||
this.mount_name = this.id.split("-").join("_");
|
||||
this.innerHTML = '';
|
||||
|
||||
let mainDiv = document.createElement('input');
|
||||
mainDiv.type = "text";
|
||||
addClasses(mainDiv, ["border", "flex-1", "w-full", "mr-3", "border-gray-300", "p-2", "rounded"]);
|
||||
this.code = htmlDecode(this.innerHTML);
|
||||
this.mount_name = this.id.split('-').join('_');
|
||||
this.innerHTML = '';
|
||||
|
||||
mainDiv.id = this.id;
|
||||
this.id = `${this.id}-container`;
|
||||
this.appendChild(mainDiv);
|
||||
const mainDiv = document.createElement('input');
|
||||
mainDiv.type = 'text';
|
||||
addClasses(mainDiv, ['border', 'flex-1', 'w-full', 'mr-3', 'border-gray-300', 'p-2', 'rounded']);
|
||||
|
||||
// now that we appended and the element is attached, lets connect with the event handlers
|
||||
// defined for this widget
|
||||
this.appendChild(mainDiv);
|
||||
this.code = this.code.split("self").join(this.mount_name);
|
||||
let registrationCode = `${this.mount_name} = Element("${ mainDiv.id }")`;
|
||||
if (this.code.includes("def on_keypress")){
|
||||
this.code = this.code.replace("def on_keypress", `def on_keypress_${this.mount_name}`);
|
||||
registrationCode += `\n${this.mount_name}.element.onkeypress = on_keypress_${this.mount_name}`
|
||||
}
|
||||
mainDiv.id = this.id;
|
||||
this.id = `${this.id}-container`;
|
||||
this.appendChild(mainDiv);
|
||||
|
||||
// TODO: For now we delay execution to allow pyodide to load but in the future this
|
||||
// should really wait for it to load..
|
||||
setTimeout(() => {
|
||||
this.eval(this.code).then(() => {
|
||||
this.eval(registrationCode).then(() => {
|
||||
console.log('registered handlers');
|
||||
});
|
||||
});
|
||||
// now that we appended and the element is attached, lets connect with the event handlers
|
||||
// defined for this widget
|
||||
this.appendChild(mainDiv);
|
||||
this.code = this.code.split('self').join(this.mount_name);
|
||||
let registrationCode = `${this.mount_name} = Element("${mainDiv.id}")`;
|
||||
if (this.code.includes('def on_keypress')) {
|
||||
this.code = this.code.replace('def on_keypress', `def on_keypress_${this.mount_name}`);
|
||||
registrationCode += `\n${this.mount_name}.element.onkeypress = on_keypress_${this.mount_name}`;
|
||||
}
|
||||
|
||||
// TODO: For now we delay execution to allow pyodide to load but in the future this
|
||||
// should really wait for it to load..
|
||||
setTimeout(() => {
|
||||
this.eval(this.code).then(() => {
|
||||
this.eval(registrationCode).then(() => {
|
||||
console.log('registered handlers');
|
||||
});
|
||||
});
|
||||
}, 4000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user