@luftborn/custom-elements 2.1.2 → 2.2.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.
Files changed (25) hide show
  1. package/demo/index.html +22 -0
  2. package/demo/index.js +344 -61
  3. package/demo/index.min.js +343 -60
  4. package/demo/index.min.js.map +1 -1
  5. package/dist/elements/Elements.d.ts +3 -1
  6. package/dist/elements/Elements.js +5 -1
  7. package/dist/elements/Elements.js.map +1 -1
  8. package/dist/elements/SECompanyRegistrationElement/SECompanyRegistrationElement.d.ts +14 -0
  9. package/dist/elements/SECompanyRegistrationElement/SECompanyRegistrationElement.js +83 -0
  10. package/dist/elements/SECompanyRegistrationElement/SECompanyRegistrationElement.js.map +1 -0
  11. package/dist/elements/SEPersonalNumberElement/SEPersonalNumberElement.d.ts +14 -0
  12. package/dist/elements/SEPersonalNumberElement/SEPersonalNumberElement.js +83 -0
  13. package/dist/elements/SEPersonalNumberElement/SEPersonalNumberElement.js.map +1 -0
  14. package/dist/framework/Validation/Validators/SECompanyRegistration.d.ts +9 -0
  15. package/dist/framework/Validation/Validators/SECompanyRegistration.js +38 -0
  16. package/dist/framework/Validation/Validators/SECompanyRegistration.js.map +1 -0
  17. package/dist/framework/Validation/Validators/SEPersonalNumber.d.ts +6 -0
  18. package/dist/framework/Validation/Validators/SEPersonalNumber.js +71 -0
  19. package/dist/framework/Validation/Validators/SEPersonalNumber.js.map +1 -0
  20. package/package.json +1 -1
  21. package/src/elements/Elements.ts +5 -1
  22. package/src/elements/SECompanyRegistrationElement/SECompanyRegistrationElement.ts +73 -0
  23. package/src/elements/SEPersonalNumberElement/SEPersonalNumberElement.ts +73 -0
  24. package/src/framework/Validation/Validators/SECompanyRegistration.ts +40 -0
  25. 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
- export { AddressElement, TextFieldElement, EmailFieldElement, CheckBoxElement, RadioButtonGroupElement, TextAreaElement, DropDownListElement, FileFieldElement, NumericFieldElement, CustomRegularExpressionElement, DateFieldElement, IntPhoneFieldElement, CPRElement, CVRElement, IdentificationElement, BankFieldElement, TypeAheadElement };
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;AAmBzD,+FAnBQ,+BAAc,OAmBR;AAlBf,iEAAgE;AAmB/D,iGAnBQ,mCAAgB,OAmBR;AAlBjB,oEAAmE;AAmBlE,kGAnBQ,qCAAiB,OAmBR;AAlBlB,qEAAoE;AAmBnE,gGAnBQ,iCAAe,OAmBR;AAlBhB,sFAAqF;AAmBpF,wGAnBQ,iDAAuB,OAmBR;AAlBxB,qEAAoE;AAmBnE,gGAnBQ,iCAAe,OAmBR;AAlBhB,0EAAyE;AAmBxE,oGAnBQ,yCAAmB,OAmBR;AAlBpB,iEAAgE;AAmB/D,iGAnBQ,mCAAgB,OAmBR;AAlBjB,0EAAyE;AAmBxE,oGAnBQ,yCAAmB,OAmBR;AAlBpB,2GAA0G;AAmBzG,+GAnBQ,+DA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AgB,OAqBR;AApBjB,6FAA4F;AAqBxF,wGArBK,iDAAuB,OAqBL;AApB3B,4GAA2G;AAqBvG,6GArBK,2DAA4B,OAqBL"}
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,qFAAqE;AACrE,yEAAwE;AACxE,6DAAsE;AACtE,qGAAyG;AAyBzG;IAAkD,gDAAkB;IAInE;QAAA,YACC,iBAAO,SACP;QAJD,eAAS,GAAmC,IAAI,+BAA8B,EAAE,CAAC;;IAIjF,CAAC;IAED,sBAAI,+CAAK;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,+CAAK;aAAT;YACC,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjE,CAAC;;;OAAA;IAED,wDAAiB,GAAjB;QACC,iBAAM,iBAAiB,WAAE,CAAC;IAC3B,CAAC;IAED,sDAAe,GAAf;QACC,IAAI,CAAC,IAAI,GAAG,iBAAM,aAAa,YAAC,gCAAgC,CAAC,CAAC;QAClE,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,6CAAM,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,+CAAQ,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,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;AAy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,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;IAnCW,iDAAQ,GAAhB,UAAiB,YAA2B;QACxC,OAAO,UAAC,KAAa,EAAE,KAAa,IAAK,OAAA,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,EAA3B,CAA2B,CAAC;IACzE,CAAC;IAID,sDAAa,GAAb,UAAc,KAAa,EAAE,UAAmB;QAC5C,IAAI,UAAU,IAAI,CAAC,KAAK,EAAE;YACtB,OAAO,IAAI,CAAC;SACf;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEO,gDAAO,GAAf,UAAgB,KAAa;QACzB,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACvE,CAAC;IAEO,2DAAkB,GAA1B,UAA4B,SAAiB,EAAE,WAAqB;QAChE,IAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;QAClC,IAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC9C,IAAI,UAAU,CAAC,MAAM,KAAK,MAAM,EAAE;YAC9B,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,EAAE;YACxC,OAAO,KAAK,CAAC;SAChB;QAED,IAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAChD,IAAM,KAAK,GAAG,UAAC,CAAS,IAAK,OAAA,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAnC,CAAmC,CAAC;QACjE,IAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,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,6 @@
1
+ import IValidation from '../IValidator.interface';
2
+ export default class SEPersonalNumberValidator implements IValidation {
3
+ private regex;
4
+ isSatisfiedBy(input: string, allowEmpty?: boolean): boolean;
5
+ private luhn;
6
+ }
@@ -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,UAAK,GAAW,IAAI,MAAM,CAC9B,gEAAgE,CACnE,CAAC;IA0EN,CAAC;IAvEG,iDAAa,GAAb,UAAc,KAAa,EAAE,UAA0B;QAA1B,2BAAA,EAAA,iBAA0B;QACnD,IAAI,UAAU,IAAI,CAAC,KAAK,EAAE;YACtB,OAAO,IAAI,CAAC;SACf;QAED,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YAChC,OAAO,KAAK,CAAC;SAChB;QAED,IAAM,MAAM,GAAG,OAAO,CAAC;QACvB,IAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,OAAO,CAAC;QAEZ,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YACX,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;SACvB;aAAM;YACH,IAAI,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC3D,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;gBAChC,IAAI,IAAI,GAAG,CAAC;aACf;YAED,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC7C;QAED,2BAA2B;QAC3B,IAAI,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,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AE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC/B,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACZ,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACpB,IAAI,IAAI,GAAG,CAAC,EAAE;gBACV,IAAI,IAAI,CAAC,CAAC;aACb;YACD,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luftborn/custom-elements",
3
- "version": "2.1.2",
3
+ "version": "2.2.0",
4
4
  "description": "custom HTML elements for the form builder application ",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -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
  };
