Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ikas/localized-address

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ikas/localized-address - npm Package Compare versions

Comparing version 1.0.0-beta.5 to 1.0.0-beta.6

2

build/config.js

@@ -1,1 +0,1 @@

var t=function(){function t(){}return t.getCDNUrl=function(){return this.cdnUrl},t.setCDNUrl=function(t){t&&(this.cdnUrl=t)},t.cdnUrl="https://eu.myikas.com/sf/static/location/settings.json",t}();export{t as LocalizedAddressConfig};
var n=function(){function n(){}return n.getCDNUrl=function(){return this.cdnUrl},n.setCDNUrl=function(n){n&&(this.cdnUrl=n)},n.cdnUrl="https://eu.myikas.com/",n}();export{n as LocalizedAddressConfig};

@@ -1,1 +0,1 @@

import{__awaiter as e,__spreadArray as i,__generator as t}from"../../_virtual/_tslib.js";import{makeAutoObservable as o}from"mobx";import*as r from"lodash";import{LocalizedAddressConfig as d}from"../../config.js";var n,l,s,a=["tr","de","en","it","es","fr","ru"],u=function(){function u(e){this._initialized=!1,this._currentLocale=e.currentLocale,this.init(),o(this)}return u.prototype.init=function(){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this.getAddressFormCountrySettings()];case 1:return e.sent(),[4,this.getAddressFormCountryLabels()];case 2:return e.sent(),this._initialized=!0,[2]}}))}))},Object.defineProperty(u.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),u.prototype.waitUntilInitialized=function(){var e=this;return new Promise((function(i){var t=setInterval((function(){e.initialized&&(clearInterval(t),i(null))}),100)}))},u.prototype.getFieldSettings=function(e){var i,t,o,r,d,n,a,u,v,c,g,m,p,h,y,f,F,b,N,A,L,x,S,C,E,T,O,_,I,R,V,B,q,D,w,M,P,U,Y,j,X,z=e.country,G=e.invisibleAddressFields,H=void 0===G?[]:G,k=e.invisibleBillingFields,W=void 0===k?[]:k,$=e.validateAddressForm,J=void 0===$||$,K=e.validateBillingForm,Q=void 0!==K&&K,Z=e.customAddressFormSettings,ee=void 0===Z?{}:Z,ie=this.getCountrySettings(z);if(ie){var te=ie.fields,oe=this.getAddressFormat(z),re=this.getBillingFormat(z);return{firstName:this.getAddressFormSetting(!0,null===(i=te.firstName)||void 0===i?void 0:i.type,null===(t=te.firstName)||void 0===t?void 0:t.regex,l.FIRSTNAME,oe,H,J,null==ee?void 0:ee.firstName),lastName:this.getAddressFormSetting(!0,null===(o=te.lastName)||void 0===o?void 0:o.type,null===(r=te.lastName)||void 0===r?void 0:r.regex,l.LASTNAME,oe,H,J,null==ee?void 0:ee.lastName),identityNumber:this.getAddressFormSetting(null===(d=te.identityNumber)||void 0===d?void 0:d.required,null===(n=te.identityNumber)||void 0===n?void 0:n.type,null===(a=te.identityNumber)||void 0===a?void 0:a.regex,l.IDENTITY_NUMBER,oe,H,J,null==ee?void 0:ee.identityNumber),addressLine1:this.getAddressFormSetting(!0,null===(u=te.addressLine1)||void 0===u?void 0:u.type,null===(v=te.addressLine1)||void 0===v?void 0:v.regex,l.ADDRESS_LINE_1,oe,H,J,null==ee?void 0:ee.addressLine1),addressLine2:this.getAddressFormSetting(null===(c=te.addressLine2)||void 0===c?void 0:c.required,null===(g=te.addressLine2)||void 0===g?void 0:g.type,null===(m=te.addressLine2)||void 0===m?void 0:m.regex,l.ADDRESS_LINE_2,oe,H,J,null==ee?void 0:ee.addressLine2),postalCode:this.getAddressFormSetting(null===(p=te.postalCode)||void 0===p?void 0:p.required,null===(h=te.postalCode)||void 0===h?void 0:h.type,null===(y=te.postalCode)||void 0===y?void 0:y.regex,l.POSTAL_CODE,oe,H,J,null==ee?void 0:ee.postalCode),country:this.getAddressFormSetting(!0,null===(f=te.country)||void 0===f?void 0:f.type,null===(F=te.country)||void 0===F?void 0:F.regex,l.COUNTRY,oe,H,J,null==ee?void 0:ee.country),state:this.getAddressFormSetting(null===(b=te.state)||void 0===b?void 0:b.required,null===(N=te.state)||void 0===N?void 0:N.type,null===(A=te.state)||void 0===A?void 0:A.regex,l.STATE,oe,H,J,null==ee?void 0:ee.state),city:this.getAddressFormSetting(null===(L=te.city)||void 0===L?void 0:L.required,null===(x=te.city)||void 0===x?void 0:x.type,null===(S=te.city)||void 0===S?void 0:S.regex,l.CITY,oe,H,J,null==ee?void 0:ee.city),district:this.getAddressFormSetting(null===(C=te.district)||void 0===C?void 0:C.required,null===(E=te.district)||void 0===E?void 0:E.type,null===(T=te.district)||void 0===T?void 0:T.regex,l.DISTRICT,oe,H,J,null==ee?void 0:ee.district),region:this.getAddressFormSetting(null===(O=te.region)||void 0===O?void 0:O.required,null===(_=te.region)||void 0===_?void 0:_.type,null===(I=te.region)||void 0===I?void 0:I.regex,l.REGION,oe,H,J,null==ee?void 0:ee.region),phone:this.getAddressFormSetting(null===(R=te.phone)||void 0===R?void 0:R.required,null===(V=te.phone)||void 0===V?void 0:V.type,(null===(B=te.phone)||void 0===B?void 0:B.regex)||/^\+?\d{10,}$/,l.PHONE,oe,H,J,null==ee?void 0:ee.phone),company:this.getBillingFormSetting(null===(q=te.company)||void 0===q?void 0:q.required,null===(D=te.company)||void 0===D?void 0:D.type,null===(w=te.company)||void 0===w?void 0:w.regex,s.COMPANY,re,W,Q,null==ee?void 0:ee.company),taxOffice:this.getBillingFormSetting(null===(M=te.taxOffice)||void 0===M?void 0:M.required,null===(P=te.taxOffice)||void 0===P?void 0:P.type,null===(U=te.taxOffice)||void 0===U?void 0:U.regex,s.TAX_OFFICE,re,W,Q,null==ee?void 0:ee.taxOffice),taxNumber:this.getBillingFormSetting(null===(Y=te.taxNumber)||void 0===Y?void 0:Y.required,null===(j=te.taxNumber)||void 0===j?void 0:j.type,null===(X=te.taxNumber)||void 0===X?void 0:X.regex,s.TAX_NUMBER,re,W,Q,null==ee?void 0:ee.taxNumber)}}},u.prototype.getFieldLabels=function(e){var i,t,o,r,d,n,l,s,a,u,v,c,g,m,p,h,y,f,F,b,N,A,L,x,S,C,E,T,O=this.getCountryLabels(e);if(O){var _=O.fields;return{firstName:this.getAddressFormLabel(null===(i=_.firstName)||void 0===i?void 0:i.label,null===(t=_.firstName)||void 0===t?void 0:t.placeholder),lastName:this.getAddressFormLabel(null===(o=_.lastName)||void 0===o?void 0:o.label,null===(r=_.lastName)||void 0===r?void 0:r.placeholder),identityNumber:this.getAddressFormLabel(null===(d=_.identityNumber)||void 0===d?void 0:d.label,null===(n=_.identityNumber)||void 0===n?void 0:n.placeholder),addressLine1:this.getAddressFormLabel(null===(l=_.addressLine1)||void 0===l?void 0:l.label,null===(s=_.addressLine1)||void 0===s?void 0:s.placeholder),addressLine2:this.getAddressFormLabel(null===(a=_.addressLine2)||void 0===a?void 0:a.label,null===(u=_.addressLine2)||void 0===u?void 0:u.placeholder),postalCode:this.getAddressFormLabel(null===(v=_.postalCode)||void 0===v?void 0:v.label,null===(c=_.postalCode)||void 0===c?void 0:c.placeholder),country:this.getAddressFormLabel(null===(g=_.country)||void 0===g?void 0:g.label,null===(m=_.country)||void 0===m?void 0:m.placeholder),state:this.getAddressFormLabel(null===(p=_.state)||void 0===p?void 0:p.label,null===(h=_.state)||void 0===h?void 0:h.placeholder),city:this.getAddressFormLabel(null===(y=_.city)||void 0===y?void 0:y.label,null===(f=_.city)||void 0===f?void 0:f.placeholder),district:this.getAddressFormLabel(null===(F=_.district)||void 0===F?void 0:F.label,null===(b=_.district)||void 0===b?void 0:b.placeholder),phone:this.getAddressFormLabel(null===(N=_.phone)||void 0===N?void 0:N.label,null===(A=_.phone)||void 0===A?void 0:A.placeholder),company:this.getAddressFormLabel(null===(L=_.company)||void 0===L?void 0:L.label,null===(x=_.company)||void 0===x?void 0:x.placeholder),taxOffice:this.getAddressFormLabel(null===(S=_.taxOffice)||void 0===S?void 0:S.label,null===(C=_.taxOffice)||void 0===C?void 0:C.placeholder),taxNumber:this.getAddressFormLabel(null===(E=_.taxNumber)||void 0===E?void 0:E.label,null===(T=_.taxNumber)||void 0===T?void 0:T.placeholder)}}},u.prototype.getAddressFormat=function(e,i){var t=this.getCountrySettings(e),o=this.getAddressFormatView(t.addressFormat),d=[];return o&&i&&i.length&&o.map((function(e){return r.difference(e,i)})).map((function(e){e.length>0&&d.push(e)})),i&&i.length?d:o},u.prototype.getBillingFormat=function(e,i){var t=this.getCountrySettings(e),o=this.getBillingFormatView(t.billingFormat),d=[];return o&&i&&i.length&&o.map((function(e){return r.difference(e,i)})).map((function(e){e.length>0&&d.push(e)})),i&&i.length?d:o},u.prototype.getAddressFormatIgnoreCountry=function(e,t){return this.getAddressFormat(e,i(i([],t||[],!0),[l.COUNTRY],!1))},u.prototype.getValidationResult=function(e){var i=e.address,t=e.country,o=e.invisibleAddressFields,r=e.invisibleBillingFields,d=e.validateAddressForm,n=e.validateBillingForm,l=e.customAddressFormSettings,s=this.getFieldSettings({country:t,invisibleAddressFields:o,invisibleBillingFields:r,validateAddressForm:d,validateBillingForm:n,customAddressFormSettings:l});if(s)return{firstName:this.isValidField(i.firstName||"",s.firstName),lastName:this.isValidField(i.lastName||"",s.lastName),identityNumber:this.isValidField(i.identityNumber||"",s.identityNumber),addressLine1:this.isValidField(i.addressLine1||"",s.addressLine1),addressLine2:this.isValidField(i.addressLine2||"",s.addressLine2),postalCode:this.isValidField(i.postalCode||"",s.postalCode),country:this.isValidField(i.country||"",s.country),state:this.isValidField(i.state||"",s.state),city:this.isValidField(i.city||"",s.city),district:this.isValidField(i.district||"",s.district),region:this.isValidField(i.region||"",s.region),phone:this.isValidField(i.phone||"",s.phone),company:this.isValidField(i.company||"",s.company),taxOffice:this.isValidField(i.taxOffice||"",s.taxOffice),taxNumber:this.isValidField(i.taxNumber||"",s.taxNumber)}},u.prototype.isValidAddress=function(e){var i=this.getValidationResult(e);return!!i&&Object.values(i).every((function(e){return!e.hasError}))},u.prototype.isValidField=function(e,i){var t=!1,o=!1,r=i.required||!1,d=i.regex||!1;return r&&!d&&(o=!e),r&&d&&(o=!e,t=!this.validateByRegexString(e,i.regex)),!r&&d&&e&&(t=!this.validateByRegexString(e,i.regex)),{hasError:t||o,isInvalid:t,isEmpty:o}},u.prototype.isFreeTextCity=function(e){var i=this.getFieldSettings({country:e});return i&&i.city&&i.city.type===n.TEXT},u.prototype.isFreeTextDistrict=function(e){var i=this.getFieldSettings({country:e});return i&&i.district&&i.district.type===n.TEXT},u.prototype.getCountrySettings=function(e){return this._addressFormCountrySettings.countrySettings[e]},u.prototype.getCountryLabels=function(e){return this._addressFormCountryLabels.countryLabels[e]},u.prototype.getAddressFormatView=function(e){return this._addressFormCountrySettings.addressFormats[e]},u.prototype.getBillingFormatView=function(e){return this._addressFormCountrySettings.billingFormats[e]},u.prototype.getAddressFormCountrySettings=function(){return e(this,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=d.getCDNUrl(),[4,fetch(e)];case 1:return[4,t.sent().json()];case 2:return i=t.sent(),this._addressFormCountrySettings=i,[2]}}))}))},u.prototype.getAddressFormCountryLabels=function(){return e(this,void 0,void 0,(function(){var e,i,o=this;return t(this,(function(t){switch(t.label){case 0:return a.find((function(e){return e===o._currentLocale}))||(this._currentLocale="en"),e="https://eu.myikas.com/sf/static/location/".concat(this._currentLocale,".json"),[4,fetch(e)];case 1:return[4,t.sent().json()];case 2:return i=t.sent(),this._addressFormCountryLabels=i,[2]}}))}))},u.prototype.getAddressFormSetting=function(e,i,t,o,r,d,n,l){var s=(d||[]).some((function(e){return e===o}))||!(r||[]).some((function(e){return e.some((function(e){return e===o}))}));return{required:!!n&&(!s&&(void 0===(null==l?void 0:l.required)?e||!1:null==l?void 0:l.required)),type:void 0===(null==l?void 0:l.type)?i:null==l?void 0:l.type,regex:n?s?void 0:void 0===(null==l?void 0:l.regex)?t:null==l?void 0:l.regex:void 0}},u.prototype.getBillingFormSetting=function(e,i,t,o,r,d,n,l){var s=(d||[]).some((function(e){return e===o}))||!(r||[]).some((function(e){return e.some((function(e){return e===o}))}));return{required:!!n&&(!s&&(void 0===(null==l?void 0:l.required)?e||!1:null==l?void 0:l.required)),type:void 0===(null==l?void 0:l.type)?i:null==l?void 0:l.type,regex:n?s?void 0:void 0===(null==l?void 0:l.regex)?t:null==l?void 0:l.regex:void 0}},u.prototype.getAddressFormLabel=function(e,i){return{label:e,placeholder:i}},u.prototype.validateByRegexString=function(e,i){return new RegExp(i).test(e)},u}();!function(e){e.TEXT="text",e.DROPDOWN="dropdown"}(n||(n={})),function(e){e.FIRSTNAME="firstName",e.LASTNAME="lastName",e.IDENTITY_NUMBER="identityNumber",e.ADDRESS_LINE_1="addressLine1",e.ADDRESS_LINE_2="addressLine2",e.POSTAL_CODE="postalCode",e.COUNTRY="country",e.STATE="state",e.CITY="city",e.DISTRICT="district",e.REGION="region",e.PHONE="phone"}(l||(l={})),function(e){e.COMPANY="company",e.TAX_OFFICE="taxOffice",e.TAX_NUMBER="taxNumber"}(s||(s={}));export{l as AddressFormItem,s as BillingFormItem,a as COUNTRY_FORMS_LOCALES,n as IkasAddressFormInputType,u as LocalizedAddressModel};
import{__awaiter as e,__spreadArray as i,__generator as t}from"../../_virtual/_tslib.js";import{makeAutoObservable as o}from"mobx";import*as r from"lodash";import{LocalizedAddressConfig as d}from"../../config.js";var n,l,s,a=["tr","de","en","it","es","fr","ru"],u=function(){function u(e){this._initialized=!1,this._currentLocale=e.currentLocale,this.init(),o(this)}return u.prototype.init=function(){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this.getAddressFormCountrySettings()];case 1:return e.sent(),[4,this.getAddressFormCountryLabels()];case 2:return e.sent(),this._initialized=!0,[2]}}))}))},Object.defineProperty(u.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),u.prototype.waitUntilInitialized=function(){var e=this;return new Promise((function(i){var t=setInterval((function(){e.initialized&&(clearInterval(t),i(null))}),100)}))},u.prototype.getFieldSettings=function(e){var i,t,o,r,d,n,a,u,v,c,g,m,p,h,y,f,F,b,N,A,L,x,S,C,E,T,O,_,I,R,V,B,q,D,w,M,P,U,Y,j,X,z=e.country,G=e.invisibleAddressFields,H=void 0===G?[]:G,k=e.invisibleBillingFields,W=void 0===k?[]:k,$=e.validateAddressForm,J=void 0===$||$,K=e.validateBillingForm,Q=void 0!==K&&K,Z=e.customAddressFormSettings,ee=void 0===Z?{}:Z,ie=this.getCountrySettings(z);if(ie){var te=ie.fields,oe=this.getAddressFormat(z),re=this.getBillingFormat(z);return{firstName:this.getAddressFormSetting(!0,null===(i=te.firstName)||void 0===i?void 0:i.type,null===(t=te.firstName)||void 0===t?void 0:t.regex,l.FIRSTNAME,oe,H,J,null==ee?void 0:ee.firstName),lastName:this.getAddressFormSetting(!0,null===(o=te.lastName)||void 0===o?void 0:o.type,null===(r=te.lastName)||void 0===r?void 0:r.regex,l.LASTNAME,oe,H,J,null==ee?void 0:ee.lastName),identityNumber:this.getAddressFormSetting(null===(d=te.identityNumber)||void 0===d?void 0:d.required,null===(n=te.identityNumber)||void 0===n?void 0:n.type,null===(a=te.identityNumber)||void 0===a?void 0:a.regex,l.IDENTITY_NUMBER,oe,H,J,null==ee?void 0:ee.identityNumber),addressLine1:this.getAddressFormSetting(!0,null===(u=te.addressLine1)||void 0===u?void 0:u.type,null===(v=te.addressLine1)||void 0===v?void 0:v.regex,l.ADDRESS_LINE_1,oe,H,J,null==ee?void 0:ee.addressLine1),addressLine2:this.getAddressFormSetting(null===(c=te.addressLine2)||void 0===c?void 0:c.required,null===(g=te.addressLine2)||void 0===g?void 0:g.type,null===(m=te.addressLine2)||void 0===m?void 0:m.regex,l.ADDRESS_LINE_2,oe,H,J,null==ee?void 0:ee.addressLine2),postalCode:this.getAddressFormSetting(null===(p=te.postalCode)||void 0===p?void 0:p.required,null===(h=te.postalCode)||void 0===h?void 0:h.type,null===(y=te.postalCode)||void 0===y?void 0:y.regex,l.POSTAL_CODE,oe,H,J,null==ee?void 0:ee.postalCode),country:this.getAddressFormSetting(!0,null===(f=te.country)||void 0===f?void 0:f.type,null===(F=te.country)||void 0===F?void 0:F.regex,l.COUNTRY,oe,H,J,null==ee?void 0:ee.country),state:this.getAddressFormSetting(null===(b=te.state)||void 0===b?void 0:b.required,null===(N=te.state)||void 0===N?void 0:N.type,null===(A=te.state)||void 0===A?void 0:A.regex,l.STATE,oe,H,J,null==ee?void 0:ee.state),city:this.getAddressFormSetting(null===(L=te.city)||void 0===L?void 0:L.required,null===(x=te.city)||void 0===x?void 0:x.type,null===(S=te.city)||void 0===S?void 0:S.regex,l.CITY,oe,H,J,null==ee?void 0:ee.city),district:this.getAddressFormSetting(null===(C=te.district)||void 0===C?void 0:C.required,null===(E=te.district)||void 0===E?void 0:E.type,null===(T=te.district)||void 0===T?void 0:T.regex,l.DISTRICT,oe,H,J,null==ee?void 0:ee.district),region:this.getAddressFormSetting(null===(O=te.region)||void 0===O?void 0:O.required,null===(_=te.region)||void 0===_?void 0:_.type,null===(I=te.region)||void 0===I?void 0:I.regex,l.REGION,oe,H,J,null==ee?void 0:ee.region),phone:this.getAddressFormSetting(null===(R=te.phone)||void 0===R?void 0:R.required,null===(V=te.phone)||void 0===V?void 0:V.type,(null===(B=te.phone)||void 0===B?void 0:B.regex)||/^\+?\d{10,}$/,l.PHONE,oe,H,J,null==ee?void 0:ee.phone),company:this.getBillingFormSetting(null===(q=te.company)||void 0===q?void 0:q.required,null===(D=te.company)||void 0===D?void 0:D.type,null===(w=te.company)||void 0===w?void 0:w.regex,s.COMPANY,re,W,Q,null==ee?void 0:ee.company),taxOffice:this.getBillingFormSetting(null===(M=te.taxOffice)||void 0===M?void 0:M.required,null===(P=te.taxOffice)||void 0===P?void 0:P.type,null===(U=te.taxOffice)||void 0===U?void 0:U.regex,s.TAX_OFFICE,re,W,Q,null==ee?void 0:ee.taxOffice),taxNumber:this.getBillingFormSetting(null===(Y=te.taxNumber)||void 0===Y?void 0:Y.required,null===(j=te.taxNumber)||void 0===j?void 0:j.type,null===(X=te.taxNumber)||void 0===X?void 0:X.regex,s.TAX_NUMBER,re,W,Q,null==ee?void 0:ee.taxNumber)}}},u.prototype.getFieldLabels=function(e){var i,t,o,r,d,n,l,s,a,u,v,c,g,m,p,h,y,f,F,b,N,A,L,x,S,C,E,T,O=this.getCountryLabels(e);if(O){var _=O.fields;return{firstName:this.getAddressFormLabel(null===(i=_.firstName)||void 0===i?void 0:i.label,null===(t=_.firstName)||void 0===t?void 0:t.placeholder),lastName:this.getAddressFormLabel(null===(o=_.lastName)||void 0===o?void 0:o.label,null===(r=_.lastName)||void 0===r?void 0:r.placeholder),identityNumber:this.getAddressFormLabel(null===(d=_.identityNumber)||void 0===d?void 0:d.label,null===(n=_.identityNumber)||void 0===n?void 0:n.placeholder),addressLine1:this.getAddressFormLabel(null===(l=_.addressLine1)||void 0===l?void 0:l.label,null===(s=_.addressLine1)||void 0===s?void 0:s.placeholder),addressLine2:this.getAddressFormLabel(null===(a=_.addressLine2)||void 0===a?void 0:a.label,null===(u=_.addressLine2)||void 0===u?void 0:u.placeholder),postalCode:this.getAddressFormLabel(null===(v=_.postalCode)||void 0===v?void 0:v.label,null===(c=_.postalCode)||void 0===c?void 0:c.placeholder),country:this.getAddressFormLabel(null===(g=_.country)||void 0===g?void 0:g.label,null===(m=_.country)||void 0===m?void 0:m.placeholder),state:this.getAddressFormLabel(null===(p=_.state)||void 0===p?void 0:p.label,null===(h=_.state)||void 0===h?void 0:h.placeholder),city:this.getAddressFormLabel(null===(y=_.city)||void 0===y?void 0:y.label,null===(f=_.city)||void 0===f?void 0:f.placeholder),district:this.getAddressFormLabel(null===(F=_.district)||void 0===F?void 0:F.label,null===(b=_.district)||void 0===b?void 0:b.placeholder),phone:this.getAddressFormLabel(null===(N=_.phone)||void 0===N?void 0:N.label,null===(A=_.phone)||void 0===A?void 0:A.placeholder),company:this.getAddressFormLabel(null===(L=_.company)||void 0===L?void 0:L.label,null===(x=_.company)||void 0===x?void 0:x.placeholder),taxOffice:this.getAddressFormLabel(null===(S=_.taxOffice)||void 0===S?void 0:S.label,null===(C=_.taxOffice)||void 0===C?void 0:C.placeholder),taxNumber:this.getAddressFormLabel(null===(E=_.taxNumber)||void 0===E?void 0:E.label,null===(T=_.taxNumber)||void 0===T?void 0:T.placeholder)}}},u.prototype.getAddressFormat=function(e,i){var t=this.getCountrySettings(e),o=this.getAddressFormatView(t.addressFormat),d=[];return o&&i&&i.length&&o.map((function(e){return r.difference(e,i)})).map((function(e){e.length>0&&d.push(e)})),i&&i.length?d:o},u.prototype.getBillingFormat=function(e,i){var t=this.getCountrySettings(e),o=this.getBillingFormatView(t.billingFormat),d=[];return o&&i&&i.length&&o.map((function(e){return r.difference(e,i)})).map((function(e){e.length>0&&d.push(e)})),i&&i.length?d:o},u.prototype.getAddressFormatIgnoreCountry=function(e,t){return this.getAddressFormat(e,i(i([],t||[],!0),[l.COUNTRY],!1))},u.prototype.getValidationResult=function(e){var i=e.address,t=e.country,o=e.invisibleAddressFields,r=e.invisibleBillingFields,d=e.validateAddressForm,n=e.validateBillingForm,l=e.customAddressFormSettings,s=this.getFieldSettings({country:t,invisibleAddressFields:o,invisibleBillingFields:r,validateAddressForm:d,validateBillingForm:n,customAddressFormSettings:l});if(s)return{firstName:this.isValidField(i.firstName||"",s.firstName),lastName:this.isValidField(i.lastName||"",s.lastName),identityNumber:this.isValidField(i.identityNumber||"",s.identityNumber),addressLine1:this.isValidField(i.addressLine1||"",s.addressLine1),addressLine2:this.isValidField(i.addressLine2||"",s.addressLine2),postalCode:this.isValidField(i.postalCode||"",s.postalCode),country:this.isValidField(i.country||"",s.country),state:this.isValidField(i.state||"",s.state),city:this.isValidField(i.city||"",s.city),district:this.isValidField(i.district||"",s.district),region:this.isValidField(i.region||"",s.region),phone:this.isValidField(i.phone||"",s.phone),company:this.isValidField(i.company||"",s.company),taxOffice:this.isValidField(i.taxOffice||"",s.taxOffice),taxNumber:this.isValidField(i.taxNumber||"",s.taxNumber)}},u.prototype.isValidAddress=function(e){var i=this.getValidationResult(e);return!!i&&Object.values(i).every((function(e){return!e.hasError}))},u.prototype.isValidField=function(e,i){var t=!1,o=!1,r=i.required||!1,d=i.regex||!1;return r&&!d&&(o=!e),r&&d&&(o=!e,t=!this.validateByRegexString(e,i.regex)),!r&&d&&e&&(t=!this.validateByRegexString(e,i.regex)),{hasError:t||o,isInvalid:t,isEmpty:o}},u.prototype.isFreeTextCity=function(e){var i=this.getFieldSettings({country:e});return i&&i.city&&i.city.type===n.TEXT},u.prototype.isFreeTextDistrict=function(e){var i=this.getFieldSettings({country:e});return i&&i.district&&i.district.type===n.TEXT},u.prototype.getCountrySettings=function(e){return this._addressFormCountrySettings.countrySettings[e]},u.prototype.getCountryLabels=function(e){return this._addressFormCountryLabels.countryLabels[e]},u.prototype.getAddressFormatView=function(e){return this._addressFormCountrySettings.addressFormats[e]},u.prototype.getBillingFormatView=function(e){return this._addressFormCountrySettings.billingFormats[e]},u.prototype.getAddressFormCountrySettings=function(){return e(this,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=d.getCDNUrl()+"sf/static/location/settings.json",[4,fetch(e)];case 1:return[4,t.sent().json()];case 2:return i=t.sent(),this._addressFormCountrySettings=i,[2]}}))}))},u.prototype.getAddressFormCountryLabels=function(){return e(this,void 0,void 0,(function(){var e,i,o=this;return t(this,(function(t){switch(t.label){case 0:return a.find((function(e){return e===o._currentLocale}))||(this._currentLocale="en"),e="https://eu.myikas.com/sf/static/location/".concat(this._currentLocale,".json"),[4,fetch(e)];case 1:return[4,t.sent().json()];case 2:return i=t.sent(),this._addressFormCountryLabels=i,[2]}}))}))},u.prototype.getAddressFormSetting=function(e,i,t,o,r,d,n,l){var s=(d||[]).some((function(e){return e===o}))||!(r||[]).some((function(e){return e.some((function(e){return e===o}))}));return{required:!!n&&(!s&&(void 0===(null==l?void 0:l.required)?e||!1:null==l?void 0:l.required)),type:void 0===(null==l?void 0:l.type)?i:null==l?void 0:l.type,regex:n?s?void 0:void 0===(null==l?void 0:l.regex)?t:null==l?void 0:l.regex:void 0}},u.prototype.getBillingFormSetting=function(e,i,t,o,r,d,n,l){var s=(d||[]).some((function(e){return e===o}))||!(r||[]).some((function(e){return e.some((function(e){return e===o}))}));return{required:!!n&&(!s&&(void 0===(null==l?void 0:l.required)?e||!1:null==l?void 0:l.required)),type:void 0===(null==l?void 0:l.type)?i:null==l?void 0:l.type,regex:n?s?void 0:void 0===(null==l?void 0:l.regex)?t:null==l?void 0:l.regex:void 0}},u.prototype.getAddressFormLabel=function(e,i){return{label:e,placeholder:i}},u.prototype.validateByRegexString=function(e,i){return new RegExp(i).test(e)},u}();!function(e){e.TEXT="text",e.DROPDOWN="dropdown"}(n||(n={})),function(e){e.FIRSTNAME="firstName",e.LASTNAME="lastName",e.IDENTITY_NUMBER="identityNumber",e.ADDRESS_LINE_1="addressLine1",e.ADDRESS_LINE_2="addressLine2",e.POSTAL_CODE="postalCode",e.COUNTRY="country",e.STATE="state",e.CITY="city",e.DISTRICT="district",e.REGION="region",e.PHONE="phone"}(l||(l={})),function(e){e.COMPANY="company",e.TAX_OFFICE="taxOffice",e.TAX_NUMBER="taxNumber"}(s||(s={}));export{l as AddressFormItem,s as BillingFormItem,a as COUNTRY_FORMS_LOCALES,n as IkasAddressFormInputType,u as LocalizedAddressModel};
{
"name": "@ikas/localized-address",
"version": "1.0.0-beta.5",
"version": "1.0.0-beta.6",
"author": "ikas",

@@ -5,0 +5,0 @@ "license": "ISC",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc