@descope/web-components-ui 1.44.0 → 1.46.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/index.cjs.js +58 -24
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +469 -232
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/3620.js +1 -1
- package/dist/umd/3620.js.map +1 -1
- package/dist/umd/5348.js +2 -0
- package/dist/umd/5348.js.map +1 -0
- package/dist/umd/6477.js +149 -0
- package/dist/umd/6477.js.map +1 -0
- package/dist/umd/9365.js +1 -1
- package/dist/umd/9365.js.map +1 -1
- package/dist/umd/DescopeDev.js +1 -1
- package/dist/umd/DescopeDev.js.map +1 -1
- package/dist/umd/descope-hybrid-field-index-js.js +3 -3
- package/dist/umd/descope-hybrid-field-index-js.js.map +1 -1
- package/dist/umd/descope-passcode-index-js.js +1 -1
- package/dist/umd/descope-passcode-index-js.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/phone-fields-descope-phone-field-descope-phone-field-internal-index-js.js +1 -1
- package/dist/umd/phone-fields-descope-phone-field-descope-phone-field-internal-index-js.js.map +1 -1
- package/dist/umd/phone-fields-descope-phone-field-index-js.js +1 -1
- package/dist/umd/phone-fields-descope-phone-field-index-js.js.map +1 -1
- package/dist/umd/phone-fields-descope-phone-input-box-field-descope-phone-input-box-internal-index-js.js +2 -2
- package/dist/umd/phone-fields-descope-phone-input-box-field-descope-phone-input-box-internal-index-js.js.map +1 -1
- package/dist/umd/phone-fields-descope-phone-input-box-field-index-js.js +2 -113
- package/dist/umd/phone-fields-descope-phone-input-box-field-index-js.js.LICENSE.txt +0 -6
- package/dist/umd/phone-fields-descope-phone-input-box-field-index-js.js.map +1 -1
- package/package.json +7 -6
- package/src/components/descope-hybrid-field/HybridFieldClass.js +6 -0
- package/src/components/descope-passcode/PasscodeClass.js +2 -0
- package/src/components/phone-fields/descope-phone-field/PhoneFieldClass.js +10 -2
- package/src/components/phone-fields/descope-phone-field/descope-phone-field-internal/PhoneFieldInternal.js +229 -126
- package/src/components/phone-fields/descope-phone-input-box-field/PhoneFieldInputBoxClass.js +42 -24
- package/src/components/phone-fields/descope-phone-input-box-field/descope-phone-input-box-internal/PhoneFieldInternalInputBox.js +179 -83
- package/src/components/phone-fields/descope-phone-input-box-field/index.js +0 -1
- package/src/components/phone-fields/helpers.js +7 -0
- package/src/mixins/index.js +1 -0
- package/src/mixins/inputOverrideValidConstraints.js +12 -0
- package/dist/umd/6424.js +0 -149
- package/dist/umd/6424.js.map +0 -1
- /package/dist/umd/{6424.js.LICENSE.txt → 6477.js.LICENSE.txt} +0 -0
@@ -2,10 +2,11 @@ import { createBaseInputClass } from '../../../../baseClasses/createBaseInputCla
|
|
2
2
|
import { forwardAttrs, getComponentName } from '../../../../helpers/componentHelpers';
|
3
3
|
import CountryCodes from '../../CountryCodes';
|
4
4
|
import { comboBoxItem, parsePhoneNumber } from '../helpers';
|
5
|
+
import { AsYouType, parsePhoneNumberFromString } from 'libphonenumber-js/min';
|
5
6
|
|
6
7
|
export const componentName = getComponentName('phone-field-internal');
|
7
8
|
|
8
|
-
const commonAttrs = ['disabled', 'size', 'bordered', 'readonly'
|
9
|
+
const commonAttrs = ['disabled', 'size', 'bordered', 'readonly'];
|
9
10
|
const countryAttrs = ['country-input-placeholder', 'default-code', 'restrict-countries'];
|
10
11
|
const phoneAttrs = ['phone-input-placeholder', 'maxlength', 'autocomplete', 'name'];
|
11
12
|
const labelTypeAttrs = ['label-type', 'country-input-label', 'label'];
|
@@ -24,6 +25,8 @@ class PhoneFieldInternal extends BaseInputClass {
|
|
24
25
|
return [].concat(BaseInputClass.observedAttributes || [], inputRelatedAttrs);
|
25
26
|
}
|
26
27
|
|
28
|
+
#ayt;
|
29
|
+
|
27
30
|
constructor() {
|
28
31
|
super();
|
29
32
|
|
@@ -40,200 +43,328 @@ class PhoneFieldInternal extends BaseInputClass {
|
|
40
43
|
</div>
|
41
44
|
`;
|
42
45
|
|
43
|
-
this.
|
44
|
-
this.
|
45
|
-
|
46
|
+
this.comboBox = this.querySelector('descope-combo-box');
|
47
|
+
this.textField = this.querySelector('descope-text-field');
|
48
|
+
|
49
|
+
this.inputs = [this.comboBox, this.textField];
|
46
50
|
|
47
|
-
forwardAttrs(this, this.
|
48
|
-
forwardAttrs(this, this.
|
51
|
+
forwardAttrs(this, this.comboBox, { includeAttrs: ['label-type'] });
|
52
|
+
forwardAttrs(this, this.textField, { includeAttrs: ['label-type', 'required'] });
|
49
53
|
|
50
54
|
// override combo box setter to display dialCode value in input
|
51
|
-
this.
|
55
|
+
this.comboBox.customValueTransformFn = (val) => {
|
52
56
|
const [, dialCode] = val?.split?.(' ') || [];
|
53
57
|
return dialCode;
|
54
58
|
};
|
55
59
|
}
|
56
60
|
|
61
|
+
// exposed from main component
|
57
62
|
get countryCodeInputData() {
|
58
|
-
return this.
|
63
|
+
return this.comboBox.items;
|
64
|
+
}
|
65
|
+
|
66
|
+
// exposed from main component
|
67
|
+
get countryCodeValue() {
|
68
|
+
return this.comboBox.shadowRoot.querySelector('input').value;
|
69
|
+
}
|
70
|
+
|
71
|
+
// exposed from main component
|
72
|
+
get phoneNumberInputEle() {
|
73
|
+
return this.textField.shadowRoot.querySelector('input');
|
59
74
|
}
|
60
75
|
|
61
76
|
get allowAlphanumericInput() {
|
62
77
|
return this.getAttribute('allow-alphanumeric-input') === 'true';
|
63
78
|
}
|
64
79
|
|
80
|
+
get defaultCode() {
|
81
|
+
return this.getAttribute('default-code');
|
82
|
+
}
|
83
|
+
|
84
|
+
get selectionStart() {
|
85
|
+
return this.textField.selectionStart;
|
86
|
+
}
|
87
|
+
|
88
|
+
get minLength() {
|
89
|
+
return parseInt(this.getAttribute('minlength'), 10) || 0;
|
90
|
+
}
|
91
|
+
|
92
|
+
get selectedCountryCode() {
|
93
|
+
return this.comboBox?.selectedItem?.getAttribute('data-country-code');
|
94
|
+
}
|
95
|
+
|
96
|
+
get restrictCountries() {
|
97
|
+
const attr = this.getAttribute('restrict-countries');
|
98
|
+
return attr?.split(',').filter(Boolean) || [];
|
99
|
+
}
|
100
|
+
|
101
|
+
get isFormatValue() {
|
102
|
+
return this.getAttribute('format-value') === 'true';
|
103
|
+
}
|
104
|
+
|
105
|
+
// `strict validation` enforces value parsing with libphonenumber-js
|
106
|
+
get isStrictValidation() {
|
107
|
+
return this.getAttribute('strict-validation') === 'true';
|
108
|
+
}
|
109
|
+
|
65
110
|
get value() {
|
66
|
-
if (!this.
|
111
|
+
if (!this.comboBox.value || !this.textField.value) {
|
67
112
|
return '';
|
68
113
|
}
|
69
|
-
|
114
|
+
|
115
|
+
const [countryCode, phoneNumber] = parsePhoneNumber(
|
116
|
+
`${this.comboBox.value}-${this.textField.value}`
|
117
|
+
);
|
118
|
+
|
119
|
+
return `${countryCode || this.comboBox.value}-${phoneNumber || this.textField.value}`;
|
70
120
|
}
|
71
121
|
|
72
122
|
set value(val) {
|
73
|
-
const [countryCode,
|
123
|
+
const [countryCode, nationalNumber] = parsePhoneNumber(val);
|
74
124
|
|
75
125
|
this.#setCountryCode(countryCode);
|
76
|
-
this.#
|
126
|
+
this.#setNationalNumber(nationalNumber);
|
77
127
|
}
|
78
128
|
|
79
|
-
|
80
|
-
this.
|
81
|
-
|
129
|
+
init() {
|
130
|
+
this.addEventListener('focus', (e) => {
|
131
|
+
// we want to ignore focus events we are dispatching
|
132
|
+
if (e.isTrusted) this.inputs[1].focus();
|
133
|
+
});
|
82
134
|
|
83
|
-
|
84
|
-
|
135
|
+
super.init?.();
|
136
|
+
|
137
|
+
this.#initInputs();
|
85
138
|
}
|
86
139
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
140
|
+
getValidity() {
|
141
|
+
const countryCode = this.comboBox.value;
|
142
|
+
const nationalNumer = this.textField.value;
|
143
|
+
|
144
|
+
const isEmpty = !countryCode || !nationalNumer;
|
145
|
+
const isValidLength = nationalNumer && nationalNumer.length >= this.minLength;
|
146
|
+
|
147
|
+
if (this.isRequired && isEmpty) {
|
148
|
+
return { valueMissing: true };
|
95
149
|
}
|
96
|
-
}
|
97
150
|
|
98
|
-
|
99
|
-
|
100
|
-
|
151
|
+
if (this.value) {
|
152
|
+
if (!isValidLength) {
|
153
|
+
return { tooShort: true };
|
154
|
+
}
|
155
|
+
|
156
|
+
if (this.isStrictValidation && !this.#isValidParsedValue()) {
|
157
|
+
return { patternMismatch: true };
|
158
|
+
}
|
101
159
|
}
|
102
160
|
|
103
|
-
|
161
|
+
return {};
|
104
162
|
}
|
105
163
|
|
106
|
-
|
107
|
-
|
164
|
+
setSelectionRange(...args) {
|
165
|
+
this.textField.setSelectionRange(...args);
|
108
166
|
}
|
109
167
|
|
110
|
-
|
111
|
-
|
112
|
-
}
|
168
|
+
attributeChangedCallback(attrName, oldValue, newValue) {
|
169
|
+
super.attributeChangedCallback(attrName, oldValue, newValue);
|
113
170
|
|
114
|
-
|
115
|
-
|
171
|
+
if (oldValue !== newValue) {
|
172
|
+
if (attrName === 'default-code' && newValue) {
|
173
|
+
this.#handleDefaultCountryCode(newValue);
|
174
|
+
} else if (inputRelatedAttrs.includes(attrName)) {
|
175
|
+
const attr = mapAttrs[attrName] || attrName;
|
176
|
+
|
177
|
+
if (commonAttrs.includes(attrName)) {
|
178
|
+
this.inputs.forEach((input) => input.setAttribute(attr, newValue));
|
179
|
+
} else if (countryAttrs.includes(attrName)) {
|
180
|
+
this.comboBox.setAttribute(attr, newValue);
|
181
|
+
} else if (phoneAttrs.includes(attrName)) {
|
182
|
+
this.textField.setAttribute(attr, newValue);
|
183
|
+
}
|
184
|
+
}
|
185
|
+
|
186
|
+
if (labelTypeAttrs.includes(attrName)) {
|
187
|
+
this.#handleLabelTypeAttrs(attrName, newValue);
|
188
|
+
}
|
189
|
+
|
190
|
+
if (attrName === 'restrict-countries') {
|
191
|
+
this.#updateComboBoxItems(this.restrictCountries);
|
192
|
+
}
|
193
|
+
}
|
116
194
|
}
|
117
195
|
|
118
|
-
|
119
|
-
|
196
|
+
#initInputs() {
|
197
|
+
// Sanitize phone input value to filter everything but digits
|
198
|
+
this.textField.addEventListener('input', (e) => {
|
199
|
+
if (!this.allowAlphanumericInput) {
|
200
|
+
const telDigitsRegExp = /^\d$/;
|
201
|
+
const sanitizedInput = e.target.value
|
202
|
+
.split('')
|
203
|
+
.filter((char) => telDigitsRegExp.test(char))
|
204
|
+
.join('');
|
205
|
+
e.target.value = sanitizedInput;
|
206
|
+
}
|
207
|
+
});
|
208
|
+
|
209
|
+
this.handleFocusEventsDispatching(this.inputs);
|
210
|
+
this.handleInputEventDispatching();
|
211
|
+
|
212
|
+
// verify country code item against phone number pattern and replace if needed and country is allowed
|
213
|
+
// (e.g. +1 can be US or CA, depending on the pattern)
|
214
|
+
this.addEventListener('input', this.#handleSameCountryCodes.bind(this));
|
120
215
|
}
|
121
216
|
|
122
|
-
|
123
|
-
|
124
|
-
const hasPhone = this.phoneNumberInput.value;
|
125
|
-
const emptyValue = !hasCode || !hasPhone;
|
126
|
-
const hasMinPhoneLength =
|
127
|
-
this.phoneNumberInput.value?.length && this.phoneNumberInput.value.length < this.minLength;
|
217
|
+
#setCountryCode(val) {
|
218
|
+
if (!val || val === this.selectedCountryCode) return;
|
128
219
|
|
129
|
-
|
130
|
-
|
220
|
+
let countryCodeItem = undefined;
|
221
|
+
|
222
|
+
if (this.value) {
|
223
|
+
// try to parse the phone number, and set country code item according to actual dial code (e.g. `+1` can be `US` or `CA`)
|
224
|
+
const code = this.#getCountryCodeByPhoneNumber(`${val}-${this.textField.value}`);
|
225
|
+
countryCodeItem = this.#getCountryByCodeId(code);
|
131
226
|
}
|
132
|
-
|
133
|
-
|
227
|
+
|
228
|
+
// in case country code item does not exist (for example: Parsed code is CA for +1 - but Canada is not allowed)
|
229
|
+
// then use the first option with same dial code (e.g. in that case - `US` for +1)
|
230
|
+
if (!countryCodeItem) {
|
231
|
+
countryCodeItem = this.#getCountryByDialCode(val);
|
134
232
|
}
|
135
|
-
|
136
|
-
|
233
|
+
|
234
|
+
// set country code item; in it doesn't exist in list - set `undefined`
|
235
|
+
this.comboBox.selectedItem = countryCodeItem;
|
236
|
+
}
|
237
|
+
|
238
|
+
#setNationalNumber(val) {
|
239
|
+
if (this.isFormatValue) {
|
240
|
+
val = this.#formatNationalNumber(val);
|
241
|
+
}
|
242
|
+
|
243
|
+
if (this.textField.value !== val) {
|
244
|
+
this.textField.value = val;
|
137
245
|
}
|
138
|
-
return {};
|
139
246
|
}
|
140
247
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
}
|
248
|
+
#formatNationalNumber(nationalNumber = '') {
|
249
|
+
// re-initialize AsYouType if country code is outdated
|
250
|
+
if (!this.#ayt || this.#ayt.country !== this.selectedCountryCode) {
|
251
|
+
this.#ayt = new AsYouType(this.selectedCountryCode);
|
252
|
+
}
|
146
253
|
|
147
|
-
|
148
|
-
this.
|
254
|
+
// reset previous AsYouType input
|
255
|
+
this.#ayt.reset();
|
256
|
+
|
257
|
+
const formattedVal = this.#ayt.input(nationalNumber);
|
258
|
+
|
259
|
+
return formattedVal || nationalNumber;
|
149
260
|
}
|
150
261
|
|
151
|
-
|
152
|
-
const
|
153
|
-
|
262
|
+
#isValidParsedValue() {
|
263
|
+
const parsed = parsePhoneNumberFromString(this.value);
|
264
|
+
|
265
|
+
return (
|
266
|
+
parsed && // Parsed successfully (not undefined)
|
267
|
+
parsed.isValid?.() && // Parsed object is valid
|
268
|
+
parsed.country && // Parsed object with a country code
|
269
|
+
this.#isAllowedCountry(parsed.country) // Parsed with allowed country code
|
270
|
+
);
|
271
|
+
}
|
272
|
+
|
273
|
+
#isAllowedCountry(countryCode) {
|
274
|
+
if (!this.restrictCountries) {
|
275
|
+
return true;
|
276
|
+
}
|
277
|
+
|
278
|
+
return this.restrictCountries.includes(countryCode);
|
154
279
|
}
|
155
280
|
|
156
|
-
|
157
|
-
|
281
|
+
// return country item by dial code `data-id` (e.g. `+1`)
|
282
|
+
#getCountryByDialCode(dialCode) {
|
283
|
+
return this.comboBox.items?.find((c) => c.getAttribute('data-id') === dialCode) || undefined;
|
158
284
|
}
|
159
285
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
);
|
286
|
+
// return country item by country code `data-country-code` (e.g. `US`)
|
287
|
+
#getCountryByCodeId(countryCode) {
|
288
|
+
return this.comboBox.items?.find((c) => c.getAttribute('data-country-code') === countryCode);
|
164
289
|
}
|
165
290
|
|
166
|
-
|
291
|
+
#getCountryCodeByPhoneNumber(val) {
|
292
|
+
if (!val) return undefined;
|
293
|
+
const parsed = parsePhoneNumberFromString(val);
|
294
|
+
if (!parsed?.country) return undefined;
|
295
|
+
const foundCountryItem = this.#getCountryByCodeId(parsed.country);
|
296
|
+
return foundCountryItem?.getAttribute('data-country-code');
|
297
|
+
}
|
298
|
+
|
299
|
+
#updateComboBoxItems(restrictCountries) {
|
167
300
|
const items = restrictCountries.length
|
168
301
|
? CountryCodes.filter((c) => restrictCountries.includes(c.code))
|
169
302
|
: CountryCodes;
|
303
|
+
|
170
304
|
this.querySelector('descope-combo-box').innerHTML = items
|
171
305
|
.map((item) => comboBoxItem(item))
|
172
306
|
.join('');
|
173
307
|
}
|
174
308
|
|
175
|
-
handleDefaultCountryCode(countryCode) {
|
176
|
-
if (!this.
|
177
|
-
const countryCodeItem = this
|
309
|
+
#handleDefaultCountryCode(countryCode) {
|
310
|
+
if (!this.comboBox.value) {
|
311
|
+
const countryCodeItem = this.#getCountryByCodeId(countryCode);
|
178
312
|
// When replacing the input component (inserting internal component into text-field) -
|
179
313
|
// Vaadin resets the input's value. We use setTimeout in order to make sure this happens
|
180
314
|
// after the reset.
|
181
315
|
if (countryCodeItem) {
|
182
316
|
setTimeout(() => {
|
183
|
-
this.
|
317
|
+
this.comboBox.selectedItem = countryCodeItem;
|
184
318
|
});
|
185
319
|
}
|
186
320
|
}
|
187
321
|
}
|
188
322
|
|
189
|
-
|
190
|
-
|
191
|
-
this.phoneNumberInput.addEventListener('input', (e) => {
|
192
|
-
// we want to update only phoneNumberInput, and avoid triggering `set value`
|
193
|
-
e.stopPropagation();
|
323
|
+
#handleSameCountryCodes() {
|
324
|
+
if (!this.value) return;
|
194
325
|
|
195
|
-
|
196
|
-
const telDigitsRegExp = /^\d$/;
|
197
|
-
const sanitizedInput = e.target.value
|
198
|
-
.split('')
|
199
|
-
.filter((char) => telDigitsRegExp.test(char))
|
200
|
-
.join('');
|
201
|
-
e.target.value = sanitizedInput;
|
202
|
-
}
|
203
|
-
});
|
326
|
+
const country = this.#getCountryCodeByPhoneNumber(this.value);
|
204
327
|
|
205
|
-
|
206
|
-
|
328
|
+
if (!country) return;
|
329
|
+
|
330
|
+
// re-set country code if needed (same coutnry code for different countries, e.g. +1 for US or CA)
|
331
|
+
if (this.selectedCountryCode !== country) {
|
332
|
+
const foundCountryItem = this.#getCountryByCodeId(country);
|
333
|
+
// if found country is defined in country list then set it, otherwise - clear phone number
|
334
|
+
if (foundCountryItem) {
|
335
|
+
this.comboBox.selectedItem = foundCountryItem;
|
336
|
+
}
|
337
|
+
}
|
207
338
|
}
|
208
339
|
|
209
|
-
handleLabelTypeAttrs(attrName, newValue) {
|
340
|
+
#handleLabelTypeAttrs(attrName, newValue) {
|
210
341
|
// set or remove label attributes from inner text/combo components on `label-type` change
|
211
342
|
const attr = mapAttrs[attrName] || attrName;
|
212
343
|
|
213
344
|
if (attrName === 'label-type') {
|
214
|
-
this
|
345
|
+
this.#handleLabelTypeChange(newValue);
|
215
346
|
}
|
216
347
|
// on inner components label attr change - set label attributes for text/combo components
|
217
348
|
// only if label-type is `floating`
|
218
349
|
else if (this.getAttribute('label-type') === 'floating') {
|
219
350
|
if (attrName === 'country-input-label') {
|
220
|
-
this.
|
351
|
+
this.comboBox.setAttribute(attr, newValue);
|
221
352
|
} else if (attrName === 'label') {
|
222
|
-
this.
|
353
|
+
this.textField.setAttribute(attr, newValue);
|
223
354
|
}
|
224
355
|
}
|
225
356
|
}
|
226
357
|
|
227
|
-
|
358
|
+
#handleLabelTypeChange(newValue) {
|
228
359
|
if (newValue === 'floating') {
|
229
360
|
// on change to `floating` label - set inner components `label` and `placeholder`
|
230
|
-
this.
|
231
|
-
this.
|
361
|
+
this.comboBox.setAttribute('label', this.getAttribute('country-input-label') || '');
|
362
|
+
this.comboBox.setAttribute(
|
232
363
|
'placeholder',
|
233
364
|
this.getAttribute('country-input-placeholder') || ''
|
234
365
|
);
|
235
|
-
this.
|
236
|
-
this.
|
366
|
+
this.textField.setAttribute('label', this.getAttribute('label') || '');
|
367
|
+
this.textField.setAttribute(
|
237
368
|
'placeholder',
|
238
369
|
this.getAttribute('phone-input-placeholder') || ''
|
239
370
|
);
|
@@ -242,34 +373,6 @@ class PhoneFieldInternal extends BaseInputClass {
|
|
242
373
|
this.inputs.forEach((input) => input.removeAttribute('label'));
|
243
374
|
}
|
244
375
|
}
|
245
|
-
|
246
|
-
attributeChangedCallback(attrName, oldValue, newValue) {
|
247
|
-
super.attributeChangedCallback(attrName, oldValue, newValue);
|
248
|
-
|
249
|
-
if (oldValue !== newValue) {
|
250
|
-
if (attrName === 'default-code' && newValue) {
|
251
|
-
this.handleDefaultCountryCode(newValue);
|
252
|
-
} else if (inputRelatedAttrs.includes(attrName)) {
|
253
|
-
const attr = mapAttrs[attrName] || attrName;
|
254
|
-
|
255
|
-
if (commonAttrs.includes(attrName)) {
|
256
|
-
this.inputs.forEach((input) => input.setAttribute(attr, newValue));
|
257
|
-
} else if (countryAttrs.includes(attrName)) {
|
258
|
-
this.countryCodeInput.setAttribute(attr, newValue);
|
259
|
-
} else if (phoneAttrs.includes(attrName)) {
|
260
|
-
this.phoneNumberInput.setAttribute(attr, newValue);
|
261
|
-
}
|
262
|
-
}
|
263
|
-
|
264
|
-
if (labelTypeAttrs.includes(attrName)) {
|
265
|
-
this.handleLabelTypeAttrs(attrName, newValue);
|
266
|
-
}
|
267
|
-
|
268
|
-
if (attrName === 'restrict-countries') {
|
269
|
-
this.updateCountryCodeItems(this.getRestrictedCountries());
|
270
|
-
}
|
271
|
-
}
|
272
|
-
}
|
273
376
|
}
|
274
377
|
|
275
378
|
export default PhoneFieldInternal;
|
package/src/components/phone-fields/descope-phone-input-box-field/PhoneFieldInputBoxClass.js
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
import { componentName as descopeInternalComponentName } from './descope-phone-input-box-internal/PhoneFieldInternalInputBox';
|
2
2
|
import { forwardAttrs, getComponentName } from '../../../helpers/componentHelpers';
|
3
3
|
import { compose } from '../../../helpers';
|
4
|
-
import {
|
4
|
+
import {
|
5
|
+
createProxy,
|
6
|
+
createStyleMixin,
|
7
|
+
draggableMixin,
|
8
|
+
inputOverrideValidConstraintsMixin,
|
9
|
+
proxyInputMixin,
|
10
|
+
} from '../../../mixins';
|
5
11
|
import { TextFieldClass } from '../../descope-text-field/TextFieldClass';
|
6
12
|
import CountryCodes from '../CountryCodes';
|
7
13
|
import {
|
@@ -18,7 +24,7 @@ const textVars = TextFieldClass.cssVarList;
|
|
18
24
|
export const componentName = getComponentName('phone-input-box-field');
|
19
25
|
|
20
26
|
const customMixin = (superclass) =>
|
21
|
-
class
|
27
|
+
class PhoneFieldInputBoxMixinClass extends superclass {
|
22
28
|
static get CountryCodes() {
|
23
29
|
return CountryCodes;
|
24
30
|
}
|
@@ -42,8 +48,6 @@ const customMixin = (superclass) =>
|
|
42
48
|
forwardAttrs(this.shadowRoot.host, this.inputElement, {
|
43
49
|
includeAttrs: [
|
44
50
|
'size',
|
45
|
-
'bordered',
|
46
|
-
'invalid',
|
47
51
|
'minlength',
|
48
52
|
'maxlength',
|
49
53
|
'default-code',
|
@@ -52,6 +56,10 @@ const customMixin = (superclass) =>
|
|
52
56
|
'label',
|
53
57
|
'label-type',
|
54
58
|
'allow-alphanumeric-input',
|
59
|
+
'restrict-countries',
|
60
|
+
'format-value',
|
61
|
+
'strict-validation',
|
62
|
+
'data-errormessage-type-mismatch',
|
55
63
|
],
|
56
64
|
});
|
57
65
|
}
|
@@ -67,7 +75,8 @@ const {
|
|
67
75
|
inputElement,
|
68
76
|
requiredIndicator,
|
69
77
|
inputField,
|
70
|
-
|
78
|
+
internalComponent,
|
79
|
+
internalComponentAfter,
|
71
80
|
phoneInput,
|
72
81
|
errorMessage,
|
73
82
|
helperText,
|
@@ -78,8 +87,11 @@ const {
|
|
78
87
|
inputElement: { selector: 'input' },
|
79
88
|
requiredIndicator: { selector: '[required]::part(required-indicator)::after' },
|
80
89
|
inputField: { selector: () => 'vaadin-text-field::part(input-field)' },
|
81
|
-
|
82
|
-
selector:
|
90
|
+
internalComponent: {
|
91
|
+
selector: 'descope-phone-field-internal-input-box',
|
92
|
+
},
|
93
|
+
internalComponentAfter: {
|
94
|
+
selector: 'descope-phone-field-internal-input-box::after',
|
83
95
|
},
|
84
96
|
phoneInput: { selector: () => 'descope-text-field' },
|
85
97
|
helperText: { selector: '::part(helper-text)' },
|
@@ -102,14 +114,6 @@ export const PhoneFieldInputBoxClass = compose(
|
|
102
114
|
hostMinWidth: { ...host, property: 'min-width' },
|
103
115
|
hostDirection: { ...host, property: 'direction' },
|
104
116
|
|
105
|
-
inputBorderStyle: { ...inputFieldInternal, property: 'border-style' },
|
106
|
-
inputBorderWidth: { ...inputFieldInternal, property: 'border-width' },
|
107
|
-
inputBorderColor: { ...inputFieldInternal, property: 'border-color' },
|
108
|
-
inputBorderRadius: [
|
109
|
-
{ ...inputField, property: 'border-radius' },
|
110
|
-
{ ...inputFieldInternal, property: 'border-radius' },
|
111
|
-
],
|
112
|
-
|
113
117
|
inputHorizontalPadding: [
|
114
118
|
{ ...phoneInput, property: 'padding-left' },
|
115
119
|
{ ...phoneInput, property: 'padding-right' },
|
@@ -134,10 +138,18 @@ export const PhoneFieldInputBoxClass = compose(
|
|
134
138
|
|
135
139
|
inputPlaceholderTextColor: { ...phoneInput, property: textVars.inputPlaceholderColor },
|
136
140
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
+
inputBorderStyle: { ...internalComponentAfter, property: 'border-style' },
|
142
|
+
inputBorderWidth: { ...internalComponentAfter, property: 'border-width' },
|
143
|
+
inputBorderColor: { ...internalComponentAfter, property: 'border-color' },
|
144
|
+
inputBorderRadius: [
|
145
|
+
{ ...internalComponent, property: 'border-radius' },
|
146
|
+
{ ...internalComponentAfter, property: 'border-radius' },
|
147
|
+
],
|
148
|
+
|
149
|
+
inputOutlineStyle: { ...internalComponent, property: 'outline-style' },
|
150
|
+
inputOutlineColor: { ...internalComponent, property: 'outline-color' },
|
151
|
+
inputOutlineWidth: { ...internalComponent, property: 'outline-width' },
|
152
|
+
inputOutlineOffset: { ...internalComponent, property: 'outline-offset' },
|
141
153
|
|
142
154
|
labelPosition: { ...label, property: 'position' },
|
143
155
|
labelTopPosition: { ...label, property: 'top' },
|
@@ -156,6 +168,7 @@ export const PhoneFieldInputBoxClass = compose(
|
|
156
168
|
},
|
157
169
|
}),
|
158
170
|
draggableMixin,
|
171
|
+
inputOverrideValidConstraintsMixin,
|
159
172
|
proxyInputMixin({ proxyProps: ['value', 'selectionStart'] }),
|
160
173
|
customMixin
|
161
174
|
)(
|
@@ -187,7 +200,6 @@ export const PhoneFieldInputBoxClass = compose(
|
|
187
200
|
vaadin-text-field::part(input-field) {
|
188
201
|
padding: 0;
|
189
202
|
background: transparent;
|
190
|
-
overflow: hidden;
|
191
203
|
-webkit-mask-image: none;
|
192
204
|
}
|
193
205
|
descope-phone-field-internal-input-box {
|
@@ -198,14 +210,20 @@ export const PhoneFieldInputBoxClass = compose(
|
|
198
210
|
descope-phone-field-internal-input-box > div {
|
199
211
|
width: 100%;
|
200
212
|
}
|
201
|
-
descope-phone-field-internal-input-box .separator {
|
202
|
-
flex: 0;
|
203
|
-
border: none;
|
204
|
-
}
|
205
213
|
descope-phone-field-internal-input-box descope-text-field {
|
206
214
|
${textVars.inputOutlineWidth}: 0;
|
207
215
|
${textVars.inputOutlineOffset}: 0;
|
208
216
|
}
|
217
|
+
descope-phone-field-internal-input-box::after {
|
218
|
+
content: '';
|
219
|
+
position: absolute;
|
220
|
+
width: 100%;
|
221
|
+
height: 100%;
|
222
|
+
top: 0;
|
223
|
+
left: 0;
|
224
|
+
box-sizing: border-box;
|
225
|
+
pointer-events: none;
|
226
|
+
}
|
209
227
|
descope-text-field {
|
210
228
|
flex-grow: 1;
|
211
229
|
width: 100%;
|