UNPKG

1.5 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.InputElement = exports.isHTMLInput = exports.IValidityState = void 0;
4class IValidityState {
5 constructor(validity) {
6 this.badInput = validity.badInput;
7 this.customError = validity.customError;
8 this.patternMismatch = validity.patternMismatch;
9 this.rangeOverflow = validity.rangeOverflow;
10 this.rangeUnderflow = validity.rangeUnderflow;
11 this.stepMismatch = validity.stepMismatch;
12 this.tooLong = validity.tooLong;
13 this.tooShort = validity.tooShort;
14 this.typeMismatch = validity.typeMismatch;
15 this.valid = validity.valid;
16 this.valueMissing = validity.valueMissing;
17 }
18}
19exports.IValidityState = IValidityState;
20function isHTMLInput(input) {
21 return input.props === undefined;
22}
23exports.isHTMLInput = isHTMLInput;
24class InputElement {
25 constructor(input) {
26 if (isHTMLInput(input)) {
27 this.name = input.name;
28 this.type = input.type;
29 this.value = input.value;
30 this.validity = new IValidityState(input.validity);
31 this.validationMessage = input.validationMessage;
32 }
33 else {
34 this.name = input.props.name;
35 this.type = undefined;
36 this.value = input.props.value;
37 this.validity = undefined;
38 this.validationMessage = undefined;
39 }
40 }
41}
42exports.InputElement = InputElement;