diff --git a/ccp/js/inputwidgetcontroller.js b/ccp/js/inputwidgetcontroller.js index 8aa15b4..836ef19 100644 --- a/ccp/js/inputwidgetcontroller.js +++ b/ccp/js/inputwidgetcontroller.js @@ -71,12 +71,22 @@ class Renderer{ if(this.isDateTime(input)){ return new DateTimeInputRenderer(input) } + if(this.isSecret(input)){ + return new SecretInputRenderer(input) + } return new SimpleInputRenderer(input) } static isEnum(input){ return (input.schema.type === "string") && ("enum" in input.schema) } + + static isSecret(input){ + return (input.schema.type === "string") && + ("format" in input.schema) && + (input.schema.format != null) && + (input.schema.format.toLowerCase() === "secret") + } static isCode(input){ return (input.schema.type === "string") && @@ -121,6 +131,30 @@ class SimpleInputRenderer extends Renderer{ } } +class SecretInputRenderer extends Renderer{ + + #html = null; + + constructor(input){ + super(input) + } + + render(){ + let required = this.required ? 'required="required"' : "" + let readonly = this.readOnly ? 'readonly="readOnly"' : "" + this.#html = ` +
+ + +
+ ` + return this.#html + } +} + class DateTimeInputRenderer extends Renderer{ #html = null; diff --git a/ccp/js/inputwidgeteditorcontroller.js b/ccp/js/inputwidgeteditorcontroller.js index 9d92e52..3bd508b 100644 --- a/ccp/js/inputwidgeteditorcontroller.js +++ b/ccp/js/inputwidgeteditorcontroller.js @@ -81,6 +81,7 @@ class CCPInputWidgetEditorController extends HTMLElement{ + @@ -97,7 +98,7 @@ class CCPInputWidgetEditorController extends HTMLElement{ Comma separated list of options -
+
@@ -126,6 +127,9 @@ class CCPInputWidgetEditorController extends HTMLElement{ } else if(ename === "format"){ this.#input.schema.format = val + if(this.#input.schema.format === "secret"){ + this.querySelector("div[name=input-default] input[name=default]").type = "password" + } } else if(ename === "contentMediaType"){ this.#input.schema.contentMediaType = val