added setValue method

This commit is contained in:
dcore94 2023-02-02 09:41:08 +01:00
parent 2a32bd5f63
commit 8d525c829b
1 changed files with 28 additions and 0 deletions

View File

@ -26,6 +26,10 @@ class CCPInputWidgetController extends HTMLElement {
get value(){
return this.#renderer.getValue(this)
}
set value(v){
return this.#renderer.setValue(this, v)
}
}
window.customElements.define('d4s-ccp-input', CCPInputWidgetController);
@ -125,6 +129,10 @@ class SimpleInputRenderer extends Renderer{
return parent.querySelector("input").value
}
setValue(parent, v){
parent.querySelector("input").value = v
}
render(){
let required = this.required ? 'required="required"' : ""
let readonly = this.readOnly ? 'readonly="readOnly"' : ""
@ -188,6 +196,10 @@ class FileInputRenderer extends Renderer{
return this.#content
}
setValue(parent, v){
parent.querySelector("input").value = v
}
render(){
let required = this.required ? 'required="required"' : ""
let readonly = this.readOnly ? 'readonly="readOnly"' : ""
@ -216,6 +228,10 @@ class SecretInputRenderer extends Renderer{
return parent.querySelector("input").value
}
setValue(parent, v){
parent.querySelector("input").value = v
}
connectedCallback(controller){
controller.addEventListener("click", ev=>{
const ename = ev.target.getAttribute("name")
@ -256,6 +272,10 @@ class DateTimeInputRenderer extends Renderer{
return parent.querySelector("input").value
}
setValue(parent, v){
parent.querySelector("input").value = v
}
render(){
let required = this.required ? 'required="required"' : ""
let readonly = this.schema.readOnly ? 'readonly="readOnly"' : ""
@ -285,6 +305,10 @@ class EnumInputRenderer extends Renderer{
return parent.querySelector("select").value
}
setValue(parent, v){
parent.querySelector("select").value = v
}
render(){
let options = this.schema.enum.map(e => {
return e === this.schema.default ?
@ -321,6 +345,10 @@ class CodeInputRenderer extends Renderer{
return parent.querySelector("textarea").textContent
}
setValue(parent, v){
parent.querySelector("textarea").textContent = v
}
connectedCallback(controller){
/*const ta = controller.querySelector("textarea")
const opts = {