@@ -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
+ }
@@ -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 SEPersonalNumberValidator from '../../framework/Validation/Validators/SEPersonalNumber';
5
+
6
+ @CustomElement({
7
+ selector: 'se-personal-number-element',
8
+ template: `
9
+ <div class="wrapper">
10
+ <input type="text" id='se-personal-number-field' placeholder='(YY)YYMMDD-SSSS'/>
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 SEPersonalNumberElement extends CustomInputElement {
30
+ text: HTMLInputElement;
31
+ validator: SEPersonalNumberValidator = new SEPersonalNumberValidator();
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-personal-number-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
+ }
@@ -0,0 +1,40 @@
1
+ import IValidation from '../IValidator.interface';
2
+
3
+ export default class SECompanyRegistrationValidator implements IValidation {
4
+ private ORG_NR_SE_LUHN_WEIGHTS = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1];
5
+ private weighted(coefficients: Array<number>) {
6
+ return (value: number, index: number) => value * coefficients[index];
7
+ }
8
+
9
+ private sum = (a: number, b: number) => a + b;
10
+
11
+ isSatisfiedBy(input: string, allowEmpty: boolean): boolean {
12
+ if (allowEmpty && !input) {
13
+ return true;
14
+ }
15
+
16
+ return this.orgNrSe(input);
17
+ }
18
+
19
+ private orgNrSe(value: string) {
20
+ return this.checkLuhnModulus10(value, this.ORG_NR_SE_LUHN_WEIGHTS);
21
+ }
22
+
23
+ private checkLuhnModulus10 (testValue: string, luhnWeights: number[]) {
24
+ const length = luhnWeights.length;
25
+ const testValue$ = testValue.replace("-", "");
26
+ if (testValue$.length !== length) {
27
+ return false;
28
+ }
29
+
30
+ if (Number.isNaN(parseInt(testValue$, 10))) {
31
+ return false;
32
+ }
33
+
34
+ const digits = testValue$.split("").map(Number);
35
+ const luhnF = (n: number) => (n < length ? n : n - (length - 1));
36
+ const luhnSum = luhnWeights.map(this.weighted(digits)).map(luhnF).reduce(this.sum);
37
+ const controlSum = length - (+luhnSum % length);
38
+ return controlSum % 10 === 0;
39
+ }
40
+ }