@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
|
@@ -1,210 +1,210 @@
|
|
|
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.TypeAheadElement = 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 DomUtility_1 = require("../../framework/Utilities/DomUtility");
|
|
29
|
-
var TypeAheadElement = /** @class */ (function (_super) {
|
|
30
|
-
__extends(TypeAheadElement, _super);
|
|
31
|
-
function TypeAheadElement() {
|
|
32
|
-
var _this = _super.call(this) || this;
|
|
33
|
-
_this.currentFoucsedIndex = -1;
|
|
34
|
-
_this.searchResultOptions = [];
|
|
35
|
-
return _this;
|
|
36
|
-
}
|
|
37
|
-
Object.defineProperty(TypeAheadElement.prototype, "searchHasResults", {
|
|
38
|
-
get: function () {
|
|
39
|
-
var autocompleteList = _super.prototype.getChildElement.call(this, '.options-list');
|
|
40
|
-
return autocompleteList && this.optionsWithDescriptions && this.optionsWithDescriptions.length > 0;
|
|
41
|
-
},
|
|
42
|
-
enumerable: false,
|
|
43
|
-
configurable: true
|
|
44
|
-
});
|
|
45
|
-
Object.defineProperty(TypeAheadElement.prototype, "value", {
|
|
46
|
-
get: function () {
|
|
47
|
-
if (!this.selectedOption) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
return this.selectedOption.value;
|
|
51
|
-
},
|
|
52
|
-
set: function (value) {
|
|
53
|
-
if (!this.optionsWithDescriptions || this.optionsWithDescriptions.length === 0) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
var option = this.optionsWithDescriptions.find(function (option) { return option.value === value; });
|
|
57
|
-
if (!option) {
|
|
58
|
-
this.descriptionElement.innerHTML = null;
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this.selectedOption = option;
|
|
62
|
-
this.textInputElement.value = option.title;
|
|
63
|
-
this.descriptionElement.innerHTML = option.description;
|
|
64
|
-
},
|
|
65
|
-
enumerable: false,
|
|
66
|
-
configurable: true
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(TypeAheadElement.prototype, "valid", {
|
|
69
|
-
get: function () {
|
|
70
|
-
if (this.required) {
|
|
71
|
-
return !!this.selectedOption;
|
|
72
|
-
}
|
|
73
|
-
return !!this.selectedOption || this.textInputElement.value === '';
|
|
74
|
-
},
|
|
75
|
-
enumerable: false,
|
|
76
|
-
configurable: true
|
|
77
|
-
});
|
|
78
|
-
TypeAheadElement.prototype.connectedCallback = function () {
|
|
79
|
-
_super.prototype.connectedCallback.call(this);
|
|
80
|
-
};
|
|
81
|
-
TypeAheadElement.prototype.initChildInputs = function () {
|
|
82
|
-
var _this = this;
|
|
83
|
-
this.textInputElement = _super.prototype.getChildInput.call(this, '#text-input');
|
|
84
|
-
this.descriptionElement = _super.prototype.getChildInput.call(this, '#description');
|
|
85
|
-
this.componentWrapper = _super.prototype.getChildElement.call(this, '.wrapper');
|
|
86
|
-
if (this.required) {
|
|
87
|
-
this.textInputElement.setAttribute('required', '');
|
|
88
|
-
}
|
|
89
|
-
this.textInputElement.addEventListener('change', this.change.bind(this));
|
|
90
|
-
this.textInputElement.addEventListener('input', function () {
|
|
91
|
-
_this.inputEventHandler();
|
|
92
|
-
});
|
|
93
|
-
this.bindNavigation();
|
|
94
|
-
};
|
|
95
|
-
TypeAheadElement.prototype.inputEventHandler = function () {
|
|
96
|
-
var _this = this;
|
|
97
|
-
this.selectedOption = null;
|
|
98
|
-
this.descriptionElement.innerHTML = null;
|
|
99
|
-
this.closeOptionsList();
|
|
100
|
-
this.searchResultOptions = [];
|
|
101
|
-
var searchValue = this.textInputElement.value;
|
|
102
|
-
if (!searchValue || searchValue.trim() === '') {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
var optionslist = document.createElement('div');
|
|
106
|
-
optionslist.classList.add('options-list');
|
|
107
|
-
if (!this.optionsWithDescriptions) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
this.optionsWithDescriptions.forEach(function (option, index) {
|
|
111
|
-
var regex = new RegExp(searchValue, 'gi');
|
|
112
|
-
var isMatchingTitle = regex.test(option.title);
|
|
113
|
-
var isMatchingValue = regex.test(option.value);
|
|
114
|
-
var isMatchingDescription = regex.test(option.description);
|
|
115
|
-
if (!isMatchingTitle && !isMatchingValue && !isMatchingDescription) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
_this.searchResultOptions.push(option);
|
|
119
|
-
var optionsListItem = document.createElement("div");
|
|
120
|
-
optionsListItem.classList.add('options-list-item');
|
|
121
|
-
optionsListItem.dataset['value'] = option.value;
|
|
122
|
-
optionslist.appendChild(optionsListItem);
|
|
123
|
-
var optionsListItemTitle = document.createElement("div");
|
|
124
|
-
optionsListItemTitle.classList.add('options-list-item-title');
|
|
125
|
-
optionsListItemTitle.innerHTML = DomUtility_1.default.boldenText(option.title, searchValue);
|
|
126
|
-
optionsListItem.appendChild(optionsListItemTitle);
|
|
127
|
-
var optionsListItemDescription = document.createElement("div");
|
|
128
|
-
optionsListItemDescription.classList.add('options-list-item-description');
|
|
129
|
-
optionsListItemDescription.innerHTML = DomUtility_1.default.boldenText(option.description, searchValue);
|
|
130
|
-
optionsListItem.appendChild(optionsListItemDescription);
|
|
131
|
-
optionsListItem.addEventListener('click', function () {
|
|
132
|
-
_this.optionSelectedHandler(option);
|
|
133
|
-
});
|
|
134
|
-
_this.componentWrapper.appendChild(optionslist);
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
TypeAheadElement.prototype.closeOptionsList = function () {
|
|
138
|
-
this.currentFoucsedIndex = -1;
|
|
139
|
-
var optionsList = _super.prototype.getChildElement.call(this, '.options-list');
|
|
140
|
-
if (!optionsList) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
optionsList.remove();
|
|
144
|
-
};
|
|
145
|
-
TypeAheadElement.prototype.optionSelectedHandler = function (option) {
|
|
146
|
-
this.value = option.value;
|
|
147
|
-
this.onChange.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'change'));
|
|
148
|
-
this.closeOptionsList();
|
|
149
|
-
};
|
|
150
|
-
TypeAheadElement.prototype.bindNavigation = function () {
|
|
151
|
-
var _this = this;
|
|
152
|
-
this.textInputElement.addEventListener('keydown', function (event) {
|
|
153
|
-
if (event.key === 'Escape') {
|
|
154
|
-
_this.closeOptionsList();
|
|
155
|
-
}
|
|
156
|
-
if (event.key === 'ArrowDown') {
|
|
157
|
-
if (!_this.searchHasResults) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
_this.currentFoucsedIndex = _this.currentFoucsedIndex === _this.searchResultOptions.length - 1 ? 0 : _this.currentFoucsedIndex + 1;
|
|
161
|
-
_this.highlightFocusedSearchResult();
|
|
162
|
-
}
|
|
163
|
-
if (event.key === 'ArrowUp') {
|
|
164
|
-
if (!_this.searchHasResults) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
_this.currentFoucsedIndex = _this.currentFoucsedIndex === 0 ? _this.searchResultOptions.length - 1 : _this.currentFoucsedIndex - 1;
|
|
168
|
-
_this.highlightFocusedSearchResult();
|
|
169
|
-
}
|
|
170
|
-
if (event.key === 'Enter') {
|
|
171
|
-
if (_this.currentFoucsedIndex !== -1 && _this.searchHasResults) {
|
|
172
|
-
_this.optionSelectedHandler(_this.searchResultOptions[_this.currentFoucsedIndex]);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
TypeAheadElement.prototype.highlightFocusedSearchResult = function () {
|
|
179
|
-
var _this = this;
|
|
180
|
-
var optionListItems = _super.prototype.getChildElements.call(this, '.options-list-item');
|
|
181
|
-
if (!optionListItems) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
optionListItems.forEach(function (listItem, index) {
|
|
185
|
-
listItem.classList.remove('active');
|
|
186
|
-
if (index === _this.currentFoucsedIndex) {
|
|
187
|
-
listItem.classList.add('active');
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
TypeAheadElement.prototype.change = function ($event) {
|
|
192
|
-
this.touched = true;
|
|
193
|
-
this.onChange.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'change'));
|
|
194
|
-
};
|
|
195
|
-
TypeAheadElement.prototype.validate = function () {
|
|
196
|
-
this.valid;
|
|
197
|
-
this.onValidate.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'validate'));
|
|
198
|
-
};
|
|
199
|
-
TypeAheadElement = __decorate([
|
|
200
|
-
(0, custom_element_decorator_1.default)({
|
|
201
|
-
selector: 'type-ahead-element',
|
|
202
|
-
template: "\n\t\t<div class=\"wrapper\">\n\t\t\t<input type=\"text\" id=\"text-input\">\n\t\t\t<div id=\"description\"></div>\n\t\t</div>",
|
|
203
|
-
style: "\n\t\t:host {\n\t\t\twidth:100%;\n\t\t}\n\t\t.wrapper {\n\t\t\tposition: relative;\n\t\t\tdisplay:flex;\n\t\t\tflex-direction: column;\n\t\t\tjustify-content: center;\n\t\t\talign-items: center;\n\t\t}\n\t\t#text-input {\n\t\t\tbox-sizing: border-box;\n\t\t\twidth: 100% !important;\n\t\t\tborder: none;\n\t\t\tbackground-color: #f1f4ff;\n\t\t\tmargin: 2px;\n\t\t\tresize: none;\n\t\t}\n\t\t.wrapper #description {\n\t\t\twidth: 100%;\n\t\t\tpadding: 0 2px;\n\t\t\tbox-sizing: border-box;\n\t\t}\n\t\t.options-list {\n\t\t\tposition: absolute;\n\t\t\tborder: 1px solid #E8E8E8;\n\t\t\tborder-bottom: none;\n\t\t\tborder-top: none;\n\t\t\tz-index: 3;\n\t\t\ttop: 100%;\n\t\t\tleft: 0;\n\t\t\tright: 0;\n\t\t\tmax-height: 200px;\n\t\t\toverflow-y: auto;\n\t\t}\n\t\t.options-list-item {\n\t\t\tpadding: 10px;\n\t\t\tcursor: pointer;\n\t\t\tbackground-color: #FFFFFF;\n\t\t\tborder-bottom: 1px solid #E8E8E8;\n\t\t}\n\t\t.options-list-item:hover {\n\t\t\tbackground-color: #E8E8E8;\n\t\t}\n\t\t.options-list-item.active {\n\t\t\t/*when navigating through the items using the arrow keys:*/\n\t\t\tbackground-color: #003E64 !important;\n\t\t\tcolor: #FFFFFF;\n\t\t}\n\t\t.options-list-item-title {\n\t\t\tfont-size: 16px;\n\t\t}\n\t\t.options-list-item-description {\n\t\t\tfont-size: 10px;\n\t\t}\n\t",
|
|
204
|
-
useShadow: true,
|
|
205
|
-
})
|
|
206
|
-
], TypeAheadElement);
|
|
207
|
-
return TypeAheadElement;
|
|
208
|
-
}(CustomInputElement_1.CustomInputElement));
|
|
209
|
-
exports.TypeAheadElement = TypeAheadElement;
|
|
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.TypeAheadElement = 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 DomUtility_1 = require("../../framework/Utilities/DomUtility");
|
|
29
|
+
var TypeAheadElement = /** @class */ (function (_super) {
|
|
30
|
+
__extends(TypeAheadElement, _super);
|
|
31
|
+
function TypeAheadElement() {
|
|
32
|
+
var _this = _super.call(this) || this;
|
|
33
|
+
_this.currentFoucsedIndex = -1;
|
|
34
|
+
_this.searchResultOptions = [];
|
|
35
|
+
return _this;
|
|
36
|
+
}
|
|
37
|
+
Object.defineProperty(TypeAheadElement.prototype, "searchHasResults", {
|
|
38
|
+
get: function () {
|
|
39
|
+
var autocompleteList = _super.prototype.getChildElement.call(this, '.options-list');
|
|
40
|
+
return autocompleteList && this.optionsWithDescriptions && this.optionsWithDescriptions.length > 0;
|
|
41
|
+
},
|
|
42
|
+
enumerable: false,
|
|
43
|
+
configurable: true
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(TypeAheadElement.prototype, "value", {
|
|
46
|
+
get: function () {
|
|
47
|
+
if (!this.selectedOption) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return this.selectedOption.value;
|
|
51
|
+
},
|
|
52
|
+
set: function (value) {
|
|
53
|
+
if (!this.optionsWithDescriptions || this.optionsWithDescriptions.length === 0) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
var option = this.optionsWithDescriptions.find(function (option) { return option.value === value; });
|
|
57
|
+
if (!option) {
|
|
58
|
+
this.descriptionElement.innerHTML = null;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.selectedOption = option;
|
|
62
|
+
this.textInputElement.value = option.title;
|
|
63
|
+
this.descriptionElement.innerHTML = option.description;
|
|
64
|
+
},
|
|
65
|
+
enumerable: false,
|
|
66
|
+
configurable: true
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(TypeAheadElement.prototype, "valid", {
|
|
69
|
+
get: function () {
|
|
70
|
+
if (this.required) {
|
|
71
|
+
return !!this.selectedOption;
|
|
72
|
+
}
|
|
73
|
+
return !!this.selectedOption || this.textInputElement.value === '';
|
|
74
|
+
},
|
|
75
|
+
enumerable: false,
|
|
76
|
+
configurable: true
|
|
77
|
+
});
|
|
78
|
+
TypeAheadElement.prototype.connectedCallback = function () {
|
|
79
|
+
_super.prototype.connectedCallback.call(this);
|
|
80
|
+
};
|
|
81
|
+
TypeAheadElement.prototype.initChildInputs = function () {
|
|
82
|
+
var _this = this;
|
|
83
|
+
this.textInputElement = _super.prototype.getChildInput.call(this, '#text-input');
|
|
84
|
+
this.descriptionElement = _super.prototype.getChildInput.call(this, '#description');
|
|
85
|
+
this.componentWrapper = _super.prototype.getChildElement.call(this, '.wrapper');
|
|
86
|
+
if (this.required) {
|
|
87
|
+
this.textInputElement.setAttribute('required', '');
|
|
88
|
+
}
|
|
89
|
+
this.textInputElement.addEventListener('change', this.change.bind(this));
|
|
90
|
+
this.textInputElement.addEventListener('input', function () {
|
|
91
|
+
_this.inputEventHandler();
|
|
92
|
+
});
|
|
93
|
+
this.bindNavigation();
|
|
94
|
+
};
|
|
95
|
+
TypeAheadElement.prototype.inputEventHandler = function () {
|
|
96
|
+
var _this = this;
|
|
97
|
+
this.selectedOption = null;
|
|
98
|
+
this.descriptionElement.innerHTML = null;
|
|
99
|
+
this.closeOptionsList();
|
|
100
|
+
this.searchResultOptions = [];
|
|
101
|
+
var searchValue = this.textInputElement.value;
|
|
102
|
+
if (!searchValue || searchValue.trim() === '') {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
var optionslist = document.createElement('div');
|
|
106
|
+
optionslist.classList.add('options-list');
|
|
107
|
+
if (!this.optionsWithDescriptions) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.optionsWithDescriptions.forEach(function (option, index) {
|
|
111
|
+
var regex = new RegExp(searchValue, 'gi');
|
|
112
|
+
var isMatchingTitle = regex.test(option.title);
|
|
113
|
+
var isMatchingValue = regex.test(option.value);
|
|
114
|
+
var isMatchingDescription = regex.test(option.description);
|
|
115
|
+
if (!isMatchingTitle && !isMatchingValue && !isMatchingDescription) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
_this.searchResultOptions.push(option);
|
|
119
|
+
var optionsListItem = document.createElement("div");
|
|
120
|
+
optionsListItem.classList.add('options-list-item');
|
|
121
|
+
optionsListItem.dataset['value'] = option.value;
|
|
122
|
+
optionslist.appendChild(optionsListItem);
|
|
123
|
+
var optionsListItemTitle = document.createElement("div");
|
|
124
|
+
optionsListItemTitle.classList.add('options-list-item-title');
|
|
125
|
+
optionsListItemTitle.innerHTML = DomUtility_1.default.boldenText(option.title, searchValue);
|
|
126
|
+
optionsListItem.appendChild(optionsListItemTitle);
|
|
127
|
+
var optionsListItemDescription = document.createElement("div");
|
|
128
|
+
optionsListItemDescription.classList.add('options-list-item-description');
|
|
129
|
+
optionsListItemDescription.innerHTML = DomUtility_1.default.boldenText(option.description, searchValue);
|
|
130
|
+
optionsListItem.appendChild(optionsListItemDescription);
|
|
131
|
+
optionsListItem.addEventListener('click', function () {
|
|
132
|
+
_this.optionSelectedHandler(option);
|
|
133
|
+
});
|
|
134
|
+
_this.componentWrapper.appendChild(optionslist);
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
TypeAheadElement.prototype.closeOptionsList = function () {
|
|
138
|
+
this.currentFoucsedIndex = -1;
|
|
139
|
+
var optionsList = _super.prototype.getChildElement.call(this, '.options-list');
|
|
140
|
+
if (!optionsList) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
optionsList.remove();
|
|
144
|
+
};
|
|
145
|
+
TypeAheadElement.prototype.optionSelectedHandler = function (option) {
|
|
146
|
+
this.value = option.value;
|
|
147
|
+
this.onChange.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'change'));
|
|
148
|
+
this.closeOptionsList();
|
|
149
|
+
};
|
|
150
|
+
TypeAheadElement.prototype.bindNavigation = function () {
|
|
151
|
+
var _this = this;
|
|
152
|
+
this.textInputElement.addEventListener('keydown', function (event) {
|
|
153
|
+
if (event.key === 'Escape') {
|
|
154
|
+
_this.closeOptionsList();
|
|
155
|
+
}
|
|
156
|
+
if (event.key === 'ArrowDown') {
|
|
157
|
+
if (!_this.searchHasResults) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
_this.currentFoucsedIndex = _this.currentFoucsedIndex === _this.searchResultOptions.length - 1 ? 0 : _this.currentFoucsedIndex + 1;
|
|
161
|
+
_this.highlightFocusedSearchResult();
|
|
162
|
+
}
|
|
163
|
+
if (event.key === 'ArrowUp') {
|
|
164
|
+
if (!_this.searchHasResults) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
_this.currentFoucsedIndex = _this.currentFoucsedIndex === 0 ? _this.searchResultOptions.length - 1 : _this.currentFoucsedIndex - 1;
|
|
168
|
+
_this.highlightFocusedSearchResult();
|
|
169
|
+
}
|
|
170
|
+
if (event.key === 'Enter') {
|
|
171
|
+
if (_this.currentFoucsedIndex !== -1 && _this.searchHasResults) {
|
|
172
|
+
_this.optionSelectedHandler(_this.searchResultOptions[_this.currentFoucsedIndex]);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
TypeAheadElement.prototype.highlightFocusedSearchResult = function () {
|
|
179
|
+
var _this = this;
|
|
180
|
+
var optionListItems = _super.prototype.getChildElements.call(this, '.options-list-item');
|
|
181
|
+
if (!optionListItems) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
optionListItems.forEach(function (listItem, index) {
|
|
185
|
+
listItem.classList.remove('active');
|
|
186
|
+
if (index === _this.currentFoucsedIndex) {
|
|
187
|
+
listItem.classList.add('active');
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
TypeAheadElement.prototype.change = function ($event) {
|
|
192
|
+
this.touched = true;
|
|
193
|
+
this.onChange.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'change'));
|
|
194
|
+
};
|
|
195
|
+
TypeAheadElement.prototype.validate = function () {
|
|
196
|
+
this.valid;
|
|
197
|
+
this.onValidate.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'validate'));
|
|
198
|
+
};
|
|
199
|
+
TypeAheadElement = __decorate([
|
|
200
|
+
(0, custom_element_decorator_1.default)({
|
|
201
|
+
selector: 'type-ahead-element',
|
|
202
|
+
template: "\n\t\t<div class=\"wrapper\">\n\t\t\t<input type=\"text\" id=\"text-input\">\n\t\t\t<div id=\"description\"></div>\n\t\t</div>",
|
|
203
|
+
style: "\n\t\t:host {\n\t\t\twidth:100%;\n\t\t}\n\t\t.wrapper {\n\t\t\tposition: relative;\n\t\t\tdisplay:flex;\n\t\t\tflex-direction: column;\n\t\t\tjustify-content: center;\n\t\t\talign-items: center;\n\t\t}\n\t\t#text-input {\n\t\t\tbox-sizing: border-box;\n\t\t\twidth: 100% !important;\n\t\t\tborder: none;\n\t\t\tbackground-color: #f1f4ff;\n\t\t\tmargin: 2px;\n\t\t\tresize: none;\n\t\t}\n\t\t.wrapper #description {\n\t\t\twidth: 100%;\n\t\t\tpadding: 0 2px;\n\t\t\tbox-sizing: border-box;\n\t\t}\n\t\t.options-list {\n\t\t\tposition: absolute;\n\t\t\tborder: 1px solid #E8E8E8;\n\t\t\tborder-bottom: none;\n\t\t\tborder-top: none;\n\t\t\tz-index: 3;\n\t\t\ttop: 100%;\n\t\t\tleft: 0;\n\t\t\tright: 0;\n\t\t\tmax-height: 200px;\n\t\t\toverflow-y: auto;\n\t\t}\n\t\t.options-list-item {\n\t\t\tpadding: 10px;\n\t\t\tcursor: pointer;\n\t\t\tbackground-color: #FFFFFF;\n\t\t\tborder-bottom: 1px solid #E8E8E8;\n\t\t}\n\t\t.options-list-item:hover {\n\t\t\tbackground-color: #E8E8E8;\n\t\t}\n\t\t.options-list-item.active {\n\t\t\t/*when navigating through the items using the arrow keys:*/\n\t\t\tbackground-color: #003E64 !important;\n\t\t\tcolor: #FFFFFF;\n\t\t}\n\t\t.options-list-item-title {\n\t\t\tfont-size: 16px;\n\t\t}\n\t\t.options-list-item-description {\n\t\t\tfont-size: 10px;\n\t\t}\n\t",
|
|
204
|
+
useShadow: true,
|
|
205
|
+
})
|
|
206
|
+
], TypeAheadElement);
|
|
207
|
+
return TypeAheadElement;
|
|
208
|
+
}(CustomInputElement_1.CustomInputElement));
|
|
209
|
+
exports.TypeAheadElement = TypeAheadElement;
|
|
210
210
|
//# sourceMappingURL=TypeAheadElement.js.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export interface Listener<T> {
|
|
2
|
-
(event: T): any;
|
|
3
|
-
}
|
|
4
|
-
export interface Disposable {
|
|
5
|
-
dispose(): any;
|
|
6
|
-
}
|
|
7
|
-
export declare class CustomElementEventArgs {
|
|
8
|
-
value: any;
|
|
9
|
-
eventName: string;
|
|
10
|
-
constructor(value: any, eventName: string);
|
|
11
|
-
}
|
|
12
|
-
/** passes through events as they happen. You will not get events from before you start listening */
|
|
13
|
-
export declare class CustomElementEvent<T> {
|
|
14
|
-
private listeners;
|
|
15
|
-
private listenersOncer;
|
|
16
|
-
on: (listener: Listener<T>) => Disposable;
|
|
17
|
-
once: (listener: Listener<T>) => void;
|
|
18
|
-
off: (listener: Listener<T>) => void;
|
|
19
|
-
emit: (event: T) => void;
|
|
20
|
-
pipe: (te: CustomElementEvent<T>) => Disposable;
|
|
21
|
-
}
|
|
1
|
+
export interface Listener<T> {
|
|
2
|
+
(event: T): any;
|
|
3
|
+
}
|
|
4
|
+
export interface Disposable {
|
|
5
|
+
dispose(): any;
|
|
6
|
+
}
|
|
7
|
+
export declare class CustomElementEventArgs {
|
|
8
|
+
value: any;
|
|
9
|
+
eventName: string;
|
|
10
|
+
constructor(value: any, eventName: string);
|
|
11
|
+
}
|
|
12
|
+
/** passes through events as they happen. You will not get events from before you start listening */
|
|
13
|
+
export declare class CustomElementEvent<T> {
|
|
14
|
+
private listeners;
|
|
15
|
+
private listenersOncer;
|
|
16
|
+
on: (listener: Listener<T>) => Disposable;
|
|
17
|
+
once: (listener: Listener<T>) => void;
|
|
18
|
+
off: (listener: Listener<T>) => void;
|
|
19
|
+
emit: (event: T) => void;
|
|
20
|
+
pipe: (te: CustomElementEvent<T>) => Disposable;
|
|
21
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CustomElementEvent = exports.CustomElementEventArgs = void 0;
|
|
4
|
-
var CustomElementEventArgs = /** @class */ (function () {
|
|
5
|
-
function CustomElementEventArgs(value, eventName) {
|
|
6
|
-
this.value = value;
|
|
7
|
-
this.eventName = eventName;
|
|
8
|
-
}
|
|
9
|
-
return CustomElementEventArgs;
|
|
10
|
-
}());
|
|
11
|
-
exports.CustomElementEventArgs = CustomElementEventArgs;
|
|
12
|
-
/** passes through events as they happen. You will not get events from before you start listening */
|
|
13
|
-
var CustomElementEvent = /** @class */ (function () {
|
|
14
|
-
function CustomElementEvent() {
|
|
15
|
-
var _this = this;
|
|
16
|
-
this.listeners = [];
|
|
17
|
-
this.listenersOncer = [];
|
|
18
|
-
this.on = function (listener) {
|
|
19
|
-
_this.listeners.push(listener);
|
|
20
|
-
return {
|
|
21
|
-
dispose: function () { return _this.off(listener); },
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
this.once = function (listener) {
|
|
25
|
-
_this.listenersOncer.push(listener);
|
|
26
|
-
};
|
|
27
|
-
this.off = function (listener) {
|
|
28
|
-
var callbackIndex = _this.listeners.indexOf(listener);
|
|
29
|
-
if (callbackIndex > -1)
|
|
30
|
-
_this.listeners.splice(callbackIndex, 1);
|
|
31
|
-
};
|
|
32
|
-
this.emit = function (event) {
|
|
33
|
-
/** Update any general listeners */
|
|
34
|
-
_this.listeners.forEach(function (listener) { return listener(event); });
|
|
35
|
-
/** Clear the `once` queue */
|
|
36
|
-
if (_this.listenersOncer.length > 0) {
|
|
37
|
-
_this.listenersOncer.forEach(function (listener) { return listener(event); });
|
|
38
|
-
_this.listenersOncer = [];
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
this.pipe = function (te) {
|
|
42
|
-
return _this.on(function (e) { return te.emit(e); });
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
return CustomElementEvent;
|
|
46
|
-
}());
|
|
47
|
-
exports.CustomElementEvent = CustomElementEvent;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomElementEvent = exports.CustomElementEventArgs = void 0;
|
|
4
|
+
var CustomElementEventArgs = /** @class */ (function () {
|
|
5
|
+
function CustomElementEventArgs(value, eventName) {
|
|
6
|
+
this.value = value;
|
|
7
|
+
this.eventName = eventName;
|
|
8
|
+
}
|
|
9
|
+
return CustomElementEventArgs;
|
|
10
|
+
}());
|
|
11
|
+
exports.CustomElementEventArgs = CustomElementEventArgs;
|
|
12
|
+
/** passes through events as they happen. You will not get events from before you start listening */
|
|
13
|
+
var CustomElementEvent = /** @class */ (function () {
|
|
14
|
+
function CustomElementEvent() {
|
|
15
|
+
var _this = this;
|
|
16
|
+
this.listeners = [];
|
|
17
|
+
this.listenersOncer = [];
|
|
18
|
+
this.on = function (listener) {
|
|
19
|
+
_this.listeners.push(listener);
|
|
20
|
+
return {
|
|
21
|
+
dispose: function () { return _this.off(listener); },
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
this.once = function (listener) {
|
|
25
|
+
_this.listenersOncer.push(listener);
|
|
26
|
+
};
|
|
27
|
+
this.off = function (listener) {
|
|
28
|
+
var callbackIndex = _this.listeners.indexOf(listener);
|
|
29
|
+
if (callbackIndex > -1)
|
|
30
|
+
_this.listeners.splice(callbackIndex, 1);
|
|
31
|
+
};
|
|
32
|
+
this.emit = function (event) {
|
|
33
|
+
/** Update any general listeners */
|
|
34
|
+
_this.listeners.forEach(function (listener) { return listener(event); });
|
|
35
|
+
/** Clear the `once` queue */
|
|
36
|
+
if (_this.listenersOncer.length > 0) {
|
|
37
|
+
_this.listenersOncer.forEach(function (listener) { return listener(event); });
|
|
38
|
+
_this.listenersOncer = [];
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
this.pipe = function (te) {
|
|
42
|
+
return _this.on(function (e) { return te.emit(e); });
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return CustomElementEvent;
|
|
46
|
+
}());
|
|
47
|
+
exports.CustomElementEvent = CustomElementEvent;
|
|
48
48
|
//# sourceMappingURL=CustomEvents.js.map
|