@everymatrix/general-input 1.10.2 → 1.15.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/cjs/checkbox-group-input_10.cjs.entry.js +35539 -0
- package/dist/cjs/general-input.cjs.entry.js +34 -13
- package/dist/cjs/general-input.cjs.js +2 -2
- package/dist/cjs/{index-64a5cb7f.js → index-132a0774.js} +119 -6
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/locale.utils-7665b010.js +71 -0
- package/dist/cjs/toggle-checkbox-input.cjs.entry.js +85 -0
- package/dist/cjs/tooltipIcon-092a795f.js +5 -0
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/checkbox-group-input/checkbox-group-input.css +62 -0
- package/dist/collection/components/checkbox-group-input/checkbox-group-input.js +366 -0
- package/dist/collection/components/checkbox-input/checkbox-input.css +47 -1
- package/dist/collection/components/checkbox-input/checkbox-input.js +143 -16
- package/dist/collection/components/date-input/date-input.css +64 -30
- package/dist/collection/components/date-input/date-input.js +194 -13
- package/dist/collection/components/email-input/email-input.css +63 -28
- package/dist/collection/components/email-input/email-input.js +197 -21
- package/dist/collection/components/general-input/general-input.js +163 -21
- package/dist/collection/components/number-input/number-input.css +65 -30
- package/dist/collection/components/number-input/number-input.js +174 -19
- package/dist/collection/components/password-input/password-input.css +120 -29
- package/dist/collection/components/password-input/password-input.js +341 -25
- package/dist/collection/components/radio-input/radio-input.css +22 -1
- package/dist/collection/components/radio-input/radio-input.js +89 -10
- package/dist/collection/components/select-input/select-input.css +75 -22
- package/dist/collection/components/select-input/select-input.js +180 -37
- package/dist/collection/components/tel-input/tel-input.css +91 -33
- package/dist/collection/components/tel-input/tel-input.js +202 -24
- package/dist/collection/components/text-input/text-input.css +63 -28
- package/dist/collection/components/text-input/text-input.js +208 -39
- package/dist/collection/components/toggle-checkbox-input/toggle-checkbox-input.css +76 -0
- package/dist/collection/components/toggle-checkbox-input/toggle-checkbox-input.js +324 -0
- package/dist/collection/utils/locale.utils.js +52 -13
- package/dist/collection/utils/tooltipIcon.svg +5 -0
- package/dist/components/active-mixin.js +975 -0
- package/dist/components/checkbox-group-input.d.ts +11 -0
- package/dist/components/checkbox-group-input.js +6 -0
- package/dist/components/checkbox-group-input2.js +1125 -0
- package/dist/components/checkbox-input2.js +62 -12
- package/dist/components/date-input2.js +10247 -15
- package/dist/components/email-input2.js +98 -21
- package/dist/components/field-mixin.js +12712 -0
- package/dist/components/general-input.js +1 -118
- package/dist/components/general-input2.js +331 -0
- package/dist/components/input-field-shared-styles.js +1114 -0
- package/dist/components/number-input2.js +92 -16
- package/dist/components/password-input2.js +924 -24
- package/dist/components/pattern-mixin.js +85 -0
- package/dist/components/radio-input2.js +45 -11
- package/dist/components/select-input2.js +87 -27
- package/dist/components/tel-input2.js +122 -22
- package/dist/components/text-input2.js +120 -34
- package/dist/components/toggle-checkbox-input.d.ts +11 -0
- package/dist/components/toggle-checkbox-input.js +6 -0
- package/dist/components/tooltipIcon.js +70 -0
- package/dist/components/vaadin-button.js +461 -0
- package/dist/components/vaadin-combo-box.js +4329 -0
- package/dist/components/virtual-keyboard-controller.js +2658 -0
- package/dist/esm/checkbox-group-input_10.entry.js +35526 -0
- package/dist/esm/general-input.entry.js +34 -13
- package/dist/esm/general-input.js +2 -2
- package/dist/esm/{index-df80f936.js → index-db76d5b5.js} +118 -7
- package/dist/esm/loader.js +2 -2
- package/dist/esm/locale.utils-95ea2605.js +68 -0
- package/dist/esm/toggle-checkbox-input.entry.js +81 -0
- package/dist/esm/tooltipIcon-99c1c7b7.js +3 -0
- package/dist/general-input/general-input.esm.js +1 -1
- package/dist/general-input/p-0966f523.entry.js +3581 -0
- package/dist/general-input/p-916a1319.entry.js +1 -0
- package/dist/general-input/p-b408093e.js +1 -0
- package/dist/general-input/p-c2d4d6ac.entry.js +1 -0
- package/dist/general-input/p-f4f4ccda.js +1 -0
- package/dist/general-input/p-f6132f1d.js +1 -0
- package/dist/types/components/checkbox-group-input/checkbox-group-input.d.ts +74 -0
- package/dist/types/components/checkbox-input/checkbox-input.d.ts +28 -2
- package/dist/types/components/date-input/date-input.d.ts +43 -1
- package/dist/types/components/email-input/email-input.d.ts +37 -3
- package/dist/types/components/general-input/general-input.d.ts +30 -0
- package/dist/types/components/number-input/number-input.d.ts +34 -3
- package/dist/types/components/password-input/password-input.d.ts +56 -7
- package/dist/types/components/radio-input/radio-input.d.ts +17 -1
- package/dist/types/components/select-input/select-input.d.ts +36 -3
- package/dist/types/components/tel-input/tel-input.d.ts +40 -5
- package/dist/types/components/text-input/text-input.d.ts +84 -0
- package/dist/types/components/toggle-checkbox-input/toggle-checkbox-input.d.ts +67 -0
- package/dist/types/components.d.ts +568 -9
- package/dist/types/utils/locale.utils.d.ts +9 -0
- package/dist/types/utils/types.d.ts +41 -9
- package/package.json +8 -1
- package/dist/cjs/checkbox-input_9.cjs.entry.js +0 -623
- package/dist/components/locale.utils.js +0 -29
- package/dist/esm/checkbox-input_9.entry.js +0 -611
- package/dist/general-input/p-1703fce3.entry.js +0 -1
- package/dist/general-input/p-d9f7fa2e.js +0 -1
- package/dist/general-input/p-dea0a4ac.entry.js +0 -1
- /package/dist/types/Users/{user/workspace/everymatrix → adrian.pripon/Documents/Work}/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { y as Debouncer, z as timeOut } from './field-mixin.js';
|
|
2
|
+
import { I as InputConstraintsMixin } from './input-field-shared-styles.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
7
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A mixin to provide `pattern` and `preventInvalidInput` properties.
|
|
12
|
+
*
|
|
13
|
+
* @polymerMixin
|
|
14
|
+
* @mixes InputConstraintsMixin
|
|
15
|
+
*/
|
|
16
|
+
const PatternMixin = (superclass) =>
|
|
17
|
+
class PatternMixinClass extends InputConstraintsMixin(superclass) {
|
|
18
|
+
static get properties() {
|
|
19
|
+
return {
|
|
20
|
+
/**
|
|
21
|
+
* A regular expression that the value is checked against.
|
|
22
|
+
* The pattern must match the entire value, not just some subset.
|
|
23
|
+
*/
|
|
24
|
+
pattern: {
|
|
25
|
+
type: String,
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* When set to true, user is prevented from typing a value that
|
|
30
|
+
* conflicts with the given `pattern`.
|
|
31
|
+
* @attr {boolean} prevent-invalid-input
|
|
32
|
+
* @deprecated Please use `allowedCharPattern` instead.
|
|
33
|
+
*/
|
|
34
|
+
preventInvalidInput: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
observer: '_preventInvalidInputChanged',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static get delegateAttrs() {
|
|
42
|
+
return [...super.delegateAttrs, 'pattern'];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static get constraints() {
|
|
46
|
+
return [...super.constraints, 'pattern'];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** @private */
|
|
50
|
+
_checkInputValue() {
|
|
51
|
+
if (this.preventInvalidInput) {
|
|
52
|
+
const input = this.inputElement;
|
|
53
|
+
if (input && input.value.length > 0 && !this.checkValidity()) {
|
|
54
|
+
input.value = this.value || '';
|
|
55
|
+
// Add input-prevented attribute for 200ms
|
|
56
|
+
this.setAttribute('input-prevented', '');
|
|
57
|
+
this._inputDebouncer = Debouncer.debounce(this._inputDebouncer, timeOut.after(200), () => {
|
|
58
|
+
this.removeAttribute('input-prevented');
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param {Event} event
|
|
66
|
+
* @protected
|
|
67
|
+
* @override
|
|
68
|
+
*/
|
|
69
|
+
_onInput(event) {
|
|
70
|
+
this._checkInputValue();
|
|
71
|
+
|
|
72
|
+
super._onInput(event);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** @private */
|
|
76
|
+
_preventInvalidInputChanged(preventInvalidInput) {
|
|
77
|
+
if (preventInvalidInput) {
|
|
78
|
+
console.warn(
|
|
79
|
+
`WARNING: Since Vaadin 23.2, "preventInvalidInput" is deprecated. Please use "allowedCharPattern" instead.`,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { PatternMixin as P };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { t as translate } from './
|
|
2
|
+
import { t as translate, a as tooltipIconSvg } from './tooltipIcon.js';
|
|
3
3
|
|
|
4
|
-
const radioInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.radio__fieldset{border:none;position:relative}.radio__wrapper{display:flex;gap:5px}.radio__error-message{position:absolute;top:calc(100% + 5px);left:0;color:
|
|
4
|
+
const radioInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.radio__fieldset{border:none;position:relative}.radio__wrapper{display:flex;gap:5px}.radio__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}.radio__tooltip-icon{position:absolute;right:0;bottom:10px}.radio__tooltip{position:absolute;bottom:35px;right:10px;background-color:#FFFFFF;border:1px solid #B0B0B0;color:#2B2D3F;padding:10px;border-radius:5px;opacity:0;transition:opacity 0.3s ease-in-out;z-index:10}.radio__tooltip.visible{opacity:1}";
|
|
5
5
|
|
|
6
6
|
const RadioInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
7
|
constructor() {
|
|
@@ -10,6 +10,17 @@ const RadioInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
10
10
|
this.__attachShadow();
|
|
11
11
|
this.sendInputValue = createEvent(this, "sendInputValue", 7);
|
|
12
12
|
this.sendValidityState = createEvent(this, "sendValidityState", 7);
|
|
13
|
+
/**
|
|
14
|
+
* Client custom styling via inline style
|
|
15
|
+
*/
|
|
16
|
+
this.clientStyling = '';
|
|
17
|
+
this.limitStylingAppends = false;
|
|
18
|
+
this.showTooltip = false;
|
|
19
|
+
this.setClientStyling = () => {
|
|
20
|
+
let sheet = document.createElement('style');
|
|
21
|
+
sheet.innerHTML = this.clientStyling;
|
|
22
|
+
this.stylingContainer.prepend(sheet);
|
|
23
|
+
};
|
|
13
24
|
}
|
|
14
25
|
validityChanged() {
|
|
15
26
|
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
@@ -28,13 +39,25 @@ const RadioInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
28
39
|
validityStateHandler(inputStateEvent) {
|
|
29
40
|
this.sendValidityState.emit(inputStateEvent);
|
|
30
41
|
}
|
|
31
|
-
|
|
42
|
+
handleClickOutside(event) {
|
|
43
|
+
if (event.composedPath()[0] === this.tooltipIconReference)
|
|
44
|
+
return;
|
|
45
|
+
if (event.composedPath()[0] !== this.tooltipReference)
|
|
46
|
+
this.showTooltip = false;
|
|
47
|
+
}
|
|
48
|
+
componentDidRender() {
|
|
49
|
+
// start custom styling area
|
|
50
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
51
|
+
if (this.clientStyling)
|
|
52
|
+
this.setClientStyling();
|
|
53
|
+
this.limitStylingAppends = true;
|
|
54
|
+
}
|
|
55
|
+
// end custom styling area
|
|
32
56
|
}
|
|
33
57
|
handleClick(event) {
|
|
34
58
|
this.value = event.target.value;
|
|
35
59
|
this.isValid = this.setValidity();
|
|
36
60
|
this.errorMessage = this.setErrorMessage();
|
|
37
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
38
61
|
this.emitValueHandler(true);
|
|
39
62
|
}
|
|
40
63
|
setValidity() {
|
|
@@ -45,8 +68,15 @@ const RadioInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
45
68
|
return translate('requiredError', this.language);
|
|
46
69
|
}
|
|
47
70
|
}
|
|
71
|
+
renderTooltip() {
|
|
72
|
+
if (this.showTooltip) {
|
|
73
|
+
return (h("div", { class: `radio__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
48
77
|
render() {
|
|
49
|
-
return h("fieldset", { class:
|
|
78
|
+
return h("fieldset", { class: `radio__fieldset ${this.name}__input`, ref: el => this.stylingContainer = el }, h("legend", { class: 'radio__legend' }, this.displayName, ":"), this.optionsGroup.map(option => h("div", { class: 'radio__wrapper' }, h("input", { type: "radio", class: 'radio__input', id: `${option.label}__input`, ref: (el) => this.inputReference = el, value: option.value, name: this.name, required: this.validation.mandatory, onClick: (e) => this.handleClick(e) }), h("label", { htmlFor: `${option.label}__input` }, option.label))), h("small", { class: 'radio__error-message' }, this.errorMessage), this.tooltip &&
|
|
79
|
+
h("img", { class: 'radio__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip());
|
|
50
80
|
}
|
|
51
81
|
static get watchers() { return {
|
|
52
82
|
"isValid": ["validityChanged"],
|
|
@@ -54,15 +84,19 @@ const RadioInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
54
84
|
}; }
|
|
55
85
|
static get style() { return radioInputCss; }
|
|
56
86
|
}, [1, "radio-input", {
|
|
57
|
-
"name": [
|
|
58
|
-
"displayName": [
|
|
87
|
+
"name": [513],
|
|
88
|
+
"displayName": [513, "display-name"],
|
|
59
89
|
"optionsGroup": [16],
|
|
60
90
|
"validation": [16],
|
|
61
|
-
"
|
|
62
|
-
"
|
|
91
|
+
"tooltip": [513],
|
|
92
|
+
"language": [513],
|
|
93
|
+
"emitValue": [516, "emit-value"],
|
|
94
|
+
"clientStyling": [513, "client-styling"],
|
|
63
95
|
"errorMessage": [32],
|
|
64
|
-
"isValid": [32]
|
|
65
|
-
|
|
96
|
+
"isValid": [32],
|
|
97
|
+
"limitStylingAppends": [32],
|
|
98
|
+
"showTooltip": [32]
|
|
99
|
+
}, [[4, "click", "handleClickOutside"]]]);
|
|
66
100
|
function defineCustomElement() {
|
|
67
101
|
if (typeof customElements === "undefined") {
|
|
68
102
|
return;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { t as translate } from './
|
|
2
|
+
import { t as translate, a as tooltipIconSvg } from './tooltipIcon.js';
|
|
3
|
+
import './input-field-shared-styles.js';
|
|
4
|
+
import './vaadin-combo-box.js';
|
|
3
5
|
|
|
4
|
-
const selectInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.select__wrapper{position:relative;
|
|
6
|
+
const selectInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.select{font-family:\"Roboto\";font-style:normal}.select__wrapper{position:relative;width:100%}.select__wrapper--autofilled{pointer-events:none}.select__wrapper--autofilled .select__label{color:#979797}.select__wrapper--autofilled .select__input::part(input-field){color:#979797}.select__wrapper--flex{display:flex;gap:5px}.select__wrapper--relative{position:relative}.select__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#2A3841}.select__label--required::after{content:\"*\";font-family:inherit;color:#2A3841;margin-left:2px}.select__input{border:none;width:inherit;position:relative}.select__input[focused]::part(input-field){border-color:#3E3E3E}.select__input[invalid]::part(input-field){border-color:#cc0000b3}.select__input vaadin-date-picker-overlay-content>vaadin-button{color:#1F1F1F}.select__input vaadin-month-calendar::part(selected date){background-color:red}.select__input::part(input-field){border-radius:4px;background-color:#FFFFFF;border:2px solid #DEE1EE;color:#2A2E3F;border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px}.select__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}.select__tooltip-icon{width:16px;height:auto}.select__tooltip{position:absolute;top:0;left:20px;background-color:#FFFFFF;border:1px solid #B0B0B0;color:#2B2D3F;padding:10px;border-radius:5px;opacity:0;transition:opacity 0.3s ease-in-out;z-index:10}.select__tooltip.visible{opacity:1}";
|
|
5
7
|
|
|
6
8
|
const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
9
|
constructor() {
|
|
@@ -10,10 +12,33 @@ const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
10
12
|
this.__attachShadow();
|
|
11
13
|
this.sendValidityState = createEvent(this, "sendValidityState", 7);
|
|
12
14
|
this.sendInputValue = createEvent(this, "sendInputValue", 7);
|
|
15
|
+
/**
|
|
16
|
+
* Default value for the input.
|
|
17
|
+
*/
|
|
18
|
+
this.defaultValue = '';
|
|
13
19
|
/**
|
|
14
20
|
* Options of the input.
|
|
15
21
|
*/
|
|
16
22
|
this.options = [];
|
|
23
|
+
/**
|
|
24
|
+
* Client custom styling via inline style
|
|
25
|
+
*/
|
|
26
|
+
this.clientStyling = '';
|
|
27
|
+
this.limitStylingAppends = false;
|
|
28
|
+
this.showTooltip = false;
|
|
29
|
+
this.touched = false;
|
|
30
|
+
this.handleChange = (event) => {
|
|
31
|
+
this.touched = true;
|
|
32
|
+
this.value = event.target.value;
|
|
33
|
+
this.isValid = this.setValidity();
|
|
34
|
+
this.errorMessage = this.setErrorMessage();
|
|
35
|
+
this.emitValueHandler(true);
|
|
36
|
+
};
|
|
37
|
+
this.setClientStyling = () => {
|
|
38
|
+
let sheet = document.createElement('style');
|
|
39
|
+
sheet.innerHTML = this.clientStyling;
|
|
40
|
+
this.stylingContainer.prepend(sheet);
|
|
41
|
+
};
|
|
17
42
|
}
|
|
18
43
|
validityChanged() {
|
|
19
44
|
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
@@ -32,23 +57,50 @@ const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
32
57
|
valueHandler(inputValueEvent) {
|
|
33
58
|
this.sendInputValue.emit(inputValueEvent);
|
|
34
59
|
}
|
|
60
|
+
handleClickOutside(event) {
|
|
61
|
+
if (event.composedPath()[0] === this.tooltipIconReference)
|
|
62
|
+
return;
|
|
63
|
+
if (event.composedPath()[0] !== this.tooltipReference)
|
|
64
|
+
this.showTooltip = false;
|
|
65
|
+
}
|
|
35
66
|
connectedCallback() {
|
|
36
|
-
this.displayedOptions = this.options
|
|
67
|
+
this.displayedOptions = this.options.map(option => ({
|
|
68
|
+
label: option.label,
|
|
69
|
+
value: option.value.toUpperCase()
|
|
70
|
+
}));
|
|
37
71
|
}
|
|
38
72
|
componentWillLoad() {
|
|
39
73
|
if (this.action && !this.options.length) {
|
|
40
74
|
if (this.action.split(" ")[0] == 'GET') {
|
|
41
|
-
|
|
42
|
-
|
|
75
|
+
const endpoint = this.action.split(" ")[1];
|
|
76
|
+
return this.getOptions(endpoint).then((options) => {
|
|
77
|
+
const firstKey = Object.keys(options)[0];
|
|
78
|
+
this.displayedOptions = options[firstKey].map(option => {
|
|
43
79
|
return { label: option.Name, value: option.Alpha2Code };
|
|
44
80
|
});
|
|
45
81
|
});
|
|
46
82
|
}
|
|
47
83
|
}
|
|
48
84
|
}
|
|
49
|
-
|
|
50
|
-
//
|
|
51
|
-
|
|
85
|
+
componentDidRender() {
|
|
86
|
+
// start custom styling area
|
|
87
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
88
|
+
if (this.clientStyling)
|
|
89
|
+
this.setClientStyling();
|
|
90
|
+
this.limitStylingAppends = true;
|
|
91
|
+
}
|
|
92
|
+
// end custom styling area
|
|
93
|
+
}
|
|
94
|
+
componentDidLoad() {
|
|
95
|
+
this.inputReference = this.element.shadowRoot.querySelector('input');
|
|
96
|
+
this.isValid = this.setValidity();
|
|
97
|
+
if (this.defaultValue) {
|
|
98
|
+
this.value = this.defaultValue.toUpperCase();
|
|
99
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
getOptions(endpoint) {
|
|
103
|
+
const url = new URL(endpoint);
|
|
52
104
|
return new Promise((resolve, reject) => {
|
|
53
105
|
fetch(url.href)
|
|
54
106
|
.then((res) => res.json())
|
|
@@ -60,14 +112,6 @@ const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
60
112
|
});
|
|
61
113
|
});
|
|
62
114
|
}
|
|
63
|
-
handleChange(event) {
|
|
64
|
-
this.value = event.target.value;
|
|
65
|
-
this.errorMessage = this.setErrorMessage();
|
|
66
|
-
this.isValid = this.setValidity();
|
|
67
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
68
|
-
this.emitValueHandler(true);
|
|
69
|
-
this.inputReference.previousElementSibling.classList.remove('select__label--hidden');
|
|
70
|
-
}
|
|
71
115
|
setValidity() {
|
|
72
116
|
return this.inputReference.validity.valid;
|
|
73
117
|
}
|
|
@@ -76,28 +120,44 @@ const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
76
120
|
return translate('requiredError', this.language);
|
|
77
121
|
}
|
|
78
122
|
}
|
|
123
|
+
renderTooltip() {
|
|
124
|
+
if (this.showTooltip) {
|
|
125
|
+
return (h("div", { class: `select__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
79
129
|
render() {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
130
|
+
let invalidClass = '';
|
|
131
|
+
if (this.touched) {
|
|
132
|
+
invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
|
|
133
|
+
}
|
|
134
|
+
return h("div", { class: `select__wrapper ${this.autofilled ? 'select__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { class: 'select__wrapper--flex' }, h("label", { class: 'select__label', htmlFor: `${this.name}__input` }, `${this.displayName} ${this.validation.mandatory ? '*' : ''}`), h("div", { class: 'select__wrapper--relative' }, this.tooltip &&
|
|
135
|
+
h("img", { class: 'select__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("vaadin-combo-box", { name: this.name, id: `${this.name}__input`, class: `select__input ${invalidClass} ${this.autofilled ? 'select__input--autofilled' : ''}`, "item-label-path": "label", "item-value-path": "value", readOnly: this.autofilled, required: this.validation.mandatory, value: this.defaultValue, placeholder: `${this.placeholder}`, items: this.displayedOptions, onChange: this.handleChange }), h("small", { class: 'select__error-message' }, this.errorMessage));
|
|
84
136
|
}
|
|
137
|
+
get element() { return this; }
|
|
85
138
|
static get watchers() { return {
|
|
86
139
|
"isValid": ["validityChanged"],
|
|
87
140
|
"emitValue": ["emitValueHandler"]
|
|
88
141
|
}; }
|
|
89
142
|
static get style() { return selectInputCss; }
|
|
90
143
|
}, [1, "select-input", {
|
|
91
|
-
"name": [
|
|
92
|
-
"displayName": [
|
|
93
|
-
"
|
|
144
|
+
"name": [513],
|
|
145
|
+
"displayName": [513, "display-name"],
|
|
146
|
+
"placeholder": [513],
|
|
147
|
+
"action": [513],
|
|
148
|
+
"defaultValue": [513, "default-value"],
|
|
149
|
+
"autofilled": [516],
|
|
150
|
+
"tooltip": [513],
|
|
94
151
|
"options": [16],
|
|
95
152
|
"validation": [16],
|
|
96
|
-
"language": [
|
|
97
|
-
"emitValue": [
|
|
153
|
+
"language": [513],
|
|
154
|
+
"emitValue": [516, "emit-value"],
|
|
155
|
+
"clientStyling": [513, "client-styling"],
|
|
98
156
|
"errorMessage": [32],
|
|
99
|
-
"isValid": [32]
|
|
100
|
-
|
|
157
|
+
"isValid": [32],
|
|
158
|
+
"limitStylingAppends": [32],
|
|
159
|
+
"showTooltip": [32]
|
|
160
|
+
}, [[4, "click", "handleClickOutside"]]]);
|
|
101
161
|
function defineCustomElement() {
|
|
102
162
|
if (typeof customElements === "undefined") {
|
|
103
163
|
return;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { t as translate } from './
|
|
2
|
+
import { t as translate, a as tooltipIconSvg } from './tooltipIcon.js';
|
|
3
|
+
import './input-field-shared-styles.js';
|
|
4
|
+
import './vaadin-combo-box.js';
|
|
3
5
|
|
|
4
|
-
const telInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.tel__wrapper{position:relative;
|
|
6
|
+
const telInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.tel{font-family:\"Roboto\";font-style:normal}.tel__wrapper{position:relative;width:100%}.tel__wrapper--autofilled{pointer-events:none}.tel__wrapper--autofilled .tel__label{color:#979797}.tel__wrapper--autofilled .tel__input::part(input-field){color:#979797}.tel__wrapper--flex{width:inherit;display:flex;align-items:stretch;border-radius:4px;border:2px solid #DEE1EE}.tel__wrapper--flex:focus-within{border:2px solid #3E3E3E}.tel__wrapper--flex--invalid{border:2px solid #cc0000b3}.tel__wrapper--flex-label{display:flex;gap:5px}.tel__wrapper--flex--relative{position:relative}.tel__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#2A3841}.tel__label--required::after{content:\"*\";font-family:inherit;color:#2A3841;margin-left:2px}.tel__prefix{width:120px}.tel__prefix[focus]{outline:none}.tel__prefix::part(input-field){border-radius:0 4px 4px 0;background-color:#DEE1EE;color:#1F1F1F;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px}.tel__input{border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px;color:#2A2E3F;border:none;padding:10px 20px;width:inherit;position:relative;-moz-appearance:textfield;}.tel__input:focus{outline:none}.tel__input::-webkit-outer-spin-button,.tel__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.tel__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}.tel__tooltip-icon{width:16px;height:auto}.tel__tooltip{position:absolute;top:0;left:20px;background-color:#FFFFFF;border:1px solid #B0B0B0;color:#2B2D3F;padding:10px;border-radius:5px;opacity:0;transition:opacity 0.3s ease-in-out;z-index:10}.tel__tooltip.visible{opacity:1}";
|
|
5
7
|
|
|
6
8
|
const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
9
|
constructor() {
|
|
@@ -10,12 +12,42 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
10
12
|
this.__attachShadow();
|
|
11
13
|
this.sendValidityState = createEvent(this, "sendValidityState", 7);
|
|
12
14
|
this.sendInputValue = createEvent(this, "sendInputValue", 7);
|
|
15
|
+
/**
|
|
16
|
+
* Client custom styling via inline style
|
|
17
|
+
*/
|
|
18
|
+
this.clientStyling = '';
|
|
19
|
+
this.limitStylingAppends = false;
|
|
20
|
+
this.showTooltip = false;
|
|
13
21
|
this.validationPattern = '';
|
|
22
|
+
this.touched = false;
|
|
23
|
+
this.handleInput = (event) => {
|
|
24
|
+
this.phoneValue = event.target.value;
|
|
25
|
+
this.value = { prefix: this.prefixValue, phone: this.phoneValue };
|
|
26
|
+
this.touched = true;
|
|
27
|
+
if (this.debounceTime) {
|
|
28
|
+
clearTimeout(this.debounceTime);
|
|
29
|
+
}
|
|
30
|
+
this.debounceTime = setTimeout(() => {
|
|
31
|
+
this.isValid = this.setValidity();
|
|
32
|
+
this.errorMessage = this.setErrorMessage();
|
|
33
|
+
this.emitValueHandler(true);
|
|
34
|
+
}, 500);
|
|
35
|
+
};
|
|
36
|
+
this.handleBlur = () => {
|
|
37
|
+
this.isValid = this.setValidity();
|
|
38
|
+
this.touched = true;
|
|
39
|
+
this.errorMessage = this.setErrorMessage();
|
|
40
|
+
};
|
|
41
|
+
this.setClientStyling = () => {
|
|
42
|
+
let sheet = document.createElement('style');
|
|
43
|
+
sheet.innerHTML = this.clientStyling;
|
|
44
|
+
this.stylingContainer.prepend(sheet);
|
|
45
|
+
};
|
|
14
46
|
}
|
|
15
47
|
validityChanged() {
|
|
16
48
|
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
17
49
|
if (this.emitValue == true) {
|
|
18
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
50
|
+
this.valueHandler({ name: this.name, value: this.value, type: 'tel' });
|
|
19
51
|
}
|
|
20
52
|
}
|
|
21
53
|
validityStateHandler(inputStateEvent) {
|
|
@@ -23,34 +55,86 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
23
55
|
}
|
|
24
56
|
emitValueHandler(newValue) {
|
|
25
57
|
if (newValue == true && this.isValid) {
|
|
26
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
58
|
+
this.valueHandler({ name: this.name, value: this.value, type: 'tel' });
|
|
27
59
|
}
|
|
28
60
|
}
|
|
29
61
|
valueHandler(inputValueEvent) {
|
|
30
62
|
this.sendInputValue.emit(inputValueEvent);
|
|
31
63
|
}
|
|
64
|
+
handleClickOutside(event) {
|
|
65
|
+
if (event.composedPath()[0] === this.tooltipIconReference)
|
|
66
|
+
return;
|
|
67
|
+
if (event.composedPath()[0] !== this.tooltipReference)
|
|
68
|
+
this.showTooltip = false;
|
|
69
|
+
}
|
|
32
70
|
connectedCallback() {
|
|
33
71
|
this.validationPattern = this.setPattern();
|
|
72
|
+
if (this.defaultValue) {
|
|
73
|
+
this.prefixValue = this.defaultValue.prefix ? this.defaultValue.prefix : this.defaultValue;
|
|
74
|
+
this.phoneValue = this.defaultValue.phone || null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
componentWillLoad() {
|
|
78
|
+
if (this.action) {
|
|
79
|
+
if (this.action.split(" ")[0] == 'GET') {
|
|
80
|
+
const endpoint = this.action.split(" ")[1];
|
|
81
|
+
return this.getPhoneCodes(endpoint).then((options) => {
|
|
82
|
+
this.phoneCodesOptions = options.phoneCodes.map(code => {
|
|
83
|
+
return { label: code.Prefix, value: code.Prefix };
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
componentDidRender() {
|
|
90
|
+
// start custom styling area
|
|
91
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
92
|
+
if (this.clientStyling)
|
|
93
|
+
this.setClientStyling();
|
|
94
|
+
this.limitStylingAppends = true;
|
|
95
|
+
}
|
|
96
|
+
// end custom styling area
|
|
34
97
|
}
|
|
35
|
-
|
|
36
|
-
this.value = event.target.value;
|
|
37
|
-
this.errorMessage = this.setErrorMessage();
|
|
98
|
+
componentDidLoad() {
|
|
38
99
|
this.isValid = this.setValidity();
|
|
39
|
-
|
|
100
|
+
if (this.defaultValue) {
|
|
101
|
+
this.value = this.defaultValue;
|
|
102
|
+
this.valueHandler({ name: this.name, value: this.value, type: 'tel' });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
getPhoneCodes(endpoint) {
|
|
106
|
+
const url = new URL(endpoint);
|
|
107
|
+
return new Promise((resolve, reject) => {
|
|
108
|
+
fetch(url.href)
|
|
109
|
+
.then((res) => res.json())
|
|
110
|
+
.then((options) => {
|
|
111
|
+
resolve(options);
|
|
112
|
+
}).catch((err) => {
|
|
113
|
+
console.error(err);
|
|
114
|
+
reject(err);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
handlePrefixInput(event) {
|
|
119
|
+
this.prefixValue = event.target.value;
|
|
120
|
+
this.value = { prefix: this.prefixValue, phone: this.phoneValue };
|
|
40
121
|
this.emitValueHandler(true);
|
|
41
122
|
}
|
|
42
123
|
setValidity() {
|
|
43
124
|
return this.inputReference.validity.valid;
|
|
44
125
|
}
|
|
45
126
|
setPattern() {
|
|
46
|
-
var _a;
|
|
127
|
+
var _a, _b;
|
|
47
128
|
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
48
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
|
|
129
|
+
return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
|
|
49
130
|
}
|
|
50
131
|
}
|
|
51
132
|
setErrorMessage() {
|
|
133
|
+
var _a, _b;
|
|
52
134
|
if (this.inputReference.validity.patternMismatch) {
|
|
53
|
-
|
|
135
|
+
const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
|
|
136
|
+
const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
|
|
137
|
+
return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
|
|
54
138
|
}
|
|
55
139
|
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
56
140
|
return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
@@ -59,9 +143,19 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
59
143
|
return translate('requiredError', this.language);
|
|
60
144
|
}
|
|
61
145
|
}
|
|
146
|
+
renderTooltip() {
|
|
147
|
+
if (this.showTooltip) {
|
|
148
|
+
return (h("div", { class: `tel__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
62
152
|
render() {
|
|
63
|
-
|
|
64
|
-
|
|
153
|
+
let invalidClass = '';
|
|
154
|
+
if (this.touched) {
|
|
155
|
+
invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
|
|
156
|
+
}
|
|
157
|
+
return h("div", { class: `tel__wrapper ${this.autofilled ? 'tel__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { class: 'tel__wrapper--flex-label' }, h("label", { class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { class: 'tel__wrapper--relative' }, this.tooltip &&
|
|
158
|
+
h("img", { class: 'tel__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("div", { class: `tel__wrapper--flex ${invalidClass}` }, h("vaadin-combo-box", { class: 'tel__prefix', items: this.phoneCodesOptions, value: this.prefixValue, readOnly: this.autofilled, onChange: (e) => this.handlePrefixInput(e) }), h("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input`, value: this.phoneValue, placeholder: `${this.placeholder}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onInput: this.handleInput, onBlur: this.handleBlur })), h("small", { class: 'tel__error-message' }, this.errorMessage));
|
|
65
159
|
}
|
|
66
160
|
static get watchers() { return {
|
|
67
161
|
"isValid": ["validityChanged"],
|
|
@@ -69,17 +163,23 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
69
163
|
}; }
|
|
70
164
|
static get style() { return telInputCss; }
|
|
71
165
|
}, [1, "tel-input", {
|
|
72
|
-
"name": [
|
|
73
|
-
"displayName": [
|
|
74
|
-
"
|
|
75
|
-
"
|
|
166
|
+
"name": [513],
|
|
167
|
+
"displayName": [513, "display-name"],
|
|
168
|
+
"placeholder": [513],
|
|
169
|
+
"showLabels": [516, "show-labels"],
|
|
170
|
+
"action": [513],
|
|
76
171
|
"validation": [16],
|
|
77
|
-
"defaultValue": [
|
|
78
|
-
"
|
|
79
|
-
"
|
|
172
|
+
"defaultValue": [520, "default-value"],
|
|
173
|
+
"autofilled": [516],
|
|
174
|
+
"tooltip": [513],
|
|
175
|
+
"language": [513],
|
|
176
|
+
"emitValue": [516, "emit-value"],
|
|
177
|
+
"clientStyling": [513, "client-styling"],
|
|
80
178
|
"isValid": [32],
|
|
81
|
-
"errorMessage": [32]
|
|
82
|
-
|
|
179
|
+
"errorMessage": [32],
|
|
180
|
+
"limitStylingAppends": [32],
|
|
181
|
+
"showTooltip": [32]
|
|
182
|
+
}, [[4, "click", "handleClickOutside"]]]);
|
|
83
183
|
function defineCustomElement() {
|
|
84
184
|
if (typeof customElements === "undefined") {
|
|
85
185
|
return;
|