@luftborn/custom-elements 2.1.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demo/index.html +22 -0
- package/demo/index.js +352 -66
- package/demo/index.min.js +351 -65
- package/demo/index.min.js.map +1 -1
- package/dist/elements/Elements.d.ts +3 -1
- package/dist/elements/Elements.js +5 -1
- package/dist/elements/Elements.js.map +1 -1
- package/dist/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.d.ts +1 -0
- package/dist/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.js +8 -5
- package/dist/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.js.map +1 -1
- package/dist/elements/SECompanyRegistrationElement/SECompanyRegistrationElement.d.ts +14 -0
- package/dist/elements/SECompanyRegistrationElement/SECompanyRegistrationElement.js +83 -0
- package/dist/elements/SECompanyRegistrationElement/SECompanyRegistrationElement.js.map +1 -0
- package/dist/elements/SEPersonalNumberElement/SEPersonalNumberElement.d.ts +14 -0
- package/dist/elements/SEPersonalNumberElement/SEPersonalNumberElement.js +83 -0
- package/dist/elements/SEPersonalNumberElement/SEPersonalNumberElement.js.map +1 -0
- package/dist/framework/Validation/Validators/SECompanyRegistration.d.ts +9 -0
- package/dist/framework/Validation/Validators/SECompanyRegistration.js +38 -0
- package/dist/framework/Validation/Validators/SECompanyRegistration.js.map +1 -0
- package/dist/framework/Validation/Validators/SEPersonalNumber.d.ts +6 -0
- package/dist/framework/Validation/Validators/SEPersonalNumber.js +71 -0
- package/dist/framework/Validation/Validators/SEPersonalNumber.js.map +1 -0
- package/package.json +1 -1
- package/src/elements/Elements.ts +5 -1
- package/src/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.ts +7 -5
- package/src/elements/SECompanyRegistrationElement/SECompanyRegistrationElement.ts +73 -0
- package/src/elements/SEPersonalNumberElement/SEPersonalNumberElement.ts +73 -0
- package/src/framework/Validation/Validators/SECompanyRegistration.ts +40 -0
- package/src/framework/Validation/Validators/SEPersonalNumber.ts +80 -0
|
@@ -15,4 +15,6 @@ import { CVRElement } from './CVRElement/CVRElement';
|
|
|
15
15
|
import { IdentificationElement } from './IdentificationElement/IdentificationElement';
|
|
16
16
|
import { BankFieldElement } from './BankField/BankFieldElement';
|
|
17
17
|
import { TypeAheadElement } from './TypeAhead/TypeAheadElement';
|
|
18
|
-
|
|
18
|
+
import { SEPersonalNumberElement } from './SEPersonalNumberElement/SEPersonalNumberElement';
|
|
19
|
+
import { SECompanyRegistrationElement } from './SECompanyRegistrationElement/SECompanyRegistrationElement';
|
|
20
|
+
export { AddressElement, TextFieldElement, EmailFieldElement, CheckBoxElement, RadioButtonGroupElement, TextAreaElement, DropDownListElement, FileFieldElement, NumericFieldElement, CustomRegularExpressionElement, DateFieldElement, IntPhoneFieldElement, CPRElement, CVRElement, IdentificationElement, BankFieldElement, TypeAheadElement, SEPersonalNumberElement, SECompanyRegistrationElement, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TypeAheadElement = exports.BankFieldElement = exports.IdentificationElement = exports.CVRElement = exports.CPRElement = exports.IntPhoneFieldElement = exports.DateFieldElement = exports.CustomRegularExpressionElement = exports.NumericFieldElement = exports.FileFieldElement = exports.DropDownListElement = exports.TextAreaElement = exports.RadioButtonGroupElement = exports.CheckBoxElement = exports.EmailFieldElement = exports.TextFieldElement = exports.AddressElement = void 0;
|
|
3
|
+
exports.SECompanyRegistrationElement = exports.SEPersonalNumberElement = exports.TypeAheadElement = exports.BankFieldElement = exports.IdentificationElement = exports.CVRElement = exports.CPRElement = exports.IntPhoneFieldElement = exports.DateFieldElement = exports.CustomRegularExpressionElement = exports.NumericFieldElement = exports.FileFieldElement = exports.DropDownListElement = exports.TextAreaElement = exports.RadioButtonGroupElement = exports.CheckBoxElement = exports.EmailFieldElement = exports.TextFieldElement = exports.AddressElement = void 0;
|
|
4
4
|
var AddressElement_1 = require("./Address/AddressElement");
|
|
5
5
|
Object.defineProperty(exports, "AddressElement", { enumerable: true, get: function () { return AddressElement_1.AddressElement; } });
|
|
6
6
|
var TextFieldElement_1 = require("./TextField/TextFieldElement");
|
|
@@ -35,4 +35,8 @@ var BankFieldElement_1 = require("./BankField/BankFieldElement");
|
|
|
35
35
|
Object.defineProperty(exports, "BankFieldElement", { enumerable: true, get: function () { return BankFieldElement_1.BankFieldElement; } });
|
|
36
36
|
var TypeAheadElement_1 = require("./TypeAhead/TypeAheadElement");
|
|
37
37
|
Object.defineProperty(exports, "TypeAheadElement", { enumerable: true, get: function () { return TypeAheadElement_1.TypeAheadElement; } });
|
|
38
|
+
var SEPersonalNumberElement_1 = require("./SEPersonalNumberElement/SEPersonalNumberElement");
|
|
39
|
+
Object.defineProperty(exports, "SEPersonalNumberElement", { enumerable: true, get: function () { return SEPersonalNumberElement_1.SEPersonalNumberElement; } });
|
|
40
|
+
var SECompanyRegistrationElement_1 = require("./SECompanyRegistrationElement/SECompanyRegistrationElement");
|
|
41
|
+
Object.defineProperty(exports, "SECompanyRegistrationElement", { enumerable: true, get: function () { return SECompanyRegistrationElement_1.SECompanyRegistrationElement; } });
|
|
38
42
|
//# sourceMappingURL=Elements.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Elements.js","sourceRoot":"","sources":["../../src/elements/Elements.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;
|
|
1
|
+
{"version":3,"file":"Elements.js","sourceRoot":"","sources":["../../src/elements/Elements.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAqBzD,+FArBQ,+BAAc,OAqBR;AApBf,iEAAgE;AAqB/D,iGArBQ,mCAAgB,OAqBR;AApBjB,oEAAmE;AAqBlE,kGArBQ,qCAAiB,OAqBR;AApBlB,qEAAoE;AAqBnE,gGArBQ,iCAAe,OAqBR;AApBhB,sFAAqF;AAqBpF,wGArBQ,iDAAuB,OAqBR;AApBxB,qEAAoE;AAqBnE,gGArBQ,iCAAe,OAqBR;AApBhB,0EAAyE;AAqBxE,oGArBQ,yCAAmB,OAqBR;AApBpB,iEAAgE;AAqB/D,iGArBQ,mCAAgB,OAqBR;AApBjB,0EAAyE;AAqBxE,oGArBQ,yCAAmB,OAqBR;AApBpB,2GAA0G;AAqBzG,+GArBQ,+DAA8B,OAqBR;AApB/B,iEAAgE;AAqB/D,iGArBQ,mCAAgB,OAqBR;AApBjB,2GAAgG;AAqB/F,qGArBQ,qDAAoB,OAqBR;AApBrB,sDAAqD;AAqBpD,2FArBQ,uBAAU,OAqBR;AApBX,sDAAqD;AAqBpD,2FArBQ,uBAAU,OAqBR;AApBX,uFAAsF;AAqBrF,sGArBQ,6CAAqB,OAqBR;AApBtB,iEAAgE;AAqB/D,iGArBQ,mCAAgB,OAqBR;AApBjB,iEAAgE;AAqB/D,iGArBQ,mCAAgB,OAqBR;AApBjB,6FAA4F;AAqBxF,wGArBK,iDAAuB,OAqBL;AApB3B,4GAA2G;AAqBvG,6GArBK,2DAA4B,OAqBL"}
|
|
@@ -32,7 +32,9 @@ var Flags2x_1 = require("./Flags2x");
|
|
|
32
32
|
var IntPhoneFieldElement = /** @class */ (function (_super) {
|
|
33
33
|
__extends(IntPhoneFieldElement, _super);
|
|
34
34
|
function IntPhoneFieldElement() {
|
|
35
|
-
|
|
35
|
+
var _this = _super.call(this) || this;
|
|
36
|
+
_this.UTILS_URL = 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/15.0.1/js/utils.js';
|
|
37
|
+
return _this;
|
|
36
38
|
}
|
|
37
39
|
Object.defineProperty(IntPhoneFieldElement.prototype, "value", {
|
|
38
40
|
get: function () {
|
|
@@ -79,6 +81,7 @@ var IntPhoneFieldElement = /** @class */ (function (_super) {
|
|
|
79
81
|
};
|
|
80
82
|
var isIplookUpDisabled = ((_a = this.getAttribute('data-disable-iplookup')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "true";
|
|
81
83
|
var defaultCountry = isIplookUpDisabled ? 'dk' : 'auto';
|
|
84
|
+
var utilsUrl = this.getAttribute('data-utils-url');
|
|
82
85
|
var country = (_b = this.getAttribute('data-country')) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
83
86
|
this.intlTelInput = intlTelInput(this.phone, {
|
|
84
87
|
geoIpLookup: isIplookUpDisabled ? null : geoIpLookup,
|
|
@@ -86,7 +89,7 @@ var IntPhoneFieldElement = /** @class */ (function (_super) {
|
|
|
86
89
|
initialCountry: country !== null && country !== void 0 ? country : defaultCountry,
|
|
87
90
|
preferredCountries: ["dk", "se", "gb"],
|
|
88
91
|
nationalMode: true,
|
|
89
|
-
utilsScript:
|
|
92
|
+
utilsScript: utilsUrl !== null && utilsUrl !== void 0 ? utilsUrl : this.UTILS_URL,
|
|
90
93
|
});
|
|
91
94
|
this.intlTelInput.promise.then(function (e) {
|
|
92
95
|
setTimeout(function () {
|
|
@@ -95,9 +98,9 @@ var IntPhoneFieldElement = /** @class */ (function (_super) {
|
|
|
95
98
|
});
|
|
96
99
|
var isLocalFlagEnabled = ((_c = this.getAttribute('data-local-flag')) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === "true";
|
|
97
100
|
if (isLocalFlagEnabled) {
|
|
98
|
-
var
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
+
var flagWrappers = this.shadowRoot.querySelectorAll(".iti__flag");
|
|
102
|
+
if (flagWrappers.length > 0) {
|
|
103
|
+
flagWrappers.forEach(function (f) { return f.style.backgroundImage = "url(" + (0, Flags_1.default)() + ")"; });
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternationaPhoneNumberElement.js","sourceRoot":"","sources":["../../../src/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,qFAAqE;AACrE,yEAAwE;AACxE,6DAAsE;AACtE,6CAA+C;AAE/C,qEAAgE;AAChE,iCAAkC;AAClC,qCAAsC;AAoCtC;IAA0C,wCAAkB;
|
|
1
|
+
{"version":3,"file":"InternationaPhoneNumberElement.js","sourceRoot":"","sources":["../../../src/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,qFAAqE;AACrE,yEAAwE;AACxE,6DAAsE;AACtE,6CAA+C;AAE/C,qEAAgE;AAChE,iCAAkC;AAClC,qCAAsC;AAoCtC;IAA0C,wCAAkB;IAM3D;QAAA,YACC,iBAAO,SACP;QAJQ,eAAS,GAAW,0EAA0E,CAAC;;IAIxG,CAAC;IAED,sBAAI,uCAAK;aAAT;YACC,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC;QACtC,CAAC;aAED,UAAU,KAAa;YACtB,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;QAC1B,CAAC;;;OAJA;IAMD,sBAAI,uCAAK;aAAT;YACC,IAAM,YAAY,GACjB,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,CAAC;YACrE,OAAO,YAAY,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QAClD,CAAC;;;OAAA;IAED,gDAAiB,GAAjB;QACC,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,iBAAM,iBAAiB,WAAE,CAAC;IAC3B,CAAC;IAED,8CAAe,GAAf;QACC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9D,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;SACxC;IACF,CAAC;IACD,8CAAe,GAAf;QAAA,iBA0CC;;QAzCA,IAA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,SAAS,EAAE,IAAI;SACf,CAAC;OACW,oBAAoB,CA0FhC;IAAD,2BAAC;CAAA,AA1FD,CAA0C,uCAAkB,GA0F3D;AA1FY,oDAAoB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CustomInputElement } from '../../framework/CustomInputElement';
|
|
2
|
+
import SECompanyRegistrationValidator from '../../framework/Validation/Validators/SECompanyRegistration';
|
|
3
|
+
export declare class SECompanyRegistrationElement extends CustomInputElement {
|
|
4
|
+
text: HTMLInputElement;
|
|
5
|
+
validator: SECompanyRegistrationValidator;
|
|
6
|
+
constructor();
|
|
7
|
+
get value(): string;
|
|
8
|
+
set value(value: string);
|
|
9
|
+
get valid(): boolean;
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
initChildInputs(): void;
|
|
12
|
+
change($event: any): void;
|
|
13
|
+
validate(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.SECompanyRegistrationElement = void 0;
|
|
25
|
+
var custom_element_decorator_1 = require("../../framework/custom-element.decorator");
|
|
26
|
+
var CustomInputElement_1 = require("../../framework/CustomInputElement");
|
|
27
|
+
var CustomEvents_1 = require("../../framework/CustomEvents");
|
|
28
|
+
var SECompanyRegistration_1 = require("../../framework/Validation/Validators/SECompanyRegistration");
|
|
29
|
+
var SECompanyRegistrationElement = /** @class */ (function (_super) {
|
|
30
|
+
__extends(SECompanyRegistrationElement, _super);
|
|
31
|
+
function SECompanyRegistrationElement() {
|
|
32
|
+
var _this = _super.call(this) || this;
|
|
33
|
+
_this.validator = new SECompanyRegistration_1.default();
|
|
34
|
+
return _this;
|
|
35
|
+
}
|
|
36
|
+
Object.defineProperty(SECompanyRegistrationElement.prototype, "value", {
|
|
37
|
+
get: function () {
|
|
38
|
+
return "" + this.text.value;
|
|
39
|
+
},
|
|
40
|
+
set: function (value) {
|
|
41
|
+
this.text.value = value;
|
|
42
|
+
},
|
|
43
|
+
enumerable: false,
|
|
44
|
+
configurable: true
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(SECompanyRegistrationElement.prototype, "valid", {
|
|
47
|
+
get: function () {
|
|
48
|
+
return this.validator.isSatisfiedBy(this.value, !this.required);
|
|
49
|
+
},
|
|
50
|
+
enumerable: false,
|
|
51
|
+
configurable: true
|
|
52
|
+
});
|
|
53
|
+
SECompanyRegistrationElement.prototype.connectedCallback = function () {
|
|
54
|
+
_super.prototype.connectedCallback.call(this);
|
|
55
|
+
};
|
|
56
|
+
SECompanyRegistrationElement.prototype.initChildInputs = function () {
|
|
57
|
+
this.text = _super.prototype.getChildInput.call(this, '#se-company-registration-field');
|
|
58
|
+
this.text.addEventListener('change', this.change.bind(this));
|
|
59
|
+
if (this.required) {
|
|
60
|
+
this.text.setAttribute('required', '');
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
// events
|
|
64
|
+
SECompanyRegistrationElement.prototype.change = function ($event) {
|
|
65
|
+
this.touched = true;
|
|
66
|
+
this.onChange.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'change'));
|
|
67
|
+
};
|
|
68
|
+
SECompanyRegistrationElement.prototype.validate = function () {
|
|
69
|
+
this.valid;
|
|
70
|
+
this.onValidate.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'validate'));
|
|
71
|
+
};
|
|
72
|
+
SECompanyRegistrationElement = __decorate([
|
|
73
|
+
(0, custom_element_decorator_1.default)({
|
|
74
|
+
selector: 'se-company-registration-element',
|
|
75
|
+
template: "\n <div class=\"wrapper\">\n <input type=\"text\" id='se-company-registration-field' placeholder='SSSSSSSSSS'/>\n </div>",
|
|
76
|
+
style: "\n :host{\n width:100%;\n }\n .wrapper{\n display:flex;\n }\n input{\n box-sizing: border-box;\n width: 100% !important;\n border: none;\n background-color: #f1f4ff;\n margin: 2px;\n resize: none;\n }",
|
|
77
|
+
useShadow: true,
|
|
78
|
+
})
|
|
79
|
+
], SECompanyRegistrationElement);
|
|
80
|
+
return SECompanyRegistrationElement;
|
|
81
|
+
}(CustomInputElement_1.CustomInputElement));
|
|
82
|
+
exports.SECompanyRegistrationElement = SECompanyRegistrationElement;
|
|
83
|
+
//# sourceMappingURL=SECompanyRegistrationElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SECompanyRegistrationElement.js","sourceRoot":"","sources":["../../../src/elements/SECompanyRegistrationElement/SECompanyRegistrationElement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;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,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAClD,CAAC;IACH,CAAC;IA3CW,4BAA4B;QAvBxC,IAAA,kCAAa,EAAC;YACd,QAAQ,EAAE,iCAAiC;YAC3C,QAAQ,EAAE,mJAGI;YACd,KAAK,EAAE,4UAcE;YACT,SAAS,EAAE,IAAI;SACf,CAAC;OACW,4BAA4B,CA4CxC;IAAD,mCAAC;CAAA,AA5CD,CAAkD,uCAAkB,GA4CnE;AA5CY,oEAA4B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CustomInputElement } from '../../framework/CustomInputElement';
|
|
2
|
+
import SEPersonalNumberValidator from '../../framework/Validation/Validators/SEPersonalNumber';
|
|
3
|
+
export declare class SEPersonalNumberElement extends CustomInputElement {
|
|
4
|
+
text: HTMLInputElement;
|
|
5
|
+
validator: SEPersonalNumberValidator;
|
|
6
|
+
constructor();
|
|
7
|
+
get value(): string;
|
|
8
|
+
set value(value: string);
|
|
9
|
+
get valid(): boolean;
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
initChildInputs(): void;
|
|
12
|
+
change($event: any): void;
|
|
13
|
+
validate(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.SEPersonalNumberElement = void 0;
|
|
25
|
+
var custom_element_decorator_1 = require("../../framework/custom-element.decorator");
|
|
26
|
+
var CustomInputElement_1 = require("../../framework/CustomInputElement");
|
|
27
|
+
var CustomEvents_1 = require("../../framework/CustomEvents");
|
|
28
|
+
var SEPersonalNumber_1 = require("../../framework/Validation/Validators/SEPersonalNumber");
|
|
29
|
+
var SEPersonalNumberElement = /** @class */ (function (_super) {
|
|
30
|
+
__extends(SEPersonalNumberElement, _super);
|
|
31
|
+
function SEPersonalNumberElement() {
|
|
32
|
+
var _this = _super.call(this) || this;
|
|
33
|
+
_this.validator = new SEPersonalNumber_1.default();
|
|
34
|
+
return _this;
|
|
35
|
+
}
|
|
36
|
+
Object.defineProperty(SEPersonalNumberElement.prototype, "value", {
|
|
37
|
+
get: function () {
|
|
38
|
+
return "" + this.text.value;
|
|
39
|
+
},
|
|
40
|
+
set: function (value) {
|
|
41
|
+
this.text.value = value;
|
|
42
|
+
},
|
|
43
|
+
enumerable: false,
|
|
44
|
+
configurable: true
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(SEPersonalNumberElement.prototype, "valid", {
|
|
47
|
+
get: function () {
|
|
48
|
+
return this.validator.isSatisfiedBy(this.value, !this.required);
|
|
49
|
+
},
|
|
50
|
+
enumerable: false,
|
|
51
|
+
configurable: true
|
|
52
|
+
});
|
|
53
|
+
SEPersonalNumberElement.prototype.connectedCallback = function () {
|
|
54
|
+
_super.prototype.connectedCallback.call(this);
|
|
55
|
+
};
|
|
56
|
+
SEPersonalNumberElement.prototype.initChildInputs = function () {
|
|
57
|
+
this.text = _super.prototype.getChildInput.call(this, '#se-personal-number-field');
|
|
58
|
+
this.text.addEventListener('change', this.change.bind(this));
|
|
59
|
+
if (this.required) {
|
|
60
|
+
this.text.setAttribute('required', '');
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
// events
|
|
64
|
+
SEPersonalNumberElement.prototype.change = function ($event) {
|
|
65
|
+
this.touched = true;
|
|
66
|
+
this.onChange.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'change'));
|
|
67
|
+
};
|
|
68
|
+
SEPersonalNumberElement.prototype.validate = function () {
|
|
69
|
+
this.valid;
|
|
70
|
+
this.onValidate.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'validate'));
|
|
71
|
+
};
|
|
72
|
+
SEPersonalNumberElement = __decorate([
|
|
73
|
+
(0, custom_element_decorator_1.default)({
|
|
74
|
+
selector: 'se-personal-number-element',
|
|
75
|
+
template: "\n <div class=\"wrapper\">\n <input type=\"text\" id='se-personal-number-field' placeholder='(YY)YYMMDD-SSSS'/>\n </div>",
|
|
76
|
+
style: "\n :host{\n width:100%;\n }\n .wrapper{\n display:flex;\n }\n input{\n box-sizing: border-box;\n width: 100% !important;\n border: none;\n background-color: #f1f4ff;\n margin: 2px;\n resize: none;\n }",
|
|
77
|
+
useShadow: true,
|
|
78
|
+
})
|
|
79
|
+
], SEPersonalNumberElement);
|
|
80
|
+
return SEPersonalNumberElement;
|
|
81
|
+
}(CustomInputElement_1.CustomInputElement));
|
|
82
|
+
exports.SEPersonalNumberElement = SEPersonalNumberElement;
|
|
83
|
+
//# sourceMappingURL=SEPersonalNumberElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SEPersonalNumberElement.js","sourceRoot":"","sources":["../../../src/elements/SEPersonalNumberElement/SEPersonalNumberElement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,qFAAqE;AACrE,yEAAwE;AACxE,6DAAsE;AACtE,2FAA+F;AAyB/F;IAA6C,2CAAkB;IAI9D;QAAA,YACC,iBAAO,SACP;QAJD,eAAS,GAA8B,IAAI,0BAAyB,EAAE,CAAC;;IAIvE,CAAC;IAED,sBAAI,0CAAK;aAAT;YACC,OAAO,KAAG,IAAI,CAAC,IAAI,CAAC,KAAO,CAAC;QAC7B,CAAC;aAED,UAAU,KAAa;YACtB,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACzB,CAAC;;;OAJA;IAMD,sBAAI,0CAAK;aAAT;YACC,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjE,CAAC;;;OAAA;IAED,mDAAiB,GAAjB;QACC,iBAAM,iBAAiB,WAAE,CAAC;IAC3B,CAAC;IAED,iDAAe,GAAf;QACC,IAAI,CAAC,IAAI,GAAG,iBAAM,aAAa,YAAC,2BAA2B,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7D,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;SACvC;IACF,CAAC;IAED,SAAS;IACF,wCAAM,GAAb,UAAc,MAAM;QACnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,qCAAsB,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IACtE,CAAC;IAEM,0CAAQ,GAAf;QACC,IAAI,CAAC,KAAK,CAAC;QACX,IAAI,CAAC,UAAU,CAAC,IAAI,CACnB,IAAI,qCAAsB,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAClD,CAAC;IACH,CAAC;IA3CW,uBAAuB;QAvBnC,IAAA,kCAAa,EAAC;YACd,QAAQ,EAAE,4BAA4B;YACtC,QAAQ,EAAE,mJAGI;YACd,KAAK,EAAE,4UAcE;YACT,SAAS,EAAE,IAAI;SACf,CAAC;OACW,uBAAuB,CA4CnC;IAAD,8BAAC;CAAA,AA5CD,CAA6C,uCAAkB,GA4C9D;AA5CY,0DAAuB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import IValidation from '../IValidator.interface';
|
|
2
|
+
export default class SECompanyRegistrationValidator implements IValidation {
|
|
3
|
+
private ORG_NR_SE_LUHN_WEIGHTS;
|
|
4
|
+
private weighted;
|
|
5
|
+
private sum;
|
|
6
|
+
isSatisfiedBy(input: string, allowEmpty: boolean): boolean;
|
|
7
|
+
private orgNrSe;
|
|
8
|
+
private checkLuhnModulus10;
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var SECompanyRegistrationValidator = /** @class */ (function () {
|
|
4
|
+
function SECompanyRegistrationValidator() {
|
|
5
|
+
this.ORG_NR_SE_LUHN_WEIGHTS = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1];
|
|
6
|
+
this.sum = function (a, b) { return a + b; };
|
|
7
|
+
}
|
|
8
|
+
SECompanyRegistrationValidator.prototype.weighted = function (coefficients) {
|
|
9
|
+
return function (value, index) { return value * coefficients[index]; };
|
|
10
|
+
};
|
|
11
|
+
SECompanyRegistrationValidator.prototype.isSatisfiedBy = function (input, allowEmpty) {
|
|
12
|
+
if (allowEmpty && !input) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return this.orgNrSe(input);
|
|
16
|
+
};
|
|
17
|
+
SECompanyRegistrationValidator.prototype.orgNrSe = function (value) {
|
|
18
|
+
return this.checkLuhnModulus10(value, this.ORG_NR_SE_LUHN_WEIGHTS);
|
|
19
|
+
};
|
|
20
|
+
SECompanyRegistrationValidator.prototype.checkLuhnModulus10 = function (testValue, luhnWeights) {
|
|
21
|
+
var length = luhnWeights.length;
|
|
22
|
+
var testValue$ = testValue.replace("-", "");
|
|
23
|
+
if (testValue$.length !== length) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (Number.isNaN(parseInt(testValue$, 10))) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
var digits = testValue$.split("").map(Number);
|
|
30
|
+
var luhnF = function (n) { return (n < length ? n : n - (length - 1)); };
|
|
31
|
+
var luhnSum = luhnWeights.map(this.weighted(digits)).map(luhnF).reduce(this.sum);
|
|
32
|
+
var controlSum = length - (+luhnSum % length);
|
|
33
|
+
return controlSum % 10 === 0;
|
|
34
|
+
};
|
|
35
|
+
return SECompanyRegistrationValidator;
|
|
36
|
+
}());
|
|
37
|
+
exports.default = SECompanyRegistrationValidator;
|
|
38
|
+
//# sourceMappingURL=SECompanyRegistration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SECompanyRegistration.js","sourceRoot":"","sources":["../../../../src/framework/Validation/Validators/SECompanyRegistration.ts"],"names":[],"mappings":";;AAEA;IAAA;QACY,2BAAsB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAKxD,QAAG,GAAG,UAAC,CAAS,EAAE,CAAS,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK,CAAC;IA+BlD,CAAC;IAnC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C,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnF,IAAM,UAAU,GAAG,MAAM,GAAG,CAAC,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;QAChD,OAAO,UAAU,GAAG,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IACL,qCAAC;AAAD,CAAC,AArCD,IAqCC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var SEPersonalNumberValidator = /** @class */ (function () {
|
|
4
|
+
function SEPersonalNumberValidator() {
|
|
5
|
+
this.regex = new RegExp('^(\d{2}){0,1}(\d{2})(\d{2})(\d{2})([\+\-]?)((?!000)\d{3})(\d)$');
|
|
6
|
+
}
|
|
7
|
+
SEPersonalNumberValidator.prototype.isSatisfiedBy = function (input, allowEmpty) {
|
|
8
|
+
if (allowEmpty === void 0) { allowEmpty = true; }
|
|
9
|
+
if (allowEmpty && !input) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
var matches = this.regex.exec(input);
|
|
13
|
+
if (!matches || matches.length < 7) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
var groups = matches;
|
|
17
|
+
var decade = groups[2];
|
|
18
|
+
var century;
|
|
19
|
+
if (groups[1]) {
|
|
20
|
+
century = groups[1];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
var born = new Date().getFullYear() - parseInt(decade, 10);
|
|
24
|
+
if (groups[5] && groups[5] === '+') {
|
|
25
|
+
born -= 100;
|
|
26
|
+
}
|
|
27
|
+
century = born.toString().substring(0, 2);
|
|
28
|
+
}
|
|
29
|
+
// Create date time object.
|
|
30
|
+
var day = parseInt(groups[4], 10);
|
|
31
|
+
var isCoordinationNumber = day > 60;
|
|
32
|
+
day = isCoordinationNumber ? day - 60 : day;
|
|
33
|
+
var realDay = day;
|
|
34
|
+
var year = decade;
|
|
35
|
+
var fullYear = century + decade;
|
|
36
|
+
var month = groups[3];
|
|
37
|
+
var numbers = groups[6] + groups[7];
|
|
38
|
+
var controlNumber = groups[7];
|
|
39
|
+
// Try parse date-time to make sure it's actually a real date.
|
|
40
|
+
if (!Date.parse(fullYear + "-" + month + "-" + realDay)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (this.luhn("" + year + month + day + groups[6]) !== parseInt(controlNumber, 10)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
};
|
|
48
|
+
SEPersonalNumberValidator.prototype.luhn = function (value) {
|
|
49
|
+
// Luhm algorithm doubles every other number in the value.
|
|
50
|
+
// To get the correct checksum digit we aught to append a 0 on the sequence.
|
|
51
|
+
// If the result becomes a two digit number, subtract 9 from the value.
|
|
52
|
+
// If the total sum is not a 0, the last checksum value should be subtracted from 10.
|
|
53
|
+
// The resulting value is the check value that we use as control number.
|
|
54
|
+
// The value passed is a string, so we aught to get the actual integer value from each char (i.e., subtract '0' which is 48).
|
|
55
|
+
var t = value.split('').map(function (d) { return parseInt(d, 10); });
|
|
56
|
+
var sum = 0;
|
|
57
|
+
var temp;
|
|
58
|
+
for (var i = 0; i < t.length; i++) {
|
|
59
|
+
temp = t[i];
|
|
60
|
+
temp *= 2 - (i % 2);
|
|
61
|
+
if (temp > 9) {
|
|
62
|
+
temp -= 9;
|
|
63
|
+
}
|
|
64
|
+
sum += temp;
|
|
65
|
+
}
|
|
66
|
+
return Math.ceil(sum / 10.0) * 10 - sum;
|
|
67
|
+
};
|
|
68
|
+
return SEPersonalNumberValidator;
|
|
69
|
+
}());
|
|
70
|
+
exports.default = SEPersonalNumberValidator;
|
|
71
|
+
//# sourceMappingURL=SEPersonalNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SEPersonalNumber.js","sourceRoot":"","sources":["../../../../src/framework/Validation/Validators/SEPersonalNumber.ts"],"names":[],"mappings":";;AAEA;IAAA;QACY,UAA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ACD,GAAG,IAAI,IAAI,CAAC;SACf;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC;IAC5C,CAAC;IACL,gCAAC;AAAD,CAAC,AA7ED,IA6EC"}
|
package/package.json
CHANGED
package/src/elements/Elements.ts
CHANGED
|
@@ -15,6 +15,8 @@ import { CVRElement } from './CVRElement/CVRElement';
|
|
|
15
15
|
import { IdentificationElement } from './IdentificationElement/IdentificationElement';
|
|
16
16
|
import { BankFieldElement } from './BankField/BankFieldElement';
|
|
17
17
|
import { TypeAheadElement } from './TypeAhead/TypeAheadElement';
|
|
18
|
+
import { SEPersonalNumberElement } from './SEPersonalNumberElement/SEPersonalNumberElement';
|
|
19
|
+
import { SECompanyRegistrationElement } from './SECompanyRegistrationElement/SECompanyRegistrationElement';
|
|
18
20
|
|
|
19
21
|
export {
|
|
20
22
|
AddressElement,
|
|
@@ -33,5 +35,7 @@ export {
|
|
|
33
35
|
CVRElement,
|
|
34
36
|
IdentificationElement,
|
|
35
37
|
BankFieldElement,
|
|
36
|
-
TypeAheadElement
|
|
38
|
+
TypeAheadElement,
|
|
39
|
+
SEPersonalNumberElement,
|
|
40
|
+
SECompanyRegistrationElement,
|
|
37
41
|
};
|
|
@@ -45,6 +45,8 @@ export class IntPhoneFieldElement extends CustomInputElement {
|
|
|
45
45
|
phone: HTMLInputElement;
|
|
46
46
|
fullPhone: HTMLInputElement;
|
|
47
47
|
intlTelInput: Plugin;
|
|
48
|
+
readonly UTILS_URL: string = 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/15.0.1/js/utils.js';
|
|
49
|
+
|
|
48
50
|
constructor() {
|
|
49
51
|
super();
|
|
50
52
|
}
|
|
@@ -93,6 +95,7 @@ export class IntPhoneFieldElement extends CustomInputElement {
|
|
|
93
95
|
};
|
|
94
96
|
const isIplookUpDisabled = this.getAttribute('data-disable-iplookup')?.toLowerCase() === "true";
|
|
95
97
|
const defaultCountry = isIplookUpDisabled ? 'dk' : 'auto';
|
|
98
|
+
const utilsUrl = this.getAttribute('data-utils-url');
|
|
96
99
|
const country = this.getAttribute('data-country')?.toLowerCase();
|
|
97
100
|
this.intlTelInput = intlTelInput(this.phone, {
|
|
98
101
|
geoIpLookup: isIplookUpDisabled ? null : geoIpLookup,
|
|
@@ -100,8 +103,7 @@ export class IntPhoneFieldElement extends CustomInputElement {
|
|
|
100
103
|
initialCountry: country ?? defaultCountry,
|
|
101
104
|
preferredCountries: ["dk", "se", "gb"],
|
|
102
105
|
nationalMode: true,
|
|
103
|
-
utilsScript:
|
|
104
|
-
'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/15.0.1/js/utils.js',
|
|
106
|
+
utilsScript: utilsUrl ?? this.UTILS_URL,
|
|
105
107
|
} as any);
|
|
106
108
|
this.intlTelInput.promise.then(e => {
|
|
107
109
|
setTimeout(() => {
|
|
@@ -111,9 +113,9 @@ export class IntPhoneFieldElement extends CustomInputElement {
|
|
|
111
113
|
|
|
112
114
|
const isLocalFlagEnabled = this.getAttribute('data-local-flag')?.toLowerCase() === "true";
|
|
113
115
|
if (isLocalFlagEnabled) {
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
|
|
116
|
+
const flagWrappers: NodeListOf<HTMLElement> = this.shadowRoot.querySelectorAll(".iti__flag");
|
|
117
|
+
if (flagWrappers.length > 0) {
|
|
118
|
+
flagWrappers.forEach(f => f.style.backgroundImage = `url(${GetFlagsUrl()})`);
|
|
117
119
|
}
|
|
118
120
|
}
|
|
119
121
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import CustomElement from '../../framework/custom-element.decorator';
|
|
2
|
+
import { CustomInputElement } from '../../framework/CustomInputElement';
|
|
3
|
+
import { CustomElementEventArgs } from '../../framework/CustomEvents';
|
|
4
|
+
import SECompanyRegistrationValidator from '../../framework/Validation/Validators/SECompanyRegistration';
|
|
5
|
+
|
|
6
|
+
@CustomElement({
|
|
7
|
+
selector: 'se-company-registration-element',
|
|
8
|
+
template: `
|
|
9
|
+
<div class="wrapper">
|
|
10
|
+
<input type="text" id='se-company-registration-field' placeholder='SSSSSSSSSS'/>
|
|
11
|
+
</div>`,
|
|
12
|
+
style: `
|
|
13
|
+
:host{
|
|
14
|
+
width:100%;
|
|
15
|
+
}
|
|
16
|
+
.wrapper{
|
|
17
|
+
display:flex;
|
|
18
|
+
}
|
|
19
|
+
input{
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
width: 100% !important;
|
|
22
|
+
border: none;
|
|
23
|
+
background-color: #f1f4ff;
|
|
24
|
+
margin: 2px;
|
|
25
|
+
resize: none;
|
|
26
|
+
}`,
|
|
27
|
+
useShadow: true,
|
|
28
|
+
})
|
|
29
|
+
export class SECompanyRegistrationElement extends CustomInputElement {
|
|
30
|
+
text: HTMLInputElement;
|
|
31
|
+
validator: SECompanyRegistrationValidator = new SECompanyRegistrationValidator();
|
|
32
|
+
|
|
33
|
+
constructor() {
|
|
34
|
+
super();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get value(): string {
|
|
38
|
+
return `${this.text.value}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
set value(value: string) {
|
|
42
|
+
this.text.value = value;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get valid(): boolean {
|
|
46
|
+
return this.validator.isSatisfiedBy(this.value, !this.required);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
connectedCallback(): void {
|
|
50
|
+
super.connectedCallback();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
initChildInputs() {
|
|
54
|
+
this.text = super.getChildInput('#se-company-registration-field');
|
|
55
|
+
this.text.addEventListener('change', this.change.bind(this));
|
|
56
|
+
if (this.required) {
|
|
57
|
+
this.text.setAttribute('required', '');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// events
|
|
62
|
+
public change($event): void {
|
|
63
|
+
this.touched = true;
|
|
64
|
+
this.onChange.emit(new CustomElementEventArgs(this.value, 'change'));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public validate(): void {
|
|
68
|
+
this.valid;
|
|
69
|
+
this.onValidate.emit(
|
|
70
|
+
new CustomElementEventArgs(this.value, 'validate'),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|