@asante-org/atlascopco-vt-litesitegenerator 1.6.41 → 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 +780 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.scss +1374 -0
- package/dist/index.js +780 -2
- package/dist/index.js.map +1 -1
- package/dist/index.scss +1374 -0
- package/dist/src/components/lsg/LsgFormContainer/LsgFormContainer.d.ts +16 -0
- package/dist/src/components/lsg/LsgFormContainer/LsgFormContainer.stories.d.ts +10 -0
- package/dist/src/components/lsg/LsgFormContainer/index.d.ts +2 -0
- package/dist/src/components/lsg/LsgFormFieldConsent/LsgFormFieldConsent.d.ts +12 -0
- package/dist/src/components/lsg/LsgFormFieldConsent/LsgFormFieldConsent.stories.d.ts +9 -0
- package/dist/src/components/lsg/LsgFormFieldConsent/index.d.ts +2 -0
- package/dist/src/components/lsg/LsgFormFieldCountry/LsgFormFieldCountry.d.ts +19 -0
- package/dist/src/components/lsg/LsgFormFieldCountry/LsgFormFieldCountry.stories.d.ts +10 -0
- package/dist/src/components/lsg/LsgFormFieldCountry/index.d.ts +2 -0
- package/dist/src/components/lsg/LsgFormFieldEmail/LsgFormFieldEmail.d.ts +15 -0
- package/dist/src/components/lsg/LsgFormFieldEmail/LsgFormFieldEmail.stories.d.ts +10 -0
- package/dist/src/components/lsg/LsgFormFieldEmail/index.d.ts +2 -0
- package/dist/src/components/lsg/LsgFormFieldSelect/LsgFormFieldSelect.d.ts +19 -0
- package/dist/src/components/lsg/LsgFormFieldSelect/LsgFormFieldSelect.stories.d.ts +10 -0
- package/dist/src/components/lsg/LsgFormFieldSelect/index.d.ts +2 -0
- package/dist/src/components/lsg/LsgFormFieldTel/LsgFormFieldTel.d.ts +19 -0
- package/dist/src/components/lsg/LsgFormFieldTel/LsgFormFieldTel.stories.d.ts +12 -0
- package/dist/src/components/lsg/LsgFormFieldTel/index.d.ts +2 -0
- package/dist/src/components/lsg/LsgFormFieldText/LsgFormFieldText.d.ts +18 -0
- package/dist/src/components/lsg/LsgFormFieldText/LsgFormFieldText.stories.d.ts +10 -0
- package/dist/src/components/lsg/LsgFormFieldText/index.d.ts +2 -0
- package/dist/src/components/lsg/LsgFormFieldTextarea/LsgFormFieldTextarea.d.ts +17 -0
- package/dist/src/components/lsg/LsgFormFieldTextarea/LsgFormFieldTextarea.stories.d.ts +10 -0
- package/dist/src/components/lsg/LsgFormFieldTextarea/index.d.ts +2 -0
- package/dist/src/components/lsg/LsgFormStep/LsgFormStep.d.ts +10 -0
- package/dist/src/components/lsg/LsgFormStep/LsgFormStep.stories.d.ts +7 -0
- package/dist/src/components/lsg/LsgFormStep/index.d.ts +2 -0
- package/dist/src/components/lsg/LsgHero/LsgHero.d.ts +31 -0
- package/dist/src/components/lsg/LsgHero/LsgHero.stories.d.ts +36 -0
- package/dist/src/components/lsg/LsgHero/LsgHeroController.d.ts +40 -0
- package/dist/src/components/lsg/LsgHero/index.d.ts +4 -0
- package/dist/src/components/lsg/LsgHeroCard/LsgHeroCard.d.ts +37 -0
- package/dist/src/components/lsg/LsgHeroCard/LsgHeroCard.stories.d.ts +20 -0
- package/dist/src/components/lsg/LsgHeroCard/index.d.ts +2 -0
- package/dist/src/components/lsg/index.d.ts +19 -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/createThemeComponents.d.ts +9 -0
- package/dist/src/themes/theme-1/components.d.ts +11 -1
- package/dist/src/themes/theme-2/components.d.ts +11 -1
- package/dist/src/themes/theme-3/components.d.ts +11 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/dist/lsg-clientlib.css +0 -2106
- package/dist/lsg-clientlib.css.map +0 -1
- package/dist/lsg-clientlib.js +0 -524
- package/dist/lsg-clientlib.js.map +0 -1
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) {
|
|
@@ -1333,6 +1333,734 @@ var LsgFooter = function (_a) {
|
|
|
1333
1333
|
}))))), bottomBar);
|
|
1334
1334
|
};
|
|
1335
1335
|
|
|
1336
|
+
var LsgFormFieldText = function (_a) {
|
|
1337
|
+
var _b = _a.id,
|
|
1338
|
+
id = _b === void 0 ? "field-text" : _b,
|
|
1339
|
+
label = _a.label,
|
|
1340
|
+
helpText = _a.helpText,
|
|
1341
|
+
placeholder = _a.placeholder,
|
|
1342
|
+
_c = _a.defaultValue,
|
|
1343
|
+
defaultValue = _c === void 0 ? "" : _c,
|
|
1344
|
+
_d = _a.required,
|
|
1345
|
+
required = _d === void 0 ? false : _d,
|
|
1346
|
+
_e = _a.disabled,
|
|
1347
|
+
disabled = _e === void 0 ? false : _e,
|
|
1348
|
+
error = _a.error,
|
|
1349
|
+
autocomplete = _a.autocomplete,
|
|
1350
|
+
minLength = _a.minLength,
|
|
1351
|
+
maxLength = _a.maxLength,
|
|
1352
|
+
name = _a.name;
|
|
1353
|
+
var helpId = helpText ? "".concat(id, "-help") : undefined;
|
|
1354
|
+
var errorId = "".concat(id, "-error");
|
|
1355
|
+
var ariaDescribedBy = [helpId, error ? errorId : undefined].filter(Boolean).join(" ") || undefined;
|
|
1356
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1357
|
+
className: "cmp-vtba-form__field cmp-vtba-form__field--text"
|
|
1358
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
1359
|
+
className: "cmp-vtba-form__label",
|
|
1360
|
+
htmlFor: id
|
|
1361
|
+
}, label, required && /*#__PURE__*/React.createElement("abbr", {
|
|
1362
|
+
className: "cmp-vtba-form__required",
|
|
1363
|
+
title: "required"
|
|
1364
|
+
}, "*")), /*#__PURE__*/React.createElement("input", {
|
|
1365
|
+
type: "text",
|
|
1366
|
+
className: "cmp-vtba-form__input",
|
|
1367
|
+
id: id,
|
|
1368
|
+
name: name,
|
|
1369
|
+
defaultValue: defaultValue,
|
|
1370
|
+
placeholder: placeholder,
|
|
1371
|
+
autoComplete: autocomplete,
|
|
1372
|
+
minLength: minLength,
|
|
1373
|
+
maxLength: maxLength,
|
|
1374
|
+
"aria-describedby": ariaDescribedBy,
|
|
1375
|
+
"aria-invalid": error ? "true" : undefined,
|
|
1376
|
+
required: required,
|
|
1377
|
+
disabled: disabled
|
|
1378
|
+
}), helpText && /*#__PURE__*/React.createElement("span", {
|
|
1379
|
+
className: "cmp-vtba-form__help",
|
|
1380
|
+
id: helpId
|
|
1381
|
+
}, helpText), /*#__PURE__*/React.createElement("span", {
|
|
1382
|
+
className: "cmp-vtba-form__field-error",
|
|
1383
|
+
id: errorId,
|
|
1384
|
+
role: "alert",
|
|
1385
|
+
"aria-live": "assertive",
|
|
1386
|
+
hidden: !error
|
|
1387
|
+
}, error));
|
|
1388
|
+
};
|
|
1389
|
+
|
|
1390
|
+
var LsgFormFieldEmail = function (_a) {
|
|
1391
|
+
var _b = _a.id,
|
|
1392
|
+
id = _b === void 0 ? "field-email" : _b,
|
|
1393
|
+
label = _a.label,
|
|
1394
|
+
helpText = _a.helpText,
|
|
1395
|
+
placeholder = _a.placeholder,
|
|
1396
|
+
_c = _a.defaultValue,
|
|
1397
|
+
defaultValue = _c === void 0 ? "" : _c,
|
|
1398
|
+
_d = _a.required,
|
|
1399
|
+
required = _d === void 0 ? false : _d,
|
|
1400
|
+
_e = _a.disabled,
|
|
1401
|
+
disabled = _e === void 0 ? false : _e,
|
|
1402
|
+
error = _a.error,
|
|
1403
|
+
maxLength = _a.maxLength,
|
|
1404
|
+
name = _a.name;
|
|
1405
|
+
var helpId = helpText ? "".concat(id, "-help") : undefined;
|
|
1406
|
+
var errorId = "".concat(id, "-error");
|
|
1407
|
+
var ariaDescribedBy = [helpId, error ? errorId : undefined].filter(Boolean).join(" ") || undefined;
|
|
1408
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1409
|
+
className: "cmp-vtba-form__field cmp-vtba-form__field--email"
|
|
1410
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
1411
|
+
className: "cmp-vtba-form__label",
|
|
1412
|
+
htmlFor: id
|
|
1413
|
+
}, label, required && /*#__PURE__*/React.createElement("abbr", {
|
|
1414
|
+
className: "cmp-vtba-form__required",
|
|
1415
|
+
title: "required"
|
|
1416
|
+
}, "*")), /*#__PURE__*/React.createElement("input", {
|
|
1417
|
+
type: "email",
|
|
1418
|
+
className: "cmp-vtba-form__input",
|
|
1419
|
+
id: id,
|
|
1420
|
+
name: name,
|
|
1421
|
+
defaultValue: defaultValue,
|
|
1422
|
+
placeholder: placeholder,
|
|
1423
|
+
autoComplete: "email",
|
|
1424
|
+
maxLength: maxLength,
|
|
1425
|
+
"aria-describedby": ariaDescribedBy,
|
|
1426
|
+
"aria-invalid": error ? "true" : undefined,
|
|
1427
|
+
required: required,
|
|
1428
|
+
disabled: disabled
|
|
1429
|
+
}), helpText && /*#__PURE__*/React.createElement("span", {
|
|
1430
|
+
className: "cmp-vtba-form__help",
|
|
1431
|
+
id: helpId
|
|
1432
|
+
}, helpText), /*#__PURE__*/React.createElement("span", {
|
|
1433
|
+
className: "cmp-vtba-form__field-error",
|
|
1434
|
+
id: errorId,
|
|
1435
|
+
role: "alert",
|
|
1436
|
+
"aria-live": "assertive",
|
|
1437
|
+
hidden: !error
|
|
1438
|
+
}, error));
|
|
1439
|
+
};
|
|
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
|
+
|
|
1673
|
+
var LsgFormFieldTel = function (_a) {
|
|
1674
|
+
var _b = _a.id,
|
|
1675
|
+
id = _b === void 0 ? "field-tel" : _b,
|
|
1676
|
+
label = _a.label,
|
|
1677
|
+
helpText = _a.helpText,
|
|
1678
|
+
placeholder = _a.placeholder,
|
|
1679
|
+
_c = _a.defaultValue,
|
|
1680
|
+
defaultValue = _c === void 0 ? "" : _c,
|
|
1681
|
+
_d = _a.required,
|
|
1682
|
+
required = _d === void 0 ? false : _d,
|
|
1683
|
+
_e = _a.disabled,
|
|
1684
|
+
disabled = _e === void 0 ? false : _e,
|
|
1685
|
+
error = _a.error,
|
|
1686
|
+
minLength = _a.minLength,
|
|
1687
|
+
maxLength = _a.maxLength,
|
|
1688
|
+
pattern = _a.pattern,
|
|
1689
|
+
name = _a.name,
|
|
1690
|
+
defaultCountry = _a.defaultCountry;
|
|
1691
|
+
var fieldRef = useRef(null);
|
|
1692
|
+
var helpId = helpText ? "".concat(id, "-help") : undefined;
|
|
1693
|
+
var errorId = "".concat(id, "-error");
|
|
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
|
+
}, []);
|
|
1701
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1702
|
+
className: "cmp-vtba-form__field cmp-vtba-form__field--tel",
|
|
1703
|
+
ref: fieldRef
|
|
1704
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
1705
|
+
className: "cmp-vtba-form__label",
|
|
1706
|
+
htmlFor: id
|
|
1707
|
+
}, label, required && /*#__PURE__*/React.createElement("abbr", {
|
|
1708
|
+
className: "cmp-vtba-form__required",
|
|
1709
|
+
title: "required"
|
|
1710
|
+
}, "*")), /*#__PURE__*/React.createElement("span", {
|
|
1711
|
+
className: "cmp-vtba-tel"
|
|
1712
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
1713
|
+
type: "tel",
|
|
1714
|
+
className: "cmp-vtba-form__input",
|
|
1715
|
+
id: id,
|
|
1716
|
+
name: name,
|
|
1717
|
+
defaultValue: defaultValue,
|
|
1718
|
+
placeholder: placeholder,
|
|
1719
|
+
autoComplete: "tel",
|
|
1720
|
+
minLength: minLength,
|
|
1721
|
+
maxLength: maxLength,
|
|
1722
|
+
pattern: pattern,
|
|
1723
|
+
"data-country": defaultCountry,
|
|
1724
|
+
"aria-describedby": ariaDescribedBy,
|
|
1725
|
+
"aria-invalid": error ? "true" : undefined,
|
|
1726
|
+
required: required,
|
|
1727
|
+
disabled: disabled
|
|
1728
|
+
})), helpText && /*#__PURE__*/React.createElement("span", {
|
|
1729
|
+
className: "cmp-vtba-form__help",
|
|
1730
|
+
id: helpId
|
|
1731
|
+
}, helpText), /*#__PURE__*/React.createElement("span", {
|
|
1732
|
+
className: "cmp-vtba-form__field-error",
|
|
1733
|
+
id: errorId,
|
|
1734
|
+
role: "alert",
|
|
1735
|
+
"aria-live": "assertive",
|
|
1736
|
+
hidden: !error
|
|
1737
|
+
}, error));
|
|
1738
|
+
};
|
|
1739
|
+
|
|
1740
|
+
var LsgFormFieldSelect = function (_a) {
|
|
1741
|
+
var _b = _a.id,
|
|
1742
|
+
id = _b === void 0 ? "field-select" : _b,
|
|
1743
|
+
label = _a.label,
|
|
1744
|
+
helpText = _a.helpText,
|
|
1745
|
+
_c = _a.placeholder,
|
|
1746
|
+
placeholder = _c === void 0 ? "Please select" : _c,
|
|
1747
|
+
_d = _a.defaultValue,
|
|
1748
|
+
defaultValue = _d === void 0 ? "" : _d,
|
|
1749
|
+
_e = _a.options,
|
|
1750
|
+
options = _e === void 0 ? [] : _e,
|
|
1751
|
+
_f = _a.required,
|
|
1752
|
+
required = _f === void 0 ? false : _f,
|
|
1753
|
+
_g = _a.disabled,
|
|
1754
|
+
disabled = _g === void 0 ? false : _g,
|
|
1755
|
+
error = _a.error,
|
|
1756
|
+
name = _a.name;
|
|
1757
|
+
var helpId = helpText ? "".concat(id, "-help") : undefined;
|
|
1758
|
+
var errorId = "".concat(id, "-error");
|
|
1759
|
+
var ariaDescribedBy = [helpId, error ? errorId : undefined].filter(Boolean).join(" ") || undefined;
|
|
1760
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1761
|
+
className: "cmp-vtba-form__field cmp-vtba-form__field--select"
|
|
1762
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
1763
|
+
className: "cmp-vtba-form__label",
|
|
1764
|
+
htmlFor: id
|
|
1765
|
+
}, label, required && /*#__PURE__*/React.createElement("abbr", {
|
|
1766
|
+
className: "cmp-vtba-form__required",
|
|
1767
|
+
title: "required"
|
|
1768
|
+
}, "*")), /*#__PURE__*/React.createElement("div", {
|
|
1769
|
+
className: "cmp-vtba-form__select-wrapper"
|
|
1770
|
+
}, /*#__PURE__*/React.createElement("select", {
|
|
1771
|
+
className: "cmp-vtba-form__select",
|
|
1772
|
+
id: id,
|
|
1773
|
+
name: name,
|
|
1774
|
+
defaultValue: defaultValue,
|
|
1775
|
+
"aria-describedby": ariaDescribedBy,
|
|
1776
|
+
"aria-invalid": error ? "true" : undefined,
|
|
1777
|
+
required: required,
|
|
1778
|
+
disabled: disabled
|
|
1779
|
+
}, /*#__PURE__*/React.createElement("option", {
|
|
1780
|
+
value: ""
|
|
1781
|
+
}, placeholder), options.map(function (opt) {
|
|
1782
|
+
return /*#__PURE__*/React.createElement("option", {
|
|
1783
|
+
key: opt.value,
|
|
1784
|
+
value: opt.value
|
|
1785
|
+
}, opt.label);
|
|
1786
|
+
}))), helpText && /*#__PURE__*/React.createElement("span", {
|
|
1787
|
+
className: "cmp-vtba-form__help",
|
|
1788
|
+
id: helpId
|
|
1789
|
+
}, helpText), /*#__PURE__*/React.createElement("span", {
|
|
1790
|
+
className: "cmp-vtba-form__field-error",
|
|
1791
|
+
id: errorId,
|
|
1792
|
+
role: "alert",
|
|
1793
|
+
"aria-live": "assertive",
|
|
1794
|
+
hidden: !error
|
|
1795
|
+
}, error));
|
|
1796
|
+
};
|
|
1797
|
+
|
|
1798
|
+
var COUNTRY_FIXTURE = [{
|
|
1799
|
+
value: "us",
|
|
1800
|
+
label: "United States"
|
|
1801
|
+
}, {
|
|
1802
|
+
value: "gb",
|
|
1803
|
+
label: "United Kingdom"
|
|
1804
|
+
}, {
|
|
1805
|
+
value: "de",
|
|
1806
|
+
label: "Germany"
|
|
1807
|
+
}, {
|
|
1808
|
+
value: "fr",
|
|
1809
|
+
label: "France"
|
|
1810
|
+
}, {
|
|
1811
|
+
value: "se",
|
|
1812
|
+
label: "Sweden"
|
|
1813
|
+
}, {
|
|
1814
|
+
value: "jp",
|
|
1815
|
+
label: "Japan"
|
|
1816
|
+
}, {
|
|
1817
|
+
value: "cn",
|
|
1818
|
+
label: "China"
|
|
1819
|
+
}, {
|
|
1820
|
+
value: "in",
|
|
1821
|
+
label: "India"
|
|
1822
|
+
}, {
|
|
1823
|
+
value: "br",
|
|
1824
|
+
label: "Brazil"
|
|
1825
|
+
}, {
|
|
1826
|
+
value: "au",
|
|
1827
|
+
label: "Australia"
|
|
1828
|
+
}];
|
|
1829
|
+
var LsgFormFieldCountry = function (_a) {
|
|
1830
|
+
var _b = _a.id,
|
|
1831
|
+
id = _b === void 0 ? "field-country" : _b,
|
|
1832
|
+
label = _a.label,
|
|
1833
|
+
helpText = _a.helpText,
|
|
1834
|
+
_c = _a.defaultValue,
|
|
1835
|
+
defaultValue = _c === void 0 ? "" : _c,
|
|
1836
|
+
_d = _a.countries,
|
|
1837
|
+
countries = _d === void 0 ? COUNTRY_FIXTURE : _d,
|
|
1838
|
+
_e = _a.required,
|
|
1839
|
+
required = _e === void 0 ? false : _e,
|
|
1840
|
+
_f = _a.disabled,
|
|
1841
|
+
disabled = _f === void 0 ? false : _f,
|
|
1842
|
+
error = _a.error,
|
|
1843
|
+
name = _a.name;
|
|
1844
|
+
var helpId = helpText ? "".concat(id, "-help") : undefined;
|
|
1845
|
+
var errorId = "".concat(id, "-error");
|
|
1846
|
+
var ariaDescribedBy = [helpId, error ? errorId : undefined].filter(Boolean).join(" ") || undefined;
|
|
1847
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1848
|
+
className: "cmp-vtba-form__field cmp-vtba-form__field--country"
|
|
1849
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
1850
|
+
className: "cmp-vtba-form__label",
|
|
1851
|
+
htmlFor: id
|
|
1852
|
+
}, label, required && /*#__PURE__*/React.createElement("abbr", {
|
|
1853
|
+
className: "cmp-vtba-form__required",
|
|
1854
|
+
title: "required"
|
|
1855
|
+
}, "*")), /*#__PURE__*/React.createElement("div", {
|
|
1856
|
+
className: "cmp-vtba-form__select-wrapper"
|
|
1857
|
+
}, /*#__PURE__*/React.createElement("select", {
|
|
1858
|
+
className: "cmp-vtba-form__select",
|
|
1859
|
+
id: id,
|
|
1860
|
+
name: name,
|
|
1861
|
+
defaultValue: defaultValue,
|
|
1862
|
+
"data-country-list": "true",
|
|
1863
|
+
"aria-describedby": ariaDescribedBy,
|
|
1864
|
+
"aria-invalid": error ? "true" : undefined,
|
|
1865
|
+
required: required,
|
|
1866
|
+
disabled: disabled
|
|
1867
|
+
}, /*#__PURE__*/React.createElement("option", {
|
|
1868
|
+
value: ""
|
|
1869
|
+
}, "Select a country"), countries.map(function (c) {
|
|
1870
|
+
return /*#__PURE__*/React.createElement("option", {
|
|
1871
|
+
key: c.value,
|
|
1872
|
+
value: c.value
|
|
1873
|
+
}, c.label);
|
|
1874
|
+
}))), helpText && /*#__PURE__*/React.createElement("span", {
|
|
1875
|
+
className: "cmp-vtba-form__help",
|
|
1876
|
+
id: helpId
|
|
1877
|
+
}, helpText), /*#__PURE__*/React.createElement("span", {
|
|
1878
|
+
className: "cmp-vtba-form__field-error",
|
|
1879
|
+
id: errorId,
|
|
1880
|
+
role: "alert",
|
|
1881
|
+
"aria-live": "assertive",
|
|
1882
|
+
hidden: !error
|
|
1883
|
+
}, error));
|
|
1884
|
+
};
|
|
1885
|
+
|
|
1886
|
+
var LsgFormFieldTextarea = function (_a) {
|
|
1887
|
+
var _b = _a.id,
|
|
1888
|
+
id = _b === void 0 ? "field-textarea" : _b,
|
|
1889
|
+
label = _a.label,
|
|
1890
|
+
helpText = _a.helpText,
|
|
1891
|
+
placeholder = _a.placeholder,
|
|
1892
|
+
_c = _a.defaultValue,
|
|
1893
|
+
defaultValue = _c === void 0 ? "" : _c,
|
|
1894
|
+
_d = _a.required,
|
|
1895
|
+
required = _d === void 0 ? false : _d,
|
|
1896
|
+
_e = _a.disabled,
|
|
1897
|
+
disabled = _e === void 0 ? false : _e,
|
|
1898
|
+
error = _a.error,
|
|
1899
|
+
autocomplete = _a.autocomplete,
|
|
1900
|
+
maxLength = _a.maxLength,
|
|
1901
|
+
_f = _a.rows,
|
|
1902
|
+
rows = _f === void 0 ? 4 : _f,
|
|
1903
|
+
name = _a.name;
|
|
1904
|
+
var helpId = helpText ? "".concat(id, "-help") : undefined;
|
|
1905
|
+
var errorId = "".concat(id, "-error");
|
|
1906
|
+
var ariaDescribedBy = [helpId, error ? errorId : undefined].filter(Boolean).join(" ") || undefined;
|
|
1907
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1908
|
+
className: "cmp-vtba-form__field cmp-vtba-form__field--textarea"
|
|
1909
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
1910
|
+
className: "cmp-vtba-form__label",
|
|
1911
|
+
htmlFor: id
|
|
1912
|
+
}, label, required && /*#__PURE__*/React.createElement("abbr", {
|
|
1913
|
+
className: "cmp-vtba-form__required",
|
|
1914
|
+
title: "required"
|
|
1915
|
+
}, "*")), /*#__PURE__*/React.createElement("textarea", {
|
|
1916
|
+
className: "cmp-vtba-form__textarea",
|
|
1917
|
+
id: id,
|
|
1918
|
+
name: name,
|
|
1919
|
+
defaultValue: defaultValue,
|
|
1920
|
+
placeholder: placeholder,
|
|
1921
|
+
autoComplete: autocomplete,
|
|
1922
|
+
maxLength: maxLength,
|
|
1923
|
+
rows: rows,
|
|
1924
|
+
"aria-describedby": ariaDescribedBy,
|
|
1925
|
+
"aria-invalid": error ? "true" : undefined,
|
|
1926
|
+
required: required,
|
|
1927
|
+
disabled: disabled
|
|
1928
|
+
}), helpText && /*#__PURE__*/React.createElement("span", {
|
|
1929
|
+
className: "cmp-vtba-form__help",
|
|
1930
|
+
id: helpId
|
|
1931
|
+
}, helpText), /*#__PURE__*/React.createElement("span", {
|
|
1932
|
+
className: "cmp-vtba-form__field-error",
|
|
1933
|
+
id: errorId,
|
|
1934
|
+
role: "alert",
|
|
1935
|
+
"aria-live": "assertive",
|
|
1936
|
+
hidden: !error
|
|
1937
|
+
}, error));
|
|
1938
|
+
};
|
|
1939
|
+
|
|
1940
|
+
var LsgFormFieldConsent = function (_a) {
|
|
1941
|
+
var _b = _a.id,
|
|
1942
|
+
id = _b === void 0 ? "field-consent" : _b,
|
|
1943
|
+
label = _a.label,
|
|
1944
|
+
_c = _a.required,
|
|
1945
|
+
required = _c === void 0 ? false : _c,
|
|
1946
|
+
_d = _a.disabled,
|
|
1947
|
+
disabled = _d === void 0 ? false : _d,
|
|
1948
|
+
error = _a.error,
|
|
1949
|
+
name = _a.name;
|
|
1950
|
+
var errorId = "".concat(id, "-error");
|
|
1951
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1952
|
+
className: "cmp-vtba-form__field cmp-vtba-form__field--consent"
|
|
1953
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1954
|
+
className: "cmp-vtba-form__consent"
|
|
1955
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
1956
|
+
type: "checkbox",
|
|
1957
|
+
className: "cmp-vtba-form__checkbox",
|
|
1958
|
+
id: id,
|
|
1959
|
+
name: name,
|
|
1960
|
+
value: "true",
|
|
1961
|
+
"data-consent": "",
|
|
1962
|
+
"aria-describedby": error ? errorId : undefined,
|
|
1963
|
+
"aria-invalid": error ? "true" : undefined,
|
|
1964
|
+
required: required,
|
|
1965
|
+
disabled: disabled
|
|
1966
|
+
}), /*#__PURE__*/React.createElement("label", {
|
|
1967
|
+
className: "cmp-vtba-form__consent-label",
|
|
1968
|
+
htmlFor: id,
|
|
1969
|
+
dangerouslySetInnerHTML: {
|
|
1970
|
+
__html: label
|
|
1971
|
+
}
|
|
1972
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
1973
|
+
className: "cmp-vtba-form__field-error",
|
|
1974
|
+
id: errorId,
|
|
1975
|
+
role: "alert",
|
|
1976
|
+
"aria-live": "assertive",
|
|
1977
|
+
hidden: !error
|
|
1978
|
+
}, error));
|
|
1979
|
+
};
|
|
1980
|
+
|
|
1981
|
+
var LsgFormStep = function (_a) {
|
|
1982
|
+
var title = _a.title,
|
|
1983
|
+
description = _a.description,
|
|
1984
|
+
children = _a.children,
|
|
1985
|
+
stepId = _a.stepId;
|
|
1986
|
+
return /*#__PURE__*/React.createElement("fieldset", {
|
|
1987
|
+
className: "cmp-vtba-form__step",
|
|
1988
|
+
"data-form-step": "",
|
|
1989
|
+
"data-step-id": stepId
|
|
1990
|
+
}, title && /*#__PURE__*/React.createElement("legend", {
|
|
1991
|
+
className: "cmp-vtba-form__step-legend"
|
|
1992
|
+
}, title), description && /*#__PURE__*/React.createElement("p", {
|
|
1993
|
+
className: "cmp-vtba-form__step-description"
|
|
1994
|
+
}, description), /*#__PURE__*/React.createElement("div", {
|
|
1995
|
+
className: "cmp-vtba-form__fields"
|
|
1996
|
+
}, children));
|
|
1997
|
+
};
|
|
1998
|
+
|
|
1999
|
+
var LsgFormContainer = function (_a) {
|
|
2000
|
+
var title = _a.title,
|
|
2001
|
+
_b = _a.multiStep,
|
|
2002
|
+
multiStep = _b === void 0 ? false : _b,
|
|
2003
|
+
_c = _a.currentStep,
|
|
2004
|
+
currentStep = _c === void 0 ? 1 : _c,
|
|
2005
|
+
_d = _a.steps,
|
|
2006
|
+
steps = _d === void 0 ? [] : _d,
|
|
2007
|
+
children = _a.children,
|
|
2008
|
+
formError = _a.formError,
|
|
2009
|
+
successMessage = _a.successMessage;
|
|
2010
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2011
|
+
className: "cmp-vtba-form",
|
|
2012
|
+
"data-vtba-form": ""
|
|
2013
|
+
}, /*#__PURE__*/React.createElement("form", {
|
|
2014
|
+
className: "cmp-vtba-form__form",
|
|
2015
|
+
method: "post",
|
|
2016
|
+
noValidate: true,
|
|
2017
|
+
"aria-label": title
|
|
2018
|
+
}, title && /*#__PURE__*/React.createElement("h2", {
|
|
2019
|
+
className: "cmp-vtba-form__title"
|
|
2020
|
+
}, title), multiStep && steps.length > 0 && /*#__PURE__*/React.createElement("nav", {
|
|
2021
|
+
className: "cmp-vtba-form__progress",
|
|
2022
|
+
"aria-label": "Form progress"
|
|
2023
|
+
}, /*#__PURE__*/React.createElement("ol", {
|
|
2024
|
+
className: "cmp-vtba-form__progress-list"
|
|
2025
|
+
}, steps.map(function (stepTitle, i) {
|
|
2026
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
2027
|
+
key: i,
|
|
2028
|
+
className: "cmp-vtba-form__progress-step",
|
|
2029
|
+
"data-step-index": i,
|
|
2030
|
+
"aria-current": i + 1 === currentStep ? "step" : undefined
|
|
2031
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
2032
|
+
className: "cmp-vtba-form__progress-number"
|
|
2033
|
+
}, i + 1), /*#__PURE__*/React.createElement("span", {
|
|
2034
|
+
className: "cmp-vtba-form__progress-title"
|
|
2035
|
+
}, stepTitle));
|
|
2036
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
2037
|
+
className: "cmp-vtba-form__steps"
|
|
2038
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
2039
|
+
className: "cmp-vtba-form__actions"
|
|
2040
|
+
}, multiStep && /*#__PURE__*/React.createElement("button", {
|
|
2041
|
+
type: "button",
|
|
2042
|
+
className: "cmp-vtba-form__prev",
|
|
2043
|
+
"data-form-prev": "",
|
|
2044
|
+
hidden: currentStep <= 1
|
|
2045
|
+
}, "Back"), multiStep && currentStep < (steps.length || 1) ? /*#__PURE__*/React.createElement("button", {
|
|
2046
|
+
type: "button",
|
|
2047
|
+
className: "cmp-vtba-form__next",
|
|
2048
|
+
"data-form-next": ""
|
|
2049
|
+
}, "Continue") : /*#__PURE__*/React.createElement("button", {
|
|
2050
|
+
type: "submit",
|
|
2051
|
+
className: "cmp-vtba-form__submit",
|
|
2052
|
+
"data-form-submit": ""
|
|
2053
|
+
}, "Submit")), formError && /*#__PURE__*/React.createElement("p", {
|
|
2054
|
+
className: "cmp-vtba-form__error",
|
|
2055
|
+
role: "alert",
|
|
2056
|
+
"aria-live": "assertive"
|
|
2057
|
+
}, formError), successMessage && /*#__PURE__*/React.createElement("div", {
|
|
2058
|
+
className: "cmp-vtba-form__success",
|
|
2059
|
+
role: "status",
|
|
2060
|
+
"aria-live": "polite"
|
|
2061
|
+
}, successMessage)));
|
|
2062
|
+
};
|
|
2063
|
+
|
|
1336
2064
|
var BASE_COMPONENTS = {
|
|
1337
2065
|
LsgButton: LsgButton,
|
|
1338
2066
|
LsgBanner: LsgBanner,
|
|
@@ -1346,7 +2074,16 @@ var BASE_COMPONENTS = {
|
|
|
1346
2074
|
LsgHeader: LsgHeader,
|
|
1347
2075
|
LsgQuickLinks: LsgQuickLinks,
|
|
1348
2076
|
LsgSocialMediaIcons: LsgSocialMediaIcons,
|
|
1349
|
-
LsgFooter: LsgFooter
|
|
2077
|
+
LsgFooter: LsgFooter,
|
|
2078
|
+
LsgFormContainer: LsgFormContainer,
|
|
2079
|
+
LsgFormFieldText: LsgFormFieldText,
|
|
2080
|
+
LsgFormFieldEmail: LsgFormFieldEmail,
|
|
2081
|
+
LsgFormFieldTel: LsgFormFieldTel,
|
|
2082
|
+
LsgFormFieldSelect: LsgFormFieldSelect,
|
|
2083
|
+
LsgFormFieldCountry: LsgFormFieldCountry,
|
|
2084
|
+
LsgFormFieldTextarea: LsgFormFieldTextarea,
|
|
2085
|
+
LsgFormFieldConsent: LsgFormFieldConsent,
|
|
2086
|
+
LsgFormStep: LsgFormStep
|
|
1350
2087
|
};
|
|
1351
2088
|
function createThemeComponent(themeName, componentName, Component) {
|
|
1352
2089
|
var WrappedComponent = function (props) {
|
|
@@ -1371,7 +2108,16 @@ function createThemeComponents(themeName) {
|
|
|
1371
2108
|
LsgHeader: createThemeComponent(themeName, "header", BASE_COMPONENTS.LsgHeader),
|
|
1372
2109
|
LsgQuickLinks: createThemeComponent(themeName, "quick-links", BASE_COMPONENTS.LsgQuickLinks),
|
|
1373
2110
|
LsgSocialMediaIcons: createThemeComponent(themeName, "social-media-icons", BASE_COMPONENTS.LsgSocialMediaIcons),
|
|
1374
|
-
LsgFooter: createThemeComponent(themeName, "footer", BASE_COMPONENTS.LsgFooter)
|
|
2111
|
+
LsgFooter: createThemeComponent(themeName, "footer", BASE_COMPONENTS.LsgFooter),
|
|
2112
|
+
LsgFormContainer: createThemeComponent(themeName, "form-container", BASE_COMPONENTS.LsgFormContainer),
|
|
2113
|
+
LsgFormFieldText: createThemeComponent(themeName, "form-field-text", BASE_COMPONENTS.LsgFormFieldText),
|
|
2114
|
+
LsgFormFieldEmail: createThemeComponent(themeName, "form-field-email", BASE_COMPONENTS.LsgFormFieldEmail),
|
|
2115
|
+
LsgFormFieldTel: createThemeComponent(themeName, "form-field-tel", BASE_COMPONENTS.LsgFormFieldTel),
|
|
2116
|
+
LsgFormFieldSelect: createThemeComponent(themeName, "form-field-select", BASE_COMPONENTS.LsgFormFieldSelect),
|
|
2117
|
+
LsgFormFieldCountry: createThemeComponent(themeName, "form-field-country", BASE_COMPONENTS.LsgFormFieldCountry),
|
|
2118
|
+
LsgFormFieldTextarea: createThemeComponent(themeName, "form-field-textarea", BASE_COMPONENTS.LsgFormFieldTextarea),
|
|
2119
|
+
LsgFormFieldConsent: createThemeComponent(themeName, "form-field-consent", BASE_COMPONENTS.LsgFormFieldConsent),
|
|
2120
|
+
LsgFormStep: createThemeComponent(themeName, "form-step", BASE_COMPONENTS.LsgFormStep)
|
|
1375
2121
|
};
|
|
1376
2122
|
}
|
|
1377
2123
|
|
|
@@ -1389,6 +2135,16 @@ var Theme1LsgButton = theme1Components.LsgButton,
|
|
|
1389
2135
|
Theme1LsgQuickLinks = theme1Components.LsgQuickLinks,
|
|
1390
2136
|
Theme1LsgSocialMediaIcons = theme1Components.LsgSocialMediaIcons,
|
|
1391
2137
|
Theme1LsgFooter = theme1Components.LsgFooter;
|
|
2138
|
+
// Form components
|
|
2139
|
+
theme1Components.LsgFormContainer;
|
|
2140
|
+
theme1Components.LsgFormFieldText;
|
|
2141
|
+
theme1Components.LsgFormFieldEmail;
|
|
2142
|
+
theme1Components.LsgFormFieldTel;
|
|
2143
|
+
theme1Components.LsgFormFieldTextarea;
|
|
2144
|
+
theme1Components.LsgFormFieldSelect;
|
|
2145
|
+
theme1Components.LsgFormFieldCountry;
|
|
2146
|
+
theme1Components.LsgFormFieldConsent;
|
|
2147
|
+
theme1Components.LsgFormStep;
|
|
1392
2148
|
|
|
1393
2149
|
var theme2Components = createThemeComponents("theme-2");
|
|
1394
2150
|
var Theme2LsgButton = theme2Components.LsgButton,
|
|
@@ -1404,6 +2160,16 @@ var Theme2LsgButton = theme2Components.LsgButton,
|
|
|
1404
2160
|
Theme2LsgQuickLinks = theme2Components.LsgQuickLinks,
|
|
1405
2161
|
Theme2LsgSocialMediaIcons = theme2Components.LsgSocialMediaIcons,
|
|
1406
2162
|
Theme2LsgFooter = theme2Components.LsgFooter;
|
|
2163
|
+
// Form components
|
|
2164
|
+
theme2Components.LsgFormContainer;
|
|
2165
|
+
theme2Components.LsgFormFieldText;
|
|
2166
|
+
theme2Components.LsgFormFieldEmail;
|
|
2167
|
+
theme2Components.LsgFormFieldTel;
|
|
2168
|
+
theme2Components.LsgFormFieldTextarea;
|
|
2169
|
+
theme2Components.LsgFormFieldSelect;
|
|
2170
|
+
theme2Components.LsgFormFieldCountry;
|
|
2171
|
+
theme2Components.LsgFormFieldConsent;
|
|
2172
|
+
theme2Components.LsgFormStep;
|
|
1407
2173
|
|
|
1408
2174
|
var theme3Components = createThemeComponents("theme-3");
|
|
1409
2175
|
var Theme3LsgButton = theme3Components.LsgButton,
|
|
@@ -1419,6 +2185,16 @@ var Theme3LsgButton = theme3Components.LsgButton,
|
|
|
1419
2185
|
Theme3LsgQuickLinks = theme3Components.LsgQuickLinks,
|
|
1420
2186
|
Theme3LsgSocialMediaIcons = theme3Components.LsgSocialMediaIcons,
|
|
1421
2187
|
Theme3LsgFooter = theme3Components.LsgFooter;
|
|
2188
|
+
// Form components
|
|
2189
|
+
theme3Components.LsgFormContainer;
|
|
2190
|
+
theme3Components.LsgFormFieldText;
|
|
2191
|
+
theme3Components.LsgFormFieldEmail;
|
|
2192
|
+
theme3Components.LsgFormFieldTel;
|
|
2193
|
+
theme3Components.LsgFormFieldTextarea;
|
|
2194
|
+
theme3Components.LsgFormFieldSelect;
|
|
2195
|
+
theme3Components.LsgFormFieldCountry;
|
|
2196
|
+
theme3Components.LsgFormFieldConsent;
|
|
2197
|
+
theme3Components.LsgFormStep;
|
|
1422
2198
|
|
|
1423
|
-
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 };
|
|
1424
2200
|
//# sourceMappingURL=index.esm.js.map
|