@ikas/storefront 4.2.0-beta.7 → 4.2.0-beta.8

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.
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import o from"lodash/sortBy";import"../../../../models/data/blog/category/index.js";import"../../../../models/data/blog/content/index.js";import"../../../../models/data/blog/meta-data/index.js";import"../../../../models/data/blog/tag/index.js";import"../../../../models/data/blog/index.js";import"../../../../models/data/brand/index.js";import"@ikas/storefront-models";import"../../../../models/data/campaign-offer/index.js";import"../../../../models/data/cart/campaign-offer/index.js";import"../../../../models/data/cart/index.js";import"../../../../models/data/category/path-item/index.js";import"../../../../models/data/category/index.js";import"../../../../models/data/checkout/index.js";import"../../../../models/data/checkout/country-settings-model.js";import"../../../../models/data/checkout-settings/index.js";import"../../../../models/data/city/index.js";import"../../../../models/data/country/index.js";import"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/address/ikas-localize-customer-address.js";import"../../../../models/data/customer/attribute/index.js";import"../../../../models/data/customer/review/summary/index.js";import"../../../../models/data/customer/review/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/district/index.js";import"../../../../models/data/favorite-product/index.js";import"../../../../models/data/filter-category/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/image/index.js";import{IkasOrderAddressCity as r}from"../../../../models/data/order/address/city/index.js";import{IkasOrderAddressCountry as n}from"../../../../models/data/order/address/country/index.js";import{IkasOrderAddressDistrict as d}from"../../../../models/data/order/address/district/index.js";import"../../../../models/data/order/address/index.js";import"../../../../models/data/order/line-item/option/value/index.js";import"../../../../models/data/order/line-item/variant/value/index.js";import"../../../../models/data/order/line-item/variant/index.js";import"../../../../models/data/order/line-item/index.js";import"../../../../models/data/order/package/index.js";import"../../../../models/data/order/transaction/index.js";import"../../../../models/data/order/index.js";import"../../../../models/data/payment-gateway/index.js";import"../../../../models/data/product/attribute-value/index.js";import"../../../../models/data/product/filter/index.js";import"../../../../models/data/product/option-set/option/index.js";import"../../../../models/data/product/option-set/index.js";import"../../../../models/data/product/stock-location/index.js";import"../../../../models/data/product/variant/price/index.js";import"../../../../models/data/product/variant/index.js";import"../../../../models/data/variant-type/index.js";import"../../../../models/data/product/index.js";import"../../../../models/data/raffle/index.js";import"../../../../models/data/state/index.js";import"../../../../models/data/theme-json/index.js";import"../../../../models/data/theme-json/custom-data/index.js";import"../../../../models/data/variant-type/variant-value/index.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-list/index.js";import"../../../../models/ui/product-attribute-detail/index.js";import"../../../../models/ui/product-attribute-list/index.js";import"../../../../models/ui/customer-review-list/index.js";import"../../../../models/ui/customer-review-summary-list/index.js";import"../../../../models/ui/validator/index.js";import"../../../../models/ui/validator/rules/index.js";import"../../../../models/ui/validator/form/login.js";import"../../../../models/ui/validator/form/address.js";import"../../../../models/ui/validator/form/ikas-address.js";import"../../../../models/ui/validator/form/register.js";import"../../../../models/ui/validator/form/contact-form.js";import"../../../../models/ui/validator/form/forgot-password.js";import"../../../../models/ui/validator/form/recover-password.js";import"../../../../models/ui/validator/form/account-info.js";import"../../../../models/ui/validator/form/raffle-form.js";import"../../../../models/ui/validator/form/customer-review.js";import"../../../../models/ui/raffle-list/index.js";import{stringSorter as a,capitalize as l}from"../../../../utils/helper.js";import{FREE_TEXT_CITY_COUNTRY_LIST as u,DISTRICT_HIDDEN_COUNTRY_LIST as m}from"../../../../utils/constants.js";import c from"../../../../store/location/index.js";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";var h=function(){function h(i){var o=this;this.isCorporate=!1,this.isErrorsVisible=!1,this.allowedCountryIds=null,this.allowCorporateInfo=!1,this.allowTitleChange=!1,this.firstNameChangeCallback=null,this.lastNameChangeCallback=null,this.countries=[],this.states=[],this.cities=[],this.districts=[],this.myCountryCode=null,this.fillDropdownOptions=function(){return t(o,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.listCountries()];case 1:return t.sent(),[4,this.listStates()];case 2:return t.sent(),[4,this.listCities()];case 3:return t.sent(),[4,this.listDistricts()];case 4:return t.sent(),[2]}}))}))},this.listCountries=function(){return t(o,void 0,void 0,(function(){var t,i,s,o,r,n,d,a,l=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),this.myCountryCode?[3,2]:[4,c.getMyCountry()];case 1:t=e.sent(),this.myCountryCode=t.data,e.label=2;case 2:return[4,c.listCountry({id:(null===(d=this.allowedCountryIds)||void 0===d?void 0:d.length)?{in:this.allowedCountryIds}:void 0,locale:p.getCurrentLocale()})];case 3:return i=e.sent(),s=i.data||[],o=p.getCurrentRouting(),(null===(a=null==o?void 0:o.countryCodes)||void 0===a?void 0:a.length)?s=s.filter((function(t){var e;return t.iso2&&(null===(e=o.countryCodes)||void 0===e?void 0:e.includes(t.iso2))})):(r=p.getRoutings().filter((function(t){return t.id!==p.getStorefrontRoutingId()})),s=s.filter((function(t){return t.iso2&&!r.some((function(e){var i;return null===(i=e.countryCodes)||void 0===i?void 0:i.includes(t.iso2)}))}))),this.countries=s,1!==this.countries.length||this.country?this.countries.length&&this.myCountryCode&&!this.country&&((n=this.countries.find((function(t){return t.iso2===l.myCountryCode})))?this.onCountryChange(n.id):this.onCountryChange(this.countries[0].id)):this.onCountryChange(this.countries[0].id),[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},this.listStates=function(){return t(o,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.country)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.listState({countryId:{eq:this.country.id}})];case 2:return t=e.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.listCities=function(){return t(o,void 0,void 0,(function(){var t,i,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.state)||void 0===i?void 0:i.id)||!(null===(s=this.country)||void 0===s?void 0:s.id))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.listCity({stateId:{eq:this.state.id},countryId:{eq:this.country.id}})];case 2:return t=e.sent(),this.cities=t.data||[],[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.listDistricts=function(){return t(o,void 0,void 0,(function(){var t,i,s,o;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.city)||void 0===i?void 0:i.id)||this.isDistrictHidden)return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.listDistrict({cityId:{eq:this.city.id},stateId:(null===(s=this.state)||void 0===s?void 0:s.id)?{eq:null===(o=this.state)||void 0===o?void 0:o.id}:void 0})];case 2:return t=e.sent(),this.districts=t.data||[],this.districts.length?this.address.isDistrictRequired=!0:this.address.isDistrictRequired=!1,[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.modelToOption=function(t){return{label:t.name,value:t.id+""}},this.onFirstNameChange=function(t){o.firstNameChangeCallback&&o.firstNameChangeCallback(t),o.address.firstName=t},this.onLastNameChange=function(t){o.lastNameChangeCallback&&o.lastNameChangeCallback(t),o.address.lastName=t},this.onPhoneChange=function(t){o.address.phone=t},this.onIdentityNumberChange=function(t){t?t.length<=11&&(o.address.identityNumber=t):o.address.identityNumber=""},this.onAddressTitleChange=function(t){o.address.title=t},this.onAddressLine1Change=function(t){o.address.addressLine1=t},this.onAddressLine2Change=function(t){o.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){o.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=o.country)||void 0===e?void 0:e.id)!==t){var i=o.countries.find((function(e){return e.id===t}));o.address.country=new n({id:(null==i?void 0:i.id)||null,name:(null==i?void 0:i.name)||"",code:(null==i?void 0:i.iso3)||null,iso2:(null==i?void 0:i.iso2)||null,iso3:(null==i?void 0:i.iso3)||null}),o.address.state=null,o.address.city=null,o.address.district=null,o.address.phone=null,o.states=[],o.cities=[],o.districts=[],o.listStates()}},this.onStateChange=function(t){var e;if((null===(e=o.state)||void 0===e?void 0:e.id)!==t){var i=o.states.find((function(e){return e.id===t}));o.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},o.address.city=null,o.address.district=null,o.cities=[],o.districts=[],o.listCities()}},this.onCityChange=function(t){var e;if((null===(e=o.city)||void 0===e?void 0:e.id)!==t){var i=o.cities.find((function(e){return e.id===t}));o.address.city=new r({id:i.id,name:i.name}),o.address.district=null,o.districts=[],o.listDistricts()}},this.onCityInputChange=function(t){o.districts=[],o.address.city=new r({id:void 0,name:t})},this.onDistrictChange=function(t){var e;if((null===(e=o.district)||void 0===e?void 0:e.id)!==t){var i=o.districts.find((function(e){return e.id===t}));o.address.district=new d({id:i.id,name:i.name})}},this.onDistrictInputChange=function(t){o.address.district=new d({id:void 0,name:t})},this.onCorporateChange=function(t){o.isCorporate=t,t||(o.address.company=null,o.address.taxNumber=null,o.address.taxOffice=null)},this.onCompanyChange=function(t){o.address.company=t},this.onTaxNumberChange=function(t){o.address.taxNumber=t},this.onTaxOfficeChange=function(t){o.address.taxOffice=t},this.address=i.address,this.isCorporate=i.isCorporate||!1,this.isErrorsVisible=i.isErrorsVisible||!1,this.isCustomerAddress=i.isCustomerAddress||!1,this.allowedCountryIds=i.allowedCountryIds,this.allowCorporateInfo=i.allowCorporateInfo||!1,this.allowTitleChange=i.allowTitleChange||!1,this.firstNameChangeCallback=i.firstNameChangeCallback||null,this.lastNameChangeCallback=i.lastNameChangeCallback||null,s(this,{firstNameChangeCallback:!1,lastNameChangeCallback:!1}),this.fillDropdownOptions()}return Object.defineProperty(h.prototype,"firstName",{get:function(){return this.address.firstName},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"lastName",{get:function(){return this.address.lastName},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"phone",{get:function(){return this.address.phone},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"identityNumber",{get:function(){return this.address.identityNumber},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"country",{get:function(){return this.address.country},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"state",{get:function(){return this.address.state},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"city",{get:function(){return this.address.city},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"district",{get:function(){return this.address.district},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"countryOptions",{get:function(){var t=this.countries.map(this.modelToOption);return t.sort((function(t,e){return a(t.label,e.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"stateOptions",{get:function(){var t=this.states.map(this.modelToOption);return t.sort((function(t,e){return a(t.label,e.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"cityOptions",{get:function(){return o(this.cities,"order").map(this.modelToOption)},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"districtOptions",{get:function(){var t=this.districts.map((function(t){return i(i({},t),{name:l(t.name)})})).map(this.modelToOption);return t.sort((function(t,e){return a(t.label,e.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isFreeTextCity",{get:function(){var t=this;return u.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isDistrictHidden",{get:function(){var t=this;return m.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),h}();export{h as default};
1
+ import{__awaiter as t,__generator as e,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import r from"lodash/sortBy";import"../../../../models/data/blog/category/index.js";import"../../../../models/data/blog/content/index.js";import"../../../../models/data/blog/meta-data/index.js";import"../../../../models/data/blog/tag/index.js";import"../../../../models/data/blog/index.js";import"../../../../models/data/brand/index.js";import"@ikas/storefront-models";import"../../../../models/data/campaign-offer/index.js";import"../../../../models/data/cart/campaign-offer/index.js";import"../../../../models/data/cart/index.js";import"../../../../models/data/category/path-item/index.js";import"../../../../models/data/category/index.js";import"../../../../models/data/checkout/index.js";import"../../../../models/data/checkout/country-settings-model.js";import"../../../../models/data/checkout-settings/index.js";import"../../../../models/data/city/index.js";import"../../../../models/data/country/index.js";import"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/address/ikas-localize-customer-address.js";import"../../../../models/data/customer/attribute/index.js";import"../../../../models/data/customer/review/summary/index.js";import"../../../../models/data/customer/review/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/district/index.js";import"../../../../models/data/favorite-product/index.js";import"../../../../models/data/filter-category/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/image/index.js";import{IkasOrderAddressCity as o}from"../../../../models/data/order/address/city/index.js";import{IkasOrderAddressCountry as n}from"../../../../models/data/order/address/country/index.js";import{IkasOrderAddressDistrict as d}from"../../../../models/data/order/address/district/index.js";import"../../../../models/data/order/address/index.js";import"../../../../models/data/order/line-item/option/value/index.js";import"../../../../models/data/order/line-item/variant/value/index.js";import"../../../../models/data/order/line-item/variant/index.js";import"../../../../models/data/order/line-item/index.js";import"../../../../models/data/order/package/index.js";import"../../../../models/data/order/transaction/index.js";import"../../../../models/data/order/index.js";import"../../../../models/data/payment-gateway/index.js";import"../../../../models/data/product/attribute-value/index.js";import"../../../../models/data/product/filter/index.js";import"../../../../models/data/product/option-set/option/index.js";import"../../../../models/data/product/option-set/index.js";import"../../../../models/data/product/stock-location/index.js";import"../../../../models/data/product/variant/price/index.js";import"../../../../models/data/product/variant/index.js";import"../../../../models/data/variant-type/index.js";import"../../../../models/data/product/index.js";import"../../../../models/data/raffle/index.js";import"../../../../models/data/state/index.js";import"../../../../models/data/theme-json/index.js";import"../../../../models/data/theme-json/custom-data/index.js";import"../../../../models/data/variant-type/variant-value/index.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-list/index.js";import"../../../../models/ui/product-attribute-detail/index.js";import"../../../../models/ui/product-attribute-list/index.js";import"../../../../models/ui/customer-review-list/index.js";import"../../../../models/ui/customer-review-summary-list/index.js";import"../../../../models/ui/validator/index.js";import"../../../../models/ui/validator/rules/index.js";import"../../../../models/ui/validator/form/login.js";import"../../../../models/ui/validator/form/address.js";import"../../../../models/ui/validator/form/ikas-address.js";import"../../../../models/ui/validator/form/register.js";import"../../../../models/ui/validator/form/contact-form.js";import"../../../../models/ui/validator/form/forgot-password.js";import"../../../../models/ui/validator/form/recover-password.js";import"../../../../models/ui/validator/form/account-info.js";import"../../../../models/ui/validator/form/raffle-form.js";import"../../../../models/ui/validator/form/customer-review.js";import"../../../../models/ui/raffle-list/index.js";import{stringSorter as a,capitalize as l}from"../../../../utils/helper.js";import{FREE_TEXT_CITY_COUNTRY_LIST as u,DISTRICT_HIDDEN_COUNTRY_LIST as m}from"../../../../utils/constants.js";import c from"../../../../store/location/index.js";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";var h=function(){function h(i){var r=this;this.isCorporate=!1,this.isErrorsVisible=!1,this.allowedCountryIds=null,this.allowCorporateInfo=!1,this.allowTitleChange=!1,this.firstNameChangeCallback=null,this.lastNameChangeCallback=null,this.countries=[],this.states=[],this.cities=[],this.districts=[],this.myCountryCode=null,this.fillDropdownOptions=function(){return t(r,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.listCountries()];case 1:return t.sent(),[4,this.listStates()];case 2:return t.sent(),[4,this.listCities()];case 3:return t.sent(),[4,this.listDistricts()];case 4:return t.sent(),[2]}}))}))},this.listCountries=function(){return t(r,void 0,void 0,(function(){var t,i,s,r,o,n,d,a,l=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),this.myCountryCode?[3,2]:[4,c.getMyCountry()];case 1:t=e.sent(),this.myCountryCode=t.data,e.label=2;case 2:return[4,c.listCountry({id:(null===(d=this.allowedCountryIds)||void 0===d?void 0:d.length)?{in:this.allowedCountryIds}:void 0,locale:p.getCurrentLocale()})];case 3:return i=e.sent(),s=i.data||[],r=p.getCurrentRouting(),(null===(a=null==r?void 0:r.countryCodes)||void 0===a?void 0:a.length)?s=s.filter((function(t){var e;return t.iso2&&(null===(e=r.countryCodes)||void 0===e?void 0:e.includes(t.iso2))})):(o=p.getRoutings().filter((function(t){return t.id!==p.getStorefrontRoutingId()})),s=s.filter((function(t){return t.iso2&&!o.some((function(e){var i;return null===(i=e.countryCodes)||void 0===i?void 0:i.includes(t.iso2)}))}))),this.countries=s,1!==this.countries.length||this.country?this.countries.length&&this.myCountryCode&&!this.country&&((n=this.countries.find((function(t){return t.iso2===l.myCountryCode})))?this.onCountryChange(n.id):this.onCountryChange(this.countries[0].id)):this.onCountryChange(this.countries[0].id),[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},this.listStates=function(){return t(r,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.country)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.listState({countryId:{eq:this.country.id}})];case 2:return t=e.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.listCities=function(){return t(r,void 0,void 0,(function(){var t,i,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.state)||void 0===i?void 0:i.id)||!(null===(s=this.country)||void 0===s?void 0:s.id))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.listCity({stateId:{eq:this.state.id},countryId:{eq:this.country.id}})];case 2:return t=e.sent(),this.cities=t.data||[],[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.listDistricts=function(){return t(r,void 0,void 0,(function(){var t,i,s,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.city)||void 0===i?void 0:i.id)||this.isDistrictHidden)return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.listDistrict({cityId:{eq:this.city.id},stateId:(null===(s=this.state)||void 0===s?void 0:s.id)?{eq:null===(r=this.state)||void 0===r?void 0:r.id}:void 0})];case 2:return t=e.sent(),this.districts=t.data||[],this.districts.length?this.address.isDistrictRequired=!0:this.address.isDistrictRequired=!1,[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.modelToOption=function(t){return{label:t.name,value:t.id+""}},this.onFirstNameChange=function(t){r.firstNameChangeCallback&&r.firstNameChangeCallback(t),r.address.firstName=t},this.onLastNameChange=function(t){r.lastNameChangeCallback&&r.lastNameChangeCallback(t),r.address.lastName=t},this.onPhoneChange=function(t){r.address.phone=t},this.onIdentityNumberChange=function(t){t?t.length<=11&&(r.address.identityNumber=t):r.address.identityNumber=""},this.onAddressTitleChange=function(t){r.address.title=t},this.onAddressLine1Change=function(t){r.address.addressLine1=t},this.onAddressLine2Change=function(t){r.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){r.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=r.country)||void 0===e?void 0:e.id)!==t){var i=r.countries.find((function(e){return e.id===t}));r.address.country=new n({id:(null==i?void 0:i.id)||null,name:(null==i?void 0:i.name)||"",code:(null==i?void 0:i.iso3)||null,iso2:(null==i?void 0:i.iso2)||null,iso3:(null==i?void 0:i.iso3)||null}),r.address.state=null,r.address.city=null,r.address.district=null,r.address.phone=null,r.states=[],r.cities=[],r.districts=[],r.listStates()}},this.onStateChange=function(t){var e;if((null===(e=r.state)||void 0===e?void 0:e.id)!==t){var i=r.states.find((function(e){return e.id===t}));r.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},r.address.isFreeTextCity||(r.address.city=null,r.cities=[],r.listCities()),r.address.isFreeTextDistrict||(r.address.district=null,r.districts=[])}},this.onCityChange=function(t){var e;if((null===(e=r.city)||void 0===e?void 0:e.id)!==t){var i=r.cities.find((function(e){return e.id===t}));r.address.city=new o({id:i.id,name:i.name}),r.address.isFreeTextDistrict||(r.address.district=null,r.districts=[],r.listDistricts())}},this.onCityInputChange=function(t){r.districts=[],r.address.city=new o({id:void 0,name:t})},this.onDistrictChange=function(t){var e;if((null===(e=r.district)||void 0===e?void 0:e.id)!==t){var i=r.districts.find((function(e){return e.id===t}));r.address.district=new d({id:i.id,name:i.name})}},this.onDistrictInputChange=function(t){r.address.district=new d({id:void 0,name:t})},this.onCorporateChange=function(t){r.isCorporate=t,t||(r.address.company=null,r.address.taxNumber=null,r.address.taxOffice=null)},this.onCompanyChange=function(t){r.address.company=t},this.onTaxNumberChange=function(t){r.address.taxNumber=t},this.onTaxOfficeChange=function(t){r.address.taxOffice=t},this.address=i.address,this.isCorporate=i.isCorporate||!1,this.isErrorsVisible=i.isErrorsVisible||!1,this.isCustomerAddress=i.isCustomerAddress||!1,this.allowedCountryIds=i.allowedCountryIds,this.allowCorporateInfo=i.allowCorporateInfo||!1,this.allowTitleChange=i.allowTitleChange||!1,this.firstNameChangeCallback=i.firstNameChangeCallback||null,this.lastNameChangeCallback=i.lastNameChangeCallback||null,s(this,{firstNameChangeCallback:!1,lastNameChangeCallback:!1}),this.fillDropdownOptions()}return Object.defineProperty(h.prototype,"firstName",{get:function(){return this.address.firstName},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"lastName",{get:function(){return this.address.lastName},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"phone",{get:function(){return this.address.phone},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"identityNumber",{get:function(){return this.address.identityNumber},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"country",{get:function(){return this.address.country},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"state",{get:function(){return this.address.state},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"city",{get:function(){return this.address.city},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"district",{get:function(){return this.address.district},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"countryOptions",{get:function(){var t=this.countries.map(this.modelToOption);return t.sort((function(t,e){return a(t.label,e.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"stateOptions",{get:function(){var t=this.states.map(this.modelToOption);return t.sort((function(t,e){return a(t.label,e.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"cityOptions",{get:function(){return r(this.cities,"order").map(this.modelToOption)},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"districtOptions",{get:function(){var t=this.districts.map((function(t){return i(i({},t),{name:l(t.name)})})).map(this.modelToOption);return t.sort((function(t,e){return a(t.label,e.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isFreeTextCity",{get:function(){var t=this;return u.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isDistrictHidden",{get:function(){var t=this;return m.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),h}();export{h as default};
@@ -16,15 +16,15 @@ export default class CountrySettingsModel {
16
16
  getFieldSettings(country: string): {
17
17
  firstName: AddressFormField;
18
18
  lastName: AddressFormField;
19
+ identityNumber: AddressFormField;
20
+ phone: AddressFormField;
19
21
  addressLine1: AddressFormField;
20
- identityNumber?: AddressFormField | undefined;
21
- addressLine2?: AddressFormField | undefined;
22
- postalCode?: AddressFormField | undefined;
23
- country?: AddressFormField | undefined;
24
- state?: AddressFormField | undefined;
25
- city?: AddressFormField | undefined;
26
- district?: AddressFormField | undefined;
27
- phone?: AddressFormField | undefined;
22
+ addressLine2: AddressFormField;
23
+ postalCode: AddressFormField;
24
+ country: AddressFormField;
25
+ state: AddressFormField;
26
+ city: AddressFormField;
27
+ district: AddressFormField;
28
28
  company?: AddressFormField | undefined;
29
29
  taxOffice?: AddressFormField | undefined;
30
30
  taxNumber?: AddressFormField | undefined;
@@ -65,8 +65,8 @@ export default class CountrySettingsModel {
65
65
  } | undefined;
66
66
  isValidAddress(address: IkasOrderAddress): boolean;
67
67
  isValidField(field: string, fieldSettings: AddressFormField | undefined, checkoutRequirement?: IkasCheckoutRequirement | null): ErrorType;
68
- isFreeTextCity(country: string): boolean | undefined;
69
- isFreeTextDistrict(country: string): boolean | undefined;
68
+ isFreeTextCity(country: string): boolean;
69
+ isFreeTextDistrict(country: string): boolean;
70
70
  getAddressFormCountrySettings(): Promise<void>;
71
71
  getAddressFormCountryLabels(): Promise<void>;
72
72
  validatePhoneNumber(str: string): boolean;
@@ -1 +1 @@
1
- import{__awaiter as t,__assign as e,__generator as i}from'./../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as n}from"mobx";import{IkasStorefrontConfig as r}from"@ikas/storefront-config";import{IkasCheckoutRequirement as s}from"@ikas/storefront-models";import o from"lodash/difference";import d from"lodash/mapValues";import{COUNTRY_FORMS_LOCALES as a}from"../../../utils/constants.js";var u,l,c=function(){function c(t){void 0===t&&(t={}),this._initialized=!1,this.checkoutSettings=t.checkoutSettings,this.init(),n(this)}return c.prototype.init=function(){return t(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.getAddressFormCountrySettings()];case 1:return t.sent(),[4,this.getAddressFormCountryLabels()];case 2:return t.sent(),this._initialized=!0,[2]}}))}))},Object.defineProperty(c.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),c.prototype.waitUntilInitialized=function(){var t=this;return new Promise((function(e){var i=setInterval((function(){t.initialized&&(clearInterval(i),e(null))}),100)}))},c.prototype.getCountrySettings=function(t){return this._addressFormCountrySettings.countrySettings[t]},c.prototype.getCountryLabels=function(t){return this._addressFormCountryLabels.countryLabels[t]},c.prototype.getFieldSettings=function(t){var i=this.getCountrySettings(t);return e(e({},i.fields),{firstName:{required:!0},lastName:{required:!0},addressLine1:{required:!0}})},c.prototype.getFieldLabels=function(t){var e=this.getCountryLabels(t);if(e)return d(e.fields,(function(t){return null==t?void 0:t.label}))},c.prototype.getAddressFormatView=function(t){return this._addressFormCountrySettings.addressFormats[t]},c.prototype.getBillingFormatView=function(t){return this._addressFormCountrySettings.billingFormats[t]},c.prototype.getAddressFormat=function(t){var e=this.getCountrySettings(t),i=this.getAddressFormatView(e.addressFormat);if(this.checkoutSettings&&i){var n=[];return this.checkoutSettings.identityNumberRequirement===s.INVISIBLE&&n.push(l.IDENTITY_NUMBER),this.checkoutSettings.postalCodeRequirement===s.INVISIBLE&&n.push(l.POSTAL_CODE),this.checkoutSettings.phoneRequirement===s.INVISIBLE&&n.push(l.PHONE),i.map((function(t){return o(t,n)}))||[]}return i},c.prototype.getBillingFormat=function(t){var e=this.getCountrySettings(t);return this.getBillingFormatView(e.billingFormat)},c.prototype.getAddressFormatIgnoreCountry=function(t){return this.getAddressFormat(t).map((function(t){return o(t,[l.COUNTRY])}))},c.prototype.getValidationResult=function(t){var e,i,n,r,o,d,a,u,l=this.getFieldSettings((null===(e=t.country)||void 0===e?void 0:e.iso2)||"TR");if(l){var c=!!t.phone&&t.phone.length>=10&&this.validatePhoneNumber(t.phone);return{firstName:this.isValidField(t.firstName,l.firstName),lastName:this.isValidField(t.lastName,l.lastName),addressLine1:this.isValidField(t.addressLine1,l.addressLine1),addressLine2:this.isValidField(t.addressLine2||"",l.addressLine2),country:this.isValidField((null===(i=t.country)||void 0===i?void 0:i.name)||"",l.country),state:this.isValidField((null===(n=t.state)||void 0===n?void 0:n.name)||"",l.state),city:this.isValidField((null===(r=t.city)||void 0===r?void 0:r.name)||"",l.city),district:this.isValidField((null===(o=t.district)||void 0===o?void 0:o.name)||"",l.district),phone:(null===(d=l.phone)||void 0===d?void 0:d.regex)?this.isValidField(t.phone||"",l.phone,this.checkoutSettings?this.checkoutSettings.phoneRequirement:void 0):(null===(a=this.checkoutSettings)||void 0===a?void 0:a.phoneRequirement)===s.MANDATORY||(null===(u=this.checkoutSettings)||void 0===u?void 0:u.phoneRequirement)===s.OPTIONAL&&t.phone?{hasError:!c,isInvalid:!c,isEmpty:!t.phone}:{hasError:!1,isInvalid:!1,isEmpty:!1},postalCode:this.isValidField(t.postalCode||"",l.postalCode,this.checkoutSettings?this.checkoutSettings.postalCodeRequirement:void 0),identityNumber:this.isValidField(t.identityNumber||"",l.identityNumber,this.checkoutSettings?this.checkoutSettings.identityNumberRequirement:void 0)}}},c.prototype.isValidAddress=function(t){var e=this.getValidationResult(t);return!!e&&Object.values(e).every((function(t){return!t.hasError}))},c.prototype.isValidField=function(t,e,i){var n=!1,r=!1,o=i?i===s.MANDATORY:(null==e?void 0:e.required)||!1,d=!!(null==e?void 0:e.regex)||!1;return o&&!d&&(r=!t),o&&d&&(r=!t,n=!this.validateByRegexString(t,e.regex)),!o&&d&&t&&(n=!this.validateByRegexString(t,e.regex)),{hasError:n||r,isInvalid:n,isEmpty:r}},c.prototype.isFreeTextCity=function(t){var e=this.getFieldSettings(t);return e&&e.city&&e.city.type===u.TEXT},c.prototype.isFreeTextDistrict=function(t){var e=this.getFieldSettings(t);return e&&e.district&&e.district.type===u.TEXT},c.prototype.getAddressFormCountrySettings=function(){return t(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return"https://cdn.myikas.com/sf/static/location/settings.json",[4,fetch("https://cdn.myikas.com/sf/static/location/settings.json")];case 1:return[4,e.sent().json()];case 2:return t=e.sent(),this._addressFormCountrySettings=t,[2]}}))}))},c.prototype.getAddressFormCountryLabels=function(){return t(this,void 0,void 0,(function(){var t,e,n;return i(this,(function(i){switch(i.label){case 0:return t=r.getCurrentLocale(),a.find((function(e){return e===t}))||(t="en"),e="https://cdn.myikas.com/sf/static/location/".concat(t,".json"),[4,fetch(e)];case 1:return[4,i.sent().json()];case 2:return n=i.sent(),this._addressFormCountryLabels=n,[2]}}))}))},c.prototype.validatePhoneNumber=function(t){return/^\+?\d+$/.test(t)},c.prototype.validateByRegexString=function(t,e){return new RegExp(e).test(t)},c}();!function(t){t.TEXT="text",t.DROPDOWN="dropdown"}(u||(u={})),function(t){t.FIRSTNAME="firstName",t.LASTNAME="lastName",t.IDENTITY_NUMBER="identityNumber",t.ADDRESS_LINE_1="addressLine1",t.ADDRESS_LINE_2="addressLine2",t.POSTAL_CODE="postalCode",t.COUNTRY="country",t.STATE="state",t.CITY="city",t.DISTRICT="district",t.PHONE="phone",t.COMPANY="company",t.TAX_OFFICE="taxOffice",t.TAX_NUMBER="taxNumber"}(l||(l={}));export{l as AddressFormItem,u as IkasAddressFormInputType,c as default};
1
+ import{__awaiter as t,__assign as e,__generator as i}from'./../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import{IkasStorefrontConfig as n}from"@ikas/storefront-config";import{IkasCheckoutRequirement as s}from"@ikas/storefront-models";import o from"lodash/difference";import d from"lodash/mapValues";import{COUNTRY_FORMS_LOCALES as u}from"../../../utils/constants.js";var a,l,c=function(){function c(t){void 0===t&&(t={}),this._initialized=!1,this.checkoutSettings=t.checkoutSettings,this.init(),r(this)}return c.prototype.init=function(){return t(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.getAddressFormCountrySettings()];case 1:return t.sent(),[4,this.getAddressFormCountryLabels()];case 2:return t.sent(),this._initialized=!0,[2]}}))}))},Object.defineProperty(c.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),c.prototype.waitUntilInitialized=function(){var t=this;return new Promise((function(e){var i=setInterval((function(){t.initialized&&(clearInterval(i),e(null))}),100)}))},c.prototype.getCountrySettings=function(t){return this._addressFormCountrySettings.countrySettings[t]},c.prototype.getCountryLabels=function(t){return this._addressFormCountryLabels.countryLabels[t]},c.prototype.getFieldSettings=function(t){var i,r,n,o,d,u,a,l,c=this.getCountrySettings(t),h=e(e({},c.fields),{firstName:{required:!0},lastName:{required:!0},identityNumber:e(e({},c.fields.identityNumber),{required:(null===(i=c.fields.identityNumber)||void 0===i?void 0:i.required)||!1}),phone:e(e({},c.fields.phone),{required:(null===(r=c.fields.phone)||void 0===r?void 0:r.required)||!1}),addressLine1:{required:!0},addressLine2:e(e({},c.fields.addressLine2),{required:(null===(n=c.fields.addressLine2)||void 0===n?void 0:n.required)||!1}),postalCode:e(e({},c.fields.postalCode),{required:(null===(o=c.fields.postalCode)||void 0===o?void 0:o.required)||!1}),country:e(e({},c.fields.country),{required:(null===(d=c.fields.country)||void 0===d?void 0:d.required)||!1}),state:e(e({},c.fields.state),{required:(null===(u=c.fields.state)||void 0===u?void 0:u.required)||!1}),city:e(e({},c.fields.city),{required:(null===(a=c.fields.city)||void 0===a?void 0:a.required)||!1}),district:e(e({},c.fields.district),{required:(null===(l=c.fields.district)||void 0===l?void 0:l.required)||!1})});return this.checkoutSettings&&(this.checkoutSettings.phoneRequirement&&(h.phone.required=this.checkoutSettings.phoneRequirement===s.MANDATORY),this.checkoutSettings.postalCodeRequirement&&(h.postalCode.required=this.checkoutSettings.postalCodeRequirement===s.MANDATORY),this.checkoutSettings.identityNumberRequirement&&(h.identityNumber.required=this.checkoutSettings.identityNumberRequirement===s.MANDATORY)),h},c.prototype.getFieldLabels=function(t){var e=this.getCountryLabels(t);if(e)return d(e.fields,(function(t){return null==t?void 0:t.label}))},c.prototype.getAddressFormatView=function(t){return this._addressFormCountrySettings.addressFormats[t]},c.prototype.getBillingFormatView=function(t){return this._addressFormCountrySettings.billingFormats[t]},c.prototype.getAddressFormat=function(t){var e=this.getCountrySettings(t),i=this.getAddressFormatView(e.addressFormat);if(this.checkoutSettings&&i){var r=[];return this.checkoutSettings.identityNumberRequirement===s.INVISIBLE&&r.push(l.IDENTITY_NUMBER),this.checkoutSettings.postalCodeRequirement===s.INVISIBLE&&r.push(l.POSTAL_CODE),this.checkoutSettings.phoneRequirement===s.INVISIBLE&&r.push(l.PHONE),i.map((function(t){return o(t,r)}))||[]}return i},c.prototype.getBillingFormat=function(t){var e=this.getCountrySettings(t);return this.getBillingFormatView(e.billingFormat)},c.prototype.getAddressFormatIgnoreCountry=function(t){return this.getAddressFormat(t).map((function(t){return o(t,[l.COUNTRY])}))},c.prototype.getValidationResult=function(t){var e,i,r,n,o,d,u,a,l=this.getFieldSettings((null===(e=t.country)||void 0===e?void 0:e.iso2)||"TR");if(l){var c=!!t.phone&&t.phone.length>=10&&this.validatePhoneNumber(t.phone);return{firstName:this.isValidField(t.firstName,l.firstName),lastName:this.isValidField(t.lastName,l.lastName),addressLine1:this.isValidField(t.addressLine1,l.addressLine1),addressLine2:this.isValidField(t.addressLine2||"",l.addressLine2),country:this.isValidField((null===(i=t.country)||void 0===i?void 0:i.name)||"",l.country),state:this.isValidField((null===(r=t.state)||void 0===r?void 0:r.name)||"",l.state),city:this.isValidField((null===(n=t.city)||void 0===n?void 0:n.name)||"",l.city),district:this.isValidField((null===(o=t.district)||void 0===o?void 0:o.name)||"",l.district),phone:(null===(d=l.phone)||void 0===d?void 0:d.regex)?this.isValidField(t.phone||"",l.phone,this.checkoutSettings?this.checkoutSettings.phoneRequirement:void 0):(null===(u=this.checkoutSettings)||void 0===u?void 0:u.phoneRequirement)===s.MANDATORY||(null===(a=this.checkoutSettings)||void 0===a?void 0:a.phoneRequirement)===s.OPTIONAL&&t.phone?{hasError:!c,isInvalid:!c,isEmpty:!t.phone}:{hasError:!1,isInvalid:!1,isEmpty:!1},postalCode:this.isValidField(t.postalCode||"",l.postalCode,this.checkoutSettings?this.checkoutSettings.postalCodeRequirement:void 0),identityNumber:this.isValidField(t.identityNumber||"",l.identityNumber,this.checkoutSettings?this.checkoutSettings.identityNumberRequirement:void 0)}}},c.prototype.isValidAddress=function(t){var e=this.getValidationResult(t);return!!e&&Object.values(e).every((function(t){return!t.hasError}))},c.prototype.isValidField=function(t,e,i){var r=!1,n=!1,o=i?i===s.MANDATORY:(null==e?void 0:e.required)||!1,d=!!(null==e?void 0:e.regex)||!1;return o&&!d&&(n=!t),o&&d&&(n=!t,r=!this.validateByRegexString(t,e.regex)),!o&&d&&t&&(r=!this.validateByRegexString(t,e.regex)),{hasError:r||n,isInvalid:r,isEmpty:n}},c.prototype.isFreeTextCity=function(t){var e=this.getFieldSettings(t);return e&&e.city&&e.city.type===a.TEXT},c.prototype.isFreeTextDistrict=function(t){var e=this.getFieldSettings(t);return e&&e.district&&e.district.type===a.TEXT},c.prototype.getAddressFormCountrySettings=function(){return t(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return"https://cdn.myikas.com/sf/static/location/settings.json",[4,fetch("https://cdn.myikas.com/sf/static/location/settings.json")];case 1:return[4,e.sent().json()];case 2:return t=e.sent(),this._addressFormCountrySettings=t,[2]}}))}))},c.prototype.getAddressFormCountryLabels=function(){return t(this,void 0,void 0,(function(){var t,e,r;return i(this,(function(i){switch(i.label){case 0:return t=n.getCurrentLocale(),u.find((function(e){return e===t}))||(t="en"),e="https://cdn.myikas.com/sf/static/location/".concat(t,".json"),[4,fetch(e)];case 1:return[4,i.sent().json()];case 2:return r=i.sent(),this._addressFormCountryLabels=r,[2]}}))}))},c.prototype.validatePhoneNumber=function(t){return/^\+?\d+$/.test(t)},c.prototype.validateByRegexString=function(t,e){return new RegExp(e).test(t)},c}();!function(t){t.TEXT="text",t.DROPDOWN="dropdown"}(a||(a={})),function(t){t.FIRSTNAME="firstName",t.LASTNAME="lastName",t.IDENTITY_NUMBER="identityNumber",t.ADDRESS_LINE_1="addressLine1",t.ADDRESS_LINE_2="addressLine2",t.POSTAL_CODE="postalCode",t.COUNTRY="country",t.STATE="state",t.CITY="city",t.DISTRICT="district",t.PHONE="phone",t.COMPANY="company",t.TAX_OFFICE="taxOffice",t.TAX_NUMBER="taxNumber"}(l||(l={}));export{l as AddressFormItem,a as IkasAddressFormInputType,c as default};
@@ -7,6 +7,22 @@ declare type IkasLocalizeCustomerAddressConstructorData = {
7
7
  export declare class IkasLocalizeCustomerAddress extends IkasCustomerAddress {
8
8
  countrySettings: CountrySettingsModel | null;
9
9
  constructor(data?: Partial<IkasLocalizeCustomerAddressConstructorData>);
10
+ get fieldSettings(): {
11
+ firstName: import("../../checkout/country-settings-model").AddressFormField;
12
+ lastName: import("../../checkout/country-settings-model").AddressFormField;
13
+ identityNumber: import("../../checkout/country-settings-model").AddressFormField;
14
+ phone: import("../../checkout/country-settings-model").AddressFormField;
15
+ addressLine1: import("../../checkout/country-settings-model").AddressFormField;
16
+ addressLine2: import("../../checkout/country-settings-model").AddressFormField;
17
+ postalCode: import("../../checkout/country-settings-model").AddressFormField;
18
+ country: import("../../checkout/country-settings-model").AddressFormField;
19
+ state: import("../../checkout/country-settings-model").AddressFormField;
20
+ city: import("../../checkout/country-settings-model").AddressFormField;
21
+ district: import("../../checkout/country-settings-model").AddressFormField;
22
+ company?: import("../../checkout/country-settings-model").AddressFormField | undefined;
23
+ taxOffice?: import("../../checkout/country-settings-model").AddressFormField | undefined;
24
+ taxNumber?: import("../../checkout/country-settings-model").AddressFormField | undefined;
25
+ } | undefined;
10
26
  get addressFormat(): import("../../checkout/country-settings-model").AddressFormItem[][] | undefined;
11
27
  get addressFormatIgnoreCountry(): import("../../checkout/country-settings-model").AddressFormItem[][] | undefined;
12
28
  get billingFormat(): import("../../checkout/country-settings-model").AddressFormItem[][] | undefined;
@@ -1 +1 @@
1
- import{__extends as t}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as e,observable as r}from"mobx";import{IkasCustomerAddress as n}from"./index.js";var i=function(n){function i(t){void 0===t&&(t={});var i=n.call(this,t)||this;return i.countrySettings=t.countrySettings||null,e(i,{countrySettings:r}),i}return t(i,n),Object.defineProperty(i.prototype,"addressFormat",{get:function(){if(this.countrySettings)return this.countrySettings.getAddressFormat(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"addressFormatIgnoreCountry",{get:function(){if(this.countrySettings)return this.countrySettings.getAddressFormatIgnoreCountry(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"billingFormat",{get:function(){if(this.countrySettings)return this.countrySettings.getBillingFormat(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"countryCode",{get:function(){var t;return(null===(t=this.country)||void 0===t?void 0:t.iso2)||"TR"},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"validationResults",{get:function(){if(this.countrySettings)return this.countrySettings.getValidationResult(this)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isValidAddress",{get:function(){if(this.countrySettings)return this.countrySettings.isValidAddress(this)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"fieldLabels",{get:function(){if(this.countrySettings)return this.countrySettings.getFieldLabels(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isFreeTextCity",{get:function(){if(this.countrySettings)return this.countrySettings.isFreeTextCity(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isFreeTextDistrict",{get:function(){if(this.countrySettings)return this.countrySettings.isFreeTextDistrict(this.countryCode)},enumerable:!1,configurable:!0}),i}(n);export{i as IkasLocalizeCustomerAddress};
1
+ import{__extends as t}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as e,observable as r}from"mobx";import{IkasCustomerAddress as n}from"./index.js";var i=function(n){function i(t){void 0===t&&(t={});var i=n.call(this,t)||this;return i.countrySettings=t.countrySettings||null,e(i,{countrySettings:r}),i}return t(i,n),Object.defineProperty(i.prototype,"fieldSettings",{get:function(){if(this.countrySettings)return this.countrySettings.getFieldSettings(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"addressFormat",{get:function(){if(this.countrySettings)return this.countrySettings.getAddressFormat(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"addressFormatIgnoreCountry",{get:function(){if(this.countrySettings)return this.countrySettings.getAddressFormatIgnoreCountry(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"billingFormat",{get:function(){if(this.countrySettings)return this.countrySettings.getBillingFormat(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"countryCode",{get:function(){var t;return(null===(t=this.country)||void 0===t?void 0:t.iso2)||"TR"},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"validationResults",{get:function(){if(this.countrySettings)return this.countrySettings.getValidationResult(this)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isValidAddress",{get:function(){if(this.countrySettings)return this.countrySettings.isValidAddress(this)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"fieldLabels",{get:function(){if(this.countrySettings)return this.countrySettings.getFieldLabels(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isFreeTextCity",{get:function(){if(this.countrySettings)return this.countrySettings.isFreeTextCity(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isFreeTextDistrict",{get:function(){if(this.countrySettings)return this.countrySettings.isFreeTextDistrict(this.countryCode)},enumerable:!1,configurable:!0}),i}(n);export{i as IkasLocalizeCustomerAddress};
@@ -65,6 +65,22 @@ export declare class IkasAddressForm {
65
65
  get isStatesPending(): boolean;
66
66
  get isCitiesPending(): boolean;
67
67
  get isDistrictsPending(): boolean;
68
+ get fieldSettings(): {
69
+ firstName: import("../../../data").AddressFormField;
70
+ lastName: import("../../../data").AddressFormField;
71
+ identityNumber: import("../../../data").AddressFormField;
72
+ phone: import("../../../data").AddressFormField;
73
+ addressLine1: import("../../../data").AddressFormField;
74
+ addressLine2: import("../../../data").AddressFormField;
75
+ postalCode: import("../../../data").AddressFormField;
76
+ country: import("../../../data").AddressFormField;
77
+ state: import("../../../data").AddressFormField;
78
+ city: import("../../../data").AddressFormField;
79
+ district: import("../../../data").AddressFormField;
80
+ company?: import("../../../data").AddressFormField | undefined;
81
+ taxOffice?: import("../../../data").AddressFormField | undefined;
82
+ taxNumber?: import("../../../data").AddressFormField | undefined;
83
+ } | undefined;
68
84
  get addressFormat(): AddressFormItem[][] | undefined;
69
85
  get validationResult(): {
70
86
  firstName: {
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as e,observable as s,computed as n,action as r}from"mobx";import d from"lodash/cloneDeep";import{listCountry as a,listState as o,listCity as u,listDistrict as c}from"@ikas/storefront-api";import{IkasStorefrontConfig as l}from"@ikas/storefront-config";import{FREE_TEXT_CITY_COUNTRY_LIST as h}from"../../../../utils/constants.js";import{IkasBaseStore as m}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import p,{AddressFormItem as f}from"../../../data/checkout/country-settings-model.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import"../../../data/customer/address/index.js";import{IkasLocalizeCustomerAddress as g}from"../../../data/customer/address/ikas-localize-customer-address.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import v from"lodash/mapValues";var y=function(t){return t.sort((function(t,i){return t.label.localeCompare(i.label)}))},b=function(t){return{label:t.name,value:t.id+""}},j=function(){function j(h){var f=this;this.countries=[],this.states=[],this.cities=[],this.districts=[],this.isLoaded=!1,this._isCountriesPending=!0,this._isStatesPending=!1,this._isCitiesPending=!1,this._isDistrictsPending=!1,this.init=function(){return t(f,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return t.sent(),this.address.countrySettings=this.countrySettings,this.isLoaded=!0,[2]}}))}))},this.onTitleChange=function(t){f.address.title=t},this.onFirstNameChange=function(t){f.address.firstName=t},this.onLastNameChange=function(t){f.address.lastName=t},this.onPhoneChange=function(t){f.address.phone=t},this.onAddressLine1Change=function(t){f.address.addressLine1=t},this.onAddressLine2Change=function(t){f.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){f.address.postalCode=t},this.onCountryChange=function(t){var i;if((null===(i=f.address.country)||void 0===i?void 0:i.id)!==t){var e=f.countries.find((function(i){return i.id===t}));f.address.country={id:(null==e?void 0:e.id)||null,name:(null==e?void 0:e.name)||"",code:(null==e?void 0:e.iso3)||null,iso2:(null==e?void 0:e.iso2)||null,iso3:(null==e?void 0:e.iso3)||null},f.address.state=null,f.address.city=null,f.address.district=null,f.states=[],f.cities=[],f.districts=[],f.listStates()}},this.onStateChange=function(t){var i;if((null===(i=f.address.state)||void 0===i?void 0:i.id)!==t){var e=f.states.find((function(i){return i.id===t}));f.address.state={id:e.id,name:null==e?void 0:e.name,code:null==e?void 0:e.stateCode},f.address.city=null,f.address.district=null,f.cities=[],f.districts=[],f.listCities()}},this.onCityChange=function(t){var i;if((null===(i=f.address.city)||void 0===i?void 0:i.id)!==t){var e=f.cities.find((function(i){return i.id===t}));f.address.city={id:e.id,name:e.name,code:null},f.address.district=null,f.districts=[],f.listDistricts()}},this.onCityInputChange=function(t){f.districts=[],f.address.city={id:null,name:t,code:null}},this.onDistrictChange=function(t){var i;if((null===(i=f.address.district)||void 0===i?void 0:i.id)!==t){var e=f.districts.find((function(i){return i.id===t}));f.address.district={id:e.id,name:e.name,code:null}}},this.onDistrictInputChange=function(t){f.address.district={id:null,name:t,code:null}},this.listCountries=function(){return t(f,void 0,void 0,(function(){var t,e,s,n;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),this._isCountriesPending=!0,[4,a({})];case 1:return t=i.sent(),e=l.getCurrentRouting(),s=t.data||[],(null===(n=null==e?void 0:e.countryCodes)||void 0===n?void 0:n.length)&&(s=s.filter((function(t){var i;return t.iso2&&(null===(i=e.countryCodes)||void 0===i?void 0:i.includes(t.iso2))}))),this.countries=s,1!==this.countries.length||this.address.country||this.onCountryChange(this.countries[0].id),this.countries=s,[3,4];case 2:return i.sent(),[3,4];case 3:return this._isCountriesPending=!1,[7];case 4:return[2]}}))}))},this.listStates=function(){return t(f,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.country)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isStatesPending=!0,[4,o({countryId:{eq:this.address.country.id}})];case 2:return t=i.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,5];case 3:return i.sent(),[3,5];case 4:return this._isStatesPending=!1,[7];case 5:return[2]}}))}))},this.listCities=function(){return t(f,void 0,void 0,(function(){var t,e,s,n;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.state)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isCitiesPending=!0,[4,u({stateId:{eq:this.address.state.id},countryId:(null===(s=this.address.country)||void 0===s?void 0:s.id)?{eq:null===(n=this.address.country)||void 0===n?void 0:n.id}:void 0})];case 2:return t=i.sent(),this.cities=t.data||[],[3,5];case 3:return i.sent(),[3,5];case 4:return this._isCitiesPending=!1,[7];case 5:return[2]}}))}))},this.listDistricts=function(){return t(f,void 0,void 0,(function(){var t,e,s,n;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.city)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isDistrictsPending=!0,[4,c({cityId:{eq:this.address.city.id},stateId:(null===(s=this.address.state)||void 0===s?void 0:s.id)?{eq:null===(n=this.address.state)||void 0===n?void 0:n.id}:void 0})];case 2:return t=i.sent(),this.districts=t.data||[],[3,5];case 3:return i.sent(),[3,5];case 4:return this._isDistrictsPending=!1,[7];case 5:return[2]}}))}))},this.submit=function(){return t(f,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:if(t={isFormError:!1,isSuccess:!1},!this.address.isValidAddress)return t.isFormError=!0,[2,t];if(!(e=d(m.getInstance().customerStore.customer))||!this.address)return[2,t];(null==e?void 0:e.addresses)||(e.addresses=[]),this.isEdit?e.addresses[this.editingAddressIndex]=this.address:e.addresses.push(this.address),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,m.getInstance().customerStore.saveCustomer(e)];case 2:return i.sent()&&(t.isSuccess=!0),[2,t];case 3:return i.sent(),[2,t];case 4:return[2]}}))}))},e(this,{isLoaded:s,isEdit:n,editingAddressIndex:n,isFreeTextCity:n,isFreeTextDistrict:n,countries:s,states:s,cities:s,districts:s,_isCountriesPending:s,_isStatesPending:s,_isCitiesPending:s,_isDistrictsPending:s,isCountriesPending:n,isStatesPending:n,isCitiesPending:n,isDistrictsPending:n,onCountryChange:r,submit:r}),this.address=h.address||new g({addressLine1:"",addressLine2:null,attributes:null,company:null,firstName:"",identityNumber:null,isDefault:null,lastName:"",phone:null,postalCode:null,taxNumber:null,taxOffice:null,title:"",country:null,state:null,city:null,district:null,id:"",createdAt:0,updatedAt:0}),this.message=h.message,this.listCountries(),this.address.state&&this.listStates(),this.address.country&&this.listCities(),this.address.city&&this.listDistricts(),this.countrySettings=new p,this.init()}return Object.defineProperty(j.prototype,"isFreeTextCity",{get:function(){var t=this;return h.some((function(i){var e,s;return(null===(s=null===(e=t.address.country)||void 0===e?void 0:e.iso2)||void 0===s?void 0:s.toLowerCase())===i.toLowerCase()}))},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isFreeTextDistrict",{get:function(){return!this.districtOptions.length},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isEdit",{get:function(){return-1!==this.editingAddressIndex},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"editingAddressIndex",{get:function(){var t,i,e,s=this;return null!==(e=null===(i=null===(t=m.getInstance().customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===i?void 0:i.findIndex((function(t){return t.id===s.address.id})))&&void 0!==e?e:-1},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"countryOptions",{get:function(){var t=this.countries.map(b);return y(t)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"stateOptions",{get:function(){var t=this.states.map(b);return y(t)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"cityOptions",{get:function(){var t=this.cities.map(b);return y(t)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"districtOptions",{get:function(){var t=this.districts.map(b);return y(t)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isCountriesPending",{get:function(){return this._isCountriesPending},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isStatesPending",{get:function(){return this.isCountriesPending||this._isStatesPending},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isCitiesPending",{get:function(){return this.isStatesPending||this._isCitiesPending},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isDistrictsPending",{get:function(){return this.isCitiesPending||this._isDistrictsPending},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"addressFormat",{get:function(){return this.countryOptions.length<=1?this.address.addressFormatIgnoreCountry:this.address.addressFormat},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"validationResult",{get:function(){var t=this;if(this.address.validationResults)return v(this.address.validationResults,(function(i,e){return{hasError:i.hasError,message:i.hasError?e===f.PHONE?t.message.phoneRule:t.message.requiredRule:""}}))},enumerable:!1,configurable:!0}),j}();export{j as IkasAddressForm};
1
+ import{__awaiter as t,__generator as e}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as i,observable as s,computed as n,action as r}from"mobx";import d from"lodash/cloneDeep";import{listCheckoutSettings as a,listCountry as o,listState as u,listCity as c,listDistrict as l}from"@ikas/storefront-api";import{IkasStorefrontConfig as h}from"@ikas/storefront-config";import{FREE_TEXT_CITY_COUNTRY_LIST as m}from"../../../../utils/constants.js";import{IkasBaseStore as p}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import f,{AddressFormItem as g}from"../../../data/checkout/country-settings-model.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import"../../../data/customer/address/index.js";import{IkasLocalizeCustomerAddress as v}from"../../../data/customer/address/ikas-localize-customer-address.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import y from"lodash/mapValues";var b=function(t){return t.sort((function(t,e){return t.label.localeCompare(e.label)}))},j=function(t){return{label:t.name,value:t.id+""}},x=function(){function x(m){var g=this;this.countries=[],this.states=[],this.cities=[],this.districts=[],this.isLoaded=!1,this._isCountriesPending=!0,this._isStatesPending=!1,this._isCitiesPending=!1,this._isDistrictsPending=!1,this.init=function(){return t(g,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,a({})];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)&&(this.countrySettings=new f({checkoutSettings:t.data[0]})),[4,this.countrySettings.waitUntilInitialized()];case 2:return e.sent(),this.address.countrySettings=this.countrySettings,this.isLoaded=!0,[2]}}))}))},this.onTitleChange=function(t){g.address.title=t},this.onFirstNameChange=function(t){g.address.firstName=t},this.onLastNameChange=function(t){g.address.lastName=t},this.onPhoneChange=function(t){g.address.phone=t},this.onAddressLine1Change=function(t){g.address.addressLine1=t},this.onAddressLine2Change=function(t){g.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){g.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=g.address.country)||void 0===e?void 0:e.id)!==t){var i=g.countries.find((function(e){return e.id===t}));g.address.country={id:(null==i?void 0:i.id)||null,name:(null==i?void 0:i.name)||"",code:(null==i?void 0:i.iso3)||null,iso2:(null==i?void 0:i.iso2)||null,iso3:(null==i?void 0:i.iso3)||null},g.address.state=null,g.address.city=null,g.address.district=null,g.states=[],g.cities=[],g.districts=[],g.listStates()}},this.onStateChange=function(t){var e;if((null===(e=g.address.state)||void 0===e?void 0:e.id)!==t){var i=g.states.find((function(e){return e.id===t}));g.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},g.address.isFreeTextCity||(g.address.city=null,g.cities=[],g.listCities()),g.address.isFreeTextDistrict||(g.address.district=null,g.districts=[])}},this.onCityChange=function(t){var e;if((null===(e=g.address.city)||void 0===e?void 0:e.id)!==t){var i=g.cities.find((function(e){return e.id===t}));g.address.city={id:i.id,name:i.name,code:null},g.address.isFreeTextDistrict||(g.address.district=null,g.districts=[],g.listDistricts())}},this.onCityInputChange=function(t){g.districts=[],g.address.city={id:null,name:t,code:null}},this.onDistrictChange=function(t){var e;if((null===(e=g.address.district)||void 0===e?void 0:e.id)!==t){var i=g.districts.find((function(e){return e.id===t}));g.address.district={id:i.id,name:i.name,code:null}}},this.onDistrictInputChange=function(t){g.address.district={id:null,name:t,code:null}},this.listCountries=function(){return t(g,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,3,4]),this._isCountriesPending=!0,[4,o({})];case 1:return t=e.sent(),i=h.getCurrentRouting(),s=t.data||[],(null===(n=null==i?void 0:i.countryCodes)||void 0===n?void 0:n.length)&&(s=s.filter((function(t){var e;return t.iso2&&(null===(e=i.countryCodes)||void 0===e?void 0:e.includes(t.iso2))}))),this.countries=s,1!==this.countries.length||this.address.country||this.onCountryChange(this.countries[0].id),this.countries=s,[3,4];case 2:return e.sent(),[3,4];case 3:return this._isCountriesPending=!1,[7];case 4:return[2]}}))}))},this.listStates=function(){return t(g,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.address.country)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,4,5]),this._isStatesPending=!0,[4,u({countryId:{eq:this.address.country.id}})];case 2:return t=e.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,5];case 3:return e.sent(),[3,5];case 4:return this._isStatesPending=!1,[7];case 5:return[2]}}))}))},this.listCities=function(){return t(g,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.address.state)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,4,5]),this._isCitiesPending=!0,[4,c({stateId:{eq:this.address.state.id},countryId:(null===(s=this.address.country)||void 0===s?void 0:s.id)?{eq:null===(n=this.address.country)||void 0===n?void 0:n.id}:void 0})];case 2:return t=e.sent(),this.cities=t.data||[],[3,5];case 3:return e.sent(),[3,5];case 4:return this._isCitiesPending=!1,[7];case 5:return[2]}}))}))},this.listDistricts=function(){return t(g,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.address.city)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,4,5]),this._isDistrictsPending=!0,[4,l({cityId:{eq:this.address.city.id},stateId:(null===(s=this.address.state)||void 0===s?void 0:s.id)?{eq:null===(n=this.address.state)||void 0===n?void 0:n.id}:void 0})];case 2:return t=e.sent(),this.districts=t.data||[],[3,5];case 3:return e.sent(),[3,5];case 4:return this._isDistrictsPending=!1,[7];case 5:return[2]}}))}))},this.submit=function(){return t(g,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(t={isFormError:!1,isSuccess:!1},!this.address.isValidAddress)return t.isFormError=!0,[2,t];if(!(i=d(p.getInstance().customerStore.customer))||!this.address)return[2,t];(null==i?void 0:i.addresses)||(i.addresses=[]),this.isEdit?i.addresses[this.editingAddressIndex]=this.address:i.addresses.push(this.address),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,p.getInstance().customerStore.saveCustomer(i)];case 2:return e.sent()&&(t.isSuccess=!0),[2,t];case 3:return e.sent(),[2,t];case 4:return[2]}}))}))},i(this,{isLoaded:s,isEdit:n,editingAddressIndex:n,isFreeTextCity:n,isFreeTextDistrict:n,countries:s,states:s,cities:s,districts:s,_isCountriesPending:s,_isStatesPending:s,_isCitiesPending:s,_isDistrictsPending:s,isCountriesPending:n,isStatesPending:n,isCitiesPending:n,isDistrictsPending:n,onCountryChange:r,submit:r}),this.address=m.address||new v({addressLine1:"",addressLine2:null,attributes:null,company:null,firstName:"",identityNumber:null,isDefault:null,lastName:"",phone:null,postalCode:null,taxNumber:null,taxOffice:null,title:"",country:null,state:null,city:null,district:null,id:"",createdAt:0,updatedAt:0}),this.message=m.message,this.listCountries(),this.address.state&&this.listStates(),this.address.country&&this.listCities(),this.address.city&&this.listDistricts(),this.countrySettings=new f,this.init()}return Object.defineProperty(x.prototype,"isFreeTextCity",{get:function(){var t=this;return m.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isFreeTextDistrict",{get:function(){return!this.districtOptions.length},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isEdit",{get:function(){return-1!==this.editingAddressIndex},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"editingAddressIndex",{get:function(){var t,e,i,s=this;return null!==(i=null===(e=null===(t=p.getInstance().customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.findIndex((function(t){return t.id===s.address.id})))&&void 0!==i?i:-1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"countryOptions",{get:function(){var t=this.countries.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stateOptions",{get:function(){var t=this.states.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"cityOptions",{get:function(){var t=this.cities.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"districtOptions",{get:function(){var t=this.districts.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCountriesPending",{get:function(){return this._isCountriesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isStatesPending",{get:function(){return this.isCountriesPending||this._isStatesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCitiesPending",{get:function(){return this.isStatesPending||this._isCitiesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isDistrictsPending",{get:function(){return this.isCitiesPending||this._isDistrictsPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"fieldSettings",{get:function(){return this.address.fieldSettings},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"addressFormat",{get:function(){return this.countryOptions.length<=1?this.address.addressFormatIgnoreCountry:this.address.addressFormat},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"validationResult",{get:function(){var t=this;if(this.address.validationResults)return y(this.address.validationResults,(function(e,i){return{hasError:e.hasError,message:e.hasError?i===g.PHONE?t.message.phoneRule:t.message.requiredRule:""}}))},enumerable:!1,configurable:!0}),x}();export{x as IkasAddressForm};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "4.2.0-beta.7",
3
+ "version": "4.2.0-beta.8",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "dependencies": {},
20
20
  "devDependencies": {
21
- "@ikas/storefront-api": "^4.2.0-beta.7",
22
- "@ikas/storefront-config": "^4.2.0-beta.7",
23
- "@ikas/storefront-model-functions": "^4.2.0-beta.7",
24
- "@ikas/storefront-models": "^4.2.0-beta.7",
25
- "@ikas/storefront-providers": "^4.2.0-beta.7",
21
+ "@ikas/storefront-api": "^4.2.0-beta.8",
22
+ "@ikas/storefront-config": "^4.2.0-beta.8",
23
+ "@ikas/storefront-model-functions": "^4.2.0-beta.8",
24
+ "@ikas/storefront-models": "^4.2.0-beta.8",
25
+ "@ikas/storefront-providers": "^4.2.0-beta.8",
26
26
  "@rollup/plugin-commonjs": "^22.0.0",
27
27
  "@rollup/plugin-json": "^4.1.0",
28
28
  "@rollup/plugin-node-resolve": "^13.3.0",
@@ -52,11 +52,11 @@
52
52
  "libphonenumber-js": "^1.10.6"
53
53
  },
54
54
  "peerDependencies": {
55
- "@ikas/storefront-api": "^4.2.0-beta.7",
56
- "@ikas/storefront-config": "^4.2.0-beta.7",
57
- "@ikas/storefront-model-functions": "^4.2.0-beta.7",
58
- "@ikas/storefront-models": "^4.2.0-beta.7",
59
- "@ikas/storefront-providers": "^4.2.0-beta.7",
55
+ "@ikas/storefront-api": "^4.2.0-beta.8",
56
+ "@ikas/storefront-config": "^4.2.0-beta.8",
57
+ "@ikas/storefront-model-functions": "^4.2.0-beta.8",
58
+ "@ikas/storefront-models": "^4.2.0-beta.8",
59
+ "@ikas/storefront-providers": "^4.2.0-beta.8",
60
60
  "mobx": "^6.1.3",
61
61
  "mobx-react-lite": "^3.1.5",
62
62
  "next": "12.2.0",