@ikas/storefront 4.2.0-beta.14 → 4.2.0-beta.15
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,__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
|
|
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{COUNTRY_FORMS_LOCALES as d}from"../../../utils/constants.js";var u,a,l=function(){function l(t){void 0===t&&(t={}),this._initialized=!1,this.checkoutSettings=t.checkoutSettings,this.init(),r(this)}return l.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(l.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),l.prototype.waitUntilInitialized=function(){var t=this;return new Promise((function(e){var i=setInterval((function(){t.initialized&&(clearInterval(i),e(null))}),100)}))},l.prototype.getCountrySettings=function(t){return this._addressFormCountrySettings.countrySettings[t]},l.prototype.getCountryLabels=function(t){return this._addressFormCountryLabels.countryLabels[t]},l.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},l.prototype.getFieldLabels=function(t){var e=this.getCountryLabels(t);if(e)return e.fields},l.prototype.getAddressFormatView=function(t){return this._addressFormCountrySettings.addressFormats[t]},l.prototype.getBillingFormatView=function(t){return this._addressFormCountrySettings.billingFormats[t]},l.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(a.IDENTITY_NUMBER),this.checkoutSettings.postalCodeRequirement===s.INVISIBLE&&r.push(a.POSTAL_CODE),this.checkoutSettings.phoneRequirement===s.INVISIBLE&&r.push(a.PHONE),i.map((function(t){return o(t,r)}))||[]}return i},l.prototype.getBillingFormat=function(t){var e=this.getCountrySettings(t);return this.getBillingFormatView(e.billingFormat)},l.prototype.getAddressFormatIgnoreCountry=function(t){return this.getAddressFormat(t).map((function(t){return o(t,[a.COUNTRY])}))},l.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)}}},l.prototype.isValidAddress=function(t){var e=this.getValidationResult(t);return!!e&&Object.values(e).every((function(t){return!t.hasError}))},l.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}},l.prototype.isFreeTextCity=function(t){var e=this.getFieldSettings(t);return e&&e.city&&e.city.type===u.TEXT},l.prototype.isFreeTextDistrict=function(t){var e=this.getFieldSettings(t);return e&&e.district&&e.district.type===u.TEXT},l.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]}}))}))},l.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(),d.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]}}))}))},l.prototype.validatePhoneNumber=function(t){return/^\+?\d+$/.test(t)},l.prototype.validateByRegexString=function(t,e){return new RegExp(e).test(t)},l}();!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"}(a||(a={}));export{a as AddressFormItem,u as IkasAddressFormInputType,l as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.2.0-beta.
|
|
3
|
+
"version": "4.2.0-beta.15",
|
|
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.
|
|
22
|
-
"@ikas/storefront-config": "^4.2.0-beta.
|
|
23
|
-
"@ikas/storefront-model-functions": "^4.2.0-beta.
|
|
24
|
-
"@ikas/storefront-models": "^4.2.0-beta.
|
|
25
|
-
"@ikas/storefront-providers": "^4.2.0-beta.
|
|
21
|
+
"@ikas/storefront-api": "^4.2.0-beta.15",
|
|
22
|
+
"@ikas/storefront-config": "^4.2.0-beta.15",
|
|
23
|
+
"@ikas/storefront-model-functions": "^4.2.0-beta.15",
|
|
24
|
+
"@ikas/storefront-models": "^4.2.0-beta.15",
|
|
25
|
+
"@ikas/storefront-providers": "^4.2.0-beta.15",
|
|
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.
|
|
56
|
-
"@ikas/storefront-config": "^4.2.0-beta.
|
|
57
|
-
"@ikas/storefront-model-functions": "^4.2.0-beta.
|
|
58
|
-
"@ikas/storefront-models": "^4.2.0-beta.
|
|
59
|
-
"@ikas/storefront-providers": "^4.2.0-beta.
|
|
55
|
+
"@ikas/storefront-api": "^4.2.0-beta.15",
|
|
56
|
+
"@ikas/storefront-config": "^4.2.0-beta.15",
|
|
57
|
+
"@ikas/storefront-model-functions": "^4.2.0-beta.15",
|
|
58
|
+
"@ikas/storefront-models": "^4.2.0-beta.15",
|
|
59
|
+
"@ikas/storefront-providers": "^4.2.0-beta.15",
|
|
60
60
|
"mobx": "^6.1.3",
|
|
61
61
|
"mobx-react-lite": "^3.1.5",
|
|
62
62
|
"next": "12.2.0",
|