@luftborn/custom-elements 1.1.44 → 1.4.1
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/README.md +2 -2
- package/assets/style.css +277 -277
- package/azure-pipeline.yml +54 -0
- package/demo/index.html +585 -585
- package/demo/index.js +6109 -0
- package/demo/index.min.js +6110 -0
- package/demo/index.min.js.map +1 -0
- package/demo/index.ts +11 -11
- package/demo/old/index.html +586 -586
- package/demo/old/index.js +10849 -10849
- package/demo/old/index.min.js +10850 -10850
- package/demo/old/index.ts +10 -10
- package/dist/custom-form.d.ts +20 -20
- package/dist/custom-form.js +147 -146
- package/dist/custom-form.js.map +1 -1
- package/dist/elements/Address/AddressElement.d.ts +28 -28
- package/dist/elements/Address/AddressElement.js +206 -206
- package/dist/elements/BankField/BankFieldElement.d.ts +22 -22
- package/dist/elements/BankField/BankFieldElement.js +127 -127
- package/dist/elements/CPRElement/CPRElement.d.ts +14 -14
- package/dist/elements/CPRElement/CPRElement.js +82 -82
- package/dist/elements/CVRElement/CVRElement.d.ts +14 -14
- package/dist/elements/CVRElement/CVRElement.js +82 -82
- package/dist/elements/CheckBoxElement/CheckBoxElement.d.ts +14 -14
- package/dist/elements/CheckBoxElement/CheckBoxElement.js +96 -96
- package/dist/elements/CheckBoxElement/CheckBoxElement.js.map +1 -1
- package/dist/elements/CustomRegularExpression/CustomRegularExpressionElement.d.ts +12 -12
- package/dist/elements/CustomRegularExpression/CustomRegularExpressionElement.js +82 -82
- package/dist/elements/DateField/DateFieldElement.d.ts +12 -12
- package/dist/elements/DateField/DateFieldElement.js +85 -85
- package/dist/elements/DropDownList/DropDownListElement.d.ts +14 -14
- package/dist/elements/DropDownList/DropDownListElement.js +93 -93
- package/dist/elements/DropDownList/DropDownListElement.js.map +1 -1
- package/dist/elements/Elements.d.ts +18 -18
- package/dist/elements/Elements.js +37 -37
- package/dist/elements/EmailField/EmailFieldElement.d.ts +13 -13
- package/dist/elements/EmailField/EmailFieldElement.js +83 -83
- package/dist/elements/FileField/FileFieldElement.d.ts +15 -12
- package/dist/elements/FileField/FileFieldElement.js +103 -83
- package/dist/elements/FileField/FileFieldElement.js.map +1 -1
- package/dist/elements/IdentificationElement/IdentificationElement.d.ts +18 -18
- package/dist/elements/IdentificationElement/IdentificationElement.js +94 -94
- package/dist/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.d.ts +16 -16
- package/dist/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.js +114 -108
- package/dist/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.js.map +1 -1
- package/dist/elements/NumericField/NumericFieldElement.d.ts +12 -12
- package/dist/elements/NumericField/NumericFieldElement.js +91 -91
- package/dist/elements/RadioButtonGroup/RadioButtonGroupElement.d.ts +14 -14
- package/dist/elements/RadioButtonGroup/RadioButtonGroupElement.js +99 -99
- package/dist/elements/RadioButtonGroup/RadioButtonGroupElement.js.map +1 -1
- package/dist/elements/TextAreaElement/TextAreaElement.d.ts +12 -12
- package/dist/elements/TextAreaElement/TextAreaElement.js +79 -79
- package/dist/elements/TextField/TextFieldElement.d.ts +12 -12
- package/dist/elements/TextField/TextFieldElement.js +79 -79
- package/dist/elements/TypeAhead/TypeAheadElement.d.ts +24 -24
- package/dist/elements/TypeAhead/TypeAheadElement.js +209 -209
- package/dist/framework/CustomEvents.d.ts +21 -21
- package/dist/framework/CustomEvents.js +47 -47
- package/dist/framework/CustomInputElement.d.ts +50 -50
- package/dist/framework/CustomInputElement.js +258 -257
- package/dist/framework/CustomInputElement.js.map +1 -1
- package/dist/framework/Language/Languages/Base/BaseDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/Base/BaseDictionary.js +20 -20
- package/dist/framework/Language/Languages/CzechDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/CzechDictionary.js +40 -0
- package/dist/framework/Language/Languages/CzechDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/DanishDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/DanishDictionary.js +39 -39
- package/dist/framework/Language/Languages/DutchDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/DutchDictionary.js +40 -0
- package/dist/framework/Language/Languages/DutchDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/EnglishDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/EnglishDictionary.js +39 -39
- package/dist/framework/Language/Languages/EstonianDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/EstonianDictionary.js +40 -0
- package/dist/framework/Language/Languages/EstonianDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/FinnishDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/FinnishDictionary.js +40 -0
- package/dist/framework/Language/Languages/FinnishDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/FrenchDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/FrenchDictionary.js +40 -0
- package/dist/framework/Language/Languages/FrenchDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/GermanDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/GermanDictionary.js +40 -0
- package/dist/framework/Language/Languages/GermanDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/GreekDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/GreekDictionary.js +40 -0
- package/dist/framework/Language/Languages/GreekDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/HungarianDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/HungarianDictionary.js +40 -0
- package/dist/framework/Language/Languages/HungarianDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/IcelandicDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/IcelandicDictionary.js +40 -0
- package/dist/framework/Language/Languages/IcelandicDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/ItalianDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/ItalianDictionary.js +40 -0
- package/dist/framework/Language/Languages/ItalianDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/LatvianDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/LatvianDictionary.js +40 -0
- package/dist/framework/Language/Languages/LatvianDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/LituanianDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/LituanianDictionary.js +40 -0
- package/dist/framework/Language/Languages/LituanianDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/NorwegianDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/NorwegianDictionary.js +40 -0
- package/dist/framework/Language/Languages/NorwegianDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/PolishDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/PolishDictionary.js +40 -0
- package/dist/framework/Language/Languages/PolishDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/PortugueseDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/PortugueseDictionary.js +40 -0
- package/dist/framework/Language/Languages/PortugueseDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/SpanishDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/SpanishDictionary.js +40 -0
- package/dist/framework/Language/Languages/SpanishDictionary.js.map +1 -0
- package/dist/framework/Language/Languages/SwedishDictionary.d.ts +4 -0
- package/dist/framework/Language/Languages/SwedishDictionary.js +40 -0
- package/dist/framework/Language/Languages/SwedishDictionary.js.map +1 -0
- package/dist/framework/Language/Translator.d.ts +23 -6
- package/dist/framework/Language/Translator.js +115 -32
- package/dist/framework/Language/Translator.js.map +1 -1
- package/dist/framework/Models/OptionWithDescription.d.ts +6 -6
- package/dist/framework/Models/OptionWithDescription.js +9 -9
- package/dist/framework/Polyfills/getAttributeNamesPolyfill.d.ts +1 -1
- package/dist/framework/Polyfills/getAttributeNamesPolyfill.js +17 -17
- package/dist/framework/Translations/CaseConverter.d.ts +5 -5
- package/dist/framework/Translations/CaseConverter.js +50 -50
- package/dist/framework/Utilities/ArrayUtil.d.ts +6 -0
- package/dist/framework/Utilities/ArrayUtil.js +37 -0
- package/dist/framework/Utilities/ArrayUtil.js.map +1 -0
- package/dist/framework/Utilities/DomUtil.d.ts +21 -0
- package/dist/framework/Utilities/DomUtil.js +102 -0
- package/dist/framework/Utilities/DomUtil.js.map +1 -0
- package/dist/framework/Utilities/DomUtility.d.ts +3 -3
- package/dist/framework/Utilities/DomUtility.js +12 -12
- package/dist/framework/Utilities/MakeRequest.d.ts +8 -0
- package/dist/framework/Utilities/MakeRequest.js +49 -0
- package/dist/framework/Utilities/MakeRequest.js.map +1 -0
- package/dist/framework/Utilities/StringUtil.d.ts +4 -0
- package/dist/framework/Utilities/StringUtil.js +17 -0
- package/dist/framework/Utilities/StringUtil.js.map +1 -0
- package/dist/framework/Utilities/ViewportUtil.d.ts +8 -0
- package/dist/framework/Utilities/ViewportUtil.js +43 -0
- package/dist/framework/Utilities/ViewportUtil.js.map +1 -0
- package/dist/framework/Utilities/debouncer.d.ts +8 -8
- package/dist/framework/Utilities/debouncer.js +51 -51
- package/dist/framework/Validation/IValidator.interface.d.ts +3 -3
- package/dist/framework/Validation/IValidator.interface.js +2 -2
- package/dist/framework/Validation/Validators/BankAccount.d.ts +4 -4
- package/dist/framework/Validation/Validators/BankAccount.js +12 -12
- package/dist/framework/Validation/Validators/BankAccountRegistrationNumber.d.ts +4 -4
- package/dist/framework/Validation/Validators/BankAccountRegistrationNumber.js +12 -12
- package/dist/framework/Validation/Validators/BankIdNorway.d.ts +5 -5
- package/dist/framework/Validation/Validators/BankIdNorway.js +21 -21
- package/dist/framework/Validation/Validators/BankIdSweden.d.ts +5 -5
- package/dist/framework/Validation/Validators/BankIdSweden.js +21 -21
- package/dist/framework/Validation/Validators/CPR.d.ts +9 -9
- package/dist/framework/Validation/Validators/CPR.js +75 -75
- package/dist/framework/Validation/Validators/CVR.d.ts +5 -5
- package/dist/framework/Validation/Validators/CVR.js +30 -30
- package/dist/framework/custom-element.decorator.d.ts +9 -9
- package/dist/framework/custom-element.decorator.js +51 -51
- package/dist/index.d.ts +7 -7
- package/dist/index.js +14 -14
- package/node_modules/@webcomponents/webcomponentsjs/CHANGELOG.md +15 -0
- package/node_modules/@webcomponents/webcomponentsjs/README.md +13 -0
- package/node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-ce.js +31 -31
- package/node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-ce.js.map +1 -1
- package/node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-pf_dom.js +15 -13
- package/node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-pf_dom.js.map +1 -1
- package/node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-pf_js.js.map +1 -1
- package/node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-sd-ce-pf.js +237 -223
- package/node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-sd-ce-pf.js.map +1 -1
- package/node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-sd-ce.js +188 -176
- package/node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-sd-ce.js.map +1 -1
- package/node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-sd.js +155 -144
- package/node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-sd.js.map +1 -1
- package/node_modules/@webcomponents/webcomponentsjs/package.json +31 -64
- package/node_modules/@webcomponents/webcomponentsjs/src/entrypoints/webcomponents-pf_dom-index.js +2 -0
- package/node_modules/@webcomponents/webcomponentsjs/src/platform/event-listener-options.js +122 -0
- package/node_modules/@webcomponents/webcomponentsjs/src/platform/toggle-attribute.js +39 -0
- package/node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.d.ts +1 -0
- package/node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js +239 -225
- package/node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js.map +1 -1
- package/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js +35 -3
- package/package.json +38 -39
- package/src/custom-form.ts +140 -139
- package/src/elements/Address/AddressElement.ts +216 -216
- package/src/elements/BankField/BankFieldElement.ts +127 -127
- package/src/elements/CPRElement/CPRElement.ts +74 -74
- package/src/elements/CVRElement/CVRElement.ts +75 -75
- package/src/elements/CheckBoxElement/CheckBoxElement.ts +99 -99
- package/src/elements/CustomRegularExpression/CustomRegularExpressionElement.ts +75 -75
- package/src/elements/DateField/DateFieldElement.ts +78 -78
- package/src/elements/DropDownList/DropDownListElement.ts +100 -100
- package/src/elements/Elements.ts +37 -37
- package/src/elements/EmailField/EmailFieldElement.ts +78 -78
- package/src/elements/FileField/FileFieldElement.ts +96 -76
- package/src/elements/IdentificationElement/IdentificationElement.ts +104 -104
- package/src/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.ts +116 -111
- package/src/elements/NumericField/NumericFieldElement.ts +84 -84
- package/src/elements/RadioButtonGroup/RadioButtonGroupElement.ts +103 -103
- package/src/elements/TextAreaElement/TextAreaElement.ts +72 -72
- package/src/elements/TextField/TextFieldElement.ts +72 -72
- package/src/elements/TypeAhead/TypeAheadElement.ts +248 -248
- package/src/framework/CustomEvents.ts +47 -47
- package/src/framework/CustomInputElement.ts +277 -276
- package/src/framework/Language/Languages/Base/BaseDictionary.ts +15 -15
- package/src/framework/Language/Languages/CzechDictionary.ts +18 -0
- package/src/framework/Language/Languages/DanishDictionary.ts +17 -17
- package/src/framework/Language/Languages/DutchDictionary.ts +18 -0
- package/src/framework/Language/Languages/EnglishDictionary.ts +18 -18
- package/src/framework/Language/Languages/EstonianDictionary.ts +18 -0
- package/src/framework/Language/Languages/FinnishDictionary.ts +18 -0
- package/src/framework/Language/Languages/FrenchDictionary.ts +18 -0
- package/src/framework/Language/Languages/GermanDictionary.ts +18 -0
- package/src/framework/Language/Languages/GreekDictionary.ts +18 -0
- package/src/framework/Language/Languages/HungarianDictionary.ts +18 -0
- package/src/framework/Language/Languages/IcelandicDictionary.ts +18 -0
- package/src/framework/Language/Languages/ItalianDictionary.ts +18 -0
- package/src/framework/Language/Languages/LatvianDictionary.ts +18 -0
- package/src/framework/Language/Languages/LituanianDictionary.ts +18 -0
- package/src/framework/Language/Languages/NorwegianDictionary.ts +18 -0
- package/src/framework/Language/Languages/PolishDictionary.ts +18 -0
- package/src/framework/Language/Languages/PortugueseDictionary.ts +18 -0
- package/src/framework/Language/Languages/SpanishDictionary.ts +18 -0
- package/src/framework/Language/Languages/SwedishDictionary.ts +18 -0
- package/src/framework/Language/Translator.ts +110 -26
- package/src/framework/Models/OptionWithDescription.ts +8 -8
- package/src/framework/Polyfills/getAttributeNamesPolyfill.ts +13 -13
- package/src/framework/Translations/CaseConverter.ts +43 -43
- package/src/framework/Utilities/ArrayUtil.ts +31 -0
- package/src/framework/Utilities/DomUtil.ts +117 -0
- package/src/framework/Utilities/DomUtility.ts +6 -6
- package/src/framework/Utilities/MakeRequest.ts +47 -0
- package/src/framework/Utilities/StringUtil.ts +9 -0
- package/src/framework/Utilities/ViewportUtil.ts +46 -0
- package/src/framework/Utilities/debouncer.ts +66 -66
- package/src/framework/Validation/IValidator.interface.ts +3 -3
- package/src/framework/Validation/Validators/BankAccount.ts +7 -7
- package/src/framework/Validation/Validators/BankAccountRegistrationNumber.ts +8 -8
- package/src/framework/Validation/Validators/BankIdNorway.ts +21 -21
- package/src/framework/Validation/Validators/BankIdSweden.ts +21 -21
- package/src/framework/Validation/Validators/CPR.ts +82 -82
- package/src/framework/Validation/Validators/CVR.ts +27 -27
- package/src/framework/custom-element.decorator.ts +57 -57
- package/src/index.ts +12 -12
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ViewportUtil } from './ViewportUtil';
|
|
2
|
+
|
|
3
|
+
export default class DomUtil {
|
|
4
|
+
private viewPortUtil: ViewportUtil;
|
|
5
|
+
public element: Element;
|
|
6
|
+
constructor(element: Element) {
|
|
7
|
+
this.element = element;
|
|
8
|
+
this.viewPortUtil = new ViewportUtil(this.element as HTMLElement);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public getDataAttr(attr: string, defaultvalue?: string): any {
|
|
12
|
+
if (!this.element) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const value = this.element.getAttribute(`data-${attr}`);
|
|
16
|
+
|
|
17
|
+
return value !== undefined ? value : defaultvalue;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public setDataAttr(attr: string, value: string): any {
|
|
21
|
+
if (!this.element) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return this.element.setAttribute(`data-${attr}`, value);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public getAttr(attr: string, defaultvalue?: string): any {
|
|
28
|
+
if (!this.element) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const value = this.element.getAttribute(attr);
|
|
32
|
+
return value !== undefined ? value : defaultvalue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public setAttr(attr: string, value: string): void {
|
|
36
|
+
if (!this.element) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
this.element.setAttribute(attr, value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public removeAttr(attr: string): void {
|
|
43
|
+
if (!this.element) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
this.element.removeAttribute(attr);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public removeDataAttr(attr: string): void {
|
|
50
|
+
if (!this.element) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
this.element.removeAttribute(`data-${attr}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public hasAttr(attr: string): boolean {
|
|
57
|
+
if (!this.element) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return this.element.hasAttribute(attr);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public shake(): void {
|
|
64
|
+
this.appendClass('shake');
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
this.removeClass('shake');
|
|
67
|
+
(this.element as HTMLInputElement).readOnly = false;
|
|
68
|
+
}, 600);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public error(): void {
|
|
72
|
+
this.appendClass('error');
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
this.removeClass('error');
|
|
75
|
+
(this.element as HTMLInputElement).readOnly = false;
|
|
76
|
+
}, 5000);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public focus(): void {
|
|
80
|
+
if (!this.viewPortUtil.IsVisible()) {
|
|
81
|
+
this.element.scrollIntoView();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public removeClass(classname): void {
|
|
86
|
+
this.element.classList.remove(classname);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public appendClass(classname): void {
|
|
90
|
+
this.element.classList.add(classname);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public deleteElement(): void {
|
|
94
|
+
if (!this.element) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
this.element.remove();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public setChildElementByAttrName(name: string, value: string): void {
|
|
101
|
+
const firstLetter = name.replace(/^\w/, c => c.toUpperCase());
|
|
102
|
+
const SubElement = this.element.querySelector(
|
|
103
|
+
`[name="${firstLetter}"]`,
|
|
104
|
+
) as HTMLInputElement;
|
|
105
|
+
if (SubElement) {
|
|
106
|
+
SubElement.value = value;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public hasClass(className: string): boolean {
|
|
111
|
+
return this.element.classList.contains(className);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public getStyle(ruleName: string) {
|
|
115
|
+
return getComputedStyle(this.element)[ruleName];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export default class DomUtility {
|
|
2
|
-
|
|
3
|
-
// https://stackoverflow.com/questions/1230445/javascript-regex-how-to-bold-specific-words-with-regex
|
|
4
|
-
static boldenText(inputText: string, matchindTextToBolden: string) {
|
|
5
|
-
return inputText.replace(new RegExp('(^|)(' + matchindTextToBolden + ')(|$)', 'ig'), '$1<b>$2</b>$3');
|
|
6
|
-
}
|
|
1
|
+
export default class DomUtility {
|
|
2
|
+
|
|
3
|
+
// https://stackoverflow.com/questions/1230445/javascript-regex-how-to-bold-specific-words-with-regex
|
|
4
|
+
static boldenText(inputText: string, matchindTextToBolden: string) {
|
|
5
|
+
return inputText.replace(new RegExp('(^|)(' + matchindTextToBolden + ')(|$)', 'ig'), '$1<b>$2</b>$3');
|
|
6
|
+
}
|
|
7
7
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export default class MakeRequest {
|
|
2
|
+
method: string;
|
|
3
|
+
url: string;
|
|
4
|
+
headers: any;
|
|
5
|
+
|
|
6
|
+
constructor(url: string, method: string = 'get', headers: any = {}) {
|
|
7
|
+
this.method = method;
|
|
8
|
+
this.url = url;
|
|
9
|
+
this.headers = headers;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
private setHeaders(httpRequest: XMLHttpRequest) {
|
|
13
|
+
for (const header in this.headers) {
|
|
14
|
+
httpRequest.setRequestHeader(header, this.headers[header]);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
send(data: any = null) {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const xmlHttpRequest = new XMLHttpRequest();
|
|
21
|
+
xmlHttpRequest.open(this.method, this.url);
|
|
22
|
+
this.setHeaders(xmlHttpRequest);
|
|
23
|
+
xmlHttpRequest.onload = () => {
|
|
24
|
+
if (
|
|
25
|
+
xmlHttpRequest.status >= 200 &&
|
|
26
|
+
xmlHttpRequest.status < 300
|
|
27
|
+
) {
|
|
28
|
+
resolve(xmlHttpRequest.response);
|
|
29
|
+
} else {
|
|
30
|
+
reject({
|
|
31
|
+
status: xmlHttpRequest.status,
|
|
32
|
+
statusText: xmlHttpRequest.statusText,
|
|
33
|
+
body: xmlHttpRequest.response,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
xmlHttpRequest.onerror = () => {
|
|
38
|
+
reject({
|
|
39
|
+
status: xmlHttpRequest.status,
|
|
40
|
+
statusText: xmlHttpRequest.statusText,
|
|
41
|
+
body: xmlHttpRequest.response,
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
xmlHttpRequest.send(data);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export class ViewportUtil {
|
|
2
|
+
private element?: HTMLElement;
|
|
3
|
+
constructor(element: HTMLElement = null) {
|
|
4
|
+
this.element = element;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
public IsVisible(): boolean {
|
|
8
|
+
const bounds = this.element.getBoundingClientRect();
|
|
9
|
+
return (
|
|
10
|
+
((bounds.top > 0 && bounds.top < innerHeight) ||
|
|
11
|
+
(bounds.bottom > 0 && bounds.bottom < innerHeight)) &&
|
|
12
|
+
((bounds.left > 0 && bounds.left < innerWidth) ||
|
|
13
|
+
(bounds.right > 0 && bounds.right < innerWidth))
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public IsPartiallyVisible() {
|
|
18
|
+
const bounds = this.element.getBoundingClientRect();
|
|
19
|
+
return (
|
|
20
|
+
bounds.top >= 0 ||
|
|
21
|
+
bounds.left >= 0 ||
|
|
22
|
+
bounds.bottom <= innerHeight ||
|
|
23
|
+
bounds.right <= innerWidth
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public IsOffsetVisible(offset: number = 300) {
|
|
28
|
+
const bounds = this.element.getBoundingClientRect();
|
|
29
|
+
// tslint:disable-next-line: max-line-length
|
|
30
|
+
return (
|
|
31
|
+
bounds.top + offset >= 0 ||
|
|
32
|
+
bounds.left + offset >= 0 ||
|
|
33
|
+
bounds.bottom - offset <= innerHeight ||
|
|
34
|
+
bounds.right - offset <= innerWidth
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public WindowTop(offset: number = 0) {
|
|
39
|
+
const YOffset =
|
|
40
|
+
window.pageYOffset ||
|
|
41
|
+
document.documentElement.scrollTop ||
|
|
42
|
+
document.body.scrollTop ||
|
|
43
|
+
0;
|
|
44
|
+
return offset <= YOffset;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
type Procedure = (...args: any[]) => any;
|
|
2
|
-
|
|
3
|
-
interface Debounce {
|
|
4
|
-
(...args: any[]): any;
|
|
5
|
-
clear: () => void;
|
|
6
|
-
flush: () => void;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const debouncer = (func: Procedure, wait: number, immediate: boolean = false) => {
|
|
10
|
-
let timeout: number | null;
|
|
11
|
-
let args: any;
|
|
12
|
-
let context: any;
|
|
13
|
-
let result: any;
|
|
14
|
-
|
|
15
|
-
const later = () => {
|
|
16
|
-
timeout = null;
|
|
17
|
-
if (!immediate) {
|
|
18
|
-
result = func.apply(context, args);
|
|
19
|
-
context = args = null;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const debouncedFunc: Procedure = function (this: any) {
|
|
24
|
-
context = this;
|
|
25
|
-
args = arguments;
|
|
26
|
-
const callNow = immediate && !timeout;
|
|
27
|
-
|
|
28
|
-
if (!timeout) {
|
|
29
|
-
timeout = window.setTimeout(later, wait);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (callNow) {
|
|
33
|
-
result = func.apply(context, args);
|
|
34
|
-
context = args = null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const clear = () => {
|
|
41
|
-
if (timeout) {
|
|
42
|
-
clearTimeout(timeout);
|
|
43
|
-
timeout = null;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const flush = () => {
|
|
48
|
-
if (timeout) {
|
|
49
|
-
result = func.apply(context, args);
|
|
50
|
-
context = args = null;
|
|
51
|
-
|
|
52
|
-
clearTimeout(timeout);
|
|
53
|
-
timeout = null;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const debounced: Debounce = (() => {
|
|
58
|
-
const f: any = debouncedFunc;
|
|
59
|
-
f.clear = clear;
|
|
60
|
-
f.flush = flush;
|
|
61
|
-
return f;
|
|
62
|
-
})();
|
|
63
|
-
|
|
64
|
-
return debounced;
|
|
65
|
-
};
|
|
66
|
-
|
|
1
|
+
type Procedure = (...args: any[]) => any;
|
|
2
|
+
|
|
3
|
+
interface Debounce {
|
|
4
|
+
(...args: any[]): any;
|
|
5
|
+
clear: () => void;
|
|
6
|
+
flush: () => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const debouncer = (func: Procedure, wait: number, immediate: boolean = false) => {
|
|
10
|
+
let timeout: number | null;
|
|
11
|
+
let args: any;
|
|
12
|
+
let context: any;
|
|
13
|
+
let result: any;
|
|
14
|
+
|
|
15
|
+
const later = () => {
|
|
16
|
+
timeout = null;
|
|
17
|
+
if (!immediate) {
|
|
18
|
+
result = func.apply(context, args);
|
|
19
|
+
context = args = null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const debouncedFunc: Procedure = function (this: any) {
|
|
24
|
+
context = this;
|
|
25
|
+
args = arguments;
|
|
26
|
+
const callNow = immediate && !timeout;
|
|
27
|
+
|
|
28
|
+
if (!timeout) {
|
|
29
|
+
timeout = window.setTimeout(later, wait);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (callNow) {
|
|
33
|
+
result = func.apply(context, args);
|
|
34
|
+
context = args = null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const clear = () => {
|
|
41
|
+
if (timeout) {
|
|
42
|
+
clearTimeout(timeout);
|
|
43
|
+
timeout = null;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const flush = () => {
|
|
48
|
+
if (timeout) {
|
|
49
|
+
result = func.apply(context, args);
|
|
50
|
+
context = args = null;
|
|
51
|
+
|
|
52
|
+
clearTimeout(timeout);
|
|
53
|
+
timeout = null;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const debounced: Debounce = (() => {
|
|
58
|
+
const f: any = debouncedFunc;
|
|
59
|
+
f.clear = clear;
|
|
60
|
+
f.flush = flush;
|
|
61
|
+
return f;
|
|
62
|
+
})();
|
|
63
|
+
|
|
64
|
+
return debounced;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
67
|
export default debouncer;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export default interface IValidator {
|
|
2
|
-
isSatisfiedBy(input: string, allowEmpty: boolean): boolean;
|
|
3
|
-
}
|
|
1
|
+
export default interface IValidator {
|
|
2
|
+
isSatisfiedBy(input: string, allowEmpty: boolean): boolean;
|
|
3
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import IValidation from '../IValidator.interface';
|
|
2
|
-
|
|
3
|
-
export default class BankAccountValidator implements IValidation {
|
|
4
|
-
isSatisfiedBy(input: string, allowEmpty: boolean = true): boolean {
|
|
5
|
-
return true;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
1
|
+
import IValidation from '../IValidator.interface';
|
|
2
|
+
|
|
3
|
+
export default class BankAccountValidator implements IValidation {
|
|
4
|
+
isSatisfiedBy(input: string, allowEmpty: boolean = true): boolean {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import IValidation from '../IValidator.interface';
|
|
2
|
-
|
|
3
|
-
export default class BankAccountRegistrationNumberValidator
|
|
4
|
-
implements IValidation {
|
|
5
|
-
isSatisfiedBy(input: string, allowEmpty: boolean = true): boolean {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
1
|
+
import IValidation from '../IValidator.interface';
|
|
2
|
+
|
|
3
|
+
export default class BankAccountRegistrationNumberValidator
|
|
4
|
+
implements IValidation {
|
|
5
|
+
isSatisfiedBy(input: string, allowEmpty: boolean = true): boolean {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import IValidation from '../IValidator.interface';
|
|
2
|
-
|
|
3
|
-
export default class BankIdNorwayValidator implements IValidation {
|
|
4
|
-
isSatisfiedBy(input: string, allowEmpty: boolean = true): boolean {
|
|
5
|
-
return this.checkNoPersonnummer(input, allowEmpty);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
private checkNoPersonnummer(
|
|
9
|
-
input: string,
|
|
10
|
-
allowEmpty: boolean = true,
|
|
11
|
-
): boolean {
|
|
12
|
-
if (!input) {
|
|
13
|
-
return allowEmpty;
|
|
14
|
-
}
|
|
15
|
-
const personnummer: string = input.replace(' ', '').replace('-', '');
|
|
16
|
-
const regex: RegExp = new RegExp(
|
|
17
|
-
/^(0[1-9]|1[0-9]|2[0-9]|3[0-1])(0[1-9]|1[0-2])(\d{2})(\d{5})$/,
|
|
18
|
-
);
|
|
19
|
-
return regex.test(personnummer);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
import IValidation from '../IValidator.interface';
|
|
2
|
+
|
|
3
|
+
export default class BankIdNorwayValidator implements IValidation {
|
|
4
|
+
isSatisfiedBy(input: string, allowEmpty: boolean = true): boolean {
|
|
5
|
+
return this.checkNoPersonnummer(input, allowEmpty);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
private checkNoPersonnummer(
|
|
9
|
+
input: string,
|
|
10
|
+
allowEmpty: boolean = true,
|
|
11
|
+
): boolean {
|
|
12
|
+
if (!input) {
|
|
13
|
+
return allowEmpty;
|
|
14
|
+
}
|
|
15
|
+
const personnummer: string = input.replace(' ', '').replace('-', '');
|
|
16
|
+
const regex: RegExp = new RegExp(
|
|
17
|
+
/^(0[1-9]|1[0-9]|2[0-9]|3[0-1])(0[1-9]|1[0-2])(\d{2})(\d{5})$/,
|
|
18
|
+
);
|
|
19
|
+
return regex.test(personnummer);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import IValidation from '../IValidator.interface';
|
|
2
|
-
|
|
3
|
-
export default class BankIdSwedenValidator implements IValidation {
|
|
4
|
-
isSatisfiedBy(input: string, allowEmpty: boolean = true): boolean {
|
|
5
|
-
return this.checkSePersonnummer(input, allowEmpty);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
private checkSePersonnummer(
|
|
9
|
-
input: string,
|
|
10
|
-
allowEmpty: boolean = true,
|
|
11
|
-
): boolean {
|
|
12
|
-
if (!input) {
|
|
13
|
-
return allowEmpty;
|
|
14
|
-
}
|
|
15
|
-
const personnummer: string = input.replace(' ', '').replace('-', '');
|
|
16
|
-
const regex: RegExp = new RegExp(
|
|
17
|
-
/^(19\d{2}|20\d{2})(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])(\d{4})$/,
|
|
18
|
-
);
|
|
19
|
-
return regex.test(personnummer);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
import IValidation from '../IValidator.interface';
|
|
2
|
+
|
|
3
|
+
export default class BankIdSwedenValidator implements IValidation {
|
|
4
|
+
isSatisfiedBy(input: string, allowEmpty: boolean = true): boolean {
|
|
5
|
+
return this.checkSePersonnummer(input, allowEmpty);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
private checkSePersonnummer(
|
|
9
|
+
input: string,
|
|
10
|
+
allowEmpty: boolean = true,
|
|
11
|
+
): boolean {
|
|
12
|
+
if (!input) {
|
|
13
|
+
return allowEmpty;
|
|
14
|
+
}
|
|
15
|
+
const personnummer: string = input.replace(' ', '').replace('-', '');
|
|
16
|
+
const regex: RegExp = new RegExp(
|
|
17
|
+
/^(19\d{2}|20\d{2})(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])(\d{4})$/,
|
|
18
|
+
);
|
|
19
|
+
return regex.test(personnummer);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import IValidation from '../IValidator.interface';
|
|
2
|
-
|
|
3
|
-
export default class CprValidator implements IValidation {
|
|
4
|
-
isSatisfiedBy(input: string, allowEmpty: boolean = true): boolean {
|
|
5
|
-
return this.checkCpr(input, allowEmpty);
|
|
6
|
-
}
|
|
7
|
-
private modulus11Multiply(value: number, index: number): number {
|
|
8
|
-
const control: number[] = [4, 3, 2, 7, 6, 5, 4, 3, 2, 1];
|
|
9
|
-
return control[index] * value;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
private modulus11Exceptions(input: string): boolean {
|
|
13
|
-
const exceptionDates: Date[] = [
|
|
14
|
-
1960,
|
|
15
|
-
1964,
|
|
16
|
-
1965,
|
|
17
|
-
1966,
|
|
18
|
-
1969,
|
|
19
|
-
1970,
|
|
20
|
-
1980,
|
|
21
|
-
1982,
|
|
22
|
-
1984,
|
|
23
|
-
1985,
|
|
24
|
-
1986,
|
|
25
|
-
1987,
|
|
26
|
-
1988,
|
|
27
|
-
1989,
|
|
28
|
-
1990,
|
|
29
|
-
].map(x => new Date(x, 0, 1)); // months are 0-indexed
|
|
30
|
-
|
|
31
|
-
const cprDate: Date = this.getCprDate(input);
|
|
32
|
-
|
|
33
|
-
return exceptionDates.some(x => x.getDate() === cprDate.getDate());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
private checkCprDate(input: string): boolean {
|
|
37
|
-
let year: number = +input.substr(4, 2) + 2000;
|
|
38
|
-
year -= year > new Date().getFullYear() ? 100 : 0; // is 20xx or 19xx
|
|
39
|
-
const month: number = +input.substr(2, 2) - 1;
|
|
40
|
-
const day: number = +input.substr(0, 2);
|
|
41
|
-
const date: Date = new Date(year, month, day);
|
|
42
|
-
return (
|
|
43
|
-
date.getFullYear() === year &&
|
|
44
|
-
date.getMonth() === month &&
|
|
45
|
-
date.getDate() === day
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private getCprDate(input: string): Date {
|
|
50
|
-
let year: number = +input.substr(4, 2) + 2000;
|
|
51
|
-
year -= year > new Date().getFullYear() ? 100 : 0; // is 20xx or 19xx
|
|
52
|
-
const month: number = +input.substr(2, 2) - 1;
|
|
53
|
-
const day: number = +input.substr(0, 2);
|
|
54
|
-
return new Date(year, month, day);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private checkCpr(input: string, allowEmpty: boolean = true): boolean {
|
|
58
|
-
if (!input) {
|
|
59
|
-
return allowEmpty;
|
|
60
|
-
}
|
|
61
|
-
const cprnr: string = input.replace(' ', '').replace('-', '');
|
|
62
|
-
if (!cprnr.match(/^\d{10}$/)) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
if (!this.checkCprDate(cprnr)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
if (this.modulus11Exceptions(cprnr)) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let output: number = 0;
|
|
73
|
-
for (let i: number = 0; i < 10; i++) {
|
|
74
|
-
output += this.modulus11Multiply(
|
|
75
|
-
parseInt(cprnr.substr(i, 1), 10),
|
|
76
|
-
i,
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return output % 11 === 0; // hvis output går op i 11, er det et gyldigt cpr.
|
|
81
|
-
}
|
|
82
|
-
}
|
|
1
|
+
import IValidation from '../IValidator.interface';
|
|
2
|
+
|
|
3
|
+
export default class CprValidator implements IValidation {
|
|
4
|
+
isSatisfiedBy(input: string, allowEmpty: boolean = true): boolean {
|
|
5
|
+
return this.checkCpr(input, allowEmpty);
|
|
6
|
+
}
|
|
7
|
+
private modulus11Multiply(value: number, index: number): number {
|
|
8
|
+
const control: number[] = [4, 3, 2, 7, 6, 5, 4, 3, 2, 1];
|
|
9
|
+
return control[index] * value;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
private modulus11Exceptions(input: string): boolean {
|
|
13
|
+
const exceptionDates: Date[] = [
|
|
14
|
+
1960,
|
|
15
|
+
1964,
|
|
16
|
+
1965,
|
|
17
|
+
1966,
|
|
18
|
+
1969,
|
|
19
|
+
1970,
|
|
20
|
+
1980,
|
|
21
|
+
1982,
|
|
22
|
+
1984,
|
|
23
|
+
1985,
|
|
24
|
+
1986,
|
|
25
|
+
1987,
|
|
26
|
+
1988,
|
|
27
|
+
1989,
|
|
28
|
+
1990,
|
|
29
|
+
].map(x => new Date(x, 0, 1)); // months are 0-indexed
|
|
30
|
+
|
|
31
|
+
const cprDate: Date = this.getCprDate(input);
|
|
32
|
+
|
|
33
|
+
return exceptionDates.some(x => x.getDate() === cprDate.getDate());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private checkCprDate(input: string): boolean {
|
|
37
|
+
let year: number = +input.substr(4, 2) + 2000;
|
|
38
|
+
year -= year > new Date().getFullYear() ? 100 : 0; // is 20xx or 19xx
|
|
39
|
+
const month: number = +input.substr(2, 2) - 1;
|
|
40
|
+
const day: number = +input.substr(0, 2);
|
|
41
|
+
const date: Date = new Date(year, month, day);
|
|
42
|
+
return (
|
|
43
|
+
date.getFullYear() === year &&
|
|
44
|
+
date.getMonth() === month &&
|
|
45
|
+
date.getDate() === day
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private getCprDate(input: string): Date {
|
|
50
|
+
let year: number = +input.substr(4, 2) + 2000;
|
|
51
|
+
year -= year > new Date().getFullYear() ? 100 : 0; // is 20xx or 19xx
|
|
52
|
+
const month: number = +input.substr(2, 2) - 1;
|
|
53
|
+
const day: number = +input.substr(0, 2);
|
|
54
|
+
return new Date(year, month, day);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private checkCpr(input: string, allowEmpty: boolean = true): boolean {
|
|
58
|
+
if (!input) {
|
|
59
|
+
return allowEmpty;
|
|
60
|
+
}
|
|
61
|
+
const cprnr: string = input.replace(' ', '').replace('-', '');
|
|
62
|
+
if (!cprnr.match(/^\d{10}$/)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
if (!this.checkCprDate(cprnr)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (this.modulus11Exceptions(cprnr)) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let output: number = 0;
|
|
73
|
+
for (let i: number = 0; i < 10; i++) {
|
|
74
|
+
output += this.modulus11Multiply(
|
|
75
|
+
parseInt(cprnr.substr(i, 1), 10),
|
|
76
|
+
i,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return output % 11 === 0; // hvis output går op i 11, er det et gyldigt cpr.
|
|
81
|
+
}
|
|
82
|
+
}
|