@ikas/storefront 4.2.2 → 4.2.4
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.
|
@@ -90,51 +90,51 @@ export declare class IkasAddressForm {
|
|
|
90
90
|
get validationResult(): {
|
|
91
91
|
firstName: {
|
|
92
92
|
hasError: boolean;
|
|
93
|
-
message: string
|
|
93
|
+
message: string;
|
|
94
94
|
};
|
|
95
95
|
lastName: {
|
|
96
96
|
hasError: boolean;
|
|
97
|
-
message: string
|
|
97
|
+
message: string;
|
|
98
98
|
};
|
|
99
99
|
addressLine1: {
|
|
100
100
|
hasError: boolean;
|
|
101
|
-
message: string
|
|
101
|
+
message: string;
|
|
102
102
|
};
|
|
103
103
|
addressLine2: {
|
|
104
104
|
hasError: boolean;
|
|
105
|
-
message: string
|
|
105
|
+
message: string;
|
|
106
106
|
};
|
|
107
107
|
country: {
|
|
108
108
|
hasError: boolean;
|
|
109
|
-
message: string
|
|
109
|
+
message: string;
|
|
110
110
|
};
|
|
111
111
|
state: {
|
|
112
112
|
hasError: boolean;
|
|
113
|
-
message: string
|
|
113
|
+
message: string;
|
|
114
114
|
};
|
|
115
115
|
city: {
|
|
116
116
|
hasError: boolean;
|
|
117
|
-
message: string
|
|
117
|
+
message: string;
|
|
118
118
|
};
|
|
119
119
|
district: {
|
|
120
120
|
hasError: boolean;
|
|
121
|
-
message: string
|
|
121
|
+
message: string;
|
|
122
122
|
};
|
|
123
123
|
phone: {
|
|
124
124
|
hasError: boolean;
|
|
125
|
-
message: string
|
|
125
|
+
message: string;
|
|
126
126
|
};
|
|
127
127
|
postalCode: {
|
|
128
128
|
hasError: boolean;
|
|
129
|
-
message: string
|
|
129
|
+
message: string;
|
|
130
130
|
};
|
|
131
131
|
identityNumber: {
|
|
132
132
|
hasError: boolean;
|
|
133
|
-
message: string
|
|
133
|
+
message: string;
|
|
134
134
|
};
|
|
135
135
|
title: {
|
|
136
136
|
hasError: boolean;
|
|
137
|
-
message: string
|
|
137
|
+
message: string;
|
|
138
138
|
};
|
|
139
139
|
} | undefined;
|
|
140
140
|
submit: () => Promise<{
|
|
@@ -1 +1 @@
|
|
|
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{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{IkasLocalizedCustomerAddress as g}from"../../../data/customer/address/ikas-localized-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";import v from"../../../../store/location/index.js";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(f){var y=this;this.countries=[],this.states=[],this.cities=[],this.districts=[],this.isLoaded=!1,this.isFormSubmit=!1,this._isCountriesPending=!0,this._isStatesPending=!1,this._isCitiesPending=!1,this._isDistrictsPending=!1,this.init=function(){return t(y,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 p({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){y.address.title=t},this.onFirstNameChange=function(t){y.address.firstName=t},this.onLastNameChange=function(t){y.address.lastName=t},this.onIdentityNumberChange=function(t){y.address.identityNumber=t},this.onPhoneChange=function(t){y.address.phone=t},this.onAddressLine1Change=function(t){y.address.addressLine1=t},this.onAddressLine2Change=function(t){y.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){y.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=y.address.country)||void 0===e?void 0:e.id)!==t){var i=y.countries.find((function(e){return e.id===t}));y.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},y.address.state=null,y.address.city=null,y.address.district=null,y.states=[],y.cities=[],y.districts=[],y.listStates()}},this.onStateChange=function(t){var e;if((null===(e=y.address.state)||void 0===e?void 0:e.id)!==t){var i=y.states.find((function(e){return e.id===t}));y.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},y.address.isFreeTextCity||(y.address.city=null,y.cities=[],y.listCities()),y.address.isFreeTextDistrict||(y.address.district=null,y.districts=[])}},this.onCityChange=function(t){var e;if((null===(e=y.address.city)||void 0===e?void 0:e.id)!==t){var i=y.cities.find((function(e){return e.id===t}));y.address.city={id:i.id,name:i.name,code:null},y.address.isFreeTextDistrict||(y.address.district=null,y.districts=[],y.listDistricts())}},this.onCityInputChange=function(t){y.districts=[],y.address.city={id:null,name:t,code:null}},this.onDistrictChange=function(t){var e;if((null===(e=y.address.district)||void 0===e?void 0:e.id)!==t){var i=y.districts.find((function(e){return e.id===t}));y.address.district={id:i.id,name:i.name,code:null}}},this.onDistrictInputChange=function(t){y.address.district={id:null,name:t,code:null}},this.listCountries=function(){return t(y,void 0,void 0,(function(){var t,i,s,n,r,d,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,6,7]),this._isCountriesPending=!0,[4,o({})];case 1:return t=e.sent(),i=h.getCurrentRouting(),s=t.data||[],(null===(a=null==i?void 0:i.countryCodes)||void 0===a?void 0:a.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?[3,2]:(this.onCountryChange(this.countries[0].id),[3,4]);case 2:return!this.countries.length||this.address.country?[3,4]:[4,v.getMyCountry()];case 3:n=e.sent(),r=n.data,(d=this.countries.find((function(t){return t.iso2===r})))?this.onCountryChange(d.id):this.onCountryChange(this.countries[0].id),e.label=4;case 4:return this.countries=s,[3,7];case 5:return e.sent(),[3,7];case 6:return this._isCountriesPending=!1,[7];case 7:return[2]}}))}))},this.listStates=function(){return t(y,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(y,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(y,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(y,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.isFormSubmit=!0,!this.address.isValidAddress)return t.isFormError=!0,[2,t];if(!(i=d(m.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,m.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=f.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=f.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(x.prototype,"isFreeTextCity",{get:function(){return this.address.isFreeTextCity},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isFreeTextDistrict",{get:function(){return this.address.isFreeTextDistrict},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=m.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,"fieldLabels",{get:function(){return this.address.fieldLabels},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:t.isFormSubmit&&e.hasError,message:t.isFormSubmit&&e.hasError?i===f.PHONE?t.message.phoneRule:e.isInvalid?t.message.invalidRule:t.message.requiredRule:""}}))},enumerable:!1,configurable:!0}),x}();export{x 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{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{IkasLocalizedCustomerAddress as g}from"../../../data/customer/address/ikas-localized-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";import v from"../../../../store/location/index.js";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(f){var y=this;this.countries=[],this.states=[],this.cities=[],this.districts=[],this.isLoaded=!1,this.isFormSubmit=!1,this._isCountriesPending=!0,this._isStatesPending=!1,this._isCitiesPending=!1,this._isDistrictsPending=!1,this.init=function(){return t(y,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 p({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){y.address.title=t},this.onFirstNameChange=function(t){y.address.firstName=t},this.onLastNameChange=function(t){y.address.lastName=t},this.onIdentityNumberChange=function(t){y.address.identityNumber=t},this.onPhoneChange=function(t){y.address.phone=t},this.onAddressLine1Change=function(t){y.address.addressLine1=t},this.onAddressLine2Change=function(t){y.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){y.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=y.address.country)||void 0===e?void 0:e.id)!==t){var i=y.countries.find((function(e){return e.id===t}));y.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},y.address.state=null,y.address.city=null,y.address.district=null,y.states=[],y.cities=[],y.districts=[],y.listStates()}},this.onStateChange=function(t){var e;if((null===(e=y.address.state)||void 0===e?void 0:e.id)!==t){var i=y.states.find((function(e){return e.id===t}));y.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},y.address.isFreeTextCity||(y.address.city=null,y.cities=[],y.listCities()),y.address.isFreeTextDistrict||(y.address.district=null,y.districts=[])}},this.onCityChange=function(t){var e;if((null===(e=y.address.city)||void 0===e?void 0:e.id)!==t){var i=y.cities.find((function(e){return e.id===t}));y.address.city={id:i.id,name:i.name,code:null},y.address.isFreeTextDistrict||(y.address.district=null,y.districts=[],y.listDistricts())}},this.onCityInputChange=function(t){y.districts=[],y.address.city={id:null,name:t,code:null}},this.onDistrictChange=function(t){var e;if((null===(e=y.address.district)||void 0===e?void 0:e.id)!==t){var i=y.districts.find((function(e){return e.id===t}));y.address.district={id:i.id,name:i.name,code:null}}},this.onDistrictInputChange=function(t){y.address.district={id:null,name:t,code:null}},this.listCountries=function(){return t(y,void 0,void 0,(function(){var t,i,s,n,r,d,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,6,7]),this._isCountriesPending=!0,[4,o({})];case 1:return t=e.sent(),i=h.getCurrentRouting(),s=t.data||[],(null===(a=null==i?void 0:i.countryCodes)||void 0===a?void 0:a.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?[3,2]:(this.onCountryChange(this.countries[0].id),[3,4]);case 2:return!this.countries.length||this.address.country?[3,4]:[4,v.getMyCountry()];case 3:n=e.sent(),r=n.data,(d=this.countries.find((function(t){return t.iso2===r})))?this.onCountryChange(d.id):this.onCountryChange(this.countries[0].id),e.label=4;case 4:return this.countries=s,[3,7];case 5:return e.sent(),[3,7];case 6:return this._isCountriesPending=!1,[7];case 7:return[2]}}))}))},this.listStates=function(){return t(y,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(y,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(y,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(y,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.isFormSubmit=!0,!this.address.isValidAddress)return t.isFormError=!0,[2,t];if(!(i=d(m.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,m.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=f.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=f.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(x.prototype,"isFreeTextCity",{get:function(){return this.address.isFreeTextCity},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isFreeTextDistrict",{get:function(){return this.address.isFreeTextDistrict},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=m.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,"fieldLabels",{get:function(){return this.address.fieldLabels},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:t.isFormSubmit&&e.hasError,message:t.isFormSubmit&&e.hasError?i===f.PHONE?t.message.phoneRule?"string"==typeof t.message.phoneRule?t.message.phoneRule:t.message.phoneRule(t.address):"":e.isInvalid?"string"==typeof t.message.invalidRule?t.message.invalidRule:t.message.invalidRule(t.address):"string"==typeof t.message.requiredRule?t.message.requiredRule:t.message.requiredRule(t.address):""}}))},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.
|
|
3
|
+
"version": "4.2.4",
|
|
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.
|
|
22
|
-
"@ikas/storefront-config": "^4.2.
|
|
23
|
-
"@ikas/storefront-model-functions": "^4.2.
|
|
24
|
-
"@ikas/storefront-models": "^4.2.
|
|
25
|
-
"@ikas/storefront-providers": "^4.2.
|
|
21
|
+
"@ikas/storefront-api": "^4.2.4",
|
|
22
|
+
"@ikas/storefront-config": "^4.2.4",
|
|
23
|
+
"@ikas/storefront-model-functions": "^4.2.4",
|
|
24
|
+
"@ikas/storefront-models": "^4.2.4",
|
|
25
|
+
"@ikas/storefront-providers": "^4.2.4",
|
|
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.
|
|
56
|
-
"@ikas/storefront-config": "^4.2.
|
|
57
|
-
"@ikas/storefront-model-functions": "^4.2.
|
|
58
|
-
"@ikas/storefront-models": "^4.2.
|
|
59
|
-
"@ikas/storefront-providers": "^4.2.
|
|
55
|
+
"@ikas/storefront-api": "^4.2.4",
|
|
56
|
+
"@ikas/storefront-config": "^4.2.4",
|
|
57
|
+
"@ikas/storefront-model-functions": "^4.2.4",
|
|
58
|
+
"@ikas/storefront-models": "^4.2.4",
|
|
59
|
+
"@ikas/storefront-providers": "^4.2.4",
|
|
60
60
|
"mobx": "^6.1.3",
|
|
61
61
|
"mobx-react-lite": "^3.1.5",
|
|
62
62
|
"next": "12.2.0",
|