@descope/web-components-ui 1.0.135 → 1.0.148
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +77 -56
- package/src/baseClasses/createBaseClass.js +18 -16
- package/src/baseClasses/createBaseInputClass.js +14 -8
- package/src/baseClasses/createCssVarImageClass.js +27 -23
- package/src/components/boolean-fields/booleanFieldMixin.js +18 -29
- package/src/components/boolean-fields/commonStyles.js +1 -1
- package/src/components/boolean-fields/descope-boolean-field-internal/BooleanFieldInternal.js +46 -51
- package/src/components/boolean-fields/descope-boolean-field-internal/index.js +1 -1
- package/src/components/boolean-fields/descope-checkbox/CheckboxClass.js +80 -85
- package/src/components/boolean-fields/descope-checkbox/index.js +2 -2
- package/src/components/boolean-fields/descope-switch-toggle/SwitchToggleClass.js +88 -95
- package/src/components/boolean-fields/descope-switch-toggle/index.js +2 -2
- package/src/components/descope-button/ButtonClass.js +57 -47
- package/src/components/descope-button/clickableMixin.js +10 -0
- package/src/components/descope-combo-box/ComboBoxClass.js +156 -160
- package/src/components/descope-container/ContainerClass.js +32 -42
- package/src/components/descope-date-picker/index.js +9 -14
- package/src/components/descope-divider/DividerClass.js +52 -62
- package/src/components/descope-email-field/EmailFieldClass.js +25 -20
- package/src/components/descope-image/ImageClass.js +21 -24
- package/src/components/descope-link/LinkClass.js +31 -35
- package/src/components/descope-loader-linear/LoaderLinearClass.js +31 -36
- package/src/components/descope-loader-radial/LoaderRadialClass.js +23 -30
- package/src/components/descope-logo/LogoClass.js +5 -1
- package/src/components/descope-new-password/NewPasswordClass.js +63 -81
- package/src/components/descope-new-password/descope-new-password-internal/NewPasswordInternal.js +157 -162
- package/src/components/descope-new-password/descope-new-password-internal/componentName.js +1 -1
- package/src/components/descope-new-password/descope-new-password-internal/index.js +3 -3
- package/src/components/descope-new-password/index.js +3 -3
- package/src/components/descope-number-field/NumberFieldClass.js +25 -20
- package/src/components/descope-passcode/PasscodeClass.js +95 -95
- package/src/components/descope-passcode/descope-passcode-internal/PasscodeInternal.js +151 -157
- package/src/components/descope-passcode/descope-passcode-internal/helpers.js +7 -8
- package/src/components/descope-passcode/descope-passcode-internal/index.js +2 -2
- package/src/components/descope-passcode/index.js +2 -2
- package/src/components/descope-password/PasswordClass.js +75 -83
- package/src/components/descope-password/passwordDraggableMixin.js +28 -27
- package/src/components/descope-phone-field/CountryCodes.js +1210 -1210
- package/src/components/descope-phone-field/PhoneFieldClass.js +139 -141
- package/src/components/descope-phone-field/descope-phone-field-internal/PhoneFieldInternal.js +157 -173
- package/src/components/descope-phone-field/helpers.js +3 -3
- package/src/components/descope-text/TextClass.js +25 -29
- package/src/components/descope-text-area/TextAreaClass.js +68 -67
- package/src/components/descope-text-field/TextFieldClass.js +42 -37
- package/src/components/descope-text-field/textFieldMappings.js +40 -55
- package/src/components/descope-totp-image/TotpImageClass.js +5 -1
- package/src/components/descope-upload-file/UploadFileClass.js +202 -0
- package/src/components/descope-upload-file/helpers.js +11 -0
- package/src/components/descope-upload-file/index.js +6 -0
- package/src/constants.js +3 -3
- package/src/helpers/componentHelpers.js +68 -74
- package/src/helpers/index.js +17 -16
- package/src/helpers/mixinsHelpers.js +21 -10
- package/src/helpers/themeHelpers/colorsHelpers.js +18 -18
- package/src/helpers/themeHelpers/componentsThemeManager.js +7 -6
- package/src/helpers/themeHelpers/index.js +114 -124
- package/src/helpers/themeHelpers/resetHelpers.js +16 -16
- package/src/index.cjs.js +3 -3
- package/src/index.d.ts +22 -21
- package/src/index.js +5 -4
- package/src/index.umd.js +14 -13
- package/src/mixins/changeMixin.js +18 -17
- package/src/mixins/componentNameValidationMixin.js +19 -19
- package/src/mixins/createProxy.js +33 -33
- package/src/mixins/createStyleMixin/helpers.js +54 -64
- package/src/mixins/createStyleMixin/index.js +155 -141
- package/src/mixins/draggableMixin.js +61 -61
- package/src/mixins/hoverableMixin.js +11 -13
- package/src/mixins/index.js +6 -6
- package/src/mixins/inputEventsDispatchingMixin.js +61 -60
- package/src/mixins/inputValidationMixin.js +153 -148
- package/src/mixins/lifecycleEventsMixin.js +17 -15
- package/src/mixins/normalizeBooleanAttributesMixin.js +31 -23
- package/src/mixins/portalMixin.js +58 -52
- package/src/mixins/proxyInputMixin.js +138 -132
- package/src/theme/components/button.js +86 -81
- package/src/theme/components/checkbox.js +26 -28
- package/src/theme/components/comboBox.js +32 -31
- package/src/theme/components/container.js +99 -89
- package/src/theme/components/divider.js +30 -31
- package/src/theme/components/emailField.js +20 -19
- package/src/theme/components/image.js +3 -3
- package/src/theme/components/index.js +33 -25
- package/src/theme/components/inputWrapper.js +28 -25
- package/src/theme/components/link.js +29 -36
- package/src/theme/components/loader/index.js +3 -3
- package/src/theme/components/loader/loaderLinear.js +34 -34
- package/src/theme/components/loader/loaderRadial.js +40 -34
- package/src/theme/components/logo.js +4 -4
- package/src/theme/components/newPassword.js +14 -13
- package/src/theme/components/numberField.js +20 -19
- package/src/theme/components/passcode.js +20 -22
- package/src/theme/components/password.js +22 -21
- package/src/theme/components/phoneField.js +23 -23
- package/src/theme/components/switchToggle.js +47 -46
- package/src/theme/components/text.js +72 -72
- package/src/theme/components/textArea.js +27 -25
- package/src/theme/components/textField.js +23 -22
- package/src/theme/components/totpImage.js +4 -4
- package/src/theme/components/uploadFile.js +60 -0
- package/src/theme/globals.js +123 -124
- package/src/theme/index.js +1 -1
- package/dist/cjs/index.cjs.js +0 -5924
- package/dist/cjs/index.cjs.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/index.d.ts +0 -51
- package/dist/index.esm.js +0 -6606
- package/dist/index.esm.js.map +0 -1
- package/dist/umd/1018.js +0 -577
- package/dist/umd/1018.js.LICENSE.txt +0 -23
- package/dist/umd/2481.js +0 -1
- package/dist/umd/3208.js +0 -2
- package/dist/umd/3208.js.LICENSE.txt +0 -5
- package/dist/umd/3585.js +0 -1
- package/dist/umd/3878.js +0 -1
- package/dist/umd/4201.js +0 -1
- package/dist/umd/422.js +0 -2
- package/dist/umd/422.js.LICENSE.txt +0 -5
- package/dist/umd/4447.js +0 -1
- package/dist/umd/4513.js +0 -1
- package/dist/umd/4803.js +0 -1
- package/dist/umd/541.js +0 -744
- package/dist/umd/541.js.LICENSE.txt +0 -21
- package/dist/umd/5767.js +0 -2
- package/dist/umd/5767.js.LICENSE.txt +0 -15
- package/dist/umd/5806.js +0 -109
- package/dist/umd/5806.js.LICENSE.txt +0 -5
- package/dist/umd/7056.js +0 -48
- package/dist/umd/7056.js.LICENSE.txt +0 -5
- package/dist/umd/7101.js +0 -148
- package/dist/umd/7101.js.LICENSE.txt +0 -11
- package/dist/umd/729.js +0 -1
- package/dist/umd/7824.js +0 -229
- package/dist/umd/7824.js.LICENSE.txt +0 -27
- package/dist/umd/7840.js +0 -356
- package/dist/umd/7840.js.LICENSE.txt +0 -61
- package/dist/umd/8725.js +0 -37
- package/dist/umd/8725.js.LICENSE.txt +0 -11
- package/dist/umd/9211.js +0 -312
- package/dist/umd/9211.js.LICENSE.txt +0 -5
- package/dist/umd/9241.js +0 -1
- package/dist/umd/9314.js +0 -283
- package/dist/umd/9314.js.LICENSE.txt +0 -27
- package/dist/umd/9437.js +0 -19
- package/dist/umd/9437.js.LICENSE.txt +0 -5
- package/dist/umd/9515.js +0 -202
- package/dist/umd/9515.js.LICENSE.txt +0 -11
- package/dist/umd/9789.js +0 -1
- package/dist/umd/boolean-fields-descope-boolean-field-internal-index-js.js +0 -1
- package/dist/umd/boolean-fields-descope-checkbox-index-js.js +0 -1
- package/dist/umd/boolean-fields-descope-switch-toggle-index-js.js +0 -1
- package/dist/umd/descope-button-index-js.js +0 -1
- package/dist/umd/descope-combo-box-index-js.js +0 -1
- package/dist/umd/descope-container-index-js.js +0 -1
- package/dist/umd/descope-date-picker-index-js.js +0 -1
- package/dist/umd/descope-divider-index-js.js +0 -1
- package/dist/umd/descope-email-field-index-js.js +0 -1
- package/dist/umd/descope-image-index-js.js +0 -1
- package/dist/umd/descope-link-index-js.js +0 -1
- package/dist/umd/descope-loader-linear-index-js.js +0 -1
- package/dist/umd/descope-loader-radial-index-js.js +0 -1
- package/dist/umd/descope-logo-index-js.js +0 -1
- package/dist/umd/descope-new-password-descope-new-password-internal-index-js.js +0 -1
- package/dist/umd/descope-new-password-index-js.js +0 -1
- package/dist/umd/descope-number-field-index-js.js +0 -1
- package/dist/umd/descope-passcode-descope-passcode-internal-index-js.js +0 -1
- package/dist/umd/descope-passcode-index-js.js +0 -1
- package/dist/umd/descope-password-index-js.js +0 -1
- package/dist/umd/descope-phone-field-descope-phone-field-internal-index-js.js +0 -1
- package/dist/umd/descope-phone-field-index-js.js +0 -1
- package/dist/umd/descope-text-area-index-js.js +0 -1
- package/dist/umd/descope-text-field-index-js.js +0 -1
- package/dist/umd/descope-text-index-js.js +0 -1
- package/dist/umd/descope-totp-image-index-js.js +0 -1
- package/dist/umd/index.js +0 -1
package/src/components/descope-phone-field/descope-phone-field-internal/PhoneFieldInternal.js
CHANGED
@@ -5,200 +5,184 @@ import { comboBoxItem } from '../helpers';
|
|
5
5
|
|
6
6
|
export const componentName = getComponentName('phone-field-internal');
|
7
7
|
|
8
|
-
const commonAttrs = [
|
9
|
-
'disabled',
|
10
|
-
'size',
|
11
|
-
'bordered',
|
12
|
-
'invalid',
|
13
|
-
'readonly',
|
14
|
-
];
|
8
|
+
const commonAttrs = ['disabled', 'size', 'bordered', 'invalid', 'readonly'];
|
15
9
|
const countryAttrs = ['country-input-placeholder', 'default-code'];
|
16
10
|
const phoneAttrs = ['phone-input-placeholder', 'maxlength'];
|
17
11
|
const mapAttrs = {
|
18
|
-
|
19
|
-
|
20
|
-
}
|
12
|
+
'country-input-placeholder': 'placeholder',
|
13
|
+
'phone-input-placeholder': 'placeholder',
|
14
|
+
};
|
21
15
|
|
22
16
|
const inputRelatedAttrs = [].concat(commonAttrs, countryAttrs, phoneAttrs);
|
23
17
|
|
24
18
|
const BaseInputClass = createBaseInputClass({ componentName, baseSelector: 'div' });
|
25
19
|
|
26
20
|
class PhoneFieldInternal extends BaseInputClass {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
inputRelatedAttrs,
|
31
|
-
);
|
32
|
-
}
|
21
|
+
static get observedAttributes() {
|
22
|
+
return [].concat(BaseInputClass.observedAttributes || [], inputRelatedAttrs);
|
23
|
+
}
|
33
24
|
|
34
|
-
|
35
|
-
|
25
|
+
constructor() {
|
26
|
+
super();
|
36
27
|
|
37
|
-
|
28
|
+
this.innerHTML = `
|
38
29
|
<div>
|
39
30
|
<descope-combo-box
|
40
31
|
item-label-path="data-name"
|
41
32
|
item-value-path="data-id"
|
42
33
|
>
|
43
|
-
${CountryCodes.map(item => comboBoxItem(item)).join('')}
|
34
|
+
${CountryCodes.map((item) => comboBoxItem(item)).join('')}
|
44
35
|
</descope-combo-box>
|
45
36
|
<div class="separator"></div>
|
46
37
|
<descope-text-field type="tel"></descope-text-field>
|
47
38
|
</div>`;
|
48
39
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
}
|
196
|
-
else if (phoneAttrs.includes(attrName)) {
|
197
|
-
this.phoneNumberInput.setAttribute(attr, newValue);
|
198
|
-
}
|
199
|
-
}
|
200
|
-
}
|
201
|
-
}
|
40
|
+
this.countryCodeInput = this.querySelector('descope-combo-box');
|
41
|
+
this.phoneNumberInput = this.querySelector('descope-text-field');
|
42
|
+
this.inputs = [this.countryCodeInput, this.phoneNumberInput];
|
43
|
+
}
|
44
|
+
|
45
|
+
get value() {
|
46
|
+
return this.inputs.map(({ value }) => value).join('-');
|
47
|
+
}
|
48
|
+
|
49
|
+
set value(val) {
|
50
|
+
const [countryCode = '', phoneNumber = ''] = val.split('-');
|
51
|
+
const countryCodeItem = this.getCountryByDialCode(countryCode);
|
52
|
+
if (countryCodeItem) {
|
53
|
+
this.countryCodeInput.selectedItem = countryCodeItem;
|
54
|
+
}
|
55
|
+
this.phoneNumberInput.value = phoneNumber;
|
56
|
+
}
|
57
|
+
|
58
|
+
get phoneNumberValue() {
|
59
|
+
return this.phoneNumberInput.value;
|
60
|
+
}
|
61
|
+
|
62
|
+
get countryCodeValue() {
|
63
|
+
return this.countryCodeInput.shadowRoot.querySelector('input').value;
|
64
|
+
}
|
65
|
+
|
66
|
+
get minLength() {
|
67
|
+
return parseInt(this.getAttribute('minlength'), 10) || 0;
|
68
|
+
}
|
69
|
+
|
70
|
+
getValidity() {
|
71
|
+
const hasCode = this.countryCodeInput.value;
|
72
|
+
const hasPhone = this.phoneNumberInput.value;
|
73
|
+
const emptyValue = !hasCode || !hasPhone;
|
74
|
+
const hasMinPhoneLength =
|
75
|
+
this.phoneNumberInput.value.length && this.phoneNumberInput.value.length < this.minLength;
|
76
|
+
|
77
|
+
if (this.isRequired && emptyValue) {
|
78
|
+
return { valueMissing: true };
|
79
|
+
}
|
80
|
+
if (hasMinPhoneLength) {
|
81
|
+
return { tooShort: true };
|
82
|
+
}
|
83
|
+
if ((hasCode && !hasPhone) || (!hasCode && hasPhone)) {
|
84
|
+
return { valueMissing: true };
|
85
|
+
}
|
86
|
+
return {};
|
87
|
+
}
|
88
|
+
|
89
|
+
init() {
|
90
|
+
this.addEventListener('focus', (e) => {
|
91
|
+
// we want to ignore focus events we are dispatching
|
92
|
+
if (e.isTrusted) this.inputs[0].focus();
|
93
|
+
});
|
94
|
+
|
95
|
+
super.init?.();
|
96
|
+
this.initInputs();
|
97
|
+
this.setComboBoxDescriptor();
|
98
|
+
}
|
99
|
+
|
100
|
+
getCountryByDialCode(countryDialCode) {
|
101
|
+
return this.countryCodeInput.items.find(
|
102
|
+
(c) => c.getAttribute('data-dial-code') === countryDialCode
|
103
|
+
);
|
104
|
+
}
|
105
|
+
|
106
|
+
getCountryByCodeId(countryCode) {
|
107
|
+
return this.countryCodeInput.items.find((c) => c['data-id'] === countryCode)?.['data-name'];
|
108
|
+
}
|
109
|
+
|
110
|
+
handleDefaultCountryCode(countryCode) {
|
111
|
+
if (!this.countryCodeInput.value) {
|
112
|
+
const countryCodeItem = this.getCountryByCodeId(countryCode);
|
113
|
+
// When replacing the input component (inserting internal component into text-field) -
|
114
|
+
// Vaadin resets the input's value. We use setTimeout in order to make sure this happens
|
115
|
+
// after the reset.
|
116
|
+
if (countryCodeItem) {
|
117
|
+
setTimeout(() => {
|
118
|
+
this.countryCodeInput.selectedItem = countryCodeItem;
|
119
|
+
});
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
// We want to override Vaadin's Combo Box value setter. This is needed since Vaadin couples between the
|
125
|
+
// field that it searches the value, and the finaly display value of the input. We want to search ALL
|
126
|
+
// the values (so we made a field with all the values), but display ONLY the dial code, so we added
|
127
|
+
// this setter, which does that.
|
128
|
+
setComboBoxDescriptor() {
|
129
|
+
const comboBox = this.countryCodeInput;
|
130
|
+
const input = comboBox.shadowRoot.querySelector('input');
|
131
|
+
const valueDescriptor = Object.getOwnPropertyDescriptor(input.constructor.prototype, 'value');
|
132
|
+
Object.defineProperties(input, {
|
133
|
+
value: {
|
134
|
+
...valueDescriptor,
|
135
|
+
set(val) {
|
136
|
+
if (!comboBox.items?.length) {
|
137
|
+
return;
|
138
|
+
}
|
139
|
+
|
140
|
+
const [, dialCode] = val.split(' ');
|
141
|
+
|
142
|
+
if (val === this.value) {
|
143
|
+
return;
|
144
|
+
}
|
145
|
+
|
146
|
+
valueDescriptor.set.call(this, dialCode || '');
|
147
|
+
},
|
148
|
+
},
|
149
|
+
});
|
150
|
+
}
|
151
|
+
|
152
|
+
initInputs() {
|
153
|
+
// Sanitize phone input value to filter everything but digits
|
154
|
+
this.phoneNumberInput.addEventListener('input', (e) => {
|
155
|
+
const telDigitsRegExp = /^\d$/;
|
156
|
+
const sanitizedInput = e.target.value
|
157
|
+
.split('')
|
158
|
+
.filter((char) => telDigitsRegExp.test(char))
|
159
|
+
.join('');
|
160
|
+
e.target.value = sanitizedInput;
|
161
|
+
});
|
162
|
+
|
163
|
+
this.handleFocusEventsDispatching(this.inputs);
|
164
|
+
this.handleInputEventDispatching();
|
165
|
+
}
|
166
|
+
|
167
|
+
attributeChangedCallback(attrName, oldValue, newValue) {
|
168
|
+
super.attributeChangedCallback(attrName, oldValue, newValue);
|
169
|
+
|
170
|
+
if (oldValue !== newValue) {
|
171
|
+
if (attrName === 'default-code' && newValue) {
|
172
|
+
this.handleDefaultCountryCode(newValue);
|
173
|
+
} else if (inputRelatedAttrs.includes(attrName)) {
|
174
|
+
const attr = mapAttrs[attrName] || attrName;
|
175
|
+
|
176
|
+
if (commonAttrs.includes(attrName)) {
|
177
|
+
this.inputs.forEach((input) => input.setAttribute(attr, newValue));
|
178
|
+
} else if (countryAttrs.includes(attrName)) {
|
179
|
+
this.countryCodeInput.setAttribute(attr, newValue);
|
180
|
+
} else if (phoneAttrs.includes(attrName)) {
|
181
|
+
this.phoneNumberInput.setAttribute(attr, newValue);
|
182
|
+
}
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|
202
186
|
}
|
203
187
|
|
204
188
|
export default PhoneFieldInternal;
|
@@ -1,9 +1,9 @@
|
|
1
1
|
// We use JSDelivr in order to fetch the images as image file from this library (svg-country-flags)
|
2
2
|
// This reduces our bundle size, and we use it as a static remote resource.
|
3
3
|
export const getCountryFlag = (code) =>
|
4
|
-
|
4
|
+
`https://cdn.jsdelivr.net/npm/svg-country-flags@1.2.10/svg/${code.toLowerCase()}.svg`;
|
5
5
|
|
6
|
-
export const comboBoxItem = ({ code, dialCode, name: country }) =>
|
6
|
+
export const comboBoxItem = ({ code, dialCode, name: country }) => `
|
7
7
|
<div
|
8
8
|
style="display:flex; flex-direction: column;"
|
9
9
|
data-id="${code}"
|
@@ -21,4 +21,4 @@ export const comboBoxItem = ({ code, dialCode, name: country }) => (`
|
|
21
21
|
<span>${dialCode}</span>
|
22
22
|
</div>
|
23
23
|
</div>
|
24
|
-
|
24
|
+
`;
|
@@ -1,8 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
createStyleMixin,
|
3
|
-
draggableMixin,
|
4
|
-
componentNameValidationMixin
|
5
|
-
} from '../../mixins';
|
1
|
+
import { createStyleMixin, draggableMixin, componentNameValidationMixin } from '../../mixins';
|
6
2
|
import { createBaseClass } from '../../baseClasses/createBaseClass';
|
7
3
|
import { compose } from '../../helpers';
|
8
4
|
import { getComponentName } from '../../helpers/componentHelpers';
|
@@ -10,10 +6,10 @@ import { getComponentName } from '../../helpers/componentHelpers';
|
|
10
6
|
export const componentName = getComponentName('text');
|
11
7
|
|
12
8
|
class RawText extends createBaseClass({ componentName, baseSelector: ':host > slot' }) {
|
13
|
-
|
14
|
-
|
9
|
+
constructor() {
|
10
|
+
super();
|
15
11
|
|
16
|
-
|
12
|
+
this.attachShadow({ mode: 'open' }).innerHTML = `
|
17
13
|
<style>
|
18
14
|
:host {
|
19
15
|
display: inline-block;
|
@@ -25,28 +21,28 @@ class RawText extends createBaseClass({ componentName, baseSelector: ':host > sl
|
|
25
21
|
</style>
|
26
22
|
<slot></slot>
|
27
23
|
`;
|
28
|
-
|
24
|
+
}
|
29
25
|
}
|
30
26
|
|
31
27
|
export const TextClass = compose(
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
28
|
+
createStyleMixin({
|
29
|
+
mappings: {
|
30
|
+
hostWidth: { selector: () => ':host', property: 'width' },
|
31
|
+
fontSize: {},
|
32
|
+
textColor: { property: 'color' },
|
33
|
+
textLineHeight: { property: 'line-height' },
|
34
|
+
textLetterSpacing: { property: 'letter-spacing' },
|
35
|
+
textShadow: {},
|
36
|
+
textAlign: {},
|
37
|
+
textTransform: {},
|
38
|
+
fontFamily: {},
|
39
|
+
fontStyle: {},
|
40
|
+
fontWeight: {},
|
41
|
+
borderWidth: {},
|
42
|
+
borderStyle: {},
|
43
|
+
borderColor: {},
|
44
|
+
},
|
45
|
+
}),
|
46
|
+
draggableMixin,
|
47
|
+
componentNameValidationMixin
|
52
48
|
)(RawText);
|
@@ -1,91 +1,92 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
createStyleMixin,
|
3
|
+
draggableMixin,
|
4
|
+
createProxy,
|
5
|
+
proxyInputMixin,
|
6
|
+
componentNameValidationMixin,
|
7
7
|
} from '../../mixins';
|
8
8
|
import { compose } from '../../helpers';
|
9
9
|
import { getComponentName } from '../../helpers/componentHelpers';
|
10
|
-
import {
|
10
|
+
import {
|
11
|
+
resetInputContainer,
|
12
|
+
resetInputCursor,
|
13
|
+
resetInputField,
|
14
|
+
resetInputPlaceholder,
|
15
|
+
useHostExternalPadding,
|
16
|
+
} from '../../helpers/themeHelpers/resetHelpers';
|
11
17
|
|
12
18
|
export const componentName = getComponentName('text-area');
|
13
19
|
|
14
20
|
const {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
host,
|
22
|
+
label,
|
23
|
+
placeholder,
|
24
|
+
inputField,
|
25
|
+
textArea,
|
26
|
+
requiredIndicator,
|
27
|
+
helperText,
|
28
|
+
errorMessage,
|
23
29
|
} = {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
host: { selector: () => ':host' },
|
31
|
+
label: { selector: '::part(label)' },
|
32
|
+
placeholder: { selector: 'textarea:placeholder-shown' },
|
33
|
+
inputField: { selector: '::part(input-field)' },
|
34
|
+
textArea: { selector: '> textarea' },
|
35
|
+
requiredIndicator: { selector: '[required]::part(required-indicator)::after' },
|
36
|
+
helperText: { selector: '::part(helper-text)' },
|
37
|
+
errorMessage: { selector: '::part(error-message)' },
|
32
38
|
};
|
33
39
|
|
34
40
|
export const TextAreaClass = compose(
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
inputResizeType: { ...textArea, property: 'resize' },
|
66
|
-
}
|
67
|
-
}),
|
68
|
-
draggableMixin,
|
69
|
-
proxyInputMixin,
|
70
|
-
componentNameValidationMixin
|
41
|
+
createStyleMixin({
|
42
|
+
mappings: {
|
43
|
+
hostWidth: { ...host, property: 'width' },
|
44
|
+
hostMinWidth: { ...host, property: 'min-width' },
|
45
|
+
fontSize: [host, textArea],
|
46
|
+
fontFamily: [label, inputField, helperText, errorMessage],
|
47
|
+
labelTextColor: [
|
48
|
+
{ ...label, property: 'color' },
|
49
|
+
{ ...requiredIndicator, property: 'color' },
|
50
|
+
],
|
51
|
+
labelRequiredIndicator: { ...requiredIndicator, property: 'content' },
|
52
|
+
errorMessageTextColor: { ...errorMessage, property: 'color' },
|
53
|
+
inputBackgroundColor: { ...inputField, property: 'background-color' },
|
54
|
+
inputValueTextColor: { ...textArea, property: 'color' },
|
55
|
+
inputPlaceholderTextColor: { ...placeholder, property: 'color' },
|
56
|
+
inputBorderWidth: { ...inputField, property: 'border-width' },
|
57
|
+
inputBorderStyle: { ...inputField, property: 'border-style' },
|
58
|
+
inputBorderColor: { ...inputField, property: 'border-color' },
|
59
|
+
inputBorderRadius: { ...inputField, property: 'border-radius' },
|
60
|
+
inputOutlineStyle: { ...inputField, property: 'outline-Style' },
|
61
|
+
inputOutlineColor: { ...inputField, property: 'outline-color' },
|
62
|
+
inputOutlineOffset: { ...inputField, property: 'outline-offset' },
|
63
|
+
inputOutlineWidth: { ...inputField, property: 'outline-width' },
|
64
|
+
inputResizeType: { ...textArea, property: 'resize' },
|
65
|
+
inputMinHeight: { ...textArea, property: 'min-height' },
|
66
|
+
},
|
67
|
+
}),
|
68
|
+
draggableMixin,
|
69
|
+
proxyInputMixin,
|
70
|
+
componentNameValidationMixin
|
71
71
|
)(
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
createProxy({
|
73
|
+
slots: [],
|
74
|
+
wrappedEleName: 'vaadin-text-area',
|
75
|
+
style: () => `
|
76
76
|
:host {
|
77
77
|
display: inline-block;
|
78
78
|
max-width: 100%;
|
79
79
|
}
|
80
|
+
textarea {
|
81
|
+
height: 100%;
|
82
|
+
}
|
80
83
|
${useHostExternalPadding(TextAreaClass.cssVarList)}
|
81
84
|
${resetInputContainer('vaadin-text-area')}
|
82
85
|
${resetInputField('vaadin-text-area')}
|
83
86
|
${resetInputPlaceholder('vaadin-text-area', 'textarea')}
|
84
87
|
${resetInputCursor('vaadin-text-area')}
|
85
88
|
`,
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
+
excludeAttrsSync: ['tabindex'],
|
90
|
+
componentName,
|
91
|
+
})
|
89
92
|
);
|
90
|
-
|
91
|
-
|