@luftborn/custom-elements 1.1.43 → 1.4.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/dist/custom-form.js +5 -4
- package/dist/custom-form.js.map +1 -1
- package/dist/elements/CheckBoxElement/CheckBoxElement.js +2 -2
- package/dist/elements/CheckBoxElement/CheckBoxElement.js.map +1 -1
- package/dist/elements/DropDownList/DropDownListElement.js +2 -2
- package/dist/elements/DropDownList/DropDownListElement.js.map +1 -1
- package/dist/elements/FileField/FileFieldElement.d.ts +3 -0
- package/dist/elements/FileField/FileFieldElement.js +21 -1
- package/dist/elements/FileField/FileFieldElement.js.map +1 -1
- package/dist/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.js +19 -13
- package/dist/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.js.map +1 -1
- package/dist/elements/RadioButtonGroup/RadioButtonGroupElement.js +2 -2
- package/dist/elements/RadioButtonGroup/RadioButtonGroupElement.js.map +1 -1
- package/dist/framework/CustomInputElement.d.ts +1 -1
- package/dist/framework/CustomInputElement.js +4 -3
- package/dist/framework/CustomInputElement.js.map +1 -1
- 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/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/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 +17 -0
- package/dist/framework/Language/Translator.js +86 -3
- package/dist/framework/Language/Translator.js.map +1 -1
- 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/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/node_modules/@webcomponents/webcomponentsjs/package.json +31 -62
- package/package.json +1 -2
- package/src/custom-form.ts +2 -1
- package/src/elements/CheckBoxElement/CheckBoxElement.ts +1 -1
- package/src/elements/DropDownList/DropDownListElement.ts +1 -1
- package/src/elements/FileField/FileFieldElement.ts +20 -0
- package/src/elements/InternationaPhoneNumber/InternationaPhoneNumberElement.ts +22 -17
- package/src/elements/RadioButtonGroup/RadioButtonGroupElement.ts +1 -1
- package/src/framework/CustomInputElement.ts +2 -1
- package/src/framework/Language/Languages/CzechDictionary.ts +18 -0
- package/src/framework/Language/Languages/DutchDictionary.ts +18 -0
- 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 +87 -3
- package/src/framework/Utilities/ArrayUtil.ts +31 -0
- package/src/framework/Utilities/DomUtil.ts +117 -0
- package/src/framework/Utilities/MakeRequest.ts +47 -0
- package/src/framework/Utilities/StringUtil.ts +9 -0
- package/src/framework/Utilities/ViewportUtil.ts +46 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ViewportUtil } from './ViewportUtil';
|
|
2
|
+
|
|
3
|
+
export default class DomUtil {
|
|
4
|
+
private viewPortUtil: ViewportUtil;
|
|
5
|
+
public element: Element;
|
|
6
|
+
constructor(element: Element) {
|
|
7
|
+
this.element = element;
|
|
8
|
+
this.viewPortUtil = new ViewportUtil(this.element as HTMLElement);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public getDataAttr(attr: string, defaultvalue?: string): any {
|
|
12
|
+
if (!this.element) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const value = this.element.getAttribute(`data-${attr}`);
|
|
16
|
+
|
|
17
|
+
return value !== undefined ? value : defaultvalue;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public setDataAttr(attr: string, value: string): any {
|
|
21
|
+
if (!this.element) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return this.element.setAttribute(`data-${attr}`, value);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public getAttr(attr: string, defaultvalue?: string): any {
|
|
28
|
+
if (!this.element) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const value = this.element.getAttribute(attr);
|
|
32
|
+
return value !== undefined ? value : defaultvalue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public setAttr(attr: string, value: string): void {
|
|
36
|
+
if (!this.element) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
this.element.setAttribute(attr, value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public removeAttr(attr: string): void {
|
|
43
|
+
if (!this.element) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
this.element.removeAttribute(attr);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public removeDataAttr(attr: string): void {
|
|
50
|
+
if (!this.element) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
this.element.removeAttribute(`data-${attr}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public hasAttr(attr: string): boolean {
|
|
57
|
+
if (!this.element) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return this.element.hasAttribute(attr);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public shake(): void {
|
|
64
|
+
this.appendClass('shake');
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
this.removeClass('shake');
|
|
67
|
+
(this.element as HTMLInputElement).readOnly = false;
|
|
68
|
+
}, 600);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public error(): void {
|
|
72
|
+
this.appendClass('error');
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
this.removeClass('error');
|
|
75
|
+
(this.element as HTMLInputElement).readOnly = false;
|
|
76
|
+
}, 5000);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public focus(): void {
|
|
80
|
+
if (!this.viewPortUtil.IsVisible()) {
|
|
81
|
+
this.element.scrollIntoView();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public removeClass(classname): void {
|
|
86
|
+
this.element.classList.remove(classname);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public appendClass(classname): void {
|
|
90
|
+
this.element.classList.add(classname);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public deleteElement(): void {
|
|
94
|
+
if (!this.element) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
this.element.remove();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public setChildElementByAttrName(name: string, value: string): void {
|
|
101
|
+
const firstLetter = name.replace(/^\w/, c => c.toUpperCase());
|
|
102
|
+
const SubElement = this.element.querySelector(
|
|
103
|
+
`[name="${firstLetter}"]`,
|
|
104
|
+
) as HTMLInputElement;
|
|
105
|
+
if (SubElement) {
|
|
106
|
+
SubElement.value = value;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public hasClass(className: string): boolean {
|
|
111
|
+
return this.element.classList.contains(className);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public getStyle(ruleName: string) {
|
|
115
|
+
return getComputedStyle(this.element)[ruleName];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export default class MakeRequest {
|
|
2
|
+
method: string;
|
|
3
|
+
url: string;
|
|
4
|
+
headers: any;
|
|
5
|
+
|
|
6
|
+
constructor(url: string, method: string = 'get', headers: any = {}) {
|
|
7
|
+
this.method = method;
|
|
8
|
+
this.url = url;
|
|
9
|
+
this.headers = headers;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
private setHeaders(httpRequest: XMLHttpRequest) {
|
|
13
|
+
for (const header in this.headers) {
|
|
14
|
+
httpRequest.setRequestHeader(header, this.headers[header]);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
send(data: any = null) {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const xmlHttpRequest = new XMLHttpRequest();
|
|
21
|
+
xmlHttpRequest.open(this.method, this.url);
|
|
22
|
+
this.setHeaders(xmlHttpRequest);
|
|
23
|
+
xmlHttpRequest.onload = () => {
|
|
24
|
+
if (
|
|
25
|
+
xmlHttpRequest.status >= 200 &&
|
|
26
|
+
xmlHttpRequest.status < 300
|
|
27
|
+
) {
|
|
28
|
+
resolve(xmlHttpRequest.response);
|
|
29
|
+
} else {
|
|
30
|
+
reject({
|
|
31
|
+
status: xmlHttpRequest.status,
|
|
32
|
+
statusText: xmlHttpRequest.statusText,
|
|
33
|
+
body: xmlHttpRequest.response,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
xmlHttpRequest.onerror = () => {
|
|
38
|
+
reject({
|
|
39
|
+
status: xmlHttpRequest.status,
|
|
40
|
+
statusText: xmlHttpRequest.statusText,
|
|
41
|
+
body: xmlHttpRequest.response,
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
xmlHttpRequest.send(data);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export class ViewportUtil {
|
|
2
|
+
private element?: HTMLElement;
|
|
3
|
+
constructor(element: HTMLElement = null) {
|
|
4
|
+
this.element = element;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
public IsVisible(): boolean {
|
|
8
|
+
const bounds = this.element.getBoundingClientRect();
|
|
9
|
+
return (
|
|
10
|
+
((bounds.top > 0 && bounds.top < innerHeight) ||
|
|
11
|
+
(bounds.bottom > 0 && bounds.bottom < innerHeight)) &&
|
|
12
|
+
((bounds.left > 0 && bounds.left < innerWidth) ||
|
|
13
|
+
(bounds.right > 0 && bounds.right < innerWidth))
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public IsPartiallyVisible() {
|
|
18
|
+
const bounds = this.element.getBoundingClientRect();
|
|
19
|
+
return (
|
|
20
|
+
bounds.top >= 0 ||
|
|
21
|
+
bounds.left >= 0 ||
|
|
22
|
+
bounds.bottom <= innerHeight ||
|
|
23
|
+
bounds.right <= innerWidth
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public IsOffsetVisible(offset: number = 300) {
|
|
28
|
+
const bounds = this.element.getBoundingClientRect();
|
|
29
|
+
// tslint:disable-next-line: max-line-length
|
|
30
|
+
return (
|
|
31
|
+
bounds.top + offset >= 0 ||
|
|
32
|
+
bounds.left + offset >= 0 ||
|
|
33
|
+
bounds.bottom - offset <= innerHeight ||
|
|
34
|
+
bounds.right - offset <= innerWidth
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public WindowTop(offset: number = 0) {
|
|
39
|
+
const YOffset =
|
|
40
|
+
window.pageYOffset ||
|
|
41
|
+
document.documentElement.scrollTop ||
|
|
42
|
+
document.body.scrollTop ||
|
|
43
|
+
0;
|
|
44
|
+
return offset <= YOffset;
|
|
45
|
+
}
|
|
46
|
+
}
|