@everymatrix/general-input 0.0.1 → 1.0.69
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/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/checkbox-group-input_10.cjs.entry.js +20007 -16663
- package/dist/cjs/general-input.cjs.entry.js +67 -40
- package/dist/cjs/general-input.cjs.js +17 -11
- package/dist/cjs/index-8cb018cb.js +1316 -0
- package/dist/cjs/index.cjs.js +16 -0
- package/dist/cjs/loader.cjs.js +7 -13
- package/dist/cjs/locale.utils-7a3dfe2f.js +128 -0
- package/dist/cjs/toggle-checkbox-input.cjs.entry.js +91 -0
- package/dist/cjs/tooltipIcon-7e9ee226.js +5 -0
- package/dist/collection/collection-manifest.json +14 -13
- package/dist/collection/components/checkbox-group-input/checkbox-group-input.css +26 -6
- package/dist/collection/components/checkbox-group-input/checkbox-group-input.js +372 -335
- package/dist/collection/components/checkbox-input/checkbox-input.css +16 -10
- package/dist/collection/components/checkbox-input/checkbox-input.js +325 -310
- package/dist/collection/components/date-input/date-input.css +35 -19
- package/dist/collection/components/date-input/date-input.js +401 -328
- package/dist/collection/components/email-input/email-input.css +30 -18
- package/dist/collection/components/email-input/email-input.js +405 -365
- package/dist/collection/components/general-input/general-input.css +1 -0
- package/dist/collection/components/general-input/general-input.js +374 -291
- package/dist/collection/components/general-input/index.js +1 -0
- package/dist/collection/components/number-input/number-input.css +28 -16
- package/dist/collection/components/number-input/number-input.js +371 -334
- package/dist/collection/components/password-input/password-input.css +105 -11
- package/dist/collection/components/password-input/password-input.js +518 -378
- package/dist/collection/components/radio-input/radio-input.css +4 -4
- package/dist/collection/components/radio-input/radio-input.js +301 -287
- package/dist/collection/components/select-input/select-input.css +47 -19
- package/dist/collection/components/select-input/select-input.js +428 -398
- package/dist/collection/components/tel-input/tel-input.css +52 -23
- package/dist/collection/components/tel-input/tel-input.js +441 -404
- package/dist/collection/components/text-input/text-input.css +33 -18
- package/dist/collection/components/text-input/text-input.js +446 -389
- package/dist/collection/components/toggle-checkbox-input/toggle-checkbox-input.css +82 -0
- package/dist/collection/components/toggle-checkbox-input/toggle-checkbox-input.js +336 -0
- package/dist/collection/index.js +16 -0
- package/dist/collection/utils/locale.utils.js +118 -21
- package/dist/collection/utils/tooltipIcon.svg +4 -4
- package/dist/collection/utils/utils.js +3 -3
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/checkbox-group-input_10.entry.js +20007 -16663
- package/dist/esm/general-input.entry.js +67 -40
- package/dist/esm/general-input.js +14 -11
- package/dist/esm/index-514fda47.js +1287 -0
- package/dist/esm/index.js +16 -1
- package/dist/esm/loader.js +7 -13
- package/dist/esm/locale.utils-21605050.js +125 -0
- package/dist/esm/toggle-checkbox-input.entry.js +87 -0
- package/dist/esm/tooltipIcon-0a5a06a2.js +3 -0
- package/dist/general-input/general-input.esm.js +1 -1
- package/dist/general-input/index.esm.js +1 -0
- package/dist/general-input/p-03e81c11.js +2 -0
- package/dist/general-input/p-2dccd0bf.js +1 -0
- package/dist/general-input/p-34939f14.entry.js +1 -0
- package/dist/general-input/p-b32f19c2.entry.js +5430 -0
- package/dist/general-input/p-c43bb82e.entry.js +1 -0
- package/dist/general-input/p-cfe9eb31.js +1 -0
- package/dist/general-input/p-e1255160.js +1 -0
- package/dist/stencil.config.dev.js +17 -0
- package/dist/stencil.config.js +14 -19
- package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/general-input/.stencil/packages/stencil/general-input/stencil.config.d.ts +2 -0
- package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/general-input/.stencil/packages/stencil/general-input/stencil.config.dev.d.ts +2 -0
- package/dist/types/components/checkbox-group-input/checkbox-group-input.d.ts +69 -67
- package/dist/types/components/checkbox-input/checkbox-input.d.ts +61 -60
- package/dist/types/components/date-input/date-input.d.ts +79 -65
- package/dist/types/components/email-input/email-input.d.ts +76 -73
- package/dist/types/components/general-input/general-input.d.ts +72 -57
- package/dist/types/components/general-input/index.d.ts +1 -0
- package/dist/types/components/number-input/number-input.d.ts +70 -66
- package/dist/types/components/password-input/password-input.d.ts +87 -75
- package/dist/types/components/radio-input/radio-input.d.ts +55 -55
- package/dist/types/components/select-input/select-input.d.ts +78 -77
- package/dist/types/components/tel-input/tel-input.d.ts +84 -80
- package/dist/types/components/text-input/text-input.d.ts +81 -78
- package/dist/types/components/toggle-checkbox-input/toggle-checkbox-input.d.ts +67 -0
- package/dist/types/components.d.ts +331 -25
- package/dist/types/stencil-public-runtime.d.ts +142 -33
- package/dist/types/utils/locale.utils.d.ts +13 -1
- package/dist/types/utils/types.d.ts +58 -47
- package/loader/cdn.js +1 -3
- package/loader/index.cjs.js +1 -3
- package/loader/index.d.ts +13 -1
- package/loader/index.es2017.js +1 -3
- package/loader/index.js +1 -3
- package/loader/package.json +1 -0
- package/package.json +9 -9
- package/dist/cjs/index-1768513d.js +0 -1286
- package/dist/components/active-mixin.js +0 -975
- package/dist/components/checkbox-group-input.d.ts +0 -11
- package/dist/components/checkbox-group-input.js +0 -6
- package/dist/components/checkbox-group-input2.js +0 -5793
- package/dist/components/checkbox-input.d.ts +0 -11
- package/dist/components/checkbox-input.js +0 -6
- package/dist/components/checkbox-input2.js +0 -127
- package/dist/components/date-input.d.ts +0 -11
- package/dist/components/date-input.js +0 -6
- package/dist/components/date-input2.js +0 -5182
- package/dist/components/email-input.d.ts +0 -11
- package/dist/components/email-input.js +0 -6
- package/dist/components/email-input2.js +0 -150
- package/dist/components/field-mixin.js +0 -12712
- package/dist/components/general-input.d.ts +0 -11
- package/dist/components/general-input.js +0 -140
- package/dist/components/index.d.ts +0 -26
- package/dist/components/index.js +0 -1
- package/dist/components/input-field-shared-styles.js +0 -1067
- package/dist/components/number-input.d.ts +0 -11
- package/dist/components/number-input.js +0 -6
- package/dist/components/number-input2.js +0 -139
- package/dist/components/password-input.d.ts +0 -11
- package/dist/components/password-input.js +0 -6
- package/dist/components/password-input2.js +0 -879
- package/dist/components/pattern-mixin.js +0 -85
- package/dist/components/radio-input.d.ts +0 -11
- package/dist/components/radio-input.js +0 -6
- package/dist/components/radio-input2.js +0 -115
- package/dist/components/select-input.d.ts +0 -11
- package/dist/components/select-input.js +0 -6
- package/dist/components/select-input2.js +0 -166
- package/dist/components/tel-input.d.ts +0 -11
- package/dist/components/tel-input.js +0 -6
- package/dist/components/tel-input2.js +0 -178
- package/dist/components/text-input.d.ts +0 -11
- package/dist/components/text-input.js +0 -6
- package/dist/components/text-input2.js +0 -157
- package/dist/components/tooltipIcon.js +0 -30
- package/dist/components/vaadin-button.js +0 -461
- package/dist/components/vaadin-combo-box.js +0 -4329
- package/dist/components/virtual-keyboard-controller.js +0 -2693
- package/dist/esm/index-7e24a6f1.js +0 -1259
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/general-input/p-61d76ec3.entry.js +0 -1
- package/dist/general-input/p-a79eb0a3.entry.js +0 -4413
- package/dist/general-input/p-fb647820.js +0 -1
- package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +0 -2
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { t as translate, a as tooltipIconSvg } from './tooltipIcon.js';
|
|
3
|
-
|
|
4
|
-
const textInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.text{font-family:\"Roboto\";font-style:normal}.text__wrapper{position:relative;width:100%}.text__wrapper--flex{display:flex;gap:5px}.text__wrapper--relative{position:relative}.text__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F}.text__label--required::after{content:\"*\";font-family:inherit;color:#1F1F1F;margin-left:2px}.text__input{border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px;color:#2A2E3F;padding:8px 20px;width:inherit;position:relative;border:2px solid #DEE1EE}.text__input:focus{outline-color:#3E3E3E}.text__input--invalid{border:2px solid #cc0000b3}.text__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}.text__tooltip-icon{width:16px;height:auto}.text__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}.text__tooltip.visible{opacity:1}";
|
|
5
|
-
|
|
6
|
-
const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
this.__registerHost();
|
|
10
|
-
this.__attachShadow();
|
|
11
|
-
this.sendValidityState = createEvent(this, "sendValidityState", 7);
|
|
12
|
-
this.sendInputValue = createEvent(this, "sendInputValue", 7);
|
|
13
|
-
/**
|
|
14
|
-
* Default value for the input.
|
|
15
|
-
*/
|
|
16
|
-
this.defaultValue = '';
|
|
17
|
-
/**
|
|
18
|
-
* Client custom styling via inline style
|
|
19
|
-
*/
|
|
20
|
-
this.clientStyling = '';
|
|
21
|
-
this.errorMessage = '';
|
|
22
|
-
this.limitStylingAppends = false;
|
|
23
|
-
this.showTooltip = false;
|
|
24
|
-
this.value = '';
|
|
25
|
-
this.customRules = [];
|
|
26
|
-
this.validationPattern = '';
|
|
27
|
-
this.setClientStyling = () => {
|
|
28
|
-
let sheet = document.createElement('style');
|
|
29
|
-
sheet.innerHTML = this.clientStyling;
|
|
30
|
-
this.stylingContainer.prepend(sheet);
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
validityChanged() {
|
|
34
|
-
if (this.emitValue == true) {
|
|
35
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
emitValueHandler(newValue) {
|
|
39
|
-
if (newValue == true && this.isValid) {
|
|
40
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
validityStateHandler(inputStateEvent) {
|
|
44
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
45
|
-
}
|
|
46
|
-
valueHandler(inputValueEvent) {
|
|
47
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
48
|
-
}
|
|
49
|
-
handleClickOutside(event) {
|
|
50
|
-
if (event.composedPath()[0] === this.tooltipIconReference)
|
|
51
|
-
return;
|
|
52
|
-
if (event.composedPath()[0] !== this.tooltipReference)
|
|
53
|
-
this.showTooltip = false;
|
|
54
|
-
}
|
|
55
|
-
valueChangedHandler(event) {
|
|
56
|
-
if (this.isDuplicateInput) {
|
|
57
|
-
if (this.name === event.detail.name + 'Duplicate') {
|
|
58
|
-
this.duplicateInputValue = event.detail.value;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
connectedCallback() {
|
|
63
|
-
this.validationPattern = this.setPattern();
|
|
64
|
-
}
|
|
65
|
-
componentDidRender() {
|
|
66
|
-
// start custom styling area
|
|
67
|
-
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
68
|
-
if (this.clientStyling)
|
|
69
|
-
this.setClientStyling();
|
|
70
|
-
this.limitStylingAppends = true;
|
|
71
|
-
}
|
|
72
|
-
// end custom styling area
|
|
73
|
-
if (this.defaultValue) {
|
|
74
|
-
this.value = this.defaultValue;
|
|
75
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
handleInput(event) {
|
|
79
|
-
this.value = event.target.value;
|
|
80
|
-
this.isValid = this.setValidity();
|
|
81
|
-
this.errorMessage = this.setErrorMessage();
|
|
82
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
83
|
-
this.emitValueHandler(true);
|
|
84
|
-
}
|
|
85
|
-
setValidity() {
|
|
86
|
-
return this.inputReference.validity.valid;
|
|
87
|
-
}
|
|
88
|
-
setPattern() {
|
|
89
|
-
var _a, _b;
|
|
90
|
-
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
91
|
-
return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
setErrorMessage() {
|
|
95
|
-
var _a;
|
|
96
|
-
if (this.inputReference.validity.patternMismatch) {
|
|
97
|
-
return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
|
|
98
|
-
}
|
|
99
|
-
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
100
|
-
return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
101
|
-
}
|
|
102
|
-
if (this.inputReference.validity.valueMissing) {
|
|
103
|
-
return translate('requiredError', this.language);
|
|
104
|
-
}
|
|
105
|
-
if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
|
|
106
|
-
return this.validation.custom.find(customRule => customRule.rule === 'duplicate-input').errorMessage;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
renderTooltip() {
|
|
110
|
-
if (this.showTooltip) {
|
|
111
|
-
return (h("div", { class: `text__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
|
|
112
|
-
}
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
render() {
|
|
116
|
-
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
|
|
117
|
-
return h("div", { class: 'text__wrapper', ref: el => this.stylingContainer = el }, h("div", { class: 'text__wrapper--flex' }, h("label", { class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { class: 'text__wrapper--relative' }, this.tooltip &&
|
|
118
|
-
h("img", { class: 'text__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("input", { name: this.name, id: `${this.name}__input`, value: this.defaultValue, type: 'text', class: `text__input ${invalidClass}`, placeholder: `${this.placeholder} ${this.placeholder && this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, readOnly: this.autofilled, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onBlur: (e) => { this.handleInput(e); } }), h("small", { class: 'text__error-message' }, this.errorMessage));
|
|
119
|
-
}
|
|
120
|
-
static get watchers() { return {
|
|
121
|
-
"isValid": ["validityChanged"],
|
|
122
|
-
"emitValue": ["emitValueHandler"]
|
|
123
|
-
}; }
|
|
124
|
-
static get style() { return textInputCss; }
|
|
125
|
-
}, [1, "text-input", {
|
|
126
|
-
"name": [513],
|
|
127
|
-
"displayName": [513, "display-name"],
|
|
128
|
-
"placeholder": [513],
|
|
129
|
-
"validation": [16],
|
|
130
|
-
"defaultValue": [513, "default-value"],
|
|
131
|
-
"autofilled": [516],
|
|
132
|
-
"tooltip": [513],
|
|
133
|
-
"language": [513],
|
|
134
|
-
"checkValidity": [516, "check-validity"],
|
|
135
|
-
"emitValue": [516, "emit-value"],
|
|
136
|
-
"isDuplicateInput": [516, "is-duplicate-input"],
|
|
137
|
-
"clientStyling": [513, "client-styling"],
|
|
138
|
-
"isValid": [32],
|
|
139
|
-
"errorMessage": [32],
|
|
140
|
-
"limitStylingAppends": [32],
|
|
141
|
-
"showTooltip": [32]
|
|
142
|
-
}, [[4, "click", "handleClickOutside"], [16, "sendInputValue", "valueChangedHandler"]]]);
|
|
143
|
-
function defineCustomElement() {
|
|
144
|
-
if (typeof customElements === "undefined") {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const components = ["text-input"];
|
|
148
|
-
components.forEach(tagName => { switch (tagName) {
|
|
149
|
-
case "text-input":
|
|
150
|
-
if (!customElements.get(tagName)) {
|
|
151
|
-
customElements.define(tagName, TextInput);
|
|
152
|
-
}
|
|
153
|
-
break;
|
|
154
|
-
} });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export { TextInput as T, defineCustomElement as d };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
-
const TRANSLATIONS = {
|
|
3
|
-
"en": {
|
|
4
|
-
"dateError": 'The selected date should be between {min} and {max}',
|
|
5
|
-
"numberLengthError": 'The number should be between {min} and {max}',
|
|
6
|
-
"lengthError": `The length should be between {minLength} and {maxLength}`,
|
|
7
|
-
"requiredError": 'This input is required.',
|
|
8
|
-
},
|
|
9
|
-
"hu": {
|
|
10
|
-
"dateError": 'A választott dátumnak {min} és {max} között kell lennie',
|
|
11
|
-
"numberLengthError": 'A számnak {min} és {max} között kell lennie',
|
|
12
|
-
"lengthError": `A hossznak {minLength} és {maxLength} között kell lennie`,
|
|
13
|
-
"requiredError": 'Ez a beviteli mező kötelező.',
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const translate = (key, customLang, values) => {
|
|
17
|
-
const lang = customLang;
|
|
18
|
-
let translation = TRANSLATIONS[lang !== undefined ? lang : DEFAULT_LANGUAGE][key];
|
|
19
|
-
if (values !== undefined) {
|
|
20
|
-
for (const [key, value] of Object.entries(values.values)) {
|
|
21
|
-
const regex = new RegExp(`{${key}}`, 'g');
|
|
22
|
-
translation = translation.replace(regex, value);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return translation;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const tooltipIconSvg = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMiAyMSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3QgeD0iMTEuOTA5OSIgeT0iMTYuMTUiIHdpZHRoPSIxLjgyIiBoZWlnaHQ9IjcuNjAwMDEiIHRyYW5zZm9ybT0icm90YXRlKC0xODAgMTEuOTA5OSAxNi4xNSkiIGZpbGw9IiMyQjJEM0YiLz4KPHJlY3QgeD0iMTEuOTA5OSIgeT0iNi42NTAwMiIgd2lkdGg9IjEuODIiIGhlaWdodD0iMS45MDAwMSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE4MCAxMS45MDk5IDYuNjUwMDIpIiBmaWxsPSIjMkIyRDNGIi8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMC45ODk5OSAxMC40NUMwLjk4OTk5IDQuNjc3NjggNS40NzE5NyAwIDExIDBDMTYuNTI4IDAgMjEuMDEgNC42Nzc2OCAyMS4wMSAxMC40NUMyMS4wMSAxNi4yMjEgMTYuNTI4IDIwLjkgMTEgMjAuOUM1LjQ3MTk3IDIwLjkgMC45ODk5OSAxNi4yMjEgMC45ODk5OSAxMC40NVpNMi44MDk5OSAxMC40NTA2QzIuODA5OTkgMTUuMTcyMyA2LjQ3Njc3IDE5IDExIDE5QzE1LjUyMiAxOSAxOS4xOSAxNS4xNzIzIDE5LjE5IDEwLjQ1MDZDMTkuMTkgNS43Mjg5MSAxNS41MjIgMS45MDAwMSAxMSAxLjkwMDAxQzYuNDc2NzcgMS45MDAwMSAyLjgwOTk5IDUuNzI4OTEgMi44MDk5OSAxMC40NTA2WiIgZmlsbD0iIzJCMkQzRiIvPgo8L3N2Zz4K';
|
|
29
|
-
|
|
30
|
-
export { tooltipIconSvg as a, translate as t };
|
|
@@ -1,461 +0,0 @@
|
|
|
1
|
-
import { i, r as registerStyles, Q as TabindexMixin, m as FocusMixin, E as ElementMixin, T as ThemableMixin, C as ControllerMixin, P as PolymerElement, h as html, g as TooltipController } from './field-mixin.js';
|
|
2
|
-
import { A as ActiveMixin } from './active-mixin.js';
|
|
3
|
-
|
|
4
|
-
const button = i`
|
|
5
|
-
:host {
|
|
6
|
-
/* Sizing */
|
|
7
|
-
--lumo-button-size: var(--lumo-size-m);
|
|
8
|
-
min-width: calc(var(--lumo-button-size) * 2);
|
|
9
|
-
height: var(--lumo-button-size);
|
|
10
|
-
padding: 0 calc(var(--lumo-button-size) / 3 + var(--lumo-border-radius-m) / 2);
|
|
11
|
-
margin: var(--lumo-space-xs) 0;
|
|
12
|
-
box-sizing: border-box;
|
|
13
|
-
/* Style */
|
|
14
|
-
font-family: var(--lumo-font-family);
|
|
15
|
-
font-size: var(--lumo-font-size-m);
|
|
16
|
-
font-weight: 500;
|
|
17
|
-
color: var(--_lumo-button-color, var(--lumo-primary-text-color));
|
|
18
|
-
background-color: var(--_lumo-button-background-color, var(--lumo-contrast-5pct));
|
|
19
|
-
border-radius: var(--lumo-border-radius-m);
|
|
20
|
-
cursor: var(--lumo-clickable-cursor);
|
|
21
|
-
-webkit-tap-highlight-color: transparent;
|
|
22
|
-
-webkit-font-smoothing: antialiased;
|
|
23
|
-
-moz-osx-font-smoothing: grayscale;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/* Set only for the internal parts so we don't affect the host vertical alignment */
|
|
27
|
-
[part='label'],
|
|
28
|
-
[part='prefix'],
|
|
29
|
-
[part='suffix'] {
|
|
30
|
-
line-height: var(--lumo-line-height-xs);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
[part='label'] {
|
|
34
|
-
padding: calc(var(--lumo-button-size) / 6) 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
:host([theme~='small']) {
|
|
38
|
-
font-size: var(--lumo-font-size-s);
|
|
39
|
-
--lumo-button-size: var(--lumo-size-s);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
:host([theme~='large']) {
|
|
43
|
-
font-size: var(--lumo-font-size-l);
|
|
44
|
-
--lumo-button-size: var(--lumo-size-l);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/* For interaction states */
|
|
48
|
-
:host::before,
|
|
49
|
-
:host::after {
|
|
50
|
-
content: '';
|
|
51
|
-
/* We rely on the host always being relative */
|
|
52
|
-
position: absolute;
|
|
53
|
-
z-index: 1;
|
|
54
|
-
top: 0;
|
|
55
|
-
right: 0;
|
|
56
|
-
bottom: 0;
|
|
57
|
-
left: 0;
|
|
58
|
-
background-color: currentColor;
|
|
59
|
-
border-radius: inherit;
|
|
60
|
-
opacity: 0;
|
|
61
|
-
pointer-events: none;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/* Hover */
|
|
65
|
-
|
|
66
|
-
@media (any-hover: hover) {
|
|
67
|
-
:host(:hover)::before {
|
|
68
|
-
opacity: 0.02;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/* Active */
|
|
73
|
-
|
|
74
|
-
:host::after {
|
|
75
|
-
transition: opacity 1.4s, transform 0.1s;
|
|
76
|
-
filter: blur(8px);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
:host([active])::before {
|
|
80
|
-
opacity: 0.05;
|
|
81
|
-
transition-duration: 0s;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
:host([active])::after {
|
|
85
|
-
opacity: 0.1;
|
|
86
|
-
transition-duration: 0s, 0s;
|
|
87
|
-
transform: scale(0);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/* Keyboard focus */
|
|
91
|
-
|
|
92
|
-
:host([focus-ring]) {
|
|
93
|
-
box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
:host([theme~='primary'][focus-ring]) {
|
|
97
|
-
box-shadow: 0 0 0 1px var(--lumo-base-color), 0 0 0 3px var(--lumo-primary-color-50pct);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/* Types (primary, tertiary, tertiary-inline */
|
|
101
|
-
|
|
102
|
-
:host([theme~='tertiary']),
|
|
103
|
-
:host([theme~='tertiary-inline']) {
|
|
104
|
-
background-color: transparent !important;
|
|
105
|
-
min-width: 0;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
:host([theme~='tertiary']) {
|
|
109
|
-
padding: 0 calc(var(--lumo-button-size) / 6);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
:host([theme~='tertiary-inline'])::before {
|
|
113
|
-
display: none;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
:host([theme~='tertiary-inline']) {
|
|
117
|
-
margin: 0;
|
|
118
|
-
height: auto;
|
|
119
|
-
padding: 0;
|
|
120
|
-
line-height: inherit;
|
|
121
|
-
font-size: inherit;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
:host([theme~='tertiary-inline']) [part='label'] {
|
|
125
|
-
padding: 0;
|
|
126
|
-
overflow: visible;
|
|
127
|
-
line-height: inherit;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
:host([theme~='primary']) {
|
|
131
|
-
background-color: var(--_lumo-button-primary-background-color, var(--lumo-primary-color));
|
|
132
|
-
color: var(--_lumo-button-primary-color, var(--lumo-primary-contrast-color));
|
|
133
|
-
font-weight: 600;
|
|
134
|
-
min-width: calc(var(--lumo-button-size) * 2.5);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
:host([theme~='primary'])::before {
|
|
138
|
-
background-color: black;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
@media (any-hover: hover) {
|
|
142
|
-
:host([theme~='primary']:hover)::before {
|
|
143
|
-
opacity: 0.05;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
:host([theme~='primary'][active])::before {
|
|
148
|
-
opacity: 0.1;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
:host([theme~='primary'][active])::after {
|
|
152
|
-
opacity: 0.2;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/* Colors (success, error, contrast) */
|
|
156
|
-
|
|
157
|
-
:host([theme~='success']) {
|
|
158
|
-
color: var(--lumo-success-text-color);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
:host([theme~='success'][theme~='primary']) {
|
|
162
|
-
background-color: var(--lumo-success-color);
|
|
163
|
-
color: var(--lumo-success-contrast-color);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
:host([theme~='error']) {
|
|
167
|
-
color: var(--lumo-error-text-color);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
:host([theme~='error'][theme~='primary']) {
|
|
171
|
-
background-color: var(--lumo-error-color);
|
|
172
|
-
color: var(--lumo-error-contrast-color);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
:host([theme~='contrast']) {
|
|
176
|
-
color: var(--lumo-contrast);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
:host([theme~='contrast'][theme~='primary']) {
|
|
180
|
-
background-color: var(--lumo-contrast);
|
|
181
|
-
color: var(--lumo-base-color);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/* Disabled state. Keep selectors after other color variants. */
|
|
185
|
-
|
|
186
|
-
:host([disabled]) {
|
|
187
|
-
pointer-events: none;
|
|
188
|
-
color: var(--lumo-disabled-text-color);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
:host([theme~='primary'][disabled]) {
|
|
192
|
-
background-color: var(--lumo-contrast-30pct);
|
|
193
|
-
color: var(--lumo-base-color);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
:host([theme~='primary'][disabled]) [part] {
|
|
197
|
-
opacity: 0.7;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/* Icons */
|
|
201
|
-
|
|
202
|
-
[part] ::slotted(vaadin-icon),
|
|
203
|
-
[part] ::slotted(iron-icon) {
|
|
204
|
-
display: inline-block;
|
|
205
|
-
width: var(--lumo-icon-size-m);
|
|
206
|
-
height: var(--lumo-icon-size-m);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/* Vaadin icons are based on a 16x16 grid (unlike Lumo and Material icons with 24x24), so they look too big by default */
|
|
210
|
-
[part] ::slotted(vaadin-icon[icon^='vaadin:']),
|
|
211
|
-
[part] ::slotted(iron-icon[icon^='vaadin:']) {
|
|
212
|
-
padding: 0.25em;
|
|
213
|
-
box-sizing: border-box !important;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
[part='prefix'] {
|
|
217
|
-
margin-left: -0.25em;
|
|
218
|
-
margin-right: 0.25em;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
[part='suffix'] {
|
|
222
|
-
margin-left: 0.25em;
|
|
223
|
-
margin-right: -0.25em;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/* Icon-only */
|
|
227
|
-
|
|
228
|
-
:host([theme~='icon']:not([theme~='tertiary-inline'])) {
|
|
229
|
-
min-width: var(--lumo-button-size);
|
|
230
|
-
padding-left: calc(var(--lumo-button-size) / 4);
|
|
231
|
-
padding-right: calc(var(--lumo-button-size) / 4);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
:host([theme~='icon']) [part='prefix'],
|
|
235
|
-
:host([theme~='icon']) [part='suffix'] {
|
|
236
|
-
margin-left: 0;
|
|
237
|
-
margin-right: 0;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/* RTL specific styles */
|
|
241
|
-
|
|
242
|
-
:host([dir='rtl']) [part='prefix'] {
|
|
243
|
-
margin-left: 0.25em;
|
|
244
|
-
margin-right: -0.25em;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
:host([dir='rtl']) [part='suffix'] {
|
|
248
|
-
margin-left: -0.25em;
|
|
249
|
-
margin-right: 0.25em;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
:host([dir='rtl'][theme~='icon']) [part='prefix'],
|
|
253
|
-
:host([dir='rtl'][theme~='icon']) [part='suffix'] {
|
|
254
|
-
margin-left: 0;
|
|
255
|
-
margin-right: 0;
|
|
256
|
-
}
|
|
257
|
-
`;
|
|
258
|
-
|
|
259
|
-
registerStyles('vaadin-button', button, { moduleId: 'lumo-button' });
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* @license
|
|
263
|
-
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
264
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
265
|
-
*/
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* A mixin providing common button functionality.
|
|
269
|
-
*
|
|
270
|
-
* @polymerMixin
|
|
271
|
-
* @mixes ActiveMixin
|
|
272
|
-
* @mixes FocusMixin
|
|
273
|
-
* @mixes TabindexMixin
|
|
274
|
-
*/
|
|
275
|
-
const ButtonMixin = (superClass) =>
|
|
276
|
-
class ButtonMixinClass extends ActiveMixin(TabindexMixin(FocusMixin(superClass))) {
|
|
277
|
-
static get properties() {
|
|
278
|
-
return {
|
|
279
|
-
/**
|
|
280
|
-
* Indicates whether the element can be focused and where it participates in sequential keyboard navigation.
|
|
281
|
-
*
|
|
282
|
-
* @override
|
|
283
|
-
* @protected
|
|
284
|
-
*/
|
|
285
|
-
tabindex: {
|
|
286
|
-
value: 0,
|
|
287
|
-
},
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* By default, `Space` is the only possible activation key for a focusable HTML element.
|
|
293
|
-
* Nonetheless, the button is an exception as it can be also activated by pressing `Enter`.
|
|
294
|
-
* See the "Keyboard Support" section in https://www.w3.org/TR/wai-aria-practices/examples/button/button.html.
|
|
295
|
-
*
|
|
296
|
-
* @protected
|
|
297
|
-
* @override
|
|
298
|
-
*/
|
|
299
|
-
get _activeKeys() {
|
|
300
|
-
return ['Enter', ' '];
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/** @protected */
|
|
304
|
-
ready() {
|
|
305
|
-
super.ready();
|
|
306
|
-
|
|
307
|
-
// By default, if the user hasn't provided a custom role,
|
|
308
|
-
// the role attribute is set to "button".
|
|
309
|
-
if (!this.hasAttribute('role')) {
|
|
310
|
-
this.setAttribute('role', 'button');
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Since the button component is designed on the base of the `[role=button]` attribute,
|
|
316
|
-
* and doesn't have a native <button> inside, in order to be fully accessible from the keyboard,
|
|
317
|
-
* it should manually fire the `click` event once an activation key is pressed,
|
|
318
|
-
* as it follows from the WAI-ARIA specifications:
|
|
319
|
-
* https://www.w3.org/TR/wai-aria-practices-1.1/#button
|
|
320
|
-
*
|
|
321
|
-
* According to the UI Events specifications,
|
|
322
|
-
* the `click` event should be fired exactly on `keydown`:
|
|
323
|
-
* https://www.w3.org/TR/uievents/#event-type-keydown
|
|
324
|
-
*
|
|
325
|
-
* @param {KeyboardEvent} event
|
|
326
|
-
* @protected
|
|
327
|
-
* @override
|
|
328
|
-
*/
|
|
329
|
-
_onKeyDown(event) {
|
|
330
|
-
super._onKeyDown(event);
|
|
331
|
-
|
|
332
|
-
if (this._activeKeys.includes(event.key)) {
|
|
333
|
-
event.preventDefault();
|
|
334
|
-
|
|
335
|
-
// `DisabledMixin` overrides the standard `click()` method
|
|
336
|
-
// so that it doesn't fire the `click` event when the element is disabled.
|
|
337
|
-
this.click();
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* @license
|
|
344
|
-
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
345
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
346
|
-
*/
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* `<vaadin-button>` is an accessible and customizable button that allows users to perform actions.
|
|
350
|
-
*
|
|
351
|
-
* ```html
|
|
352
|
-
* <vaadin-button>Press me</vaadin-button>
|
|
353
|
-
* ```
|
|
354
|
-
*
|
|
355
|
-
* ### Styling
|
|
356
|
-
*
|
|
357
|
-
* The following shadow DOM parts are available for styling:
|
|
358
|
-
*
|
|
359
|
-
* Part name | Description
|
|
360
|
-
* ----------|-------------
|
|
361
|
-
* `label` | The label (text) inside the button.
|
|
362
|
-
* `prefix` | A slot for content before the label (e.g. an icon).
|
|
363
|
-
* `suffix` | A slot for content after the label (e.g. an icon).
|
|
364
|
-
*
|
|
365
|
-
* The following attributes are available for styling:
|
|
366
|
-
*
|
|
367
|
-
* Attribute | Description
|
|
368
|
-
* -------------|-------------
|
|
369
|
-
* `active` | Set when the button is pressed down, either with mouse, touch or the keyboard.
|
|
370
|
-
* `disabled` | Set when the button is disabled.
|
|
371
|
-
* `focus-ring` | Set when the button is focused using the keyboard.
|
|
372
|
-
* `focused` | Set when the button is focused.
|
|
373
|
-
*
|
|
374
|
-
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
375
|
-
*
|
|
376
|
-
* @extends HTMLElement
|
|
377
|
-
* @mixes ButtonMixin
|
|
378
|
-
* @mixes ControllerMixin
|
|
379
|
-
* @mixes ElementMixin
|
|
380
|
-
* @mixes ThemableMixin
|
|
381
|
-
*/
|
|
382
|
-
class Button extends ButtonMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement)))) {
|
|
383
|
-
static get is() {
|
|
384
|
-
return 'vaadin-button';
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
static get template() {
|
|
388
|
-
return html`
|
|
389
|
-
<style>
|
|
390
|
-
:host {
|
|
391
|
-
display: inline-block;
|
|
392
|
-
position: relative;
|
|
393
|
-
outline: none;
|
|
394
|
-
white-space: nowrap;
|
|
395
|
-
-webkit-user-select: none;
|
|
396
|
-
-moz-user-select: none;
|
|
397
|
-
user-select: none;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
:host([hidden]) {
|
|
401
|
-
display: none !important;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/* Aligns the button with form fields when placed on the same line.
|
|
405
|
-
Note, to make it work, the form fields should have the same "::before" pseudo-element. */
|
|
406
|
-
.vaadin-button-container::before {
|
|
407
|
-
content: '\\2003';
|
|
408
|
-
display: inline-block;
|
|
409
|
-
width: 0;
|
|
410
|
-
max-height: 100%;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
.vaadin-button-container {
|
|
414
|
-
display: inline-flex;
|
|
415
|
-
align-items: center;
|
|
416
|
-
justify-content: center;
|
|
417
|
-
text-align: center;
|
|
418
|
-
width: 100%;
|
|
419
|
-
height: 100%;
|
|
420
|
-
min-height: inherit;
|
|
421
|
-
text-shadow: inherit;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
[part='prefix'],
|
|
425
|
-
[part='suffix'] {
|
|
426
|
-
flex: none;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
[part='label'] {
|
|
430
|
-
white-space: nowrap;
|
|
431
|
-
overflow: hidden;
|
|
432
|
-
text-overflow: ellipsis;
|
|
433
|
-
}
|
|
434
|
-
</style>
|
|
435
|
-
<div class="vaadin-button-container">
|
|
436
|
-
<span part="prefix" aria-hidden="true">
|
|
437
|
-
<slot name="prefix"></slot>
|
|
438
|
-
</span>
|
|
439
|
-
<span part="label">
|
|
440
|
-
<slot></slot>
|
|
441
|
-
</span>
|
|
442
|
-
<span part="suffix" aria-hidden="true">
|
|
443
|
-
<slot name="suffix"></slot>
|
|
444
|
-
</span>
|
|
445
|
-
</div>
|
|
446
|
-
<slot name="tooltip"></slot>
|
|
447
|
-
`;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
/** @protected */
|
|
451
|
-
ready() {
|
|
452
|
-
super.ready();
|
|
453
|
-
|
|
454
|
-
this._tooltipController = new TooltipController(this);
|
|
455
|
-
this.addController(this._tooltipController);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
customElements.define(Button.is, Button);
|
|
460
|
-
|
|
461
|
-
export { Button as B, button as b };
|