No notes defined.
<div class="sds-input sds-inputPhone js-input-phone-intl">
<label for="input-phone-intl" class="sds-label -labelForm">
Phone number
</label>
<input type="tel" id="input-phone-intl" class="form-control" placeholder="phone number" value="" autocomplete="tel" />
</div>
<div class="{{ namespace }}input{% for mod in parentModifiers %} {{ mod }}{% endfor %}{% for mod in parentClasses %} {{ mod }}{% endfor %} js-input-phone-intl">
{% render "@label--form", {
classes: [namespace+"inputPhone__label"],
labelFor: labelFor,
text: labelText or "Phone number",
modifiers: labelModifiers,
classes: labelClasses
}, true %}
<input type="tel"
id="{{ labelFor }}"
class="form-control{% for mod in modifiers %} {{ mod }}{% endfor %}{% for mod in classes %} {{ mod }}{% endfor %}"
placeholder="{{ placeholder }}"
value="{{ value }}"
{%- if hint or error %} aria-describedby="{% if hint %}{{ hintID }}{% endif%}{% if error %} {{ errorID }}{% endif %}"{% endif -%}
{%- if autocomplete %} autocomplete="{{ autocomplete }}"{% endif %}{% if disabled %} disabled{% endif -%}
{%- if readonly %} readonly{% endif -%} />
{% if error %}
<div class="invalid-feedback" role="alert">
{% render "@hint--error", {
text: "Error in entered value",
attrs: {
"id": errorID
}
}, true %}
</div>
{% endif %}
{% if hint %}
<div class="{{ namespace }}input__hint">
{% render "@hint", {
text: "Expected format: 123 456 789",
attrs: {
"id": hintID
}
}, true %}
</div>
{% endif %}
</div>
import intlTelInput from "intl-tel-input";
export default class InputPhoneIntl {
constructor() {
this.phoneInputs = document.querySelectorAll('.js-input-phone-intl input');
this.instances = [];
this.initPhoneInputs();
}
initPhoneInputs() {
if (!this.phoneInputs.length) return;
this.phoneInputs.forEach((input) => {
const iti = intlTelInput(input, {
initialCountry: "lu",
countryOrder: ["lu","de","fr","be"],
loadUtils: () => import("intl-tel-input/utils"),
separateDialCode: true
});
this.instances.push({
input,
instance: iti
});
});
}
getNumber(inputElement) {
const item = this.instances.find(i => i.input === inputElement);
return item ? item.instance.getNumber() : null;
}
isValid(inputElement) {
const item = this.instances.find(i => i.input === inputElement);
return item ? item.instance.isValidNumber() : false;
}
}
/* variables specific to current element */
$element-specific-variables: "";
.#{$namespace}inputPhone {
/* Save root element context for easy access if nesting is needed */
$self: &;
/* properties of current element + media queries */
/* Pseudo Elements */
&::before {
}
&::after {
}
/*
Include elements that are linked to the current element but have to reside at the root level of the stylesheet
(e.g: keyframes)
*/
@at-root {
}
/* children - write selector in full in comments in order to facilitate search */
&:has(INPUT.is-invalid) {
.invalid-feedback {
display: block;
}
}
/* modifiers */
// inputPhone.-modifier
/* random parent element */
/*
*
* Syntax : .randomParentElt & {}
*
*/
/* Pseudo Classes */
&:hover {
@media (hover: hover) {
}
}
&:focus {
}
&:active {
}
&:focus,
&:active {
}
}