UNPKG

@dzeio/form-manager

Version:

A powerfull Form Manager

56 lines (55 loc) 2.18 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var Functions_1 = require("../Functions"); var InputAbstract_1 = __importDefault(require("./InputAbstract")); var DefaultInput = (function (_super) { __extends(DefaultInput, _super); function DefaultInput() { return _super !== null && _super.apply(this, arguments) || this; } DefaultInput.prototype.setValue = function (value) { this.element.value = this.formatValue(value); }; DefaultInput.prototype.getValue = function () { return this.formatValue(this.element.value); }; DefaultInput.prototype.formatValue = function (value) { if (typeof value === "undefined") return ""; return Functions_1.realType(value); }; DefaultInput.prototype.getName = function () { var attr = this.element.getAttribute("name") || this.element.dataset.name; if (attr) return attr; console.error(this.element); throw Error("Error: could not get input name!"); }; DefaultInput.prototype.verify = function () { var val = this.getValue(); if (this.element.hasAttribute("required") && (val === undefined || val === null || val === "")) return false; return true; }; DefaultInput.identity = { input: DefaultInput }; return DefaultInput; }(InputAbstract_1.default)); exports.default = DefaultInput;