@luftborn/custom-elements 1.4.0 → 2.0.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/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 -147
- 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/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/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 -15
- package/dist/elements/FileField/FileFieldElement.js +103 -103
- 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 -114
- 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/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 -258
- 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 -4
- package/dist/framework/Language/Languages/CzechDictionary.js +39 -39
- 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 -4
- package/dist/framework/Language/Languages/DutchDictionary.js +39 -39
- 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 -4
- package/dist/framework/Language/Languages/EstonianDictionary.js +39 -39
- package/dist/framework/Language/Languages/FinnishDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/FinnishDictionary.js +39 -39
- package/dist/framework/Language/Languages/FrenchDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/FrenchDictionary.js +39 -39
- package/dist/framework/Language/Languages/GermanDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/GermanDictionary.js +39 -39
- package/dist/framework/Language/Languages/GreekDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/GreekDictionary.js +39 -39
- package/dist/framework/Language/Languages/HungarianDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/HungarianDictionary.js +39 -39
- package/dist/framework/Language/Languages/IcelandicDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/IcelandicDictionary.js +39 -39
- package/dist/framework/Language/Languages/ItalianDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/ItalianDictionary.js +39 -39
- package/dist/framework/Language/Languages/LatvianDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/LatvianDictionary.js +39 -39
- package/dist/framework/Language/Languages/LituanianDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/LituanianDictionary.js +39 -39
- package/dist/framework/Language/Languages/NorwegianDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/NorwegianDictionary.js +39 -39
- package/dist/framework/Language/Languages/PolishDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/PolishDictionary.js +39 -39
- package/dist/framework/Language/Languages/PortugueseDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/PortugueseDictionary.js +39 -39
- package/dist/framework/Language/Languages/SpanishDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/SpanishDictionary.js +39 -39
- package/dist/framework/Language/Languages/SwedishDictionary.d.ts +4 -4
- package/dist/framework/Language/Languages/SwedishDictionary.js +39 -39
- package/dist/framework/Language/Translator.d.ts +23 -23
- package/dist/framework/Language/Translator.js +115 -115
- 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 -6
- package/dist/framework/Utilities/ArrayUtil.js +36 -36
- package/dist/framework/Utilities/DomUtil.d.ts +21 -21
- package/dist/framework/Utilities/DomUtil.js +101 -101
- 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 -8
- package/dist/framework/Utilities/MakeRequest.js +48 -48
- package/dist/framework/Utilities/StringUtil.d.ts +4 -4
- package/dist/framework/Utilities/StringUtil.js +16 -16
- package/dist/framework/Utilities/ViewportUtil.d.ts +8 -8
- package/dist/framework/Utilities/ViewportUtil.js +42 -42
- 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/package.json +38 -38
- package/src/custom-form.ts +140 -140
- 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 -96
- package/src/elements/IdentificationElement/IdentificationElement.ts +104 -104
- package/src/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.ts +116 -116
- 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 -277
- package/src/framework/Language/Languages/Base/BaseDictionary.ts +15 -15
- package/src/framework/Language/Languages/CzechDictionary.ts +18 -18
- package/src/framework/Language/Languages/DanishDictionary.ts +17 -17
- package/src/framework/Language/Languages/DutchDictionary.ts +17 -17
- package/src/framework/Language/Languages/EnglishDictionary.ts +18 -18
- package/src/framework/Language/Languages/EstonianDictionary.ts +17 -17
- package/src/framework/Language/Languages/FinnishDictionary.ts +17 -17
- package/src/framework/Language/Languages/FrenchDictionary.ts +17 -17
- package/src/framework/Language/Languages/GermanDictionary.ts +17 -17
- package/src/framework/Language/Languages/GreekDictionary.ts +17 -17
- package/src/framework/Language/Languages/HungarianDictionary.ts +17 -17
- package/src/framework/Language/Languages/IcelandicDictionary.ts +17 -17
- package/src/framework/Language/Languages/ItalianDictionary.ts +17 -17
- package/src/framework/Language/Languages/LatvianDictionary.ts +17 -17
- package/src/framework/Language/Languages/LituanianDictionary.ts +17 -17
- package/src/framework/Language/Languages/NorwegianDictionary.ts +17 -17
- package/src/framework/Language/Languages/PolishDictionary.ts +17 -17
- package/src/framework/Language/Languages/PortugueseDictionary.ts +17 -17
- package/src/framework/Language/Languages/SpanishDictionary.ts +17 -17
- package/src/framework/Language/Languages/SwedishDictionary.ts +17 -17
- package/src/framework/Language/Translator.ts +110 -110
- 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 -31
- package/src/framework/Utilities/DomUtil.ts +117 -117
- package/src/framework/Utilities/DomUtility.ts +6 -6
- package/src/framework/Utilities/MakeRequest.ts +47 -47
- package/src/framework/Utilities/StringUtil.ts +8 -8
- package/src/framework/Utilities/ViewportUtil.ts +46 -46
- 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
|
@@ -1,207 +1,207 @@
|
|
|
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.AddressElement = 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 Translator_1 = require("../../framework/Language/Translator");
|
|
29
|
-
var getAttributeNamesPolyfill_1 = require("../../framework/Polyfills/getAttributeNamesPolyfill");
|
|
30
|
-
var debouncer_1 = require("../../framework/Utilities/debouncer");
|
|
31
|
-
var AddressElement = /** @class */ (function (_super) {
|
|
32
|
-
__extends(AddressElement, _super);
|
|
33
|
-
function AddressElement() {
|
|
34
|
-
var _this = _super.call(this) || this;
|
|
35
|
-
_this.autoCompleteEnabled = false;
|
|
36
|
-
(0, getAttributeNamesPolyfill_1.default)();
|
|
37
|
-
return _this;
|
|
38
|
-
}
|
|
39
|
-
Object.defineProperty(AddressElement.prototype, "value", {
|
|
40
|
-
get: function () {
|
|
41
|
-
var address = this.address.value || '';
|
|
42
|
-
var city = this.city.value ? "," + this.city.value : '';
|
|
43
|
-
var zip = this.zip.value ? "," + this.zip.value : '';
|
|
44
|
-
var country = this.country.value ? "," + this.country.value : '';
|
|
45
|
-
return "" + address + city + zip + country;
|
|
46
|
-
},
|
|
47
|
-
set: function (value) {
|
|
48
|
-
var values = value.split(',');
|
|
49
|
-
this.address.value = values[0];
|
|
50
|
-
this.city.value = values[1];
|
|
51
|
-
this.country.value = values[2];
|
|
52
|
-
this.zip.value = values[3];
|
|
53
|
-
},
|
|
54
|
-
enumerable: false,
|
|
55
|
-
configurable: true
|
|
56
|
-
});
|
|
57
|
-
Object.defineProperty(AddressElement.prototype, "valid", {
|
|
58
|
-
get: function () {
|
|
59
|
-
return (this.address.validity.valid &&
|
|
60
|
-
this.city.validity.valid &&
|
|
61
|
-
this.country.validity.valid &&
|
|
62
|
-
this.zip.validity.valid);
|
|
63
|
-
},
|
|
64
|
-
enumerable: false,
|
|
65
|
-
configurable: true
|
|
66
|
-
});
|
|
67
|
-
AddressElement.prototype.connectedCallback = function () {
|
|
68
|
-
_super.prototype.connectedCallback.call(this);
|
|
69
|
-
};
|
|
70
|
-
AddressElement.prototype.componentDidMount = function () {
|
|
71
|
-
var _this = this;
|
|
72
|
-
this.initChildInputs();
|
|
73
|
-
this.getAttributeNames().forEach(function (attributeName) {
|
|
74
|
-
var attributeValue = _this.getAttribute(attributeName);
|
|
75
|
-
_this.attributeChanged(attributeName, null, attributeValue);
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
AddressElement.prototype.initChildInputs = function () {
|
|
79
|
-
this.address = _super.prototype.getChildInput.call(this, '#address');
|
|
80
|
-
this.city = _super.prototype.getChildInput.call(this, '#city');
|
|
81
|
-
this.country = _super.prototype.getChildInput.call(this, '#country');
|
|
82
|
-
this.zip = _super.prototype.getChildInput.call(this, '#zip');
|
|
83
|
-
var addressChaneDebounce = (0, debouncer_1.default)(this.change.bind(this), 400, false);
|
|
84
|
-
this.address.addEventListener('change', function () {
|
|
85
|
-
addressChaneDebounce();
|
|
86
|
-
});
|
|
87
|
-
this.city.addEventListener('change', this.change.bind(this));
|
|
88
|
-
this.country.addEventListener('change', this.change.bind(this));
|
|
89
|
-
this.zip.addEventListener('change', this.change.bind(this));
|
|
90
|
-
if (this.required) {
|
|
91
|
-
this.address.setAttribute('required', '');
|
|
92
|
-
this.city.setAttribute('required', '');
|
|
93
|
-
this.country.setAttribute('required', '');
|
|
94
|
-
this.zip.setAttribute('required', '');
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
// events
|
|
98
|
-
AddressElement.prototype.change = function ($event) {
|
|
99
|
-
this.touched = true;
|
|
100
|
-
this.onChange.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'change'));
|
|
101
|
-
};
|
|
102
|
-
AddressElement.prototype.validate = function () {
|
|
103
|
-
this.valid;
|
|
104
|
-
this.onValidate.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'validate'));
|
|
105
|
-
};
|
|
106
|
-
AddressElement.prototype.changeLanguage = function (language) {
|
|
107
|
-
if (!this.address || !this.city || !this.country || !this.zip) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
this.address.placeholder = Translator_1.default.Translate('AddressElement.Address', language);
|
|
111
|
-
this.city.placeholder = Translator_1.default.Translate('AddressElement.City', language);
|
|
112
|
-
this.country.placeholder = Translator_1.default.Translate('AddressElement.Country', language);
|
|
113
|
-
this.zip.placeholder = Translator_1.default.Translate('AddressElement.Zip', language);
|
|
114
|
-
};
|
|
115
|
-
AddressElement.prototype.enableAutoComplete = function () {
|
|
116
|
-
if (!this.googlePlacesApiKey || this.googlePlacesApiKey.trim() === '' || !this.autoCompleteEnabled) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
this.googlePlacesLibraryElement = document.querySelector("[src=\"https://maps.googleapis.com/maps/api/js?key=" + this.googlePlacesApiKey + "&libraries=places\"]");
|
|
120
|
-
if (this.googlePlacesLibraryElement) {
|
|
121
|
-
this.googlePlacesLibraryElementBindLoad();
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
this.googlePlacesLibraryElement = document.createElement('script');
|
|
125
|
-
this.googlePlacesLibraryElement.type = 'text/javascript';
|
|
126
|
-
this.googlePlacesLibraryElement.src = "https://maps.googleapis.com/maps/api/js?key=" + this.googlePlacesApiKey + "&libraries=places";
|
|
127
|
-
window.document.head.appendChild(this.googlePlacesLibraryElement);
|
|
128
|
-
this.googlePlacesLibraryElementBindLoad();
|
|
129
|
-
};
|
|
130
|
-
AddressElement.prototype.googlePlacesLibraryElementBindLoad = function () {
|
|
131
|
-
var _this = this;
|
|
132
|
-
this.googlePlacesLibraryElement.addEventListener('load', function () {
|
|
133
|
-
_this.bindAutoComplete();
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
AddressElement.prototype.bindAutoComplete = function () {
|
|
137
|
-
this.addressAutoComplete = new google.maps.places.Autocomplete(this.address);
|
|
138
|
-
this.addressAutoComplete.addListener("place_changed", this.onAddressChangedHandler.bind(this));
|
|
139
|
-
};
|
|
140
|
-
AddressElement.prototype.onAddressChangedHandler = function () {
|
|
141
|
-
this.city.value = '';
|
|
142
|
-
this.country.value = '';
|
|
143
|
-
this.zip.value = '';
|
|
144
|
-
var place = this.addressAutoComplete.getPlace();
|
|
145
|
-
console.log(place);
|
|
146
|
-
if (!place.address_components) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
this.address.value = place.name;
|
|
150
|
-
var cityComponents = place.address_components.filter(function (component) {
|
|
151
|
-
var citySynonyms = ['administrative_area_level_1', 'locality'];
|
|
152
|
-
var isCityComponent = citySynonyms.some(function (citySynonym) { return component.types.indexOf(citySynonym) != -1; });
|
|
153
|
-
return isCityComponent;
|
|
154
|
-
});
|
|
155
|
-
if (cityComponents && cityComponents[0]) {
|
|
156
|
-
this.city.value = cityComponents[cityComponents.length - 1].long_name;
|
|
157
|
-
}
|
|
158
|
-
var countryComponents = place.address_components.filter(function (component) { return component.types.indexOf('country') != -1; });
|
|
159
|
-
if (countryComponents && countryComponents[0]) {
|
|
160
|
-
this.country.value = countryComponents[countryComponents.length - 1].long_name;
|
|
161
|
-
}
|
|
162
|
-
var zipComponents = place.address_components.filter(function (component) { return component.types.indexOf('postal_code') != -1; });
|
|
163
|
-
if (zipComponents && zipComponents[0]) {
|
|
164
|
-
this.zip.value = zipComponents[0].long_name;
|
|
165
|
-
}
|
|
166
|
-
this.change(null);
|
|
167
|
-
};
|
|
168
|
-
Object.defineProperty(AddressElement, "observedAttributes", {
|
|
169
|
-
get: function () {
|
|
170
|
-
return ['language', 'google-places-key', 'enable-auto-complete'];
|
|
171
|
-
},
|
|
172
|
-
enumerable: false,
|
|
173
|
-
configurable: true
|
|
174
|
-
});
|
|
175
|
-
AddressElement.prototype.attributeChangedCallback = function (name, oldVal, newVal) {
|
|
176
|
-
this.attributeChanged(name, oldVal, newVal);
|
|
177
|
-
};
|
|
178
|
-
AddressElement.prototype.attributeChanged = function (name, oldVal, newVal) {
|
|
179
|
-
switch (name) {
|
|
180
|
-
case 'language':
|
|
181
|
-
this.changeLanguage(newVal);
|
|
182
|
-
break;
|
|
183
|
-
case 'google-places-key':
|
|
184
|
-
this.googlePlacesApiKey = newVal;
|
|
185
|
-
this.enableAutoComplete();
|
|
186
|
-
break;
|
|
187
|
-
case 'enable-auto-complete':
|
|
188
|
-
if (newVal && newVal != 'false') {
|
|
189
|
-
this.autoCompleteEnabled = true;
|
|
190
|
-
this.enableAutoComplete();
|
|
191
|
-
}
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
AddressElement = __decorate([
|
|
196
|
-
(0, custom_element_decorator_1.default)({
|
|
197
|
-
selector: 'address-element',
|
|
198
|
-
template: "\n\t\t\t<div class=\"address-wrapper\">\n\t\t\t\t<input class='address-part' id='address' type=\"text\" placeholder='Address'/>\n\t\t\t\t<input class='address-part' id='zip' type=\"text\" placeholder='Zip'/>\n\t\t\t\t<input class='address-part' id='city' type=\"text\" placeholder='City'/>\n\t\t\t\t<input class='address-part' id='country' type=\"text\" placeholder='Country'/>\n\t\t\t</div>",
|
|
199
|
-
style: ".address-wrapper{\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-wrap: nowrap;\n\t\t\t}\n\t\t\tinput.address-part{\n\t\t\t\tbox-sizing: border-box;\n\t\t\t\tborder: none;\n\t\t\t\tbackground-color: #f1f4ff;\n\t\t\t\tmargin: 2px;\n\t\t\t\tresize: none;\n\t\t\t\twidth:33% !important;\n\t\t\t}\n\t\t",
|
|
200
|
-
templatePath: './html.html',
|
|
201
|
-
useShadow: true,
|
|
202
|
-
})
|
|
203
|
-
], AddressElement);
|
|
204
|
-
return AddressElement;
|
|
205
|
-
}(CustomInputElement_1.CustomInputElement));
|
|
206
|
-
exports.AddressElement = AddressElement;
|
|
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.AddressElement = 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 Translator_1 = require("../../framework/Language/Translator");
|
|
29
|
+
var getAttributeNamesPolyfill_1 = require("../../framework/Polyfills/getAttributeNamesPolyfill");
|
|
30
|
+
var debouncer_1 = require("../../framework/Utilities/debouncer");
|
|
31
|
+
var AddressElement = /** @class */ (function (_super) {
|
|
32
|
+
__extends(AddressElement, _super);
|
|
33
|
+
function AddressElement() {
|
|
34
|
+
var _this = _super.call(this) || this;
|
|
35
|
+
_this.autoCompleteEnabled = false;
|
|
36
|
+
(0, getAttributeNamesPolyfill_1.default)();
|
|
37
|
+
return _this;
|
|
38
|
+
}
|
|
39
|
+
Object.defineProperty(AddressElement.prototype, "value", {
|
|
40
|
+
get: function () {
|
|
41
|
+
var address = this.address.value || '';
|
|
42
|
+
var city = this.city.value ? "," + this.city.value : '';
|
|
43
|
+
var zip = this.zip.value ? "," + this.zip.value : '';
|
|
44
|
+
var country = this.country.value ? "," + this.country.value : '';
|
|
45
|
+
return "" + address + city + zip + country;
|
|
46
|
+
},
|
|
47
|
+
set: function (value) {
|
|
48
|
+
var values = value.split(',');
|
|
49
|
+
this.address.value = values[0];
|
|
50
|
+
this.city.value = values[1];
|
|
51
|
+
this.country.value = values[2];
|
|
52
|
+
this.zip.value = values[3];
|
|
53
|
+
},
|
|
54
|
+
enumerable: false,
|
|
55
|
+
configurable: true
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(AddressElement.prototype, "valid", {
|
|
58
|
+
get: function () {
|
|
59
|
+
return (this.address.validity.valid &&
|
|
60
|
+
this.city.validity.valid &&
|
|
61
|
+
this.country.validity.valid &&
|
|
62
|
+
this.zip.validity.valid);
|
|
63
|
+
},
|
|
64
|
+
enumerable: false,
|
|
65
|
+
configurable: true
|
|
66
|
+
});
|
|
67
|
+
AddressElement.prototype.connectedCallback = function () {
|
|
68
|
+
_super.prototype.connectedCallback.call(this);
|
|
69
|
+
};
|
|
70
|
+
AddressElement.prototype.componentDidMount = function () {
|
|
71
|
+
var _this = this;
|
|
72
|
+
this.initChildInputs();
|
|
73
|
+
this.getAttributeNames().forEach(function (attributeName) {
|
|
74
|
+
var attributeValue = _this.getAttribute(attributeName);
|
|
75
|
+
_this.attributeChanged(attributeName, null, attributeValue);
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
AddressElement.prototype.initChildInputs = function () {
|
|
79
|
+
this.address = _super.prototype.getChildInput.call(this, '#address');
|
|
80
|
+
this.city = _super.prototype.getChildInput.call(this, '#city');
|
|
81
|
+
this.country = _super.prototype.getChildInput.call(this, '#country');
|
|
82
|
+
this.zip = _super.prototype.getChildInput.call(this, '#zip');
|
|
83
|
+
var addressChaneDebounce = (0, debouncer_1.default)(this.change.bind(this), 400, false);
|
|
84
|
+
this.address.addEventListener('change', function () {
|
|
85
|
+
addressChaneDebounce();
|
|
86
|
+
});
|
|
87
|
+
this.city.addEventListener('change', this.change.bind(this));
|
|
88
|
+
this.country.addEventListener('change', this.change.bind(this));
|
|
89
|
+
this.zip.addEventListener('change', this.change.bind(this));
|
|
90
|
+
if (this.required) {
|
|
91
|
+
this.address.setAttribute('required', '');
|
|
92
|
+
this.city.setAttribute('required', '');
|
|
93
|
+
this.country.setAttribute('required', '');
|
|
94
|
+
this.zip.setAttribute('required', '');
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
// events
|
|
98
|
+
AddressElement.prototype.change = function ($event) {
|
|
99
|
+
this.touched = true;
|
|
100
|
+
this.onChange.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'change'));
|
|
101
|
+
};
|
|
102
|
+
AddressElement.prototype.validate = function () {
|
|
103
|
+
this.valid;
|
|
104
|
+
this.onValidate.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'validate'));
|
|
105
|
+
};
|
|
106
|
+
AddressElement.prototype.changeLanguage = function (language) {
|
|
107
|
+
if (!this.address || !this.city || !this.country || !this.zip) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.address.placeholder = Translator_1.default.Translate('AddressElement.Address', language);
|
|
111
|
+
this.city.placeholder = Translator_1.default.Translate('AddressElement.City', language);
|
|
112
|
+
this.country.placeholder = Translator_1.default.Translate('AddressElement.Country', language);
|
|
113
|
+
this.zip.placeholder = Translator_1.default.Translate('AddressElement.Zip', language);
|
|
114
|
+
};
|
|
115
|
+
AddressElement.prototype.enableAutoComplete = function () {
|
|
116
|
+
if (!this.googlePlacesApiKey || this.googlePlacesApiKey.trim() === '' || !this.autoCompleteEnabled) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.googlePlacesLibraryElement = document.querySelector("[src=\"https://maps.googleapis.com/maps/api/js?key=" + this.googlePlacesApiKey + "&libraries=places\"]");
|
|
120
|
+
if (this.googlePlacesLibraryElement) {
|
|
121
|
+
this.googlePlacesLibraryElementBindLoad();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.googlePlacesLibraryElement = document.createElement('script');
|
|
125
|
+
this.googlePlacesLibraryElement.type = 'text/javascript';
|
|
126
|
+
this.googlePlacesLibraryElement.src = "https://maps.googleapis.com/maps/api/js?key=" + this.googlePlacesApiKey + "&libraries=places";
|
|
127
|
+
window.document.head.appendChild(this.googlePlacesLibraryElement);
|
|
128
|
+
this.googlePlacesLibraryElementBindLoad();
|
|
129
|
+
};
|
|
130
|
+
AddressElement.prototype.googlePlacesLibraryElementBindLoad = function () {
|
|
131
|
+
var _this = this;
|
|
132
|
+
this.googlePlacesLibraryElement.addEventListener('load', function () {
|
|
133
|
+
_this.bindAutoComplete();
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
AddressElement.prototype.bindAutoComplete = function () {
|
|
137
|
+
this.addressAutoComplete = new google.maps.places.Autocomplete(this.address);
|
|
138
|
+
this.addressAutoComplete.addListener("place_changed", this.onAddressChangedHandler.bind(this));
|
|
139
|
+
};
|
|
140
|
+
AddressElement.prototype.onAddressChangedHandler = function () {
|
|
141
|
+
this.city.value = '';
|
|
142
|
+
this.country.value = '';
|
|
143
|
+
this.zip.value = '';
|
|
144
|
+
var place = this.addressAutoComplete.getPlace();
|
|
145
|
+
console.log(place);
|
|
146
|
+
if (!place.address_components) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
this.address.value = place.name;
|
|
150
|
+
var cityComponents = place.address_components.filter(function (component) {
|
|
151
|
+
var citySynonyms = ['administrative_area_level_1', 'locality'];
|
|
152
|
+
var isCityComponent = citySynonyms.some(function (citySynonym) { return component.types.indexOf(citySynonym) != -1; });
|
|
153
|
+
return isCityComponent;
|
|
154
|
+
});
|
|
155
|
+
if (cityComponents && cityComponents[0]) {
|
|
156
|
+
this.city.value = cityComponents[cityComponents.length - 1].long_name;
|
|
157
|
+
}
|
|
158
|
+
var countryComponents = place.address_components.filter(function (component) { return component.types.indexOf('country') != -1; });
|
|
159
|
+
if (countryComponents && countryComponents[0]) {
|
|
160
|
+
this.country.value = countryComponents[countryComponents.length - 1].long_name;
|
|
161
|
+
}
|
|
162
|
+
var zipComponents = place.address_components.filter(function (component) { return component.types.indexOf('postal_code') != -1; });
|
|
163
|
+
if (zipComponents && zipComponents[0]) {
|
|
164
|
+
this.zip.value = zipComponents[0].long_name;
|
|
165
|
+
}
|
|
166
|
+
this.change(null);
|
|
167
|
+
};
|
|
168
|
+
Object.defineProperty(AddressElement, "observedAttributes", {
|
|
169
|
+
get: function () {
|
|
170
|
+
return ['language', 'google-places-key', 'enable-auto-complete'];
|
|
171
|
+
},
|
|
172
|
+
enumerable: false,
|
|
173
|
+
configurable: true
|
|
174
|
+
});
|
|
175
|
+
AddressElement.prototype.attributeChangedCallback = function (name, oldVal, newVal) {
|
|
176
|
+
this.attributeChanged(name, oldVal, newVal);
|
|
177
|
+
};
|
|
178
|
+
AddressElement.prototype.attributeChanged = function (name, oldVal, newVal) {
|
|
179
|
+
switch (name) {
|
|
180
|
+
case 'language':
|
|
181
|
+
this.changeLanguage(newVal);
|
|
182
|
+
break;
|
|
183
|
+
case 'google-places-key':
|
|
184
|
+
this.googlePlacesApiKey = newVal;
|
|
185
|
+
this.enableAutoComplete();
|
|
186
|
+
break;
|
|
187
|
+
case 'enable-auto-complete':
|
|
188
|
+
if (newVal && newVal != 'false') {
|
|
189
|
+
this.autoCompleteEnabled = true;
|
|
190
|
+
this.enableAutoComplete();
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
AddressElement = __decorate([
|
|
196
|
+
(0, custom_element_decorator_1.default)({
|
|
197
|
+
selector: 'address-element',
|
|
198
|
+
template: "\n\t\t\t<div class=\"address-wrapper\">\n\t\t\t\t<input class='address-part' id='address' type=\"text\" placeholder='Address'/>\n\t\t\t\t<input class='address-part' id='zip' type=\"text\" placeholder='Zip'/>\n\t\t\t\t<input class='address-part' id='city' type=\"text\" placeholder='City'/>\n\t\t\t\t<input class='address-part' id='country' type=\"text\" placeholder='Country'/>\n\t\t\t</div>",
|
|
199
|
+
style: ".address-wrapper{\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-wrap: nowrap;\n\t\t\t}\n\t\t\tinput.address-part{\n\t\t\t\tbox-sizing: border-box;\n\t\t\t\tborder: none;\n\t\t\t\tbackground-color: #f1f4ff;\n\t\t\t\tmargin: 2px;\n\t\t\t\tresize: none;\n\t\t\t\twidth:33% !important;\n\t\t\t}\n\t\t",
|
|
200
|
+
templatePath: './html.html',
|
|
201
|
+
useShadow: true,
|
|
202
|
+
})
|
|
203
|
+
], AddressElement);
|
|
204
|
+
return AddressElement;
|
|
205
|
+
}(CustomInputElement_1.CustomInputElement));
|
|
206
|
+
exports.AddressElement = AddressElement;
|
|
207
207
|
//# sourceMappingURL=AddressElement.js.map
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { CustomInputElement } from '../../framework/CustomInputElement';
|
|
2
|
-
import BankAccountValidator from '../../framework/Validation/Validators/BankAccount';
|
|
3
|
-
import BankAccountRegistrationNumberValidator from '../../framework/Validation/Validators/BankAccountRegistrationNumber';
|
|
4
|
-
export declare class BankFieldElement extends CustomInputElement {
|
|
5
|
-
account: HTMLInputElement;
|
|
6
|
-
regNumber: HTMLInputElement;
|
|
7
|
-
bankAccountValidator: BankAccountValidator;
|
|
8
|
-
regNumberValidator: BankAccountRegistrationNumberValidator;
|
|
9
|
-
constructor();
|
|
10
|
-
get value(): string;
|
|
11
|
-
set value(value: string);
|
|
12
|
-
get valid(): boolean;
|
|
13
|
-
connectedCallback(): void;
|
|
14
|
-
componentDidMount(): void;
|
|
15
|
-
changeLanguage(language: string): void;
|
|
16
|
-
initChildInputs(): void;
|
|
17
|
-
change($event: any): void;
|
|
18
|
-
validate(): void;
|
|
19
|
-
static get observedAttributes(): string[];
|
|
20
|
-
attributeChangedCallback(name: string, oldVal: string, newVal: string): void;
|
|
21
|
-
private attributeChanged;
|
|
22
|
-
}
|
|
1
|
+
import { CustomInputElement } from '../../framework/CustomInputElement';
|
|
2
|
+
import BankAccountValidator from '../../framework/Validation/Validators/BankAccount';
|
|
3
|
+
import BankAccountRegistrationNumberValidator from '../../framework/Validation/Validators/BankAccountRegistrationNumber';
|
|
4
|
+
export declare class BankFieldElement extends CustomInputElement {
|
|
5
|
+
account: HTMLInputElement;
|
|
6
|
+
regNumber: HTMLInputElement;
|
|
7
|
+
bankAccountValidator: BankAccountValidator;
|
|
8
|
+
regNumberValidator: BankAccountRegistrationNumberValidator;
|
|
9
|
+
constructor();
|
|
10
|
+
get value(): string;
|
|
11
|
+
set value(value: string);
|
|
12
|
+
get valid(): boolean;
|
|
13
|
+
connectedCallback(): void;
|
|
14
|
+
componentDidMount(): void;
|
|
15
|
+
changeLanguage(language: string): void;
|
|
16
|
+
initChildInputs(): void;
|
|
17
|
+
change($event: any): void;
|
|
18
|
+
validate(): void;
|
|
19
|
+
static get observedAttributes(): string[];
|
|
20
|
+
attributeChangedCallback(name: string, oldVal: string, newVal: string): void;
|
|
21
|
+
private attributeChanged;
|
|
22
|
+
}
|