@asante-org/atlascopco-vt-litesitegenerator 3.0.1 → 3.0.2
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/index.esm.js +250 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.scss +84 -6
- package/dist/index.js +250 -4
- package/dist/index.js.map +1 -1
- package/dist/index.scss +84 -6
- package/dist/src/components/lsg/LsgFormFieldTel/LsgFormFieldTel.d.ts +2 -0
- package/dist/src/components/lsg/LsgFormFieldTel/LsgFormFieldTel.stories.d.ts +2 -0
- package/dist/src/components/lsg/index.d.ts +1 -0
- package/dist/src/components/lsg/telPicker/index.d.ts +1 -0
- package/dist/src/components/lsg/telPicker/telPicker.d.ts +12 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/themes/theme-1/components.d.ts +1 -0
- package/dist/src/themes/theme-2/components.d.ts +1 -0
- package/dist/src/themes/theme-3/components.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useRef, useId, useEffect } from 'react';
|
|
1
|
+
import React, { useState, useRef, useId, useEffect, useMemo, forwardRef, useCallback, useImperativeHandle } from 'react';
|
|
2
2
|
|
|
3
3
|
function _extends() {
|
|
4
4
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
@@ -1438,6 +1438,238 @@ var LsgFormFieldEmail = function (_a) {
|
|
|
1438
1438
|
}, error));
|
|
1439
1439
|
};
|
|
1440
1440
|
|
|
1441
|
+
var M=[["Afghanistan","af","93"],["Albania","al","355"],["Algeria","dz","213"],["Andorra","ad","376"],["Angola","ao","244"],["Antigua and Barbuda","ag","1268"],["Argentina","ar","54",{default:"(..) .... ....","/^11/":"(..) .... ....","/^15/":"(..) ... ....","/^(2|3|4|5)/":"(.) .... ....","/^9/":"(.) .... ....."},0],["Armenia","am","374",".. ......"],["Aruba","aw","297"],["Australia","au","61",{default:". .... ....","/^4/":"... ... ...","/^5(?!50)/":"... ... ...","/^1(3|8)00/":".... ... ...","/^13/":".. .. ..","/^180/":"... ...."},0,[]],["Austria","at","43"],["Azerbaijan","az","994","(..) ... .. .."],["Bahamas","bs","1242"],["Bahrain","bh","973",".... ...."],["Bangladesh","bd","880"],["Barbados","bb","1246"],["Belarus","by","375","(..) ... .. .."],["Belgium","be","32","... .. .. .."],["Belize","bz","501"],["Benin","bj","229"],["Bhutan","bt","975"],["Bolivia","bo","591"],["Bosnia and Herzegovina","ba","387"],["Botswana","bw","267"],["Brazil","br","55","(..) .....-...."],["British Indian Ocean Territory","io","246"],["Brunei","bn","673"],["Bulgaria","bg","359"],["Burkina Faso","bf","226"],["Burundi","bi","257"],["Cambodia","kh","855"],["Cameroon","cm","237"],["Canada","ca","1","(...) ...-....",1,["204","226","236","249","250","289","306","343","365","387","403","416","418","431","437","438","450","506","514","519","548","579","581","587","604","613","639","647","672","705","709","742","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde","cv","238"],["Caribbean Netherlands","bq","599","",1],["Cayman Islands","ky","1","... ... ....",4,["345"]],["Central African Republic","cf","236"],["Chad","td","235"],["Chile","cl","56"],["China","cn","86","... .... ...."],["Colombia","co","57","... ... ...."],["Comoros","km","269"],["Congo","cd","243"],["Congo","cg","242"],["Costa Rica","cr","506","....-...."],["C\xF4te d'Ivoire","ci","225",".. .. .. .. .."],["Croatia","hr","385"],["Cuba","cu","53"],["Cura\xE7ao","cw","599","",0],["Cyprus","cy","357",".. ......"],["Czech Republic","cz","420","... ... ..."],["Denmark","dk","45",".. .. .. .."],["Djibouti","dj","253",".. .. ...."],["Dominica","dm","1767"],["Dominican Republic","do","1","(...) ...-....",2,["809","829","849"]],["Ecuador","ec","593"],["Egypt","eg","20"],["El Salvador","sv","503","....-...."],["Equatorial Guinea","gq","240"],["Eritrea","er","291"],["Estonia","ee","372",".... ......"],["Ethiopia","et","251",".. ... ...."],["Faroe Islands","fo","298",".. .. .."],["Fiji","fj","679"],["Finland","fi","358",".. ... .. .."],["France","fr","33",". .. .. .. .."],["French Guiana","gf","594","... .. .. .."],["French Polynesia","pf","689",{"/^44/":".. .. ..","/^80[0-5]/":"... .. .. ..",default:".. .. .. .."}],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia","ge","995"],["Germany","de","49","... ........."],["Ghana","gh","233"],["Gibraltar","gi","350"],["Greece","gr","30"],["Greenland","gl","299",".. .. .."],["Grenada","gd","1473"],["Guadeloupe","gp","590","... .. .. ..",0],["Guam","gu","1671"],["Guatemala","gt","502","....-...."],["Guinea","gn","224"],["Guinea-Bissau","gw","245"],["Guyana","gy","592"],["Haiti","ht","509","....-...."],["Honduras","hn","504"],["Hong Kong","hk","852",".... ...."],["Hungary","hu","36"],["Iceland","is","354","... ...."],["India","in","91",".....-....."],["Indonesia","id","62"],["Iran","ir","98","... ... ...."],["Iraq","iq","964"],["Ireland","ie","353",".. ......."],["Israel","il","972","... ... ...."],["Italy","it","39","... .......",0],["Jamaica","jm","1876"],["Japan","jp","81",".. .... ...."],["Jordan","jo","962"],["Kazakhstan","kz","7","... ...-..-..",0],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait","kw","965",".... ...."],["Kyrgyzstan","kg","996","... ... ..."],["Laos","la","856"],["Latvia","lv","371",".. ... ..."],["Lebanon","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya","ly","218"],["Liechtenstein","li","423"],["Lithuania","lt","370"],["Luxembourg","lu","352"],["Macau","mo","853"],["Macedonia","mk","389"],["Madagascar","mg","261"],["Malawi","mw","265"],["Malaysia","my","60","..-....-...."],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596","... .. .. .."],["Mauritania","mr","222"],["Mauritius","mu","230"],["Mayotte","yt","262","... .. .. ..",1,["269","639"]],["Mexico","mx","52","... ... ....",0],["Micronesia","fm","691"],["Moldova","md","373","(..) ..-..-.."],["Monaco","mc","377"],["Mongolia","mn","976"],["Montenegro","me","382"],["Morocco","ma","212"],["Mozambique","mz","258"],["Myanmar","mm","95"],["Namibia","na","264"],["Nauru","nr","674"],["Nepal","np","977"],["Netherlands","nl","31",{"/^06/":"(.). .........","/^6/":". .........","/^0(10|13|14|15|20|23|24|26|30|33|35|36|38|40|43|44|45|46|50|53|55|58|70|71|72|73|74|75|76|77|78|79|82|84|85|87|88|91)/":"(.).. ........","/^(10|13|14|15|20|23|24|26|30|33|35|36|38|40|43|44|45|46|50|53|55|58|70|71|72|73|74|75|76|77|78|79|82|84|85|87|88|91)/":".. ........","/^0/":"(.)... .......",default:"... ......."}],["New Caledonia","nc","687"],["New Zealand","nz","64","...-...-...."],["Nicaragua","ni","505"],["Niger","ne","227"],["Nigeria","ng","234"],["North Korea","kp","850"],["Norway","no","47","... .. ..."],["Oman","om","968",".... ...."],["Pakistan","pk","92","...-......."],["Palau","pw","680"],["Palestine","ps","970"],["Panama","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru","pe","51"],["Philippines","ph","63","... ... ...."],["Poland","pl","48","...-...-..."],["Portugal","pt","351"],["Puerto Rico","pr","1","(...) ...-....",3,["787","939"]],["Qatar","qa","974",".... ...."],["R\xE9union","re","262","... .. .. ..",0],["Romania","ro","40"],["Russia","ru","7","(...) ...-..-..",1],["Rwanda","rw","250"],["Saint Kitts and Nevis","kn","1869"],["Saint Lucia","lc","1758"],["Saint Pierre & Miquelon","pm","508",{"/^708/":"... ... ...","/^8/":"... .. .. ..",default:".. .. .."}],["Saint Vincent and the Grenadines","vc","1784"],["Samoa","ws","685"],["San Marino","sm","378"],["S\xE3o Tom\xE9 and Pr\xEDncipe","st","239"],["Saudi Arabia","sa","966",".. ... ...."],["Senegal","sn","221"],["Serbia","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65","....-...."],["Slovakia","sk","421"],["Slovenia","si","386"],["Solomon Islands","sb","677"],["Somalia","so","252"],["South Africa","za","27"],["South Korea","kr","82","... .... ...."],["South Sudan","ss","211"],["Spain","es","34","... ... ..."],["Sri Lanka","lk","94"],["Sudan","sd","249"],["Suriname","sr","597"],["Swaziland","sz","268"],["Sweden","se","46","... ... ..."],["Switzerland","ch","41",".. ... .. .."],["Syria","sy","963"],["Taiwan","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tonga","to","676"],["Trinidad and Tobago","tt","1868"],["Tunisia","tn","216"],["Turkey","tr","90","... ... .. .."],["Turkmenistan","tm","993"],["Tuvalu","tv","688"],["Uganda","ug","256"],["Ukraine","ua","380","(..) ... .. .."],["United Arab Emirates","ae","971",{default:".. ... ....","/^5[024568]/":".. ... ....","/^[234679]/":". ... ...."}],["United Kingdom","gb","44",".... ......"],["United States","us","1","(...) ...-....",0],["Uruguay","uy","598"],["Uzbekistan","uz","998",".. ... .. .."],["Vanuatu","vu","678"],["Vatican City","va","39",".. .... ....",1],["Venezuela","ve","58"],["Vietnam","vn","84"],["Wallis & Futuna","wf","681",".. .. .."],["Yemen","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"]];var Ne="react-international-phone-",de=(...t)=>t.filter(e=>!!e).join(" ").trim(),Me=(...t)=>de(...t).split(" ").map(e=>`${Ne}${e}`).join(" "),S=({addPrefix:t,rawClassNames:e})=>de(Me(...t),...e);var ce=({value:t,mask:e,maskSymbol:n,offset:s=0,trimNonMaskCharsLeftover:r=false,allowMaskOverflow:a=false})=>{if(t.length<s)return t;let p=t.slice(0,s),i=t.slice(s),o=e.split("").filter(d=>d===n).length,u=i.slice(0,o),l=a?i.slice(o):"",m=p,y=0;for(let d of e.split("")){if(y>=u.length){if(!r&&d!==n){m+=d;continue}break}d===n?(m+=u[y],y+=1):m+=d;}return m+l};var O=t=>t?/^\d+$/.test(t):false;var V=t=>t.replace(/\D/g,"");var pe=(t,e)=>{let n=t.style.display;n!=="block"&&(t.style.display="block");let s=t.getBoundingClientRect(),r=e.getBoundingClientRect(),a=r.top-s.top,p=s.bottom-r.bottom;a>=0&&p>=0||(Math.abs(a)<Math.abs(p)?t.scrollTop+=a:t.scrollTop-=p),t.style.display=n;};var me=()=>typeof window>"u"?false:window.navigator.userAgent.toLowerCase().includes("macintosh");var Ce=(t,e)=>{let n=e.disableDialCodeAndPrefix?false:e.forceDialCode,s=e.disableDialCodeAndPrefix?false:e.insertDialCodeOnEmpty,r=t,a=u=>e.trimNonDigitsEnd?u.trim():u;if(!r)return s&&!r.length||n?a(`${e.prefix}${e.dialCode}${e.charAfterDialCode}`):a(r);if(r=V(r),r===e.dialCode&&!e.disableDialCodeAndPrefix)return a(`${e.prefix}${e.dialCode}${e.charAfterDialCode}`);if(e.dialCode.startsWith(r)&&!e.disableDialCodeAndPrefix)return a(n?`${e.prefix}${e.dialCode}${e.charAfterDialCode}`:`${e.prefix}${r}`);if(!r.startsWith(e.dialCode)&&!e.disableDialCodeAndPrefix){if(n)return a(`${e.prefix}${e.dialCode}${e.charAfterDialCode}`);if(r.length<e.dialCode.length)return a(`${e.prefix}${r}`)}let p=()=>{let u=e.dialCode.length,l=r.slice(0,u),m=r.slice(u);return {phoneLeftSide:l,phoneRightSide:m}},{phoneLeftSide:i,phoneRightSide:o}=p();return i=`${e.prefix}${i}${e.charAfterDialCode}`,o=ce({value:o,mask:e.mask,maskSymbol:e.maskChar,trimNonMaskCharsLeftover:e.trimNonDigitsEnd||e.disableDialCodeAndPrefix&&o.length===0,allowMaskOverflow:e.allowMaskOverflow}),e.disableDialCodeAndPrefix&&(i=""),a(`${i}${o}`)};var he=({phoneBeforeInput:t,phoneAfterInput:e,phoneAfterFormatted:n,cursorPositionAfterInput:s,leftOffset:r=0,deletion:a})=>{if(s<r)return r;if(!t)return n.length;let p=null;for(let l=s-1;l>=0;l-=1)if(O(e[l])){p=l;break}if(p===null){for(let l=0;l<e.length;l+=1)if(O(n[l]))return l;return e.length}let i=0;for(let l=0;l<p;l+=1)O(e[l])&&(i+=1);let o=0,u=0;for(let l=0;l<n.length&&(o+=1,O(n[l])&&(u+=1),!(u>=i+1));l+=1);if(a!=="backward")for(;!O(n[o])&&o<n.length;)o+=1;return o};var G=({phone:t,prefix:e})=>t?`${e}${V(t)}`:"";function W({value:t,country:e,insertDialCodeOnEmpty:n,trimNonDigitsEnd:s,countries:r,prefix:a,charAfterDialCode:p,forceDialCode:i,disableDialCodeAndPrefix:o,defaultMask:u,countryGuessingEnabled:l,disableFormatting:m,allowMaskOverflow:y}){let d=t;o&&(d=d.startsWith(`${a}`)?d:`${a}${e.dialCode}${d}`);let w=l?ee({phone:d,countries:r,currentCountryIso2:e?.iso2}):void 0,f=w?.country??e,v=Ce(d,{prefix:a,mask:Y({phone:d,country:f,defaultMask:u,disableFormatting:m}),maskChar:J,dialCode:f.dialCode,trimNonDigitsEnd:s,charAfterDialCode:p,forceDialCode:i,insertDialCodeOnEmpty:n,disableDialCodeAndPrefix:o,allowMaskOverflow:y}),g=l&&!w?.fullDialCodeMatch?e:f;return {phone:G({phone:o?`${g.dialCode}${v}`:v,prefix:a}),inputValue:v,country:g}}var _e=t=>{if(t?.toLocaleLowerCase().includes("delete")??false)return t?.toLocaleLowerCase().includes("forward")?"forward":"backward"},ye=(t,{country:e,insertDialCodeOnEmpty:n,phoneBeforeInput:s,prefix:r,charAfterDialCode:a,forceDialCode:p,disableDialCodeAndPrefix:i,countryGuessingEnabled:o,defaultMask:u,disableFormatting:l,countries:m,allowMaskOverflow:y})=>{let d=t.nativeEvent,w=d.inputType,f=_e(w),v=!!w?.startsWith("insertFrom"),g=w==="insertText",D=d?.data||void 0,I=t.target.value,_=t.target.selectionStart??0;if(w?.includes("history"))return {inputValue:s,phone:G({phone:s,prefix:r}),cursorPosition:s.length,country:e};if(g&&!O(D)&&I!==r)return {inputValue:s,phone:G({phone:i?`${e.dialCode}${s}`:s,prefix:r}),cursorPosition:_-(D?.length??0),country:e};if(p&&!I.startsWith(`${r}${e.dialCode}`)&&!v){let b=I?s:`${r}${e.dialCode}${a}`;return {inputValue:b,phone:G({phone:b,prefix:r}),cursorPosition:r.length+e.dialCode.length+a.length,country:e}}let{phone:c,inputValue:C,country:h}=W({value:I,country:e,trimNonDigitsEnd:f==="backward",insertDialCodeOnEmpty:n,countryGuessingEnabled:o,countries:m,prefix:r,charAfterDialCode:a,forceDialCode:p,disableDialCodeAndPrefix:i,disableFormatting:l,defaultMask:u,allowMaskOverflow:y}),P=he({cursorPositionAfterInput:_,phoneBeforeInput:s,phoneAfterInput:I,phoneAfterFormatted:C,leftOffset:p?r.length+e.dialCode.length+a.length:0,deletion:f});return {phone:c,inputValue:C,cursorPosition:P,country:h}};var ge=(t,e)=>{let n=Object.keys(t),s=Object.keys(e);if(n.length!==s.length)return false;for(let r of n)if(t[r]!==e[r])return false;return true};var we=()=>{let t=useRef(),e=useRef(Date.now()),n=useCallback(()=>{let s=Date.now(),r=t.current?s-e.current:void 0;return t.current=e.current,e.current=s,r},[]);return useMemo(()=>({check:n}),[n])};var Le={size:20,overrideLastItemDebounceMS:-1};function Pe(t,e){let{size:n,overrideLastItemDebounceMS:s,onChange:r}={...Le,...e},[a,p]=useState(t),i=useRef([a]),o=useRef(0),u=we(),l=useCallback((d,w)=>{let f=i.current[o.current];if(d===f||typeof d=="object"&&typeof f=="object"&&ge(d,f))return;let v=s>0,g=u.check(),E=v&&g!==void 0?g>s:true;if(w?.overrideLastItem!==void 0?w.overrideLastItem:!E)i.current=[...i.current.slice(0,o.current),d];else {let I=i.current.length>=n;i.current=[...i.current.slice(I?1:0,o.current+1),d],I||(o.current+=1);}p(d),r?.(d);},[r,s,n,u]),m=useCallback(()=>{if(o.current<=0)return {success:false};let d=i.current[o.current-1];return p(d),o.current-=1,r?.(d),{success:true,value:d}},[r]),y=useCallback(()=>{if(o.current+1>=i.current.length)return {success:false};let d=i.current[o.current+1];return p(d),o.current+=1,r?.(d),{success:true,value:d}},[r]);return [a,l,m,y]}var J=".",R={defaultCountry:"us",value:"",prefix:"+",defaultMask:"............",charAfterDialCode:" ",historySaveDebounceMS:200,disableCountryGuess:false,disableDialCodePrefill:false,forceDialCode:false,disableDialCodeAndPrefix:false,disableFormatting:false,allowMaskOverflow:false,countries:M},oe=({defaultCountry:t=R.defaultCountry,value:e=R.value,countries:n=R.countries,prefix:s=R.prefix,defaultMask:r=R.defaultMask,charAfterDialCode:a=R.charAfterDialCode,historySaveDebounceMS:p=R.historySaveDebounceMS,disableCountryGuess:i=R.disableCountryGuess,disableDialCodePrefill:o=R.disableDialCodePrefill,forceDialCode:u=R.forceDialCode,disableDialCodeAndPrefix:l=R.disableDialCodeAndPrefix,disableFormatting:m=R.disableFormatting,allowMaskOverflow:y=R.allowMaskOverflow,onChange:d,inputRef:w})=>{let g={countries:n,prefix:s,charAfterDialCode:a,forceDialCode:l?false:u,disableDialCodeAndPrefix:l,defaultMask:r,countryGuessingEnabled:!i,disableFormatting:m,allowMaskOverflow:y},E=useRef(null),D=w||E,I=x=>{Promise.resolve().then(()=>{typeof window>"u"||D.current!==document?.activeElement||D.current?.setSelectionRange(x,x);});},_=useCallback(x=>z({value:x,field:"iso2",countries:n}),[n]),c=useCallback(({inputValue:x,phone:T,country:k})=>{if(!d)return;let F=_(k);d({phone:T,inputValue:x,country:F});},[_,d]),[{phone:C,inputValue:h,country:P},b,L,$]=Pe(()=>{let x=z({value:t,field:"iso2",countries:n});x||console.error(`[react-international-phone]: can not find a country with "${t}" iso2 code`);let T=x||z({value:"us",field:"iso2",countries:n}),{phone:k,inputValue:F,country:U}=W({value:e,country:T,insertDialCodeOnEmpty:!o,...g});return I(F.length),{phone:k,inputValue:F,country:U.iso2}},{overrideLastItemDebounceMS:p,onChange:c}),A=useMemo(()=>_(P),[P,_]);useEffect(()=>{let x=D.current;if(!x)return;let T=k=>{if(!k.key)return;let F=k.ctrlKey,U=k.metaKey,Ie=k.shiftKey;if(k.key.toLowerCase()==="z"){if(me()){if(!U)return}else if(!F)return;Ie?$():L();}};return x.addEventListener("keydown",T),()=>{x.removeEventListener("keydown",T);}},[D,L,$]);let K=x=>{x.preventDefault();let{phone:T,inputValue:k,country:F,cursorPosition:U}=ye(x,{country:A,phoneBeforeInput:h,insertDialCodeOnEmpty:false,...g});return b({inputValue:k,phone:T,country:F.iso2}),I(U),e},Q=useCallback((x,T={focusOnInput:false})=>{let k=z({value:x,field:"iso2",countries:n});if(!k){console.error(`[react-international-phone]: can not find a country with "${x}" iso2 code`);return}let F=l?"":`${s}${k.dialCode}${a}`;b({inputValue:F,phone:`${s}${k.dialCode}`,country:k.iso2}),T.focusOnInput&&Promise.resolve().then(()=>{D.current?.focus();});},[n,l,s,a,b,D]),[X,j]=useState(false);return useEffect(()=>{if(!X){j(true),e!==C&&d?.({inputValue:h,phone:C,country:A});return}if(e===C)return;let{phone:x,inputValue:T,country:k}=W({value:e,country:A,insertDialCodeOnEmpty:!o,...g});b({phone:x,inputValue:T,country:k.iso2});},[e]),{phone:C,inputValue:h,country:A,setCountry:Q,handlePhoneValueChange:K,inputRef:D}};var Y=({phone:t,country:e,defaultMask:n="............",disableFormatting:s=false})=>{let r=e.format,a=i=>s?i.replace(new RegExp(`[^${J}]`,"g"),""):i;if(!r)return a(n);if(typeof r=="string")return a(r);if(!r.default)return console.error(`[react-international-phone]: default mask for ${e.iso2} is not provided`),a(n);let p=Object.keys(r).find(i=>{if(i==="default")return false;if(!(i.charAt(0)==="/"&&i.charAt(i.length-1)==="/"))return console.error(`[react-international-phone]: format regex "${i}" for ${e.iso2} is not valid`),false;let u=new RegExp(i.substring(1,i.length-1)),l=t.replace(e.dialCode,"");return u.test(V(l))});return a(p?r[p]:r.default)};var N=t=>{let[e,n,s,r,a,p]=t;return {name:e,iso2:n,dialCode:s,format:r,priority:a,areaCodes:p}};var Oe=t=>`Field "${t}" is not supported`,z=({field:t,value:e,countries:n=M})=>{if(["priority"].includes(t))throw new Error(Oe(t));let s=n.find(r=>{let a=N(r);return e===a[t]});if(s)return N(s)};var ee=({phone:t,countries:e=M,currentCountryIso2:n})=>{let s={country:void 0,fullDialCodeMatch:false};if(!t)return s;let r=V(t);if(!r)return s;let a=s,p=({country:i,fullDialCodeMatch:o})=>{let u=i.dialCode===a.country?.dialCode,l=(i.priority??0)<(a.country?.priority??0);(!u||l)&&(a={country:i,fullDialCodeMatch:o});};for(let i of e){let o=N(i),{dialCode:u,areaCodes:l}=o;if(r.startsWith(u)){let m=a.country?Number(u)>=Number(a.country.dialCode):true;if(l){let y=r.substring(u.length);for(let d of l)if(y.startsWith(d))return {country:o,fullDialCodeMatch:true}}(m||u===r||!a.fullDialCodeMatch)&&p({country:o,fullDialCodeMatch:true});}a.fullDialCodeMatch||r.length<u.length&&u.startsWith(r)&&(!a.country||Number(u)<=Number(a.country.dialCode))&&p({country:o,fullDialCodeMatch:false});}if(n){let i=z({value:n,field:"iso2",countries:e});if(!i)return a;let u=i?(m=>{if(!m?.areaCodes)return false;let y=r.substring(m.dialCode.length);return m.areaCodes.some(d=>d.startsWith(y))})(i):false;!!a&&a.country?.dialCode===i.dialCode&&a.country!==i&&a.fullDialCodeMatch&&(!i.areaCodes||u)&&(a={country:i,fullDialCodeMatch:true});}return a};var Ve=(t,e)=>{let n=parseInt(t,16);return Number(n+e).toString(16)},He="abcdefghijklmnopqrstuvwxyz",je="1f1e6",De=He.split("").reduce((t,e,n)=>({...t,[e]:Ve(je,n)}),{}),Be=t=>[De[t[0]],De[t[1]]].join("-"),q=({iso2:t,size:e,src:n,protocol:s="https",disableLazyLoading:r,className:a,style:p,...i})=>{if(!t)return React.createElement("img",{className:S({addPrefix:["flag-emoji"],rawClassNames:[a]}),width:e,height:e,...i});let o=()=>{if(n)return n;let u=Be(t);return `${s}://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${u}.svg`};return React.createElement("img",{className:S({addPrefix:["flag-emoji"],rawClassNames:[a]}),src:o(),width:e,height:e,draggable:false,"data-country":t,loading:r?void 0:"lazy",style:{width:e,height:e,...p},alt:"",...i})};var Ue=1e3,se=({show:t,dialCodePrefix:e="+",selectedCountry:n,countries:s=M,preferredCountries:r=[],flags:a,onSelect:p,onClose:i,...o})=>{let u=useRef(null),l=useRef(),m=useMemo(()=>{if(!r||!r.length)return s;let c=[],C=[...s];for(let h of r){let P=C.findIndex(b=>N(b).iso2===h);if(P!==-1){let b=C.splice(P,1)[0];c.push(b);}}return c.concat(C)},[s,r]),y=useRef({updatedAt:void 0,value:""}),d=c=>{let C=y.current.updatedAt&&new Date().getTime()-y.current.updatedAt.getTime()>Ue;y.current={value:C?c:`${y.current.value}${c}`,updatedAt:new Date};let h=m.findIndex(P=>N(P).name.toLowerCase().startsWith(y.current.value));h!==-1&&v(h);},w=useCallback(c=>m.findIndex(C=>N(C).iso2===c),[m]),[f,v]=useState(w(n)),g=()=>{l.current!==n&&v(w(n));},E=useCallback(c=>{v(w(c.iso2)),p?.(c);},[p,w]),D=c=>{let C=m.length-1,h=P=>c==="prev"?P-1:c==="next"?P+1:c==="last"?C:0;v(P=>{let b=h(P);return b<0?0:b>C?C:b});},I=c=>{if(c.stopPropagation(),c.key==="Enter"){c.preventDefault();let C=N(m[f]);E(C);return}if(c.key==="Escape"){i?.();return}if(c.key==="ArrowUp"){c.preventDefault(),D("prev");return}if(c.key==="ArrowDown"){c.preventDefault(),D("next");return}if(c.key==="PageUp"){c.preventDefault(),D("first");return}if(c.key==="PageDown"){c.preventDefault(),D("last");return}c.key===" "&&c.preventDefault(),c.key.length===1&&!c.altKey&&!c.ctrlKey&&!c.metaKey&&d(c.key.toLocaleLowerCase());},_=useCallback(()=>{if(!u.current||f===void 0)return;let c=N(m[f]).iso2;if(c===l.current)return;let C=u.current.querySelector(`[data-country="${c}"]`);C&&(pe(u.current,C),l.current=c);},[f,m]);return useEffect(()=>{_();},[f,_]),useEffect(()=>{u.current&&(t?u.current.focus():g());},[t]),useEffect(()=>{g();},[n]),React.createElement("ul",{ref:u,role:"listbox",className:S({addPrefix:["country-selector-dropdown"],rawClassNames:[o.className]}),style:{display:t?"block":"none",...o.style},onKeyDown:I,onBlur:i,tabIndex:-1,"aria-activedescendant":`react-international-phone__${N(m[f]).iso2}-option`},m.map((c,C)=>{let h=N(c),P=h.iso2===n,b=C===f,L=r.includes(h.iso2),$=C===r.length-1,A=a?.find(K=>K.iso2===h.iso2);return React.createElement(React.Fragment,{key:h.iso2},React.createElement("li",{"data-country":h.iso2,role:"option","aria-selected":P,"aria-label":`${h.name} ${e}${h.dialCode}`,id:`react-international-phone__${h.iso2}-option`,className:S({addPrefix:["country-selector-dropdown__list-item",L&&"country-selector-dropdown__list-item--preferred",P&&"country-selector-dropdown__list-item--selected",b&&"country-selector-dropdown__list-item--focused"],rawClassNames:[o.listItemClassName,L&&o.listItemPreferredClassName,P&&o.listItemSelectedClassName,b&&o.listItemFocusedClassName]}),onClick:()=>E(h),style:o.listItemStyle,title:h.name},React.createElement(q,{iso2:h.iso2,src:A?.src,className:S({addPrefix:["country-selector-dropdown__list-item-flag-emoji"],rawClassNames:[o.listItemFlagClassName]}),style:o.listItemFlagStyle}),React.createElement("span",{className:S({addPrefix:["country-selector-dropdown__list-item-country-name"],rawClassNames:[o.listItemCountryNameClassName]}),style:o.listItemCountryNameStyle},h.name),React.createElement("span",{className:S({addPrefix:["country-selector-dropdown__list-item-dial-code"],rawClassNames:[o.listItemDialCodeClassName]}),style:o.listItemDialCodeStyle},e,h.dialCode)),$?React.createElement("hr",{className:S({addPrefix:["country-selector-dropdown__preferred-list-divider"],rawClassNames:[o.preferredListDividerClassName]}),style:o.preferredListDividerStyle}):null)}))};var le=React.memo(({selectedCountry:t,onSelect:e,disabled:n,hideDropdown:s,countries:r=M,preferredCountries:a=[],flags:p,renderButtonWrapper:i,...o})=>{let[u,l]=useState(false),m=useMemo(()=>{if(t)return z({value:t,field:"iso2",countries:r})},[r,t]),y=useRef(null),d=f=>{f.key&&["ArrowUp","ArrowDown"].includes(f.key)&&(f.preventDefault(),l(true));},w=()=>{let f={title:m?.name,onClick:()=>l(g=>!g),onMouseDown:g=>g.preventDefault(),onKeyDown:d,disabled:s||n,role:"combobox","aria-label":"Country selector","aria-haspopup":"listbox","aria-expanded":u},v=React.createElement("div",{className:S({addPrefix:["country-selector-button__button-content"],rawClassNames:[o.buttonContentWrapperClassName]}),style:o.buttonContentWrapperStyle},React.createElement(q,{iso2:t,src:p?.find(g=>g.iso2===t)?.src,className:S({addPrefix:["country-selector-button__flag-emoji",n&&"country-selector-button__flag-emoji--disabled"],rawClassNames:[o.flagClassName]}),style:{visibility:t?"visible":"hidden",...o.flagStyle}}),!s&&React.createElement("div",{className:S({addPrefix:["country-selector-button__dropdown-arrow",n&&"country-selector-button__dropdown-arrow--disabled",u&&"country-selector-button__dropdown-arrow--active"],rawClassNames:[o.dropdownArrowClassName]}),style:o.dropdownArrowStyle}));return i?i({children:v,rootProps:f}):React.createElement("button",{...f,type:"button",className:S({addPrefix:["country-selector-button",u&&"country-selector-button--active",n&&"country-selector-button--disabled",s&&"country-selector-button--hide-dropdown"],rawClassNames:[o.buttonClassName]}),"data-country":t,style:o.buttonStyle},v)};return React.createElement("div",{className:S({addPrefix:["country-selector"],rawClassNames:[o.className]}),style:o.style,ref:y},w(),React.createElement(se,{show:u,countries:r,preferredCountries:a,flags:p,onSelect:f=>{l(false),e?.(f);},selectedCountry:t,onClose:()=>{l(false);},...o.dropdownStyleProps}))});var ue=({dialCode:t,prefix:e,disabled:n,style:s,className:r})=>React.createElement("div",{className:S({addPrefix:["dial-code-preview",n&&"dial-code-preview--disabled"],rawClassNames:[r]}),style:s},`${e}${t}`);forwardRef(({value:t,onChange:e,countries:n=M,preferredCountries:s,hideDropdown:r,showDisabledDialCodeAndPrefix:a,disableFocusAfterCountrySelect:p,flags:i,style:o,className:u,inputStyle:l,inputClassName:m,countrySelectorStyleProps:y,dialCodePreviewStyleProps:d,inputProps:w,placeholder:f,disabled:v,name:g,onFocus:E,onBlur:D,required:I,autoFocus:_,...c},C)=>{let h=useCallback(j=>{e?.(j.phone,{country:j.country,inputValue:j.inputValue});},[e]),{phone:P,inputValue:b,inputRef:L,country:$,setCountry:A,handlePhoneValueChange:K}=oe({value:t,countries:n,...c,onChange:h}),Q=c.disableDialCodeAndPrefix&&a&&$?.dialCode,X=useCallback(j=>{A(j.iso2,{focusOnInput:!p});},[A,p]);return useImperativeHandle(C,()=>L.current?Object.assign(L.current,{setCountry:A,state:{phone:P,inputValue:b,country:$}}):null,[L,A,P,b,$]),React.createElement("div",{ref:C,className:S({addPrefix:["input-container"],rawClassNames:[u]}),style:o},React.createElement(le,{onSelect:X,flags:i,selectedCountry:$?.iso2,countries:n,preferredCountries:s,disabled:v,hideDropdown:r,...y}),Q&&React.createElement(ue,{dialCode:$.dialCode,prefix:c.prefix??"+",disabled:v,...d}),React.createElement("input",{onChange:K,value:b,type:"tel",ref:L,className:S({addPrefix:["input",v&&"input--disabled"],rawClassNames:[m]}),placeholder:f,disabled:v,style:l,name:g,onFocus:E,onBlur:D,autoFocus:_,required:I,...w}))});
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* Vanilla emoji-flag + dial-code picker for VTBA form tel fields.
|
|
1445
|
+
*
|
|
1446
|
+
* Framework-agnostic: this is the single source of truth for the phone flag
|
|
1447
|
+
* picker. It is used two ways:
|
|
1448
|
+
* 1. In AEM (server-rendered HTL) via the ac-react-app form runtime, which
|
|
1449
|
+
* calls {@link initTelPickers} on DOM-ready.
|
|
1450
|
+
* 2. In Storybook via the React {@link ../LsgFormFieldTel} component, which
|
|
1451
|
+
* calls it from a `useEffect`.
|
|
1452
|
+
*
|
|
1453
|
+
* It enhances `.cmp-vtba-form__field--tel input[type="tel"]` with a country
|
|
1454
|
+
* toggle (Unicode emoji flag + dial code) and a searchable dropdown. Emoji flags
|
|
1455
|
+
* mean no image assets to ship. Country/dial-code data is reused from
|
|
1456
|
+
* `react-international-phone` (data only — no React needed at runtime here).
|
|
1457
|
+
*
|
|
1458
|
+
* DOM strategy (so it is safe inside React too): if the input already sits in a
|
|
1459
|
+
* `.cmp-vtba-tel` wrapper (React renders one), the picker only *appends* the
|
|
1460
|
+
* toggle + dropdown and never moves the React-managed input. Otherwise (plain
|
|
1461
|
+
* AEM markup) it creates the wrapper and moves the input in.
|
|
1462
|
+
*
|
|
1463
|
+
* On submit, the field value is the full international number
|
|
1464
|
+
* (`+<dialCode><nationalDigits>`) via {@link getTelValue}.
|
|
1465
|
+
*/
|
|
1466
|
+
/** `defaultCountries` items are tuples `[name, iso2, dialCode, format?, ...]`. */
|
|
1467
|
+
var COUNTRIES = M.map(function (c) {
|
|
1468
|
+
var t = c;
|
|
1469
|
+
return {
|
|
1470
|
+
name: t[0],
|
|
1471
|
+
iso2: t[1],
|
|
1472
|
+
dialCode: t[2]
|
|
1473
|
+
};
|
|
1474
|
+
}).filter(function (c) {
|
|
1475
|
+
return !!c.iso2 && !!c.dialCode;
|
|
1476
|
+
});
|
|
1477
|
+
var DEFAULT_ISO2 = "gb";
|
|
1478
|
+
/** Converts an ISO-2 country code to its Unicode regional-indicator flag emoji. */
|
|
1479
|
+
function flagEmoji(iso2) {
|
|
1480
|
+
return iso2.toUpperCase().replace(/[A-Z]/g, function (ch) {
|
|
1481
|
+
return String.fromCodePoint(0x1f1e6 + ch.charCodeAt(0) - 65);
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
function findCountry(iso2) {
|
|
1485
|
+
var target = (iso2 || "").toLowerCase();
|
|
1486
|
+
for (var i = 0; i < COUNTRIES.length; i++) {
|
|
1487
|
+
if (COUNTRIES[i].iso2 === target) {
|
|
1488
|
+
return COUNTRIES[i];
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
return undefined;
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Enhances every tel field under {@code root} (or {@code root} itself when it is
|
|
1495
|
+
* a tel field). Idempotent per input. Works whether {@code root} is the whole
|
|
1496
|
+
* form (AEM) or a single field element (React component).
|
|
1497
|
+
*/
|
|
1498
|
+
function initTelPickers(root) {
|
|
1499
|
+
if (!root) {
|
|
1500
|
+
return;
|
|
1501
|
+
}
|
|
1502
|
+
var inputs = root.querySelectorAll("input[type='tel']");
|
|
1503
|
+
for (var i = 0; i < inputs.length; i++) {
|
|
1504
|
+
var input = inputs[i];
|
|
1505
|
+
if (input.closest(".cmp-vtba-form__field--tel")) {
|
|
1506
|
+
enhance(input);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Full international number for a picker-enhanced tel input:
|
|
1512
|
+
* `+<dialCode><nationalDigits>`. Falls back to the raw value if not enhanced.
|
|
1513
|
+
*/
|
|
1514
|
+
function getTelValue(input) {
|
|
1515
|
+
var dial = input.getAttribute("data-dial-code");
|
|
1516
|
+
if (!dial) {
|
|
1517
|
+
return input.value;
|
|
1518
|
+
}
|
|
1519
|
+
var national = (input.value || "").replace(/\D/g, "");
|
|
1520
|
+
return national ? "+" + dial + national : "";
|
|
1521
|
+
}
|
|
1522
|
+
function enhance(input) {
|
|
1523
|
+
if (input.getAttribute("data-tel-picker") === "true" || !input.parentElement) {
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
input.setAttribute("data-tel-picker", "true");
|
|
1527
|
+
var initialIso2 = (input.getAttribute("data-country") || DEFAULT_ISO2).toLowerCase();
|
|
1528
|
+
var selected = findCountry(initialIso2) || findCountry(DEFAULT_ISO2) || COUNTRIES[0];
|
|
1529
|
+
// Reuse a pre-rendered wrapper (React) — append-only, never move the input.
|
|
1530
|
+
// Otherwise create the wrapper and move the input (plain vanilla markup).
|
|
1531
|
+
var wrapper;
|
|
1532
|
+
if (input.parentElement.classList.contains("cmp-vtba-tel")) {
|
|
1533
|
+
wrapper = input.parentElement;
|
|
1534
|
+
} else {
|
|
1535
|
+
wrapper = document.createElement("div");
|
|
1536
|
+
wrapper.className = "cmp-vtba-tel";
|
|
1537
|
+
input.parentElement.insertBefore(wrapper, input);
|
|
1538
|
+
wrapper.appendChild(input);
|
|
1539
|
+
}
|
|
1540
|
+
var toggle = document.createElement("button");
|
|
1541
|
+
toggle.type = "button";
|
|
1542
|
+
toggle.className = "cmp-vtba-tel__toggle";
|
|
1543
|
+
toggle.setAttribute("aria-haspopup", "listbox");
|
|
1544
|
+
toggle.setAttribute("aria-expanded", "false");
|
|
1545
|
+
var dropdown = document.createElement("div");
|
|
1546
|
+
dropdown.className = "cmp-vtba-tel__dropdown";
|
|
1547
|
+
dropdown.hidden = true;
|
|
1548
|
+
var search = document.createElement("input");
|
|
1549
|
+
search.type = "text";
|
|
1550
|
+
search.className = "cmp-vtba-tel__search";
|
|
1551
|
+
search.placeholder = "Search";
|
|
1552
|
+
search.setAttribute("aria-label", "Search countries");
|
|
1553
|
+
var list = document.createElement("ul");
|
|
1554
|
+
list.className = "cmp-vtba-tel__list";
|
|
1555
|
+
list.setAttribute("role", "listbox");
|
|
1556
|
+
dropdown.appendChild(search);
|
|
1557
|
+
dropdown.appendChild(list);
|
|
1558
|
+
// Toggle goes before the input; dropdown after — both inside the wrapper.
|
|
1559
|
+
wrapper.insertBefore(toggle, input);
|
|
1560
|
+
wrapper.appendChild(dropdown);
|
|
1561
|
+
function applySelected(country) {
|
|
1562
|
+
selected = country;
|
|
1563
|
+
input.setAttribute("data-dial-code", country.dialCode);
|
|
1564
|
+
input.setAttribute("data-iso2", country.iso2);
|
|
1565
|
+
toggle.textContent = "";
|
|
1566
|
+
var flag = document.createElement("span");
|
|
1567
|
+
flag.className = "cmp-vtba-tel__flag";
|
|
1568
|
+
flag.setAttribute("aria-hidden", "true");
|
|
1569
|
+
flag.textContent = flagEmoji(country.iso2);
|
|
1570
|
+
var code = document.createElement("span");
|
|
1571
|
+
code.className = "cmp-vtba-tel__code";
|
|
1572
|
+
code.textContent = "+" + country.dialCode;
|
|
1573
|
+
toggle.appendChild(flag);
|
|
1574
|
+
toggle.appendChild(code);
|
|
1575
|
+
toggle.setAttribute("aria-label", "Country calling code: " + country.name + " +" + country.dialCode);
|
|
1576
|
+
}
|
|
1577
|
+
function renderList(filter) {
|
|
1578
|
+
list.textContent = "";
|
|
1579
|
+
var f = filter.trim().toLowerCase();
|
|
1580
|
+
var digits = f.replace(/[^0-9]/g, "");
|
|
1581
|
+
var _loop_1 = function (i) {
|
|
1582
|
+
var c = COUNTRIES[i];
|
|
1583
|
+
var match = !f || c.name.toLowerCase().indexOf(f) !== -1 || c.iso2 === f || !!digits && c.dialCode.indexOf(digits) === 0;
|
|
1584
|
+
if (!match) {
|
|
1585
|
+
return "continue";
|
|
1586
|
+
}
|
|
1587
|
+
var li = document.createElement("li");
|
|
1588
|
+
li.className = "cmp-vtba-tel__option";
|
|
1589
|
+
li.setAttribute("role", "option");
|
|
1590
|
+
li.tabIndex = -1;
|
|
1591
|
+
li.setAttribute("data-iso2", c.iso2);
|
|
1592
|
+
li.setAttribute("aria-selected", c.iso2 === selected.iso2 ? "true" : "false");
|
|
1593
|
+
li.textContent = flagEmoji(c.iso2) + " " + c.name + " +" + c.dialCode;
|
|
1594
|
+
li.addEventListener("click", function () {
|
|
1595
|
+
applySelected(c);
|
|
1596
|
+
close();
|
|
1597
|
+
input.focus();
|
|
1598
|
+
});
|
|
1599
|
+
list.appendChild(li);
|
|
1600
|
+
};
|
|
1601
|
+
for (var i = 0; i < COUNTRIES.length; i++) {
|
|
1602
|
+
_loop_1(i);
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
function open() {
|
|
1606
|
+
dropdown.hidden = false;
|
|
1607
|
+
toggle.setAttribute("aria-expanded", "true");
|
|
1608
|
+
search.value = "";
|
|
1609
|
+
renderList("");
|
|
1610
|
+
search.focus();
|
|
1611
|
+
}
|
|
1612
|
+
function close() {
|
|
1613
|
+
dropdown.hidden = true;
|
|
1614
|
+
toggle.setAttribute("aria-expanded", "false");
|
|
1615
|
+
}
|
|
1616
|
+
toggle.addEventListener("click", function () {
|
|
1617
|
+
if (dropdown.hidden) {
|
|
1618
|
+
open();
|
|
1619
|
+
} else {
|
|
1620
|
+
close();
|
|
1621
|
+
}
|
|
1622
|
+
});
|
|
1623
|
+
search.addEventListener("input", function () {
|
|
1624
|
+
return renderList(search.value);
|
|
1625
|
+
});
|
|
1626
|
+
search.addEventListener("keydown", function (e) {
|
|
1627
|
+
if (e.key === "Escape") {
|
|
1628
|
+
close();
|
|
1629
|
+
toggle.focus();
|
|
1630
|
+
} else if (e.key === "ArrowDown") {
|
|
1631
|
+
e.preventDefault();
|
|
1632
|
+
var first = list.querySelector(".cmp-vtba-tel__option");
|
|
1633
|
+
if (first) {
|
|
1634
|
+
first.focus();
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
});
|
|
1638
|
+
list.addEventListener("keydown", function (e) {
|
|
1639
|
+
var opts = Array.prototype.slice.call(list.querySelectorAll(".cmp-vtba-tel__option"));
|
|
1640
|
+
var idx = opts.indexOf(document.activeElement);
|
|
1641
|
+
if (e.key === "ArrowDown") {
|
|
1642
|
+
e.preventDefault();
|
|
1643
|
+
(opts[idx + 1] || opts[0]).focus();
|
|
1644
|
+
} else if (e.key === "ArrowUp") {
|
|
1645
|
+
e.preventDefault();
|
|
1646
|
+
if (idx <= 0) {
|
|
1647
|
+
search.focus();
|
|
1648
|
+
} else {
|
|
1649
|
+
opts[idx - 1].focus();
|
|
1650
|
+
}
|
|
1651
|
+
} else if (e.key === "Enter" || e.key === " ") {
|
|
1652
|
+
e.preventDefault();
|
|
1653
|
+
var iso2 = document.activeElement.getAttribute("data-iso2");
|
|
1654
|
+
var c = iso2 ? findCountry(iso2) : undefined;
|
|
1655
|
+
if (c) {
|
|
1656
|
+
applySelected(c);
|
|
1657
|
+
close();
|
|
1658
|
+
input.focus();
|
|
1659
|
+
}
|
|
1660
|
+
} else if (e.key === "Escape") {
|
|
1661
|
+
close();
|
|
1662
|
+
toggle.focus();
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
document.addEventListener("click", function (e) {
|
|
1666
|
+
if (!wrapper.contains(e.target)) {
|
|
1667
|
+
close();
|
|
1668
|
+
}
|
|
1669
|
+
});
|
|
1670
|
+
applySelected(selected);
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1441
1673
|
var LsgFormFieldTel = function (_a) {
|
|
1442
1674
|
var _b = _a.id,
|
|
1443
1675
|
id = _b === void 0 ? "field-tel" : _b,
|
|
@@ -1454,19 +1686,30 @@ var LsgFormFieldTel = function (_a) {
|
|
|
1454
1686
|
minLength = _a.minLength,
|
|
1455
1687
|
maxLength = _a.maxLength,
|
|
1456
1688
|
pattern = _a.pattern,
|
|
1457
|
-
name = _a.name
|
|
1689
|
+
name = _a.name,
|
|
1690
|
+
defaultCountry = _a.defaultCountry;
|
|
1691
|
+
var fieldRef = useRef(null);
|
|
1458
1692
|
var helpId = helpText ? "".concat(id, "-help") : undefined;
|
|
1459
1693
|
var errorId = "".concat(id, "-error");
|
|
1460
1694
|
var ariaDescribedBy = [helpId, error ? errorId : undefined].filter(Boolean).join(" ") || undefined;
|
|
1695
|
+
// Enhance the tel input with the shared emoji-flag + dial-code picker.
|
|
1696
|
+
// The input is pre-wrapped in `.cmp-vtba-tel`, so the picker appends its
|
|
1697
|
+
// toggle/dropdown without moving the React-managed input.
|
|
1698
|
+
useEffect(function () {
|
|
1699
|
+
initTelPickers(fieldRef.current);
|
|
1700
|
+
}, []);
|
|
1461
1701
|
return /*#__PURE__*/React.createElement("div", {
|
|
1462
|
-
className: "cmp-vtba-form__field cmp-vtba-form__field--tel"
|
|
1702
|
+
className: "cmp-vtba-form__field cmp-vtba-form__field--tel",
|
|
1703
|
+
ref: fieldRef
|
|
1463
1704
|
}, /*#__PURE__*/React.createElement("label", {
|
|
1464
1705
|
className: "cmp-vtba-form__label",
|
|
1465
1706
|
htmlFor: id
|
|
1466
1707
|
}, label, required && /*#__PURE__*/React.createElement("abbr", {
|
|
1467
1708
|
className: "cmp-vtba-form__required",
|
|
1468
1709
|
title: "required"
|
|
1469
|
-
}, "*")), /*#__PURE__*/React.createElement("
|
|
1710
|
+
}, "*")), /*#__PURE__*/React.createElement("span", {
|
|
1711
|
+
className: "cmp-vtba-tel"
|
|
1712
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
1470
1713
|
type: "tel",
|
|
1471
1714
|
className: "cmp-vtba-form__input",
|
|
1472
1715
|
id: id,
|
|
@@ -1477,11 +1720,12 @@ var LsgFormFieldTel = function (_a) {
|
|
|
1477
1720
|
minLength: minLength,
|
|
1478
1721
|
maxLength: maxLength,
|
|
1479
1722
|
pattern: pattern,
|
|
1723
|
+
"data-country": defaultCountry,
|
|
1480
1724
|
"aria-describedby": ariaDescribedBy,
|
|
1481
1725
|
"aria-invalid": error ? "true" : undefined,
|
|
1482
1726
|
required: required,
|
|
1483
1727
|
disabled: disabled
|
|
1484
|
-
}), helpText && /*#__PURE__*/React.createElement("span", {
|
|
1728
|
+
})), helpText && /*#__PURE__*/React.createElement("span", {
|
|
1485
1729
|
className: "cmp-vtba-form__help",
|
|
1486
1730
|
id: helpId
|
|
1487
1731
|
}, helpText), /*#__PURE__*/React.createElement("span", {
|
|
@@ -1952,5 +2196,5 @@ var Theme3LsgButton = theme3Components.LsgButton,
|
|
|
1952
2196
|
theme3Components.LsgFormFieldConsent;
|
|
1953
2197
|
theme3Components.LsgFormStep;
|
|
1954
2198
|
|
|
1955
|
-
export { LsgBanner, LsgButton, LsgCard, LsgCards, LsgFooter, LsgHeader, LsgLanguageSwitcher, LsgLogo, LsgNavigation, LsgQuickLinks, LsgSearchOverlay, LsgSearchTrigger, LsgSocialMediaIcons, Theme1LsgBanner, Theme1LsgButton, Theme1LsgCard, Theme1LsgCards, Theme1LsgFooter, Theme1LsgHeader, Theme1LsgLanguageSwitcher, Theme1LsgLogo, Theme1LsgNavigation, Theme1LsgQuickLinks, Theme1LsgSearchOverlay, Theme1LsgSearchTrigger, Theme1LsgSocialMediaIcons, Theme2LsgBanner, Theme2LsgButton, Theme2LsgCard, Theme2LsgCards, Theme2LsgFooter, Theme2LsgHeader, Theme2LsgLanguageSwitcher, Theme2LsgLogo, Theme2LsgNavigation, Theme2LsgQuickLinks, Theme2LsgSearchOverlay, Theme2LsgSearchTrigger, Theme2LsgSocialMediaIcons, Theme3LsgBanner, Theme3LsgButton, Theme3LsgCard, Theme3LsgCards, Theme3LsgFooter, Theme3LsgHeader, Theme3LsgLanguageSwitcher, Theme3LsgLogo, Theme3LsgNavigation, Theme3LsgQuickLinks, Theme3LsgSearchOverlay, Theme3LsgSearchTrigger, Theme3LsgSocialMediaIcons, theme1Components, theme2Components, theme3Components };
|
|
2199
|
+
export { LsgBanner, LsgButton, LsgCard, LsgCards, LsgFooter, LsgHeader, LsgLanguageSwitcher, LsgLogo, LsgNavigation, LsgQuickLinks, LsgSearchOverlay, LsgSearchTrigger, LsgSocialMediaIcons, Theme1LsgBanner, Theme1LsgButton, Theme1LsgCard, Theme1LsgCards, Theme1LsgFooter, Theme1LsgHeader, Theme1LsgLanguageSwitcher, Theme1LsgLogo, Theme1LsgNavigation, Theme1LsgQuickLinks, Theme1LsgSearchOverlay, Theme1LsgSearchTrigger, Theme1LsgSocialMediaIcons, Theme2LsgBanner, Theme2LsgButton, Theme2LsgCard, Theme2LsgCards, Theme2LsgFooter, Theme2LsgHeader, Theme2LsgLanguageSwitcher, Theme2LsgLogo, Theme2LsgNavigation, Theme2LsgQuickLinks, Theme2LsgSearchOverlay, Theme2LsgSearchTrigger, Theme2LsgSocialMediaIcons, Theme3LsgBanner, Theme3LsgButton, Theme3LsgCard, Theme3LsgCards, Theme3LsgFooter, Theme3LsgHeader, Theme3LsgLanguageSwitcher, Theme3LsgLogo, Theme3LsgNavigation, Theme3LsgQuickLinks, Theme3LsgSearchOverlay, Theme3LsgSearchTrigger, Theme3LsgSocialMediaIcons, getTelValue, initTelPickers, theme1Components, theme2Components, theme3Components };
|
|
1956
2200
|
//# sourceMappingURL=index.esm.js.map
|