simpa
Version:
Lightweight library for prototyping Single Page Applications.
75 lines • 2.09 kB
JavaScript
;
/* MIT License
*
* Copyright (c) 2016-2023 Dariusz Depta
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.PasswordField = exports.TextField = void 0;
class InputField {
/** HTML input element */
inputElement;
constructor(inputElementId) {
this.inputElement = document.getElementById(inputElementId);
}
get enabled() {
return !this.inputElement.disabled;
}
set enabled(enabled) {
this.inputElement.disabled = !enabled;
}
get readOnly() {
return this.inputElement.readOnly;
}
set readOnly(readOnly) {
this.inputElement.readOnly = readOnly;
}
get required() {
return this.inputElement.required;
}
set required(required) {
this.inputElement.required = required;
}
clear() {
this.inputElement.value = '';
}
focus() {
this.inputElement.focus();
}
select() {
this.inputElement.select();
}
focusAndSelect() {
this.focus();
this.select();
}
validate() {
return this.inputElement.checkValidity();
}
}
class TextField extends InputField {
constructor(inputElementId) {
super(inputElementId);
}
get value() {
return this.inputElement.value;
}
set value(value) {
this.inputElement.value = value;
}
}
exports.TextField = TextField;
class PasswordField extends TextField {
constructor(inputElementId) {
super(inputElementId);
}
}
exports.PasswordField = PasswordField;
//# sourceMappingURL=fields.js.map