@dzeio/form-manager
Version:
A powerfull Form Manager
57 lines (56 loc) • 2.03 kB
JavaScript
;
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 DefaultInput_1 = __importDefault(require("./DefaultInput"));
var DateInput = (function (_super) {
__extends(DateInput, _super);
function DateInput() {
return _super !== null && _super.apply(this, arguments) || this;
}
DateInput.prototype.setValue = function (value) {
var format = this.formatValue(value);
if (typeof format === "object") {
this.element.valueAsDate = format;
return;
}
this.element.value = "";
};
DateInput.prototype.getValue = function () {
var date = this.element.valueAsDate;
return date == null ? undefined : date;
};
DateInput.prototype.formatValue = function (val) {
if (typeof val === "object" && typeof val.getDate === "function") {
return val;
}
if (val === "0001-01-01T00:00:00Z") {
return undefined;
}
if (typeof val === "string" || typeof val === "number") {
return new Date(val);
}
return undefined;
};
DateInput.identity = {
input: DateInput,
type: "date",
tagName: "input"
};
return DateInput;
}(DefaultInput_1.default));
exports.default = DateInput;